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 // if parent was disabled, then do not try and create the children..
251 if(!this[cntr](true)){
256 cn = Roo.factory(tree);
258 cn.parentType = this.xtype; //??
259 cn.parentId = this.id;
261 var build_from_html = Roo.XComponent.build_from_html;
264 // does the container contain child eleemnts with 'xtype' attributes.
265 // that match this xtype..
266 // note - when we render we create these as well..
267 // so we should check to see if body has xtype set.
268 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
270 var self_cntr_el = Roo.get(this[cntr](false));
271 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
273 //Roo.log(Roo.XComponent.build_from_html);
274 //Roo.log("got echild:");
277 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
278 // and are not displayed -this causes this to use up the wrong element when matching.
279 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
282 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
283 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
289 //echild.dom.removeAttribute('xtype');
291 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
292 Roo.debug && Roo.log(self_cntr_el);
293 Roo.debug && Roo.log(echild);
294 Roo.debug && Roo.log(cn);
300 // if object has flexy:if - then it may or may not be rendered.
301 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
302 // skip a flexy if element.
303 Roo.debug && Roo.log('skipping render');
304 Roo.debug && Roo.log(tree);
306 Roo.debug && Roo.log('skipping all children');
307 skip_children = true;
312 // actually if flexy:foreach is found, we really want to create
313 // multiple copies here...
315 //Roo.log(this[cntr]());
316 // some elements do not have render methods.. like the layouts...
318 if(this[cntr](true) === false){
323 cn.render && cn.render(this[cntr](true));
326 // then add the element..
333 if (typeof (tree.menu) != 'undefined') {
334 tree.menu.parentType = cn.xtype;
335 tree.menu.triggerEl = cn.el;
336 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
340 if (!tree.items || !tree.items.length) {
342 //Roo.log(["no children", this]);
347 var items = tree.items;
350 //Roo.log(items.length);
352 if (!skip_children) {
353 for(var i =0;i < items.length;i++) {
354 // Roo.log(['add child', items[i]]);
355 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
361 //Roo.log("fire childrenrendered");
363 cn.fireEvent('childrenrendered', this);
368 * Show a component - removes 'hidden' class
373 this.el.removeClass('hidden');
377 * Hide a component - adds 'hidden' class
381 if (this.el && !this.el.hasClass('hidden')) {
382 this.el.addClass('hidden');
395 * @class Roo.bootstrap.Body
396 * @extends Roo.bootstrap.Component
397 * Bootstrap Body class
401 * @param {Object} config The config object
404 Roo.bootstrap.Body = function(config){
406 config = config || {};
408 Roo.bootstrap.Body.superclass.constructor.call(this, config);
409 this.el = Roo.get(config.el ? config.el : document.body );
410 if (this.cls && this.cls.length) {
411 Roo.get(document.body).addClass(this.cls);
415 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
417 is_body : true,// just to make sure it's constructed?
422 onRender : function(ct, position)
424 /* Roo.log("Roo.bootstrap.Body - onRender");
425 if (this.cls && this.cls.length) {
426 Roo.get(document.body).addClass(this.cls);
445 * @class Roo.bootstrap.ButtonGroup
446 * @extends Roo.bootstrap.Component
447 * Bootstrap ButtonGroup class
448 * @cfg {String} size lg | sm | xs (default empty normal)
449 * @cfg {String} align vertical | justified (default none)
450 * @cfg {String} direction up | down (default down)
451 * @cfg {Boolean} toolbar false | true
452 * @cfg {Boolean} btn true | false
457 * @param {Object} config The config object
460 Roo.bootstrap.ButtonGroup = function(config){
461 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
464 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
472 getAutoCreate : function(){
478 cfg.html = this.html || cfg.html;
489 if (['vertical','justified'].indexOf(this.align)!==-1) {
490 cfg.cls = 'btn-group-' + this.align;
492 if (this.align == 'justified') {
493 console.log(this.items);
497 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
498 cfg.cls += ' btn-group-' + this.size;
501 if (this.direction == 'up') {
502 cfg.cls += ' dropup' ;
518 * @class Roo.bootstrap.Button
519 * @extends Roo.bootstrap.Component
520 * Bootstrap Button class
521 * @cfg {String} html The button content
522 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
523 * @cfg {String} size ( lg | sm | xs)
524 * @cfg {String} tag ( a | input | submit)
525 * @cfg {String} href empty or href
526 * @cfg {Boolean} disabled default false;
527 * @cfg {Boolean} isClose default false;
528 * @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)
529 * @cfg {String} badge text for badge
530 * @cfg {String} theme default
531 * @cfg {Boolean} inverse
532 * @cfg {Boolean} toggle
533 * @cfg {String} ontext text for on toggle state
534 * @cfg {String} offtext text for off toggle state
535 * @cfg {Boolean} defaulton
536 * @cfg {Boolean} preventDefault default true
537 * @cfg {Boolean} removeClass remove the standard class..
538 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
541 * Create a new button
542 * @param {Object} config The config object
546 Roo.bootstrap.Button = function(config){
547 Roo.bootstrap.Button.superclass.constructor.call(this, config);
548 this.weightClass = ["btn-default",
560 * When a butotn is pressed
561 * @param {Roo.bootstrap.Button} this
562 * @param {Roo.EventObject} e
567 * After the button has been toggles
568 * @param {Roo.EventObject} e
569 * @param {boolean} pressed (also available as button.pressed)
575 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
593 preventDefault: true,
602 getAutoCreate : function(){
610 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
611 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
616 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
618 if (this.toggle == true) {
621 cls: 'slider-frame roo-button',
626 'data-off-text':'OFF',
627 cls: 'slider-button',
633 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
634 cfg.cls += ' '+this.weight;
643 cfg["aria-hidden"] = true;
645 cfg.html = "×";
651 if (this.theme==='default') {
652 cfg.cls = 'btn roo-button';
654 //if (this.parentType != 'Navbar') {
655 this.weight = this.weight.length ? this.weight : 'default';
657 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
659 cfg.cls += ' btn-' + this.weight;
661 } else if (this.theme==='glow') {
664 cfg.cls = 'btn-glow roo-button';
666 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
668 cfg.cls += ' ' + this.weight;
674 this.cls += ' inverse';
679 cfg.cls += ' active';
683 cfg.disabled = 'disabled';
687 Roo.log('changing to ul' );
689 this.glyphicon = 'caret';
692 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
694 //gsRoo.log(this.parentType);
695 if (this.parentType === 'Navbar' && !this.parent().bar) {
696 Roo.log('changing to li?');
705 href : this.href || '#'
708 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
709 cfg.cls += ' dropdown';
716 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
718 if (this.glyphicon) {
719 cfg.html = ' ' + cfg.html;
724 cls: 'glyphicon glyphicon-' + this.glyphicon
734 // cfg.cls='btn roo-button';
738 var value = cfg.html;
743 cls: 'glyphicon glyphicon-' + this.glyphicon,
762 cfg.cls += ' dropdown';
763 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
766 if (cfg.tag !== 'a' && this.href !== '') {
767 throw "Tag must be a to set href.";
768 } else if (this.href.length > 0) {
769 cfg.href = this.href;
772 if(this.removeClass){
777 cfg.target = this.target;
782 initEvents: function() {
783 // Roo.log('init events?');
784 // Roo.log(this.el.dom);
787 if (typeof (this.menu) != 'undefined') {
788 this.menu.parentType = this.xtype;
789 this.menu.triggerEl = this.el;
790 this.addxtype(Roo.apply({}, this.menu));
794 if (this.el.hasClass('roo-button')) {
795 this.el.on('click', this.onClick, this);
797 this.el.select('.roo-button').on('click', this.onClick, this);
800 if(this.removeClass){
801 this.el.on('click', this.onClick, this);
804 this.el.enableDisplayMode();
807 onClick : function(e)
814 Roo.log('button on click ');
815 if(this.preventDefault){
818 if (this.pressed === true || this.pressed === false) {
819 this.pressed = !this.pressed;
820 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
821 this.fireEvent('toggle', this, e, this.pressed);
825 this.fireEvent('click', this, e);
829 * Enables this button
833 this.disabled = false;
834 this.el.removeClass('disabled');
838 * Disable this button
842 this.disabled = true;
843 this.el.addClass('disabled');
846 * sets the active state on/off,
847 * @param {Boolean} state (optional) Force a particular state
849 setActive : function(v) {
851 this.el[v ? 'addClass' : 'removeClass']('active');
854 * toggles the current active state
856 toggleActive : function()
858 var active = this.el.hasClass('active');
859 this.setActive(!active);
863 setText : function(str)
865 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
869 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
880 setWeight : function(str)
882 this.el.removeClass(this.weightClass);
883 this.el.addClass('btn-' + str);
897 * @class Roo.bootstrap.Column
898 * @extends Roo.bootstrap.Component
899 * Bootstrap Column class
900 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
901 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
902 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
903 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
904 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
905 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
906 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
907 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
910 * @cfg {Boolean} hidden (true|false) hide the element
911 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
912 * @cfg {String} fa (ban|check|...) font awesome icon
913 * @cfg {Number} fasize (1|2|....) font awsome size
915 * @cfg {String} icon (info-sign|check|...) glyphicon name
917 * @cfg {String} html content of column.
920 * Create a new Column
921 * @param {Object} config The config object
924 Roo.bootstrap.Column = function(config){
925 Roo.bootstrap.Column.superclass.constructor.call(this, config);
928 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
946 getAutoCreate : function(){
947 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
955 ['xs','sm','md','lg'].map(function(size){
956 //Roo.log( size + ':' + settings[size]);
958 if (settings[size+'off'] !== false) {
959 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
962 if (settings[size] === false) {
966 if (!settings[size]) { // 0 = hidden
967 cfg.cls += ' hidden-' + size;
970 cfg.cls += ' col-' + size + '-' + settings[size];
975 cfg.cls += ' hidden';
978 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
979 cfg.cls +=' alert alert-' + this.alert;
983 if (this.html.length) {
984 cfg.html = this.html;
988 if (this.fasize > 1) {
989 fasize = ' fa-' + this.fasize + 'x';
991 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
996 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1015 * @class Roo.bootstrap.Container
1016 * @extends Roo.bootstrap.Component
1017 * Bootstrap Container class
1018 * @cfg {Boolean} jumbotron is it a jumbotron element
1019 * @cfg {String} html content of element
1020 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1021 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1022 * @cfg {String} header content of header (for panel)
1023 * @cfg {String} footer content of footer (for panel)
1024 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1025 * @cfg {String} tag (header|aside|section) type of HTML tag.
1026 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1027 * @cfg {String} fa font awesome icon
1028 * @cfg {String} icon (info-sign|check|...) glyphicon name
1029 * @cfg {Boolean} hidden (true|false) hide the element
1030 * @cfg {Boolean} expandable (true|false) default false
1031 * @cfg {Boolean} expanded (true|false) default true
1032 * @cfg {String} rheader contet on the right of header
1033 * @cfg {Boolean} clickable (true|false) default false
1037 * Create a new Container
1038 * @param {Object} config The config object
1041 Roo.bootstrap.Container = function(config){
1042 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1048 * After the panel has been expand
1050 * @param {Roo.bootstrap.Container} this
1055 * After the panel has been collapsed
1057 * @param {Roo.bootstrap.Container} this
1062 * When a element is chick
1063 * @param {Roo.bootstrap.Container} this
1064 * @param {Roo.EventObject} e
1070 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1088 getChildContainer : function() {
1094 if (this.panel.length) {
1095 return this.el.select('.panel-body',true).first();
1102 getAutoCreate : function(){
1105 tag : this.tag || 'div',
1109 if (this.jumbotron) {
1110 cfg.cls = 'jumbotron';
1115 // - this is applied by the parent..
1117 // cfg.cls = this.cls + '';
1120 if (this.sticky.length) {
1122 var bd = Roo.get(document.body);
1123 if (!bd.hasClass('bootstrap-sticky')) {
1124 bd.addClass('bootstrap-sticky');
1125 Roo.select('html',true).setStyle('height', '100%');
1128 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1132 if (this.well.length) {
1133 switch (this.well) {
1136 cfg.cls +=' well well-' +this.well;
1145 cfg.cls += ' hidden';
1149 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1150 cfg.cls +=' alert alert-' + this.alert;
1155 if (this.panel.length) {
1156 cfg.cls += ' panel panel-' + this.panel;
1158 if (this.header.length) {
1162 if(this.expandable){
1164 cfg.cls = cfg.cls + ' expandable';
1168 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1176 cls : 'panel-title',
1177 html : (this.expandable ? ' ' : '') + this.header
1181 cls: 'panel-header-right',
1187 cls : 'panel-heading',
1188 style : this.expandable ? 'cursor: pointer' : '',
1196 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1201 if (this.footer.length) {
1203 cls : 'panel-footer',
1212 body.html = this.html || cfg.html;
1213 // prefix with the icons..
1215 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1218 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1223 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1224 cfg.cls = 'container';
1230 initEvents: function()
1232 if(this.expandable){
1233 var headerEl = this.headerEl();
1236 headerEl.on('click', this.onToggleClick, this);
1241 this.el.on('click', this.onClick, this);
1246 onToggleClick : function()
1248 var headerEl = this.headerEl();
1264 if(this.fireEvent('expand', this)) {
1266 this.expanded = true;
1268 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1270 this.el.select('.panel-body',true).first().removeClass('hide');
1272 var toggleEl = this.toggleEl();
1278 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1283 collapse : function()
1285 if(this.fireEvent('collapse', this)) {
1287 this.expanded = false;
1289 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1290 this.el.select('.panel-body',true).first().addClass('hide');
1292 var toggleEl = this.toggleEl();
1298 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1302 toggleEl : function()
1304 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1308 return this.el.select('.panel-heading .fa',true).first();
1311 headerEl : function()
1313 if(!this.el || !this.panel.length || !this.header.length){
1317 return this.el.select('.panel-heading',true).first()
1322 if(!this.el || !this.panel.length){
1326 return this.el.select('.panel-body',true).first()
1329 titleEl : function()
1331 if(!this.el || !this.panel.length || !this.header.length){
1335 return this.el.select('.panel-title',true).first();
1338 setTitle : function(v)
1340 var titleEl = this.titleEl();
1346 titleEl.dom.innerHTML = v;
1349 getTitle : function()
1352 var titleEl = this.titleEl();
1358 return titleEl.dom.innerHTML;
1361 setRightTitle : function(v)
1363 var t = this.el.select('.panel-header-right',true).first();
1369 t.dom.innerHTML = v;
1372 onClick : function(e)
1376 this.fireEvent('click', this, e);
1390 * @class Roo.bootstrap.Img
1391 * @extends Roo.bootstrap.Component
1392 * Bootstrap Img class
1393 * @cfg {Boolean} imgResponsive false | true
1394 * @cfg {String} border rounded | circle | thumbnail
1395 * @cfg {String} src image source
1396 * @cfg {String} alt image alternative text
1397 * @cfg {String} href a tag href
1398 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1399 * @cfg {String} xsUrl xs image source
1400 * @cfg {String} smUrl sm image source
1401 * @cfg {String} mdUrl md image source
1402 * @cfg {String} lgUrl lg image source
1405 * Create a new Input
1406 * @param {Object} config The config object
1409 Roo.bootstrap.Img = function(config){
1410 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1416 * The img click event for the img.
1417 * @param {Roo.EventObject} e
1423 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1425 imgResponsive: true,
1435 getAutoCreate : function()
1437 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1438 return this.createSingleImg();
1443 cls: 'roo-image-responsive-group',
1448 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1450 if(!_this[size + 'Url']){
1456 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1457 html: _this.html || cfg.html,
1458 src: _this[size + 'Url']
1461 img.cls += ' roo-image-responsive-' + size;
1463 var s = ['xs', 'sm', 'md', 'lg'];
1465 s.splice(s.indexOf(size), 1);
1467 Roo.each(s, function(ss){
1468 img.cls += ' hidden-' + ss;
1471 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1472 cfg.cls += ' img-' + _this.border;
1476 cfg.alt = _this.alt;
1489 a.target = _this.target;
1493 cfg.cn.push((_this.href) ? a : img);
1500 createSingleImg : function()
1504 cls: (this.imgResponsive) ? 'img-responsive' : '',
1506 src : 'about:blank' // just incase src get's set to undefined?!?
1509 cfg.html = this.html || cfg.html;
1511 cfg.src = this.src || cfg.src;
1513 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1514 cfg.cls += ' img-' + this.border;
1531 a.target = this.target;
1536 return (this.href) ? a : cfg;
1539 initEvents: function()
1542 this.el.on('click', this.onClick, this);
1547 onClick : function(e)
1549 Roo.log('img onclick');
1550 this.fireEvent('click', this, e);
1553 * Sets the url of the image - used to update it
1554 * @param {String} url the url of the image
1557 setSrc : function(url)
1561 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1562 this.el.dom.src = url;
1566 this.el.select('img', true).first().dom.src = url;
1582 * @class Roo.bootstrap.Link
1583 * @extends Roo.bootstrap.Component
1584 * Bootstrap Link Class
1585 * @cfg {String} alt image alternative text
1586 * @cfg {String} href a tag href
1587 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1588 * @cfg {String} html the content of the link.
1589 * @cfg {String} anchor name for the anchor link
1590 * @cfg {String} fa - favicon
1592 * @cfg {Boolean} preventDefault (true | false) default false
1596 * Create a new Input
1597 * @param {Object} config The config object
1600 Roo.bootstrap.Link = function(config){
1601 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1607 * The img click event for the img.
1608 * @param {Roo.EventObject} e
1614 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1618 preventDefault: false,
1624 getAutoCreate : function()
1626 var html = this.html || '';
1628 if (this.fa !== false) {
1629 html = '<i class="fa fa-' + this.fa + '"></i>';
1634 // anchor's do not require html/href...
1635 if (this.anchor === false) {
1637 cfg.href = this.href || '#';
1639 cfg.name = this.anchor;
1640 if (this.html !== false || this.fa !== false) {
1643 if (this.href !== false) {
1644 cfg.href = this.href;
1648 if(this.alt !== false){
1653 if(this.target !== false) {
1654 cfg.target = this.target;
1660 initEvents: function() {
1662 if(!this.href || this.preventDefault){
1663 this.el.on('click', this.onClick, this);
1667 onClick : function(e)
1669 if(this.preventDefault){
1672 //Roo.log('img onclick');
1673 this.fireEvent('click', this, e);
1686 * @class Roo.bootstrap.Header
1687 * @extends Roo.bootstrap.Component
1688 * Bootstrap Header class
1689 * @cfg {String} html content of header
1690 * @cfg {Number} level (1|2|3|4|5|6) default 1
1693 * Create a new Header
1694 * @param {Object} config The config object
1698 Roo.bootstrap.Header = function(config){
1699 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1702 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1710 getAutoCreate : function(){
1715 tag: 'h' + (1 *this.level),
1716 html: this.html || ''
1728 * Ext JS Library 1.1.1
1729 * Copyright(c) 2006-2007, Ext JS, LLC.
1731 * Originally Released Under LGPL - original licence link has changed is not relivant.
1734 * <script type="text/javascript">
1738 * @class Roo.bootstrap.MenuMgr
1739 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1742 Roo.bootstrap.MenuMgr = function(){
1743 var menus, active, groups = {}, attached = false, lastShow = new Date();
1745 // private - called when first menu is created
1748 active = new Roo.util.MixedCollection();
1749 Roo.get(document).addKeyListener(27, function(){
1750 if(active.length > 0){
1758 if(active && active.length > 0){
1759 var c = active.clone();
1769 if(active.length < 1){
1770 Roo.get(document).un("mouseup", onMouseDown);
1778 var last = active.last();
1779 lastShow = new Date();
1782 Roo.get(document).on("mouseup", onMouseDown);
1787 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1788 m.parentMenu.activeChild = m;
1789 }else if(last && last.isVisible()){
1790 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1795 function onBeforeHide(m){
1797 m.activeChild.hide();
1799 if(m.autoHideTimer){
1800 clearTimeout(m.autoHideTimer);
1801 delete m.autoHideTimer;
1806 function onBeforeShow(m){
1807 var pm = m.parentMenu;
1808 if(!pm && !m.allowOtherMenus){
1810 }else if(pm && pm.activeChild && active != m){
1811 pm.activeChild.hide();
1815 // private this should really trigger on mouseup..
1816 function onMouseDown(e){
1817 Roo.log("on Mouse Up");
1819 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1820 Roo.log("MenuManager hideAll");
1829 function onBeforeCheck(mi, state){
1831 var g = groups[mi.group];
1832 for(var i = 0, l = g.length; i < l; i++){
1834 g[i].setChecked(false);
1843 * Hides all menus that are currently visible
1845 hideAll : function(){
1850 register : function(menu){
1854 menus[menu.id] = menu;
1855 menu.on("beforehide", onBeforeHide);
1856 menu.on("hide", onHide);
1857 menu.on("beforeshow", onBeforeShow);
1858 menu.on("show", onShow);
1860 if(g && menu.events["checkchange"]){
1864 groups[g].push(menu);
1865 menu.on("checkchange", onCheck);
1870 * Returns a {@link Roo.menu.Menu} object
1871 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1872 * be used to generate and return a new Menu instance.
1874 get : function(menu){
1875 if(typeof menu == "string"){ // menu id
1877 }else if(menu.events){ // menu instance
1880 /*else if(typeof menu.length == 'number'){ // array of menu items?
1881 return new Roo.bootstrap.Menu({items:menu});
1882 }else{ // otherwise, must be a config
1883 return new Roo.bootstrap.Menu(menu);
1890 unregister : function(menu){
1891 delete menus[menu.id];
1892 menu.un("beforehide", onBeforeHide);
1893 menu.un("hide", onHide);
1894 menu.un("beforeshow", onBeforeShow);
1895 menu.un("show", onShow);
1897 if(g && menu.events["checkchange"]){
1898 groups[g].remove(menu);
1899 menu.un("checkchange", onCheck);
1904 registerCheckable : function(menuItem){
1905 var g = menuItem.group;
1910 groups[g].push(menuItem);
1911 menuItem.on("beforecheckchange", onBeforeCheck);
1916 unregisterCheckable : function(menuItem){
1917 var g = menuItem.group;
1919 groups[g].remove(menuItem);
1920 menuItem.un("beforecheckchange", onBeforeCheck);
1932 * @class Roo.bootstrap.Menu
1933 * @extends Roo.bootstrap.Component
1934 * Bootstrap Menu class - container for MenuItems
1935 * @cfg {String} type (dropdown|treeview|submenu) type of menu
1936 * @cfg {bool} hidden if the menu should be hidden when rendered.
1937 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
1938 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
1942 * @param {Object} config The config object
1946 Roo.bootstrap.Menu = function(config){
1947 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
1948 if (this.registerMenu && this.type != 'treeview') {
1949 Roo.bootstrap.MenuMgr.register(this);
1954 * Fires before this menu is displayed
1955 * @param {Roo.menu.Menu} this
1960 * Fires before this menu is hidden
1961 * @param {Roo.menu.Menu} this
1966 * Fires after this menu is displayed
1967 * @param {Roo.menu.Menu} this
1972 * Fires after this menu is hidden
1973 * @param {Roo.menu.Menu} this
1978 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
1979 * @param {Roo.menu.Menu} this
1980 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1981 * @param {Roo.EventObject} e
1986 * Fires when the mouse is hovering over this menu
1987 * @param {Roo.menu.Menu} this
1988 * @param {Roo.EventObject} e
1989 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1994 * Fires when the mouse exits this menu
1995 * @param {Roo.menu.Menu} this
1996 * @param {Roo.EventObject} e
1997 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2002 * Fires when a menu item contained in this menu is clicked
2003 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2004 * @param {Roo.EventObject} e
2008 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2011 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2015 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2018 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2020 registerMenu : true,
2022 menuItems :false, // stores the menu items..
2032 getChildContainer : function() {
2036 getAutoCreate : function(){
2038 //if (['right'].indexOf(this.align)!==-1) {
2039 // cfg.cn[1].cls += ' pull-right'
2045 cls : 'dropdown-menu' ,
2046 style : 'z-index:1000'
2050 if (this.type === 'submenu') {
2051 cfg.cls = 'submenu active';
2053 if (this.type === 'treeview') {
2054 cfg.cls = 'treeview-menu';
2059 initEvents : function() {
2061 // Roo.log("ADD event");
2062 // Roo.log(this.triggerEl.dom);
2064 this.triggerEl.on('click', this.onTriggerClick, this);
2066 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2068 this.triggerEl.addClass('dropdown-toggle');
2071 this.el.on('touchstart' , this.onTouch, this);
2073 this.el.on('click' , this.onClick, this);
2075 this.el.on("mouseover", this.onMouseOver, this);
2076 this.el.on("mouseout", this.onMouseOut, this);
2080 findTargetItem : function(e)
2082 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2086 //Roo.log(t); Roo.log(t.id);
2088 //Roo.log(this.menuitems);
2089 return this.menuitems.get(t.id);
2091 //return this.items.get(t.menuItemId);
2097 onTouch : function(e)
2099 Roo.log("menu.onTouch");
2100 //e.stopEvent(); this make the user popdown broken
2104 onClick : function(e)
2106 Roo.log("menu.onClick");
2108 var t = this.findTargetItem(e);
2109 if(!t || t.isContainer){
2114 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2115 if(t == this.activeItem && t.shouldDeactivate(e)){
2116 this.activeItem.deactivate();
2117 delete this.activeItem;
2121 this.setActiveItem(t, true);
2129 Roo.log('pass click event');
2133 this.fireEvent("click", this, t, e);
2137 if(!t.href.length || t.href == '#'){
2138 (function() { _this.hide(); }).defer(100);
2143 onMouseOver : function(e){
2144 var t = this.findTargetItem(e);
2147 // if(t.canActivate && !t.disabled){
2148 // this.setActiveItem(t, true);
2152 this.fireEvent("mouseover", this, e, t);
2154 isVisible : function(){
2155 return !this.hidden;
2157 onMouseOut : function(e){
2158 var t = this.findTargetItem(e);
2161 // if(t == this.activeItem && t.shouldDeactivate(e)){
2162 // this.activeItem.deactivate();
2163 // delete this.activeItem;
2166 this.fireEvent("mouseout", this, e, t);
2171 * Displays this menu relative to another element
2172 * @param {String/HTMLElement/Roo.Element} element The element to align to
2173 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2174 * the element (defaults to this.defaultAlign)
2175 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2177 show : function(el, pos, parentMenu){
2178 this.parentMenu = parentMenu;
2182 this.fireEvent("beforeshow", this);
2183 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2186 * Displays this menu at a specific xy position
2187 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2188 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2190 showAt : function(xy, parentMenu, /* private: */_e){
2191 this.parentMenu = parentMenu;
2196 this.fireEvent("beforeshow", this);
2197 //xy = this.el.adjustForConstraints(xy);
2201 this.hideMenuItems();
2202 this.hidden = false;
2203 this.triggerEl.addClass('open');
2205 if(this.el.getWidth() + xy[0] > Roo.lib.Dom.getViewWidth()){
2206 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2209 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2214 this.fireEvent("show", this);
2220 this.doFocus.defer(50, this);
2224 doFocus : function(){
2226 this.focusEl.focus();
2231 * Hides this menu and optionally all parent menus
2232 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2234 hide : function(deep)
2237 this.hideMenuItems();
2238 if(this.el && this.isVisible()){
2239 this.fireEvent("beforehide", this);
2240 if(this.activeItem){
2241 this.activeItem.deactivate();
2242 this.activeItem = null;
2244 this.triggerEl.removeClass('open');;
2246 this.fireEvent("hide", this);
2248 if(deep === true && this.parentMenu){
2249 this.parentMenu.hide(true);
2253 onTriggerClick : function(e)
2255 Roo.log('trigger click');
2257 var target = e.getTarget();
2259 Roo.log(target.nodeName.toLowerCase());
2261 if(target.nodeName.toLowerCase() === 'i'){
2267 onTriggerPress : function(e)
2269 Roo.log('trigger press');
2270 //Roo.log(e.getTarget());
2271 // Roo.log(this.triggerEl.dom);
2273 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2274 var pel = Roo.get(e.getTarget());
2275 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2276 Roo.log('is treeview or dropdown?');
2280 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2284 if (this.isVisible()) {
2289 this.show(this.triggerEl, false, false);
2292 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2299 hideMenuItems : function()
2301 Roo.log("hide Menu Items");
2305 //$(backdrop).remove()
2306 this.el.select('.open',true).each(function(aa) {
2308 aa.removeClass('open');
2309 //var parent = getParent($(this))
2310 //var relatedTarget = { relatedTarget: this }
2312 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2313 //if (e.isDefaultPrevented()) return
2314 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2317 addxtypeChild : function (tree, cntr) {
2318 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2320 this.menuitems.add(comp);
2341 * @class Roo.bootstrap.MenuItem
2342 * @extends Roo.bootstrap.Component
2343 * Bootstrap MenuItem class
2344 * @cfg {String} html the menu label
2345 * @cfg {String} href the link
2346 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2347 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2348 * @cfg {Boolean} active used on sidebars to highlight active itesm
2349 * @cfg {String} fa favicon to show on left of menu item.
2350 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2354 * Create a new MenuItem
2355 * @param {Object} config The config object
2359 Roo.bootstrap.MenuItem = function(config){
2360 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2365 * The raw click event for the entire grid.
2366 * @param {Roo.bootstrap.MenuItem} this
2367 * @param {Roo.EventObject} e
2373 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2377 preventDefault: false,
2378 isContainer : false,
2382 getAutoCreate : function(){
2384 if(this.isContainer){
2387 cls: 'dropdown-menu-item'
2401 if (this.fa !== false) {
2404 cls : 'fa fa-' + this.fa
2413 cls: 'dropdown-menu-item',
2416 if (this.parent().type == 'treeview') {
2417 cfg.cls = 'treeview-menu';
2420 cfg.cls += ' active';
2425 anc.href = this.href || cfg.cn[0].href ;
2426 ctag.html = this.html || cfg.cn[0].html ;
2430 initEvents: function()
2432 if (this.parent().type == 'treeview') {
2433 this.el.select('a').on('click', this.onClick, this);
2437 this.menu.parentType = this.xtype;
2438 this.menu.triggerEl = this.el;
2439 this.menu = this.addxtype(Roo.apply({}, this.menu));
2443 onClick : function(e)
2445 Roo.log('item on click ');
2447 if(this.preventDefault){
2450 //this.parent().hideMenuItems();
2452 this.fireEvent('click', this, e);
2471 * @class Roo.bootstrap.MenuSeparator
2472 * @extends Roo.bootstrap.Component
2473 * Bootstrap MenuSeparator class
2476 * Create a new MenuItem
2477 * @param {Object} config The config object
2481 Roo.bootstrap.MenuSeparator = function(config){
2482 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2485 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2487 getAutoCreate : function(){
2506 * @class Roo.bootstrap.Modal
2507 * @extends Roo.bootstrap.Component
2508 * Bootstrap Modal class
2509 * @cfg {String} title Title of dialog
2510 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2511 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2512 * @cfg {Boolean} specificTitle default false
2513 * @cfg {Array} buttons Array of buttons or standard button set..
2514 * @cfg {String} buttonPosition (left|right|center) default right
2515 * @cfg {Boolean} animate default true
2516 * @cfg {Boolean} allow_close default true
2517 * @cfg {Boolean} fitwindow default false
2518 * @cfg {String} size (sm|lg) default empty
2522 * Create a new Modal Dialog
2523 * @param {Object} config The config object
2526 Roo.bootstrap.Modal = function(config){
2527 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2532 * The raw btnclick event for the button
2533 * @param {Roo.EventObject} e
2538 * Fire when dialog resize
2539 * @param {Roo.bootstrap.Modal} this
2540 * @param {Roo.EventObject} e
2544 this.buttons = this.buttons || [];
2547 this.tmpl = Roo.factory(this.tmpl);
2552 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2554 title : 'test dialog',
2564 specificTitle: false,
2566 buttonPosition: 'right',
2585 onRender : function(ct, position)
2587 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2590 var cfg = Roo.apply({}, this.getAutoCreate());
2593 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2595 //if (!cfg.name.length) {
2599 cfg.cls += ' ' + this.cls;
2602 cfg.style = this.style;
2604 this.el = Roo.get(document.body).createChild(cfg, position);
2606 //var type = this.el.dom.type;
2609 if(this.tabIndex !== undefined){
2610 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2613 this.dialogEl = this.el.select('.modal-dialog',true).first();
2614 this.bodyEl = this.el.select('.modal-body',true).first();
2615 this.closeEl = this.el.select('.modal-header .close', true).first();
2616 this.headerEl = this.el.select('.modal-header',true).first();
2617 this.titleEl = this.el.select('.modal-title',true).first();
2618 this.footerEl = this.el.select('.modal-footer',true).first();
2620 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2621 this.maskEl.enableDisplayMode("block");
2623 //this.el.addClass("x-dlg-modal");
2625 if (this.buttons.length) {
2626 Roo.each(this.buttons, function(bb) {
2627 var b = Roo.apply({}, bb);
2628 b.xns = b.xns || Roo.bootstrap;
2629 b.xtype = b.xtype || 'Button';
2630 if (typeof(b.listeners) == 'undefined') {
2631 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2634 var btn = Roo.factory(b);
2636 btn.render(this.el.select('.modal-footer div').first());
2640 // render the children.
2643 if(typeof(this.items) != 'undefined'){
2644 var items = this.items;
2647 for(var i =0;i < items.length;i++) {
2648 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2652 this.items = nitems;
2654 // where are these used - they used to be body/close/footer
2658 //this.el.addClass([this.fieldClass, this.cls]);
2662 getAutoCreate : function(){
2667 html : this.html || ''
2672 cls : 'modal-title',
2676 if(this.specificTitle){
2682 if (this.allow_close) {
2694 if(this.size.length){
2695 size = 'modal-' + this.size;
2700 style : 'display: none',
2703 cls: "modal-dialog " + size,
2706 cls : "modal-content",
2709 cls : 'modal-header',
2714 cls : 'modal-footer',
2718 cls: 'btn-' + this.buttonPosition
2735 modal.cls += ' fade';
2741 getChildContainer : function() {
2746 getButtonContainer : function() {
2747 return this.el.select('.modal-footer div',true).first();
2750 initEvents : function()
2752 if (this.allow_close) {
2753 this.closeEl.on('click', this.hide, this);
2755 Roo.EventManager.onWindowResize(this.resize, this, true);
2762 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2763 if (this.fitwindow) {
2764 var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
2765 var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
2770 setSize : function(w,h)
2780 if (!this.rendered) {
2784 this.el.setStyle('display', 'block');
2786 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2789 this.el.addClass('in');
2792 this.el.addClass('in');
2796 // not sure how we can show data in here..
2798 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2801 Roo.get(document.body).addClass("x-body-masked");
2803 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2804 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2809 this.fireEvent('show', this);
2811 // set zindex here - otherwise it appears to be ignored...
2812 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2815 this.items.forEach( function(e) {
2816 e.layout ? e.layout() : false;
2824 if(this.fireEvent("beforehide", this) !== false){
2826 Roo.get(document.body).removeClass("x-body-masked");
2827 this.el.removeClass('in');
2828 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2830 if(this.animate){ // why
2832 (function(){ _this.el.setStyle('display', 'none'); }).defer(150);
2834 this.el.setStyle('display', 'none');
2836 this.fireEvent('hide', this);
2840 addButton : function(str, cb)
2844 var b = Roo.apply({}, { html : str } );
2845 b.xns = b.xns || Roo.bootstrap;
2846 b.xtype = b.xtype || 'Button';
2847 if (typeof(b.listeners) == 'undefined') {
2848 b.listeners = { click : cb.createDelegate(this) };
2851 var btn = Roo.factory(b);
2853 btn.render(this.el.select('.modal-footer div').first());
2859 setDefaultButton : function(btn)
2861 //this.el.select('.modal-footer').()
2865 resizeTo: function(w,h)
2869 this.dialogEl.setWidth(w);
2870 if (this.diff === false) {
2871 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
2874 this.bodyEl.setHeight(h-this.diff);
2876 this.fireEvent('resize', this);
2879 setContentSize : function(w, h)
2883 onButtonClick: function(btn,e)
2886 this.fireEvent('btnclick', btn.name, e);
2889 * Set the title of the Dialog
2890 * @param {String} str new Title
2892 setTitle: function(str) {
2893 this.titleEl.dom.innerHTML = str;
2896 * Set the body of the Dialog
2897 * @param {String} str new Title
2899 setBody: function(str) {
2900 this.bodyEl.dom.innerHTML = str;
2903 * Set the body of the Dialog using the template
2904 * @param {Obj} data - apply this data to the template and replace the body contents.
2906 applyBody: function(obj)
2909 Roo.log("Error - using apply Body without a template");
2912 this.tmpl.overwrite(this.bodyEl, obj);
2918 Roo.apply(Roo.bootstrap.Modal, {
2920 * Button config that displays a single OK button
2929 * Button config that displays Yes and No buttons
2945 * Button config that displays OK and Cancel buttons
2960 * Button config that displays Yes, No and Cancel buttons
2984 * messagebox - can be used as a replace
2988 * @class Roo.MessageBox
2989 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
2993 Roo.Msg.alert('Status', 'Changes saved successfully.');
2995 // Prompt for user data:
2996 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
2998 // process text value...
3002 // Show a dialog using config options:
3004 title:'Save Changes?',
3005 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3006 buttons: Roo.Msg.YESNOCANCEL,
3013 Roo.bootstrap.MessageBox = function(){
3014 var dlg, opt, mask, waitTimer;
3015 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3016 var buttons, activeTextEl, bwidth;
3020 var handleButton = function(button){
3022 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3026 var handleHide = function(){
3028 dlg.el.removeClass(opt.cls);
3031 // Roo.TaskMgr.stop(waitTimer);
3032 // waitTimer = null;
3037 var updateButtons = function(b){
3040 buttons["ok"].hide();
3041 buttons["cancel"].hide();
3042 buttons["yes"].hide();
3043 buttons["no"].hide();
3044 //dlg.footer.dom.style.display = 'none';
3047 dlg.footerEl.dom.style.display = '';
3048 for(var k in buttons){
3049 if(typeof buttons[k] != "function"){
3052 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3053 width += buttons[k].el.getWidth()+15;
3063 var handleEsc = function(d, k, e){
3064 if(opt && opt.closable !== false){
3074 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3075 * @return {Roo.BasicDialog} The BasicDialog element
3077 getDialog : function(){
3079 dlg = new Roo.bootstrap.Modal( {
3082 //constraintoviewport:false,
3084 //collapsible : false,
3089 //buttonAlign:"center",
3090 closeClick : function(){
3091 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3094 handleButton("cancel");
3099 dlg.on("hide", handleHide);
3101 //dlg.addKeyListener(27, handleEsc);
3103 this.buttons = buttons;
3104 var bt = this.buttonText;
3105 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3106 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3107 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3108 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3110 bodyEl = dlg.bodyEl.createChild({
3112 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3113 '<textarea class="roo-mb-textarea"></textarea>' +
3114 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3116 msgEl = bodyEl.dom.firstChild;
3117 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3118 textboxEl.enableDisplayMode();
3119 textboxEl.addKeyListener([10,13], function(){
3120 if(dlg.isVisible() && opt && opt.buttons){
3123 }else if(opt.buttons.yes){
3124 handleButton("yes");
3128 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3129 textareaEl.enableDisplayMode();
3130 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3131 progressEl.enableDisplayMode();
3133 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3134 var pf = progressEl.dom.firstChild;
3136 pp = Roo.get(pf.firstChild);
3137 pp.setHeight(pf.offsetHeight);
3145 * Updates the message box body text
3146 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3147 * the XHTML-compliant non-breaking space character '&#160;')
3148 * @return {Roo.MessageBox} This message box
3150 updateText : function(text)
3152 if(!dlg.isVisible() && !opt.width){
3153 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3154 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3156 msgEl.innerHTML = text || ' ';
3158 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3159 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3161 Math.min(opt.width || cw , this.maxWidth),
3162 Math.max(opt.minWidth || this.minWidth, bwidth)
3165 activeTextEl.setWidth(w);
3167 if(dlg.isVisible()){
3168 dlg.fixedcenter = false;
3170 // to big, make it scroll. = But as usual stupid IE does not support
3173 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3174 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3175 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3177 bodyEl.dom.style.height = '';
3178 bodyEl.dom.style.overflowY = '';
3181 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3183 bodyEl.dom.style.overflowX = '';
3186 dlg.setContentSize(w, bodyEl.getHeight());
3187 if(dlg.isVisible()){
3188 dlg.fixedcenter = true;
3194 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3195 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3196 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3197 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3198 * @return {Roo.MessageBox} This message box
3200 updateProgress : function(value, text){
3202 this.updateText(text);
3205 if (pp) { // weird bug on my firefox - for some reason this is not defined
3206 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3207 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3213 * Returns true if the message box is currently displayed
3214 * @return {Boolean} True if the message box is visible, else false
3216 isVisible : function(){
3217 return dlg && dlg.isVisible();
3221 * Hides the message box if it is displayed
3224 if(this.isVisible()){
3230 * Displays a new message box, or reinitializes an existing message box, based on the config options
3231 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3232 * The following config object properties are supported:
3234 Property Type Description
3235 ---------- --------------- ------------------------------------------------------------------------------------
3236 animEl String/Element An id or Element from which the message box should animate as it opens and
3237 closes (defaults to undefined)
3238 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3239 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3240 closable Boolean False to hide the top-right close button (defaults to true). Note that
3241 progress and wait dialogs will ignore this property and always hide the
3242 close button as they can only be closed programmatically.
3243 cls String A custom CSS class to apply to the message box element
3244 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3245 displayed (defaults to 75)
3246 fn Function A callback function to execute after closing the dialog. The arguments to the
3247 function will be btn (the name of the button that was clicked, if applicable,
3248 e.g. "ok"), and text (the value of the active text field, if applicable).
3249 Progress and wait dialogs will ignore this option since they do not respond to
3250 user actions and can only be closed programmatically, so any required function
3251 should be called by the same code after it closes the dialog.
3252 icon String A CSS class that provides a background image to be used as an icon for
3253 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3254 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3255 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3256 modal Boolean False to allow user interaction with the page while the message box is
3257 displayed (defaults to true)
3258 msg String A string that will replace the existing message box body text (defaults
3259 to the XHTML-compliant non-breaking space character ' ')
3260 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3261 progress Boolean True to display a progress bar (defaults to false)
3262 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3263 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3264 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3265 title String The title text
3266 value String The string value to set into the active textbox element if displayed
3267 wait Boolean True to display a progress bar (defaults to false)
3268 width Number The width of the dialog in pixels
3275 msg: 'Please enter your address:',
3277 buttons: Roo.MessageBox.OKCANCEL,
3280 animEl: 'addAddressBtn'
3283 * @param {Object} config Configuration options
3284 * @return {Roo.MessageBox} This message box
3286 show : function(options)
3289 // this causes nightmares if you show one dialog after another
3290 // especially on callbacks..
3292 if(this.isVisible()){
3295 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3296 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3297 Roo.log("New Dialog Message:" + options.msg )
3298 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3299 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3302 var d = this.getDialog();
3304 d.setTitle(opt.title || " ");
3305 d.closeEl.setDisplayed(opt.closable !== false);
3306 activeTextEl = textboxEl;
3307 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3312 textareaEl.setHeight(typeof opt.multiline == "number" ?
3313 opt.multiline : this.defaultTextHeight);
3314 activeTextEl = textareaEl;
3323 progressEl.setDisplayed(opt.progress === true);
3324 this.updateProgress(0);
3325 activeTextEl.dom.value = opt.value || "";
3327 dlg.setDefaultButton(activeTextEl);
3329 var bs = opt.buttons;
3333 }else if(bs && bs.yes){
3334 db = buttons["yes"];
3336 dlg.setDefaultButton(db);
3338 bwidth = updateButtons(opt.buttons);
3339 this.updateText(opt.msg);
3341 d.el.addClass(opt.cls);
3343 d.proxyDrag = opt.proxyDrag === true;
3344 d.modal = opt.modal !== false;
3345 d.mask = opt.modal !== false ? mask : false;
3347 // force it to the end of the z-index stack so it gets a cursor in FF
3348 document.body.appendChild(dlg.el.dom);
3349 d.animateTarget = null;
3350 d.show(options.animEl);
3356 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3357 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3358 * and closing the message box when the process is complete.
3359 * @param {String} title The title bar text
3360 * @param {String} msg The message box body text
3361 * @return {Roo.MessageBox} This message box
3363 progress : function(title, msg){
3370 minWidth: this.minProgressWidth,
3377 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3378 * If a callback function is passed it will be called after the user clicks the button, and the
3379 * id of the button that was clicked will be passed as the only parameter to the callback
3380 * (could also be the top-right close button).
3381 * @param {String} title The title bar text
3382 * @param {String} msg The message box body text
3383 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3384 * @param {Object} scope (optional) The scope of the callback function
3385 * @return {Roo.MessageBox} This message box
3387 alert : function(title, msg, fn, scope)
3402 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3403 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3404 * You are responsible for closing the message box when the process is complete.
3405 * @param {String} msg The message box body text
3406 * @param {String} title (optional) The title bar text
3407 * @return {Roo.MessageBox} This message box
3409 wait : function(msg, title){
3420 waitTimer = Roo.TaskMgr.start({
3422 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3430 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3431 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3432 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3433 * @param {String} title The title bar text
3434 * @param {String} msg The message box body text
3435 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3436 * @param {Object} scope (optional) The scope of the callback function
3437 * @return {Roo.MessageBox} This message box
3439 confirm : function(title, msg, fn, scope){
3443 buttons: this.YESNO,
3452 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3453 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3454 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3455 * (could also be the top-right close button) and the text that was entered will be passed as the two
3456 * parameters to the callback.
3457 * @param {String} title The title bar text
3458 * @param {String} msg The message box body text
3459 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3460 * @param {Object} scope (optional) The scope of the callback function
3461 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3462 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3463 * @return {Roo.MessageBox} This message box
3465 prompt : function(title, msg, fn, scope, multiline){
3469 buttons: this.OKCANCEL,
3474 multiline: multiline,
3481 * Button config that displays a single OK button
3486 * Button config that displays Yes and No buttons
3489 YESNO : {yes:true, no:true},
3491 * Button config that displays OK and Cancel buttons
3494 OKCANCEL : {ok:true, cancel:true},
3496 * Button config that displays Yes, No and Cancel buttons
3499 YESNOCANCEL : {yes:true, no:true, cancel:true},
3502 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3505 defaultTextHeight : 75,
3507 * The maximum width in pixels of the message box (defaults to 600)
3512 * The minimum width in pixels of the message box (defaults to 100)
3517 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3518 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3521 minProgressWidth : 250,
3523 * An object containing the default button text strings that can be overriden for localized language support.
3524 * Supported properties are: ok, cancel, yes and no.
3525 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3538 * Shorthand for {@link Roo.MessageBox}
3540 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3541 Roo.Msg = Roo.Msg || Roo.MessageBox;
3550 * @class Roo.bootstrap.Navbar
3551 * @extends Roo.bootstrap.Component
3552 * Bootstrap Navbar class
3555 * Create a new Navbar
3556 * @param {Object} config The config object
3560 Roo.bootstrap.Navbar = function(config){
3561 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3565 * @event beforetoggle
3566 * Fire before toggle the menu
3567 * @param {Roo.EventObject} e
3569 "beforetoggle" : true
3573 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3582 getAutoCreate : function(){
3585 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3589 initEvents :function ()
3591 //Roo.log(this.el.select('.navbar-toggle',true));
3592 this.el.select('.navbar-toggle',true).on('click', function() {
3593 if(this.fireEvent('beforetoggle', this) !== false){
3594 this.el.select('.navbar-collapse',true).toggleClass('in');
3604 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3606 var size = this.el.getSize();
3607 this.maskEl.setSize(size.width, size.height);
3608 this.maskEl.enableDisplayMode("block");
3617 getChildContainer : function()
3619 if (this.el.select('.collapse').getCount()) {
3620 return this.el.select('.collapse',true).first();
3653 * @class Roo.bootstrap.NavSimplebar
3654 * @extends Roo.bootstrap.Navbar
3655 * Bootstrap Sidebar class
3657 * @cfg {Boolean} inverse is inverted color
3659 * @cfg {String} type (nav | pills | tabs)
3660 * @cfg {Boolean} arrangement stacked | justified
3661 * @cfg {String} align (left | right) alignment
3663 * @cfg {Boolean} main (true|false) main nav bar? default false
3664 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3666 * @cfg {String} tag (header|footer|nav|div) default is nav
3672 * Create a new Sidebar
3673 * @param {Object} config The config object
3677 Roo.bootstrap.NavSimplebar = function(config){
3678 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3681 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3697 getAutoCreate : function(){
3701 tag : this.tag || 'div',
3714 this.type = this.type || 'nav';
3715 if (['tabs','pills'].indexOf(this.type)!==-1) {
3716 cfg.cn[0].cls += ' nav-' + this.type
3720 if (this.type!=='nav') {
3721 Roo.log('nav type must be nav/tabs/pills')
3723 cfg.cn[0].cls += ' navbar-nav'
3729 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3730 cfg.cn[0].cls += ' nav-' + this.arrangement;
3734 if (this.align === 'right') {
3735 cfg.cn[0].cls += ' navbar-right';
3739 cfg.cls += ' navbar-inverse';
3766 * @class Roo.bootstrap.NavHeaderbar
3767 * @extends Roo.bootstrap.NavSimplebar
3768 * Bootstrap Sidebar class
3770 * @cfg {String} brand what is brand
3771 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
3772 * @cfg {String} brand_href href of the brand
3773 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
3774 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
3775 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
3776 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
3779 * Create a new Sidebar
3780 * @param {Object} config The config object
3784 Roo.bootstrap.NavHeaderbar = function(config){
3785 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
3789 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
3796 desktopCenter : false,
3799 getAutoCreate : function(){
3802 tag: this.nav || 'nav',
3809 if (this.desktopCenter) {
3810 cn.push({cls : 'container', cn : []});
3817 cls: 'navbar-header',
3822 cls: 'navbar-toggle',
3823 'data-toggle': 'collapse',
3828 html: 'Toggle navigation'
3850 cls: 'collapse navbar-collapse',
3854 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
3856 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
3857 cfg.cls += ' navbar-' + this.position;
3859 // tag can override this..
3861 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
3864 if (this.brand !== '') {
3867 href: this.brand_href ? this.brand_href : '#',
3868 cls: 'navbar-brand',
3876 cfg.cls += ' main-nav';
3884 getHeaderChildContainer : function()
3886 if (this.srButton && this.el.select('.navbar-header').getCount()) {
3887 return this.el.select('.navbar-header',true).first();
3890 return this.getChildContainer();
3894 initEvents : function()
3896 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
3898 if (this.autohide) {
3903 Roo.get(document).on('scroll',function(e) {
3904 var ns = Roo.get(document).getScroll().top;
3905 var os = prevScroll;
3909 ft.removeClass('slideDown');
3910 ft.addClass('slideUp');
3913 ft.removeClass('slideUp');
3914 ft.addClass('slideDown');
3935 * @class Roo.bootstrap.NavSidebar
3936 * @extends Roo.bootstrap.Navbar
3937 * Bootstrap Sidebar class
3940 * Create a new Sidebar
3941 * @param {Object} config The config object
3945 Roo.bootstrap.NavSidebar = function(config){
3946 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
3949 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
3951 sidebar : true, // used by Navbar Item and NavbarGroup at present...
3953 getAutoCreate : function(){
3958 cls: 'sidebar sidebar-nav'
3980 * @class Roo.bootstrap.NavGroup
3981 * @extends Roo.bootstrap.Component
3982 * Bootstrap NavGroup class
3983 * @cfg {String} align (left|right)
3984 * @cfg {Boolean} inverse
3985 * @cfg {String} type (nav|pills|tab) default nav
3986 * @cfg {String} navId - reference Id for navbar.
3990 * Create a new nav group
3991 * @param {Object} config The config object
3994 Roo.bootstrap.NavGroup = function(config){
3995 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
3998 Roo.bootstrap.NavGroup.register(this);
4002 * Fires when the active item changes
4003 * @param {Roo.bootstrap.NavGroup} this
4004 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4005 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4012 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4023 getAutoCreate : function()
4025 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4032 if (['tabs','pills'].indexOf(this.type)!==-1) {
4033 cfg.cls += ' nav-' + this.type
4035 if (this.type!=='nav') {
4036 Roo.log('nav type must be nav/tabs/pills')
4038 cfg.cls += ' navbar-nav'
4041 if (this.parent() && this.parent().sidebar) {
4044 cls: 'dashboard-menu sidebar-menu'
4050 if (this.form === true) {
4056 if (this.align === 'right') {
4057 cfg.cls += ' navbar-right';
4059 cfg.cls += ' navbar-left';
4063 if (this.align === 'right') {
4064 cfg.cls += ' navbar-right';
4068 cfg.cls += ' navbar-inverse';
4076 * sets the active Navigation item
4077 * @param {Roo.bootstrap.NavItem} the new current navitem
4079 setActiveItem : function(item)
4082 Roo.each(this.navItems, function(v){
4087 v.setActive(false, true);
4094 item.setActive(true, true);
4095 this.fireEvent('changed', this, item, prev);
4100 * gets the active Navigation item
4101 * @return {Roo.bootstrap.NavItem} the current navitem
4103 getActive : function()
4107 Roo.each(this.navItems, function(v){
4118 indexOfNav : function()
4122 Roo.each(this.navItems, function(v,i){
4133 * adds a Navigation item
4134 * @param {Roo.bootstrap.NavItem} the navitem to add
4136 addItem : function(cfg)
4138 var cn = new Roo.bootstrap.NavItem(cfg);
4140 cn.parentId = this.id;
4141 cn.onRender(this.el, null);
4145 * register a Navigation item
4146 * @param {Roo.bootstrap.NavItem} the navitem to add
4148 register : function(item)
4150 this.navItems.push( item);
4151 item.navId = this.navId;
4156 * clear all the Navigation item
4159 clearAll : function()
4162 this.el.dom.innerHTML = '';
4165 getNavItem: function(tabId)
4168 Roo.each(this.navItems, function(e) {
4169 if (e.tabId == tabId) {
4179 setActiveNext : function()
4181 var i = this.indexOfNav(this.getActive());
4182 if (i > this.navItems.length) {
4185 this.setActiveItem(this.navItems[i+1]);
4187 setActivePrev : function()
4189 var i = this.indexOfNav(this.getActive());
4193 this.setActiveItem(this.navItems[i-1]);
4195 clearWasActive : function(except) {
4196 Roo.each(this.navItems, function(e) {
4197 if (e.tabId != except.tabId && e.was_active) {
4198 e.was_active = false;
4205 getWasActive : function ()
4208 Roo.each(this.navItems, function(e) {
4223 Roo.apply(Roo.bootstrap.NavGroup, {
4227 * register a Navigation Group
4228 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4230 register : function(navgrp)
4232 this.groups[navgrp.navId] = navgrp;
4236 * fetch a Navigation Group based on the navigation ID
4237 * @param {string} the navgroup to add
4238 * @returns {Roo.bootstrap.NavGroup} the navgroup
4240 get: function(navId) {
4241 if (typeof(this.groups[navId]) == 'undefined') {
4243 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4245 return this.groups[navId] ;
4260 * @class Roo.bootstrap.NavItem
4261 * @extends Roo.bootstrap.Component
4262 * Bootstrap Navbar.NavItem class
4263 * @cfg {String} href link to
4264 * @cfg {String} html content of button
4265 * @cfg {String} badge text inside badge
4266 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4267 * @cfg {String} glyphicon name of glyphicon
4268 * @cfg {String} icon name of font awesome icon
4269 * @cfg {Boolean} active Is item active
4270 * @cfg {Boolean} disabled Is item disabled
4272 * @cfg {Boolean} preventDefault (true | false) default false
4273 * @cfg {String} tabId the tab that this item activates.
4274 * @cfg {String} tagtype (a|span) render as a href or span?
4275 * @cfg {Boolean} animateRef (true|false) link to element default false
4278 * Create a new Navbar Item
4279 * @param {Object} config The config object
4281 Roo.bootstrap.NavItem = function(config){
4282 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4287 * The raw click event for the entire grid.
4288 * @param {Roo.EventObject} e
4293 * Fires when the active item active state changes
4294 * @param {Roo.bootstrap.NavItem} this
4295 * @param {boolean} state the new state
4301 * Fires when scroll to element
4302 * @param {Roo.bootstrap.NavItem} this
4303 * @param {Object} options
4304 * @param {Roo.EventObject} e
4312 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4320 preventDefault : false,
4327 getAutoCreate : function(){
4336 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4338 if (this.disabled) {
4339 cfg.cls += ' disabled';
4342 if (this.href || this.html || this.glyphicon || this.icon) {
4346 href : this.href || "#",
4347 html: this.html || ''
4352 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4355 if(this.glyphicon) {
4356 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4361 cfg.cn[0].html += " <span class='caret'></span>";
4365 if (this.badge !== '') {
4367 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
4375 initEvents: function()
4377 if (typeof (this.menu) != 'undefined') {
4378 this.menu.parentType = this.xtype;
4379 this.menu.triggerEl = this.el;
4380 this.menu = this.addxtype(Roo.apply({}, this.menu));
4383 this.el.select('a',true).on('click', this.onClick, this);
4385 if(this.tagtype == 'span'){
4386 this.el.select('span',true).on('click', this.onClick, this);
4389 // at this point parent should be available..
4390 this.parent().register(this);
4393 onClick : function(e)
4395 if (e.getTarget('.dropdown-menu-item')) {
4396 // did you click on a menu itemm.... - then don't trigger onclick..
4401 this.preventDefault ||
4404 Roo.log("NavItem - prevent Default?");
4408 if (this.disabled) {
4412 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4413 if (tg && tg.transition) {
4414 Roo.log("waiting for the transitionend");
4420 //Roo.log("fire event clicked");
4421 if(this.fireEvent('click', this, e) === false){
4425 if(this.tagtype == 'span'){
4429 //Roo.log(this.href);
4430 var ael = this.el.select('a',true).first();
4433 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4434 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4435 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4436 return; // ignore... - it's a 'hash' to another page.
4438 Roo.log("NavItem - prevent Default?");
4440 this.scrollToElement(e);
4444 var p = this.parent();
4446 if (['tabs','pills'].indexOf(p.type)!==-1) {
4447 if (typeof(p.setActiveItem) !== 'undefined') {
4448 p.setActiveItem(this);
4452 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4453 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4454 // remove the collapsed menu expand...
4455 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4459 isActive: function () {
4462 setActive : function(state, fire, is_was_active)
4464 if (this.active && !state && this.navId) {
4465 this.was_active = true;
4466 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4468 nv.clearWasActive(this);
4472 this.active = state;
4475 this.el.removeClass('active');
4476 } else if (!this.el.hasClass('active')) {
4477 this.el.addClass('active');
4480 this.fireEvent('changed', this, state);
4483 // show a panel if it's registered and related..
4485 if (!this.navId || !this.tabId || !state || is_was_active) {
4489 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4493 var pan = tg.getPanelByName(this.tabId);
4497 // if we can not flip to new panel - go back to old nav highlight..
4498 if (false == tg.showPanel(pan)) {
4499 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4501 var onav = nv.getWasActive();
4503 onav.setActive(true, false, true);
4512 // this should not be here...
4513 setDisabled : function(state)
4515 this.disabled = state;
4517 this.el.removeClass('disabled');
4518 } else if (!this.el.hasClass('disabled')) {
4519 this.el.addClass('disabled');
4525 * Fetch the element to display the tooltip on.
4526 * @return {Roo.Element} defaults to this.el
4528 tooltipEl : function()
4530 return this.el.select('' + this.tagtype + '', true).first();
4533 scrollToElement : function(e)
4535 var c = document.body;
4538 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4540 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4541 c = document.documentElement;
4544 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4550 var o = target.calcOffsetsTo(c);
4557 this.fireEvent('scrollto', this, options, e);
4559 Roo.get(c).scrollTo('top', options.value, true);
4572 * <span> icon </span>
4573 * <span> text </span>
4574 * <span>badge </span>
4578 * @class Roo.bootstrap.NavSidebarItem
4579 * @extends Roo.bootstrap.NavItem
4580 * Bootstrap Navbar.NavSidebarItem class
4581 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4582 * {Boolean} open is the menu open
4583 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4584 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4585 * {String} buttonSize (sm|md|lg)the extra classes for the button
4586 * {Boolean} showArrow show arrow next to the text (default true)
4588 * Create a new Navbar Button
4589 * @param {Object} config The config object
4591 Roo.bootstrap.NavSidebarItem = function(config){
4592 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4597 * The raw click event for the entire grid.
4598 * @param {Roo.EventObject} e
4603 * Fires when the active item active state changes
4604 * @param {Roo.bootstrap.NavSidebarItem} this
4605 * @param {boolean} state the new state
4613 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4615 badgeWeight : 'default',
4621 buttonWeight : 'default',
4627 getAutoCreate : function(){
4632 href : this.href || '#',
4638 if(this.buttonView){
4641 href : this.href || '#',
4642 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4655 cfg.cls += ' active';
4658 if (this.disabled) {
4659 cfg.cls += ' disabled';
4662 cfg.cls += ' open x-open';
4665 if (this.glyphicon || this.icon) {
4666 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4667 a.cn.push({ tag : 'i', cls : c }) ;
4670 if(!this.buttonView){
4673 html : this.html || ''
4680 if (this.badge !== '') {
4681 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4687 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4690 a.cls += ' dropdown-toggle treeview' ;
4696 initEvents : function()
4698 if (typeof (this.menu) != 'undefined') {
4699 this.menu.parentType = this.xtype;
4700 this.menu.triggerEl = this.el;
4701 this.menu = this.addxtype(Roo.apply({}, this.menu));
4704 this.el.on('click', this.onClick, this);
4706 if(this.badge !== ''){
4707 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4712 onClick : function(e)
4719 if(this.preventDefault){
4723 this.fireEvent('click', this);
4726 disable : function()
4728 this.setDisabled(true);
4733 this.setDisabled(false);
4736 setDisabled : function(state)
4738 if(this.disabled == state){
4742 this.disabled = state;
4745 this.el.addClass('disabled');
4749 this.el.removeClass('disabled');
4754 setActive : function(state)
4756 if(this.active == state){
4760 this.active = state;
4763 this.el.addClass('active');
4767 this.el.removeClass('active');
4772 isActive: function ()
4777 setBadge : function(str)
4783 this.badgeEl.dom.innerHTML = str;
4800 * @class Roo.bootstrap.Row
4801 * @extends Roo.bootstrap.Component
4802 * Bootstrap Row class (contains columns...)
4806 * @param {Object} config The config object
4809 Roo.bootstrap.Row = function(config){
4810 Roo.bootstrap.Row.superclass.constructor.call(this, config);
4813 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
4815 getAutoCreate : function(){
4834 * @class Roo.bootstrap.Element
4835 * @extends Roo.bootstrap.Component
4836 * Bootstrap Element class
4837 * @cfg {String} html contents of the element
4838 * @cfg {String} tag tag of the element
4839 * @cfg {String} cls class of the element
4840 * @cfg {Boolean} preventDefault (true|false) default false
4841 * @cfg {Boolean} clickable (true|false) default false
4844 * Create a new Element
4845 * @param {Object} config The config object
4848 Roo.bootstrap.Element = function(config){
4849 Roo.bootstrap.Element.superclass.constructor.call(this, config);
4855 * When a element is chick
4856 * @param {Roo.bootstrap.Element} this
4857 * @param {Roo.EventObject} e
4863 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
4868 preventDefault: false,
4871 getAutoCreate : function(){
4882 initEvents: function()
4884 Roo.bootstrap.Element.superclass.initEvents.call(this);
4887 this.el.on('click', this.onClick, this);
4892 onClick : function(e)
4894 if(this.preventDefault){
4898 this.fireEvent('click', this, e);
4901 getValue : function()
4903 return this.el.dom.innerHTML;
4906 setValue : function(value)
4908 this.el.dom.innerHTML = value;
4923 * @class Roo.bootstrap.Pagination
4924 * @extends Roo.bootstrap.Component
4925 * Bootstrap Pagination class
4926 * @cfg {String} size xs | sm | md | lg
4927 * @cfg {Boolean} inverse false | true
4930 * Create a new Pagination
4931 * @param {Object} config The config object
4934 Roo.bootstrap.Pagination = function(config){
4935 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
4938 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
4944 getAutoCreate : function(){
4950 cfg.cls += ' inverse';
4956 cfg.cls += " " + this.cls;
4974 * @class Roo.bootstrap.PaginationItem
4975 * @extends Roo.bootstrap.Component
4976 * Bootstrap PaginationItem class
4977 * @cfg {String} html text
4978 * @cfg {String} href the link
4979 * @cfg {Boolean} preventDefault (true | false) default true
4980 * @cfg {Boolean} active (true | false) default false
4981 * @cfg {Boolean} disabled default false
4985 * Create a new PaginationItem
4986 * @param {Object} config The config object
4990 Roo.bootstrap.PaginationItem = function(config){
4991 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
4996 * The raw click event for the entire grid.
4997 * @param {Roo.EventObject} e
5003 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5007 preventDefault: true,
5012 getAutoCreate : function(){
5018 href : this.href ? this.href : '#',
5019 html : this.html ? this.html : ''
5029 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5033 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5039 initEvents: function() {
5041 this.el.on('click', this.onClick, this);
5044 onClick : function(e)
5046 Roo.log('PaginationItem on click ');
5047 if(this.preventDefault){
5055 this.fireEvent('click', this, e);
5071 * @class Roo.bootstrap.Slider
5072 * @extends Roo.bootstrap.Component
5073 * Bootstrap Slider class
5076 * Create a new Slider
5077 * @param {Object} config The config object
5080 Roo.bootstrap.Slider = function(config){
5081 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5084 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5086 getAutoCreate : function(){
5090 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5094 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5106 * Ext JS Library 1.1.1
5107 * Copyright(c) 2006-2007, Ext JS, LLC.
5109 * Originally Released Under LGPL - original licence link has changed is not relivant.
5112 * <script type="text/javascript">
5117 * @class Roo.grid.ColumnModel
5118 * @extends Roo.util.Observable
5119 * This is the default implementation of a ColumnModel used by the Grid. It defines
5120 * the columns in the grid.
5123 var colModel = new Roo.grid.ColumnModel([
5124 {header: "Ticker", width: 60, sortable: true, locked: true},
5125 {header: "Company Name", width: 150, sortable: true},
5126 {header: "Market Cap.", width: 100, sortable: true},
5127 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5128 {header: "Employees", width: 100, sortable: true, resizable: false}
5133 * The config options listed for this class are options which may appear in each
5134 * individual column definition.
5135 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5137 * @param {Object} config An Array of column config objects. See this class's
5138 * config objects for details.
5140 Roo.grid.ColumnModel = function(config){
5142 * The config passed into the constructor
5144 this.config = config;
5147 // if no id, create one
5148 // if the column does not have a dataIndex mapping,
5149 // map it to the order it is in the config
5150 for(var i = 0, len = config.length; i < len; i++){
5152 if(typeof c.dataIndex == "undefined"){
5155 if(typeof c.renderer == "string"){
5156 c.renderer = Roo.util.Format[c.renderer];
5158 if(typeof c.id == "undefined"){
5161 if(c.editor && c.editor.xtype){
5162 c.editor = Roo.factory(c.editor, Roo.grid);
5164 if(c.editor && c.editor.isFormField){
5165 c.editor = new Roo.grid.GridEditor(c.editor);
5167 this.lookup[c.id] = c;
5171 * The width of columns which have no width specified (defaults to 100)
5174 this.defaultWidth = 100;
5177 * Default sortable of columns which have no sortable specified (defaults to false)
5180 this.defaultSortable = false;
5184 * @event widthchange
5185 * Fires when the width of a column changes.
5186 * @param {ColumnModel} this
5187 * @param {Number} columnIndex The column index
5188 * @param {Number} newWidth The new width
5190 "widthchange": true,
5192 * @event headerchange
5193 * Fires when the text of a header changes.
5194 * @param {ColumnModel} this
5195 * @param {Number} columnIndex The column index
5196 * @param {Number} newText The new header text
5198 "headerchange": true,
5200 * @event hiddenchange
5201 * Fires when a column is hidden or "unhidden".
5202 * @param {ColumnModel} this
5203 * @param {Number} columnIndex The column index
5204 * @param {Boolean} hidden true if hidden, false otherwise
5206 "hiddenchange": true,
5208 * @event columnmoved
5209 * Fires when a column is moved.
5210 * @param {ColumnModel} this
5211 * @param {Number} oldIndex
5212 * @param {Number} newIndex
5214 "columnmoved" : true,
5216 * @event columlockchange
5217 * Fires when a column's locked state is changed
5218 * @param {ColumnModel} this
5219 * @param {Number} colIndex
5220 * @param {Boolean} locked true if locked
5222 "columnlockchange" : true
5224 Roo.grid.ColumnModel.superclass.constructor.call(this);
5226 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5228 * @cfg {String} header The header text to display in the Grid view.
5231 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5232 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5233 * specified, the column's index is used as an index into the Record's data Array.
5236 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5237 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5240 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5241 * Defaults to the value of the {@link #defaultSortable} property.
5242 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5245 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5248 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5251 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5254 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5257 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5258 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5259 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5260 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5263 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5266 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5269 * @cfg {String} cursor (Optional)
5272 * @cfg {String} tooltip (Optional)
5275 * @cfg {Number} xs (Optional)
5278 * @cfg {Number} sm (Optional)
5281 * @cfg {Number} md (Optional)
5284 * @cfg {Number} lg (Optional)
5287 * Returns the id of the column at the specified index.
5288 * @param {Number} index The column index
5289 * @return {String} the id
5291 getColumnId : function(index){
5292 return this.config[index].id;
5296 * Returns the column for a specified id.
5297 * @param {String} id The column id
5298 * @return {Object} the column
5300 getColumnById : function(id){
5301 return this.lookup[id];
5306 * Returns the column for a specified dataIndex.
5307 * @param {String} dataIndex The column dataIndex
5308 * @return {Object|Boolean} the column or false if not found
5310 getColumnByDataIndex: function(dataIndex){
5311 var index = this.findColumnIndex(dataIndex);
5312 return index > -1 ? this.config[index] : false;
5316 * Returns the index for a specified column id.
5317 * @param {String} id The column id
5318 * @return {Number} the index, or -1 if not found
5320 getIndexById : function(id){
5321 for(var i = 0, len = this.config.length; i < len; i++){
5322 if(this.config[i].id == id){
5330 * Returns the index for a specified column dataIndex.
5331 * @param {String} dataIndex The column dataIndex
5332 * @return {Number} the index, or -1 if not found
5335 findColumnIndex : function(dataIndex){
5336 for(var i = 0, len = this.config.length; i < len; i++){
5337 if(this.config[i].dataIndex == dataIndex){
5345 moveColumn : function(oldIndex, newIndex){
5346 var c = this.config[oldIndex];
5347 this.config.splice(oldIndex, 1);
5348 this.config.splice(newIndex, 0, c);
5349 this.dataMap = null;
5350 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5353 isLocked : function(colIndex){
5354 return this.config[colIndex].locked === true;
5357 setLocked : function(colIndex, value, suppressEvent){
5358 if(this.isLocked(colIndex) == value){
5361 this.config[colIndex].locked = value;
5363 this.fireEvent("columnlockchange", this, colIndex, value);
5367 getTotalLockedWidth : function(){
5369 for(var i = 0; i < this.config.length; i++){
5370 if(this.isLocked(i) && !this.isHidden(i)){
5371 this.totalWidth += this.getColumnWidth(i);
5377 getLockedCount : function(){
5378 for(var i = 0, len = this.config.length; i < len; i++){
5379 if(!this.isLocked(i)){
5384 return this.config.length;
5388 * Returns the number of columns.
5391 getColumnCount : function(visibleOnly){
5392 if(visibleOnly === true){
5394 for(var i = 0, len = this.config.length; i < len; i++){
5395 if(!this.isHidden(i)){
5401 return this.config.length;
5405 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5406 * @param {Function} fn
5407 * @param {Object} scope (optional)
5408 * @return {Array} result
5410 getColumnsBy : function(fn, scope){
5412 for(var i = 0, len = this.config.length; i < len; i++){
5413 var c = this.config[i];
5414 if(fn.call(scope||this, c, i) === true){
5422 * Returns true if the specified column is sortable.
5423 * @param {Number} col The column index
5426 isSortable : function(col){
5427 if(typeof this.config[col].sortable == "undefined"){
5428 return this.defaultSortable;
5430 return this.config[col].sortable;
5434 * Returns the rendering (formatting) function defined for the column.
5435 * @param {Number} col The column index.
5436 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5438 getRenderer : function(col){
5439 if(!this.config[col].renderer){
5440 return Roo.grid.ColumnModel.defaultRenderer;
5442 return this.config[col].renderer;
5446 * Sets the rendering (formatting) function for a column.
5447 * @param {Number} col The column index
5448 * @param {Function} fn The function to use to process the cell's raw data
5449 * to return HTML markup for the grid view. The render function is called with
5450 * the following parameters:<ul>
5451 * <li>Data value.</li>
5452 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5453 * <li>css A CSS style string to apply to the table cell.</li>
5454 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5455 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5456 * <li>Row index</li>
5457 * <li>Column index</li>
5458 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5460 setRenderer : function(col, fn){
5461 this.config[col].renderer = fn;
5465 * Returns the width for the specified column.
5466 * @param {Number} col The column index
5469 getColumnWidth : function(col){
5470 return this.config[col].width * 1 || this.defaultWidth;
5474 * Sets the width for a column.
5475 * @param {Number} col The column index
5476 * @param {Number} width The new width
5478 setColumnWidth : function(col, width, suppressEvent){
5479 this.config[col].width = width;
5480 this.totalWidth = null;
5482 this.fireEvent("widthchange", this, col, width);
5487 * Returns the total width of all columns.
5488 * @param {Boolean} includeHidden True to include hidden column widths
5491 getTotalWidth : function(includeHidden){
5492 if(!this.totalWidth){
5493 this.totalWidth = 0;
5494 for(var i = 0, len = this.config.length; i < len; i++){
5495 if(includeHidden || !this.isHidden(i)){
5496 this.totalWidth += this.getColumnWidth(i);
5500 return this.totalWidth;
5504 * Returns the header for the specified column.
5505 * @param {Number} col The column index
5508 getColumnHeader : function(col){
5509 return this.config[col].header;
5513 * Sets the header for a column.
5514 * @param {Number} col The column index
5515 * @param {String} header The new header
5517 setColumnHeader : function(col, header){
5518 this.config[col].header = header;
5519 this.fireEvent("headerchange", this, col, header);
5523 * Returns the tooltip for the specified column.
5524 * @param {Number} col The column index
5527 getColumnTooltip : function(col){
5528 return this.config[col].tooltip;
5531 * Sets the tooltip for a column.
5532 * @param {Number} col The column index
5533 * @param {String} tooltip The new tooltip
5535 setColumnTooltip : function(col, tooltip){
5536 this.config[col].tooltip = tooltip;
5540 * Returns the dataIndex for the specified column.
5541 * @param {Number} col The column index
5544 getDataIndex : function(col){
5545 return this.config[col].dataIndex;
5549 * Sets the dataIndex for a column.
5550 * @param {Number} col The column index
5551 * @param {Number} dataIndex The new dataIndex
5553 setDataIndex : function(col, dataIndex){
5554 this.config[col].dataIndex = dataIndex;
5560 * Returns true if the cell is editable.
5561 * @param {Number} colIndex The column index
5562 * @param {Number} rowIndex The row index - this is nto actually used..?
5565 isCellEditable : function(colIndex, rowIndex){
5566 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5570 * Returns the editor defined for the cell/column.
5571 * return false or null to disable editing.
5572 * @param {Number} colIndex The column index
5573 * @param {Number} rowIndex The row index
5576 getCellEditor : function(colIndex, rowIndex){
5577 return this.config[colIndex].editor;
5581 * Sets if a column is editable.
5582 * @param {Number} col The column index
5583 * @param {Boolean} editable True if the column is editable
5585 setEditable : function(col, editable){
5586 this.config[col].editable = editable;
5591 * Returns true if the column is hidden.
5592 * @param {Number} colIndex The column index
5595 isHidden : function(colIndex){
5596 return this.config[colIndex].hidden;
5601 * Returns true if the column width cannot be changed
5603 isFixed : function(colIndex){
5604 return this.config[colIndex].fixed;
5608 * Returns true if the column can be resized
5611 isResizable : function(colIndex){
5612 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5615 * Sets if a column is hidden.
5616 * @param {Number} colIndex The column index
5617 * @param {Boolean} hidden True if the column is hidden
5619 setHidden : function(colIndex, hidden){
5620 this.config[colIndex].hidden = hidden;
5621 this.totalWidth = null;
5622 this.fireEvent("hiddenchange", this, colIndex, hidden);
5626 * Sets the editor for a column.
5627 * @param {Number} col The column index
5628 * @param {Object} editor The editor object
5630 setEditor : function(col, editor){
5631 this.config[col].editor = editor;
5635 Roo.grid.ColumnModel.defaultRenderer = function(value)
5637 if(typeof value == "object") {
5640 if(typeof value == "string" && value.length < 1){
5644 return String.format("{0}", value);
5647 // Alias for backwards compatibility
5648 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5651 * Ext JS Library 1.1.1
5652 * Copyright(c) 2006-2007, Ext JS, LLC.
5654 * Originally Released Under LGPL - original licence link has changed is not relivant.
5657 * <script type="text/javascript">
5661 * @class Roo.LoadMask
5662 * A simple utility class for generically masking elements while loading data. If the element being masked has
5663 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5664 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5665 * element's UpdateManager load indicator and will be destroyed after the initial load.
5667 * Create a new LoadMask
5668 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5669 * @param {Object} config The config object
5671 Roo.LoadMask = function(el, config){
5672 this.el = Roo.get(el);
5673 Roo.apply(this, config);
5675 this.store.on('beforeload', this.onBeforeLoad, this);
5676 this.store.on('load', this.onLoad, this);
5677 this.store.on('loadexception', this.onLoadException, this);
5678 this.removeMask = false;
5680 var um = this.el.getUpdateManager();
5681 um.showLoadIndicator = false; // disable the default indicator
5682 um.on('beforeupdate', this.onBeforeLoad, this);
5683 um.on('update', this.onLoad, this);
5684 um.on('failure', this.onLoad, this);
5685 this.removeMask = true;
5689 Roo.LoadMask.prototype = {
5691 * @cfg {Boolean} removeMask
5692 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5693 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5697 * The text to display in a centered loading message box (defaults to 'Loading...')
5701 * @cfg {String} msgCls
5702 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5704 msgCls : 'x-mask-loading',
5707 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5713 * Disables the mask to prevent it from being displayed
5715 disable : function(){
5716 this.disabled = true;
5720 * Enables the mask so that it can be displayed
5722 enable : function(){
5723 this.disabled = false;
5726 onLoadException : function()
5730 if (typeof(arguments[3]) != 'undefined') {
5731 Roo.MessageBox.alert("Error loading",arguments[3]);
5735 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5736 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5743 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5748 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5752 onBeforeLoad : function(){
5754 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5759 destroy : function(){
5761 this.store.un('beforeload', this.onBeforeLoad, this);
5762 this.store.un('load', this.onLoad, this);
5763 this.store.un('loadexception', this.onLoadException, this);
5765 var um = this.el.getUpdateManager();
5766 um.un('beforeupdate', this.onBeforeLoad, this);
5767 um.un('update', this.onLoad, this);
5768 um.un('failure', this.onLoad, this);
5779 * @class Roo.bootstrap.Table
5780 * @extends Roo.bootstrap.Component
5781 * Bootstrap Table class
5782 * @cfg {String} cls table class
5783 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
5784 * @cfg {String} bgcolor Specifies the background color for a table
5785 * @cfg {Number} border Specifies whether the table cells should have borders or not
5786 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
5787 * @cfg {Number} cellspacing Specifies the space between cells
5788 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
5789 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
5790 * @cfg {String} sortable Specifies that the table should be sortable
5791 * @cfg {String} summary Specifies a summary of the content of a table
5792 * @cfg {Number} width Specifies the width of a table
5793 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
5795 * @cfg {boolean} striped Should the rows be alternative striped
5796 * @cfg {boolean} bordered Add borders to the table
5797 * @cfg {boolean} hover Add hover highlighting
5798 * @cfg {boolean} condensed Format condensed
5799 * @cfg {boolean} responsive Format condensed
5800 * @cfg {Boolean} loadMask (true|false) default false
5801 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
5802 * @cfg {Boolean} headerShow (true|false) generate thead, default true
5803 * @cfg {Boolean} rowSelection (true|false) default false
5804 * @cfg {Boolean} cellSelection (true|false) default false
5805 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
5806 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
5807 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
5811 * Create a new Table
5812 * @param {Object} config The config object
5815 Roo.bootstrap.Table = function(config){
5816 Roo.bootstrap.Table.superclass.constructor.call(this, config);
5821 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
5822 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
5823 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
5824 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
5826 this.sm = this.sm || {xtype: 'RowSelectionModel'};
5828 this.sm.grid = this;
5829 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
5830 this.sm = this.selModel;
5831 this.sm.xmodule = this.xmodule || false;
5834 if (this.cm && typeof(this.cm.config) == 'undefined') {
5835 this.colModel = new Roo.grid.ColumnModel(this.cm);
5836 this.cm = this.colModel;
5837 this.cm.xmodule = this.xmodule || false;
5840 this.store= Roo.factory(this.store, Roo.data);
5841 this.ds = this.store;
5842 this.ds.xmodule = this.xmodule || false;
5845 if (this.footer && this.store) {
5846 this.footer.dataSource = this.ds;
5847 this.footer = Roo.factory(this.footer);
5854 * Fires when a cell is clicked
5855 * @param {Roo.bootstrap.Table} this
5856 * @param {Roo.Element} el
5857 * @param {Number} rowIndex
5858 * @param {Number} columnIndex
5859 * @param {Roo.EventObject} e
5863 * @event celldblclick
5864 * Fires when a cell is double clicked
5865 * @param {Roo.bootstrap.Table} this
5866 * @param {Roo.Element} el
5867 * @param {Number} rowIndex
5868 * @param {Number} columnIndex
5869 * @param {Roo.EventObject} e
5871 "celldblclick" : true,
5874 * Fires when a row is clicked
5875 * @param {Roo.bootstrap.Table} this
5876 * @param {Roo.Element} el
5877 * @param {Number} rowIndex
5878 * @param {Roo.EventObject} e
5882 * @event rowdblclick
5883 * Fires when a row is double clicked
5884 * @param {Roo.bootstrap.Table} this
5885 * @param {Roo.Element} el
5886 * @param {Number} rowIndex
5887 * @param {Roo.EventObject} e
5889 "rowdblclick" : true,
5892 * Fires when a mouseover occur
5893 * @param {Roo.bootstrap.Table} this
5894 * @param {Roo.Element} el
5895 * @param {Number} rowIndex
5896 * @param {Number} columnIndex
5897 * @param {Roo.EventObject} e
5902 * Fires when a mouseout occur
5903 * @param {Roo.bootstrap.Table} this
5904 * @param {Roo.Element} el
5905 * @param {Number} rowIndex
5906 * @param {Number} columnIndex
5907 * @param {Roo.EventObject} e
5912 * Fires when a row is rendered, so you can change add a style to it.
5913 * @param {Roo.bootstrap.Table} this
5914 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
5918 * @event rowsrendered
5919 * Fires when all the rows have been rendered
5920 * @param {Roo.bootstrap.Table} this
5922 'rowsrendered' : true,
5924 * @event contextmenu
5925 * The raw contextmenu event for the entire grid.
5926 * @param {Roo.EventObject} e
5928 "contextmenu" : true,
5930 * @event rowcontextmenu
5931 * Fires when a row is right clicked
5932 * @param {Roo.bootstrap.Table} this
5933 * @param {Number} rowIndex
5934 * @param {Roo.EventObject} e
5936 "rowcontextmenu" : true,
5938 * @event cellcontextmenu
5939 * Fires when a cell is right clicked
5940 * @param {Roo.bootstrap.Table} this
5941 * @param {Number} rowIndex
5942 * @param {Number} cellIndex
5943 * @param {Roo.EventObject} e
5945 "cellcontextmenu" : true,
5947 * @event headercontextmenu
5948 * Fires when a header is right clicked
5949 * @param {Roo.bootstrap.Table} this
5950 * @param {Number} columnIndex
5951 * @param {Roo.EventObject} e
5953 "headercontextmenu" : true
5957 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
5983 rowSelection : false,
5984 cellSelection : false,
5987 // Roo.Element - the tbody
5989 // Roo.Element - thead element
5992 container: false, // used by gridpanel...
5996 getAutoCreate : function()
5998 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6005 if (this.scrollBody) {
6006 cfg.cls += ' table-body-fixed';
6009 cfg.cls += ' table-striped';
6013 cfg.cls += ' table-hover';
6015 if (this.bordered) {
6016 cfg.cls += ' table-bordered';
6018 if (this.condensed) {
6019 cfg.cls += ' table-condensed';
6021 if (this.responsive) {
6022 cfg.cls += ' table-responsive';
6026 cfg.cls+= ' ' +this.cls;
6029 // this lot should be simplifed...
6032 cfg.align=this.align;
6035 cfg.bgcolor=this.bgcolor;
6038 cfg.border=this.border;
6040 if (this.cellpadding) {
6041 cfg.cellpadding=this.cellpadding;
6043 if (this.cellspacing) {
6044 cfg.cellspacing=this.cellspacing;
6047 cfg.frame=this.frame;
6050 cfg.rules=this.rules;
6052 if (this.sortable) {
6053 cfg.sortable=this.sortable;
6056 cfg.summary=this.summary;
6059 cfg.width=this.width;
6062 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6065 if(this.store || this.cm){
6066 if(this.headerShow){
6067 cfg.cn.push(this.renderHeader());
6070 cfg.cn.push(this.renderBody());
6072 if(this.footerShow){
6073 cfg.cn.push(this.renderFooter());
6075 // where does this come from?
6076 //cfg.cls+= ' TableGrid';
6079 return { cn : [ cfg ] };
6082 initEvents : function()
6084 if(!this.store || !this.cm){
6087 if (this.selModel) {
6088 this.selModel.initEvents();
6092 //Roo.log('initEvents with ds!!!!');
6094 this.mainBody = this.el.select('tbody', true).first();
6095 this.mainHead = this.el.select('thead', true).first();
6102 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6103 e.on('click', _this.sort, _this);
6106 this.mainBody.on("click", this.onClick, this);
6107 this.mainBody.on("dblclick", this.onDblClick, this);
6109 // why is this done????? = it breaks dialogs??
6110 //this.parent().el.setStyle('position', 'relative');
6114 this.footer.parentId = this.id;
6115 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6118 this.el.select('tfoot tr td').first().addClass('hide');
6122 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6124 this.store.on('load', this.onLoad, this);
6125 this.store.on('beforeload', this.onBeforeLoad, this);
6126 this.store.on('update', this.onUpdate, this);
6127 this.store.on('add', this.onAdd, this);
6128 this.store.on("clear", this.clear, this);
6130 this.el.on("contextmenu", this.onContextMenu, this);
6132 this.mainBody.on('scroll', this.onBodyScroll, this);
6134 this.cm.on("headerchange", this.onHeaderChange, this);
6138 onContextMenu : function(e, t)
6140 this.processEvent("contextmenu", e);
6143 processEvent : function(name, e)
6145 if (name != 'touchstart' ) {
6146 this.fireEvent(name, e);
6149 var t = e.getTarget();
6151 var cell = Roo.get(t);
6157 if(cell.findParent('tfoot', false, true)){
6161 if(cell.findParent('thead', false, true)){
6163 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6164 cell = Roo.get(t).findParent('th', false, true);
6166 Roo.log("failed to find th in thead?");
6167 Roo.log(e.getTarget());
6172 var cellIndex = cell.dom.cellIndex;
6174 var ename = name == 'touchstart' ? 'click' : name;
6175 this.fireEvent("header" + ename, this, cellIndex, e);
6180 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6181 cell = Roo.get(t).findParent('td', false, true);
6183 Roo.log("failed to find th in tbody?");
6184 Roo.log(e.getTarget());
6189 var row = cell.findParent('tr', false, true);
6190 var cellIndex = cell.dom.cellIndex;
6191 var rowIndex = row.dom.rowIndex - 1;
6195 this.fireEvent("row" + name, this, rowIndex, e);
6199 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6205 onMouseover : function(e, el)
6207 var cell = Roo.get(el);
6213 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6214 cell = cell.findParent('td', false, true);
6217 var row = cell.findParent('tr', false, true);
6218 var cellIndex = cell.dom.cellIndex;
6219 var rowIndex = row.dom.rowIndex - 1; // start from 0
6221 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6225 onMouseout : function(e, el)
6227 var cell = Roo.get(el);
6233 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6234 cell = cell.findParent('td', false, true);
6237 var row = cell.findParent('tr', false, true);
6238 var cellIndex = cell.dom.cellIndex;
6239 var rowIndex = row.dom.rowIndex - 1; // start from 0
6241 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6245 onClick : function(e, el)
6247 var cell = Roo.get(el);
6249 if(!cell || (!this.cellSelection && !this.rowSelection)){
6253 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6254 cell = cell.findParent('td', false, true);
6257 if(!cell || typeof(cell) == 'undefined'){
6261 var row = cell.findParent('tr', false, true);
6263 if(!row || typeof(row) == 'undefined'){
6267 var cellIndex = cell.dom.cellIndex;
6268 var rowIndex = this.getRowIndex(row);
6270 // why??? - should these not be based on SelectionModel?
6271 if(this.cellSelection){
6272 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6275 if(this.rowSelection){
6276 this.fireEvent('rowclick', this, row, rowIndex, e);
6282 onDblClick : function(e,el)
6284 var cell = Roo.get(el);
6286 if(!cell || (!this.cellSelection && !this.rowSelection)){
6290 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6291 cell = cell.findParent('td', false, true);
6294 if(!cell || typeof(cell) == 'undefined'){
6298 var row = cell.findParent('tr', false, true);
6300 if(!row || typeof(row) == 'undefined'){
6304 var cellIndex = cell.dom.cellIndex;
6305 var rowIndex = this.getRowIndex(row);
6307 if(this.cellSelection){
6308 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6311 if(this.rowSelection){
6312 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6316 sort : function(e,el)
6318 var col = Roo.get(el);
6320 if(!col.hasClass('sortable')){
6324 var sort = col.attr('sort');
6327 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6331 this.store.sortInfo = {field : sort, direction : dir};
6334 Roo.log("calling footer first");
6335 this.footer.onClick('first');
6338 this.store.load({ params : { start : 0 } });
6342 renderHeader : function()
6350 this.totalWidth = 0;
6352 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6354 var config = cm.config[i];
6359 html: cm.getColumnHeader(i)
6364 if(typeof(config.sortable) != 'undefined' && config.sortable){
6366 c.html = '<i class="glyphicon"></i>' + c.html;
6369 if(typeof(config.lgHeader) != 'undefined'){
6370 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6373 if(typeof(config.mdHeader) != 'undefined'){
6374 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6377 if(typeof(config.smHeader) != 'undefined'){
6378 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6381 if(typeof(config.xsHeader) != 'undefined'){
6382 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6389 if(typeof(config.tooltip) != 'undefined'){
6390 c.tooltip = config.tooltip;
6393 if(typeof(config.colspan) != 'undefined'){
6394 c.colspan = config.colspan;
6397 if(typeof(config.hidden) != 'undefined' && config.hidden){
6398 c.style += ' display:none;';
6401 if(typeof(config.dataIndex) != 'undefined'){
6402 c.sort = config.dataIndex;
6407 if(typeof(config.align) != 'undefined' && config.align.length){
6408 c.style += ' text-align:' + config.align + ';';
6411 if(typeof(config.width) != 'undefined'){
6412 c.style += ' width:' + config.width + 'px;';
6413 this.totalWidth += config.width;
6415 this.totalWidth += 100; // assume minimum of 100 per column?
6418 if(typeof(config.cls) != 'undefined'){
6419 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6422 ['xs','sm','md','lg'].map(function(size){
6424 if(typeof(config[size]) == 'undefined'){
6428 if (!config[size]) { // 0 = hidden
6429 c.cls += ' hidden-' + size;
6433 c.cls += ' col-' + size + '-' + config[size];
6443 renderBody : function()
6453 colspan : this.cm.getColumnCount()
6463 renderFooter : function()
6473 colspan : this.cm.getColumnCount()
6487 // Roo.log('ds onload');
6492 var ds = this.store;
6494 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6495 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6496 if (_this.store.sortInfo) {
6498 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6499 e.select('i', true).addClass(['glyphicon-arrow-up']);
6502 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6503 e.select('i', true).addClass(['glyphicon-arrow-down']);
6508 var tbody = this.mainBody;
6510 if(ds.getCount() > 0){
6511 ds.data.each(function(d,rowIndex){
6512 var row = this.renderRow(cm, ds, rowIndex);
6514 tbody.createChild(row);
6518 if(row.cellObjects.length){
6519 Roo.each(row.cellObjects, function(r){
6520 _this.renderCellObject(r);
6527 Roo.each(this.el.select('tbody td', true).elements, function(e){
6528 e.on('mouseover', _this.onMouseover, _this);
6531 Roo.each(this.el.select('tbody td', true).elements, function(e){
6532 e.on('mouseout', _this.onMouseout, _this);
6534 this.fireEvent('rowsrendered', this);
6535 //if(this.loadMask){
6536 // this.maskEl.hide();
6543 onUpdate : function(ds,record)
6545 this.refreshRow(record);
6549 onRemove : function(ds, record, index, isUpdate){
6550 if(isUpdate !== true){
6551 this.fireEvent("beforerowremoved", this, index, record);
6553 var bt = this.mainBody.dom;
6555 var rows = this.el.select('tbody > tr', true).elements;
6557 if(typeof(rows[index]) != 'undefined'){
6558 bt.removeChild(rows[index].dom);
6561 // if(bt.rows[index]){
6562 // bt.removeChild(bt.rows[index]);
6565 if(isUpdate !== true){
6566 //this.stripeRows(index);
6567 //this.syncRowHeights(index, index);
6569 this.fireEvent("rowremoved", this, index, record);
6573 onAdd : function(ds, records, rowIndex)
6575 //Roo.log('on Add called');
6576 // - note this does not handle multiple adding very well..
6577 var bt = this.mainBody.dom;
6578 for (var i =0 ; i < records.length;i++) {
6579 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6580 //Roo.log(records[i]);
6581 //Roo.log(this.store.getAt(rowIndex+i));
6582 this.insertRow(this.store, rowIndex + i, false);
6589 refreshRow : function(record){
6590 var ds = this.store, index;
6591 if(typeof record == 'number'){
6593 record = ds.getAt(index);
6595 index = ds.indexOf(record);
6597 this.insertRow(ds, index, true);
6599 this.onRemove(ds, record, index+1, true);
6601 //this.syncRowHeights(index, index);
6603 this.fireEvent("rowupdated", this, index, record);
6606 insertRow : function(dm, rowIndex, isUpdate){
6609 this.fireEvent("beforerowsinserted", this, rowIndex);
6611 //var s = this.getScrollState();
6612 var row = this.renderRow(this.cm, this.store, rowIndex);
6613 // insert before rowIndex..
6614 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6618 if(row.cellObjects.length){
6619 Roo.each(row.cellObjects, function(r){
6620 _this.renderCellObject(r);
6625 this.fireEvent("rowsinserted", this, rowIndex);
6626 //this.syncRowHeights(firstRow, lastRow);
6627 //this.stripeRows(firstRow);
6634 getRowDom : function(rowIndex)
6636 var rows = this.el.select('tbody > tr', true).elements;
6638 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6641 // returns the object tree for a tr..
6644 renderRow : function(cm, ds, rowIndex)
6647 var d = ds.getAt(rowIndex);
6654 var cellObjects = [];
6656 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6657 var config = cm.config[i];
6659 var renderer = cm.getRenderer(i);
6663 if(typeof(renderer) !== 'undefined'){
6664 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6666 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6667 // and are rendered into the cells after the row is rendered - using the id for the element.
6669 if(typeof(value) === 'object'){
6679 rowIndex : rowIndex,
6684 this.fireEvent('rowclass', this, rowcfg);
6688 cls : rowcfg.rowClass,
6690 html: (typeof(value) === 'object') ? '' : value
6697 if(typeof(config.colspan) != 'undefined'){
6698 td.colspan = config.colspan;
6701 if(typeof(config.hidden) != 'undefined' && config.hidden){
6702 td.style += ' display:none;';
6705 if(typeof(config.align) != 'undefined' && config.align.length){
6706 td.style += ' text-align:' + config.align + ';';
6709 if(typeof(config.width) != 'undefined'){
6710 td.style += ' width:' + config.width + 'px;';
6713 if(typeof(config.cursor) != 'undefined'){
6714 td.style += ' cursor:' + config.cursor + ';';
6717 if(typeof(config.cls) != 'undefined'){
6718 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6721 ['xs','sm','md','lg'].map(function(size){
6723 if(typeof(config[size]) == 'undefined'){
6727 if (!config[size]) { // 0 = hidden
6728 td.cls += ' hidden-' + size;
6732 td.cls += ' col-' + size + '-' + config[size];
6740 row.cellObjects = cellObjects;
6748 onBeforeLoad : function()
6750 //Roo.log('ds onBeforeLoad');
6754 //if(this.loadMask){
6755 // this.maskEl.show();
6763 this.el.select('tbody', true).first().dom.innerHTML = '';
6766 * Show or hide a row.
6767 * @param {Number} rowIndex to show or hide
6768 * @param {Boolean} state hide
6770 setRowVisibility : function(rowIndex, state)
6772 var bt = this.mainBody.dom;
6774 var rows = this.el.select('tbody > tr', true).elements;
6776 if(typeof(rows[rowIndex]) == 'undefined'){
6779 rows[rowIndex].dom.style.display = state ? '' : 'none';
6783 getSelectionModel : function(){
6785 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
6787 return this.selModel;
6790 * Render the Roo.bootstrap object from renderder
6792 renderCellObject : function(r)
6796 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
6798 var t = r.cfg.render(r.container);
6801 Roo.each(r.cfg.cn, function(c){
6803 container: t.getChildContainer(),
6806 _this.renderCellObject(child);
6811 getRowIndex : function(row)
6815 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
6826 * Returns the grid's underlying element = used by panel.Grid
6827 * @return {Element} The element
6829 getGridEl : function(){
6833 * Forces a resize - used by panel.Grid
6834 * @return {Element} The element
6836 autoSize : function()
6838 //var ctr = Roo.get(this.container.dom.parentElement);
6839 var ctr = Roo.get(this.el.dom);
6841 var thd = this.getGridEl().select('thead',true).first();
6842 var tbd = this.getGridEl().select('tbody', true).first();
6843 var tfd = this.getGridEl().select('tfoot', true).first();
6845 var cw = ctr.getWidth();
6849 tbd.setSize(ctr.getWidth(),
6850 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
6852 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
6855 cw = Math.max(cw, this.totalWidth);
6856 this.getGridEl().select('tr',true).setWidth(cw);
6857 // resize 'expandable coloumn?
6859 return; // we doe not have a view in this design..
6862 onBodyScroll: function()
6864 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
6866 this.mainHead.setStyle({
6867 'position' : 'relative',
6868 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6874 var scrollHeight = this.mainBody.dom.scrollHeight;
6876 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
6878 var height = this.mainBody.getHeight();
6880 if(scrollHeight - height == scrollTop) {
6882 var total = this.ds.getTotalCount();
6884 if(this.footer.cursor + this.footer.pageSize < total){
6886 this.footer.ds.load({
6888 start : this.footer.cursor + this.footer.pageSize,
6889 limit : this.footer.pageSize
6899 onHeaderChange : function()
6902 var header = this.renderHeader();
6903 var table = this.el.select('table', true).first();
6905 this.mainHead.remove();
6906 this.mainHead = table.createChild(header, this.mainBody, false);
6921 * @class Roo.bootstrap.TableCell
6922 * @extends Roo.bootstrap.Component
6923 * Bootstrap TableCell class
6924 * @cfg {String} html cell contain text
6925 * @cfg {String} cls cell class
6926 * @cfg {String} tag cell tag (td|th) default td
6927 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6928 * @cfg {String} align Aligns the content in a cell
6929 * @cfg {String} axis Categorizes cells
6930 * @cfg {String} bgcolor Specifies the background color of a cell
6931 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6932 * @cfg {Number} colspan Specifies the number of columns a cell should span
6933 * @cfg {String} headers Specifies one or more header cells a cell is related to
6934 * @cfg {Number} height Sets the height of a cell
6935 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
6936 * @cfg {Number} rowspan Sets the number of rows a cell should span
6937 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
6938 * @cfg {String} valign Vertical aligns the content in a cell
6939 * @cfg {Number} width Specifies the width of a cell
6942 * Create a new TableCell
6943 * @param {Object} config The config object
6946 Roo.bootstrap.TableCell = function(config){
6947 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
6950 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
6970 getAutoCreate : function(){
6971 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
6991 cfg.align=this.align
6997 cfg.bgcolor=this.bgcolor
7000 cfg.charoff=this.charoff
7003 cfg.colspan=this.colspan
7006 cfg.headers=this.headers
7009 cfg.height=this.height
7012 cfg.nowrap=this.nowrap
7015 cfg.rowspan=this.rowspan
7018 cfg.scope=this.scope
7021 cfg.valign=this.valign
7024 cfg.width=this.width
7043 * @class Roo.bootstrap.TableRow
7044 * @extends Roo.bootstrap.Component
7045 * Bootstrap TableRow class
7046 * @cfg {String} cls row class
7047 * @cfg {String} align Aligns the content in a table row
7048 * @cfg {String} bgcolor Specifies a background color for a table row
7049 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7050 * @cfg {String} valign Vertical aligns the content in a table row
7053 * Create a new TableRow
7054 * @param {Object} config The config object
7057 Roo.bootstrap.TableRow = function(config){
7058 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7061 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7069 getAutoCreate : function(){
7070 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7080 cfg.align = this.align;
7083 cfg.bgcolor = this.bgcolor;
7086 cfg.charoff = this.charoff;
7089 cfg.valign = this.valign;
7107 * @class Roo.bootstrap.TableBody
7108 * @extends Roo.bootstrap.Component
7109 * Bootstrap TableBody class
7110 * @cfg {String} cls element class
7111 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7112 * @cfg {String} align Aligns the content inside the element
7113 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7114 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7117 * Create a new TableBody
7118 * @param {Object} config The config object
7121 Roo.bootstrap.TableBody = function(config){
7122 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7125 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7133 getAutoCreate : function(){
7134 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7148 cfg.align = this.align;
7151 cfg.charoff = this.charoff;
7154 cfg.valign = this.valign;
7161 // initEvents : function()
7168 // this.store = Roo.factory(this.store, Roo.data);
7169 // this.store.on('load', this.onLoad, this);
7171 // this.store.load();
7175 // onLoad: function ()
7177 // this.fireEvent('load', this);
7187 * Ext JS Library 1.1.1
7188 * Copyright(c) 2006-2007, Ext JS, LLC.
7190 * Originally Released Under LGPL - original licence link has changed is not relivant.
7193 * <script type="text/javascript">
7196 // as we use this in bootstrap.
7197 Roo.namespace('Roo.form');
7199 * @class Roo.form.Action
7200 * Internal Class used to handle form actions
7202 * @param {Roo.form.BasicForm} el The form element or its id
7203 * @param {Object} config Configuration options
7208 // define the action interface
7209 Roo.form.Action = function(form, options){
7211 this.options = options || {};
7214 * Client Validation Failed
7217 Roo.form.Action.CLIENT_INVALID = 'client';
7219 * Server Validation Failed
7222 Roo.form.Action.SERVER_INVALID = 'server';
7224 * Connect to Server Failed
7227 Roo.form.Action.CONNECT_FAILURE = 'connect';
7229 * Reading Data from Server Failed
7232 Roo.form.Action.LOAD_FAILURE = 'load';
7234 Roo.form.Action.prototype = {
7236 failureType : undefined,
7237 response : undefined,
7241 run : function(options){
7246 success : function(response){
7251 handleResponse : function(response){
7255 // default connection failure
7256 failure : function(response){
7258 this.response = response;
7259 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7260 this.form.afterAction(this, false);
7263 processResponse : function(response){
7264 this.response = response;
7265 if(!response.responseText){
7268 this.result = this.handleResponse(response);
7272 // utility functions used internally
7273 getUrl : function(appendParams){
7274 var url = this.options.url || this.form.url || this.form.el.dom.action;
7276 var p = this.getParams();
7278 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7284 getMethod : function(){
7285 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7288 getParams : function(){
7289 var bp = this.form.baseParams;
7290 var p = this.options.params;
7292 if(typeof p == "object"){
7293 p = Roo.urlEncode(Roo.applyIf(p, bp));
7294 }else if(typeof p == 'string' && bp){
7295 p += '&' + Roo.urlEncode(bp);
7298 p = Roo.urlEncode(bp);
7303 createCallback : function(){
7305 success: this.success,
7306 failure: this.failure,
7308 timeout: (this.form.timeout*1000),
7309 upload: this.form.fileUpload ? this.success : undefined
7314 Roo.form.Action.Submit = function(form, options){
7315 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7318 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7321 haveProgress : false,
7322 uploadComplete : false,
7324 // uploadProgress indicator.
7325 uploadProgress : function()
7327 if (!this.form.progressUrl) {
7331 if (!this.haveProgress) {
7332 Roo.MessageBox.progress("Uploading", "Uploading");
7334 if (this.uploadComplete) {
7335 Roo.MessageBox.hide();
7339 this.haveProgress = true;
7341 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7343 var c = new Roo.data.Connection();
7345 url : this.form.progressUrl,
7350 success : function(req){
7351 //console.log(data);
7355 rdata = Roo.decode(req.responseText)
7357 Roo.log("Invalid data from server..");
7361 if (!rdata || !rdata.success) {
7363 Roo.MessageBox.alert(Roo.encode(rdata));
7366 var data = rdata.data;
7368 if (this.uploadComplete) {
7369 Roo.MessageBox.hide();
7374 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7375 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7378 this.uploadProgress.defer(2000,this);
7381 failure: function(data) {
7382 Roo.log('progress url failed ');
7393 // run get Values on the form, so it syncs any secondary forms.
7394 this.form.getValues();
7396 var o = this.options;
7397 var method = this.getMethod();
7398 var isPost = method == 'POST';
7399 if(o.clientValidation === false || this.form.isValid()){
7401 if (this.form.progressUrl) {
7402 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7403 (new Date() * 1) + '' + Math.random());
7408 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7409 form:this.form.el.dom,
7410 url:this.getUrl(!isPost),
7412 params:isPost ? this.getParams() : null,
7413 isUpload: this.form.fileUpload
7416 this.uploadProgress();
7418 }else if (o.clientValidation !== false){ // client validation failed
7419 this.failureType = Roo.form.Action.CLIENT_INVALID;
7420 this.form.afterAction(this, false);
7424 success : function(response)
7426 this.uploadComplete= true;
7427 if (this.haveProgress) {
7428 Roo.MessageBox.hide();
7432 var result = this.processResponse(response);
7433 if(result === true || result.success){
7434 this.form.afterAction(this, true);
7438 this.form.markInvalid(result.errors);
7439 this.failureType = Roo.form.Action.SERVER_INVALID;
7441 this.form.afterAction(this, false);
7443 failure : function(response)
7445 this.uploadComplete= true;
7446 if (this.haveProgress) {
7447 Roo.MessageBox.hide();
7450 this.response = response;
7451 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7452 this.form.afterAction(this, false);
7455 handleResponse : function(response){
7456 if(this.form.errorReader){
7457 var rs = this.form.errorReader.read(response);
7460 for(var i = 0, len = rs.records.length; i < len; i++) {
7461 var r = rs.records[i];
7465 if(errors.length < 1){
7469 success : rs.success,
7475 ret = Roo.decode(response.responseText);
7479 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7489 Roo.form.Action.Load = function(form, options){
7490 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7491 this.reader = this.form.reader;
7494 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7499 Roo.Ajax.request(Roo.apply(
7500 this.createCallback(), {
7501 method:this.getMethod(),
7502 url:this.getUrl(false),
7503 params:this.getParams()
7507 success : function(response){
7509 var result = this.processResponse(response);
7510 if(result === true || !result.success || !result.data){
7511 this.failureType = Roo.form.Action.LOAD_FAILURE;
7512 this.form.afterAction(this, false);
7515 this.form.clearInvalid();
7516 this.form.setValues(result.data);
7517 this.form.afterAction(this, true);
7520 handleResponse : function(response){
7521 if(this.form.reader){
7522 var rs = this.form.reader.read(response);
7523 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7525 success : rs.success,
7529 return Roo.decode(response.responseText);
7533 Roo.form.Action.ACTION_TYPES = {
7534 'load' : Roo.form.Action.Load,
7535 'submit' : Roo.form.Action.Submit
7544 * @class Roo.bootstrap.Form
7545 * @extends Roo.bootstrap.Component
7546 * Bootstrap Form class
7547 * @cfg {String} method GET | POST (default POST)
7548 * @cfg {String} labelAlign top | left (default top)
7549 * @cfg {String} align left | right - for navbars
7550 * @cfg {Boolean} loadMask load mask when submit (default true)
7555 * @param {Object} config The config object
7559 Roo.bootstrap.Form = function(config){
7561 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7563 Roo.bootstrap.Form.popover.apply();
7567 * @event clientvalidation
7568 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7569 * @param {Form} this
7570 * @param {Boolean} valid true if the form has passed client-side validation
7572 clientvalidation: true,
7574 * @event beforeaction
7575 * Fires before any action is performed. Return false to cancel the action.
7576 * @param {Form} this
7577 * @param {Action} action The action to be performed
7581 * @event actionfailed
7582 * Fires when an action fails.
7583 * @param {Form} this
7584 * @param {Action} action The action that failed
7586 actionfailed : true,
7588 * @event actioncomplete
7589 * Fires when an action is completed.
7590 * @param {Form} this
7591 * @param {Action} action The action that completed
7593 actioncomplete : true
7597 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7600 * @cfg {String} method
7601 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7606 * The URL to use for form actions if one isn't supplied in the action options.
7609 * @cfg {Boolean} fileUpload
7610 * Set to true if this form is a file upload.
7614 * @cfg {Object} baseParams
7615 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7619 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7623 * @cfg {Sting} align (left|right) for navbar forms
7628 activeAction : null,
7631 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7632 * element by passing it or its id or mask the form itself by passing in true.
7635 waitMsgTarget : false,
7640 * @cfg {Boolean} errorMask (true|false) default false
7645 * @cfg {Number} maskOffset Default 100
7650 * @cfg {Boolean} maskBody
7654 getAutoCreate : function(){
7658 method : this.method || 'POST',
7659 id : this.id || Roo.id(),
7662 if (this.parent().xtype.match(/^Nav/)) {
7663 cfg.cls = 'navbar-form navbar-' + this.align;
7667 if (this.labelAlign == 'left' ) {
7668 cfg.cls += ' form-horizontal';
7674 initEvents : function()
7676 this.el.on('submit', this.onSubmit, this);
7677 // this was added as random key presses on the form where triggering form submit.
7678 this.el.on('keypress', function(e) {
7679 if (e.getCharCode() != 13) {
7682 // we might need to allow it for textareas.. and some other items.
7683 // check e.getTarget().
7685 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7689 Roo.log("keypress blocked");
7697 onSubmit : function(e){
7702 * Returns true if client-side validation on the form is successful.
7705 isValid : function(){
7706 var items = this.getItems();
7710 items.each(function(f){
7716 if(!target && f.el.isVisible(true)){
7722 if(this.errorMask && !valid){
7723 Roo.bootstrap.Form.popover.mask(this, target);
7730 * Returns true if any fields in this form have changed since their original load.
7733 isDirty : function(){
7735 var items = this.getItems();
7736 items.each(function(f){
7746 * Performs a predefined action (submit or load) or custom actions you define on this form.
7747 * @param {String} actionName The name of the action type
7748 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7749 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7750 * accept other config options):
7752 Property Type Description
7753 ---------------- --------------- ----------------------------------------------------------------------------------
7754 url String The url for the action (defaults to the form's url)
7755 method String The form method to use (defaults to the form's method, or POST if not defined)
7756 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7757 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7758 validate the form on the client (defaults to false)
7760 * @return {BasicForm} this
7762 doAction : function(action, options){
7763 if(typeof action == 'string'){
7764 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7766 if(this.fireEvent('beforeaction', this, action) !== false){
7767 this.beforeAction(action);
7768 action.run.defer(100, action);
7774 beforeAction : function(action){
7775 var o = action.options;
7780 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
7782 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7785 // not really supported yet.. ??
7787 //if(this.waitMsgTarget === true){
7788 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7789 //}else if(this.waitMsgTarget){
7790 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7791 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7793 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7799 afterAction : function(action, success){
7800 this.activeAction = null;
7801 var o = action.options;
7806 Roo.get(document.body).unmask();
7812 //if(this.waitMsgTarget === true){
7813 // this.el.unmask();
7814 //}else if(this.waitMsgTarget){
7815 // this.waitMsgTarget.unmask();
7817 // Roo.MessageBox.updateProgress(1);
7818 // Roo.MessageBox.hide();
7825 Roo.callback(o.success, o.scope, [this, action]);
7826 this.fireEvent('actioncomplete', this, action);
7830 // failure condition..
7831 // we have a scenario where updates need confirming.
7832 // eg. if a locking scenario exists..
7833 // we look for { errors : { needs_confirm : true }} in the response.
7835 (typeof(action.result) != 'undefined') &&
7836 (typeof(action.result.errors) != 'undefined') &&
7837 (typeof(action.result.errors.needs_confirm) != 'undefined')
7840 Roo.log("not supported yet");
7843 Roo.MessageBox.confirm(
7844 "Change requires confirmation",
7845 action.result.errorMsg,
7850 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7860 Roo.callback(o.failure, o.scope, [this, action]);
7861 // show an error message if no failed handler is set..
7862 if (!this.hasListener('actionfailed')) {
7863 Roo.log("need to add dialog support");
7865 Roo.MessageBox.alert("Error",
7866 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7867 action.result.errorMsg :
7868 "Saving Failed, please check your entries or try again"
7873 this.fireEvent('actionfailed', this, action);
7878 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7879 * @param {String} id The value to search for
7882 findField : function(id){
7883 var items = this.getItems();
7884 var field = items.get(id);
7886 items.each(function(f){
7887 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7894 return field || null;
7897 * Mark fields in this form invalid in bulk.
7898 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7899 * @return {BasicForm} this
7901 markInvalid : function(errors){
7902 if(errors instanceof Array){
7903 for(var i = 0, len = errors.length; i < len; i++){
7904 var fieldError = errors[i];
7905 var f = this.findField(fieldError.id);
7907 f.markInvalid(fieldError.msg);
7913 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7914 field.markInvalid(errors[id]);
7918 //Roo.each(this.childForms || [], function (f) {
7919 // f.markInvalid(errors);
7926 * Set values for fields in this form in bulk.
7927 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7928 * @return {BasicForm} this
7930 setValues : function(values){
7931 if(values instanceof Array){ // array of objects
7932 for(var i = 0, len = values.length; i < len; i++){
7934 var f = this.findField(v.id);
7936 f.setValue(v.value);
7937 if(this.trackResetOnLoad){
7938 f.originalValue = f.getValue();
7942 }else{ // object hash
7945 if(typeof values[id] != 'function' && (field = this.findField(id))){
7947 if (field.setFromData &&
7949 field.displayField &&
7950 // combos' with local stores can
7951 // be queried via setValue()
7952 // to set their value..
7953 (field.store && !field.store.isLocal)
7957 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
7958 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
7959 field.setFromData(sd);
7961 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
7963 field.setFromData(values);
7966 field.setValue(values[id]);
7970 if(this.trackResetOnLoad){
7971 field.originalValue = field.getValue();
7977 //Roo.each(this.childForms || [], function (f) {
7978 // f.setValues(values);
7985 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
7986 * they are returned as an array.
7987 * @param {Boolean} asString
7990 getValues : function(asString){
7991 //if (this.childForms) {
7992 // copy values from the child forms
7993 // Roo.each(this.childForms, function (f) {
7994 // this.setValues(f.getValues());
8000 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8001 if(asString === true){
8004 return Roo.urlDecode(fs);
8008 * Returns the fields in this form as an object with key/value pairs.
8009 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8012 getFieldValues : function(with_hidden)
8014 var items = this.getItems();
8016 items.each(function(f){
8022 var v = f.getValue();
8024 if (f.inputType =='radio') {
8025 if (typeof(ret[f.getName()]) == 'undefined') {
8026 ret[f.getName()] = ''; // empty..
8029 if (!f.el.dom.checked) {
8037 if(f.xtype == 'MoneyField'){
8038 ret[f.currencyName] = f.getCurrency();
8041 // not sure if this supported any more..
8042 if ((typeof(v) == 'object') && f.getRawValue) {
8043 v = f.getRawValue() ; // dates..
8045 // combo boxes where name != hiddenName...
8046 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8047 ret[f.name] = f.getRawValue();
8049 ret[f.getName()] = v;
8056 * Clears all invalid messages in this form.
8057 * @return {BasicForm} this
8059 clearInvalid : function(){
8060 var items = this.getItems();
8062 items.each(function(f){
8071 * @return {BasicForm} this
8074 var items = this.getItems();
8075 items.each(function(f){
8079 Roo.each(this.childForms || [], function (f) {
8087 getItems : function()
8089 var r=new Roo.util.MixedCollection(false, function(o){
8090 return o.id || (o.id = Roo.id());
8092 var iter = function(el) {
8099 Roo.each(el.items,function(e) {
8110 Roo.apply(Roo.bootstrap.Form, {
8137 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8138 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8139 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8140 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8143 this.maskEl.top.enableDisplayMode("block");
8144 this.maskEl.left.enableDisplayMode("block");
8145 this.maskEl.bottom.enableDisplayMode("block");
8146 this.maskEl.right.enableDisplayMode("block");
8148 this.toolTip = new Roo.bootstrap.Tooltip({
8149 cls : 'roo-form-error-popover',
8151 'left' : ['r-l', [-2,0], 'right'],
8152 'right' : ['l-r', [2,0], 'left'],
8153 'bottom' : ['tl-bl', [0,2], 'top'],
8154 'top' : [ 'bl-tl', [0,-2], 'bottom']
8158 this.toolTip.render(Roo.get(document.body));
8160 this.toolTip.el.enableDisplayMode("block");
8162 Roo.get(document.body).on('click', function(){
8166 Roo.get(document.body).on('touchstart', function(){
8170 this.isApplied = true
8173 mask : function(form, target)
8177 this.target = target;
8179 if(!this.form.errorMask || !target.el){
8183 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8185 Roo.log(scrollable);
8187 var ot = this.target.el.calcOffsetsTo(scrollable);
8189 var scrollTo = ot[1] - this.form.maskOffset;
8191 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8193 scrollable.scrollTo('top', scrollTo);
8195 var box = this.target.el.getBox();
8197 var zIndex = Roo.bootstrap.Modal.zIndex++;
8200 this.maskEl.top.setStyle('position', 'absolute');
8201 this.maskEl.top.setStyle('z-index', zIndex);
8202 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8203 this.maskEl.top.setLeft(0);
8204 this.maskEl.top.setTop(0);
8205 this.maskEl.top.show();
8207 this.maskEl.left.setStyle('position', 'absolute');
8208 this.maskEl.left.setStyle('z-index', zIndex);
8209 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8210 this.maskEl.left.setLeft(0);
8211 this.maskEl.left.setTop(box.y - this.padding);
8212 this.maskEl.left.show();
8214 this.maskEl.bottom.setStyle('position', 'absolute');
8215 this.maskEl.bottom.setStyle('z-index', zIndex);
8216 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8217 this.maskEl.bottom.setLeft(0);
8218 this.maskEl.bottom.setTop(box.bottom + this.padding);
8219 this.maskEl.bottom.show();
8221 this.maskEl.right.setStyle('position', 'absolute');
8222 this.maskEl.right.setStyle('z-index', zIndex);
8223 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8224 this.maskEl.right.setLeft(box.right + this.padding);
8225 this.maskEl.right.setTop(box.y - this.padding);
8226 this.maskEl.right.show();
8228 this.toolTip.bindEl = this.target.el;
8230 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8232 var tip = this.target.blankText;
8234 if(this.target.getValue() !== '' ) {
8236 if (this.target.invalidText.length) {
8237 tip = this.target.invalidText;
8238 } else if (this.target.regexText.length){
8239 tip = this.target.regexText;
8243 this.toolTip.show(tip);
8245 this.intervalID = window.setInterval(function() {
8246 Roo.bootstrap.Form.popover.unmask();
8249 window.onwheel = function(){ return false;};
8251 (function(){ this.isMasked = true; }).defer(500, this);
8257 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8261 this.maskEl.top.setStyle('position', 'absolute');
8262 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8263 this.maskEl.top.hide();
8265 this.maskEl.left.setStyle('position', 'absolute');
8266 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8267 this.maskEl.left.hide();
8269 this.maskEl.bottom.setStyle('position', 'absolute');
8270 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8271 this.maskEl.bottom.hide();
8273 this.maskEl.right.setStyle('position', 'absolute');
8274 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8275 this.maskEl.right.hide();
8277 this.toolTip.hide();
8279 this.toolTip.el.hide();
8281 window.onwheel = function(){ return true;};
8283 if(this.intervalID){
8284 window.clearInterval(this.intervalID);
8285 this.intervalID = false;
8288 this.isMasked = false;
8298 * Ext JS Library 1.1.1
8299 * Copyright(c) 2006-2007, Ext JS, LLC.
8301 * Originally Released Under LGPL - original licence link has changed is not relivant.
8304 * <script type="text/javascript">
8307 * @class Roo.form.VTypes
8308 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8311 Roo.form.VTypes = function(){
8312 // closure these in so they are only created once.
8313 var alpha = /^[a-zA-Z_]+$/;
8314 var alphanum = /^[a-zA-Z0-9_]+$/;
8315 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8316 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8318 // All these messages and functions are configurable
8321 * The function used to validate email addresses
8322 * @param {String} value The email address
8324 'email' : function(v){
8325 return email.test(v);
8328 * The error text to display when the email validation function returns false
8331 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8333 * The keystroke filter mask to be applied on email input
8336 'emailMask' : /[a-z0-9_\.\-@]/i,
8339 * The function used to validate URLs
8340 * @param {String} value The URL
8342 'url' : function(v){
8346 * The error text to display when the url validation function returns false
8349 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8352 * The function used to validate alpha values
8353 * @param {String} value The value
8355 'alpha' : function(v){
8356 return alpha.test(v);
8359 * The error text to display when the alpha validation function returns false
8362 'alphaText' : 'This field should only contain letters and _',
8364 * The keystroke filter mask to be applied on alpha input
8367 'alphaMask' : /[a-z_]/i,
8370 * The function used to validate alphanumeric values
8371 * @param {String} value The value
8373 'alphanum' : function(v){
8374 return alphanum.test(v);
8377 * The error text to display when the alphanumeric validation function returns false
8380 'alphanumText' : 'This field should only contain letters, numbers and _',
8382 * The keystroke filter mask to be applied on alphanumeric input
8385 'alphanumMask' : /[a-z0-9_]/i
8395 * @class Roo.bootstrap.Input
8396 * @extends Roo.bootstrap.Component
8397 * Bootstrap Input class
8398 * @cfg {Boolean} disabled is it disabled
8399 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8400 * @cfg {String} name name of the input
8401 * @cfg {string} fieldLabel - the label associated
8402 * @cfg {string} placeholder - placeholder to put in text.
8403 * @cfg {string} before - input group add on before
8404 * @cfg {string} after - input group add on after
8405 * @cfg {string} size - (lg|sm) or leave empty..
8406 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8407 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8408 * @cfg {Number} md colspan out of 12 for computer-sized screens
8409 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8410 * @cfg {string} value default value of the input
8411 * @cfg {Number} labelWidth set the width of label
8412 * @cfg {Number} labellg set the width of label (1-12)
8413 * @cfg {Number} labelmd set the width of label (1-12)
8414 * @cfg {Number} labelsm set the width of label (1-12)
8415 * @cfg {Number} labelxs set the width of label (1-12)
8416 * @cfg {String} labelAlign (top|left)
8417 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8418 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8419 * @cfg {String} indicatorpos (left|right) default left
8421 * @cfg {String} align (left|center|right) Default left
8422 * @cfg {Boolean} forceFeedback (true|false) Default false
8428 * Create a new Input
8429 * @param {Object} config The config object
8432 Roo.bootstrap.Input = function(config){
8434 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8439 * Fires when this field receives input focus.
8440 * @param {Roo.form.Field} this
8445 * Fires when this field loses input focus.
8446 * @param {Roo.form.Field} this
8451 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8452 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8453 * @param {Roo.form.Field} this
8454 * @param {Roo.EventObject} e The event object
8459 * Fires just before the field blurs if the field value has changed.
8460 * @param {Roo.form.Field} this
8461 * @param {Mixed} newValue The new value
8462 * @param {Mixed} oldValue The original value
8467 * Fires after the field has been marked as invalid.
8468 * @param {Roo.form.Field} this
8469 * @param {String} msg The validation message
8474 * Fires after the field has been validated with no errors.
8475 * @param {Roo.form.Field} this
8480 * Fires after the key up
8481 * @param {Roo.form.Field} this
8482 * @param {Roo.EventObject} e The event Object
8488 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8490 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8491 automatic validation (defaults to "keyup").
8493 validationEvent : "keyup",
8495 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8497 validateOnBlur : true,
8499 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8501 validationDelay : 250,
8503 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8505 focusClass : "x-form-focus", // not needed???
8509 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8511 invalidClass : "has-warning",
8514 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8516 validClass : "has-success",
8519 * @cfg {Boolean} hasFeedback (true|false) default true
8524 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8526 invalidFeedbackClass : "glyphicon-warning-sign",
8529 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8531 validFeedbackClass : "glyphicon-ok",
8534 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8536 selectOnFocus : false,
8539 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8543 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8548 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8550 disableKeyFilter : false,
8553 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8557 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8561 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8563 blankText : "Please complete this mandatory field",
8566 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8570 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8572 maxLength : Number.MAX_VALUE,
8574 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8576 minLengthText : "The minimum length for this field is {0}",
8578 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8580 maxLengthText : "The maximum length for this field is {0}",
8584 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8585 * If available, this function will be called only after the basic validators all return true, and will be passed the
8586 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8590 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8591 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8592 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8596 * @cfg {String} regexText -- Depricated - use Invalid Text
8601 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8607 autocomplete: false,
8626 formatedValue : false,
8627 forceFeedback : false,
8629 indicatorpos : 'left',
8636 parentLabelAlign : function()
8639 while (parent.parent()) {
8640 parent = parent.parent();
8641 if (typeof(parent.labelAlign) !='undefined') {
8642 return parent.labelAlign;
8649 getAutoCreate : function()
8651 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8657 if(this.inputType != 'hidden'){
8658 cfg.cls = 'form-group' //input-group
8664 type : this.inputType,
8666 cls : 'form-control',
8667 placeholder : this.placeholder || '',
8668 autocomplete : this.autocomplete || 'new-password'
8672 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8675 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8676 input.maxLength = this.maxLength;
8679 if (this.disabled) {
8680 input.disabled=true;
8683 if (this.readOnly) {
8684 input.readonly=true;
8688 input.name = this.name;
8692 input.cls += ' input-' + this.size;
8696 ['xs','sm','md','lg'].map(function(size){
8697 if (settings[size]) {
8698 cfg.cls += ' col-' + size + '-' + settings[size];
8702 var inputblock = input;
8706 cls: 'glyphicon form-control-feedback'
8709 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8712 cls : 'has-feedback',
8720 if (this.before || this.after) {
8723 cls : 'input-group',
8727 if (this.before && typeof(this.before) == 'string') {
8729 inputblock.cn.push({
8731 cls : 'roo-input-before input-group-addon',
8735 if (this.before && typeof(this.before) == 'object') {
8736 this.before = Roo.factory(this.before);
8738 inputblock.cn.push({
8740 cls : 'roo-input-before input-group-' +
8741 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8745 inputblock.cn.push(input);
8747 if (this.after && typeof(this.after) == 'string') {
8748 inputblock.cn.push({
8750 cls : 'roo-input-after input-group-addon',
8754 if (this.after && typeof(this.after) == 'object') {
8755 this.after = Roo.factory(this.after);
8757 inputblock.cn.push({
8759 cls : 'roo-input-after input-group-' +
8760 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8764 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8765 inputblock.cls += ' has-feedback';
8766 inputblock.cn.push(feedback);
8770 if (align ==='left' && this.fieldLabel.length) {
8772 cfg.cls += ' roo-form-group-label-left';
8777 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8778 tooltip : 'This field is required'
8783 cls : 'control-label',
8784 html : this.fieldLabel
8795 var labelCfg = cfg.cn[1];
8796 var contentCfg = cfg.cn[2];
8798 if(this.indicatorpos == 'right'){
8803 cls : 'control-label',
8807 html : this.fieldLabel
8811 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8812 tooltip : 'This field is required'
8825 labelCfg = cfg.cn[0];
8826 contentCfg = cfg.cn[1];
8830 if(this.labelWidth > 12){
8831 labelCfg.style = "width: " + this.labelWidth + 'px';
8834 if(this.labelWidth < 13 && this.labelmd == 0){
8835 this.labelmd = this.labelWidth;
8838 if(this.labellg > 0){
8839 labelCfg.cls += ' col-lg-' + this.labellg;
8840 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8843 if(this.labelmd > 0){
8844 labelCfg.cls += ' col-md-' + this.labelmd;
8845 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8848 if(this.labelsm > 0){
8849 labelCfg.cls += ' col-sm-' + this.labelsm;
8850 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8853 if(this.labelxs > 0){
8854 labelCfg.cls += ' col-xs-' + this.labelxs;
8855 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8859 } else if ( this.fieldLabel.length) {
8864 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8865 tooltip : 'This field is required'
8869 //cls : 'input-group-addon',
8870 html : this.fieldLabel
8878 if(this.indicatorpos == 'right'){
8883 //cls : 'input-group-addon',
8884 html : this.fieldLabel
8889 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8890 tooltip : 'This field is required'
8910 if (this.parentType === 'Navbar' && this.parent().bar) {
8911 cfg.cls += ' navbar-form';
8914 if (this.parentType === 'NavGroup') {
8915 cfg.cls += ' navbar-form';
8923 * return the real input element.
8925 inputEl: function ()
8927 return this.el.select('input.form-control',true).first();
8930 tooltipEl : function()
8932 return this.inputEl();
8935 indicatorEl : function()
8937 var indicator = this.el.select('i.roo-required-indicator',true).first();
8947 setDisabled : function(v)
8949 var i = this.inputEl().dom;
8951 i.removeAttribute('disabled');
8955 i.setAttribute('disabled','true');
8957 initEvents : function()
8960 this.inputEl().on("keydown" , this.fireKey, this);
8961 this.inputEl().on("focus", this.onFocus, this);
8962 this.inputEl().on("blur", this.onBlur, this);
8964 this.inputEl().relayEvent('keyup', this);
8966 this.indicator = this.indicatorEl();
8969 this.indicator.addClass('invisible');
8973 // reference to original value for reset
8974 this.originalValue = this.getValue();
8975 //Roo.form.TextField.superclass.initEvents.call(this);
8976 if(this.validationEvent == 'keyup'){
8977 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8978 this.inputEl().on('keyup', this.filterValidation, this);
8980 else if(this.validationEvent !== false){
8981 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8984 if(this.selectOnFocus){
8985 this.on("focus", this.preFocus, this);
8988 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8989 this.inputEl().on("keypress", this.filterKeys, this);
8991 this.inputEl().relayEvent('keypress', this);
8994 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8995 this.el.on("click", this.autoSize, this);
8998 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
8999 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9002 if (typeof(this.before) == 'object') {
9003 this.before.render(this.el.select('.roo-input-before',true).first());
9005 if (typeof(this.after) == 'object') {
9006 this.after.render(this.el.select('.roo-input-after',true).first());
9011 filterValidation : function(e){
9012 if(!e.isNavKeyPress()){
9013 this.validationTask.delay(this.validationDelay);
9017 * Validates the field value
9018 * @return {Boolean} True if the value is valid, else false
9020 validate : function(){
9021 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9022 if(this.disabled || this.validateValue(this.getRawValue())){
9033 * Validates a value according to the field's validation rules and marks the field as invalid
9034 * if the validation fails
9035 * @param {Mixed} value The value to validate
9036 * @return {Boolean} True if the value is valid, else false
9038 validateValue : function(value){
9039 if(value.length < 1) { // if it's blank
9040 if(this.allowBlank){
9043 return this.inputEl().hasClass('hide') ? true : false;
9046 if(value.length < this.minLength){
9049 if(value.length > this.maxLength){
9053 var vt = Roo.form.VTypes;
9054 if(!vt[this.vtype](value, this)){
9058 if(typeof this.validator == "function"){
9059 var msg = this.validator(value);
9063 if (typeof(msg) == 'string') {
9064 this.invalidText = msg;
9068 if(this.regex && !this.regex.test(value)){
9078 fireKey : function(e){
9079 //Roo.log('field ' + e.getKey());
9080 if(e.isNavKeyPress()){
9081 this.fireEvent("specialkey", this, e);
9084 focus : function (selectText){
9086 this.inputEl().focus();
9087 if(selectText === true){
9088 this.inputEl().dom.select();
9094 onFocus : function(){
9095 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9096 // this.el.addClass(this.focusClass);
9099 this.hasFocus = true;
9100 this.startValue = this.getValue();
9101 this.fireEvent("focus", this);
9105 beforeBlur : Roo.emptyFn,
9109 onBlur : function(){
9111 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9112 //this.el.removeClass(this.focusClass);
9114 this.hasFocus = false;
9115 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9118 var v = this.getValue();
9119 if(String(v) !== String(this.startValue)){
9120 this.fireEvent('change', this, v, this.startValue);
9122 this.fireEvent("blur", this);
9126 * Resets the current field value to the originally loaded value and clears any validation messages
9129 this.setValue(this.originalValue);
9133 * Returns the name of the field
9134 * @return {Mixed} name The name field
9136 getName: function(){
9140 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9141 * @return {Mixed} value The field value
9143 getValue : function(){
9145 var v = this.inputEl().getValue();
9150 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9151 * @return {Mixed} value The field value
9153 getRawValue : function(){
9154 var v = this.inputEl().getValue();
9160 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9161 * @param {Mixed} value The value to set
9163 setRawValue : function(v){
9164 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9167 selectText : function(start, end){
9168 var v = this.getRawValue();
9170 start = start === undefined ? 0 : start;
9171 end = end === undefined ? v.length : end;
9172 var d = this.inputEl().dom;
9173 if(d.setSelectionRange){
9174 d.setSelectionRange(start, end);
9175 }else if(d.createTextRange){
9176 var range = d.createTextRange();
9177 range.moveStart("character", start);
9178 range.moveEnd("character", v.length-end);
9185 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9186 * @param {Mixed} value The value to set
9188 setValue : function(v){
9191 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9197 processValue : function(value){
9198 if(this.stripCharsRe){
9199 var newValue = value.replace(this.stripCharsRe, '');
9200 if(newValue !== value){
9201 this.setRawValue(newValue);
9208 preFocus : function(){
9210 if(this.selectOnFocus){
9211 this.inputEl().dom.select();
9214 filterKeys : function(e){
9216 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9219 var c = e.getCharCode(), cc = String.fromCharCode(c);
9220 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9223 if(!this.maskRe.test(cc)){
9228 * Clear any invalid styles/messages for this field
9230 clearInvalid : function(){
9232 if(!this.el || this.preventMark){ // not rendered
9237 this.el.removeClass(this.invalidClass);
9239 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9241 var feedback = this.el.select('.form-control-feedback', true).first();
9244 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9249 this.fireEvent('valid', this);
9253 * Mark this field as valid
9255 markValid : function()
9257 if(!this.el || this.preventMark){ // not rendered...
9261 this.el.removeClass([this.invalidClass, this.validClass]);
9263 var feedback = this.el.select('.form-control-feedback', true).first();
9266 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9270 this.indicator.removeClass('visible');
9271 this.indicator.addClass('invisible');
9278 if(this.allowBlank && !this.getRawValue().length){
9282 this.el.addClass(this.validClass);
9284 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9286 var feedback = this.el.select('.form-control-feedback', true).first();
9289 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9290 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9295 this.fireEvent('valid', this);
9299 * Mark this field as invalid
9300 * @param {String} msg The validation message
9302 markInvalid : function(msg)
9304 if(!this.el || this.preventMark){ // not rendered
9308 this.el.removeClass([this.invalidClass, this.validClass]);
9310 var feedback = this.el.select('.form-control-feedback', true).first();
9313 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9320 if(this.allowBlank && !this.getRawValue().length){
9325 this.indicator.removeClass('invisible');
9326 this.indicator.addClass('visible');
9329 this.el.addClass(this.invalidClass);
9331 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9333 var feedback = this.el.select('.form-control-feedback', true).first();
9336 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9338 if(this.getValue().length || this.forceFeedback){
9339 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9346 this.fireEvent('invalid', this, msg);
9349 SafariOnKeyDown : function(event)
9351 // this is a workaround for a password hang bug on chrome/ webkit.
9352 if (this.inputEl().dom.type != 'password') {
9356 var isSelectAll = false;
9358 if(this.inputEl().dom.selectionEnd > 0){
9359 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9361 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9362 event.preventDefault();
9367 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9369 event.preventDefault();
9370 // this is very hacky as keydown always get's upper case.
9372 var cc = String.fromCharCode(event.getCharCode());
9373 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9377 adjustWidth : function(tag, w){
9378 tag = tag.toLowerCase();
9379 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9380 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9384 if(tag == 'textarea'){
9387 }else if(Roo.isOpera){
9391 if(tag == 'textarea'){
9399 setFieldLabel : function(v)
9406 var ar = this.el.select('label > span',true);
9408 if (ar.elements.length) {
9409 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9410 this.fieldLabel = v;
9414 var br = this.el.select('label',true);
9416 if(br.elements.length) {
9417 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9418 this.fieldLabel = v;
9422 Roo.log('Cannot Found any of label > span || label in input');
9426 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9427 this.fieldLabel = v;
9442 * @class Roo.bootstrap.TextArea
9443 * @extends Roo.bootstrap.Input
9444 * Bootstrap TextArea class
9445 * @cfg {Number} cols Specifies the visible width of a text area
9446 * @cfg {Number} rows Specifies the visible number of lines in a text area
9447 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9448 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9449 * @cfg {string} html text
9452 * Create a new TextArea
9453 * @param {Object} config The config object
9456 Roo.bootstrap.TextArea = function(config){
9457 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9461 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9471 getAutoCreate : function(){
9473 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9479 if(this.inputType != 'hidden'){
9480 cfg.cls = 'form-group' //input-group
9488 value : this.value || '',
9489 html: this.html || '',
9490 cls : 'form-control',
9491 placeholder : this.placeholder || ''
9495 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9496 input.maxLength = this.maxLength;
9500 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9504 input.cols = this.cols;
9507 if (this.readOnly) {
9508 input.readonly = true;
9512 input.name = this.name;
9516 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9520 ['xs','sm','md','lg'].map(function(size){
9521 if (settings[size]) {
9522 cfg.cls += ' col-' + size + '-' + settings[size];
9526 var inputblock = input;
9528 if(this.hasFeedback && !this.allowBlank){
9532 cls: 'glyphicon form-control-feedback'
9536 cls : 'has-feedback',
9545 if (this.before || this.after) {
9548 cls : 'input-group',
9552 inputblock.cn.push({
9554 cls : 'input-group-addon',
9559 inputblock.cn.push(input);
9561 if(this.hasFeedback && !this.allowBlank){
9562 inputblock.cls += ' has-feedback';
9563 inputblock.cn.push(feedback);
9567 inputblock.cn.push({
9569 cls : 'input-group-addon',
9576 if (align ==='left' && this.fieldLabel.length) {
9581 cls : 'control-label',
9582 html : this.fieldLabel
9593 if(this.labelWidth > 12){
9594 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9597 if(this.labelWidth < 13 && this.labelmd == 0){
9598 this.labelmd = this.labelWidth;
9601 if(this.labellg > 0){
9602 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9603 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9606 if(this.labelmd > 0){
9607 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9608 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9611 if(this.labelsm > 0){
9612 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9613 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9616 if(this.labelxs > 0){
9617 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9618 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9621 } else if ( this.fieldLabel.length) {
9626 //cls : 'input-group-addon',
9627 html : this.fieldLabel
9645 if (this.disabled) {
9646 input.disabled=true;
9653 * return the real textarea element.
9655 inputEl: function ()
9657 return this.el.select('textarea.form-control',true).first();
9661 * Clear any invalid styles/messages for this field
9663 clearInvalid : function()
9666 if(!this.el || this.preventMark){ // not rendered
9670 var label = this.el.select('label', true).first();
9671 var icon = this.el.select('i.fa-star', true).first();
9677 this.el.removeClass(this.invalidClass);
9679 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9681 var feedback = this.el.select('.form-control-feedback', true).first();
9684 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9689 this.fireEvent('valid', this);
9693 * Mark this field as valid
9695 markValid : function()
9697 if(!this.el || this.preventMark){ // not rendered
9701 this.el.removeClass([this.invalidClass, this.validClass]);
9703 var feedback = this.el.select('.form-control-feedback', true).first();
9706 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9709 if(this.disabled || this.allowBlank){
9713 var label = this.el.select('label', true).first();
9714 var icon = this.el.select('i.fa-star', true).first();
9720 this.el.addClass(this.validClass);
9722 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9724 var feedback = this.el.select('.form-control-feedback', true).first();
9727 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9728 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9733 this.fireEvent('valid', this);
9737 * Mark this field as invalid
9738 * @param {String} msg The validation message
9740 markInvalid : function(msg)
9742 if(!this.el || this.preventMark){ // not rendered
9746 this.el.removeClass([this.invalidClass, this.validClass]);
9748 var feedback = this.el.select('.form-control-feedback', true).first();
9751 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9754 if(this.disabled || this.allowBlank){
9758 var label = this.el.select('label', true).first();
9759 var icon = this.el.select('i.fa-star', true).first();
9761 if(!this.getValue().length && label && !icon){
9762 this.el.createChild({
9764 cls : 'text-danger fa fa-lg fa-star',
9765 tooltip : 'This field is required',
9766 style : 'margin-right:5px;'
9770 this.el.addClass(this.invalidClass);
9772 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9774 var feedback = this.el.select('.form-control-feedback', true).first();
9777 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9779 if(this.getValue().length || this.forceFeedback){
9780 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9787 this.fireEvent('invalid', this, msg);
9795 * trigger field - base class for combo..
9800 * @class Roo.bootstrap.TriggerField
9801 * @extends Roo.bootstrap.Input
9802 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9803 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9804 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9805 * for which you can provide a custom implementation. For example:
9807 var trigger = new Roo.bootstrap.TriggerField();
9808 trigger.onTriggerClick = myTriggerFn;
9809 trigger.applyTo('my-field');
9812 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9813 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9814 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9815 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9816 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9819 * Create a new TriggerField.
9820 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9821 * to the base TextField)
9823 Roo.bootstrap.TriggerField = function(config){
9824 this.mimicing = false;
9825 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9828 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9830 * @cfg {String} triggerClass A CSS class to apply to the trigger
9833 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9838 * @cfg {Boolean} removable (true|false) special filter default false
9842 /** @cfg {Boolean} grow @hide */
9843 /** @cfg {Number} growMin @hide */
9844 /** @cfg {Number} growMax @hide */
9850 autoSize: Roo.emptyFn,
9857 actionMode : 'wrap',
9862 getAutoCreate : function(){
9864 var align = this.labelAlign || this.parentLabelAlign();
9869 cls: 'form-group' //input-group
9876 type : this.inputType,
9877 cls : 'form-control',
9878 autocomplete: 'new-password',
9879 placeholder : this.placeholder || ''
9883 input.name = this.name;
9886 input.cls += ' input-' + this.size;
9889 if (this.disabled) {
9890 input.disabled=true;
9893 var inputblock = input;
9895 if(this.hasFeedback && !this.allowBlank){
9899 cls: 'glyphicon form-control-feedback'
9902 if(this.removable && !this.editable && !this.tickable){
9904 cls : 'has-feedback',
9910 cls : 'roo-combo-removable-btn close'
9917 cls : 'has-feedback',
9926 if(this.removable && !this.editable && !this.tickable){
9928 cls : 'roo-removable',
9934 cls : 'roo-combo-removable-btn close'
9941 if (this.before || this.after) {
9944 cls : 'input-group',
9948 inputblock.cn.push({
9950 cls : 'input-group-addon',
9955 inputblock.cn.push(input);
9957 if(this.hasFeedback && !this.allowBlank){
9958 inputblock.cls += ' has-feedback';
9959 inputblock.cn.push(feedback);
9963 inputblock.cn.push({
9965 cls : 'input-group-addon',
9978 cls: 'form-hidden-field'
9992 cls: 'form-hidden-field'
9996 cls: 'roo-select2-choices',
10000 cls: 'roo-select2-search-field',
10013 cls: 'roo-select2-container input-group',
10018 // cls: 'typeahead typeahead-long dropdown-menu',
10019 // style: 'display:none'
10024 if(!this.multiple && this.showToggleBtn){
10030 if (this.caret != false) {
10033 cls: 'fa fa-' + this.caret
10040 cls : 'input-group-addon btn dropdown-toggle',
10045 cls: 'combobox-clear',
10059 combobox.cls += ' roo-select2-container-multi';
10062 if (align ==='left' && this.fieldLabel.length) {
10064 cfg.cls += ' roo-form-group-label-left';
10069 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10070 tooltip : 'This field is required'
10075 cls : 'control-label',
10076 html : this.fieldLabel
10088 var labelCfg = cfg.cn[1];
10089 var contentCfg = cfg.cn[2];
10091 if(this.indicatorpos == 'right'){
10096 cls : 'control-label',
10100 html : this.fieldLabel
10104 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10105 tooltip : 'This field is required'
10118 labelCfg = cfg.cn[0];
10119 contentCfg = cfg.cn[1];
10122 if(this.labelWidth > 12){
10123 labelCfg.style = "width: " + this.labelWidth + 'px';
10126 if(this.labelWidth < 13 && this.labelmd == 0){
10127 this.labelmd = this.labelWidth;
10130 if(this.labellg > 0){
10131 labelCfg.cls += ' col-lg-' + this.labellg;
10132 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10135 if(this.labelmd > 0){
10136 labelCfg.cls += ' col-md-' + this.labelmd;
10137 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10140 if(this.labelsm > 0){
10141 labelCfg.cls += ' col-sm-' + this.labelsm;
10142 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10145 if(this.labelxs > 0){
10146 labelCfg.cls += ' col-xs-' + this.labelxs;
10147 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10150 } else if ( this.fieldLabel.length) {
10151 // Roo.log(" label");
10155 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10156 tooltip : 'This field is required'
10160 //cls : 'input-group-addon',
10161 html : this.fieldLabel
10169 if(this.indicatorpos == 'right'){
10177 html : this.fieldLabel
10181 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10182 tooltip : 'This field is required'
10195 // Roo.log(" no label && no align");
10202 ['xs','sm','md','lg'].map(function(size){
10203 if (settings[size]) {
10204 cfg.cls += ' col-' + size + '-' + settings[size];
10215 onResize : function(w, h){
10216 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10217 // if(typeof w == 'number'){
10218 // var x = w - this.trigger.getWidth();
10219 // this.inputEl().setWidth(this.adjustWidth('input', x));
10220 // this.trigger.setStyle('left', x+'px');
10225 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10228 getResizeEl : function(){
10229 return this.inputEl();
10233 getPositionEl : function(){
10234 return this.inputEl();
10238 alignErrorIcon : function(){
10239 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10243 initEvents : function(){
10247 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10248 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10249 if(!this.multiple && this.showToggleBtn){
10250 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10251 if(this.hideTrigger){
10252 this.trigger.setDisplayed(false);
10254 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10258 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10261 if(this.removable && !this.editable && !this.tickable){
10262 var close = this.closeTriggerEl();
10265 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10266 close.on('click', this.removeBtnClick, this, close);
10270 //this.trigger.addClassOnOver('x-form-trigger-over');
10271 //this.trigger.addClassOnClick('x-form-trigger-click');
10274 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10278 closeTriggerEl : function()
10280 var close = this.el.select('.roo-combo-removable-btn', true).first();
10281 return close ? close : false;
10284 removeBtnClick : function(e, h, el)
10286 e.preventDefault();
10288 if(this.fireEvent("remove", this) !== false){
10290 this.fireEvent("afterremove", this)
10294 createList : function()
10296 this.list = Roo.get(document.body).createChild({
10298 cls: 'typeahead typeahead-long dropdown-menu',
10299 style: 'display:none'
10302 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10307 initTrigger : function(){
10312 onDestroy : function(){
10314 this.trigger.removeAllListeners();
10315 // this.trigger.remove();
10318 // this.wrap.remove();
10320 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10324 onFocus : function(){
10325 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10327 if(!this.mimicing){
10328 this.wrap.addClass('x-trigger-wrap-focus');
10329 this.mimicing = true;
10330 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10331 if(this.monitorTab){
10332 this.el.on("keydown", this.checkTab, this);
10339 checkTab : function(e){
10340 if(e.getKey() == e.TAB){
10341 this.triggerBlur();
10346 onBlur : function(){
10351 mimicBlur : function(e, t){
10353 if(!this.wrap.contains(t) && this.validateBlur()){
10354 this.triggerBlur();
10360 triggerBlur : function(){
10361 this.mimicing = false;
10362 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10363 if(this.monitorTab){
10364 this.el.un("keydown", this.checkTab, this);
10366 //this.wrap.removeClass('x-trigger-wrap-focus');
10367 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10371 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10372 validateBlur : function(e, t){
10377 onDisable : function(){
10378 this.inputEl().dom.disabled = true;
10379 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10381 // this.wrap.addClass('x-item-disabled');
10386 onEnable : function(){
10387 this.inputEl().dom.disabled = false;
10388 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10390 // this.el.removeClass('x-item-disabled');
10395 onShow : function(){
10396 var ae = this.getActionEl();
10399 ae.dom.style.display = '';
10400 ae.dom.style.visibility = 'visible';
10406 onHide : function(){
10407 var ae = this.getActionEl();
10408 ae.dom.style.display = 'none';
10412 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10413 * by an implementing function.
10415 * @param {EventObject} e
10417 onTriggerClick : Roo.emptyFn
10421 * Ext JS Library 1.1.1
10422 * Copyright(c) 2006-2007, Ext JS, LLC.
10424 * Originally Released Under LGPL - original licence link has changed is not relivant.
10427 * <script type="text/javascript">
10432 * @class Roo.data.SortTypes
10434 * Defines the default sorting (casting?) comparison functions used when sorting data.
10436 Roo.data.SortTypes = {
10438 * Default sort that does nothing
10439 * @param {Mixed} s The value being converted
10440 * @return {Mixed} The comparison value
10442 none : function(s){
10447 * The regular expression used to strip tags
10451 stripTagsRE : /<\/?[^>]+>/gi,
10454 * Strips all HTML tags to sort on text only
10455 * @param {Mixed} s The value being converted
10456 * @return {String} The comparison value
10458 asText : function(s){
10459 return String(s).replace(this.stripTagsRE, "");
10463 * Strips all HTML tags to sort on text only - Case insensitive
10464 * @param {Mixed} s The value being converted
10465 * @return {String} The comparison value
10467 asUCText : function(s){
10468 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10472 * Case insensitive string
10473 * @param {Mixed} s The value being converted
10474 * @return {String} The comparison value
10476 asUCString : function(s) {
10477 return String(s).toUpperCase();
10482 * @param {Mixed} s The value being converted
10483 * @return {Number} The comparison value
10485 asDate : function(s) {
10489 if(s instanceof Date){
10490 return s.getTime();
10492 return Date.parse(String(s));
10497 * @param {Mixed} s The value being converted
10498 * @return {Float} The comparison value
10500 asFloat : function(s) {
10501 var val = parseFloat(String(s).replace(/,/g, ""));
10510 * @param {Mixed} s The value being converted
10511 * @return {Number} The comparison value
10513 asInt : function(s) {
10514 var val = parseInt(String(s).replace(/,/g, ""));
10522 * Ext JS Library 1.1.1
10523 * Copyright(c) 2006-2007, Ext JS, LLC.
10525 * Originally Released Under LGPL - original licence link has changed is not relivant.
10528 * <script type="text/javascript">
10532 * @class Roo.data.Record
10533 * Instances of this class encapsulate both record <em>definition</em> information, and record
10534 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10535 * to access Records cached in an {@link Roo.data.Store} object.<br>
10537 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10538 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10541 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10543 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10544 * {@link #create}. The parameters are the same.
10545 * @param {Array} data An associative Array of data values keyed by the field name.
10546 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10547 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10548 * not specified an integer id is generated.
10550 Roo.data.Record = function(data, id){
10551 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10556 * Generate a constructor for a specific record layout.
10557 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10558 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10559 * Each field definition object may contain the following properties: <ul>
10560 * <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,
10561 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10562 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10563 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10564 * is being used, then this is a string containing the javascript expression to reference the data relative to
10565 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10566 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10567 * this may be omitted.</p></li>
10568 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10569 * <ul><li>auto (Default, implies no conversion)</li>
10574 * <li>date</li></ul></p></li>
10575 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10576 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10577 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10578 * by the Reader into an object that will be stored in the Record. It is passed the
10579 * following parameters:<ul>
10580 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10582 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10584 * <br>usage:<br><pre><code>
10585 var TopicRecord = Roo.data.Record.create(
10586 {name: 'title', mapping: 'topic_title'},
10587 {name: 'author', mapping: 'username'},
10588 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10589 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10590 {name: 'lastPoster', mapping: 'user2'},
10591 {name: 'excerpt', mapping: 'post_text'}
10594 var myNewRecord = new TopicRecord({
10595 title: 'Do my job please',
10598 lastPost: new Date(),
10599 lastPoster: 'Animal',
10600 excerpt: 'No way dude!'
10602 myStore.add(myNewRecord);
10607 Roo.data.Record.create = function(o){
10608 var f = function(){
10609 f.superclass.constructor.apply(this, arguments);
10611 Roo.extend(f, Roo.data.Record);
10612 var p = f.prototype;
10613 p.fields = new Roo.util.MixedCollection(false, function(field){
10616 for(var i = 0, len = o.length; i < len; i++){
10617 p.fields.add(new Roo.data.Field(o[i]));
10619 f.getField = function(name){
10620 return p.fields.get(name);
10625 Roo.data.Record.AUTO_ID = 1000;
10626 Roo.data.Record.EDIT = 'edit';
10627 Roo.data.Record.REJECT = 'reject';
10628 Roo.data.Record.COMMIT = 'commit';
10630 Roo.data.Record.prototype = {
10632 * Readonly flag - true if this record has been modified.
10641 join : function(store){
10642 this.store = store;
10646 * Set the named field to the specified value.
10647 * @param {String} name The name of the field to set.
10648 * @param {Object} value The value to set the field to.
10650 set : function(name, value){
10651 if(this.data[name] == value){
10655 if(!this.modified){
10656 this.modified = {};
10658 if(typeof this.modified[name] == 'undefined'){
10659 this.modified[name] = this.data[name];
10661 this.data[name] = value;
10662 if(!this.editing && this.store){
10663 this.store.afterEdit(this);
10668 * Get the value of the named field.
10669 * @param {String} name The name of the field to get the value of.
10670 * @return {Object} The value of the field.
10672 get : function(name){
10673 return this.data[name];
10677 beginEdit : function(){
10678 this.editing = true;
10679 this.modified = {};
10683 cancelEdit : function(){
10684 this.editing = false;
10685 delete this.modified;
10689 endEdit : function(){
10690 this.editing = false;
10691 if(this.dirty && this.store){
10692 this.store.afterEdit(this);
10697 * Usually called by the {@link Roo.data.Store} which owns the Record.
10698 * Rejects all changes made to the Record since either creation, or the last commit operation.
10699 * Modified fields are reverted to their original values.
10701 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10702 * of reject operations.
10704 reject : function(){
10705 var m = this.modified;
10707 if(typeof m[n] != "function"){
10708 this.data[n] = m[n];
10711 this.dirty = false;
10712 delete this.modified;
10713 this.editing = false;
10715 this.store.afterReject(this);
10720 * Usually called by the {@link Roo.data.Store} which owns the Record.
10721 * Commits all changes made to the Record since either creation, or the last commit operation.
10723 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10724 * of commit operations.
10726 commit : function(){
10727 this.dirty = false;
10728 delete this.modified;
10729 this.editing = false;
10731 this.store.afterCommit(this);
10736 hasError : function(){
10737 return this.error != null;
10741 clearError : function(){
10746 * Creates a copy of this record.
10747 * @param {String} id (optional) A new record id if you don't want to use this record's id
10750 copy : function(newId) {
10751 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10755 * Ext JS Library 1.1.1
10756 * Copyright(c) 2006-2007, Ext JS, LLC.
10758 * Originally Released Under LGPL - original licence link has changed is not relivant.
10761 * <script type="text/javascript">
10767 * @class Roo.data.Store
10768 * @extends Roo.util.Observable
10769 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10770 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10772 * 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
10773 * has no knowledge of the format of the data returned by the Proxy.<br>
10775 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10776 * instances from the data object. These records are cached and made available through accessor functions.
10778 * Creates a new Store.
10779 * @param {Object} config A config object containing the objects needed for the Store to access data,
10780 * and read the data into Records.
10782 Roo.data.Store = function(config){
10783 this.data = new Roo.util.MixedCollection(false);
10784 this.data.getKey = function(o){
10787 this.baseParams = {};
10789 this.paramNames = {
10794 "multisort" : "_multisort"
10797 if(config && config.data){
10798 this.inlineData = config.data;
10799 delete config.data;
10802 Roo.apply(this, config);
10804 if(this.reader){ // reader passed
10805 this.reader = Roo.factory(this.reader, Roo.data);
10806 this.reader.xmodule = this.xmodule || false;
10807 if(!this.recordType){
10808 this.recordType = this.reader.recordType;
10810 if(this.reader.onMetaChange){
10811 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10815 if(this.recordType){
10816 this.fields = this.recordType.prototype.fields;
10818 this.modified = [];
10822 * @event datachanged
10823 * Fires when the data cache has changed, and a widget which is using this Store
10824 * as a Record cache should refresh its view.
10825 * @param {Store} this
10827 datachanged : true,
10829 * @event metachange
10830 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10831 * @param {Store} this
10832 * @param {Object} meta The JSON metadata
10837 * Fires when Records have been added to the Store
10838 * @param {Store} this
10839 * @param {Roo.data.Record[]} records The array of Records added
10840 * @param {Number} index The index at which the record(s) were added
10845 * Fires when a Record has been removed from the Store
10846 * @param {Store} this
10847 * @param {Roo.data.Record} record The Record that was removed
10848 * @param {Number} index The index at which the record was removed
10853 * Fires when a Record has been updated
10854 * @param {Store} this
10855 * @param {Roo.data.Record} record The Record that was updated
10856 * @param {String} operation The update operation being performed. Value may be one of:
10858 Roo.data.Record.EDIT
10859 Roo.data.Record.REJECT
10860 Roo.data.Record.COMMIT
10866 * Fires when the data cache has been cleared.
10867 * @param {Store} this
10871 * @event beforeload
10872 * Fires before a request is made for a new data object. If the beforeload handler returns false
10873 * the load action will be canceled.
10874 * @param {Store} this
10875 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10879 * @event beforeloadadd
10880 * Fires after a new set of Records has been loaded.
10881 * @param {Store} this
10882 * @param {Roo.data.Record[]} records The Records that were loaded
10883 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10885 beforeloadadd : true,
10888 * Fires after a new set of Records has been loaded, before they are added to the store.
10889 * @param {Store} this
10890 * @param {Roo.data.Record[]} records The Records that were loaded
10891 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10892 * @params {Object} return from reader
10896 * @event loadexception
10897 * Fires if an exception occurs in the Proxy during loading.
10898 * Called with the signature of the Proxy's "loadexception" event.
10899 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10902 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10903 * @param {Object} load options
10904 * @param {Object} jsonData from your request (normally this contains the Exception)
10906 loadexception : true
10910 this.proxy = Roo.factory(this.proxy, Roo.data);
10911 this.proxy.xmodule = this.xmodule || false;
10912 this.relayEvents(this.proxy, ["loadexception"]);
10914 this.sortToggle = {};
10915 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10917 Roo.data.Store.superclass.constructor.call(this);
10919 if(this.inlineData){
10920 this.loadData(this.inlineData);
10921 delete this.inlineData;
10925 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10927 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10928 * without a remote query - used by combo/forms at present.
10932 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10935 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10938 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10939 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10942 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10943 * on any HTTP request
10946 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10949 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10953 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10954 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10956 remoteSort : false,
10959 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10960 * loaded or when a record is removed. (defaults to false).
10962 pruneModifiedRecords : false,
10965 lastOptions : null,
10968 * Add Records to the Store and fires the add event.
10969 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10971 add : function(records){
10972 records = [].concat(records);
10973 for(var i = 0, len = records.length; i < len; i++){
10974 records[i].join(this);
10976 var index = this.data.length;
10977 this.data.addAll(records);
10978 this.fireEvent("add", this, records, index);
10982 * Remove a Record from the Store and fires the remove event.
10983 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10985 remove : function(record){
10986 var index = this.data.indexOf(record);
10987 this.data.removeAt(index);
10988 if(this.pruneModifiedRecords){
10989 this.modified.remove(record);
10991 this.fireEvent("remove", this, record, index);
10995 * Remove all Records from the Store and fires the clear event.
10997 removeAll : function(){
10999 if(this.pruneModifiedRecords){
11000 this.modified = [];
11002 this.fireEvent("clear", this);
11006 * Inserts Records to the Store at the given index and fires the add event.
11007 * @param {Number} index The start index at which to insert the passed Records.
11008 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11010 insert : function(index, records){
11011 records = [].concat(records);
11012 for(var i = 0, len = records.length; i < len; i++){
11013 this.data.insert(index, records[i]);
11014 records[i].join(this);
11016 this.fireEvent("add", this, records, index);
11020 * Get the index within the cache of the passed Record.
11021 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11022 * @return {Number} The index of the passed Record. Returns -1 if not found.
11024 indexOf : function(record){
11025 return this.data.indexOf(record);
11029 * Get the index within the cache of the Record with the passed id.
11030 * @param {String} id The id of the Record to find.
11031 * @return {Number} The index of the Record. Returns -1 if not found.
11033 indexOfId : function(id){
11034 return this.data.indexOfKey(id);
11038 * Get the Record with the specified id.
11039 * @param {String} id The id of the Record to find.
11040 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11042 getById : function(id){
11043 return this.data.key(id);
11047 * Get the Record at the specified index.
11048 * @param {Number} index The index of the Record to find.
11049 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11051 getAt : function(index){
11052 return this.data.itemAt(index);
11056 * Returns a range of Records between specified indices.
11057 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11058 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11059 * @return {Roo.data.Record[]} An array of Records
11061 getRange : function(start, end){
11062 return this.data.getRange(start, end);
11066 storeOptions : function(o){
11067 o = Roo.apply({}, o);
11070 this.lastOptions = o;
11074 * Loads the Record cache from the configured Proxy using the configured Reader.
11076 * If using remote paging, then the first load call must specify the <em>start</em>
11077 * and <em>limit</em> properties in the options.params property to establish the initial
11078 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11080 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11081 * and this call will return before the new data has been loaded. Perform any post-processing
11082 * in a callback function, or in a "load" event handler.</strong>
11084 * @param {Object} options An object containing properties which control loading options:<ul>
11085 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11086 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11087 * passed the following arguments:<ul>
11088 * <li>r : Roo.data.Record[]</li>
11089 * <li>options: Options object from the load call</li>
11090 * <li>success: Boolean success indicator</li></ul></li>
11091 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11092 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11095 load : function(options){
11096 options = options || {};
11097 if(this.fireEvent("beforeload", this, options) !== false){
11098 this.storeOptions(options);
11099 var p = Roo.apply(options.params || {}, this.baseParams);
11100 // if meta was not loaded from remote source.. try requesting it.
11101 if (!this.reader.metaFromRemote) {
11102 p._requestMeta = 1;
11104 if(this.sortInfo && this.remoteSort){
11105 var pn = this.paramNames;
11106 p[pn["sort"]] = this.sortInfo.field;
11107 p[pn["dir"]] = this.sortInfo.direction;
11109 if (this.multiSort) {
11110 var pn = this.paramNames;
11111 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11114 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11119 * Reloads the Record cache from the configured Proxy using the configured Reader and
11120 * the options from the last load operation performed.
11121 * @param {Object} options (optional) An object containing properties which may override the options
11122 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11123 * the most recently used options are reused).
11125 reload : function(options){
11126 this.load(Roo.applyIf(options||{}, this.lastOptions));
11130 // Called as a callback by the Reader during a load operation.
11131 loadRecords : function(o, options, success){
11132 if(!o || success === false){
11133 if(success !== false){
11134 this.fireEvent("load", this, [], options, o);
11136 if(options.callback){
11137 options.callback.call(options.scope || this, [], options, false);
11141 // if data returned failure - throw an exception.
11142 if (o.success === false) {
11143 // show a message if no listener is registered.
11144 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11145 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11147 // loadmask wil be hooked into this..
11148 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11151 var r = o.records, t = o.totalRecords || r.length;
11153 this.fireEvent("beforeloadadd", this, r, options, o);
11155 if(!options || options.add !== true){
11156 if(this.pruneModifiedRecords){
11157 this.modified = [];
11159 for(var i = 0, len = r.length; i < len; i++){
11163 this.data = this.snapshot;
11164 delete this.snapshot;
11167 this.data.addAll(r);
11168 this.totalLength = t;
11170 this.fireEvent("datachanged", this);
11172 this.totalLength = Math.max(t, this.data.length+r.length);
11176 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11178 var e = new Roo.data.Record({});
11180 e.set(this.parent.displayField, this.parent.emptyTitle);
11181 e.set(this.parent.valueField, '');
11186 this.fireEvent("load", this, r, options, o);
11187 if(options.callback){
11188 options.callback.call(options.scope || this, r, options, true);
11194 * Loads data from a passed data block. A Reader which understands the format of the data
11195 * must have been configured in the constructor.
11196 * @param {Object} data The data block from which to read the Records. The format of the data expected
11197 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11198 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11200 loadData : function(o, append){
11201 var r = this.reader.readRecords(o);
11202 this.loadRecords(r, {add: append}, true);
11206 * Gets the number of cached records.
11208 * <em>If using paging, this may not be the total size of the dataset. If the data object
11209 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11210 * the data set size</em>
11212 getCount : function(){
11213 return this.data.length || 0;
11217 * Gets the total number of records in the dataset as returned by the server.
11219 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11220 * the dataset size</em>
11222 getTotalCount : function(){
11223 return this.totalLength || 0;
11227 * Returns the sort state of the Store as an object with two properties:
11229 field {String} The name of the field by which the Records are sorted
11230 direction {String} The sort order, "ASC" or "DESC"
11233 getSortState : function(){
11234 return this.sortInfo;
11238 applySort : function(){
11239 if(this.sortInfo && !this.remoteSort){
11240 var s = this.sortInfo, f = s.field;
11241 var st = this.fields.get(f).sortType;
11242 var fn = function(r1, r2){
11243 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11244 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11246 this.data.sort(s.direction, fn);
11247 if(this.snapshot && this.snapshot != this.data){
11248 this.snapshot.sort(s.direction, fn);
11254 * Sets the default sort column and order to be used by the next load operation.
11255 * @param {String} fieldName The name of the field to sort by.
11256 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11258 setDefaultSort : function(field, dir){
11259 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11263 * Sort the Records.
11264 * If remote sorting is used, the sort is performed on the server, and the cache is
11265 * reloaded. If local sorting is used, the cache is sorted internally.
11266 * @param {String} fieldName The name of the field to sort by.
11267 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11269 sort : function(fieldName, dir){
11270 var f = this.fields.get(fieldName);
11272 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11274 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11275 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11280 this.sortToggle[f.name] = dir;
11281 this.sortInfo = {field: f.name, direction: dir};
11282 if(!this.remoteSort){
11284 this.fireEvent("datachanged", this);
11286 this.load(this.lastOptions);
11291 * Calls the specified function for each of the Records in the cache.
11292 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11293 * Returning <em>false</em> aborts and exits the iteration.
11294 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11296 each : function(fn, scope){
11297 this.data.each(fn, scope);
11301 * Gets all records modified since the last commit. Modified records are persisted across load operations
11302 * (e.g., during paging).
11303 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11305 getModifiedRecords : function(){
11306 return this.modified;
11310 createFilterFn : function(property, value, anyMatch){
11311 if(!value.exec){ // not a regex
11312 value = String(value);
11313 if(value.length == 0){
11316 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11318 return function(r){
11319 return value.test(r.data[property]);
11324 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11325 * @param {String} property A field on your records
11326 * @param {Number} start The record index to start at (defaults to 0)
11327 * @param {Number} end The last record index to include (defaults to length - 1)
11328 * @return {Number} The sum
11330 sum : function(property, start, end){
11331 var rs = this.data.items, v = 0;
11332 start = start || 0;
11333 end = (end || end === 0) ? end : rs.length-1;
11335 for(var i = start; i <= end; i++){
11336 v += (rs[i].data[property] || 0);
11342 * Filter the records by a specified property.
11343 * @param {String} field A field on your records
11344 * @param {String/RegExp} value Either a string that the field
11345 * should start with or a RegExp to test against the field
11346 * @param {Boolean} anyMatch True to match any part not just the beginning
11348 filter : function(property, value, anyMatch){
11349 var fn = this.createFilterFn(property, value, anyMatch);
11350 return fn ? this.filterBy(fn) : this.clearFilter();
11354 * Filter by a function. The specified function will be called with each
11355 * record in this data source. If the function returns true the record is included,
11356 * otherwise it is filtered.
11357 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11358 * @param {Object} scope (optional) The scope of the function (defaults to this)
11360 filterBy : function(fn, scope){
11361 this.snapshot = this.snapshot || this.data;
11362 this.data = this.queryBy(fn, scope||this);
11363 this.fireEvent("datachanged", this);
11367 * Query the records by a specified property.
11368 * @param {String} field A field on your records
11369 * @param {String/RegExp} value Either a string that the field
11370 * should start with or a RegExp to test against the field
11371 * @param {Boolean} anyMatch True to match any part not just the beginning
11372 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11374 query : function(property, value, anyMatch){
11375 var fn = this.createFilterFn(property, value, anyMatch);
11376 return fn ? this.queryBy(fn) : this.data.clone();
11380 * Query by a function. The specified function will be called with each
11381 * record in this data source. If the function returns true the record is included
11383 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11384 * @param {Object} scope (optional) The scope of the function (defaults to this)
11385 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11387 queryBy : function(fn, scope){
11388 var data = this.snapshot || this.data;
11389 return data.filterBy(fn, scope||this);
11393 * Collects unique values for a particular dataIndex from this store.
11394 * @param {String} dataIndex The property to collect
11395 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11396 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11397 * @return {Array} An array of the unique values
11399 collect : function(dataIndex, allowNull, bypassFilter){
11400 var d = (bypassFilter === true && this.snapshot) ?
11401 this.snapshot.items : this.data.items;
11402 var v, sv, r = [], l = {};
11403 for(var i = 0, len = d.length; i < len; i++){
11404 v = d[i].data[dataIndex];
11406 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11415 * Revert to a view of the Record cache with no filtering applied.
11416 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11418 clearFilter : function(suppressEvent){
11419 if(this.snapshot && this.snapshot != this.data){
11420 this.data = this.snapshot;
11421 delete this.snapshot;
11422 if(suppressEvent !== true){
11423 this.fireEvent("datachanged", this);
11429 afterEdit : function(record){
11430 if(this.modified.indexOf(record) == -1){
11431 this.modified.push(record);
11433 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11437 afterReject : function(record){
11438 this.modified.remove(record);
11439 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11443 afterCommit : function(record){
11444 this.modified.remove(record);
11445 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11449 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11450 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11452 commitChanges : function(){
11453 var m = this.modified.slice(0);
11454 this.modified = [];
11455 for(var i = 0, len = m.length; i < len; i++){
11461 * Cancel outstanding changes on all changed records.
11463 rejectChanges : function(){
11464 var m = this.modified.slice(0);
11465 this.modified = [];
11466 for(var i = 0, len = m.length; i < len; i++){
11471 onMetaChange : function(meta, rtype, o){
11472 this.recordType = rtype;
11473 this.fields = rtype.prototype.fields;
11474 delete this.snapshot;
11475 this.sortInfo = meta.sortInfo || this.sortInfo;
11476 this.modified = [];
11477 this.fireEvent('metachange', this, this.reader.meta);
11480 moveIndex : function(data, type)
11482 var index = this.indexOf(data);
11484 var newIndex = index + type;
11488 this.insert(newIndex, data);
11493 * Ext JS Library 1.1.1
11494 * Copyright(c) 2006-2007, Ext JS, LLC.
11496 * Originally Released Under LGPL - original licence link has changed is not relivant.
11499 * <script type="text/javascript">
11503 * @class Roo.data.SimpleStore
11504 * @extends Roo.data.Store
11505 * Small helper class to make creating Stores from Array data easier.
11506 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11507 * @cfg {Array} fields An array of field definition objects, or field name strings.
11508 * @cfg {Array} data The multi-dimensional array of data
11510 * @param {Object} config
11512 Roo.data.SimpleStore = function(config){
11513 Roo.data.SimpleStore.superclass.constructor.call(this, {
11515 reader: new Roo.data.ArrayReader({
11518 Roo.data.Record.create(config.fields)
11520 proxy : new Roo.data.MemoryProxy(config.data)
11524 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11526 * Ext JS Library 1.1.1
11527 * Copyright(c) 2006-2007, Ext JS, LLC.
11529 * Originally Released Under LGPL - original licence link has changed is not relivant.
11532 * <script type="text/javascript">
11537 * @extends Roo.data.Store
11538 * @class Roo.data.JsonStore
11539 * Small helper class to make creating Stores for JSON data easier. <br/>
11541 var store = new Roo.data.JsonStore({
11542 url: 'get-images.php',
11544 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11547 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11548 * JsonReader and HttpProxy (unless inline data is provided).</b>
11549 * @cfg {Array} fields An array of field definition objects, or field name strings.
11551 * @param {Object} config
11553 Roo.data.JsonStore = function(c){
11554 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11555 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11556 reader: new Roo.data.JsonReader(c, c.fields)
11559 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11561 * Ext JS Library 1.1.1
11562 * Copyright(c) 2006-2007, Ext JS, LLC.
11564 * Originally Released Under LGPL - original licence link has changed is not relivant.
11567 * <script type="text/javascript">
11571 Roo.data.Field = function(config){
11572 if(typeof config == "string"){
11573 config = {name: config};
11575 Roo.apply(this, config);
11578 this.type = "auto";
11581 var st = Roo.data.SortTypes;
11582 // named sortTypes are supported, here we look them up
11583 if(typeof this.sortType == "string"){
11584 this.sortType = st[this.sortType];
11587 // set default sortType for strings and dates
11588 if(!this.sortType){
11591 this.sortType = st.asUCString;
11594 this.sortType = st.asDate;
11597 this.sortType = st.none;
11602 var stripRe = /[\$,%]/g;
11604 // prebuilt conversion function for this field, instead of
11605 // switching every time we're reading a value
11607 var cv, dateFormat = this.dateFormat;
11612 cv = function(v){ return v; };
11615 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11619 return v !== undefined && v !== null && v !== '' ?
11620 parseInt(String(v).replace(stripRe, ""), 10) : '';
11625 return v !== undefined && v !== null && v !== '' ?
11626 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11631 cv = function(v){ return v === true || v === "true" || v == 1; };
11638 if(v instanceof Date){
11642 if(dateFormat == "timestamp"){
11643 return new Date(v*1000);
11645 return Date.parseDate(v, dateFormat);
11647 var parsed = Date.parse(v);
11648 return parsed ? new Date(parsed) : null;
11657 Roo.data.Field.prototype = {
11665 * Ext JS Library 1.1.1
11666 * Copyright(c) 2006-2007, Ext JS, LLC.
11668 * Originally Released Under LGPL - original licence link has changed is not relivant.
11671 * <script type="text/javascript">
11674 // Base class for reading structured data from a data source. This class is intended to be
11675 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11678 * @class Roo.data.DataReader
11679 * Base class for reading structured data from a data source. This class is intended to be
11680 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11683 Roo.data.DataReader = function(meta, recordType){
11687 this.recordType = recordType instanceof Array ?
11688 Roo.data.Record.create(recordType) : recordType;
11691 Roo.data.DataReader.prototype = {
11693 * Create an empty record
11694 * @param {Object} data (optional) - overlay some values
11695 * @return {Roo.data.Record} record created.
11697 newRow : function(d) {
11699 this.recordType.prototype.fields.each(function(c) {
11701 case 'int' : da[c.name] = 0; break;
11702 case 'date' : da[c.name] = new Date(); break;
11703 case 'float' : da[c.name] = 0.0; break;
11704 case 'boolean' : da[c.name] = false; break;
11705 default : da[c.name] = ""; break;
11709 return new this.recordType(Roo.apply(da, d));
11714 * Ext JS Library 1.1.1
11715 * Copyright(c) 2006-2007, Ext JS, LLC.
11717 * Originally Released Under LGPL - original licence link has changed is not relivant.
11720 * <script type="text/javascript">
11724 * @class Roo.data.DataProxy
11725 * @extends Roo.data.Observable
11726 * This class is an abstract base class for implementations which provide retrieval of
11727 * unformatted data objects.<br>
11729 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11730 * (of the appropriate type which knows how to parse the data object) to provide a block of
11731 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11733 * Custom implementations must implement the load method as described in
11734 * {@link Roo.data.HttpProxy#load}.
11736 Roo.data.DataProxy = function(){
11739 * @event beforeload
11740 * Fires before a network request is made to retrieve a data object.
11741 * @param {Object} This DataProxy object.
11742 * @param {Object} params The params parameter to the load function.
11747 * Fires before the load method's callback is called.
11748 * @param {Object} This DataProxy object.
11749 * @param {Object} o The data object.
11750 * @param {Object} arg The callback argument object passed to the load function.
11754 * @event loadexception
11755 * Fires if an Exception occurs during data retrieval.
11756 * @param {Object} This DataProxy object.
11757 * @param {Object} o The data object.
11758 * @param {Object} arg The callback argument object passed to the load function.
11759 * @param {Object} e The Exception.
11761 loadexception : true
11763 Roo.data.DataProxy.superclass.constructor.call(this);
11766 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11769 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11773 * Ext JS Library 1.1.1
11774 * Copyright(c) 2006-2007, Ext JS, LLC.
11776 * Originally Released Under LGPL - original licence link has changed is not relivant.
11779 * <script type="text/javascript">
11782 * @class Roo.data.MemoryProxy
11783 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11784 * to the Reader when its load method is called.
11786 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11788 Roo.data.MemoryProxy = function(data){
11792 Roo.data.MemoryProxy.superclass.constructor.call(this);
11796 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11799 * Load data from the requested source (in this case an in-memory
11800 * data object passed to the constructor), read the data object into
11801 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11802 * process that block using the passed callback.
11803 * @param {Object} params This parameter is not used by the MemoryProxy class.
11804 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11805 * object into a block of Roo.data.Records.
11806 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11807 * The function must be passed <ul>
11808 * <li>The Record block object</li>
11809 * <li>The "arg" argument from the load function</li>
11810 * <li>A boolean success indicator</li>
11812 * @param {Object} scope The scope in which to call the callback
11813 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11815 load : function(params, reader, callback, scope, arg){
11816 params = params || {};
11819 result = reader.readRecords(this.data);
11821 this.fireEvent("loadexception", this, arg, null, e);
11822 callback.call(scope, null, arg, false);
11825 callback.call(scope, result, arg, true);
11829 update : function(params, records){
11834 * Ext JS Library 1.1.1
11835 * Copyright(c) 2006-2007, Ext JS, LLC.
11837 * Originally Released Under LGPL - original licence link has changed is not relivant.
11840 * <script type="text/javascript">
11843 * @class Roo.data.HttpProxy
11844 * @extends Roo.data.DataProxy
11845 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11846 * configured to reference a certain URL.<br><br>
11848 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11849 * from which the running page was served.<br><br>
11851 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11853 * Be aware that to enable the browser to parse an XML document, the server must set
11854 * the Content-Type header in the HTTP response to "text/xml".
11856 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11857 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11858 * will be used to make the request.
11860 Roo.data.HttpProxy = function(conn){
11861 Roo.data.HttpProxy.superclass.constructor.call(this);
11862 // is conn a conn config or a real conn?
11864 this.useAjax = !conn || !conn.events;
11868 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11869 // thse are take from connection...
11872 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11875 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11876 * extra parameters to each request made by this object. (defaults to undefined)
11879 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11880 * to each request made by this object. (defaults to undefined)
11883 * @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)
11886 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11889 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11895 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11899 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11900 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11901 * a finer-grained basis than the DataProxy events.
11903 getConnection : function(){
11904 return this.useAjax ? Roo.Ajax : this.conn;
11908 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11909 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11910 * process that block using the passed callback.
11911 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11912 * for the request to the remote server.
11913 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11914 * object into a block of Roo.data.Records.
11915 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11916 * The function must be passed <ul>
11917 * <li>The Record block object</li>
11918 * <li>The "arg" argument from the load function</li>
11919 * <li>A boolean success indicator</li>
11921 * @param {Object} scope The scope in which to call the callback
11922 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11924 load : function(params, reader, callback, scope, arg){
11925 if(this.fireEvent("beforeload", this, params) !== false){
11927 params : params || {},
11929 callback : callback,
11934 callback : this.loadResponse,
11938 Roo.applyIf(o, this.conn);
11939 if(this.activeRequest){
11940 Roo.Ajax.abort(this.activeRequest);
11942 this.activeRequest = Roo.Ajax.request(o);
11944 this.conn.request(o);
11947 callback.call(scope||this, null, arg, false);
11952 loadResponse : function(o, success, response){
11953 delete this.activeRequest;
11955 this.fireEvent("loadexception", this, o, response);
11956 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11961 result = o.reader.read(response);
11963 this.fireEvent("loadexception", this, o, response, e);
11964 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11968 this.fireEvent("load", this, o, o.request.arg);
11969 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11973 update : function(dataSet){
11978 updateResponse : function(dataSet){
11983 * Ext JS Library 1.1.1
11984 * Copyright(c) 2006-2007, Ext JS, LLC.
11986 * Originally Released Under LGPL - original licence link has changed is not relivant.
11989 * <script type="text/javascript">
11993 * @class Roo.data.ScriptTagProxy
11994 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11995 * other than the originating domain of the running page.<br><br>
11997 * <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
11998 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12000 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12001 * source code that is used as the source inside a <script> tag.<br><br>
12003 * In order for the browser to process the returned data, the server must wrap the data object
12004 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12005 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12006 * depending on whether the callback name was passed:
12009 boolean scriptTag = false;
12010 String cb = request.getParameter("callback");
12013 response.setContentType("text/javascript");
12015 response.setContentType("application/x-json");
12017 Writer out = response.getWriter();
12019 out.write(cb + "(");
12021 out.print(dataBlock.toJsonString());
12028 * @param {Object} config A configuration object.
12030 Roo.data.ScriptTagProxy = function(config){
12031 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12032 Roo.apply(this, config);
12033 this.head = document.getElementsByTagName("head")[0];
12036 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12038 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12040 * @cfg {String} url The URL from which to request the data object.
12043 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12047 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12048 * the server the name of the callback function set up by the load call to process the returned data object.
12049 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12050 * javascript output which calls this named function passing the data object as its only parameter.
12052 callbackParam : "callback",
12054 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12055 * name to the request.
12060 * Load data from the configured URL, read the data object into
12061 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12062 * process that block using the passed callback.
12063 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12064 * for the request to the remote server.
12065 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12066 * object into a block of Roo.data.Records.
12067 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12068 * The function must be passed <ul>
12069 * <li>The Record block object</li>
12070 * <li>The "arg" argument from the load function</li>
12071 * <li>A boolean success indicator</li>
12073 * @param {Object} scope The scope in which to call the callback
12074 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12076 load : function(params, reader, callback, scope, arg){
12077 if(this.fireEvent("beforeload", this, params) !== false){
12079 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12081 var url = this.url;
12082 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12084 url += "&_dc=" + (new Date().getTime());
12086 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12089 cb : "stcCallback"+transId,
12090 scriptId : "stcScript"+transId,
12094 callback : callback,
12100 window[trans.cb] = function(o){
12101 conn.handleResponse(o, trans);
12104 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12106 if(this.autoAbort !== false){
12110 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12112 var script = document.createElement("script");
12113 script.setAttribute("src", url);
12114 script.setAttribute("type", "text/javascript");
12115 script.setAttribute("id", trans.scriptId);
12116 this.head.appendChild(script);
12118 this.trans = trans;
12120 callback.call(scope||this, null, arg, false);
12125 isLoading : function(){
12126 return this.trans ? true : false;
12130 * Abort the current server request.
12132 abort : function(){
12133 if(this.isLoading()){
12134 this.destroyTrans(this.trans);
12139 destroyTrans : function(trans, isLoaded){
12140 this.head.removeChild(document.getElementById(trans.scriptId));
12141 clearTimeout(trans.timeoutId);
12143 window[trans.cb] = undefined;
12145 delete window[trans.cb];
12148 // if hasn't been loaded, wait for load to remove it to prevent script error
12149 window[trans.cb] = function(){
12150 window[trans.cb] = undefined;
12152 delete window[trans.cb];
12159 handleResponse : function(o, trans){
12160 this.trans = false;
12161 this.destroyTrans(trans, true);
12164 result = trans.reader.readRecords(o);
12166 this.fireEvent("loadexception", this, o, trans.arg, e);
12167 trans.callback.call(trans.scope||window, null, trans.arg, false);
12170 this.fireEvent("load", this, o, trans.arg);
12171 trans.callback.call(trans.scope||window, result, trans.arg, true);
12175 handleFailure : function(trans){
12176 this.trans = false;
12177 this.destroyTrans(trans, false);
12178 this.fireEvent("loadexception", this, null, trans.arg);
12179 trans.callback.call(trans.scope||window, null, trans.arg, false);
12183 * Ext JS Library 1.1.1
12184 * Copyright(c) 2006-2007, Ext JS, LLC.
12186 * Originally Released Under LGPL - original licence link has changed is not relivant.
12189 * <script type="text/javascript">
12193 * @class Roo.data.JsonReader
12194 * @extends Roo.data.DataReader
12195 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12196 * based on mappings in a provided Roo.data.Record constructor.
12198 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12199 * in the reply previously.
12204 var RecordDef = Roo.data.Record.create([
12205 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12206 {name: 'occupation'} // This field will use "occupation" as the mapping.
12208 var myReader = new Roo.data.JsonReader({
12209 totalProperty: "results", // The property which contains the total dataset size (optional)
12210 root: "rows", // The property which contains an Array of row objects
12211 id: "id" // The property within each row object that provides an ID for the record (optional)
12215 * This would consume a JSON file like this:
12217 { 'results': 2, 'rows': [
12218 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12219 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12222 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12223 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12224 * paged from the remote server.
12225 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12226 * @cfg {String} root name of the property which contains the Array of row objects.
12227 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12228 * @cfg {Array} fields Array of field definition objects
12230 * Create a new JsonReader
12231 * @param {Object} meta Metadata configuration options
12232 * @param {Object} recordType Either an Array of field definition objects,
12233 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12235 Roo.data.JsonReader = function(meta, recordType){
12238 // set some defaults:
12239 Roo.applyIf(meta, {
12240 totalProperty: 'total',
12241 successProperty : 'success',
12246 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12248 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12251 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12252 * Used by Store query builder to append _requestMeta to params.
12255 metaFromRemote : false,
12257 * This method is only used by a DataProxy which has retrieved data from a remote server.
12258 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12259 * @return {Object} data A data block which is used by an Roo.data.Store object as
12260 * a cache of Roo.data.Records.
12262 read : function(response){
12263 var json = response.responseText;
12265 var o = /* eval:var:o */ eval("("+json+")");
12267 throw {message: "JsonReader.read: Json object not found"};
12273 this.metaFromRemote = true;
12274 this.meta = o.metaData;
12275 this.recordType = Roo.data.Record.create(o.metaData.fields);
12276 this.onMetaChange(this.meta, this.recordType, o);
12278 return this.readRecords(o);
12281 // private function a store will implement
12282 onMetaChange : function(meta, recordType, o){
12289 simpleAccess: function(obj, subsc) {
12296 getJsonAccessor: function(){
12298 return function(expr) {
12300 return(re.test(expr))
12301 ? new Function("obj", "return obj." + expr)
12306 return Roo.emptyFn;
12311 * Create a data block containing Roo.data.Records from an XML document.
12312 * @param {Object} o An object which contains an Array of row objects in the property specified
12313 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12314 * which contains the total size of the dataset.
12315 * @return {Object} data A data block which is used by an Roo.data.Store object as
12316 * a cache of Roo.data.Records.
12318 readRecords : function(o){
12320 * After any data loads, the raw JSON data is available for further custom processing.
12324 var s = this.meta, Record = this.recordType,
12325 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12327 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12329 if(s.totalProperty) {
12330 this.getTotal = this.getJsonAccessor(s.totalProperty);
12332 if(s.successProperty) {
12333 this.getSuccess = this.getJsonAccessor(s.successProperty);
12335 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12337 var g = this.getJsonAccessor(s.id);
12338 this.getId = function(rec) {
12340 return (r === undefined || r === "") ? null : r;
12343 this.getId = function(){return null;};
12346 for(var jj = 0; jj < fl; jj++){
12348 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12349 this.ef[jj] = this.getJsonAccessor(map);
12353 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12354 if(s.totalProperty){
12355 var vt = parseInt(this.getTotal(o), 10);
12360 if(s.successProperty){
12361 var vs = this.getSuccess(o);
12362 if(vs === false || vs === 'false'){
12367 for(var i = 0; i < c; i++){
12370 var id = this.getId(n);
12371 for(var j = 0; j < fl; j++){
12373 var v = this.ef[j](n);
12375 Roo.log('missing convert for ' + f.name);
12379 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12381 var record = new Record(values, id);
12383 records[i] = record;
12389 totalRecords : totalRecords
12394 * Ext JS Library 1.1.1
12395 * Copyright(c) 2006-2007, Ext JS, LLC.
12397 * Originally Released Under LGPL - original licence link has changed is not relivant.
12400 * <script type="text/javascript">
12404 * @class Roo.data.ArrayReader
12405 * @extends Roo.data.DataReader
12406 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12407 * Each element of that Array represents a row of data fields. The
12408 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12409 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12413 var RecordDef = Roo.data.Record.create([
12414 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12415 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12417 var myReader = new Roo.data.ArrayReader({
12418 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12422 * This would consume an Array like this:
12424 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12426 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12428 * Create a new JsonReader
12429 * @param {Object} meta Metadata configuration options.
12430 * @param {Object} recordType Either an Array of field definition objects
12431 * as specified to {@link Roo.data.Record#create},
12432 * or an {@link Roo.data.Record} object
12433 * created using {@link Roo.data.Record#create}.
12435 Roo.data.ArrayReader = function(meta, recordType){
12436 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12439 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12441 * Create a data block containing Roo.data.Records from an XML document.
12442 * @param {Object} o An Array of row objects which represents the dataset.
12443 * @return {Object} data A data block which is used by an Roo.data.Store object as
12444 * a cache of Roo.data.Records.
12446 readRecords : function(o){
12447 var sid = this.meta ? this.meta.id : null;
12448 var recordType = this.recordType, fields = recordType.prototype.fields;
12451 for(var i = 0; i < root.length; i++){
12454 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12455 for(var j = 0, jlen = fields.length; j < jlen; j++){
12456 var f = fields.items[j];
12457 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12458 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12460 values[f.name] = v;
12462 var record = new recordType(values, id);
12464 records[records.length] = record;
12468 totalRecords : records.length
12477 * @class Roo.bootstrap.ComboBox
12478 * @extends Roo.bootstrap.TriggerField
12479 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12480 * @cfg {Boolean} append (true|false) default false
12481 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12482 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12483 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12484 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12485 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12486 * @cfg {Boolean} animate default true
12487 * @cfg {Boolean} emptyResultText only for touch device
12488 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12489 * @cfg {String} emptyTitle default ''
12491 * Create a new ComboBox.
12492 * @param {Object} config Configuration options
12494 Roo.bootstrap.ComboBox = function(config){
12495 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12499 * Fires when the dropdown list is expanded
12500 * @param {Roo.bootstrap.ComboBox} combo This combo box
12505 * Fires when the dropdown list is collapsed
12506 * @param {Roo.bootstrap.ComboBox} combo This combo box
12510 * @event beforeselect
12511 * Fires before a list item is selected. Return false to cancel the selection.
12512 * @param {Roo.bootstrap.ComboBox} combo This combo box
12513 * @param {Roo.data.Record} record The data record returned from the underlying store
12514 * @param {Number} index The index of the selected item in the dropdown list
12516 'beforeselect' : true,
12519 * Fires when a list item is selected
12520 * @param {Roo.bootstrap.ComboBox} combo This combo box
12521 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12522 * @param {Number} index The index of the selected item in the dropdown list
12526 * @event beforequery
12527 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12528 * The event object passed has these properties:
12529 * @param {Roo.bootstrap.ComboBox} combo This combo box
12530 * @param {String} query The query
12531 * @param {Boolean} forceAll true to force "all" query
12532 * @param {Boolean} cancel true to cancel the query
12533 * @param {Object} e The query event object
12535 'beforequery': true,
12538 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12539 * @param {Roo.bootstrap.ComboBox} combo This combo box
12544 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12545 * @param {Roo.bootstrap.ComboBox} combo This combo box
12546 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12551 * Fires when the remove value from the combobox array
12552 * @param {Roo.bootstrap.ComboBox} combo This combo box
12556 * @event afterremove
12557 * Fires when the remove value from the combobox array
12558 * @param {Roo.bootstrap.ComboBox} combo This combo box
12560 'afterremove' : true,
12562 * @event specialfilter
12563 * Fires when specialfilter
12564 * @param {Roo.bootstrap.ComboBox} combo This combo box
12566 'specialfilter' : true,
12569 * Fires when tick the element
12570 * @param {Roo.bootstrap.ComboBox} combo This combo box
12574 * @event touchviewdisplay
12575 * Fires when touch view require special display (default is using displayField)
12576 * @param {Roo.bootstrap.ComboBox} combo This combo box
12577 * @param {Object} cfg set html .
12579 'touchviewdisplay' : true
12584 this.tickItems = [];
12586 this.selectedIndex = -1;
12587 if(this.mode == 'local'){
12588 if(config.queryDelay === undefined){
12589 this.queryDelay = 10;
12591 if(config.minChars === undefined){
12597 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12600 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12601 * rendering into an Roo.Editor, defaults to false)
12604 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12605 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12608 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12611 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12612 * the dropdown list (defaults to undefined, with no header element)
12616 * @cfg {String/Roo.Template} tpl The template to use to render the output
12620 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12622 listWidth: undefined,
12624 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12625 * mode = 'remote' or 'text' if mode = 'local')
12627 displayField: undefined,
12630 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12631 * mode = 'remote' or 'value' if mode = 'local').
12632 * Note: use of a valueField requires the user make a selection
12633 * in order for a value to be mapped.
12635 valueField: undefined,
12637 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12642 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12643 * field's data value (defaults to the underlying DOM element's name)
12645 hiddenName: undefined,
12647 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12651 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12653 selectedClass: 'active',
12656 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12660 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12661 * anchor positions (defaults to 'tl-bl')
12663 listAlign: 'tl-bl?',
12665 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12669 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12670 * query specified by the allQuery config option (defaults to 'query')
12672 triggerAction: 'query',
12674 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12675 * (defaults to 4, does not apply if editable = false)
12679 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12680 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12684 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12685 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12689 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12690 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12694 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12695 * when editable = true (defaults to false)
12697 selectOnFocus:false,
12699 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12701 queryParam: 'query',
12703 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12704 * when mode = 'remote' (defaults to 'Loading...')
12706 loadingText: 'Loading...',
12708 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12712 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12716 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12717 * traditional select (defaults to true)
12721 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12725 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12729 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12730 * listWidth has a higher value)
12734 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12735 * allow the user to set arbitrary text into the field (defaults to false)
12737 forceSelection:false,
12739 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12740 * if typeAhead = true (defaults to 250)
12742 typeAheadDelay : 250,
12744 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12745 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12747 valueNotFoundText : undefined,
12749 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12751 blockFocus : false,
12754 * @cfg {Boolean} disableClear Disable showing of clear button.
12756 disableClear : false,
12758 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12760 alwaysQuery : false,
12763 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12768 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12770 invalidClass : "has-warning",
12773 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12775 validClass : "has-success",
12778 * @cfg {Boolean} specialFilter (true|false) special filter default false
12780 specialFilter : false,
12783 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12785 mobileTouchView : true,
12788 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12790 useNativeIOS : false,
12792 ios_options : false,
12804 btnPosition : 'right',
12805 triggerList : true,
12806 showToggleBtn : true,
12808 emptyResultText: 'Empty',
12809 triggerText : 'Select',
12812 // element that contains real text value.. (when hidden is used..)
12814 getAutoCreate : function()
12819 * Render classic select for iso
12822 if(Roo.isIOS && this.useNativeIOS){
12823 cfg = this.getAutoCreateNativeIOS();
12831 if(Roo.isTouch && this.mobileTouchView){
12832 cfg = this.getAutoCreateTouchView();
12839 if(!this.tickable){
12840 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12845 * ComboBox with tickable selections
12848 var align = this.labelAlign || this.parentLabelAlign();
12851 cls : 'form-group roo-combobox-tickable' //input-group
12854 var btn_text_select = '';
12855 var btn_text_done = '';
12856 var btn_text_cancel = '';
12858 if (this.btn_text_show) {
12859 btn_text_select = 'Select';
12860 btn_text_done = 'Done';
12861 btn_text_cancel = 'Cancel';
12866 cls : 'tickable-buttons',
12871 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12872 //html : this.triggerText
12873 html: btn_text_select
12879 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12881 html: btn_text_done
12887 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12889 html: btn_text_cancel
12895 buttons.cn.unshift({
12897 cls: 'roo-select2-search-field-input'
12903 Roo.each(buttons.cn, function(c){
12905 c.cls += ' btn-' + _this.size;
12908 if (_this.disabled) {
12919 cls: 'form-hidden-field'
12923 cls: 'roo-select2-choices',
12927 cls: 'roo-select2-search-field',
12938 cls: 'roo-select2-container input-group roo-select2-container-multi',
12943 // cls: 'typeahead typeahead-long dropdown-menu',
12944 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12949 if(this.hasFeedback && !this.allowBlank){
12953 cls: 'glyphicon form-control-feedback'
12956 combobox.cn.push(feedback);
12960 if (align ==='left' && this.fieldLabel.length) {
12962 cfg.cls += ' roo-form-group-label-left';
12967 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12968 tooltip : 'This field is required'
12973 cls : 'control-label',
12974 html : this.fieldLabel
12986 var labelCfg = cfg.cn[1];
12987 var contentCfg = cfg.cn[2];
12990 if(this.indicatorpos == 'right'){
12996 cls : 'control-label',
13000 html : this.fieldLabel
13004 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13005 tooltip : 'This field is required'
13020 labelCfg = cfg.cn[0];
13021 contentCfg = cfg.cn[1];
13025 if(this.labelWidth > 12){
13026 labelCfg.style = "width: " + this.labelWidth + 'px';
13029 if(this.labelWidth < 13 && this.labelmd == 0){
13030 this.labelmd = this.labelWidth;
13033 if(this.labellg > 0){
13034 labelCfg.cls += ' col-lg-' + this.labellg;
13035 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13038 if(this.labelmd > 0){
13039 labelCfg.cls += ' col-md-' + this.labelmd;
13040 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13043 if(this.labelsm > 0){
13044 labelCfg.cls += ' col-sm-' + this.labelsm;
13045 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13048 if(this.labelxs > 0){
13049 labelCfg.cls += ' col-xs-' + this.labelxs;
13050 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13054 } else if ( this.fieldLabel.length) {
13055 // Roo.log(" label");
13059 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13060 tooltip : 'This field is required'
13064 //cls : 'input-group-addon',
13065 html : this.fieldLabel
13070 if(this.indicatorpos == 'right'){
13074 //cls : 'input-group-addon',
13075 html : this.fieldLabel
13079 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13080 tooltip : 'This field is required'
13089 // Roo.log(" no label && no align");
13096 ['xs','sm','md','lg'].map(function(size){
13097 if (settings[size]) {
13098 cfg.cls += ' col-' + size + '-' + settings[size];
13106 _initEventsCalled : false,
13109 initEvents: function()
13111 if (this._initEventsCalled) { // as we call render... prevent looping...
13114 this._initEventsCalled = true;
13117 throw "can not find store for combo";
13120 this.indicator = this.indicatorEl();
13122 this.store = Roo.factory(this.store, Roo.data);
13123 this.store.parent = this;
13125 // if we are building from html. then this element is so complex, that we can not really
13126 // use the rendered HTML.
13127 // so we have to trash and replace the previous code.
13128 if (Roo.XComponent.build_from_html) {
13129 // remove this element....
13130 var e = this.el.dom, k=0;
13131 while (e ) { e = e.previousSibling; ++k;}
13136 this.rendered = false;
13138 this.render(this.parent().getChildContainer(true), k);
13141 if(Roo.isIOS && this.useNativeIOS){
13142 this.initIOSView();
13150 if(Roo.isTouch && this.mobileTouchView){
13151 this.initTouchView();
13156 this.initTickableEvents();
13160 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13162 if(this.hiddenName){
13164 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13166 this.hiddenField.dom.value =
13167 this.hiddenValue !== undefined ? this.hiddenValue :
13168 this.value !== undefined ? this.value : '';
13170 // prevent input submission
13171 this.el.dom.removeAttribute('name');
13172 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13177 // this.el.dom.setAttribute('autocomplete', 'off');
13180 var cls = 'x-combo-list';
13182 //this.list = new Roo.Layer({
13183 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13189 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13190 _this.list.setWidth(lw);
13193 this.list.on('mouseover', this.onViewOver, this);
13194 this.list.on('mousemove', this.onViewMove, this);
13195 this.list.on('scroll', this.onViewScroll, this);
13198 this.list.swallowEvent('mousewheel');
13199 this.assetHeight = 0;
13202 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13203 this.assetHeight += this.header.getHeight();
13206 this.innerList = this.list.createChild({cls:cls+'-inner'});
13207 this.innerList.on('mouseover', this.onViewOver, this);
13208 this.innerList.on('mousemove', this.onViewMove, this);
13209 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13211 if(this.allowBlank && !this.pageSize && !this.disableClear){
13212 this.footer = this.list.createChild({cls:cls+'-ft'});
13213 this.pageTb = new Roo.Toolbar(this.footer);
13217 this.footer = this.list.createChild({cls:cls+'-ft'});
13218 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13219 {pageSize: this.pageSize});
13223 if (this.pageTb && this.allowBlank && !this.disableClear) {
13225 this.pageTb.add(new Roo.Toolbar.Fill(), {
13226 cls: 'x-btn-icon x-btn-clear',
13228 handler: function()
13231 _this.clearValue();
13232 _this.onSelect(false, -1);
13237 this.assetHeight += this.footer.getHeight();
13242 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13245 this.view = new Roo.View(this.list, this.tpl, {
13246 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13248 //this.view.wrapEl.setDisplayed(false);
13249 this.view.on('click', this.onViewClick, this);
13252 this.store.on('beforeload', this.onBeforeLoad, this);
13253 this.store.on('load', this.onLoad, this);
13254 this.store.on('loadexception', this.onLoadException, this);
13256 if(this.resizable){
13257 this.resizer = new Roo.Resizable(this.list, {
13258 pinned:true, handles:'se'
13260 this.resizer.on('resize', function(r, w, h){
13261 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13262 this.listWidth = w;
13263 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13264 this.restrictHeight();
13266 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13269 if(!this.editable){
13270 this.editable = true;
13271 this.setEditable(false);
13276 if (typeof(this.events.add.listeners) != 'undefined') {
13278 this.addicon = this.wrap.createChild(
13279 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13281 this.addicon.on('click', function(e) {
13282 this.fireEvent('add', this);
13285 if (typeof(this.events.edit.listeners) != 'undefined') {
13287 this.editicon = this.wrap.createChild(
13288 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13289 if (this.addicon) {
13290 this.editicon.setStyle('margin-left', '40px');
13292 this.editicon.on('click', function(e) {
13294 // we fire even if inothing is selected..
13295 this.fireEvent('edit', this, this.lastData );
13301 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13302 "up" : function(e){
13303 this.inKeyMode = true;
13307 "down" : function(e){
13308 if(!this.isExpanded()){
13309 this.onTriggerClick();
13311 this.inKeyMode = true;
13316 "enter" : function(e){
13317 // this.onViewClick();
13321 if(this.fireEvent("specialkey", this, e)){
13322 this.onViewClick(false);
13328 "esc" : function(e){
13332 "tab" : function(e){
13335 if(this.fireEvent("specialkey", this, e)){
13336 this.onViewClick(false);
13344 doRelay : function(foo, bar, hname){
13345 if(hname == 'down' || this.scope.isExpanded()){
13346 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13355 this.queryDelay = Math.max(this.queryDelay || 10,
13356 this.mode == 'local' ? 10 : 250);
13359 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13361 if(this.typeAhead){
13362 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13364 if(this.editable !== false){
13365 this.inputEl().on("keyup", this.onKeyUp, this);
13367 if(this.forceSelection){
13368 this.inputEl().on('blur', this.doForce, this);
13372 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13373 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13377 initTickableEvents: function()
13381 if(this.hiddenName){
13383 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13385 this.hiddenField.dom.value =
13386 this.hiddenValue !== undefined ? this.hiddenValue :
13387 this.value !== undefined ? this.value : '';
13389 // prevent input submission
13390 this.el.dom.removeAttribute('name');
13391 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13396 // this.list = this.el.select('ul.dropdown-menu',true).first();
13398 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13399 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13400 if(this.triggerList){
13401 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13404 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13405 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13407 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13408 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13410 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13411 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13413 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13414 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13415 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13418 this.cancelBtn.hide();
13423 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13424 _this.list.setWidth(lw);
13427 this.list.on('mouseover', this.onViewOver, this);
13428 this.list.on('mousemove', this.onViewMove, this);
13430 this.list.on('scroll', this.onViewScroll, this);
13433 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>';
13436 this.view = new Roo.View(this.list, this.tpl, {
13437 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13440 //this.view.wrapEl.setDisplayed(false);
13441 this.view.on('click', this.onViewClick, this);
13445 this.store.on('beforeload', this.onBeforeLoad, this);
13446 this.store.on('load', this.onLoad, this);
13447 this.store.on('loadexception', this.onLoadException, this);
13450 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13451 "up" : function(e){
13452 this.inKeyMode = true;
13456 "down" : function(e){
13457 this.inKeyMode = true;
13461 "enter" : function(e){
13462 if(this.fireEvent("specialkey", this, e)){
13463 this.onViewClick(false);
13469 "esc" : function(e){
13470 this.onTickableFooterButtonClick(e, false, false);
13473 "tab" : function(e){
13474 this.fireEvent("specialkey", this, e);
13476 this.onTickableFooterButtonClick(e, false, false);
13483 doRelay : function(e, fn, key){
13484 if(this.scope.isExpanded()){
13485 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13494 this.queryDelay = Math.max(this.queryDelay || 10,
13495 this.mode == 'local' ? 10 : 250);
13498 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13500 if(this.typeAhead){
13501 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13504 if(this.editable !== false){
13505 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13508 this.indicator = this.indicatorEl();
13510 if(this.indicator){
13511 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13512 this.indicator.hide();
13517 onDestroy : function(){
13519 this.view.setStore(null);
13520 this.view.el.removeAllListeners();
13521 this.view.el.remove();
13522 this.view.purgeListeners();
13525 this.list.dom.innerHTML = '';
13529 this.store.un('beforeload', this.onBeforeLoad, this);
13530 this.store.un('load', this.onLoad, this);
13531 this.store.un('loadexception', this.onLoadException, this);
13533 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13537 fireKey : function(e){
13538 if(e.isNavKeyPress() && !this.list.isVisible()){
13539 this.fireEvent("specialkey", this, e);
13544 onResize: function(w, h){
13545 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13547 // if(typeof w != 'number'){
13548 // // we do not handle it!?!?
13551 // var tw = this.trigger.getWidth();
13552 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13553 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13555 // this.inputEl().setWidth( this.adjustWidth('input', x));
13557 // //this.trigger.setStyle('left', x+'px');
13559 // if(this.list && this.listWidth === undefined){
13560 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13561 // this.list.setWidth(lw);
13562 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13570 * Allow or prevent the user from directly editing the field text. If false is passed,
13571 * the user will only be able to select from the items defined in the dropdown list. This method
13572 * is the runtime equivalent of setting the 'editable' config option at config time.
13573 * @param {Boolean} value True to allow the user to directly edit the field text
13575 setEditable : function(value){
13576 if(value == this.editable){
13579 this.editable = value;
13581 this.inputEl().dom.setAttribute('readOnly', true);
13582 this.inputEl().on('mousedown', this.onTriggerClick, this);
13583 this.inputEl().addClass('x-combo-noedit');
13585 this.inputEl().dom.setAttribute('readOnly', false);
13586 this.inputEl().un('mousedown', this.onTriggerClick, this);
13587 this.inputEl().removeClass('x-combo-noedit');
13593 onBeforeLoad : function(combo,opts){
13594 if(!this.hasFocus){
13598 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13600 this.restrictHeight();
13601 this.selectedIndex = -1;
13605 onLoad : function(){
13607 this.hasQuery = false;
13609 if(!this.hasFocus){
13613 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13614 this.loading.hide();
13617 if(this.store.getCount() > 0){
13620 this.restrictHeight();
13621 if(this.lastQuery == this.allQuery){
13622 if(this.editable && !this.tickable){
13623 this.inputEl().dom.select();
13627 !this.selectByValue(this.value, true) &&
13630 !this.store.lastOptions ||
13631 typeof(this.store.lastOptions.add) == 'undefined' ||
13632 this.store.lastOptions.add != true
13635 this.select(0, true);
13638 if(this.autoFocus){
13641 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13642 this.taTask.delay(this.typeAheadDelay);
13646 this.onEmptyResults();
13652 onLoadException : function()
13654 this.hasQuery = false;
13656 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13657 this.loading.hide();
13660 if(this.tickable && this.editable){
13665 // only causes errors at present
13666 //Roo.log(this.store.reader.jsonData);
13667 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13669 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13675 onTypeAhead : function(){
13676 if(this.store.getCount() > 0){
13677 var r = this.store.getAt(0);
13678 var newValue = r.data[this.displayField];
13679 var len = newValue.length;
13680 var selStart = this.getRawValue().length;
13682 if(selStart != len){
13683 this.setRawValue(newValue);
13684 this.selectText(selStart, newValue.length);
13690 onSelect : function(record, index){
13692 if(this.fireEvent('beforeselect', this, record, index) !== false){
13694 this.setFromData(index > -1 ? record.data : false);
13697 this.fireEvent('select', this, record, index);
13702 * Returns the currently selected field value or empty string if no value is set.
13703 * @return {String} value The selected value
13705 getValue : function()
13707 if(Roo.isIOS && this.useNativeIOS){
13708 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13712 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13715 if(this.valueField){
13716 return typeof this.value != 'undefined' ? this.value : '';
13718 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13722 getRawValue : function()
13724 if(Roo.isIOS && this.useNativeIOS){
13725 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13728 var v = this.inputEl().getValue();
13734 * Clears any text/value currently set in the field
13736 clearValue : function(){
13738 if(this.hiddenField){
13739 this.hiddenField.dom.value = '';
13742 this.setRawValue('');
13743 this.lastSelectionText = '';
13744 this.lastData = false;
13746 var close = this.closeTriggerEl();
13757 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13758 * will be displayed in the field. If the value does not match the data value of an existing item,
13759 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13760 * Otherwise the field will be blank (although the value will still be set).
13761 * @param {String} value The value to match
13763 setValue : function(v)
13765 if(Roo.isIOS && this.useNativeIOS){
13766 this.setIOSValue(v);
13776 if(this.valueField){
13777 var r = this.findRecord(this.valueField, v);
13779 text = r.data[this.displayField];
13780 }else if(this.valueNotFoundText !== undefined){
13781 text = this.valueNotFoundText;
13784 this.lastSelectionText = text;
13785 if(this.hiddenField){
13786 this.hiddenField.dom.value = v;
13788 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13791 var close = this.closeTriggerEl();
13794 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13800 * @property {Object} the last set data for the element
13805 * Sets the value of the field based on a object which is related to the record format for the store.
13806 * @param {Object} value the value to set as. or false on reset?
13808 setFromData : function(o){
13815 var dv = ''; // display value
13816 var vv = ''; // value value..
13818 if (this.displayField) {
13819 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13821 // this is an error condition!!!
13822 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13825 if(this.valueField){
13826 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13829 var close = this.closeTriggerEl();
13832 if(dv.length || vv * 1 > 0){
13834 this.blockFocus=true;
13840 if(this.hiddenField){
13841 this.hiddenField.dom.value = vv;
13843 this.lastSelectionText = dv;
13844 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13848 // no hidden field.. - we store the value in 'value', but still display
13849 // display field!!!!
13850 this.lastSelectionText = dv;
13851 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13858 reset : function(){
13859 // overridden so that last data is reset..
13866 this.setValue(this.originalValue);
13867 //this.clearInvalid();
13868 this.lastData = false;
13870 this.view.clearSelections();
13876 findRecord : function(prop, value){
13878 if(this.store.getCount() > 0){
13879 this.store.each(function(r){
13880 if(r.data[prop] == value){
13890 getName: function()
13892 // returns hidden if it's set..
13893 if (!this.rendered) {return ''};
13894 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13898 onViewMove : function(e, t){
13899 this.inKeyMode = false;
13903 onViewOver : function(e, t){
13904 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13907 var item = this.view.findItemFromChild(t);
13910 var index = this.view.indexOf(item);
13911 this.select(index, false);
13916 onViewClick : function(view, doFocus, el, e)
13918 var index = this.view.getSelectedIndexes()[0];
13920 var r = this.store.getAt(index);
13924 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13931 Roo.each(this.tickItems, function(v,k){
13933 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13935 _this.tickItems.splice(k, 1);
13937 if(typeof(e) == 'undefined' && view == false){
13938 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13950 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13951 this.tickItems.push(r.data);
13954 if(typeof(e) == 'undefined' && view == false){
13955 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13962 this.onSelect(r, index);
13964 if(doFocus !== false && !this.blockFocus){
13965 this.inputEl().focus();
13970 restrictHeight : function(){
13971 //this.innerList.dom.style.height = '';
13972 //var inner = this.innerList.dom;
13973 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13974 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13975 //this.list.beginUpdate();
13976 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13977 this.list.alignTo(this.inputEl(), this.listAlign);
13978 this.list.alignTo(this.inputEl(), this.listAlign);
13979 //this.list.endUpdate();
13983 onEmptyResults : function(){
13985 if(this.tickable && this.editable){
13986 this.hasFocus = false;
13987 this.restrictHeight();
13995 * Returns true if the dropdown list is expanded, else false.
13997 isExpanded : function(){
13998 return this.list.isVisible();
14002 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14003 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14004 * @param {String} value The data value of the item to select
14005 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14006 * selected item if it is not currently in view (defaults to true)
14007 * @return {Boolean} True if the value matched an item in the list, else false
14009 selectByValue : function(v, scrollIntoView){
14010 if(v !== undefined && v !== null){
14011 var r = this.findRecord(this.valueField || this.displayField, v);
14013 this.select(this.store.indexOf(r), scrollIntoView);
14021 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14022 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14023 * @param {Number} index The zero-based index of the list item to select
14024 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14025 * selected item if it is not currently in view (defaults to true)
14027 select : function(index, scrollIntoView){
14028 this.selectedIndex = index;
14029 this.view.select(index);
14030 if(scrollIntoView !== false){
14031 var el = this.view.getNode(index);
14033 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14036 this.list.scrollChildIntoView(el, false);
14042 selectNext : function(){
14043 var ct = this.store.getCount();
14045 if(this.selectedIndex == -1){
14047 }else if(this.selectedIndex < ct-1){
14048 this.select(this.selectedIndex+1);
14054 selectPrev : function(){
14055 var ct = this.store.getCount();
14057 if(this.selectedIndex == -1){
14059 }else if(this.selectedIndex != 0){
14060 this.select(this.selectedIndex-1);
14066 onKeyUp : function(e){
14067 if(this.editable !== false && !e.isSpecialKey()){
14068 this.lastKey = e.getKey();
14069 this.dqTask.delay(this.queryDelay);
14074 validateBlur : function(){
14075 return !this.list || !this.list.isVisible();
14079 initQuery : function(){
14081 var v = this.getRawValue();
14083 if(this.tickable && this.editable){
14084 v = this.tickableInputEl().getValue();
14091 doForce : function(){
14092 if(this.inputEl().dom.value.length > 0){
14093 this.inputEl().dom.value =
14094 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14100 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14101 * query allowing the query action to be canceled if needed.
14102 * @param {String} query The SQL query to execute
14103 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14104 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14105 * saved in the current store (defaults to false)
14107 doQuery : function(q, forceAll){
14109 if(q === undefined || q === null){
14114 forceAll: forceAll,
14118 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14123 forceAll = qe.forceAll;
14124 if(forceAll === true || (q.length >= this.minChars)){
14126 this.hasQuery = true;
14128 if(this.lastQuery != q || this.alwaysQuery){
14129 this.lastQuery = q;
14130 if(this.mode == 'local'){
14131 this.selectedIndex = -1;
14133 this.store.clearFilter();
14136 if(this.specialFilter){
14137 this.fireEvent('specialfilter', this);
14142 this.store.filter(this.displayField, q);
14145 this.store.fireEvent("datachanged", this.store);
14152 this.store.baseParams[this.queryParam] = q;
14154 var options = {params : this.getParams(q)};
14157 options.add = true;
14158 options.params.start = this.page * this.pageSize;
14161 this.store.load(options);
14164 * this code will make the page width larger, at the beginning, the list not align correctly,
14165 * we should expand the list on onLoad
14166 * so command out it
14171 this.selectedIndex = -1;
14176 this.loadNext = false;
14180 getParams : function(q){
14182 //p[this.queryParam] = q;
14186 p.limit = this.pageSize;
14192 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14194 collapse : function(){
14195 if(!this.isExpanded()){
14201 this.hasFocus = false;
14205 this.cancelBtn.hide();
14206 this.trigger.show();
14209 this.tickableInputEl().dom.value = '';
14210 this.tickableInputEl().blur();
14215 Roo.get(document).un('mousedown', this.collapseIf, this);
14216 Roo.get(document).un('mousewheel', this.collapseIf, this);
14217 if (!this.editable) {
14218 Roo.get(document).un('keydown', this.listKeyPress, this);
14220 this.fireEvent('collapse', this);
14226 collapseIf : function(e){
14227 var in_combo = e.within(this.el);
14228 var in_list = e.within(this.list);
14229 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14231 if (in_combo || in_list || is_list) {
14232 //e.stopPropagation();
14237 this.onTickableFooterButtonClick(e, false, false);
14245 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14247 expand : function(){
14249 if(this.isExpanded() || !this.hasFocus){
14253 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14254 this.list.setWidth(lw);
14260 this.restrictHeight();
14264 this.tickItems = Roo.apply([], this.item);
14267 this.cancelBtn.show();
14268 this.trigger.hide();
14271 this.tickableInputEl().focus();
14276 Roo.get(document).on('mousedown', this.collapseIf, this);
14277 Roo.get(document).on('mousewheel', this.collapseIf, this);
14278 if (!this.editable) {
14279 Roo.get(document).on('keydown', this.listKeyPress, this);
14282 this.fireEvent('expand', this);
14286 // Implements the default empty TriggerField.onTriggerClick function
14287 onTriggerClick : function(e)
14289 Roo.log('trigger click');
14291 if(this.disabled || !this.triggerList){
14296 this.loadNext = false;
14298 if(this.isExpanded()){
14300 if (!this.blockFocus) {
14301 this.inputEl().focus();
14305 this.hasFocus = true;
14306 if(this.triggerAction == 'all') {
14307 this.doQuery(this.allQuery, true);
14309 this.doQuery(this.getRawValue());
14311 if (!this.blockFocus) {
14312 this.inputEl().focus();
14317 onTickableTriggerClick : function(e)
14324 this.loadNext = false;
14325 this.hasFocus = true;
14327 if(this.triggerAction == 'all') {
14328 this.doQuery(this.allQuery, true);
14330 this.doQuery(this.getRawValue());
14334 onSearchFieldClick : function(e)
14336 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14337 this.onTickableFooterButtonClick(e, false, false);
14341 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14346 this.loadNext = false;
14347 this.hasFocus = true;
14349 if(this.triggerAction == 'all') {
14350 this.doQuery(this.allQuery, true);
14352 this.doQuery(this.getRawValue());
14356 listKeyPress : function(e)
14358 //Roo.log('listkeypress');
14359 // scroll to first matching element based on key pres..
14360 if (e.isSpecialKey()) {
14363 var k = String.fromCharCode(e.getKey()).toUpperCase();
14366 var csel = this.view.getSelectedNodes();
14367 var cselitem = false;
14369 var ix = this.view.indexOf(csel[0]);
14370 cselitem = this.store.getAt(ix);
14371 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14377 this.store.each(function(v) {
14379 // start at existing selection.
14380 if (cselitem.id == v.id) {
14386 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14387 match = this.store.indexOf(v);
14393 if (match === false) {
14394 return true; // no more action?
14397 this.view.select(match);
14398 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14399 sn.scrollIntoView(sn.dom.parentNode, false);
14402 onViewScroll : function(e, t){
14404 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){
14408 this.hasQuery = true;
14410 this.loading = this.list.select('.loading', true).first();
14412 if(this.loading === null){
14413 this.list.createChild({
14415 cls: 'loading roo-select2-more-results roo-select2-active',
14416 html: 'Loading more results...'
14419 this.loading = this.list.select('.loading', true).first();
14421 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14423 this.loading.hide();
14426 this.loading.show();
14431 this.loadNext = true;
14433 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14438 addItem : function(o)
14440 var dv = ''; // display value
14442 if (this.displayField) {
14443 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14445 // this is an error condition!!!
14446 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14453 var choice = this.choices.createChild({
14455 cls: 'roo-select2-search-choice',
14464 cls: 'roo-select2-search-choice-close fa fa-times',
14469 }, this.searchField);
14471 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14473 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14481 this.inputEl().dom.value = '';
14486 onRemoveItem : function(e, _self, o)
14488 e.preventDefault();
14490 this.lastItem = Roo.apply([], this.item);
14492 var index = this.item.indexOf(o.data) * 1;
14495 Roo.log('not this item?!');
14499 this.item.splice(index, 1);
14504 this.fireEvent('remove', this, e);
14510 syncValue : function()
14512 if(!this.item.length){
14519 Roo.each(this.item, function(i){
14520 if(_this.valueField){
14521 value.push(i[_this.valueField]);
14528 this.value = value.join(',');
14530 if(this.hiddenField){
14531 this.hiddenField.dom.value = this.value;
14534 this.store.fireEvent("datachanged", this.store);
14539 clearItem : function()
14541 if(!this.multiple){
14547 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14555 if(this.tickable && !Roo.isTouch){
14556 this.view.refresh();
14560 inputEl: function ()
14562 if(Roo.isIOS && this.useNativeIOS){
14563 return this.el.select('select.roo-ios-select', true).first();
14566 if(Roo.isTouch && this.mobileTouchView){
14567 return this.el.select('input.form-control',true).first();
14571 return this.searchField;
14574 return this.el.select('input.form-control',true).first();
14577 onTickableFooterButtonClick : function(e, btn, el)
14579 e.preventDefault();
14581 this.lastItem = Roo.apply([], this.item);
14583 if(btn && btn.name == 'cancel'){
14584 this.tickItems = Roo.apply([], this.item);
14593 Roo.each(this.tickItems, function(o){
14601 validate : function()
14603 var v = this.getRawValue();
14606 v = this.getValue();
14609 if(this.disabled || this.allowBlank || v.length){
14614 this.markInvalid();
14618 tickableInputEl : function()
14620 if(!this.tickable || !this.editable){
14621 return this.inputEl();
14624 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14628 getAutoCreateTouchView : function()
14633 cls: 'form-group' //input-group
14639 type : this.inputType,
14640 cls : 'form-control x-combo-noedit',
14641 autocomplete: 'new-password',
14642 placeholder : this.placeholder || '',
14647 input.name = this.name;
14651 input.cls += ' input-' + this.size;
14654 if (this.disabled) {
14655 input.disabled = true;
14666 inputblock.cls += ' input-group';
14668 inputblock.cn.unshift({
14670 cls : 'input-group-addon',
14675 if(this.removable && !this.multiple){
14676 inputblock.cls += ' roo-removable';
14678 inputblock.cn.push({
14681 cls : 'roo-combo-removable-btn close'
14685 if(this.hasFeedback && !this.allowBlank){
14687 inputblock.cls += ' has-feedback';
14689 inputblock.cn.push({
14691 cls: 'glyphicon form-control-feedback'
14698 inputblock.cls += (this.before) ? '' : ' input-group';
14700 inputblock.cn.push({
14702 cls : 'input-group-addon',
14713 cls: 'form-hidden-field'
14727 cls: 'form-hidden-field'
14731 cls: 'roo-select2-choices',
14735 cls: 'roo-select2-search-field',
14748 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14754 if(!this.multiple && this.showToggleBtn){
14761 if (this.caret != false) {
14764 cls: 'fa fa-' + this.caret
14771 cls : 'input-group-addon btn dropdown-toggle',
14776 cls: 'combobox-clear',
14790 combobox.cls += ' roo-select2-container-multi';
14793 var align = this.labelAlign || this.parentLabelAlign();
14795 if (align ==='left' && this.fieldLabel.length) {
14800 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14801 tooltip : 'This field is required'
14805 cls : 'control-label',
14806 html : this.fieldLabel
14817 var labelCfg = cfg.cn[1];
14818 var contentCfg = cfg.cn[2];
14821 if(this.indicatorpos == 'right'){
14826 cls : 'control-label',
14830 html : this.fieldLabel
14834 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14835 tooltip : 'This field is required'
14848 labelCfg = cfg.cn[0];
14849 contentCfg = cfg.cn[1];
14854 if(this.labelWidth > 12){
14855 labelCfg.style = "width: " + this.labelWidth + 'px';
14858 if(this.labelWidth < 13 && this.labelmd == 0){
14859 this.labelmd = this.labelWidth;
14862 if(this.labellg > 0){
14863 labelCfg.cls += ' col-lg-' + this.labellg;
14864 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14867 if(this.labelmd > 0){
14868 labelCfg.cls += ' col-md-' + this.labelmd;
14869 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14872 if(this.labelsm > 0){
14873 labelCfg.cls += ' col-sm-' + this.labelsm;
14874 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14877 if(this.labelxs > 0){
14878 labelCfg.cls += ' col-xs-' + this.labelxs;
14879 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14883 } else if ( this.fieldLabel.length) {
14887 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14888 tooltip : 'This field is required'
14892 cls : 'control-label',
14893 html : this.fieldLabel
14904 if(this.indicatorpos == 'right'){
14908 cls : 'control-label',
14909 html : this.fieldLabel,
14913 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14914 tooltip : 'This field is required'
14931 var settings = this;
14933 ['xs','sm','md','lg'].map(function(size){
14934 if (settings[size]) {
14935 cfg.cls += ' col-' + size + '-' + settings[size];
14942 initTouchView : function()
14944 this.renderTouchView();
14946 this.touchViewEl.on('scroll', function(){
14947 this.el.dom.scrollTop = 0;
14950 this.originalValue = this.getValue();
14952 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14954 this.inputEl().on("click", this.showTouchView, this);
14955 if (this.triggerEl) {
14956 this.triggerEl.on("click", this.showTouchView, this);
14960 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14961 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14963 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14965 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14966 this.store.on('load', this.onTouchViewLoad, this);
14967 this.store.on('loadexception', this.onTouchViewLoadException, this);
14969 if(this.hiddenName){
14971 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14973 this.hiddenField.dom.value =
14974 this.hiddenValue !== undefined ? this.hiddenValue :
14975 this.value !== undefined ? this.value : '';
14977 this.el.dom.removeAttribute('name');
14978 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14982 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14983 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14986 if(this.removable && !this.multiple){
14987 var close = this.closeTriggerEl();
14989 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14990 close.on('click', this.removeBtnClick, this, close);
14994 * fix the bug in Safari iOS8
14996 this.inputEl().on("focus", function(e){
14997 document.activeElement.blur();
15005 renderTouchView : function()
15007 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15008 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15010 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15011 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15013 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15014 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15015 this.touchViewBodyEl.setStyle('overflow', 'auto');
15017 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15018 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15020 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15021 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15025 showTouchView : function()
15031 this.touchViewHeaderEl.hide();
15033 if(this.modalTitle.length){
15034 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15035 this.touchViewHeaderEl.show();
15038 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15039 this.touchViewEl.show();
15041 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15043 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15044 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15046 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15048 if(this.modalTitle.length){
15049 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15052 this.touchViewBodyEl.setHeight(bodyHeight);
15056 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15058 this.touchViewEl.addClass('in');
15061 this.doTouchViewQuery();
15065 hideTouchView : function()
15067 this.touchViewEl.removeClass('in');
15071 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15073 this.touchViewEl.setStyle('display', 'none');
15078 setTouchViewValue : function()
15085 Roo.each(this.tickItems, function(o){
15090 this.hideTouchView();
15093 doTouchViewQuery : function()
15102 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15106 if(!this.alwaysQuery || this.mode == 'local'){
15107 this.onTouchViewLoad();
15114 onTouchViewBeforeLoad : function(combo,opts)
15120 onTouchViewLoad : function()
15122 if(this.store.getCount() < 1){
15123 this.onTouchViewEmptyResults();
15127 this.clearTouchView();
15129 var rawValue = this.getRawValue();
15131 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15133 this.tickItems = [];
15135 this.store.data.each(function(d, rowIndex){
15136 var row = this.touchViewListGroup.createChild(template);
15138 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15139 row.addClass(d.data.cls);
15142 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15145 html : d.data[this.displayField]
15148 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15149 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15152 row.removeClass('selected');
15153 if(!this.multiple && this.valueField &&
15154 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15157 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15158 row.addClass('selected');
15161 if(this.multiple && this.valueField &&
15162 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15166 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15167 this.tickItems.push(d.data);
15170 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15174 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15176 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15178 if(this.modalTitle.length){
15179 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15182 var listHeight = this.touchViewListGroup.getHeight();
15186 if(firstChecked && listHeight > bodyHeight){
15187 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15192 onTouchViewLoadException : function()
15194 this.hideTouchView();
15197 onTouchViewEmptyResults : function()
15199 this.clearTouchView();
15201 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15203 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15207 clearTouchView : function()
15209 this.touchViewListGroup.dom.innerHTML = '';
15212 onTouchViewClick : function(e, el, o)
15214 e.preventDefault();
15217 var rowIndex = o.rowIndex;
15219 var r = this.store.getAt(rowIndex);
15221 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15223 if(!this.multiple){
15224 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15225 c.dom.removeAttribute('checked');
15228 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15230 this.setFromData(r.data);
15232 var close = this.closeTriggerEl();
15238 this.hideTouchView();
15240 this.fireEvent('select', this, r, rowIndex);
15245 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15246 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15247 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15251 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15252 this.addItem(r.data);
15253 this.tickItems.push(r.data);
15257 getAutoCreateNativeIOS : function()
15260 cls: 'form-group' //input-group,
15265 cls : 'roo-ios-select'
15269 combobox.name = this.name;
15272 if (this.disabled) {
15273 combobox.disabled = true;
15276 var settings = this;
15278 ['xs','sm','md','lg'].map(function(size){
15279 if (settings[size]) {
15280 cfg.cls += ' col-' + size + '-' + settings[size];
15290 initIOSView : function()
15292 this.store.on('load', this.onIOSViewLoad, this);
15297 onIOSViewLoad : function()
15299 if(this.store.getCount() < 1){
15303 this.clearIOSView();
15305 if(this.allowBlank) {
15307 var default_text = '-- SELECT --';
15309 if(this.placeholder.length){
15310 default_text = this.placeholder;
15313 if(this.emptyTitle.length){
15314 default_text += ' - ' + this.emptyTitle + ' -';
15317 var opt = this.inputEl().createChild({
15320 html : default_text
15324 o[this.valueField] = 0;
15325 o[this.displayField] = default_text;
15327 this.ios_options.push({
15334 this.store.data.each(function(d, rowIndex){
15338 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15339 html = d.data[this.displayField];
15344 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15345 value = d.data[this.valueField];
15354 if(this.value == d.data[this.valueField]){
15355 option['selected'] = true;
15358 var opt = this.inputEl().createChild(option);
15360 this.ios_options.push({
15367 this.inputEl().on('change', function(){
15368 this.fireEvent('select', this);
15373 clearIOSView: function()
15375 this.inputEl().dom.innerHTML = '';
15377 this.ios_options = [];
15380 setIOSValue: function(v)
15384 if(!this.ios_options){
15388 Roo.each(this.ios_options, function(opts){
15390 opts.el.dom.removeAttribute('selected');
15392 if(opts.data[this.valueField] != v){
15396 opts.el.dom.setAttribute('selected', true);
15402 * @cfg {Boolean} grow
15406 * @cfg {Number} growMin
15410 * @cfg {Number} growMax
15419 Roo.apply(Roo.bootstrap.ComboBox, {
15423 cls: 'modal-header',
15445 cls: 'list-group-item',
15449 cls: 'roo-combobox-list-group-item-value'
15453 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15467 listItemCheckbox : {
15469 cls: 'list-group-item',
15473 cls: 'roo-combobox-list-group-item-value'
15477 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15493 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15498 cls: 'modal-footer',
15506 cls: 'col-xs-6 text-left',
15509 cls: 'btn btn-danger roo-touch-view-cancel',
15515 cls: 'col-xs-6 text-right',
15518 cls: 'btn btn-success roo-touch-view-ok',
15529 Roo.apply(Roo.bootstrap.ComboBox, {
15531 touchViewTemplate : {
15533 cls: 'modal fade roo-combobox-touch-view',
15537 cls: 'modal-dialog',
15538 style : 'position:fixed', // we have to fix position....
15542 cls: 'modal-content',
15544 Roo.bootstrap.ComboBox.header,
15545 Roo.bootstrap.ComboBox.body,
15546 Roo.bootstrap.ComboBox.footer
15555 * Ext JS Library 1.1.1
15556 * Copyright(c) 2006-2007, Ext JS, LLC.
15558 * Originally Released Under LGPL - original licence link has changed is not relivant.
15561 * <script type="text/javascript">
15566 * @extends Roo.util.Observable
15567 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15568 * This class also supports single and multi selection modes. <br>
15569 * Create a data model bound view:
15571 var store = new Roo.data.Store(...);
15573 var view = new Roo.View({
15575 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15577 singleSelect: true,
15578 selectedClass: "ydataview-selected",
15582 // listen for node click?
15583 view.on("click", function(vw, index, node, e){
15584 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15588 dataModel.load("foobar.xml");
15590 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15592 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15593 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15595 * Note: old style constructor is still suported (container, template, config)
15598 * Create a new View
15599 * @param {Object} config The config object
15602 Roo.View = function(config, depreciated_tpl, depreciated_config){
15604 this.parent = false;
15606 if (typeof(depreciated_tpl) == 'undefined') {
15607 // new way.. - universal constructor.
15608 Roo.apply(this, config);
15609 this.el = Roo.get(this.el);
15612 this.el = Roo.get(config);
15613 this.tpl = depreciated_tpl;
15614 Roo.apply(this, depreciated_config);
15616 this.wrapEl = this.el.wrap().wrap();
15617 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15620 if(typeof(this.tpl) == "string"){
15621 this.tpl = new Roo.Template(this.tpl);
15623 // support xtype ctors..
15624 this.tpl = new Roo.factory(this.tpl, Roo);
15628 this.tpl.compile();
15633 * @event beforeclick
15634 * Fires before a click is processed. Returns false to cancel the default action.
15635 * @param {Roo.View} this
15636 * @param {Number} index The index of the target node
15637 * @param {HTMLElement} node The target node
15638 * @param {Roo.EventObject} e The raw event object
15640 "beforeclick" : true,
15643 * Fires when a template node is clicked.
15644 * @param {Roo.View} this
15645 * @param {Number} index The index of the target node
15646 * @param {HTMLElement} node The target node
15647 * @param {Roo.EventObject} e The raw event object
15652 * Fires when a template node is double clicked.
15653 * @param {Roo.View} this
15654 * @param {Number} index The index of the target node
15655 * @param {HTMLElement} node The target node
15656 * @param {Roo.EventObject} e The raw event object
15660 * @event contextmenu
15661 * Fires when a template node is right clicked.
15662 * @param {Roo.View} this
15663 * @param {Number} index The index of the target node
15664 * @param {HTMLElement} node The target node
15665 * @param {Roo.EventObject} e The raw event object
15667 "contextmenu" : true,
15669 * @event selectionchange
15670 * Fires when the selected nodes change.
15671 * @param {Roo.View} this
15672 * @param {Array} selections Array of the selected nodes
15674 "selectionchange" : true,
15677 * @event beforeselect
15678 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15679 * @param {Roo.View} this
15680 * @param {HTMLElement} node The node to be selected
15681 * @param {Array} selections Array of currently selected nodes
15683 "beforeselect" : true,
15685 * @event preparedata
15686 * Fires on every row to render, to allow you to change the data.
15687 * @param {Roo.View} this
15688 * @param {Object} data to be rendered (change this)
15690 "preparedata" : true
15698 "click": this.onClick,
15699 "dblclick": this.onDblClick,
15700 "contextmenu": this.onContextMenu,
15704 this.selections = [];
15706 this.cmp = new Roo.CompositeElementLite([]);
15708 this.store = Roo.factory(this.store, Roo.data);
15709 this.setStore(this.store, true);
15712 if ( this.footer && this.footer.xtype) {
15714 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15716 this.footer.dataSource = this.store;
15717 this.footer.container = fctr;
15718 this.footer = Roo.factory(this.footer, Roo);
15719 fctr.insertFirst(this.el);
15721 // this is a bit insane - as the paging toolbar seems to detach the el..
15722 // dom.parentNode.parentNode.parentNode
15723 // they get detached?
15727 Roo.View.superclass.constructor.call(this);
15732 Roo.extend(Roo.View, Roo.util.Observable, {
15735 * @cfg {Roo.data.Store} store Data store to load data from.
15740 * @cfg {String|Roo.Element} el The container element.
15745 * @cfg {String|Roo.Template} tpl The template used by this View
15749 * @cfg {String} dataName the named area of the template to use as the data area
15750 * Works with domtemplates roo-name="name"
15754 * @cfg {String} selectedClass The css class to add to selected nodes
15756 selectedClass : "x-view-selected",
15758 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15763 * @cfg {String} text to display on mask (default Loading)
15767 * @cfg {Boolean} multiSelect Allow multiple selection
15769 multiSelect : false,
15771 * @cfg {Boolean} singleSelect Allow single selection
15773 singleSelect: false,
15776 * @cfg {Boolean} toggleSelect - selecting
15778 toggleSelect : false,
15781 * @cfg {Boolean} tickable - selecting
15786 * Returns the element this view is bound to.
15787 * @return {Roo.Element}
15789 getEl : function(){
15790 return this.wrapEl;
15796 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15798 refresh : function(){
15799 //Roo.log('refresh');
15802 // if we are using something like 'domtemplate', then
15803 // the what gets used is:
15804 // t.applySubtemplate(NAME, data, wrapping data..)
15805 // the outer template then get' applied with
15806 // the store 'extra data'
15807 // and the body get's added to the
15808 // roo-name="data" node?
15809 // <span class='roo-tpl-{name}'></span> ?????
15813 this.clearSelections();
15814 this.el.update("");
15816 var records = this.store.getRange();
15817 if(records.length < 1) {
15819 // is this valid?? = should it render a template??
15821 this.el.update(this.emptyText);
15825 if (this.dataName) {
15826 this.el.update(t.apply(this.store.meta)); //????
15827 el = this.el.child('.roo-tpl-' + this.dataName);
15830 for(var i = 0, len = records.length; i < len; i++){
15831 var data = this.prepareData(records[i].data, i, records[i]);
15832 this.fireEvent("preparedata", this, data, i, records[i]);
15834 var d = Roo.apply({}, data);
15837 Roo.apply(d, {'roo-id' : Roo.id()});
15841 Roo.each(this.parent.item, function(item){
15842 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15845 Roo.apply(d, {'roo-data-checked' : 'checked'});
15849 html[html.length] = Roo.util.Format.trim(
15851 t.applySubtemplate(this.dataName, d, this.store.meta) :
15858 el.update(html.join(""));
15859 this.nodes = el.dom.childNodes;
15860 this.updateIndexes(0);
15865 * Function to override to reformat the data that is sent to
15866 * the template for each node.
15867 * DEPRICATED - use the preparedata event handler.
15868 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15869 * a JSON object for an UpdateManager bound view).
15871 prepareData : function(data, index, record)
15873 this.fireEvent("preparedata", this, data, index, record);
15877 onUpdate : function(ds, record){
15878 // Roo.log('on update');
15879 this.clearSelections();
15880 var index = this.store.indexOf(record);
15881 var n = this.nodes[index];
15882 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15883 n.parentNode.removeChild(n);
15884 this.updateIndexes(index, index);
15890 onAdd : function(ds, records, index)
15892 //Roo.log(['on Add', ds, records, index] );
15893 this.clearSelections();
15894 if(this.nodes.length == 0){
15898 var n = this.nodes[index];
15899 for(var i = 0, len = records.length; i < len; i++){
15900 var d = this.prepareData(records[i].data, i, records[i]);
15902 this.tpl.insertBefore(n, d);
15905 this.tpl.append(this.el, d);
15908 this.updateIndexes(index);
15911 onRemove : function(ds, record, index){
15912 // Roo.log('onRemove');
15913 this.clearSelections();
15914 var el = this.dataName ?
15915 this.el.child('.roo-tpl-' + this.dataName) :
15918 el.dom.removeChild(this.nodes[index]);
15919 this.updateIndexes(index);
15923 * Refresh an individual node.
15924 * @param {Number} index
15926 refreshNode : function(index){
15927 this.onUpdate(this.store, this.store.getAt(index));
15930 updateIndexes : function(startIndex, endIndex){
15931 var ns = this.nodes;
15932 startIndex = startIndex || 0;
15933 endIndex = endIndex || ns.length - 1;
15934 for(var i = startIndex; i <= endIndex; i++){
15935 ns[i].nodeIndex = i;
15940 * Changes the data store this view uses and refresh the view.
15941 * @param {Store} store
15943 setStore : function(store, initial){
15944 if(!initial && this.store){
15945 this.store.un("datachanged", this.refresh);
15946 this.store.un("add", this.onAdd);
15947 this.store.un("remove", this.onRemove);
15948 this.store.un("update", this.onUpdate);
15949 this.store.un("clear", this.refresh);
15950 this.store.un("beforeload", this.onBeforeLoad);
15951 this.store.un("load", this.onLoad);
15952 this.store.un("loadexception", this.onLoad);
15956 store.on("datachanged", this.refresh, this);
15957 store.on("add", this.onAdd, this);
15958 store.on("remove", this.onRemove, this);
15959 store.on("update", this.onUpdate, this);
15960 store.on("clear", this.refresh, this);
15961 store.on("beforeload", this.onBeforeLoad, this);
15962 store.on("load", this.onLoad, this);
15963 store.on("loadexception", this.onLoad, this);
15971 * onbeforeLoad - masks the loading area.
15974 onBeforeLoad : function(store,opts)
15976 //Roo.log('onBeforeLoad');
15978 this.el.update("");
15980 this.el.mask(this.mask ? this.mask : "Loading" );
15982 onLoad : function ()
15989 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15990 * @param {HTMLElement} node
15991 * @return {HTMLElement} The template node
15993 findItemFromChild : function(node){
15994 var el = this.dataName ?
15995 this.el.child('.roo-tpl-' + this.dataName,true) :
15998 if(!node || node.parentNode == el){
16001 var p = node.parentNode;
16002 while(p && p != el){
16003 if(p.parentNode == el){
16012 onClick : function(e){
16013 var item = this.findItemFromChild(e.getTarget());
16015 var index = this.indexOf(item);
16016 if(this.onItemClick(item, index, e) !== false){
16017 this.fireEvent("click", this, index, item, e);
16020 this.clearSelections();
16025 onContextMenu : function(e){
16026 var item = this.findItemFromChild(e.getTarget());
16028 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16033 onDblClick : function(e){
16034 var item = this.findItemFromChild(e.getTarget());
16036 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16040 onItemClick : function(item, index, e)
16042 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16045 if (this.toggleSelect) {
16046 var m = this.isSelected(item) ? 'unselect' : 'select';
16049 _t[m](item, true, false);
16052 if(this.multiSelect || this.singleSelect){
16053 if(this.multiSelect && e.shiftKey && this.lastSelection){
16054 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16056 this.select(item, this.multiSelect && e.ctrlKey);
16057 this.lastSelection = item;
16060 if(!this.tickable){
16061 e.preventDefault();
16069 * Get the number of selected nodes.
16072 getSelectionCount : function(){
16073 return this.selections.length;
16077 * Get the currently selected nodes.
16078 * @return {Array} An array of HTMLElements
16080 getSelectedNodes : function(){
16081 return this.selections;
16085 * Get the indexes of the selected nodes.
16088 getSelectedIndexes : function(){
16089 var indexes = [], s = this.selections;
16090 for(var i = 0, len = s.length; i < len; i++){
16091 indexes.push(s[i].nodeIndex);
16097 * Clear all selections
16098 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16100 clearSelections : function(suppressEvent){
16101 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16102 this.cmp.elements = this.selections;
16103 this.cmp.removeClass(this.selectedClass);
16104 this.selections = [];
16105 if(!suppressEvent){
16106 this.fireEvent("selectionchange", this, this.selections);
16112 * Returns true if the passed node is selected
16113 * @param {HTMLElement/Number} node The node or node index
16114 * @return {Boolean}
16116 isSelected : function(node){
16117 var s = this.selections;
16121 node = this.getNode(node);
16122 return s.indexOf(node) !== -1;
16127 * @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
16128 * @param {Boolean} keepExisting (optional) true to keep existing selections
16129 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16131 select : function(nodeInfo, keepExisting, suppressEvent){
16132 if(nodeInfo instanceof Array){
16134 this.clearSelections(true);
16136 for(var i = 0, len = nodeInfo.length; i < len; i++){
16137 this.select(nodeInfo[i], true, true);
16141 var node = this.getNode(nodeInfo);
16142 if(!node || this.isSelected(node)){
16143 return; // already selected.
16146 this.clearSelections(true);
16149 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16150 Roo.fly(node).addClass(this.selectedClass);
16151 this.selections.push(node);
16152 if(!suppressEvent){
16153 this.fireEvent("selectionchange", this, this.selections);
16161 * @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
16162 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16163 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16165 unselect : function(nodeInfo, keepExisting, suppressEvent)
16167 if(nodeInfo instanceof Array){
16168 Roo.each(this.selections, function(s) {
16169 this.unselect(s, nodeInfo);
16173 var node = this.getNode(nodeInfo);
16174 if(!node || !this.isSelected(node)){
16175 //Roo.log("not selected");
16176 return; // not selected.
16180 Roo.each(this.selections, function(s) {
16182 Roo.fly(node).removeClass(this.selectedClass);
16189 this.selections= ns;
16190 this.fireEvent("selectionchange", this, this.selections);
16194 * Gets a template node.
16195 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16196 * @return {HTMLElement} The node or null if it wasn't found
16198 getNode : function(nodeInfo){
16199 if(typeof nodeInfo == "string"){
16200 return document.getElementById(nodeInfo);
16201 }else if(typeof nodeInfo == "number"){
16202 return this.nodes[nodeInfo];
16208 * Gets a range template nodes.
16209 * @param {Number} startIndex
16210 * @param {Number} endIndex
16211 * @return {Array} An array of nodes
16213 getNodes : function(start, end){
16214 var ns = this.nodes;
16215 start = start || 0;
16216 end = typeof end == "undefined" ? ns.length - 1 : end;
16219 for(var i = start; i <= end; i++){
16223 for(var i = start; i >= end; i--){
16231 * Finds the index of the passed node
16232 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16233 * @return {Number} The index of the node or -1
16235 indexOf : function(node){
16236 node = this.getNode(node);
16237 if(typeof node.nodeIndex == "number"){
16238 return node.nodeIndex;
16240 var ns = this.nodes;
16241 for(var i = 0, len = ns.length; i < len; i++){
16252 * based on jquery fullcalendar
16256 Roo.bootstrap = Roo.bootstrap || {};
16258 * @class Roo.bootstrap.Calendar
16259 * @extends Roo.bootstrap.Component
16260 * Bootstrap Calendar class
16261 * @cfg {Boolean} loadMask (true|false) default false
16262 * @cfg {Object} header generate the user specific header of the calendar, default false
16265 * Create a new Container
16266 * @param {Object} config The config object
16271 Roo.bootstrap.Calendar = function(config){
16272 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16276 * Fires when a date is selected
16277 * @param {DatePicker} this
16278 * @param {Date} date The selected date
16282 * @event monthchange
16283 * Fires when the displayed month changes
16284 * @param {DatePicker} this
16285 * @param {Date} date The selected month
16287 'monthchange': true,
16289 * @event evententer
16290 * Fires when mouse over an event
16291 * @param {Calendar} this
16292 * @param {event} Event
16294 'evententer': true,
16296 * @event eventleave
16297 * Fires when the mouse leaves an
16298 * @param {Calendar} this
16301 'eventleave': true,
16303 * @event eventclick
16304 * Fires when the mouse click an
16305 * @param {Calendar} this
16314 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16317 * @cfg {Number} startDay
16318 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16326 getAutoCreate : function(){
16329 var fc_button = function(name, corner, style, content ) {
16330 return Roo.apply({},{
16332 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16334 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16337 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16348 style : 'width:100%',
16355 cls : 'fc-header-left',
16357 fc_button('prev', 'left', 'arrow', '‹' ),
16358 fc_button('next', 'right', 'arrow', '›' ),
16359 { tag: 'span', cls: 'fc-header-space' },
16360 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16368 cls : 'fc-header-center',
16372 cls: 'fc-header-title',
16375 html : 'month / year'
16383 cls : 'fc-header-right',
16385 /* fc_button('month', 'left', '', 'month' ),
16386 fc_button('week', '', '', 'week' ),
16387 fc_button('day', 'right', '', 'day' )
16399 header = this.header;
16402 var cal_heads = function() {
16404 // fixme - handle this.
16406 for (var i =0; i < Date.dayNames.length; i++) {
16407 var d = Date.dayNames[i];
16410 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16411 html : d.substring(0,3)
16415 ret[0].cls += ' fc-first';
16416 ret[6].cls += ' fc-last';
16419 var cal_cell = function(n) {
16422 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16427 cls: 'fc-day-number',
16431 cls: 'fc-day-content',
16435 style: 'position: relative;' // height: 17px;
16447 var cal_rows = function() {
16450 for (var r = 0; r < 6; r++) {
16457 for (var i =0; i < Date.dayNames.length; i++) {
16458 var d = Date.dayNames[i];
16459 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16462 row.cn[0].cls+=' fc-first';
16463 row.cn[0].cn[0].style = 'min-height:90px';
16464 row.cn[6].cls+=' fc-last';
16468 ret[0].cls += ' fc-first';
16469 ret[4].cls += ' fc-prev-last';
16470 ret[5].cls += ' fc-last';
16477 cls: 'fc-border-separate',
16478 style : 'width:100%',
16486 cls : 'fc-first fc-last',
16504 cls : 'fc-content',
16505 style : "position: relative;",
16508 cls : 'fc-view fc-view-month fc-grid',
16509 style : 'position: relative',
16510 unselectable : 'on',
16513 cls : 'fc-event-container',
16514 style : 'position:absolute;z-index:8;top:0;left:0;'
16532 initEvents : function()
16535 throw "can not find store for calendar";
16541 style: "text-align:center",
16545 style: "background-color:white;width:50%;margin:250 auto",
16549 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16560 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16562 var size = this.el.select('.fc-content', true).first().getSize();
16563 this.maskEl.setSize(size.width, size.height);
16564 this.maskEl.enableDisplayMode("block");
16565 if(!this.loadMask){
16566 this.maskEl.hide();
16569 this.store = Roo.factory(this.store, Roo.data);
16570 this.store.on('load', this.onLoad, this);
16571 this.store.on('beforeload', this.onBeforeLoad, this);
16575 this.cells = this.el.select('.fc-day',true);
16576 //Roo.log(this.cells);
16577 this.textNodes = this.el.query('.fc-day-number');
16578 this.cells.addClassOnOver('fc-state-hover');
16580 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16581 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16582 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16583 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16585 this.on('monthchange', this.onMonthChange, this);
16587 this.update(new Date().clearTime());
16590 resize : function() {
16591 var sz = this.el.getSize();
16593 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16594 this.el.select('.fc-day-content div',true).setHeight(34);
16599 showPrevMonth : function(e){
16600 this.update(this.activeDate.add("mo", -1));
16602 showToday : function(e){
16603 this.update(new Date().clearTime());
16606 showNextMonth : function(e){
16607 this.update(this.activeDate.add("mo", 1));
16611 showPrevYear : function(){
16612 this.update(this.activeDate.add("y", -1));
16616 showNextYear : function(){
16617 this.update(this.activeDate.add("y", 1));
16622 update : function(date)
16624 var vd = this.activeDate;
16625 this.activeDate = date;
16626 // if(vd && this.el){
16627 // var t = date.getTime();
16628 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16629 // Roo.log('using add remove');
16631 // this.fireEvent('monthchange', this, date);
16633 // this.cells.removeClass("fc-state-highlight");
16634 // this.cells.each(function(c){
16635 // if(c.dateValue == t){
16636 // c.addClass("fc-state-highlight");
16637 // setTimeout(function(){
16638 // try{c.dom.firstChild.focus();}catch(e){}
16648 var days = date.getDaysInMonth();
16650 var firstOfMonth = date.getFirstDateOfMonth();
16651 var startingPos = firstOfMonth.getDay()-this.startDay;
16653 if(startingPos < this.startDay){
16657 var pm = date.add(Date.MONTH, -1);
16658 var prevStart = pm.getDaysInMonth()-startingPos;
16660 this.cells = this.el.select('.fc-day',true);
16661 this.textNodes = this.el.query('.fc-day-number');
16662 this.cells.addClassOnOver('fc-state-hover');
16664 var cells = this.cells.elements;
16665 var textEls = this.textNodes;
16667 Roo.each(cells, function(cell){
16668 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16671 days += startingPos;
16673 // convert everything to numbers so it's fast
16674 var day = 86400000;
16675 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16678 //Roo.log(prevStart);
16680 var today = new Date().clearTime().getTime();
16681 var sel = date.clearTime().getTime();
16682 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16683 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16684 var ddMatch = this.disabledDatesRE;
16685 var ddText = this.disabledDatesText;
16686 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16687 var ddaysText = this.disabledDaysText;
16688 var format = this.format;
16690 var setCellClass = function(cal, cell){
16694 //Roo.log('set Cell Class');
16696 var t = d.getTime();
16700 cell.dateValue = t;
16702 cell.className += " fc-today";
16703 cell.className += " fc-state-highlight";
16704 cell.title = cal.todayText;
16707 // disable highlight in other month..
16708 //cell.className += " fc-state-highlight";
16713 cell.className = " fc-state-disabled";
16714 cell.title = cal.minText;
16718 cell.className = " fc-state-disabled";
16719 cell.title = cal.maxText;
16723 if(ddays.indexOf(d.getDay()) != -1){
16724 cell.title = ddaysText;
16725 cell.className = " fc-state-disabled";
16728 if(ddMatch && format){
16729 var fvalue = d.dateFormat(format);
16730 if(ddMatch.test(fvalue)){
16731 cell.title = ddText.replace("%0", fvalue);
16732 cell.className = " fc-state-disabled";
16736 if (!cell.initialClassName) {
16737 cell.initialClassName = cell.dom.className;
16740 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16745 for(; i < startingPos; i++) {
16746 textEls[i].innerHTML = (++prevStart);
16747 d.setDate(d.getDate()+1);
16749 cells[i].className = "fc-past fc-other-month";
16750 setCellClass(this, cells[i]);
16755 for(; i < days; i++){
16756 intDay = i - startingPos + 1;
16757 textEls[i].innerHTML = (intDay);
16758 d.setDate(d.getDate()+1);
16760 cells[i].className = ''; // "x-date-active";
16761 setCellClass(this, cells[i]);
16765 for(; i < 42; i++) {
16766 textEls[i].innerHTML = (++extraDays);
16767 d.setDate(d.getDate()+1);
16769 cells[i].className = "fc-future fc-other-month";
16770 setCellClass(this, cells[i]);
16773 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16775 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16777 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16778 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16780 if(totalRows != 6){
16781 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16782 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16785 this.fireEvent('monthchange', this, date);
16789 if(!this.internalRender){
16790 var main = this.el.dom.firstChild;
16791 var w = main.offsetWidth;
16792 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16793 Roo.fly(main).setWidth(w);
16794 this.internalRender = true;
16795 // opera does not respect the auto grow header center column
16796 // then, after it gets a width opera refuses to recalculate
16797 // without a second pass
16798 if(Roo.isOpera && !this.secondPass){
16799 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16800 this.secondPass = true;
16801 this.update.defer(10, this, [date]);
16808 findCell : function(dt) {
16809 dt = dt.clearTime().getTime();
16811 this.cells.each(function(c){
16812 //Roo.log("check " +c.dateValue + '?=' + dt);
16813 if(c.dateValue == dt){
16823 findCells : function(ev) {
16824 var s = ev.start.clone().clearTime().getTime();
16826 var e= ev.end.clone().clearTime().getTime();
16829 this.cells.each(function(c){
16830 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16832 if(c.dateValue > e){
16835 if(c.dateValue < s){
16844 // findBestRow: function(cells)
16848 // for (var i =0 ; i < cells.length;i++) {
16849 // ret = Math.max(cells[i].rows || 0,ret);
16856 addItem : function(ev)
16858 // look for vertical location slot in
16859 var cells = this.findCells(ev);
16861 // ev.row = this.findBestRow(cells);
16863 // work out the location.
16867 for(var i =0; i < cells.length; i++) {
16869 cells[i].row = cells[0].row;
16872 cells[i].row = cells[i].row + 1;
16882 if (crow.start.getY() == cells[i].getY()) {
16884 crow.end = cells[i];
16901 cells[0].events.push(ev);
16903 this.calevents.push(ev);
16906 clearEvents: function() {
16908 if(!this.calevents){
16912 Roo.each(this.cells.elements, function(c){
16918 Roo.each(this.calevents, function(e) {
16919 Roo.each(e.els, function(el) {
16920 el.un('mouseenter' ,this.onEventEnter, this);
16921 el.un('mouseleave' ,this.onEventLeave, this);
16926 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16932 renderEvents: function()
16936 this.cells.each(function(c) {
16945 if(c.row != c.events.length){
16946 r = 4 - (4 - (c.row - c.events.length));
16949 c.events = ev.slice(0, r);
16950 c.more = ev.slice(r);
16952 if(c.more.length && c.more.length == 1){
16953 c.events.push(c.more.pop());
16956 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16960 this.cells.each(function(c) {
16962 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16965 for (var e = 0; e < c.events.length; e++){
16966 var ev = c.events[e];
16967 var rows = ev.rows;
16969 for(var i = 0; i < rows.length; i++) {
16971 // how many rows should it span..
16974 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16975 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16977 unselectable : "on",
16980 cls: 'fc-event-inner',
16984 // cls: 'fc-event-time',
16985 // html : cells.length > 1 ? '' : ev.time
16989 cls: 'fc-event-title',
16990 html : String.format('{0}', ev.title)
16997 cls: 'ui-resizable-handle ui-resizable-e',
16998 html : '  '
17005 cfg.cls += ' fc-event-start';
17007 if ((i+1) == rows.length) {
17008 cfg.cls += ' fc-event-end';
17011 var ctr = _this.el.select('.fc-event-container',true).first();
17012 var cg = ctr.createChild(cfg);
17014 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17015 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17017 var r = (c.more.length) ? 1 : 0;
17018 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17019 cg.setWidth(ebox.right - sbox.x -2);
17021 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17022 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17023 cg.on('click', _this.onEventClick, _this, ev);
17034 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17035 style : 'position: absolute',
17036 unselectable : "on",
17039 cls: 'fc-event-inner',
17043 cls: 'fc-event-title',
17051 cls: 'ui-resizable-handle ui-resizable-e',
17052 html : '  '
17058 var ctr = _this.el.select('.fc-event-container',true).first();
17059 var cg = ctr.createChild(cfg);
17061 var sbox = c.select('.fc-day-content',true).first().getBox();
17062 var ebox = c.select('.fc-day-content',true).first().getBox();
17064 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17065 cg.setWidth(ebox.right - sbox.x -2);
17067 cg.on('click', _this.onMoreEventClick, _this, c.more);
17077 onEventEnter: function (e, el,event,d) {
17078 this.fireEvent('evententer', this, el, event);
17081 onEventLeave: function (e, el,event,d) {
17082 this.fireEvent('eventleave', this, el, event);
17085 onEventClick: function (e, el,event,d) {
17086 this.fireEvent('eventclick', this, el, event);
17089 onMonthChange: function () {
17093 onMoreEventClick: function(e, el, more)
17097 this.calpopover.placement = 'right';
17098 this.calpopover.setTitle('More');
17100 this.calpopover.setContent('');
17102 var ctr = this.calpopover.el.select('.popover-content', true).first();
17104 Roo.each(more, function(m){
17106 cls : 'fc-event-hori fc-event-draggable',
17109 var cg = ctr.createChild(cfg);
17111 cg.on('click', _this.onEventClick, _this, m);
17114 this.calpopover.show(el);
17119 onLoad: function ()
17121 this.calevents = [];
17124 if(this.store.getCount() > 0){
17125 this.store.data.each(function(d){
17128 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17129 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17130 time : d.data.start_time,
17131 title : d.data.title,
17132 description : d.data.description,
17133 venue : d.data.venue
17138 this.renderEvents();
17140 if(this.calevents.length && this.loadMask){
17141 this.maskEl.hide();
17145 onBeforeLoad: function()
17147 this.clearEvents();
17149 this.maskEl.show();
17163 * @class Roo.bootstrap.Popover
17164 * @extends Roo.bootstrap.Component
17165 * Bootstrap Popover class
17166 * @cfg {String} html contents of the popover (or false to use children..)
17167 * @cfg {String} title of popover (or false to hide)
17168 * @cfg {String} placement how it is placed
17169 * @cfg {String} trigger click || hover (or false to trigger manually)
17170 * @cfg {String} over what (parent or false to trigger manually.)
17171 * @cfg {Number} delay - delay before showing
17174 * Create a new Popover
17175 * @param {Object} config The config object
17178 Roo.bootstrap.Popover = function(config){
17179 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17185 * After the popover show
17187 * @param {Roo.bootstrap.Popover} this
17192 * After the popover hide
17194 * @param {Roo.bootstrap.Popover} this
17200 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17202 title: 'Fill in a title',
17205 placement : 'right',
17206 trigger : 'hover', // hover
17212 can_build_overlaid : false,
17214 getChildContainer : function()
17216 return this.el.select('.popover-content',true).first();
17219 getAutoCreate : function(){
17222 cls : 'popover roo-dynamic',
17223 style: 'display:block',
17229 cls : 'popover-inner',
17233 cls: 'popover-title',
17237 cls : 'popover-content',
17248 setTitle: function(str)
17251 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17253 setContent: function(str)
17256 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17258 // as it get's added to the bottom of the page.
17259 onRender : function(ct, position)
17261 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17263 var cfg = Roo.apply({}, this.getAutoCreate());
17267 cfg.cls += ' ' + this.cls;
17270 cfg.style = this.style;
17272 //Roo.log("adding to ");
17273 this.el = Roo.get(document.body).createChild(cfg, position);
17274 // Roo.log(this.el);
17279 initEvents : function()
17281 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17282 this.el.enableDisplayMode('block');
17284 if (this.over === false) {
17287 if (this.triggers === false) {
17290 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17291 var triggers = this.trigger ? this.trigger.split(' ') : [];
17292 Roo.each(triggers, function(trigger) {
17294 if (trigger == 'click') {
17295 on_el.on('click', this.toggle, this);
17296 } else if (trigger != 'manual') {
17297 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17298 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17300 on_el.on(eventIn ,this.enter, this);
17301 on_el.on(eventOut, this.leave, this);
17312 toggle : function () {
17313 this.hoverState == 'in' ? this.leave() : this.enter();
17316 enter : function () {
17318 clearTimeout(this.timeout);
17320 this.hoverState = 'in';
17322 if (!this.delay || !this.delay.show) {
17327 this.timeout = setTimeout(function () {
17328 if (_t.hoverState == 'in') {
17331 }, this.delay.show)
17334 leave : function() {
17335 clearTimeout(this.timeout);
17337 this.hoverState = 'out';
17339 if (!this.delay || !this.delay.hide) {
17344 this.timeout = setTimeout(function () {
17345 if (_t.hoverState == 'out') {
17348 }, this.delay.hide)
17351 show : function (on_el)
17354 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17358 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17359 if (this.html !== false) {
17360 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17362 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17363 if (!this.title.length) {
17364 this.el.select('.popover-title',true).hide();
17367 var placement = typeof this.placement == 'function' ?
17368 this.placement.call(this, this.el, on_el) :
17371 var autoToken = /\s?auto?\s?/i;
17372 var autoPlace = autoToken.test(placement);
17374 placement = placement.replace(autoToken, '') || 'top';
17378 //this.el.setXY([0,0]);
17380 this.el.dom.style.display='block';
17381 this.el.addClass(placement);
17383 //this.el.appendTo(on_el);
17385 var p = this.getPosition();
17386 var box = this.el.getBox();
17391 var align = Roo.bootstrap.Popover.alignment[placement];
17394 this.el.alignTo(on_el, align[0],align[1]);
17395 //var arrow = this.el.select('.arrow',true).first();
17396 //arrow.set(align[2],
17398 this.el.addClass('in');
17401 if (this.el.hasClass('fade')) {
17405 this.hoverState = 'in';
17407 this.fireEvent('show', this);
17412 this.el.setXY([0,0]);
17413 this.el.removeClass('in');
17415 this.hoverState = null;
17417 this.fireEvent('hide', this);
17422 Roo.bootstrap.Popover.alignment = {
17423 'left' : ['r-l', [-10,0], 'right'],
17424 'right' : ['l-r', [10,0], 'left'],
17425 'bottom' : ['t-b', [0,10], 'top'],
17426 'top' : [ 'b-t', [0,-10], 'bottom']
17437 * @class Roo.bootstrap.Progress
17438 * @extends Roo.bootstrap.Component
17439 * Bootstrap Progress class
17440 * @cfg {Boolean} striped striped of the progress bar
17441 * @cfg {Boolean} active animated of the progress bar
17445 * Create a new Progress
17446 * @param {Object} config The config object
17449 Roo.bootstrap.Progress = function(config){
17450 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17453 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17458 getAutoCreate : function(){
17466 cfg.cls += ' progress-striped';
17470 cfg.cls += ' active';
17489 * @class Roo.bootstrap.ProgressBar
17490 * @extends Roo.bootstrap.Component
17491 * Bootstrap ProgressBar class
17492 * @cfg {Number} aria_valuenow aria-value now
17493 * @cfg {Number} aria_valuemin aria-value min
17494 * @cfg {Number} aria_valuemax aria-value max
17495 * @cfg {String} label label for the progress bar
17496 * @cfg {String} panel (success | info | warning | danger )
17497 * @cfg {String} role role of the progress bar
17498 * @cfg {String} sr_only text
17502 * Create a new ProgressBar
17503 * @param {Object} config The config object
17506 Roo.bootstrap.ProgressBar = function(config){
17507 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17510 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17514 aria_valuemax : 100,
17520 getAutoCreate : function()
17525 cls: 'progress-bar',
17526 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17538 cfg.role = this.role;
17541 if(this.aria_valuenow){
17542 cfg['aria-valuenow'] = this.aria_valuenow;
17545 if(this.aria_valuemin){
17546 cfg['aria-valuemin'] = this.aria_valuemin;
17549 if(this.aria_valuemax){
17550 cfg['aria-valuemax'] = this.aria_valuemax;
17553 if(this.label && !this.sr_only){
17554 cfg.html = this.label;
17558 cfg.cls += ' progress-bar-' + this.panel;
17564 update : function(aria_valuenow)
17566 this.aria_valuenow = aria_valuenow;
17568 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17583 * @class Roo.bootstrap.TabGroup
17584 * @extends Roo.bootstrap.Column
17585 * Bootstrap Column class
17586 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17587 * @cfg {Boolean} carousel true to make the group behave like a carousel
17588 * @cfg {Boolean} bullets show bullets for the panels
17589 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17590 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17591 * @cfg {Boolean} showarrow (true|false) show arrow default true
17594 * Create a new TabGroup
17595 * @param {Object} config The config object
17598 Roo.bootstrap.TabGroup = function(config){
17599 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17601 this.navId = Roo.id();
17604 Roo.bootstrap.TabGroup.register(this);
17608 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17611 transition : false,
17616 slideOnTouch : false,
17619 getAutoCreate : function()
17621 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17623 cfg.cls += ' tab-content';
17625 if (this.carousel) {
17626 cfg.cls += ' carousel slide';
17629 cls : 'carousel-inner',
17633 if(this.bullets && !Roo.isTouch){
17636 cls : 'carousel-bullets',
17640 if(this.bullets_cls){
17641 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17648 cfg.cn[0].cn.push(bullets);
17651 if(this.showarrow){
17652 cfg.cn[0].cn.push({
17654 class : 'carousel-arrow',
17658 class : 'carousel-prev',
17662 class : 'fa fa-chevron-left'
17668 class : 'carousel-next',
17672 class : 'fa fa-chevron-right'
17685 initEvents: function()
17687 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17688 // this.el.on("touchstart", this.onTouchStart, this);
17691 if(this.autoslide){
17694 this.slideFn = window.setInterval(function() {
17695 _this.showPanelNext();
17699 if(this.showarrow){
17700 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17701 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17707 // onTouchStart : function(e, el, o)
17709 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17713 // this.showPanelNext();
17717 getChildContainer : function()
17719 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17723 * register a Navigation item
17724 * @param {Roo.bootstrap.NavItem} the navitem to add
17726 register : function(item)
17728 this.tabs.push( item);
17729 item.navId = this.navId; // not really needed..
17734 getActivePanel : function()
17737 Roo.each(this.tabs, function(t) {
17747 getPanelByName : function(n)
17750 Roo.each(this.tabs, function(t) {
17751 if (t.tabId == n) {
17759 indexOfPanel : function(p)
17762 Roo.each(this.tabs, function(t,i) {
17763 if (t.tabId == p.tabId) {
17772 * show a specific panel
17773 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17774 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17776 showPanel : function (pan)
17778 if(this.transition || typeof(pan) == 'undefined'){
17779 Roo.log("waiting for the transitionend");
17783 if (typeof(pan) == 'number') {
17784 pan = this.tabs[pan];
17787 if (typeof(pan) == 'string') {
17788 pan = this.getPanelByName(pan);
17791 var cur = this.getActivePanel();
17794 Roo.log('pan or acitve pan is undefined');
17798 if (pan.tabId == this.getActivePanel().tabId) {
17802 if (false === cur.fireEvent('beforedeactivate')) {
17806 if(this.bullets > 0 && !Roo.isTouch){
17807 this.setActiveBullet(this.indexOfPanel(pan));
17810 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17812 this.transition = true;
17813 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17814 var lr = dir == 'next' ? 'left' : 'right';
17815 pan.el.addClass(dir); // or prev
17816 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17817 cur.el.addClass(lr); // or right
17818 pan.el.addClass(lr);
17821 cur.el.on('transitionend', function() {
17822 Roo.log("trans end?");
17824 pan.el.removeClass([lr,dir]);
17825 pan.setActive(true);
17827 cur.el.removeClass([lr]);
17828 cur.setActive(false);
17830 _this.transition = false;
17832 }, this, { single: true } );
17837 cur.setActive(false);
17838 pan.setActive(true);
17843 showPanelNext : function()
17845 var i = this.indexOfPanel(this.getActivePanel());
17847 if (i >= this.tabs.length - 1 && !this.autoslide) {
17851 if (i >= this.tabs.length - 1 && this.autoslide) {
17855 this.showPanel(this.tabs[i+1]);
17858 showPanelPrev : function()
17860 var i = this.indexOfPanel(this.getActivePanel());
17862 if (i < 1 && !this.autoslide) {
17866 if (i < 1 && this.autoslide) {
17867 i = this.tabs.length;
17870 this.showPanel(this.tabs[i-1]);
17874 addBullet: function()
17876 if(!this.bullets || Roo.isTouch){
17879 var ctr = this.el.select('.carousel-bullets',true).first();
17880 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17881 var bullet = ctr.createChild({
17882 cls : 'bullet bullet-' + i
17883 },ctr.dom.lastChild);
17888 bullet.on('click', (function(e, el, o, ii, t){
17890 e.preventDefault();
17892 this.showPanel(ii);
17894 if(this.autoslide && this.slideFn){
17895 clearInterval(this.slideFn);
17896 this.slideFn = window.setInterval(function() {
17897 _this.showPanelNext();
17901 }).createDelegate(this, [i, bullet], true));
17906 setActiveBullet : function(i)
17912 Roo.each(this.el.select('.bullet', true).elements, function(el){
17913 el.removeClass('selected');
17916 var bullet = this.el.select('.bullet-' + i, true).first();
17922 bullet.addClass('selected');
17933 Roo.apply(Roo.bootstrap.TabGroup, {
17937 * register a Navigation Group
17938 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17940 register : function(navgrp)
17942 this.groups[navgrp.navId] = navgrp;
17946 * fetch a Navigation Group based on the navigation ID
17947 * if one does not exist , it will get created.
17948 * @param {string} the navgroup to add
17949 * @returns {Roo.bootstrap.NavGroup} the navgroup
17951 get: function(navId) {
17952 if (typeof(this.groups[navId]) == 'undefined') {
17953 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17955 return this.groups[navId] ;
17970 * @class Roo.bootstrap.TabPanel
17971 * @extends Roo.bootstrap.Component
17972 * Bootstrap TabPanel class
17973 * @cfg {Boolean} active panel active
17974 * @cfg {String} html panel content
17975 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17976 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17977 * @cfg {String} href click to link..
17981 * Create a new TabPanel
17982 * @param {Object} config The config object
17985 Roo.bootstrap.TabPanel = function(config){
17986 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17990 * Fires when the active status changes
17991 * @param {Roo.bootstrap.TabPanel} this
17992 * @param {Boolean} state the new state
17997 * @event beforedeactivate
17998 * Fires before a tab is de-activated - can be used to do validation on a form.
17999 * @param {Roo.bootstrap.TabPanel} this
18000 * @return {Boolean} false if there is an error
18003 'beforedeactivate': true
18006 this.tabId = this.tabId || Roo.id();
18010 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18018 getAutoCreate : function(){
18021 // item is needed for carousel - not sure if it has any effect otherwise
18022 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18023 html: this.html || ''
18027 cfg.cls += ' active';
18031 cfg.tabId = this.tabId;
18038 initEvents: function()
18040 var p = this.parent();
18042 this.navId = this.navId || p.navId;
18044 if (typeof(this.navId) != 'undefined') {
18045 // not really needed.. but just in case.. parent should be a NavGroup.
18046 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18050 var i = tg.tabs.length - 1;
18052 if(this.active && tg.bullets > 0 && i < tg.bullets){
18053 tg.setActiveBullet(i);
18057 this.el.on('click', this.onClick, this);
18060 this.el.on("touchstart", this.onTouchStart, this);
18061 this.el.on("touchmove", this.onTouchMove, this);
18062 this.el.on("touchend", this.onTouchEnd, this);
18067 onRender : function(ct, position)
18069 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18072 setActive : function(state)
18074 Roo.log("panel - set active " + this.tabId + "=" + state);
18076 this.active = state;
18078 this.el.removeClass('active');
18080 } else if (!this.el.hasClass('active')) {
18081 this.el.addClass('active');
18084 this.fireEvent('changed', this, state);
18087 onClick : function(e)
18089 e.preventDefault();
18091 if(!this.href.length){
18095 window.location.href = this.href;
18104 onTouchStart : function(e)
18106 this.swiping = false;
18108 this.startX = e.browserEvent.touches[0].clientX;
18109 this.startY = e.browserEvent.touches[0].clientY;
18112 onTouchMove : function(e)
18114 this.swiping = true;
18116 this.endX = e.browserEvent.touches[0].clientX;
18117 this.endY = e.browserEvent.touches[0].clientY;
18120 onTouchEnd : function(e)
18127 var tabGroup = this.parent();
18129 if(this.endX > this.startX){ // swiping right
18130 tabGroup.showPanelPrev();
18134 if(this.startX > this.endX){ // swiping left
18135 tabGroup.showPanelNext();
18154 * @class Roo.bootstrap.DateField
18155 * @extends Roo.bootstrap.Input
18156 * Bootstrap DateField class
18157 * @cfg {Number} weekStart default 0
18158 * @cfg {String} viewMode default empty, (months|years)
18159 * @cfg {String} minViewMode default empty, (months|years)
18160 * @cfg {Number} startDate default -Infinity
18161 * @cfg {Number} endDate default Infinity
18162 * @cfg {Boolean} todayHighlight default false
18163 * @cfg {Boolean} todayBtn default false
18164 * @cfg {Boolean} calendarWeeks default false
18165 * @cfg {Object} daysOfWeekDisabled default empty
18166 * @cfg {Boolean} singleMode default false (true | false)
18168 * @cfg {Boolean} keyboardNavigation default true
18169 * @cfg {String} language default en
18172 * Create a new DateField
18173 * @param {Object} config The config object
18176 Roo.bootstrap.DateField = function(config){
18177 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18181 * Fires when this field show.
18182 * @param {Roo.bootstrap.DateField} this
18183 * @param {Mixed} date The date value
18188 * Fires when this field hide.
18189 * @param {Roo.bootstrap.DateField} this
18190 * @param {Mixed} date The date value
18195 * Fires when select a date.
18196 * @param {Roo.bootstrap.DateField} this
18197 * @param {Mixed} date The date value
18201 * @event beforeselect
18202 * Fires when before select a date.
18203 * @param {Roo.bootstrap.DateField} this
18204 * @param {Mixed} date The date value
18206 beforeselect : true
18210 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18213 * @cfg {String} format
18214 * The default date format string which can be overriden for localization support. The format must be
18215 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18219 * @cfg {String} altFormats
18220 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18221 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18223 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18231 todayHighlight : false,
18237 keyboardNavigation: true,
18239 calendarWeeks: false,
18241 startDate: -Infinity,
18245 daysOfWeekDisabled: [],
18249 singleMode : false,
18251 UTCDate: function()
18253 return new Date(Date.UTC.apply(Date, arguments));
18256 UTCToday: function()
18258 var today = new Date();
18259 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18262 getDate: function() {
18263 var d = this.getUTCDate();
18264 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18267 getUTCDate: function() {
18271 setDate: function(d) {
18272 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18275 setUTCDate: function(d) {
18277 this.setValue(this.formatDate(this.date));
18280 onRender: function(ct, position)
18283 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18285 this.language = this.language || 'en';
18286 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18287 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18289 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18290 this.format = this.format || 'm/d/y';
18291 this.isInline = false;
18292 this.isInput = true;
18293 this.component = this.el.select('.add-on', true).first() || false;
18294 this.component = (this.component && this.component.length === 0) ? false : this.component;
18295 this.hasInput = this.component && this.inputEl().length;
18297 if (typeof(this.minViewMode === 'string')) {
18298 switch (this.minViewMode) {
18300 this.minViewMode = 1;
18303 this.minViewMode = 2;
18306 this.minViewMode = 0;
18311 if (typeof(this.viewMode === 'string')) {
18312 switch (this.viewMode) {
18325 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18327 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18329 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18331 this.picker().on('mousedown', this.onMousedown, this);
18332 this.picker().on('click', this.onClick, this);
18334 this.picker().addClass('datepicker-dropdown');
18336 this.startViewMode = this.viewMode;
18338 if(this.singleMode){
18339 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18340 v.setVisibilityMode(Roo.Element.DISPLAY);
18344 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18345 v.setStyle('width', '189px');
18349 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18350 if(!this.calendarWeeks){
18355 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18356 v.attr('colspan', function(i, val){
18357 return parseInt(val) + 1;
18362 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18364 this.setStartDate(this.startDate);
18365 this.setEndDate(this.endDate);
18367 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18374 if(this.isInline) {
18379 picker : function()
18381 return this.pickerEl;
18382 // return this.el.select('.datepicker', true).first();
18385 fillDow: function()
18387 var dowCnt = this.weekStart;
18396 if(this.calendarWeeks){
18404 while (dowCnt < this.weekStart + 7) {
18408 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18412 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18415 fillMonths: function()
18418 var months = this.picker().select('>.datepicker-months td', true).first();
18420 months.dom.innerHTML = '';
18426 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18429 months.createChild(month);
18436 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;
18438 if (this.date < this.startDate) {
18439 this.viewDate = new Date(this.startDate);
18440 } else if (this.date > this.endDate) {
18441 this.viewDate = new Date(this.endDate);
18443 this.viewDate = new Date(this.date);
18451 var d = new Date(this.viewDate),
18452 year = d.getUTCFullYear(),
18453 month = d.getUTCMonth(),
18454 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18455 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18456 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18457 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18458 currentDate = this.date && this.date.valueOf(),
18459 today = this.UTCToday();
18461 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18463 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18465 // this.picker.select('>tfoot th.today').
18466 // .text(dates[this.language].today)
18467 // .toggle(this.todayBtn !== false);
18469 this.updateNavArrows();
18472 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18474 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18476 prevMonth.setUTCDate(day);
18478 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18480 var nextMonth = new Date(prevMonth);
18482 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18484 nextMonth = nextMonth.valueOf();
18486 var fillMonths = false;
18488 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18490 while(prevMonth.valueOf() < nextMonth) {
18493 if (prevMonth.getUTCDay() === this.weekStart) {
18495 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18503 if(this.calendarWeeks){
18504 // ISO 8601: First week contains first thursday.
18505 // ISO also states week starts on Monday, but we can be more abstract here.
18507 // Start of current week: based on weekstart/current date
18508 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18509 // Thursday of this week
18510 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18511 // First Thursday of year, year from thursday
18512 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18513 // Calendar week: ms between thursdays, div ms per day, div 7 days
18514 calWeek = (th - yth) / 864e5 / 7 + 1;
18516 fillMonths.cn.push({
18524 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18526 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18529 if (this.todayHighlight &&
18530 prevMonth.getUTCFullYear() == today.getFullYear() &&
18531 prevMonth.getUTCMonth() == today.getMonth() &&
18532 prevMonth.getUTCDate() == today.getDate()) {
18533 clsName += ' today';
18536 if (currentDate && prevMonth.valueOf() === currentDate) {
18537 clsName += ' active';
18540 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18541 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18542 clsName += ' disabled';
18545 fillMonths.cn.push({
18547 cls: 'day ' + clsName,
18548 html: prevMonth.getDate()
18551 prevMonth.setDate(prevMonth.getDate()+1);
18554 var currentYear = this.date && this.date.getUTCFullYear();
18555 var currentMonth = this.date && this.date.getUTCMonth();
18557 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18559 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18560 v.removeClass('active');
18562 if(currentYear === year && k === currentMonth){
18563 v.addClass('active');
18566 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18567 v.addClass('disabled');
18573 year = parseInt(year/10, 10) * 10;
18575 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18577 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18580 for (var i = -1; i < 11; i++) {
18581 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18583 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18591 showMode: function(dir)
18594 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18597 Roo.each(this.picker().select('>div',true).elements, function(v){
18598 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18601 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18606 if(this.isInline) {
18610 this.picker().removeClass(['bottom', 'top']);
18612 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18614 * place to the top of element!
18618 this.picker().addClass('top');
18619 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18624 this.picker().addClass('bottom');
18626 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18629 parseDate : function(value)
18631 if(!value || value instanceof Date){
18634 var v = Date.parseDate(value, this.format);
18635 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18636 v = Date.parseDate(value, 'Y-m-d');
18638 if(!v && this.altFormats){
18639 if(!this.altFormatsArray){
18640 this.altFormatsArray = this.altFormats.split("|");
18642 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18643 v = Date.parseDate(value, this.altFormatsArray[i]);
18649 formatDate : function(date, fmt)
18651 return (!date || !(date instanceof Date)) ?
18652 date : date.dateFormat(fmt || this.format);
18655 onFocus : function()
18657 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18661 onBlur : function()
18663 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18665 var d = this.inputEl().getValue();
18674 this.picker().show();
18678 this.fireEvent('show', this, this.date);
18683 if(this.isInline) {
18686 this.picker().hide();
18687 this.viewMode = this.startViewMode;
18690 this.fireEvent('hide', this, this.date);
18694 onMousedown: function(e)
18696 e.stopPropagation();
18697 e.preventDefault();
18702 Roo.bootstrap.DateField.superclass.keyup.call(this);
18706 setValue: function(v)
18708 if(this.fireEvent('beforeselect', this, v) !== false){
18709 var d = new Date(this.parseDate(v) ).clearTime();
18711 if(isNaN(d.getTime())){
18712 this.date = this.viewDate = '';
18713 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18717 v = this.formatDate(d);
18719 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18721 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18725 this.fireEvent('select', this, this.date);
18729 getValue: function()
18731 return this.formatDate(this.date);
18734 fireKey: function(e)
18736 if (!this.picker().isVisible()){
18737 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18743 var dateChanged = false,
18745 newDate, newViewDate;
18750 e.preventDefault();
18754 if (!this.keyboardNavigation) {
18757 dir = e.keyCode == 37 ? -1 : 1;
18760 newDate = this.moveYear(this.date, dir);
18761 newViewDate = this.moveYear(this.viewDate, dir);
18762 } else if (e.shiftKey){
18763 newDate = this.moveMonth(this.date, dir);
18764 newViewDate = this.moveMonth(this.viewDate, dir);
18766 newDate = new Date(this.date);
18767 newDate.setUTCDate(this.date.getUTCDate() + dir);
18768 newViewDate = new Date(this.viewDate);
18769 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18771 if (this.dateWithinRange(newDate)){
18772 this.date = newDate;
18773 this.viewDate = newViewDate;
18774 this.setValue(this.formatDate(this.date));
18776 e.preventDefault();
18777 dateChanged = true;
18782 if (!this.keyboardNavigation) {
18785 dir = e.keyCode == 38 ? -1 : 1;
18787 newDate = this.moveYear(this.date, dir);
18788 newViewDate = this.moveYear(this.viewDate, dir);
18789 } else if (e.shiftKey){
18790 newDate = this.moveMonth(this.date, dir);
18791 newViewDate = this.moveMonth(this.viewDate, dir);
18793 newDate = new Date(this.date);
18794 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18795 newViewDate = new Date(this.viewDate);
18796 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18798 if (this.dateWithinRange(newDate)){
18799 this.date = newDate;
18800 this.viewDate = newViewDate;
18801 this.setValue(this.formatDate(this.date));
18803 e.preventDefault();
18804 dateChanged = true;
18808 this.setValue(this.formatDate(this.date));
18810 e.preventDefault();
18813 this.setValue(this.formatDate(this.date));
18827 onClick: function(e)
18829 e.stopPropagation();
18830 e.preventDefault();
18832 var target = e.getTarget();
18834 if(target.nodeName.toLowerCase() === 'i'){
18835 target = Roo.get(target).dom.parentNode;
18838 var nodeName = target.nodeName;
18839 var className = target.className;
18840 var html = target.innerHTML;
18841 //Roo.log(nodeName);
18843 switch(nodeName.toLowerCase()) {
18845 switch(className) {
18851 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18852 switch(this.viewMode){
18854 this.viewDate = this.moveMonth(this.viewDate, dir);
18858 this.viewDate = this.moveYear(this.viewDate, dir);
18864 var date = new Date();
18865 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18867 this.setValue(this.formatDate(this.date));
18874 if (className.indexOf('disabled') < 0) {
18875 this.viewDate.setUTCDate(1);
18876 if (className.indexOf('month') > -1) {
18877 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18879 var year = parseInt(html, 10) || 0;
18880 this.viewDate.setUTCFullYear(year);
18884 if(this.singleMode){
18885 this.setValue(this.formatDate(this.viewDate));
18896 //Roo.log(className);
18897 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18898 var day = parseInt(html, 10) || 1;
18899 var year = this.viewDate.getUTCFullYear(),
18900 month = this.viewDate.getUTCMonth();
18902 if (className.indexOf('old') > -1) {
18909 } else if (className.indexOf('new') > -1) {
18917 //Roo.log([year,month,day]);
18918 this.date = this.UTCDate(year, month, day,0,0,0,0);
18919 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18921 //Roo.log(this.formatDate(this.date));
18922 this.setValue(this.formatDate(this.date));
18929 setStartDate: function(startDate)
18931 this.startDate = startDate || -Infinity;
18932 if (this.startDate !== -Infinity) {
18933 this.startDate = this.parseDate(this.startDate);
18936 this.updateNavArrows();
18939 setEndDate: function(endDate)
18941 this.endDate = endDate || Infinity;
18942 if (this.endDate !== Infinity) {
18943 this.endDate = this.parseDate(this.endDate);
18946 this.updateNavArrows();
18949 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18951 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18952 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18953 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18955 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18956 return parseInt(d, 10);
18959 this.updateNavArrows();
18962 updateNavArrows: function()
18964 if(this.singleMode){
18968 var d = new Date(this.viewDate),
18969 year = d.getUTCFullYear(),
18970 month = d.getUTCMonth();
18972 Roo.each(this.picker().select('.prev', true).elements, function(v){
18974 switch (this.viewMode) {
18977 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18983 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18990 Roo.each(this.picker().select('.next', true).elements, function(v){
18992 switch (this.viewMode) {
18995 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19001 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19009 moveMonth: function(date, dir)
19014 var new_date = new Date(date.valueOf()),
19015 day = new_date.getUTCDate(),
19016 month = new_date.getUTCMonth(),
19017 mag = Math.abs(dir),
19019 dir = dir > 0 ? 1 : -1;
19022 // If going back one month, make sure month is not current month
19023 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19025 return new_date.getUTCMonth() == month;
19027 // If going forward one month, make sure month is as expected
19028 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19030 return new_date.getUTCMonth() != new_month;
19032 new_month = month + dir;
19033 new_date.setUTCMonth(new_month);
19034 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19035 if (new_month < 0 || new_month > 11) {
19036 new_month = (new_month + 12) % 12;
19039 // For magnitudes >1, move one month at a time...
19040 for (var i=0; i<mag; i++) {
19041 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19042 new_date = this.moveMonth(new_date, dir);
19044 // ...then reset the day, keeping it in the new month
19045 new_month = new_date.getUTCMonth();
19046 new_date.setUTCDate(day);
19048 return new_month != new_date.getUTCMonth();
19051 // Common date-resetting loop -- if date is beyond end of month, make it
19054 new_date.setUTCDate(--day);
19055 new_date.setUTCMonth(new_month);
19060 moveYear: function(date, dir)
19062 return this.moveMonth(date, dir*12);
19065 dateWithinRange: function(date)
19067 return date >= this.startDate && date <= this.endDate;
19073 this.picker().remove();
19076 validateValue : function(value)
19078 if(value.length < 1) {
19079 if(this.allowBlank){
19085 if(value.length < this.minLength){
19088 if(value.length > this.maxLength){
19092 var vt = Roo.form.VTypes;
19093 if(!vt[this.vtype](value, this)){
19097 if(typeof this.validator == "function"){
19098 var msg = this.validator(value);
19104 if(this.regex && !this.regex.test(value)){
19108 if(typeof(this.parseDate(value)) == 'undefined'){
19112 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19116 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19126 Roo.apply(Roo.bootstrap.DateField, {
19137 html: '<i class="fa fa-arrow-left"/>'
19147 html: '<i class="fa fa-arrow-right"/>'
19189 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19190 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19191 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19192 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19193 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19206 navFnc: 'FullYear',
19211 navFnc: 'FullYear',
19216 Roo.apply(Roo.bootstrap.DateField, {
19220 cls: 'datepicker dropdown-menu roo-dynamic',
19224 cls: 'datepicker-days',
19228 cls: 'table-condensed',
19230 Roo.bootstrap.DateField.head,
19234 Roo.bootstrap.DateField.footer
19241 cls: 'datepicker-months',
19245 cls: 'table-condensed',
19247 Roo.bootstrap.DateField.head,
19248 Roo.bootstrap.DateField.content,
19249 Roo.bootstrap.DateField.footer
19256 cls: 'datepicker-years',
19260 cls: 'table-condensed',
19262 Roo.bootstrap.DateField.head,
19263 Roo.bootstrap.DateField.content,
19264 Roo.bootstrap.DateField.footer
19283 * @class Roo.bootstrap.TimeField
19284 * @extends Roo.bootstrap.Input
19285 * Bootstrap DateField class
19289 * Create a new TimeField
19290 * @param {Object} config The config object
19293 Roo.bootstrap.TimeField = function(config){
19294 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19298 * Fires when this field show.
19299 * @param {Roo.bootstrap.DateField} thisthis
19300 * @param {Mixed} date The date value
19305 * Fires when this field hide.
19306 * @param {Roo.bootstrap.DateField} this
19307 * @param {Mixed} date The date value
19312 * Fires when select a date.
19313 * @param {Roo.bootstrap.DateField} this
19314 * @param {Mixed} date The date value
19320 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19323 * @cfg {String} format
19324 * The default time format string which can be overriden for localization support. The format must be
19325 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19329 onRender: function(ct, position)
19332 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19334 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19336 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19338 this.pop = this.picker().select('>.datepicker-time',true).first();
19339 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19341 this.picker().on('mousedown', this.onMousedown, this);
19342 this.picker().on('click', this.onClick, this);
19344 this.picker().addClass('datepicker-dropdown');
19349 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19350 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19351 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19352 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19353 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19354 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19358 fireKey: function(e){
19359 if (!this.picker().isVisible()){
19360 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19366 e.preventDefault();
19374 this.onTogglePeriod();
19377 this.onIncrementMinutes();
19380 this.onDecrementMinutes();
19389 onClick: function(e) {
19390 e.stopPropagation();
19391 e.preventDefault();
19394 picker : function()
19396 return this.el.select('.datepicker', true).first();
19399 fillTime: function()
19401 var time = this.pop.select('tbody', true).first();
19403 time.dom.innerHTML = '';
19418 cls: 'hours-up glyphicon glyphicon-chevron-up'
19438 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19459 cls: 'timepicker-hour',
19474 cls: 'timepicker-minute',
19489 cls: 'btn btn-primary period',
19511 cls: 'hours-down glyphicon glyphicon-chevron-down'
19531 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19549 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19556 var hours = this.time.getHours();
19557 var minutes = this.time.getMinutes();
19570 hours = hours - 12;
19574 hours = '0' + hours;
19578 minutes = '0' + minutes;
19581 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19582 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19583 this.pop.select('button', true).first().dom.innerHTML = period;
19589 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19591 var cls = ['bottom'];
19593 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19600 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19605 this.picker().addClass(cls.join('-'));
19609 Roo.each(cls, function(c){
19611 _this.picker().setTop(_this.inputEl().getHeight());
19615 _this.picker().setTop(0 - _this.picker().getHeight());
19620 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19624 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19631 onFocus : function()
19633 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19637 onBlur : function()
19639 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19645 this.picker().show();
19650 this.fireEvent('show', this, this.date);
19655 this.picker().hide();
19658 this.fireEvent('hide', this, this.date);
19661 setTime : function()
19664 this.setValue(this.time.format(this.format));
19666 this.fireEvent('select', this, this.date);
19671 onMousedown: function(e){
19672 e.stopPropagation();
19673 e.preventDefault();
19676 onIncrementHours: function()
19678 Roo.log('onIncrementHours');
19679 this.time = this.time.add(Date.HOUR, 1);
19684 onDecrementHours: function()
19686 Roo.log('onDecrementHours');
19687 this.time = this.time.add(Date.HOUR, -1);
19691 onIncrementMinutes: function()
19693 Roo.log('onIncrementMinutes');
19694 this.time = this.time.add(Date.MINUTE, 1);
19698 onDecrementMinutes: function()
19700 Roo.log('onDecrementMinutes');
19701 this.time = this.time.add(Date.MINUTE, -1);
19705 onTogglePeriod: function()
19707 Roo.log('onTogglePeriod');
19708 this.time = this.time.add(Date.HOUR, 12);
19715 Roo.apply(Roo.bootstrap.TimeField, {
19745 cls: 'btn btn-info ok',
19757 Roo.apply(Roo.bootstrap.TimeField, {
19761 cls: 'datepicker dropdown-menu',
19765 cls: 'datepicker-time',
19769 cls: 'table-condensed',
19771 Roo.bootstrap.TimeField.content,
19772 Roo.bootstrap.TimeField.footer
19791 * @class Roo.bootstrap.MonthField
19792 * @extends Roo.bootstrap.Input
19793 * Bootstrap MonthField class
19795 * @cfg {String} language default en
19798 * Create a new MonthField
19799 * @param {Object} config The config object
19802 Roo.bootstrap.MonthField = function(config){
19803 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19808 * Fires when this field show.
19809 * @param {Roo.bootstrap.MonthField} this
19810 * @param {Mixed} date The date value
19815 * Fires when this field hide.
19816 * @param {Roo.bootstrap.MonthField} this
19817 * @param {Mixed} date The date value
19822 * Fires when select a date.
19823 * @param {Roo.bootstrap.MonthField} this
19824 * @param {String} oldvalue The old value
19825 * @param {String} newvalue The new value
19831 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19833 onRender: function(ct, position)
19836 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19838 this.language = this.language || 'en';
19839 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19840 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19842 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19843 this.isInline = false;
19844 this.isInput = true;
19845 this.component = this.el.select('.add-on', true).first() || false;
19846 this.component = (this.component && this.component.length === 0) ? false : this.component;
19847 this.hasInput = this.component && this.inputEL().length;
19849 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19851 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19853 this.picker().on('mousedown', this.onMousedown, this);
19854 this.picker().on('click', this.onClick, this);
19856 this.picker().addClass('datepicker-dropdown');
19858 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19859 v.setStyle('width', '189px');
19866 if(this.isInline) {
19872 setValue: function(v, suppressEvent)
19874 var o = this.getValue();
19876 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19880 if(suppressEvent !== true){
19881 this.fireEvent('select', this, o, v);
19886 getValue: function()
19891 onClick: function(e)
19893 e.stopPropagation();
19894 e.preventDefault();
19896 var target = e.getTarget();
19898 if(target.nodeName.toLowerCase() === 'i'){
19899 target = Roo.get(target).dom.parentNode;
19902 var nodeName = target.nodeName;
19903 var className = target.className;
19904 var html = target.innerHTML;
19906 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19910 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19912 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19918 picker : function()
19920 return this.pickerEl;
19923 fillMonths: function()
19926 var months = this.picker().select('>.datepicker-months td', true).first();
19928 months.dom.innerHTML = '';
19934 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19937 months.createChild(month);
19946 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19947 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19950 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19951 e.removeClass('active');
19953 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19954 e.addClass('active');
19961 if(this.isInline) {
19965 this.picker().removeClass(['bottom', 'top']);
19967 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19969 * place to the top of element!
19973 this.picker().addClass('top');
19974 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19979 this.picker().addClass('bottom');
19981 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19984 onFocus : function()
19986 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19990 onBlur : function()
19992 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19994 var d = this.inputEl().getValue();
20003 this.picker().show();
20004 this.picker().select('>.datepicker-months', true).first().show();
20008 this.fireEvent('show', this, this.date);
20013 if(this.isInline) {
20016 this.picker().hide();
20017 this.fireEvent('hide', this, this.date);
20021 onMousedown: function(e)
20023 e.stopPropagation();
20024 e.preventDefault();
20029 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20033 fireKey: function(e)
20035 if (!this.picker().isVisible()){
20036 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20047 e.preventDefault();
20051 dir = e.keyCode == 37 ? -1 : 1;
20053 this.vIndex = this.vIndex + dir;
20055 if(this.vIndex < 0){
20059 if(this.vIndex > 11){
20063 if(isNaN(this.vIndex)){
20067 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20073 dir = e.keyCode == 38 ? -1 : 1;
20075 this.vIndex = this.vIndex + dir * 4;
20077 if(this.vIndex < 0){
20081 if(this.vIndex > 11){
20085 if(isNaN(this.vIndex)){
20089 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20094 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20095 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20099 e.preventDefault();
20102 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20103 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20119 this.picker().remove();
20124 Roo.apply(Roo.bootstrap.MonthField, {
20143 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20144 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20149 Roo.apply(Roo.bootstrap.MonthField, {
20153 cls: 'datepicker dropdown-menu roo-dynamic',
20157 cls: 'datepicker-months',
20161 cls: 'table-condensed',
20163 Roo.bootstrap.DateField.content
20183 * @class Roo.bootstrap.CheckBox
20184 * @extends Roo.bootstrap.Input
20185 * Bootstrap CheckBox class
20187 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20188 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20189 * @cfg {String} boxLabel The text that appears beside the checkbox
20190 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20191 * @cfg {Boolean} checked initnal the element
20192 * @cfg {Boolean} inline inline the element (default false)
20193 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20194 * @cfg {String} tooltip label tooltip
20197 * Create a new CheckBox
20198 * @param {Object} config The config object
20201 Roo.bootstrap.CheckBox = function(config){
20202 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20207 * Fires when the element is checked or unchecked.
20208 * @param {Roo.bootstrap.CheckBox} this This input
20209 * @param {Boolean} checked The new checked value
20214 * Fires when the element is click.
20215 * @param {Roo.bootstrap.CheckBox} this This input
20222 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20224 inputType: 'checkbox',
20233 getAutoCreate : function()
20235 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20241 cfg.cls = 'form-group ' + this.inputType; //input-group
20244 cfg.cls += ' ' + this.inputType + '-inline';
20250 type : this.inputType,
20251 value : this.inputValue,
20252 cls : 'roo-' + this.inputType, //'form-box',
20253 placeholder : this.placeholder || ''
20257 if(this.inputType != 'radio'){
20261 cls : 'roo-hidden-value',
20262 value : this.checked ? this.inputValue : this.valueOff
20267 if (this.weight) { // Validity check?
20268 cfg.cls += " " + this.inputType + "-" + this.weight;
20271 if (this.disabled) {
20272 input.disabled=true;
20276 input.checked = this.checked;
20281 input.name = this.name;
20283 if(this.inputType != 'radio'){
20284 hidden.name = this.name;
20285 input.name = '_hidden_' + this.name;
20290 input.cls += ' input-' + this.size;
20295 ['xs','sm','md','lg'].map(function(size){
20296 if (settings[size]) {
20297 cfg.cls += ' col-' + size + '-' + settings[size];
20301 var inputblock = input;
20303 if (this.before || this.after) {
20306 cls : 'input-group',
20311 inputblock.cn.push({
20313 cls : 'input-group-addon',
20318 inputblock.cn.push(input);
20320 if(this.inputType != 'radio'){
20321 inputblock.cn.push(hidden);
20325 inputblock.cn.push({
20327 cls : 'input-group-addon',
20334 if (align ==='left' && this.fieldLabel.length) {
20335 // Roo.log("left and has label");
20340 cls : 'control-label',
20341 html : this.fieldLabel
20351 if(this.labelWidth > 12){
20352 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20355 if(this.labelWidth < 13 && this.labelmd == 0){
20356 this.labelmd = this.labelWidth;
20359 if(this.labellg > 0){
20360 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20361 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20364 if(this.labelmd > 0){
20365 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20366 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20369 if(this.labelsm > 0){
20370 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20371 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20374 if(this.labelxs > 0){
20375 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20376 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20379 } else if ( this.fieldLabel.length) {
20380 // Roo.log(" label");
20384 tag: this.boxLabel ? 'span' : 'label',
20386 cls: 'control-label box-input-label',
20387 //cls : 'input-group-addon',
20388 html : this.fieldLabel
20397 // Roo.log(" no label && no align");
20398 cfg.cn = [ inputblock ] ;
20404 var boxLabelCfg = {
20406 //'for': id, // box label is handled by onclick - so no for...
20408 html: this.boxLabel
20412 boxLabelCfg.tooltip = this.tooltip;
20415 cfg.cn.push(boxLabelCfg);
20418 if(this.inputType != 'radio'){
20419 cfg.cn.push(hidden);
20427 * return the real input element.
20429 inputEl: function ()
20431 return this.el.select('input.roo-' + this.inputType,true).first();
20433 hiddenEl: function ()
20435 return this.el.select('input.roo-hidden-value',true).first();
20438 labelEl: function()
20440 return this.el.select('label.control-label',true).first();
20442 /* depricated... */
20446 return this.labelEl();
20449 boxLabelEl: function()
20451 return this.el.select('label.box-label',true).first();
20454 initEvents : function()
20456 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20458 this.inputEl().on('click', this.onClick, this);
20460 if (this.boxLabel) {
20461 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20464 this.startValue = this.getValue();
20467 Roo.bootstrap.CheckBox.register(this);
20471 onClick : function(e)
20473 if(this.fireEvent('click', this, e) !== false){
20474 this.setChecked(!this.checked);
20479 setChecked : function(state,suppressEvent)
20481 this.startValue = this.getValue();
20483 if(this.inputType == 'radio'){
20485 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20486 e.dom.checked = false;
20489 this.inputEl().dom.checked = true;
20491 this.inputEl().dom.value = this.inputValue;
20493 if(suppressEvent !== true){
20494 this.fireEvent('check', this, true);
20502 this.checked = state;
20504 this.inputEl().dom.checked = state;
20507 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20509 if(suppressEvent !== true){
20510 this.fireEvent('check', this, state);
20516 getValue : function()
20518 if(this.inputType == 'radio'){
20519 return this.getGroupValue();
20522 return this.hiddenEl().dom.value;
20526 getGroupValue : function()
20528 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20532 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20535 setValue : function(v,suppressEvent)
20537 if(this.inputType == 'radio'){
20538 this.setGroupValue(v, suppressEvent);
20542 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20547 setGroupValue : function(v, suppressEvent)
20549 this.startValue = this.getValue();
20551 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20552 e.dom.checked = false;
20554 if(e.dom.value == v){
20555 e.dom.checked = true;
20559 if(suppressEvent !== true){
20560 this.fireEvent('check', this, true);
20568 validate : function()
20572 (this.inputType == 'radio' && this.validateRadio()) ||
20573 (this.inputType == 'checkbox' && this.validateCheckbox())
20579 this.markInvalid();
20583 validateRadio : function()
20585 if(this.allowBlank){
20591 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20592 if(!e.dom.checked){
20604 validateCheckbox : function()
20607 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20608 //return (this.getValue() == this.inputValue) ? true : false;
20611 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20619 for(var i in group){
20620 if(group[i].el.isVisible(true)){
20628 for(var i in group){
20633 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20640 * Mark this field as valid
20642 markValid : function()
20646 this.fireEvent('valid', this);
20648 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20651 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20658 if(this.inputType == 'radio'){
20659 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20660 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20661 e.findParent('.form-group', false, true).addClass(_this.validClass);
20668 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20669 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20673 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20679 for(var i in group){
20680 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20681 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20686 * Mark this field as invalid
20687 * @param {String} msg The validation message
20689 markInvalid : function(msg)
20691 if(this.allowBlank){
20697 this.fireEvent('invalid', this, msg);
20699 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20702 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20706 label.markInvalid();
20709 if(this.inputType == 'radio'){
20710 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20711 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20712 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20719 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20720 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20724 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20730 for(var i in group){
20731 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20732 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20737 clearInvalid : function()
20739 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20741 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20743 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20745 if (label && label.iconEl) {
20746 label.iconEl.removeClass(label.validClass);
20747 label.iconEl.removeClass(label.invalidClass);
20751 disable : function()
20753 if(this.inputType != 'radio'){
20754 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20761 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20762 _this.getActionEl().addClass(this.disabledClass);
20763 e.dom.disabled = true;
20767 this.disabled = true;
20768 this.fireEvent("disable", this);
20772 enable : function()
20774 if(this.inputType != 'radio'){
20775 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20782 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20783 _this.getActionEl().removeClass(this.disabledClass);
20784 e.dom.disabled = false;
20788 this.disabled = false;
20789 this.fireEvent("enable", this);
20793 setBoxLabel : function(v)
20798 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20804 Roo.apply(Roo.bootstrap.CheckBox, {
20809 * register a CheckBox Group
20810 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20812 register : function(checkbox)
20814 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20815 this.groups[checkbox.groupId] = {};
20818 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20822 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20826 * fetch a CheckBox Group based on the group ID
20827 * @param {string} the group ID
20828 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20830 get: function(groupId) {
20831 if (typeof(this.groups[groupId]) == 'undefined') {
20835 return this.groups[groupId] ;
20848 * @class Roo.bootstrap.Radio
20849 * @extends Roo.bootstrap.Component
20850 * Bootstrap Radio class
20851 * @cfg {String} boxLabel - the label associated
20852 * @cfg {String} value - the value of radio
20855 * Create a new Radio
20856 * @param {Object} config The config object
20858 Roo.bootstrap.Radio = function(config){
20859 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20863 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20869 getAutoCreate : function()
20873 cls : 'form-group radio',
20878 html : this.boxLabel
20886 initEvents : function()
20888 this.parent().register(this);
20890 this.el.on('click', this.onClick, this);
20894 onClick : function()
20896 this.setChecked(true);
20899 setChecked : function(state, suppressEvent)
20901 this.parent().setValue(this.value, suppressEvent);
20905 setBoxLabel : function(v)
20910 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20925 * @class Roo.bootstrap.SecurePass
20926 * @extends Roo.bootstrap.Input
20927 * Bootstrap SecurePass class
20931 * Create a new SecurePass
20932 * @param {Object} config The config object
20935 Roo.bootstrap.SecurePass = function (config) {
20936 // these go here, so the translation tool can replace them..
20938 PwdEmpty: "Please type a password, and then retype it to confirm.",
20939 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20940 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20941 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20942 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20943 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20944 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20945 TooWeak: "Your password is Too Weak."
20947 this.meterLabel = "Password strength:";
20948 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20949 this.meterClass = [
20950 "roo-password-meter-tooweak",
20951 "roo-password-meter-weak",
20952 "roo-password-meter-medium",
20953 "roo-password-meter-strong",
20954 "roo-password-meter-grey"
20959 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20962 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20964 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20966 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20967 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20968 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20969 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20970 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20971 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20972 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20982 * @cfg {String/Object} Label for the strength meter (defaults to
20983 * 'Password strength:')
20988 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20989 * ['Weak', 'Medium', 'Strong'])
20992 pwdStrengths: false,
21005 initEvents: function ()
21007 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21009 if (this.el.is('input[type=password]') && Roo.isSafari) {
21010 this.el.on('keydown', this.SafariOnKeyDown, this);
21013 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21016 onRender: function (ct, position)
21018 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21019 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21020 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21022 this.trigger.createChild({
21027 cls: 'roo-password-meter-grey col-xs-12',
21030 //width: this.meterWidth + 'px'
21034 cls: 'roo-password-meter-text'
21040 if (this.hideTrigger) {
21041 this.trigger.setDisplayed(false);
21043 this.setSize(this.width || '', this.height || '');
21046 onDestroy: function ()
21048 if (this.trigger) {
21049 this.trigger.removeAllListeners();
21050 this.trigger.remove();
21053 this.wrap.remove();
21055 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21058 checkStrength: function ()
21060 var pwd = this.inputEl().getValue();
21061 if (pwd == this._lastPwd) {
21066 if (this.ClientSideStrongPassword(pwd)) {
21068 } else if (this.ClientSideMediumPassword(pwd)) {
21070 } else if (this.ClientSideWeakPassword(pwd)) {
21076 Roo.log('strength1: ' + strength);
21078 //var pm = this.trigger.child('div/div/div').dom;
21079 var pm = this.trigger.child('div/div');
21080 pm.removeClass(this.meterClass);
21081 pm.addClass(this.meterClass[strength]);
21084 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21086 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21088 this._lastPwd = pwd;
21092 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21094 this._lastPwd = '';
21096 var pm = this.trigger.child('div/div');
21097 pm.removeClass(this.meterClass);
21098 pm.addClass('roo-password-meter-grey');
21101 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21104 this.inputEl().dom.type='password';
21107 validateValue: function (value)
21110 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21113 if (value.length == 0) {
21114 if (this.allowBlank) {
21115 this.clearInvalid();
21119 this.markInvalid(this.errors.PwdEmpty);
21120 this.errorMsg = this.errors.PwdEmpty;
21128 if ('[\x21-\x7e]*'.match(value)) {
21129 this.markInvalid(this.errors.PwdBadChar);
21130 this.errorMsg = this.errors.PwdBadChar;
21133 if (value.length < 6) {
21134 this.markInvalid(this.errors.PwdShort);
21135 this.errorMsg = this.errors.PwdShort;
21138 if (value.length > 16) {
21139 this.markInvalid(this.errors.PwdLong);
21140 this.errorMsg = this.errors.PwdLong;
21144 if (this.ClientSideStrongPassword(value)) {
21146 } else if (this.ClientSideMediumPassword(value)) {
21148 } else if (this.ClientSideWeakPassword(value)) {
21155 if (strength < 2) {
21156 //this.markInvalid(this.errors.TooWeak);
21157 this.errorMsg = this.errors.TooWeak;
21162 console.log('strength2: ' + strength);
21164 //var pm = this.trigger.child('div/div/div').dom;
21166 var pm = this.trigger.child('div/div');
21167 pm.removeClass(this.meterClass);
21168 pm.addClass(this.meterClass[strength]);
21170 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21172 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21174 this.errorMsg = '';
21178 CharacterSetChecks: function (type)
21181 this.fResult = false;
21184 isctype: function (character, type)
21187 case this.kCapitalLetter:
21188 if (character >= 'A' && character <= 'Z') {
21193 case this.kSmallLetter:
21194 if (character >= 'a' && character <= 'z') {
21200 if (character >= '0' && character <= '9') {
21205 case this.kPunctuation:
21206 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21217 IsLongEnough: function (pwd, size)
21219 return !(pwd == null || isNaN(size) || pwd.length < size);
21222 SpansEnoughCharacterSets: function (word, nb)
21224 if (!this.IsLongEnough(word, nb))
21229 var characterSetChecks = new Array(
21230 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21231 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21234 for (var index = 0; index < word.length; ++index) {
21235 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21236 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21237 characterSetChecks[nCharSet].fResult = true;
21244 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21245 if (characterSetChecks[nCharSet].fResult) {
21250 if (nCharSets < nb) {
21256 ClientSideStrongPassword: function (pwd)
21258 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21261 ClientSideMediumPassword: function (pwd)
21263 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21266 ClientSideWeakPassword: function (pwd)
21268 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21271 })//<script type="text/javascript">
21274 * Based Ext JS Library 1.1.1
21275 * Copyright(c) 2006-2007, Ext JS, LLC.
21281 * @class Roo.HtmlEditorCore
21282 * @extends Roo.Component
21283 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21285 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21288 Roo.HtmlEditorCore = function(config){
21291 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21296 * @event initialize
21297 * Fires when the editor is fully initialized (including the iframe)
21298 * @param {Roo.HtmlEditorCore} this
21303 * Fires when the editor is first receives the focus. Any insertion must wait
21304 * until after this event.
21305 * @param {Roo.HtmlEditorCore} this
21309 * @event beforesync
21310 * Fires before the textarea is updated with content from the editor iframe. Return false
21311 * to cancel the sync.
21312 * @param {Roo.HtmlEditorCore} this
21313 * @param {String} html
21317 * @event beforepush
21318 * Fires before the iframe editor is updated with content from the textarea. Return false
21319 * to cancel the push.
21320 * @param {Roo.HtmlEditorCore} this
21321 * @param {String} html
21326 * Fires when the textarea is updated with content from the editor iframe.
21327 * @param {Roo.HtmlEditorCore} this
21328 * @param {String} html
21333 * Fires when the iframe editor is updated with content from the textarea.
21334 * @param {Roo.HtmlEditorCore} this
21335 * @param {String} html
21340 * @event editorevent
21341 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21342 * @param {Roo.HtmlEditorCore} this
21348 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21350 // defaults : white / black...
21351 this.applyBlacklists();
21358 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21362 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21368 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21373 * @cfg {Number} height (in pixels)
21377 * @cfg {Number} width (in pixels)
21382 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21385 stylesheets: false,
21390 // private properties
21391 validationEvent : false,
21393 initialized : false,
21395 sourceEditMode : false,
21396 onFocus : Roo.emptyFn,
21398 hideMode:'offsets',
21402 // blacklist + whitelisted elements..
21409 * Protected method that will not generally be called directly. It
21410 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21411 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21413 getDocMarkup : function(){
21417 // inherit styels from page...??
21418 if (this.stylesheets === false) {
21420 Roo.get(document.head).select('style').each(function(node) {
21421 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21424 Roo.get(document.head).select('link').each(function(node) {
21425 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21428 } else if (!this.stylesheets.length) {
21430 st = '<style type="text/css">' +
21431 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21434 st = '<style type="text/css">' +
21439 st += '<style type="text/css">' +
21440 'IMG { cursor: pointer } ' +
21443 var cls = 'roo-htmleditor-body';
21445 if(this.bodyCls.length){
21446 cls += ' ' + this.bodyCls;
21449 return '<html><head>' + st +
21450 //<style type="text/css">' +
21451 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21453 ' </head><body class="' + cls + '"></body></html>';
21457 onRender : function(ct, position)
21460 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21461 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21464 this.el.dom.style.border = '0 none';
21465 this.el.dom.setAttribute('tabIndex', -1);
21466 this.el.addClass('x-hidden hide');
21470 if(Roo.isIE){ // fix IE 1px bogus margin
21471 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21475 this.frameId = Roo.id();
21479 var iframe = this.owner.wrap.createChild({
21481 cls: 'form-control', // bootstrap..
21483 name: this.frameId,
21484 frameBorder : 'no',
21485 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21490 this.iframe = iframe.dom;
21492 this.assignDocWin();
21494 this.doc.designMode = 'on';
21497 this.doc.write(this.getDocMarkup());
21501 var task = { // must defer to wait for browser to be ready
21503 //console.log("run task?" + this.doc.readyState);
21504 this.assignDocWin();
21505 if(this.doc.body || this.doc.readyState == 'complete'){
21507 this.doc.designMode="on";
21511 Roo.TaskMgr.stop(task);
21512 this.initEditor.defer(10, this);
21519 Roo.TaskMgr.start(task);
21524 onResize : function(w, h)
21526 Roo.log('resize: ' +w + ',' + h );
21527 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21531 if(typeof w == 'number'){
21533 this.iframe.style.width = w + 'px';
21535 if(typeof h == 'number'){
21537 this.iframe.style.height = h + 'px';
21539 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21546 * Toggles the editor between standard and source edit mode.
21547 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21549 toggleSourceEdit : function(sourceEditMode){
21551 this.sourceEditMode = sourceEditMode === true;
21553 if(this.sourceEditMode){
21555 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21558 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21559 //this.iframe.className = '';
21562 //this.setSize(this.owner.wrap.getSize());
21563 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21570 * Protected method that will not generally be called directly. If you need/want
21571 * custom HTML cleanup, this is the method you should override.
21572 * @param {String} html The HTML to be cleaned
21573 * return {String} The cleaned HTML
21575 cleanHtml : function(html){
21576 html = String(html);
21577 if(html.length > 5){
21578 if(Roo.isSafari){ // strip safari nonsense
21579 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21582 if(html == ' '){
21589 * HTML Editor -> Textarea
21590 * Protected method that will not generally be called directly. Syncs the contents
21591 * of the editor iframe with the textarea.
21593 syncValue : function(){
21594 if(this.initialized){
21595 var bd = (this.doc.body || this.doc.documentElement);
21596 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21597 var html = bd.innerHTML;
21599 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21600 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21602 html = '<div style="'+m[0]+'">' + html + '</div>';
21605 html = this.cleanHtml(html);
21606 // fix up the special chars.. normaly like back quotes in word...
21607 // however we do not want to do this with chinese..
21608 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21609 var cc = b.charCodeAt();
21611 (cc >= 0x4E00 && cc < 0xA000 ) ||
21612 (cc >= 0x3400 && cc < 0x4E00 ) ||
21613 (cc >= 0xf900 && cc < 0xfb00 )
21619 if(this.owner.fireEvent('beforesync', this, html) !== false){
21620 this.el.dom.value = html;
21621 this.owner.fireEvent('sync', this, html);
21627 * Protected method that will not generally be called directly. Pushes the value of the textarea
21628 * into the iframe editor.
21630 pushValue : function(){
21631 if(this.initialized){
21632 var v = this.el.dom.value.trim();
21634 // if(v.length < 1){
21638 if(this.owner.fireEvent('beforepush', this, v) !== false){
21639 var d = (this.doc.body || this.doc.documentElement);
21641 this.cleanUpPaste();
21642 this.el.dom.value = d.innerHTML;
21643 this.owner.fireEvent('push', this, v);
21649 deferFocus : function(){
21650 this.focus.defer(10, this);
21654 focus : function(){
21655 if(this.win && !this.sourceEditMode){
21662 assignDocWin: function()
21664 var iframe = this.iframe;
21667 this.doc = iframe.contentWindow.document;
21668 this.win = iframe.contentWindow;
21670 // if (!Roo.get(this.frameId)) {
21673 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21674 // this.win = Roo.get(this.frameId).dom.contentWindow;
21676 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21680 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21681 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21686 initEditor : function(){
21687 //console.log("INIT EDITOR");
21688 this.assignDocWin();
21692 this.doc.designMode="on";
21694 this.doc.write(this.getDocMarkup());
21697 var dbody = (this.doc.body || this.doc.documentElement);
21698 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21699 // this copies styles from the containing element into thsi one..
21700 // not sure why we need all of this..
21701 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21703 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21704 //ss['background-attachment'] = 'fixed'; // w3c
21705 dbody.bgProperties = 'fixed'; // ie
21706 //Roo.DomHelper.applyStyles(dbody, ss);
21707 Roo.EventManager.on(this.doc, {
21708 //'mousedown': this.onEditorEvent,
21709 'mouseup': this.onEditorEvent,
21710 'dblclick': this.onEditorEvent,
21711 'click': this.onEditorEvent,
21712 'keyup': this.onEditorEvent,
21717 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21719 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21720 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21722 this.initialized = true;
21724 this.owner.fireEvent('initialize', this);
21729 onDestroy : function(){
21735 //for (var i =0; i < this.toolbars.length;i++) {
21736 // // fixme - ask toolbars for heights?
21737 // this.toolbars[i].onDestroy();
21740 //this.wrap.dom.innerHTML = '';
21741 //this.wrap.remove();
21746 onFirstFocus : function(){
21748 this.assignDocWin();
21751 this.activated = true;
21754 if(Roo.isGecko){ // prevent silly gecko errors
21756 var s = this.win.getSelection();
21757 if(!s.focusNode || s.focusNode.nodeType != 3){
21758 var r = s.getRangeAt(0);
21759 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21764 this.execCmd('useCSS', true);
21765 this.execCmd('styleWithCSS', false);
21768 this.owner.fireEvent('activate', this);
21772 adjustFont: function(btn){
21773 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21774 //if(Roo.isSafari){ // safari
21777 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21778 if(Roo.isSafari){ // safari
21779 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21780 v = (v < 10) ? 10 : v;
21781 v = (v > 48) ? 48 : v;
21782 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21787 v = Math.max(1, v+adjust);
21789 this.execCmd('FontSize', v );
21792 onEditorEvent : function(e)
21794 this.owner.fireEvent('editorevent', this, e);
21795 // this.updateToolbar();
21796 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21799 insertTag : function(tg)
21801 // could be a bit smarter... -> wrap the current selected tRoo..
21802 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21804 range = this.createRange(this.getSelection());
21805 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21806 wrappingNode.appendChild(range.extractContents());
21807 range.insertNode(wrappingNode);
21814 this.execCmd("formatblock", tg);
21818 insertText : function(txt)
21822 var range = this.createRange();
21823 range.deleteContents();
21824 //alert(Sender.getAttribute('label'));
21826 range.insertNode(this.doc.createTextNode(txt));
21832 * Executes a Midas editor command on the editor document and performs necessary focus and
21833 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21834 * @param {String} cmd The Midas command
21835 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21837 relayCmd : function(cmd, value){
21839 this.execCmd(cmd, value);
21840 this.owner.fireEvent('editorevent', this);
21841 //this.updateToolbar();
21842 this.owner.deferFocus();
21846 * Executes a Midas editor command directly on the editor document.
21847 * For visual commands, you should use {@link #relayCmd} instead.
21848 * <b>This should only be called after the editor is initialized.</b>
21849 * @param {String} cmd The Midas command
21850 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21852 execCmd : function(cmd, value){
21853 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21860 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21862 * @param {String} text | dom node..
21864 insertAtCursor : function(text)
21867 if(!this.activated){
21873 var r = this.doc.selection.createRange();
21884 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21888 // from jquery ui (MIT licenced)
21890 var win = this.win;
21892 if (win.getSelection && win.getSelection().getRangeAt) {
21893 range = win.getSelection().getRangeAt(0);
21894 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21895 range.insertNode(node);
21896 } else if (win.document.selection && win.document.selection.createRange) {
21897 // no firefox support
21898 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21899 win.document.selection.createRange().pasteHTML(txt);
21901 // no firefox support
21902 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21903 this.execCmd('InsertHTML', txt);
21912 mozKeyPress : function(e){
21914 var c = e.getCharCode(), cmd;
21917 c = String.fromCharCode(c).toLowerCase();
21931 this.cleanUpPaste.defer(100, this);
21939 e.preventDefault();
21947 fixKeys : function(){ // load time branching for fastest keydown performance
21949 return function(e){
21950 var k = e.getKey(), r;
21953 r = this.doc.selection.createRange();
21956 r.pasteHTML('    ');
21963 r = this.doc.selection.createRange();
21965 var target = r.parentElement();
21966 if(!target || target.tagName.toLowerCase() != 'li'){
21968 r.pasteHTML('<br />');
21974 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21975 this.cleanUpPaste.defer(100, this);
21981 }else if(Roo.isOpera){
21982 return function(e){
21983 var k = e.getKey();
21987 this.execCmd('InsertHTML','    ');
21990 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21991 this.cleanUpPaste.defer(100, this);
21996 }else if(Roo.isSafari){
21997 return function(e){
21998 var k = e.getKey();
22002 this.execCmd('InsertText','\t');
22006 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22007 this.cleanUpPaste.defer(100, this);
22015 getAllAncestors: function()
22017 var p = this.getSelectedNode();
22020 a.push(p); // push blank onto stack..
22021 p = this.getParentElement();
22025 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22029 a.push(this.doc.body);
22033 lastSelNode : false,
22036 getSelection : function()
22038 this.assignDocWin();
22039 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22042 getSelectedNode: function()
22044 // this may only work on Gecko!!!
22046 // should we cache this!!!!
22051 var range = this.createRange(this.getSelection()).cloneRange();
22054 var parent = range.parentElement();
22056 var testRange = range.duplicate();
22057 testRange.moveToElementText(parent);
22058 if (testRange.inRange(range)) {
22061 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22064 parent = parent.parentElement;
22069 // is ancestor a text element.
22070 var ac = range.commonAncestorContainer;
22071 if (ac.nodeType == 3) {
22072 ac = ac.parentNode;
22075 var ar = ac.childNodes;
22078 var other_nodes = [];
22079 var has_other_nodes = false;
22080 for (var i=0;i<ar.length;i++) {
22081 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22084 // fullly contained node.
22086 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22091 // probably selected..
22092 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22093 other_nodes.push(ar[i]);
22097 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22102 has_other_nodes = true;
22104 if (!nodes.length && other_nodes.length) {
22105 nodes= other_nodes;
22107 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22113 createRange: function(sel)
22115 // this has strange effects when using with
22116 // top toolbar - not sure if it's a great idea.
22117 //this.editor.contentWindow.focus();
22118 if (typeof sel != "undefined") {
22120 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22122 return this.doc.createRange();
22125 return this.doc.createRange();
22128 getParentElement: function()
22131 this.assignDocWin();
22132 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22134 var range = this.createRange(sel);
22137 var p = range.commonAncestorContainer;
22138 while (p.nodeType == 3) { // text node
22149 * Range intersection.. the hard stuff...
22153 * [ -- selected range --- ]
22157 * if end is before start or hits it. fail.
22158 * if start is after end or hits it fail.
22160 * if either hits (but other is outside. - then it's not
22166 // @see http://www.thismuchiknow.co.uk/?p=64.
22167 rangeIntersectsNode : function(range, node)
22169 var nodeRange = node.ownerDocument.createRange();
22171 nodeRange.selectNode(node);
22173 nodeRange.selectNodeContents(node);
22176 var rangeStartRange = range.cloneRange();
22177 rangeStartRange.collapse(true);
22179 var rangeEndRange = range.cloneRange();
22180 rangeEndRange.collapse(false);
22182 var nodeStartRange = nodeRange.cloneRange();
22183 nodeStartRange.collapse(true);
22185 var nodeEndRange = nodeRange.cloneRange();
22186 nodeEndRange.collapse(false);
22188 return rangeStartRange.compareBoundaryPoints(
22189 Range.START_TO_START, nodeEndRange) == -1 &&
22190 rangeEndRange.compareBoundaryPoints(
22191 Range.START_TO_START, nodeStartRange) == 1;
22195 rangeCompareNode : function(range, node)
22197 var nodeRange = node.ownerDocument.createRange();
22199 nodeRange.selectNode(node);
22201 nodeRange.selectNodeContents(node);
22205 range.collapse(true);
22207 nodeRange.collapse(true);
22209 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22210 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22212 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22214 var nodeIsBefore = ss == 1;
22215 var nodeIsAfter = ee == -1;
22217 if (nodeIsBefore && nodeIsAfter) {
22220 if (!nodeIsBefore && nodeIsAfter) {
22221 return 1; //right trailed.
22224 if (nodeIsBefore && !nodeIsAfter) {
22225 return 2; // left trailed.
22231 // private? - in a new class?
22232 cleanUpPaste : function()
22234 // cleans up the whole document..
22235 Roo.log('cleanuppaste');
22237 this.cleanUpChildren(this.doc.body);
22238 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22239 if (clean != this.doc.body.innerHTML) {
22240 this.doc.body.innerHTML = clean;
22245 cleanWordChars : function(input) {// change the chars to hex code
22246 var he = Roo.HtmlEditorCore;
22248 var output = input;
22249 Roo.each(he.swapCodes, function(sw) {
22250 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22252 output = output.replace(swapper, sw[1]);
22259 cleanUpChildren : function (n)
22261 if (!n.childNodes.length) {
22264 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22265 this.cleanUpChild(n.childNodes[i]);
22272 cleanUpChild : function (node)
22275 //console.log(node);
22276 if (node.nodeName == "#text") {
22277 // clean up silly Windows -- stuff?
22280 if (node.nodeName == "#comment") {
22281 node.parentNode.removeChild(node);
22282 // clean up silly Windows -- stuff?
22285 var lcname = node.tagName.toLowerCase();
22286 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22287 // whitelist of tags..
22289 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22291 node.parentNode.removeChild(node);
22296 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22298 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22299 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22301 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22302 // remove_keep_children = true;
22305 if (remove_keep_children) {
22306 this.cleanUpChildren(node);
22307 // inserts everything just before this node...
22308 while (node.childNodes.length) {
22309 var cn = node.childNodes[0];
22310 node.removeChild(cn);
22311 node.parentNode.insertBefore(cn, node);
22313 node.parentNode.removeChild(node);
22317 if (!node.attributes || !node.attributes.length) {
22318 this.cleanUpChildren(node);
22322 function cleanAttr(n,v)
22325 if (v.match(/^\./) || v.match(/^\//)) {
22328 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22331 if (v.match(/^#/)) {
22334 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22335 node.removeAttribute(n);
22339 var cwhite = this.cwhite;
22340 var cblack = this.cblack;
22342 function cleanStyle(n,v)
22344 if (v.match(/expression/)) { //XSS?? should we even bother..
22345 node.removeAttribute(n);
22349 var parts = v.split(/;/);
22352 Roo.each(parts, function(p) {
22353 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22357 var l = p.split(':').shift().replace(/\s+/g,'');
22358 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22360 if ( cwhite.length && cblack.indexOf(l) > -1) {
22361 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22362 //node.removeAttribute(n);
22366 // only allow 'c whitelisted system attributes'
22367 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22368 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22369 //node.removeAttribute(n);
22379 if (clean.length) {
22380 node.setAttribute(n, clean.join(';'));
22382 node.removeAttribute(n);
22388 for (var i = node.attributes.length-1; i > -1 ; i--) {
22389 var a = node.attributes[i];
22392 if (a.name.toLowerCase().substr(0,2)=='on') {
22393 node.removeAttribute(a.name);
22396 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22397 node.removeAttribute(a.name);
22400 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22401 cleanAttr(a.name,a.value); // fixme..
22404 if (a.name == 'style') {
22405 cleanStyle(a.name,a.value);
22408 /// clean up MS crap..
22409 // tecnically this should be a list of valid class'es..
22412 if (a.name == 'class') {
22413 if (a.value.match(/^Mso/)) {
22414 node.className = '';
22417 if (a.value.match(/^body$/)) {
22418 node.className = '';
22429 this.cleanUpChildren(node);
22435 * Clean up MS wordisms...
22437 cleanWord : function(node)
22442 this.cleanWord(this.doc.body);
22445 if (node.nodeName == "#text") {
22446 // clean up silly Windows -- stuff?
22449 if (node.nodeName == "#comment") {
22450 node.parentNode.removeChild(node);
22451 // clean up silly Windows -- stuff?
22455 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22456 node.parentNode.removeChild(node);
22460 // remove - but keep children..
22461 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22462 while (node.childNodes.length) {
22463 var cn = node.childNodes[0];
22464 node.removeChild(cn);
22465 node.parentNode.insertBefore(cn, node);
22467 node.parentNode.removeChild(node);
22468 this.iterateChildren(node, this.cleanWord);
22472 if (node.className.length) {
22474 var cn = node.className.split(/\W+/);
22476 Roo.each(cn, function(cls) {
22477 if (cls.match(/Mso[a-zA-Z]+/)) {
22482 node.className = cna.length ? cna.join(' ') : '';
22484 node.removeAttribute("class");
22488 if (node.hasAttribute("lang")) {
22489 node.removeAttribute("lang");
22492 if (node.hasAttribute("style")) {
22494 var styles = node.getAttribute("style").split(";");
22496 Roo.each(styles, function(s) {
22497 if (!s.match(/:/)) {
22500 var kv = s.split(":");
22501 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22504 // what ever is left... we allow.
22507 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22508 if (!nstyle.length) {
22509 node.removeAttribute('style');
22512 this.iterateChildren(node, this.cleanWord);
22518 * iterateChildren of a Node, calling fn each time, using this as the scole..
22519 * @param {DomNode} node node to iterate children of.
22520 * @param {Function} fn method of this class to call on each item.
22522 iterateChildren : function(node, fn)
22524 if (!node.childNodes.length) {
22527 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22528 fn.call(this, node.childNodes[i])
22534 * cleanTableWidths.
22536 * Quite often pasting from word etc.. results in tables with column and widths.
22537 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22540 cleanTableWidths : function(node)
22545 this.cleanTableWidths(this.doc.body);
22550 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22553 Roo.log(node.tagName);
22554 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22555 this.iterateChildren(node, this.cleanTableWidths);
22558 if (node.hasAttribute('width')) {
22559 node.removeAttribute('width');
22563 if (node.hasAttribute("style")) {
22566 var styles = node.getAttribute("style").split(";");
22568 Roo.each(styles, function(s) {
22569 if (!s.match(/:/)) {
22572 var kv = s.split(":");
22573 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22576 // what ever is left... we allow.
22579 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22580 if (!nstyle.length) {
22581 node.removeAttribute('style');
22585 this.iterateChildren(node, this.cleanTableWidths);
22593 domToHTML : function(currentElement, depth, nopadtext) {
22595 depth = depth || 0;
22596 nopadtext = nopadtext || false;
22598 if (!currentElement) {
22599 return this.domToHTML(this.doc.body);
22602 //Roo.log(currentElement);
22604 var allText = false;
22605 var nodeName = currentElement.nodeName;
22606 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22608 if (nodeName == '#text') {
22610 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22615 if (nodeName != 'BODY') {
22618 // Prints the node tagName, such as <A>, <IMG>, etc
22621 for(i = 0; i < currentElement.attributes.length;i++) {
22623 var aname = currentElement.attributes.item(i).name;
22624 if (!currentElement.attributes.item(i).value.length) {
22627 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22630 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22639 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22642 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22647 // Traverse the tree
22649 var currentElementChild = currentElement.childNodes.item(i);
22650 var allText = true;
22651 var innerHTML = '';
22653 while (currentElementChild) {
22654 // Formatting code (indent the tree so it looks nice on the screen)
22655 var nopad = nopadtext;
22656 if (lastnode == 'SPAN') {
22660 if (currentElementChild.nodeName == '#text') {
22661 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22662 toadd = nopadtext ? toadd : toadd.trim();
22663 if (!nopad && toadd.length > 80) {
22664 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22666 innerHTML += toadd;
22669 currentElementChild = currentElement.childNodes.item(i);
22675 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22677 // Recursively traverse the tree structure of the child node
22678 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22679 lastnode = currentElementChild.nodeName;
22681 currentElementChild=currentElement.childNodes.item(i);
22687 // The remaining code is mostly for formatting the tree
22688 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22693 ret+= "</"+tagName+">";
22699 applyBlacklists : function()
22701 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22702 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22706 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22707 if (b.indexOf(tag) > -1) {
22710 this.white.push(tag);
22714 Roo.each(w, function(tag) {
22715 if (b.indexOf(tag) > -1) {
22718 if (this.white.indexOf(tag) > -1) {
22721 this.white.push(tag);
22726 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22727 if (w.indexOf(tag) > -1) {
22730 this.black.push(tag);
22734 Roo.each(b, function(tag) {
22735 if (w.indexOf(tag) > -1) {
22738 if (this.black.indexOf(tag) > -1) {
22741 this.black.push(tag);
22746 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22747 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22751 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22752 if (b.indexOf(tag) > -1) {
22755 this.cwhite.push(tag);
22759 Roo.each(w, function(tag) {
22760 if (b.indexOf(tag) > -1) {
22763 if (this.cwhite.indexOf(tag) > -1) {
22766 this.cwhite.push(tag);
22771 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22772 if (w.indexOf(tag) > -1) {
22775 this.cblack.push(tag);
22779 Roo.each(b, function(tag) {
22780 if (w.indexOf(tag) > -1) {
22783 if (this.cblack.indexOf(tag) > -1) {
22786 this.cblack.push(tag);
22791 setStylesheets : function(stylesheets)
22793 if(typeof(stylesheets) == 'string'){
22794 Roo.get(this.iframe.contentDocument.head).createChild({
22796 rel : 'stylesheet',
22805 Roo.each(stylesheets, function(s) {
22810 Roo.get(_this.iframe.contentDocument.head).createChild({
22812 rel : 'stylesheet',
22821 removeStylesheets : function()
22825 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22830 setStyle : function(style)
22832 Roo.get(this.iframe.contentDocument.head).createChild({
22841 // hide stuff that is not compatible
22855 * @event specialkey
22859 * @cfg {String} fieldClass @hide
22862 * @cfg {String} focusClass @hide
22865 * @cfg {String} autoCreate @hide
22868 * @cfg {String} inputType @hide
22871 * @cfg {String} invalidClass @hide
22874 * @cfg {String} invalidText @hide
22877 * @cfg {String} msgFx @hide
22880 * @cfg {String} validateOnBlur @hide
22884 Roo.HtmlEditorCore.white = [
22885 'area', 'br', 'img', 'input', 'hr', 'wbr',
22887 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22888 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22889 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22890 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22891 'table', 'ul', 'xmp',
22893 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22896 'dir', 'menu', 'ol', 'ul', 'dl',
22902 Roo.HtmlEditorCore.black = [
22903 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22905 'base', 'basefont', 'bgsound', 'blink', 'body',
22906 'frame', 'frameset', 'head', 'html', 'ilayer',
22907 'iframe', 'layer', 'link', 'meta', 'object',
22908 'script', 'style' ,'title', 'xml' // clean later..
22910 Roo.HtmlEditorCore.clean = [
22911 'script', 'style', 'title', 'xml'
22913 Roo.HtmlEditorCore.remove = [
22918 Roo.HtmlEditorCore.ablack = [
22922 Roo.HtmlEditorCore.aclean = [
22923 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22927 Roo.HtmlEditorCore.pwhite= [
22928 'http', 'https', 'mailto'
22931 // white listed style attributes.
22932 Roo.HtmlEditorCore.cwhite= [
22933 // 'text-align', /// default is to allow most things..
22939 // black listed style attributes.
22940 Roo.HtmlEditorCore.cblack= [
22941 // 'font-size' -- this can be set by the project
22945 Roo.HtmlEditorCore.swapCodes =[
22964 * @class Roo.bootstrap.HtmlEditor
22965 * @extends Roo.bootstrap.TextArea
22966 * Bootstrap HtmlEditor class
22969 * Create a new HtmlEditor
22970 * @param {Object} config The config object
22973 Roo.bootstrap.HtmlEditor = function(config){
22974 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22975 if (!this.toolbars) {
22976 this.toolbars = [];
22979 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22982 * @event initialize
22983 * Fires when the editor is fully initialized (including the iframe)
22984 * @param {HtmlEditor} this
22989 * Fires when the editor is first receives the focus. Any insertion must wait
22990 * until after this event.
22991 * @param {HtmlEditor} this
22995 * @event beforesync
22996 * Fires before the textarea is updated with content from the editor iframe. Return false
22997 * to cancel the sync.
22998 * @param {HtmlEditor} this
22999 * @param {String} html
23003 * @event beforepush
23004 * Fires before the iframe editor is updated with content from the textarea. Return false
23005 * to cancel the push.
23006 * @param {HtmlEditor} this
23007 * @param {String} html
23012 * Fires when the textarea is updated with content from the editor iframe.
23013 * @param {HtmlEditor} this
23014 * @param {String} html
23019 * Fires when the iframe editor is updated with content from the textarea.
23020 * @param {HtmlEditor} this
23021 * @param {String} html
23025 * @event editmodechange
23026 * Fires when the editor switches edit modes
23027 * @param {HtmlEditor} this
23028 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23030 editmodechange: true,
23032 * @event editorevent
23033 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23034 * @param {HtmlEditor} this
23038 * @event firstfocus
23039 * Fires when on first focus - needed by toolbars..
23040 * @param {HtmlEditor} this
23045 * Auto save the htmlEditor value as a file into Events
23046 * @param {HtmlEditor} this
23050 * @event savedpreview
23051 * preview the saved version of htmlEditor
23052 * @param {HtmlEditor} this
23059 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23063 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23068 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23073 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23078 * @cfg {Number} height (in pixels)
23082 * @cfg {Number} width (in pixels)
23087 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23090 stylesheets: false,
23095 // private properties
23096 validationEvent : false,
23098 initialized : false,
23101 onFocus : Roo.emptyFn,
23103 hideMode:'offsets',
23105 tbContainer : false,
23109 toolbarContainer :function() {
23110 return this.wrap.select('.x-html-editor-tb',true).first();
23114 * Protected method that will not generally be called directly. It
23115 * is called when the editor creates its toolbar. Override this method if you need to
23116 * add custom toolbar buttons.
23117 * @param {HtmlEditor} editor
23119 createToolbar : function(){
23120 Roo.log('renewing');
23121 Roo.log("create toolbars");
23123 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23124 this.toolbars[0].render(this.toolbarContainer());
23128 // if (!editor.toolbars || !editor.toolbars.length) {
23129 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23132 // for (var i =0 ; i < editor.toolbars.length;i++) {
23133 // editor.toolbars[i] = Roo.factory(
23134 // typeof(editor.toolbars[i]) == 'string' ?
23135 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23136 // Roo.bootstrap.HtmlEditor);
23137 // editor.toolbars[i].init(editor);
23143 onRender : function(ct, position)
23145 // Roo.log("Call onRender: " + this.xtype);
23147 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23149 this.wrap = this.inputEl().wrap({
23150 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23153 this.editorcore.onRender(ct, position);
23155 if (this.resizable) {
23156 this.resizeEl = new Roo.Resizable(this.wrap, {
23160 minHeight : this.height,
23161 height: this.height,
23162 handles : this.resizable,
23165 resize : function(r, w, h) {
23166 _t.onResize(w,h); // -something
23172 this.createToolbar(this);
23175 if(!this.width && this.resizable){
23176 this.setSize(this.wrap.getSize());
23178 if (this.resizeEl) {
23179 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23180 // should trigger onReize..
23186 onResize : function(w, h)
23188 Roo.log('resize: ' +w + ',' + h );
23189 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23193 if(this.inputEl() ){
23194 if(typeof w == 'number'){
23195 var aw = w - this.wrap.getFrameWidth('lr');
23196 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23199 if(typeof h == 'number'){
23200 var tbh = -11; // fixme it needs to tool bar size!
23201 for (var i =0; i < this.toolbars.length;i++) {
23202 // fixme - ask toolbars for heights?
23203 tbh += this.toolbars[i].el.getHeight();
23204 //if (this.toolbars[i].footer) {
23205 // tbh += this.toolbars[i].footer.el.getHeight();
23213 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23214 ah -= 5; // knock a few pixes off for look..
23215 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23219 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23220 this.editorcore.onResize(ew,eh);
23225 * Toggles the editor between standard and source edit mode.
23226 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23228 toggleSourceEdit : function(sourceEditMode)
23230 this.editorcore.toggleSourceEdit(sourceEditMode);
23232 if(this.editorcore.sourceEditMode){
23233 Roo.log('editor - showing textarea');
23236 // Roo.log(this.syncValue());
23238 this.inputEl().removeClass(['hide', 'x-hidden']);
23239 this.inputEl().dom.removeAttribute('tabIndex');
23240 this.inputEl().focus();
23242 Roo.log('editor - hiding textarea');
23244 // Roo.log(this.pushValue());
23247 this.inputEl().addClass(['hide', 'x-hidden']);
23248 this.inputEl().dom.setAttribute('tabIndex', -1);
23249 //this.deferFocus();
23252 if(this.resizable){
23253 this.setSize(this.wrap.getSize());
23256 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23259 // private (for BoxComponent)
23260 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23262 // private (for BoxComponent)
23263 getResizeEl : function(){
23267 // private (for BoxComponent)
23268 getPositionEl : function(){
23273 initEvents : function(){
23274 this.originalValue = this.getValue();
23278 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23281 // markInvalid : Roo.emptyFn,
23283 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23286 // clearInvalid : Roo.emptyFn,
23288 setValue : function(v){
23289 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23290 this.editorcore.pushValue();
23295 deferFocus : function(){
23296 this.focus.defer(10, this);
23300 focus : function(){
23301 this.editorcore.focus();
23307 onDestroy : function(){
23313 for (var i =0; i < this.toolbars.length;i++) {
23314 // fixme - ask toolbars for heights?
23315 this.toolbars[i].onDestroy();
23318 this.wrap.dom.innerHTML = '';
23319 this.wrap.remove();
23324 onFirstFocus : function(){
23325 //Roo.log("onFirstFocus");
23326 this.editorcore.onFirstFocus();
23327 for (var i =0; i < this.toolbars.length;i++) {
23328 this.toolbars[i].onFirstFocus();
23334 syncValue : function()
23336 this.editorcore.syncValue();
23339 pushValue : function()
23341 this.editorcore.pushValue();
23345 // hide stuff that is not compatible
23359 * @event specialkey
23363 * @cfg {String} fieldClass @hide
23366 * @cfg {String} focusClass @hide
23369 * @cfg {String} autoCreate @hide
23372 * @cfg {String} inputType @hide
23375 * @cfg {String} invalidClass @hide
23378 * @cfg {String} invalidText @hide
23381 * @cfg {String} msgFx @hide
23384 * @cfg {String} validateOnBlur @hide
23393 Roo.namespace('Roo.bootstrap.htmleditor');
23395 * @class Roo.bootstrap.HtmlEditorToolbar1
23400 new Roo.bootstrap.HtmlEditor({
23403 new Roo.bootstrap.HtmlEditorToolbar1({
23404 disable : { fonts: 1 , format: 1, ..., ... , ...],
23410 * @cfg {Object} disable List of elements to disable..
23411 * @cfg {Array} btns List of additional buttons.
23415 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23418 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23421 Roo.apply(this, config);
23423 // default disabled, based on 'good practice'..
23424 this.disable = this.disable || {};
23425 Roo.applyIf(this.disable, {
23428 specialElements : true
23430 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23432 this.editor = config.editor;
23433 this.editorcore = config.editor.editorcore;
23435 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23437 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23438 // dont call parent... till later.
23440 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23445 editorcore : false,
23450 "h1","h2","h3","h4","h5","h6",
23452 "abbr", "acronym", "address", "cite", "samp", "var",
23456 onRender : function(ct, position)
23458 // Roo.log("Call onRender: " + this.xtype);
23460 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23462 this.el.dom.style.marginBottom = '0';
23464 var editorcore = this.editorcore;
23465 var editor= this.editor;
23468 var btn = function(id,cmd , toggle, handler, html){
23470 var event = toggle ? 'toggle' : 'click';
23475 xns: Roo.bootstrap,
23478 enableToggle:toggle !== false,
23480 pressed : toggle ? false : null,
23483 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23484 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23490 // var cb_box = function...
23495 xns: Roo.bootstrap,
23496 glyphicon : 'font',
23500 xns: Roo.bootstrap,
23504 Roo.each(this.formats, function(f) {
23505 style.menu.items.push({
23507 xns: Roo.bootstrap,
23508 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23513 editorcore.insertTag(this.tagname);
23520 children.push(style);
23522 btn('bold',false,true);
23523 btn('italic',false,true);
23524 btn('align-left', 'justifyleft',true);
23525 btn('align-center', 'justifycenter',true);
23526 btn('align-right' , 'justifyright',true);
23527 btn('link', false, false, function(btn) {
23528 //Roo.log("create link?");
23529 var url = prompt(this.createLinkText, this.defaultLinkValue);
23530 if(url && url != 'http:/'+'/'){
23531 this.editorcore.relayCmd('createlink', url);
23534 btn('list','insertunorderedlist',true);
23535 btn('pencil', false,true, function(btn){
23537 this.toggleSourceEdit(btn.pressed);
23540 if (this.editor.btns.length > 0) {
23541 for (var i = 0; i<this.editor.btns.length; i++) {
23542 children.push(this.editor.btns[i]);
23550 xns: Roo.bootstrap,
23555 xns: Roo.bootstrap,
23560 cog.menu.items.push({
23562 xns: Roo.bootstrap,
23563 html : Clean styles,
23568 editorcore.insertTag(this.tagname);
23577 this.xtype = 'NavSimplebar';
23579 for(var i=0;i< children.length;i++) {
23581 this.buttons.add(this.addxtypeChild(children[i]));
23585 editor.on('editorevent', this.updateToolbar, this);
23587 onBtnClick : function(id)
23589 this.editorcore.relayCmd(id);
23590 this.editorcore.focus();
23594 * Protected method that will not generally be called directly. It triggers
23595 * a toolbar update by reading the markup state of the current selection in the editor.
23597 updateToolbar: function(){
23599 if(!this.editorcore.activated){
23600 this.editor.onFirstFocus(); // is this neeed?
23604 var btns = this.buttons;
23605 var doc = this.editorcore.doc;
23606 btns.get('bold').setActive(doc.queryCommandState('bold'));
23607 btns.get('italic').setActive(doc.queryCommandState('italic'));
23608 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23610 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23611 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23612 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23614 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23615 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23618 var ans = this.editorcore.getAllAncestors();
23619 if (this.formatCombo) {
23622 var store = this.formatCombo.store;
23623 this.formatCombo.setValue("");
23624 for (var i =0; i < ans.length;i++) {
23625 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23627 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23635 // hides menus... - so this cant be on a menu...
23636 Roo.bootstrap.MenuMgr.hideAll();
23638 Roo.bootstrap.MenuMgr.hideAll();
23639 //this.editorsyncValue();
23641 onFirstFocus: function() {
23642 this.buttons.each(function(item){
23646 toggleSourceEdit : function(sourceEditMode){
23649 if(sourceEditMode){
23650 Roo.log("disabling buttons");
23651 this.buttons.each( function(item){
23652 if(item.cmd != 'pencil'){
23658 Roo.log("enabling buttons");
23659 if(this.editorcore.initialized){
23660 this.buttons.each( function(item){
23666 Roo.log("calling toggole on editor");
23667 // tell the editor that it's been pressed..
23668 this.editor.toggleSourceEdit(sourceEditMode);
23678 * @class Roo.bootstrap.Table.AbstractSelectionModel
23679 * @extends Roo.util.Observable
23680 * Abstract base class for grid SelectionModels. It provides the interface that should be
23681 * implemented by descendant classes. This class should not be directly instantiated.
23684 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23685 this.locked = false;
23686 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23690 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23691 /** @ignore Called by the grid automatically. Do not call directly. */
23692 init : function(grid){
23698 * Locks the selections.
23701 this.locked = true;
23705 * Unlocks the selections.
23707 unlock : function(){
23708 this.locked = false;
23712 * Returns true if the selections are locked.
23713 * @return {Boolean}
23715 isLocked : function(){
23716 return this.locked;
23720 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23721 * @class Roo.bootstrap.Table.RowSelectionModel
23722 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23723 * It supports multiple selections and keyboard selection/navigation.
23725 * @param {Object} config
23728 Roo.bootstrap.Table.RowSelectionModel = function(config){
23729 Roo.apply(this, config);
23730 this.selections = new Roo.util.MixedCollection(false, function(o){
23735 this.lastActive = false;
23739 * @event selectionchange
23740 * Fires when the selection changes
23741 * @param {SelectionModel} this
23743 "selectionchange" : true,
23745 * @event afterselectionchange
23746 * Fires after the selection changes (eg. by key press or clicking)
23747 * @param {SelectionModel} this
23749 "afterselectionchange" : true,
23751 * @event beforerowselect
23752 * Fires when a row is selected being selected, return false to cancel.
23753 * @param {SelectionModel} this
23754 * @param {Number} rowIndex The selected index
23755 * @param {Boolean} keepExisting False if other selections will be cleared
23757 "beforerowselect" : true,
23760 * Fires when a row is selected.
23761 * @param {SelectionModel} this
23762 * @param {Number} rowIndex The selected index
23763 * @param {Roo.data.Record} r The record
23765 "rowselect" : true,
23767 * @event rowdeselect
23768 * Fires when a row is deselected.
23769 * @param {SelectionModel} this
23770 * @param {Number} rowIndex The selected index
23772 "rowdeselect" : true
23774 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23775 this.locked = false;
23778 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23780 * @cfg {Boolean} singleSelect
23781 * True to allow selection of only one row at a time (defaults to false)
23783 singleSelect : false,
23786 initEvents : function()
23789 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23790 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23791 //}else{ // allow click to work like normal
23792 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23794 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23795 this.grid.on("rowclick", this.handleMouseDown, this);
23797 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23798 "up" : function(e){
23800 this.selectPrevious(e.shiftKey);
23801 }else if(this.last !== false && this.lastActive !== false){
23802 var last = this.last;
23803 this.selectRange(this.last, this.lastActive-1);
23804 this.grid.getView().focusRow(this.lastActive);
23805 if(last !== false){
23809 this.selectFirstRow();
23811 this.fireEvent("afterselectionchange", this);
23813 "down" : function(e){
23815 this.selectNext(e.shiftKey);
23816 }else if(this.last !== false && this.lastActive !== false){
23817 var last = this.last;
23818 this.selectRange(this.last, this.lastActive+1);
23819 this.grid.getView().focusRow(this.lastActive);
23820 if(last !== false){
23824 this.selectFirstRow();
23826 this.fireEvent("afterselectionchange", this);
23830 this.grid.store.on('load', function(){
23831 this.selections.clear();
23834 var view = this.grid.view;
23835 view.on("refresh", this.onRefresh, this);
23836 view.on("rowupdated", this.onRowUpdated, this);
23837 view.on("rowremoved", this.onRemove, this);
23842 onRefresh : function()
23844 var ds = this.grid.store, i, v = this.grid.view;
23845 var s = this.selections;
23846 s.each(function(r){
23847 if((i = ds.indexOfId(r.id)) != -1){
23856 onRemove : function(v, index, r){
23857 this.selections.remove(r);
23861 onRowUpdated : function(v, index, r){
23862 if(this.isSelected(r)){
23863 v.onRowSelect(index);
23869 * @param {Array} records The records to select
23870 * @param {Boolean} keepExisting (optional) True to keep existing selections
23872 selectRecords : function(records, keepExisting)
23875 this.clearSelections();
23877 var ds = this.grid.store;
23878 for(var i = 0, len = records.length; i < len; i++){
23879 this.selectRow(ds.indexOf(records[i]), true);
23884 * Gets the number of selected rows.
23887 getCount : function(){
23888 return this.selections.length;
23892 * Selects the first row in the grid.
23894 selectFirstRow : function(){
23899 * Select the last row.
23900 * @param {Boolean} keepExisting (optional) True to keep existing selections
23902 selectLastRow : function(keepExisting){
23903 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23904 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23908 * Selects the row immediately following the last selected row.
23909 * @param {Boolean} keepExisting (optional) True to keep existing selections
23911 selectNext : function(keepExisting)
23913 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23914 this.selectRow(this.last+1, keepExisting);
23915 this.grid.getView().focusRow(this.last);
23920 * Selects the row that precedes the last selected row.
23921 * @param {Boolean} keepExisting (optional) True to keep existing selections
23923 selectPrevious : function(keepExisting){
23925 this.selectRow(this.last-1, keepExisting);
23926 this.grid.getView().focusRow(this.last);
23931 * Returns the selected records
23932 * @return {Array} Array of selected records
23934 getSelections : function(){
23935 return [].concat(this.selections.items);
23939 * Returns the first selected record.
23942 getSelected : function(){
23943 return this.selections.itemAt(0);
23948 * Clears all selections.
23950 clearSelections : function(fast)
23956 var ds = this.grid.store;
23957 var s = this.selections;
23958 s.each(function(r){
23959 this.deselectRow(ds.indexOfId(r.id));
23963 this.selections.clear();
23970 * Selects all rows.
23972 selectAll : function(){
23976 this.selections.clear();
23977 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23978 this.selectRow(i, true);
23983 * Returns True if there is a selection.
23984 * @return {Boolean}
23986 hasSelection : function(){
23987 return this.selections.length > 0;
23991 * Returns True if the specified row is selected.
23992 * @param {Number/Record} record The record or index of the record to check
23993 * @return {Boolean}
23995 isSelected : function(index){
23996 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
23997 return (r && this.selections.key(r.id) ? true : false);
24001 * Returns True if the specified record id is selected.
24002 * @param {String} id The id of record to check
24003 * @return {Boolean}
24005 isIdSelected : function(id){
24006 return (this.selections.key(id) ? true : false);
24011 handleMouseDBClick : function(e, t){
24015 handleMouseDown : function(e, t)
24017 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24018 if(this.isLocked() || rowIndex < 0 ){
24021 if(e.shiftKey && this.last !== false){
24022 var last = this.last;
24023 this.selectRange(last, rowIndex, e.ctrlKey);
24024 this.last = last; // reset the last
24028 var isSelected = this.isSelected(rowIndex);
24029 //Roo.log("select row:" + rowIndex);
24031 this.deselectRow(rowIndex);
24033 this.selectRow(rowIndex, true);
24037 if(e.button !== 0 && isSelected){
24038 alert('rowIndex 2: ' + rowIndex);
24039 view.focusRow(rowIndex);
24040 }else if(e.ctrlKey && isSelected){
24041 this.deselectRow(rowIndex);
24042 }else if(!isSelected){
24043 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24044 view.focusRow(rowIndex);
24048 this.fireEvent("afterselectionchange", this);
24051 handleDragableRowClick : function(grid, rowIndex, e)
24053 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24054 this.selectRow(rowIndex, false);
24055 grid.view.focusRow(rowIndex);
24056 this.fireEvent("afterselectionchange", this);
24061 * Selects multiple rows.
24062 * @param {Array} rows Array of the indexes of the row to select
24063 * @param {Boolean} keepExisting (optional) True to keep existing selections
24065 selectRows : function(rows, keepExisting){
24067 this.clearSelections();
24069 for(var i = 0, len = rows.length; i < len; i++){
24070 this.selectRow(rows[i], true);
24075 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24076 * @param {Number} startRow The index of the first row in the range
24077 * @param {Number} endRow The index of the last row in the range
24078 * @param {Boolean} keepExisting (optional) True to retain existing selections
24080 selectRange : function(startRow, endRow, keepExisting){
24085 this.clearSelections();
24087 if(startRow <= endRow){
24088 for(var i = startRow; i <= endRow; i++){
24089 this.selectRow(i, true);
24092 for(var i = startRow; i >= endRow; i--){
24093 this.selectRow(i, true);
24099 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24100 * @param {Number} startRow The index of the first row in the range
24101 * @param {Number} endRow The index of the last row in the range
24103 deselectRange : function(startRow, endRow, preventViewNotify){
24107 for(var i = startRow; i <= endRow; i++){
24108 this.deselectRow(i, preventViewNotify);
24114 * @param {Number} row The index of the row to select
24115 * @param {Boolean} keepExisting (optional) True to keep existing selections
24117 selectRow : function(index, keepExisting, preventViewNotify)
24119 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24122 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24123 if(!keepExisting || this.singleSelect){
24124 this.clearSelections();
24127 var r = this.grid.store.getAt(index);
24128 //console.log('selectRow - record id :' + r.id);
24130 this.selections.add(r);
24131 this.last = this.lastActive = index;
24132 if(!preventViewNotify){
24133 var proxy = new Roo.Element(
24134 this.grid.getRowDom(index)
24136 proxy.addClass('bg-info info');
24138 this.fireEvent("rowselect", this, index, r);
24139 this.fireEvent("selectionchange", this);
24145 * @param {Number} row The index of the row to deselect
24147 deselectRow : function(index, preventViewNotify)
24152 if(this.last == index){
24155 if(this.lastActive == index){
24156 this.lastActive = false;
24159 var r = this.grid.store.getAt(index);
24164 this.selections.remove(r);
24165 //.console.log('deselectRow - record id :' + r.id);
24166 if(!preventViewNotify){
24168 var proxy = new Roo.Element(
24169 this.grid.getRowDom(index)
24171 proxy.removeClass('bg-info info');
24173 this.fireEvent("rowdeselect", this, index);
24174 this.fireEvent("selectionchange", this);
24178 restoreLast : function(){
24180 this.last = this._last;
24185 acceptsNav : function(row, col, cm){
24186 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24190 onEditorKey : function(field, e){
24191 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24196 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24198 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24200 }else if(k == e.ENTER && !e.ctrlKey){
24204 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24206 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24208 }else if(k == e.ESC){
24212 g.startEditing(newCell[0], newCell[1]);
24218 * Ext JS Library 1.1.1
24219 * Copyright(c) 2006-2007, Ext JS, LLC.
24221 * Originally Released Under LGPL - original licence link has changed is not relivant.
24224 * <script type="text/javascript">
24228 * @class Roo.bootstrap.PagingToolbar
24229 * @extends Roo.bootstrap.NavSimplebar
24230 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24232 * Create a new PagingToolbar
24233 * @param {Object} config The config object
24234 * @param {Roo.data.Store} store
24236 Roo.bootstrap.PagingToolbar = function(config)
24238 // old args format still supported... - xtype is prefered..
24239 // created from xtype...
24241 this.ds = config.dataSource;
24243 if (config.store && !this.ds) {
24244 this.store= Roo.factory(config.store, Roo.data);
24245 this.ds = this.store;
24246 this.ds.xmodule = this.xmodule || false;
24249 this.toolbarItems = [];
24250 if (config.items) {
24251 this.toolbarItems = config.items;
24254 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24259 this.bind(this.ds);
24262 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24266 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24268 * @cfg {Roo.data.Store} dataSource
24269 * The underlying data store providing the paged data
24272 * @cfg {String/HTMLElement/Element} container
24273 * container The id or element that will contain the toolbar
24276 * @cfg {Boolean} displayInfo
24277 * True to display the displayMsg (defaults to false)
24280 * @cfg {Number} pageSize
24281 * The number of records to display per page (defaults to 20)
24285 * @cfg {String} displayMsg
24286 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24288 displayMsg : 'Displaying {0} - {1} of {2}',
24290 * @cfg {String} emptyMsg
24291 * The message to display when no records are found (defaults to "No data to display")
24293 emptyMsg : 'No data to display',
24295 * Customizable piece of the default paging text (defaults to "Page")
24298 beforePageText : "Page",
24300 * Customizable piece of the default paging text (defaults to "of %0")
24303 afterPageText : "of {0}",
24305 * Customizable piece of the default paging text (defaults to "First Page")
24308 firstText : "First Page",
24310 * Customizable piece of the default paging text (defaults to "Previous Page")
24313 prevText : "Previous Page",
24315 * Customizable piece of the default paging text (defaults to "Next Page")
24318 nextText : "Next Page",
24320 * Customizable piece of the default paging text (defaults to "Last Page")
24323 lastText : "Last Page",
24325 * Customizable piece of the default paging text (defaults to "Refresh")
24328 refreshText : "Refresh",
24332 onRender : function(ct, position)
24334 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24335 this.navgroup.parentId = this.id;
24336 this.navgroup.onRender(this.el, null);
24337 // add the buttons to the navgroup
24339 if(this.displayInfo){
24340 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24341 this.displayEl = this.el.select('.x-paging-info', true).first();
24342 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24343 // this.displayEl = navel.el.select('span',true).first();
24349 Roo.each(_this.buttons, function(e){ // this might need to use render????
24350 Roo.factory(e).onRender(_this.el, null);
24354 Roo.each(_this.toolbarItems, function(e) {
24355 _this.navgroup.addItem(e);
24359 this.first = this.navgroup.addItem({
24360 tooltip: this.firstText,
24362 icon : 'fa fa-backward',
24364 preventDefault: true,
24365 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24368 this.prev = this.navgroup.addItem({
24369 tooltip: this.prevText,
24371 icon : 'fa fa-step-backward',
24373 preventDefault: true,
24374 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24376 //this.addSeparator();
24379 var field = this.navgroup.addItem( {
24381 cls : 'x-paging-position',
24383 html : this.beforePageText +
24384 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24385 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24388 this.field = field.el.select('input', true).first();
24389 this.field.on("keydown", this.onPagingKeydown, this);
24390 this.field.on("focus", function(){this.dom.select();});
24393 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24394 //this.field.setHeight(18);
24395 //this.addSeparator();
24396 this.next = this.navgroup.addItem({
24397 tooltip: this.nextText,
24399 html : ' <i class="fa fa-step-forward">',
24401 preventDefault: true,
24402 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24404 this.last = this.navgroup.addItem({
24405 tooltip: this.lastText,
24406 icon : 'fa fa-forward',
24409 preventDefault: true,
24410 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24412 //this.addSeparator();
24413 this.loading = this.navgroup.addItem({
24414 tooltip: this.refreshText,
24415 icon: 'fa fa-refresh',
24416 preventDefault: true,
24417 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24423 updateInfo : function(){
24424 if(this.displayEl){
24425 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24426 var msg = count == 0 ?
24430 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24432 this.displayEl.update(msg);
24437 onLoad : function(ds, r, o)
24439 this.cursor = o.params.start ? o.params.start : 0;
24441 var d = this.getPageData(),
24446 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24447 this.field.dom.value = ap;
24448 this.first.setDisabled(ap == 1);
24449 this.prev.setDisabled(ap == 1);
24450 this.next.setDisabled(ap == ps);
24451 this.last.setDisabled(ap == ps);
24452 this.loading.enable();
24457 getPageData : function(){
24458 var total = this.ds.getTotalCount();
24461 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24462 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24467 onLoadError : function(){
24468 this.loading.enable();
24472 onPagingKeydown : function(e){
24473 var k = e.getKey();
24474 var d = this.getPageData();
24476 var v = this.field.dom.value, pageNum;
24477 if(!v || isNaN(pageNum = parseInt(v, 10))){
24478 this.field.dom.value = d.activePage;
24481 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24482 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24485 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))
24487 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24488 this.field.dom.value = pageNum;
24489 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24492 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24494 var v = this.field.dom.value, pageNum;
24495 var increment = (e.shiftKey) ? 10 : 1;
24496 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24499 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24500 this.field.dom.value = d.activePage;
24503 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24505 this.field.dom.value = parseInt(v, 10) + increment;
24506 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24507 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24514 beforeLoad : function(){
24516 this.loading.disable();
24521 onClick : function(which){
24530 ds.load({params:{start: 0, limit: this.pageSize}});
24533 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24536 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24539 var total = ds.getTotalCount();
24540 var extra = total % this.pageSize;
24541 var lastStart = extra ? (total - extra) : total-this.pageSize;
24542 ds.load({params:{start: lastStart, limit: this.pageSize}});
24545 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24551 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24552 * @param {Roo.data.Store} store The data store to unbind
24554 unbind : function(ds){
24555 ds.un("beforeload", this.beforeLoad, this);
24556 ds.un("load", this.onLoad, this);
24557 ds.un("loadexception", this.onLoadError, this);
24558 ds.un("remove", this.updateInfo, this);
24559 ds.un("add", this.updateInfo, this);
24560 this.ds = undefined;
24564 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24565 * @param {Roo.data.Store} store The data store to bind
24567 bind : function(ds){
24568 ds.on("beforeload", this.beforeLoad, this);
24569 ds.on("load", this.onLoad, this);
24570 ds.on("loadexception", this.onLoadError, this);
24571 ds.on("remove", this.updateInfo, this);
24572 ds.on("add", this.updateInfo, this);
24583 * @class Roo.bootstrap.MessageBar
24584 * @extends Roo.bootstrap.Component
24585 * Bootstrap MessageBar class
24586 * @cfg {String} html contents of the MessageBar
24587 * @cfg {String} weight (info | success | warning | danger) default info
24588 * @cfg {String} beforeClass insert the bar before the given class
24589 * @cfg {Boolean} closable (true | false) default false
24590 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24593 * Create a new Element
24594 * @param {Object} config The config object
24597 Roo.bootstrap.MessageBar = function(config){
24598 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24601 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24607 beforeClass: 'bootstrap-sticky-wrap',
24609 getAutoCreate : function(){
24613 cls: 'alert alert-dismissable alert-' + this.weight,
24618 html: this.html || ''
24624 cfg.cls += ' alert-messages-fixed';
24638 onRender : function(ct, position)
24640 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24643 var cfg = Roo.apply({}, this.getAutoCreate());
24647 cfg.cls += ' ' + this.cls;
24650 cfg.style = this.style;
24652 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24654 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24657 this.el.select('>button.close').on('click', this.hide, this);
24663 if (!this.rendered) {
24669 this.fireEvent('show', this);
24675 if (!this.rendered) {
24681 this.fireEvent('hide', this);
24684 update : function()
24686 // var e = this.el.dom.firstChild;
24688 // if(this.closable){
24689 // e = e.nextSibling;
24692 // e.data = this.html || '';
24694 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24710 * @class Roo.bootstrap.Graph
24711 * @extends Roo.bootstrap.Component
24712 * Bootstrap Graph class
24716 @cfg {String} graphtype bar | vbar | pie
24717 @cfg {number} g_x coodinator | centre x (pie)
24718 @cfg {number} g_y coodinator | centre y (pie)
24719 @cfg {number} g_r radius (pie)
24720 @cfg {number} g_height height of the chart (respected by all elements in the set)
24721 @cfg {number} g_width width of the chart (respected by all elements in the set)
24722 @cfg {Object} title The title of the chart
24725 -opts (object) options for the chart
24727 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24728 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24730 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.
24731 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24733 o stretch (boolean)
24735 -opts (object) options for the pie
24738 o startAngle (number)
24739 o endAngle (number)
24743 * Create a new Input
24744 * @param {Object} config The config object
24747 Roo.bootstrap.Graph = function(config){
24748 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24754 * The img click event for the img.
24755 * @param {Roo.EventObject} e
24761 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24772 //g_colors: this.colors,
24779 getAutoCreate : function(){
24790 onRender : function(ct,position){
24793 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24795 if (typeof(Raphael) == 'undefined') {
24796 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24800 this.raphael = Raphael(this.el.dom);
24802 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24803 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24804 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24805 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24807 r.text(160, 10, "Single Series Chart").attr(txtattr);
24808 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24809 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24810 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24812 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24813 r.barchart(330, 10, 300, 220, data1);
24814 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24815 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24818 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24819 // r.barchart(30, 30, 560, 250, xdata, {
24820 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24821 // axis : "0 0 1 1",
24822 // axisxlabels : xdata
24823 // //yvalues : cols,
24826 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24828 // this.load(null,xdata,{
24829 // axis : "0 0 1 1",
24830 // axisxlabels : xdata
24835 load : function(graphtype,xdata,opts)
24837 this.raphael.clear();
24839 graphtype = this.graphtype;
24844 var r = this.raphael,
24845 fin = function () {
24846 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24848 fout = function () {
24849 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24851 pfin = function() {
24852 this.sector.stop();
24853 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24856 this.label[0].stop();
24857 this.label[0].attr({ r: 7.5 });
24858 this.label[1].attr({ "font-weight": 800 });
24861 pfout = function() {
24862 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24865 this.label[0].animate({ r: 5 }, 500, "bounce");
24866 this.label[1].attr({ "font-weight": 400 });
24872 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24875 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24878 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24879 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24881 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24888 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24893 setTitle: function(o)
24898 initEvents: function() {
24901 this.el.on('click', this.onClick, this);
24905 onClick : function(e)
24907 Roo.log('img onclick');
24908 this.fireEvent('click', this, e);
24920 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24923 * @class Roo.bootstrap.dash.NumberBox
24924 * @extends Roo.bootstrap.Component
24925 * Bootstrap NumberBox class
24926 * @cfg {String} headline Box headline
24927 * @cfg {String} content Box content
24928 * @cfg {String} icon Box icon
24929 * @cfg {String} footer Footer text
24930 * @cfg {String} fhref Footer href
24933 * Create a new NumberBox
24934 * @param {Object} config The config object
24938 Roo.bootstrap.dash.NumberBox = function(config){
24939 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24943 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24952 getAutoCreate : function(){
24956 cls : 'small-box ',
24964 cls : 'roo-headline',
24965 html : this.headline
24969 cls : 'roo-content',
24970 html : this.content
24984 cls : 'ion ' + this.icon
24993 cls : 'small-box-footer',
24994 href : this.fhref || '#',
24998 cfg.cn.push(footer);
25005 onRender : function(ct,position){
25006 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25013 setHeadline: function (value)
25015 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25018 setFooter: function (value, href)
25020 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25023 this.el.select('a.small-box-footer',true).first().attr('href', href);
25028 setContent: function (value)
25030 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25033 initEvents: function()
25047 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25050 * @class Roo.bootstrap.dash.TabBox
25051 * @extends Roo.bootstrap.Component
25052 * Bootstrap TabBox class
25053 * @cfg {String} title Title of the TabBox
25054 * @cfg {String} icon Icon of the TabBox
25055 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25056 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25059 * Create a new TabBox
25060 * @param {Object} config The config object
25064 Roo.bootstrap.dash.TabBox = function(config){
25065 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25070 * When a pane is added
25071 * @param {Roo.bootstrap.dash.TabPane} pane
25075 * @event activatepane
25076 * When a pane is activated
25077 * @param {Roo.bootstrap.dash.TabPane} pane
25079 "activatepane" : true
25087 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25092 tabScrollable : false,
25094 getChildContainer : function()
25096 return this.el.select('.tab-content', true).first();
25099 getAutoCreate : function(){
25103 cls: 'pull-left header',
25111 cls: 'fa ' + this.icon
25117 cls: 'nav nav-tabs pull-right',
25123 if(this.tabScrollable){
25130 cls: 'nav nav-tabs pull-right',
25141 cls: 'nav-tabs-custom',
25146 cls: 'tab-content no-padding',
25154 initEvents : function()
25156 //Roo.log('add add pane handler');
25157 this.on('addpane', this.onAddPane, this);
25160 * Updates the box title
25161 * @param {String} html to set the title to.
25163 setTitle : function(value)
25165 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25167 onAddPane : function(pane)
25169 this.panes.push(pane);
25170 //Roo.log('addpane');
25172 // tabs are rendere left to right..
25173 if(!this.showtabs){
25177 var ctr = this.el.select('.nav-tabs', true).first();
25180 var existing = ctr.select('.nav-tab',true);
25181 var qty = existing.getCount();;
25184 var tab = ctr.createChild({
25186 cls : 'nav-tab' + (qty ? '' : ' active'),
25194 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25197 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25199 pane.el.addClass('active');
25204 onTabClick : function(ev,un,ob,pane)
25206 //Roo.log('tab - prev default');
25207 ev.preventDefault();
25210 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25211 pane.tab.addClass('active');
25212 //Roo.log(pane.title);
25213 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25214 // technically we should have a deactivate event.. but maybe add later.
25215 // and it should not de-activate the selected tab...
25216 this.fireEvent('activatepane', pane);
25217 pane.el.addClass('active');
25218 pane.fireEvent('activate');
25223 getActivePane : function()
25226 Roo.each(this.panes, function(p) {
25227 if(p.el.hasClass('active')){
25248 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25250 * @class Roo.bootstrap.TabPane
25251 * @extends Roo.bootstrap.Component
25252 * Bootstrap TabPane class
25253 * @cfg {Boolean} active (false | true) Default false
25254 * @cfg {String} title title of panel
25258 * Create a new TabPane
25259 * @param {Object} config The config object
25262 Roo.bootstrap.dash.TabPane = function(config){
25263 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25269 * When a pane is activated
25270 * @param {Roo.bootstrap.dash.TabPane} pane
25277 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25282 // the tabBox that this is attached to.
25285 getAutoCreate : function()
25293 cfg.cls += ' active';
25298 initEvents : function()
25300 //Roo.log('trigger add pane handler');
25301 this.parent().fireEvent('addpane', this)
25305 * Updates the tab title
25306 * @param {String} html to set the title to.
25308 setTitle: function(str)
25314 this.tab.select('a', true).first().dom.innerHTML = str;
25331 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25334 * @class Roo.bootstrap.menu.Menu
25335 * @extends Roo.bootstrap.Component
25336 * Bootstrap Menu class - container for Menu
25337 * @cfg {String} html Text of the menu
25338 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25339 * @cfg {String} icon Font awesome icon
25340 * @cfg {String} pos Menu align to (top | bottom) default bottom
25344 * Create a new Menu
25345 * @param {Object} config The config object
25349 Roo.bootstrap.menu.Menu = function(config){
25350 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25354 * @event beforeshow
25355 * Fires before this menu is displayed
25356 * @param {Roo.bootstrap.menu.Menu} this
25360 * @event beforehide
25361 * Fires before this menu is hidden
25362 * @param {Roo.bootstrap.menu.Menu} this
25367 * Fires after this menu is displayed
25368 * @param {Roo.bootstrap.menu.Menu} this
25373 * Fires after this menu is hidden
25374 * @param {Roo.bootstrap.menu.Menu} this
25379 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25380 * @param {Roo.bootstrap.menu.Menu} this
25381 * @param {Roo.EventObject} e
25388 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25392 weight : 'default',
25397 getChildContainer : function() {
25398 if(this.isSubMenu){
25402 return this.el.select('ul.dropdown-menu', true).first();
25405 getAutoCreate : function()
25410 cls : 'roo-menu-text',
25418 cls : 'fa ' + this.icon
25429 cls : 'dropdown-button btn btn-' + this.weight,
25434 cls : 'dropdown-toggle btn btn-' + this.weight,
25444 cls : 'dropdown-menu'
25450 if(this.pos == 'top'){
25451 cfg.cls += ' dropup';
25454 if(this.isSubMenu){
25457 cls : 'dropdown-menu'
25464 onRender : function(ct, position)
25466 this.isSubMenu = ct.hasClass('dropdown-submenu');
25468 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25471 initEvents : function()
25473 if(this.isSubMenu){
25477 this.hidden = true;
25479 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25480 this.triggerEl.on('click', this.onTriggerPress, this);
25482 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25483 this.buttonEl.on('click', this.onClick, this);
25489 if(this.isSubMenu){
25493 return this.el.select('ul.dropdown-menu', true).first();
25496 onClick : function(e)
25498 this.fireEvent("click", this, e);
25501 onTriggerPress : function(e)
25503 if (this.isVisible()) {
25510 isVisible : function(){
25511 return !this.hidden;
25516 this.fireEvent("beforeshow", this);
25518 this.hidden = false;
25519 this.el.addClass('open');
25521 Roo.get(document).on("mouseup", this.onMouseUp, this);
25523 this.fireEvent("show", this);
25530 this.fireEvent("beforehide", this);
25532 this.hidden = true;
25533 this.el.removeClass('open');
25535 Roo.get(document).un("mouseup", this.onMouseUp);
25537 this.fireEvent("hide", this);
25540 onMouseUp : function()
25554 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25557 * @class Roo.bootstrap.menu.Item
25558 * @extends Roo.bootstrap.Component
25559 * Bootstrap MenuItem class
25560 * @cfg {Boolean} submenu (true | false) default false
25561 * @cfg {String} html text of the item
25562 * @cfg {String} href the link
25563 * @cfg {Boolean} disable (true | false) default false
25564 * @cfg {Boolean} preventDefault (true | false) default true
25565 * @cfg {String} icon Font awesome icon
25566 * @cfg {String} pos Submenu align to (left | right) default right
25570 * Create a new Item
25571 * @param {Object} config The config object
25575 Roo.bootstrap.menu.Item = function(config){
25576 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25580 * Fires when the mouse is hovering over this menu
25581 * @param {Roo.bootstrap.menu.Item} this
25582 * @param {Roo.EventObject} e
25587 * Fires when the mouse exits this menu
25588 * @param {Roo.bootstrap.menu.Item} this
25589 * @param {Roo.EventObject} e
25595 * The raw click event for the entire grid.
25596 * @param {Roo.EventObject} e
25602 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25607 preventDefault: true,
25612 getAutoCreate : function()
25617 cls : 'roo-menu-item-text',
25625 cls : 'fa ' + this.icon
25634 href : this.href || '#',
25641 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25645 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25647 if(this.pos == 'left'){
25648 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25655 initEvents : function()
25657 this.el.on('mouseover', this.onMouseOver, this);
25658 this.el.on('mouseout', this.onMouseOut, this);
25660 this.el.select('a', true).first().on('click', this.onClick, this);
25664 onClick : function(e)
25666 if(this.preventDefault){
25667 e.preventDefault();
25670 this.fireEvent("click", this, e);
25673 onMouseOver : function(e)
25675 if(this.submenu && this.pos == 'left'){
25676 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25679 this.fireEvent("mouseover", this, e);
25682 onMouseOut : function(e)
25684 this.fireEvent("mouseout", this, e);
25696 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25699 * @class Roo.bootstrap.menu.Separator
25700 * @extends Roo.bootstrap.Component
25701 * Bootstrap Separator class
25704 * Create a new Separator
25705 * @param {Object} config The config object
25709 Roo.bootstrap.menu.Separator = function(config){
25710 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25713 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25715 getAutoCreate : function(){
25736 * @class Roo.bootstrap.Tooltip
25737 * Bootstrap Tooltip class
25738 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25739 * to determine which dom element triggers the tooltip.
25741 * It needs to add support for additional attributes like tooltip-position
25744 * Create a new Toolti
25745 * @param {Object} config The config object
25748 Roo.bootstrap.Tooltip = function(config){
25749 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25751 this.alignment = Roo.bootstrap.Tooltip.alignment;
25753 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25754 this.alignment = config.alignment;
25759 Roo.apply(Roo.bootstrap.Tooltip, {
25761 * @function init initialize tooltip monitoring.
25765 currentTip : false,
25766 currentRegion : false,
25772 Roo.get(document).on('mouseover', this.enter ,this);
25773 Roo.get(document).on('mouseout', this.leave, this);
25776 this.currentTip = new Roo.bootstrap.Tooltip();
25779 enter : function(ev)
25781 var dom = ev.getTarget();
25783 //Roo.log(['enter',dom]);
25784 var el = Roo.fly(dom);
25785 if (this.currentEl) {
25787 //Roo.log(this.currentEl);
25788 //Roo.log(this.currentEl.contains(dom));
25789 if (this.currentEl == el) {
25792 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25798 if (this.currentTip.el) {
25799 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25803 if(!el || el.dom == document){
25809 // you can not look for children, as if el is the body.. then everythign is the child..
25810 if (!el.attr('tooltip')) { //
25811 if (!el.select("[tooltip]").elements.length) {
25814 // is the mouse over this child...?
25815 bindEl = el.select("[tooltip]").first();
25816 var xy = ev.getXY();
25817 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25818 //Roo.log("not in region.");
25821 //Roo.log("child element over..");
25824 this.currentEl = bindEl;
25825 this.currentTip.bind(bindEl);
25826 this.currentRegion = Roo.lib.Region.getRegion(dom);
25827 this.currentTip.enter();
25830 leave : function(ev)
25832 var dom = ev.getTarget();
25833 //Roo.log(['leave',dom]);
25834 if (!this.currentEl) {
25839 if (dom != this.currentEl.dom) {
25842 var xy = ev.getXY();
25843 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25846 // only activate leave if mouse cursor is outside... bounding box..
25851 if (this.currentTip) {
25852 this.currentTip.leave();
25854 //Roo.log('clear currentEl');
25855 this.currentEl = false;
25860 'left' : ['r-l', [-2,0], 'right'],
25861 'right' : ['l-r', [2,0], 'left'],
25862 'bottom' : ['t-b', [0,2], 'top'],
25863 'top' : [ 'b-t', [0,-2], 'bottom']
25869 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25874 delay : null, // can be { show : 300 , hide: 500}
25878 hoverState : null, //???
25880 placement : 'bottom',
25884 getAutoCreate : function(){
25891 cls : 'tooltip-arrow'
25894 cls : 'tooltip-inner'
25901 bind : function(el)
25907 enter : function () {
25909 if (this.timeout != null) {
25910 clearTimeout(this.timeout);
25913 this.hoverState = 'in';
25914 //Roo.log("enter - show");
25915 if (!this.delay || !this.delay.show) {
25920 this.timeout = setTimeout(function () {
25921 if (_t.hoverState == 'in') {
25924 }, this.delay.show);
25928 clearTimeout(this.timeout);
25930 this.hoverState = 'out';
25931 if (!this.delay || !this.delay.hide) {
25937 this.timeout = setTimeout(function () {
25938 //Roo.log("leave - timeout");
25940 if (_t.hoverState == 'out') {
25942 Roo.bootstrap.Tooltip.currentEl = false;
25947 show : function (msg)
25950 this.render(document.body);
25953 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25955 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25957 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25959 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25961 var placement = typeof this.placement == 'function' ?
25962 this.placement.call(this, this.el, on_el) :
25965 var autoToken = /\s?auto?\s?/i;
25966 var autoPlace = autoToken.test(placement);
25968 placement = placement.replace(autoToken, '') || 'top';
25972 //this.el.setXY([0,0]);
25974 //this.el.dom.style.display='block';
25976 //this.el.appendTo(on_el);
25978 var p = this.getPosition();
25979 var box = this.el.getBox();
25985 var align = this.alignment[placement];
25987 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25989 if(placement == 'top' || placement == 'bottom'){
25991 placement = 'right';
25994 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25995 placement = 'left';
25998 var scroll = Roo.select('body', true).first().getScroll();
26000 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26006 this.el.alignTo(this.bindEl, align[0],align[1]);
26007 //var arrow = this.el.select('.arrow',true).first();
26008 //arrow.set(align[2],
26010 this.el.addClass(placement);
26012 this.el.addClass('in fade');
26014 this.hoverState = null;
26016 if (this.el.hasClass('fade')) {
26027 //this.el.setXY([0,0]);
26028 this.el.removeClass('in');
26044 * @class Roo.bootstrap.LocationPicker
26045 * @extends Roo.bootstrap.Component
26046 * Bootstrap LocationPicker class
26047 * @cfg {Number} latitude Position when init default 0
26048 * @cfg {Number} longitude Position when init default 0
26049 * @cfg {Number} zoom default 15
26050 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26051 * @cfg {Boolean} mapTypeControl default false
26052 * @cfg {Boolean} disableDoubleClickZoom default false
26053 * @cfg {Boolean} scrollwheel default true
26054 * @cfg {Boolean} streetViewControl default false
26055 * @cfg {Number} radius default 0
26056 * @cfg {String} locationName
26057 * @cfg {Boolean} draggable default true
26058 * @cfg {Boolean} enableAutocomplete default false
26059 * @cfg {Boolean} enableReverseGeocode default true
26060 * @cfg {String} markerTitle
26063 * Create a new LocationPicker
26064 * @param {Object} config The config object
26068 Roo.bootstrap.LocationPicker = function(config){
26070 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26075 * Fires when the picker initialized.
26076 * @param {Roo.bootstrap.LocationPicker} this
26077 * @param {Google Location} location
26081 * @event positionchanged
26082 * Fires when the picker position changed.
26083 * @param {Roo.bootstrap.LocationPicker} this
26084 * @param {Google Location} location
26086 positionchanged : true,
26089 * Fires when the map resize.
26090 * @param {Roo.bootstrap.LocationPicker} this
26095 * Fires when the map show.
26096 * @param {Roo.bootstrap.LocationPicker} this
26101 * Fires when the map hide.
26102 * @param {Roo.bootstrap.LocationPicker} this
26107 * Fires when click the map.
26108 * @param {Roo.bootstrap.LocationPicker} this
26109 * @param {Map event} e
26113 * @event mapRightClick
26114 * Fires when right click the map.
26115 * @param {Roo.bootstrap.LocationPicker} this
26116 * @param {Map event} e
26118 mapRightClick : true,
26120 * @event markerClick
26121 * Fires when click the marker.
26122 * @param {Roo.bootstrap.LocationPicker} this
26123 * @param {Map event} e
26125 markerClick : true,
26127 * @event markerRightClick
26128 * Fires when right click the marker.
26129 * @param {Roo.bootstrap.LocationPicker} this
26130 * @param {Map event} e
26132 markerRightClick : true,
26134 * @event OverlayViewDraw
26135 * Fires when OverlayView Draw
26136 * @param {Roo.bootstrap.LocationPicker} this
26138 OverlayViewDraw : true,
26140 * @event OverlayViewOnAdd
26141 * Fires when OverlayView Draw
26142 * @param {Roo.bootstrap.LocationPicker} this
26144 OverlayViewOnAdd : true,
26146 * @event OverlayViewOnRemove
26147 * Fires when OverlayView Draw
26148 * @param {Roo.bootstrap.LocationPicker} this
26150 OverlayViewOnRemove : true,
26152 * @event OverlayViewShow
26153 * Fires when OverlayView Draw
26154 * @param {Roo.bootstrap.LocationPicker} this
26155 * @param {Pixel} cpx
26157 OverlayViewShow : true,
26159 * @event OverlayViewHide
26160 * Fires when OverlayView Draw
26161 * @param {Roo.bootstrap.LocationPicker} this
26163 OverlayViewHide : true,
26165 * @event loadexception
26166 * Fires when load google lib failed.
26167 * @param {Roo.bootstrap.LocationPicker} this
26169 loadexception : true
26174 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26176 gMapContext: false,
26182 mapTypeControl: false,
26183 disableDoubleClickZoom: false,
26185 streetViewControl: false,
26189 enableAutocomplete: false,
26190 enableReverseGeocode: true,
26193 getAutoCreate: function()
26198 cls: 'roo-location-picker'
26204 initEvents: function(ct, position)
26206 if(!this.el.getWidth() || this.isApplied()){
26210 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26215 initial: function()
26217 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26218 this.fireEvent('loadexception', this);
26222 if(!this.mapTypeId){
26223 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26226 this.gMapContext = this.GMapContext();
26228 this.initOverlayView();
26230 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26234 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26235 _this.setPosition(_this.gMapContext.marker.position);
26238 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26239 _this.fireEvent('mapClick', this, event);
26243 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26244 _this.fireEvent('mapRightClick', this, event);
26248 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26249 _this.fireEvent('markerClick', this, event);
26253 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26254 _this.fireEvent('markerRightClick', this, event);
26258 this.setPosition(this.gMapContext.location);
26260 this.fireEvent('initial', this, this.gMapContext.location);
26263 initOverlayView: function()
26267 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26271 _this.fireEvent('OverlayViewDraw', _this);
26276 _this.fireEvent('OverlayViewOnAdd', _this);
26279 onRemove: function()
26281 _this.fireEvent('OverlayViewOnRemove', _this);
26284 show: function(cpx)
26286 _this.fireEvent('OverlayViewShow', _this, cpx);
26291 _this.fireEvent('OverlayViewHide', _this);
26297 fromLatLngToContainerPixel: function(event)
26299 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26302 isApplied: function()
26304 return this.getGmapContext() == false ? false : true;
26307 getGmapContext: function()
26309 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26312 GMapContext: function()
26314 var position = new google.maps.LatLng(this.latitude, this.longitude);
26316 var _map = new google.maps.Map(this.el.dom, {
26319 mapTypeId: this.mapTypeId,
26320 mapTypeControl: this.mapTypeControl,
26321 disableDoubleClickZoom: this.disableDoubleClickZoom,
26322 scrollwheel: this.scrollwheel,
26323 streetViewControl: this.streetViewControl,
26324 locationName: this.locationName,
26325 draggable: this.draggable,
26326 enableAutocomplete: this.enableAutocomplete,
26327 enableReverseGeocode: this.enableReverseGeocode
26330 var _marker = new google.maps.Marker({
26331 position: position,
26333 title: this.markerTitle,
26334 draggable: this.draggable
26341 location: position,
26342 radius: this.radius,
26343 locationName: this.locationName,
26344 addressComponents: {
26345 formatted_address: null,
26346 addressLine1: null,
26347 addressLine2: null,
26349 streetNumber: null,
26353 stateOrProvince: null
26356 domContainer: this.el.dom,
26357 geodecoder: new google.maps.Geocoder()
26361 drawCircle: function(center, radius, options)
26363 if (this.gMapContext.circle != null) {
26364 this.gMapContext.circle.setMap(null);
26368 options = Roo.apply({}, options, {
26369 strokeColor: "#0000FF",
26370 strokeOpacity: .35,
26372 fillColor: "#0000FF",
26376 options.map = this.gMapContext.map;
26377 options.radius = radius;
26378 options.center = center;
26379 this.gMapContext.circle = new google.maps.Circle(options);
26380 return this.gMapContext.circle;
26386 setPosition: function(location)
26388 this.gMapContext.location = location;
26389 this.gMapContext.marker.setPosition(location);
26390 this.gMapContext.map.panTo(location);
26391 this.drawCircle(location, this.gMapContext.radius, {});
26395 if (this.gMapContext.settings.enableReverseGeocode) {
26396 this.gMapContext.geodecoder.geocode({
26397 latLng: this.gMapContext.location
26398 }, function(results, status) {
26400 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26401 _this.gMapContext.locationName = results[0].formatted_address;
26402 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26404 _this.fireEvent('positionchanged', this, location);
26411 this.fireEvent('positionchanged', this, location);
26416 google.maps.event.trigger(this.gMapContext.map, "resize");
26418 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26420 this.fireEvent('resize', this);
26423 setPositionByLatLng: function(latitude, longitude)
26425 this.setPosition(new google.maps.LatLng(latitude, longitude));
26428 getCurrentPosition: function()
26431 latitude: this.gMapContext.location.lat(),
26432 longitude: this.gMapContext.location.lng()
26436 getAddressName: function()
26438 return this.gMapContext.locationName;
26441 getAddressComponents: function()
26443 return this.gMapContext.addressComponents;
26446 address_component_from_google_geocode: function(address_components)
26450 for (var i = 0; i < address_components.length; i++) {
26451 var component = address_components[i];
26452 if (component.types.indexOf("postal_code") >= 0) {
26453 result.postalCode = component.short_name;
26454 } else if (component.types.indexOf("street_number") >= 0) {
26455 result.streetNumber = component.short_name;
26456 } else if (component.types.indexOf("route") >= 0) {
26457 result.streetName = component.short_name;
26458 } else if (component.types.indexOf("neighborhood") >= 0) {
26459 result.city = component.short_name;
26460 } else if (component.types.indexOf("locality") >= 0) {
26461 result.city = component.short_name;
26462 } else if (component.types.indexOf("sublocality") >= 0) {
26463 result.district = component.short_name;
26464 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26465 result.stateOrProvince = component.short_name;
26466 } else if (component.types.indexOf("country") >= 0) {
26467 result.country = component.short_name;
26471 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26472 result.addressLine2 = "";
26476 setZoomLevel: function(zoom)
26478 this.gMapContext.map.setZoom(zoom);
26491 this.fireEvent('show', this);
26502 this.fireEvent('hide', this);
26507 Roo.apply(Roo.bootstrap.LocationPicker, {
26509 OverlayView : function(map, options)
26511 options = options || {};
26525 * @class Roo.bootstrap.Alert
26526 * @extends Roo.bootstrap.Component
26527 * Bootstrap Alert class
26528 * @cfg {String} title The title of alert
26529 * @cfg {String} html The content of alert
26530 * @cfg {String} weight ( success | info | warning | danger )
26531 * @cfg {String} faicon font-awesomeicon
26534 * Create a new alert
26535 * @param {Object} config The config object
26539 Roo.bootstrap.Alert = function(config){
26540 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26544 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26551 getAutoCreate : function()
26560 cls : 'roo-alert-icon'
26565 cls : 'roo-alert-title',
26570 cls : 'roo-alert-text',
26577 cfg.cn[0].cls += ' fa ' + this.faicon;
26581 cfg.cls += ' alert-' + this.weight;
26587 initEvents: function()
26589 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26592 setTitle : function(str)
26594 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26597 setText : function(str)
26599 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26602 setWeight : function(weight)
26605 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26608 this.weight = weight;
26610 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26613 setIcon : function(icon)
26616 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26619 this.faicon = icon;
26621 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26642 * @class Roo.bootstrap.UploadCropbox
26643 * @extends Roo.bootstrap.Component
26644 * Bootstrap UploadCropbox class
26645 * @cfg {String} emptyText show when image has been loaded
26646 * @cfg {String} rotateNotify show when image too small to rotate
26647 * @cfg {Number} errorTimeout default 3000
26648 * @cfg {Number} minWidth default 300
26649 * @cfg {Number} minHeight default 300
26650 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26651 * @cfg {Boolean} isDocument (true|false) default false
26652 * @cfg {String} url action url
26653 * @cfg {String} paramName default 'imageUpload'
26654 * @cfg {String} method default POST
26655 * @cfg {Boolean} loadMask (true|false) default true
26656 * @cfg {Boolean} loadingText default 'Loading...'
26659 * Create a new UploadCropbox
26660 * @param {Object} config The config object
26663 Roo.bootstrap.UploadCropbox = function(config){
26664 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26668 * @event beforeselectfile
26669 * Fire before select file
26670 * @param {Roo.bootstrap.UploadCropbox} this
26672 "beforeselectfile" : true,
26675 * Fire after initEvent
26676 * @param {Roo.bootstrap.UploadCropbox} this
26681 * Fire after initEvent
26682 * @param {Roo.bootstrap.UploadCropbox} this
26683 * @param {String} data
26688 * Fire when preparing the file data
26689 * @param {Roo.bootstrap.UploadCropbox} this
26690 * @param {Object} file
26695 * Fire when get exception
26696 * @param {Roo.bootstrap.UploadCropbox} this
26697 * @param {XMLHttpRequest} xhr
26699 "exception" : true,
26701 * @event beforeloadcanvas
26702 * Fire before load the canvas
26703 * @param {Roo.bootstrap.UploadCropbox} this
26704 * @param {String} src
26706 "beforeloadcanvas" : true,
26709 * Fire when trash image
26710 * @param {Roo.bootstrap.UploadCropbox} this
26715 * Fire when download the image
26716 * @param {Roo.bootstrap.UploadCropbox} this
26720 * @event footerbuttonclick
26721 * Fire when footerbuttonclick
26722 * @param {Roo.bootstrap.UploadCropbox} this
26723 * @param {String} type
26725 "footerbuttonclick" : true,
26729 * @param {Roo.bootstrap.UploadCropbox} this
26734 * Fire when rotate the image
26735 * @param {Roo.bootstrap.UploadCropbox} this
26736 * @param {String} pos
26741 * Fire when inspect the file
26742 * @param {Roo.bootstrap.UploadCropbox} this
26743 * @param {Object} file
26748 * Fire when xhr upload the file
26749 * @param {Roo.bootstrap.UploadCropbox} this
26750 * @param {Object} data
26755 * Fire when arrange the file data
26756 * @param {Roo.bootstrap.UploadCropbox} this
26757 * @param {Object} formData
26762 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26765 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26767 emptyText : 'Click to upload image',
26768 rotateNotify : 'Image is too small to rotate',
26769 errorTimeout : 3000,
26783 cropType : 'image/jpeg',
26785 canvasLoaded : false,
26786 isDocument : false,
26788 paramName : 'imageUpload',
26790 loadingText : 'Loading...',
26793 getAutoCreate : function()
26797 cls : 'roo-upload-cropbox',
26801 cls : 'roo-upload-cropbox-selector',
26806 cls : 'roo-upload-cropbox-body',
26807 style : 'cursor:pointer',
26811 cls : 'roo-upload-cropbox-preview'
26815 cls : 'roo-upload-cropbox-thumb'
26819 cls : 'roo-upload-cropbox-empty-notify',
26820 html : this.emptyText
26824 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26825 html : this.rotateNotify
26831 cls : 'roo-upload-cropbox-footer',
26834 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26844 onRender : function(ct, position)
26846 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26848 if (this.buttons.length) {
26850 Roo.each(this.buttons, function(bb) {
26852 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26854 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26860 this.maskEl = this.el;
26864 initEvents : function()
26866 this.urlAPI = (window.createObjectURL && window) ||
26867 (window.URL && URL.revokeObjectURL && URL) ||
26868 (window.webkitURL && webkitURL);
26870 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26871 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26873 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26874 this.selectorEl.hide();
26876 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26877 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26879 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26880 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26881 this.thumbEl.hide();
26883 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26884 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26886 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26887 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26888 this.errorEl.hide();
26890 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26891 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26892 this.footerEl.hide();
26894 this.setThumbBoxSize();
26900 this.fireEvent('initial', this);
26907 window.addEventListener("resize", function() { _this.resize(); } );
26909 this.bodyEl.on('click', this.beforeSelectFile, this);
26912 this.bodyEl.on('touchstart', this.onTouchStart, this);
26913 this.bodyEl.on('touchmove', this.onTouchMove, this);
26914 this.bodyEl.on('touchend', this.onTouchEnd, this);
26918 this.bodyEl.on('mousedown', this.onMouseDown, this);
26919 this.bodyEl.on('mousemove', this.onMouseMove, this);
26920 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26921 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26922 Roo.get(document).on('mouseup', this.onMouseUp, this);
26925 this.selectorEl.on('change', this.onFileSelected, this);
26931 this.baseScale = 1;
26933 this.baseRotate = 1;
26934 this.dragable = false;
26935 this.pinching = false;
26938 this.cropData = false;
26939 this.notifyEl.dom.innerHTML = this.emptyText;
26941 this.selectorEl.dom.value = '';
26945 resize : function()
26947 if(this.fireEvent('resize', this) != false){
26948 this.setThumbBoxPosition();
26949 this.setCanvasPosition();
26953 onFooterButtonClick : function(e, el, o, type)
26956 case 'rotate-left' :
26957 this.onRotateLeft(e);
26959 case 'rotate-right' :
26960 this.onRotateRight(e);
26963 this.beforeSelectFile(e);
26978 this.fireEvent('footerbuttonclick', this, type);
26981 beforeSelectFile : function(e)
26983 e.preventDefault();
26985 if(this.fireEvent('beforeselectfile', this) != false){
26986 this.selectorEl.dom.click();
26990 onFileSelected : function(e)
26992 e.preventDefault();
26994 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
26998 var file = this.selectorEl.dom.files[0];
27000 if(this.fireEvent('inspect', this, file) != false){
27001 this.prepare(file);
27006 trash : function(e)
27008 this.fireEvent('trash', this);
27011 download : function(e)
27013 this.fireEvent('download', this);
27016 loadCanvas : function(src)
27018 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27022 this.imageEl = document.createElement('img');
27026 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27028 this.imageEl.src = src;
27032 onLoadCanvas : function()
27034 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27035 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27037 this.bodyEl.un('click', this.beforeSelectFile, this);
27039 this.notifyEl.hide();
27040 this.thumbEl.show();
27041 this.footerEl.show();
27043 this.baseRotateLevel();
27045 if(this.isDocument){
27046 this.setThumbBoxSize();
27049 this.setThumbBoxPosition();
27051 this.baseScaleLevel();
27057 this.canvasLoaded = true;
27060 this.maskEl.unmask();
27065 setCanvasPosition : function()
27067 if(!this.canvasEl){
27071 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27072 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27074 this.previewEl.setLeft(pw);
27075 this.previewEl.setTop(ph);
27079 onMouseDown : function(e)
27083 this.dragable = true;
27084 this.pinching = false;
27086 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27087 this.dragable = false;
27091 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27092 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27096 onMouseMove : function(e)
27100 if(!this.canvasLoaded){
27104 if (!this.dragable){
27108 var minX = Math.ceil(this.thumbEl.getLeft(true));
27109 var minY = Math.ceil(this.thumbEl.getTop(true));
27111 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27112 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27114 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27115 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27117 x = x - this.mouseX;
27118 y = y - this.mouseY;
27120 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27121 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27123 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27124 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27126 this.previewEl.setLeft(bgX);
27127 this.previewEl.setTop(bgY);
27129 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27130 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27133 onMouseUp : function(e)
27137 this.dragable = false;
27140 onMouseWheel : function(e)
27144 this.startScale = this.scale;
27146 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27148 if(!this.zoomable()){
27149 this.scale = this.startScale;
27158 zoomable : function()
27160 var minScale = this.thumbEl.getWidth() / this.minWidth;
27162 if(this.minWidth < this.minHeight){
27163 minScale = this.thumbEl.getHeight() / this.minHeight;
27166 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27167 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27171 (this.rotate == 0 || this.rotate == 180) &&
27173 width > this.imageEl.OriginWidth ||
27174 height > this.imageEl.OriginHeight ||
27175 (width < this.minWidth && height < this.minHeight)
27183 (this.rotate == 90 || this.rotate == 270) &&
27185 width > this.imageEl.OriginWidth ||
27186 height > this.imageEl.OriginHeight ||
27187 (width < this.minHeight && height < this.minWidth)
27194 !this.isDocument &&
27195 (this.rotate == 0 || this.rotate == 180) &&
27197 width < this.minWidth ||
27198 width > this.imageEl.OriginWidth ||
27199 height < this.minHeight ||
27200 height > this.imageEl.OriginHeight
27207 !this.isDocument &&
27208 (this.rotate == 90 || this.rotate == 270) &&
27210 width < this.minHeight ||
27211 width > this.imageEl.OriginWidth ||
27212 height < this.minWidth ||
27213 height > this.imageEl.OriginHeight
27223 onRotateLeft : function(e)
27225 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27227 var minScale = this.thumbEl.getWidth() / this.minWidth;
27229 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27230 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27232 this.startScale = this.scale;
27234 while (this.getScaleLevel() < minScale){
27236 this.scale = this.scale + 1;
27238 if(!this.zoomable()){
27243 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27244 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27249 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27256 this.scale = this.startScale;
27258 this.onRotateFail();
27263 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27265 if(this.isDocument){
27266 this.setThumbBoxSize();
27267 this.setThumbBoxPosition();
27268 this.setCanvasPosition();
27273 this.fireEvent('rotate', this, 'left');
27277 onRotateRight : function(e)
27279 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27281 var minScale = this.thumbEl.getWidth() / this.minWidth;
27283 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27284 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27286 this.startScale = this.scale;
27288 while (this.getScaleLevel() < minScale){
27290 this.scale = this.scale + 1;
27292 if(!this.zoomable()){
27297 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27298 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27303 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27310 this.scale = this.startScale;
27312 this.onRotateFail();
27317 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27319 if(this.isDocument){
27320 this.setThumbBoxSize();
27321 this.setThumbBoxPosition();
27322 this.setCanvasPosition();
27327 this.fireEvent('rotate', this, 'right');
27330 onRotateFail : function()
27332 this.errorEl.show(true);
27336 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27341 this.previewEl.dom.innerHTML = '';
27343 var canvasEl = document.createElement("canvas");
27345 var contextEl = canvasEl.getContext("2d");
27347 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27348 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27349 var center = this.imageEl.OriginWidth / 2;
27351 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27352 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27353 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27354 center = this.imageEl.OriginHeight / 2;
27357 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27359 contextEl.translate(center, center);
27360 contextEl.rotate(this.rotate * Math.PI / 180);
27362 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27364 this.canvasEl = document.createElement("canvas");
27366 this.contextEl = this.canvasEl.getContext("2d");
27368 switch (this.rotate) {
27371 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27372 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27374 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27379 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27380 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27382 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27383 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);
27387 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27392 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27393 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27395 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27396 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);
27400 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);
27405 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27406 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27408 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27409 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27413 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);
27420 this.previewEl.appendChild(this.canvasEl);
27422 this.setCanvasPosition();
27427 if(!this.canvasLoaded){
27431 var imageCanvas = document.createElement("canvas");
27433 var imageContext = imageCanvas.getContext("2d");
27435 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27436 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27438 var center = imageCanvas.width / 2;
27440 imageContext.translate(center, center);
27442 imageContext.rotate(this.rotate * Math.PI / 180);
27444 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27446 var canvas = document.createElement("canvas");
27448 var context = canvas.getContext("2d");
27450 canvas.width = this.minWidth;
27451 canvas.height = this.minHeight;
27453 switch (this.rotate) {
27456 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27457 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27459 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27460 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27462 var targetWidth = this.minWidth - 2 * x;
27463 var targetHeight = this.minHeight - 2 * y;
27467 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27468 scale = targetWidth / width;
27471 if(x > 0 && y == 0){
27472 scale = targetHeight / height;
27475 if(x > 0 && y > 0){
27476 scale = targetWidth / width;
27478 if(width < height){
27479 scale = targetHeight / height;
27483 context.scale(scale, scale);
27485 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27486 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27488 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27489 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27491 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27496 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27497 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27499 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27500 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27502 var targetWidth = this.minWidth - 2 * x;
27503 var targetHeight = this.minHeight - 2 * y;
27507 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27508 scale = targetWidth / width;
27511 if(x > 0 && y == 0){
27512 scale = targetHeight / height;
27515 if(x > 0 && y > 0){
27516 scale = targetWidth / width;
27518 if(width < height){
27519 scale = targetHeight / height;
27523 context.scale(scale, scale);
27525 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27526 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27528 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27529 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27531 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27533 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27538 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27539 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27541 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27542 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27544 var targetWidth = this.minWidth - 2 * x;
27545 var targetHeight = this.minHeight - 2 * y;
27549 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27550 scale = targetWidth / width;
27553 if(x > 0 && y == 0){
27554 scale = targetHeight / height;
27557 if(x > 0 && y > 0){
27558 scale = targetWidth / width;
27560 if(width < height){
27561 scale = targetHeight / height;
27565 context.scale(scale, scale);
27567 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27568 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27570 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27571 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27573 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27574 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27576 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27581 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27582 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27584 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27585 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27587 var targetWidth = this.minWidth - 2 * x;
27588 var targetHeight = this.minHeight - 2 * y;
27592 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27593 scale = targetWidth / width;
27596 if(x > 0 && y == 0){
27597 scale = targetHeight / height;
27600 if(x > 0 && y > 0){
27601 scale = targetWidth / width;
27603 if(width < height){
27604 scale = targetHeight / height;
27608 context.scale(scale, scale);
27610 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27611 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27613 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27614 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27616 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27618 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27625 this.cropData = canvas.toDataURL(this.cropType);
27627 if(this.fireEvent('crop', this, this.cropData) !== false){
27628 this.process(this.file, this.cropData);
27635 setThumbBoxSize : function()
27639 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27640 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27641 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27643 this.minWidth = width;
27644 this.minHeight = height;
27646 if(this.rotate == 90 || this.rotate == 270){
27647 this.minWidth = height;
27648 this.minHeight = width;
27653 width = Math.ceil(this.minWidth * height / this.minHeight);
27655 if(this.minWidth > this.minHeight){
27657 height = Math.ceil(this.minHeight * width / this.minWidth);
27660 this.thumbEl.setStyle({
27661 width : width + 'px',
27662 height : height + 'px'
27669 setThumbBoxPosition : function()
27671 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27672 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27674 this.thumbEl.setLeft(x);
27675 this.thumbEl.setTop(y);
27679 baseRotateLevel : function()
27681 this.baseRotate = 1;
27684 typeof(this.exif) != 'undefined' &&
27685 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27686 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27688 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27691 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27695 baseScaleLevel : function()
27699 if(this.isDocument){
27701 if(this.baseRotate == 6 || this.baseRotate == 8){
27703 height = this.thumbEl.getHeight();
27704 this.baseScale = height / this.imageEl.OriginWidth;
27706 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27707 width = this.thumbEl.getWidth();
27708 this.baseScale = width / this.imageEl.OriginHeight;
27714 height = this.thumbEl.getHeight();
27715 this.baseScale = height / this.imageEl.OriginHeight;
27717 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27718 width = this.thumbEl.getWidth();
27719 this.baseScale = width / this.imageEl.OriginWidth;
27725 if(this.baseRotate == 6 || this.baseRotate == 8){
27727 width = this.thumbEl.getHeight();
27728 this.baseScale = width / this.imageEl.OriginHeight;
27730 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27731 height = this.thumbEl.getWidth();
27732 this.baseScale = height / this.imageEl.OriginHeight;
27735 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27736 height = this.thumbEl.getWidth();
27737 this.baseScale = height / this.imageEl.OriginHeight;
27739 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27740 width = this.thumbEl.getHeight();
27741 this.baseScale = width / this.imageEl.OriginWidth;
27748 width = this.thumbEl.getWidth();
27749 this.baseScale = width / this.imageEl.OriginWidth;
27751 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27752 height = this.thumbEl.getHeight();
27753 this.baseScale = height / this.imageEl.OriginHeight;
27756 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27758 height = this.thumbEl.getHeight();
27759 this.baseScale = height / this.imageEl.OriginHeight;
27761 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27762 width = this.thumbEl.getWidth();
27763 this.baseScale = width / this.imageEl.OriginWidth;
27771 getScaleLevel : function()
27773 return this.baseScale * Math.pow(1.1, this.scale);
27776 onTouchStart : function(e)
27778 if(!this.canvasLoaded){
27779 this.beforeSelectFile(e);
27783 var touches = e.browserEvent.touches;
27789 if(touches.length == 1){
27790 this.onMouseDown(e);
27794 if(touches.length != 2){
27800 for(var i = 0, finger; finger = touches[i]; i++){
27801 coords.push(finger.pageX, finger.pageY);
27804 var x = Math.pow(coords[0] - coords[2], 2);
27805 var y = Math.pow(coords[1] - coords[3], 2);
27807 this.startDistance = Math.sqrt(x + y);
27809 this.startScale = this.scale;
27811 this.pinching = true;
27812 this.dragable = false;
27816 onTouchMove : function(e)
27818 if(!this.pinching && !this.dragable){
27822 var touches = e.browserEvent.touches;
27829 this.onMouseMove(e);
27835 for(var i = 0, finger; finger = touches[i]; i++){
27836 coords.push(finger.pageX, finger.pageY);
27839 var x = Math.pow(coords[0] - coords[2], 2);
27840 var y = Math.pow(coords[1] - coords[3], 2);
27842 this.endDistance = Math.sqrt(x + y);
27844 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27846 if(!this.zoomable()){
27847 this.scale = this.startScale;
27855 onTouchEnd : function(e)
27857 this.pinching = false;
27858 this.dragable = false;
27862 process : function(file, crop)
27865 this.maskEl.mask(this.loadingText);
27868 this.xhr = new XMLHttpRequest();
27870 file.xhr = this.xhr;
27872 this.xhr.open(this.method, this.url, true);
27875 "Accept": "application/json",
27876 "Cache-Control": "no-cache",
27877 "X-Requested-With": "XMLHttpRequest"
27880 for (var headerName in headers) {
27881 var headerValue = headers[headerName];
27883 this.xhr.setRequestHeader(headerName, headerValue);
27889 this.xhr.onload = function()
27891 _this.xhrOnLoad(_this.xhr);
27894 this.xhr.onerror = function()
27896 _this.xhrOnError(_this.xhr);
27899 var formData = new FormData();
27901 formData.append('returnHTML', 'NO');
27904 formData.append('crop', crop);
27907 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27908 formData.append(this.paramName, file, file.name);
27911 if(typeof(file.filename) != 'undefined'){
27912 formData.append('filename', file.filename);
27915 if(typeof(file.mimetype) != 'undefined'){
27916 formData.append('mimetype', file.mimetype);
27919 if(this.fireEvent('arrange', this, formData) != false){
27920 this.xhr.send(formData);
27924 xhrOnLoad : function(xhr)
27927 this.maskEl.unmask();
27930 if (xhr.readyState !== 4) {
27931 this.fireEvent('exception', this, xhr);
27935 var response = Roo.decode(xhr.responseText);
27937 if(!response.success){
27938 this.fireEvent('exception', this, xhr);
27942 var response = Roo.decode(xhr.responseText);
27944 this.fireEvent('upload', this, response);
27948 xhrOnError : function()
27951 this.maskEl.unmask();
27954 Roo.log('xhr on error');
27956 var response = Roo.decode(xhr.responseText);
27962 prepare : function(file)
27965 this.maskEl.mask(this.loadingText);
27971 if(typeof(file) === 'string'){
27972 this.loadCanvas(file);
27976 if(!file || !this.urlAPI){
27981 this.cropType = file.type;
27985 if(this.fireEvent('prepare', this, this.file) != false){
27987 var reader = new FileReader();
27989 reader.onload = function (e) {
27990 if (e.target.error) {
27991 Roo.log(e.target.error);
27995 var buffer = e.target.result,
27996 dataView = new DataView(buffer),
27998 maxOffset = dataView.byteLength - 4,
28002 if (dataView.getUint16(0) === 0xffd8) {
28003 while (offset < maxOffset) {
28004 markerBytes = dataView.getUint16(offset);
28006 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28007 markerLength = dataView.getUint16(offset + 2) + 2;
28008 if (offset + markerLength > dataView.byteLength) {
28009 Roo.log('Invalid meta data: Invalid segment size.');
28013 if(markerBytes == 0xffe1){
28014 _this.parseExifData(
28021 offset += markerLength;
28031 var url = _this.urlAPI.createObjectURL(_this.file);
28033 _this.loadCanvas(url);
28038 reader.readAsArrayBuffer(this.file);
28044 parseExifData : function(dataView, offset, length)
28046 var tiffOffset = offset + 10,
28050 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28051 // No Exif data, might be XMP data instead
28055 // Check for the ASCII code for "Exif" (0x45786966):
28056 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28057 // No Exif data, might be XMP data instead
28060 if (tiffOffset + 8 > dataView.byteLength) {
28061 Roo.log('Invalid Exif data: Invalid segment size.');
28064 // Check for the two null bytes:
28065 if (dataView.getUint16(offset + 8) !== 0x0000) {
28066 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28069 // Check the byte alignment:
28070 switch (dataView.getUint16(tiffOffset)) {
28072 littleEndian = true;
28075 littleEndian = false;
28078 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28081 // Check for the TIFF tag marker (0x002A):
28082 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28083 Roo.log('Invalid Exif data: Missing TIFF marker.');
28086 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28087 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28089 this.parseExifTags(
28092 tiffOffset + dirOffset,
28097 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28102 if (dirOffset + 6 > dataView.byteLength) {
28103 Roo.log('Invalid Exif data: Invalid directory offset.');
28106 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28107 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28108 if (dirEndOffset + 4 > dataView.byteLength) {
28109 Roo.log('Invalid Exif data: Invalid directory size.');
28112 for (i = 0; i < tagsNumber; i += 1) {
28116 dirOffset + 2 + 12 * i, // tag offset
28120 // Return the offset to the next directory:
28121 return dataView.getUint32(dirEndOffset, littleEndian);
28124 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28126 var tag = dataView.getUint16(offset, littleEndian);
28128 this.exif[tag] = this.getExifValue(
28132 dataView.getUint16(offset + 2, littleEndian), // tag type
28133 dataView.getUint32(offset + 4, littleEndian), // tag length
28138 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28140 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28149 Roo.log('Invalid Exif data: Invalid tag type.');
28153 tagSize = tagType.size * length;
28154 // Determine if the value is contained in the dataOffset bytes,
28155 // or if the value at the dataOffset is a pointer to the actual data:
28156 dataOffset = tagSize > 4 ?
28157 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28158 if (dataOffset + tagSize > dataView.byteLength) {
28159 Roo.log('Invalid Exif data: Invalid data offset.');
28162 if (length === 1) {
28163 return tagType.getValue(dataView, dataOffset, littleEndian);
28166 for (i = 0; i < length; i += 1) {
28167 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28170 if (tagType.ascii) {
28172 // Concatenate the chars:
28173 for (i = 0; i < values.length; i += 1) {
28175 // Ignore the terminating NULL byte(s):
28176 if (c === '\u0000') {
28188 Roo.apply(Roo.bootstrap.UploadCropbox, {
28190 'Orientation': 0x0112
28194 1: 0, //'top-left',
28196 3: 180, //'bottom-right',
28197 // 4: 'bottom-left',
28199 6: 90, //'right-top',
28200 // 7: 'right-bottom',
28201 8: 270 //'left-bottom'
28205 // byte, 8-bit unsigned int:
28207 getValue: function (dataView, dataOffset) {
28208 return dataView.getUint8(dataOffset);
28212 // ascii, 8-bit byte:
28214 getValue: function (dataView, dataOffset) {
28215 return String.fromCharCode(dataView.getUint8(dataOffset));
28220 // short, 16 bit int:
28222 getValue: function (dataView, dataOffset, littleEndian) {
28223 return dataView.getUint16(dataOffset, littleEndian);
28227 // long, 32 bit int:
28229 getValue: function (dataView, dataOffset, littleEndian) {
28230 return dataView.getUint32(dataOffset, littleEndian);
28234 // rational = two long values, first is numerator, second is denominator:
28236 getValue: function (dataView, dataOffset, littleEndian) {
28237 return dataView.getUint32(dataOffset, littleEndian) /
28238 dataView.getUint32(dataOffset + 4, littleEndian);
28242 // slong, 32 bit signed int:
28244 getValue: function (dataView, dataOffset, littleEndian) {
28245 return dataView.getInt32(dataOffset, littleEndian);
28249 // srational, two slongs, first is numerator, second is denominator:
28251 getValue: function (dataView, dataOffset, littleEndian) {
28252 return dataView.getInt32(dataOffset, littleEndian) /
28253 dataView.getInt32(dataOffset + 4, littleEndian);
28263 cls : 'btn-group roo-upload-cropbox-rotate-left',
28264 action : 'rotate-left',
28268 cls : 'btn btn-default',
28269 html : '<i class="fa fa-undo"></i>'
28275 cls : 'btn-group roo-upload-cropbox-picture',
28276 action : 'picture',
28280 cls : 'btn btn-default',
28281 html : '<i class="fa fa-picture-o"></i>'
28287 cls : 'btn-group roo-upload-cropbox-rotate-right',
28288 action : 'rotate-right',
28292 cls : 'btn btn-default',
28293 html : '<i class="fa fa-repeat"></i>'
28301 cls : 'btn-group roo-upload-cropbox-rotate-left',
28302 action : 'rotate-left',
28306 cls : 'btn btn-default',
28307 html : '<i class="fa fa-undo"></i>'
28313 cls : 'btn-group roo-upload-cropbox-download',
28314 action : 'download',
28318 cls : 'btn btn-default',
28319 html : '<i class="fa fa-download"></i>'
28325 cls : 'btn-group roo-upload-cropbox-crop',
28330 cls : 'btn btn-default',
28331 html : '<i class="fa fa-crop"></i>'
28337 cls : 'btn-group roo-upload-cropbox-trash',
28342 cls : 'btn btn-default',
28343 html : '<i class="fa fa-trash"></i>'
28349 cls : 'btn-group roo-upload-cropbox-rotate-right',
28350 action : 'rotate-right',
28354 cls : 'btn btn-default',
28355 html : '<i class="fa fa-repeat"></i>'
28363 cls : 'btn-group roo-upload-cropbox-rotate-left',
28364 action : 'rotate-left',
28368 cls : 'btn btn-default',
28369 html : '<i class="fa fa-undo"></i>'
28375 cls : 'btn-group roo-upload-cropbox-rotate-right',
28376 action : 'rotate-right',
28380 cls : 'btn btn-default',
28381 html : '<i class="fa fa-repeat"></i>'
28394 * @class Roo.bootstrap.DocumentManager
28395 * @extends Roo.bootstrap.Component
28396 * Bootstrap DocumentManager class
28397 * @cfg {String} paramName default 'imageUpload'
28398 * @cfg {String} toolTipName default 'filename'
28399 * @cfg {String} method default POST
28400 * @cfg {String} url action url
28401 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28402 * @cfg {Boolean} multiple multiple upload default true
28403 * @cfg {Number} thumbSize default 300
28404 * @cfg {String} fieldLabel
28405 * @cfg {Number} labelWidth default 4
28406 * @cfg {String} labelAlign (left|top) default left
28407 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28408 * @cfg {Number} labellg set the width of label (1-12)
28409 * @cfg {Number} labelmd set the width of label (1-12)
28410 * @cfg {Number} labelsm set the width of label (1-12)
28411 * @cfg {Number} labelxs set the width of label (1-12)
28414 * Create a new DocumentManager
28415 * @param {Object} config The config object
28418 Roo.bootstrap.DocumentManager = function(config){
28419 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28422 this.delegates = [];
28427 * Fire when initial the DocumentManager
28428 * @param {Roo.bootstrap.DocumentManager} this
28433 * inspect selected file
28434 * @param {Roo.bootstrap.DocumentManager} this
28435 * @param {File} file
28440 * Fire when xhr load exception
28441 * @param {Roo.bootstrap.DocumentManager} this
28442 * @param {XMLHttpRequest} xhr
28444 "exception" : true,
28446 * @event afterupload
28447 * Fire when xhr load exception
28448 * @param {Roo.bootstrap.DocumentManager} this
28449 * @param {XMLHttpRequest} xhr
28451 "afterupload" : true,
28454 * prepare the form data
28455 * @param {Roo.bootstrap.DocumentManager} this
28456 * @param {Object} formData
28461 * Fire when remove the file
28462 * @param {Roo.bootstrap.DocumentManager} this
28463 * @param {Object} file
28468 * Fire after refresh the file
28469 * @param {Roo.bootstrap.DocumentManager} this
28474 * Fire after click the image
28475 * @param {Roo.bootstrap.DocumentManager} this
28476 * @param {Object} file
28481 * Fire when upload a image and editable set to true
28482 * @param {Roo.bootstrap.DocumentManager} this
28483 * @param {Object} file
28487 * @event beforeselectfile
28488 * Fire before select file
28489 * @param {Roo.bootstrap.DocumentManager} this
28491 "beforeselectfile" : true,
28494 * Fire before process file
28495 * @param {Roo.bootstrap.DocumentManager} this
28496 * @param {Object} file
28500 * @event previewrendered
28501 * Fire when preview rendered
28502 * @param {Roo.bootstrap.DocumentManager} this
28503 * @param {Object} file
28505 "previewrendered" : true
28510 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28519 paramName : 'imageUpload',
28520 toolTipName : 'filename',
28523 labelAlign : 'left',
28533 getAutoCreate : function()
28535 var managerWidget = {
28537 cls : 'roo-document-manager',
28541 cls : 'roo-document-manager-selector',
28546 cls : 'roo-document-manager-uploader',
28550 cls : 'roo-document-manager-upload-btn',
28551 html : '<i class="fa fa-plus"></i>'
28562 cls : 'column col-md-12',
28567 if(this.fieldLabel.length){
28572 cls : 'column col-md-12',
28573 html : this.fieldLabel
28577 cls : 'column col-md-12',
28582 if(this.labelAlign == 'left'){
28587 html : this.fieldLabel
28596 if(this.labelWidth > 12){
28597 content[0].style = "width: " + this.labelWidth + 'px';
28600 if(this.labelWidth < 13 && this.labelmd == 0){
28601 this.labelmd = this.labelWidth;
28604 if(this.labellg > 0){
28605 content[0].cls += ' col-lg-' + this.labellg;
28606 content[1].cls += ' col-lg-' + (12 - this.labellg);
28609 if(this.labelmd > 0){
28610 content[0].cls += ' col-md-' + this.labelmd;
28611 content[1].cls += ' col-md-' + (12 - this.labelmd);
28614 if(this.labelsm > 0){
28615 content[0].cls += ' col-sm-' + this.labelsm;
28616 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28619 if(this.labelxs > 0){
28620 content[0].cls += ' col-xs-' + this.labelxs;
28621 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28629 cls : 'row clearfix',
28637 initEvents : function()
28639 this.managerEl = this.el.select('.roo-document-manager', true).first();
28640 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28642 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28643 this.selectorEl.hide();
28646 this.selectorEl.attr('multiple', 'multiple');
28649 this.selectorEl.on('change', this.onFileSelected, this);
28651 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28652 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28654 this.uploader.on('click', this.onUploaderClick, this);
28656 this.renderProgressDialog();
28660 window.addEventListener("resize", function() { _this.refresh(); } );
28662 this.fireEvent('initial', this);
28665 renderProgressDialog : function()
28669 this.progressDialog = new Roo.bootstrap.Modal({
28670 cls : 'roo-document-manager-progress-dialog',
28671 allow_close : false,
28681 btnclick : function() {
28682 _this.uploadCancel();
28688 this.progressDialog.render(Roo.get(document.body));
28690 this.progress = new Roo.bootstrap.Progress({
28691 cls : 'roo-document-manager-progress',
28696 this.progress.render(this.progressDialog.getChildContainer());
28698 this.progressBar = new Roo.bootstrap.ProgressBar({
28699 cls : 'roo-document-manager-progress-bar',
28702 aria_valuemax : 12,
28706 this.progressBar.render(this.progress.getChildContainer());
28709 onUploaderClick : function(e)
28711 e.preventDefault();
28713 if(this.fireEvent('beforeselectfile', this) != false){
28714 this.selectorEl.dom.click();
28719 onFileSelected : function(e)
28721 e.preventDefault();
28723 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28727 Roo.each(this.selectorEl.dom.files, function(file){
28728 if(this.fireEvent('inspect', this, file) != false){
28729 this.files.push(file);
28739 this.selectorEl.dom.value = '';
28741 if(!this.files || !this.files.length){
28745 if(this.boxes > 0 && this.files.length > this.boxes){
28746 this.files = this.files.slice(0, this.boxes);
28749 this.uploader.show();
28751 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28752 this.uploader.hide();
28761 Roo.each(this.files, function(file){
28763 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28764 var f = this.renderPreview(file);
28769 if(file.type.indexOf('image') != -1){
28770 this.delegates.push(
28772 _this.process(file);
28773 }).createDelegate(this)
28781 _this.process(file);
28782 }).createDelegate(this)
28787 this.files = files;
28789 this.delegates = this.delegates.concat(docs);
28791 if(!this.delegates.length){
28796 this.progressBar.aria_valuemax = this.delegates.length;
28803 arrange : function()
28805 if(!this.delegates.length){
28806 this.progressDialog.hide();
28811 var delegate = this.delegates.shift();
28813 this.progressDialog.show();
28815 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28817 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28822 refresh : function()
28824 this.uploader.show();
28826 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28827 this.uploader.hide();
28830 Roo.isTouch ? this.closable(false) : this.closable(true);
28832 this.fireEvent('refresh', this);
28835 onRemove : function(e, el, o)
28837 e.preventDefault();
28839 this.fireEvent('remove', this, o);
28843 remove : function(o)
28847 Roo.each(this.files, function(file){
28848 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28857 this.files = files;
28864 Roo.each(this.files, function(file){
28869 file.target.remove();
28878 onClick : function(e, el, o)
28880 e.preventDefault();
28882 this.fireEvent('click', this, o);
28886 closable : function(closable)
28888 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28890 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28902 xhrOnLoad : function(xhr)
28904 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28908 if (xhr.readyState !== 4) {
28910 this.fireEvent('exception', this, xhr);
28914 var response = Roo.decode(xhr.responseText);
28916 if(!response.success){
28918 this.fireEvent('exception', this, xhr);
28922 var file = this.renderPreview(response.data);
28924 this.files.push(file);
28928 this.fireEvent('afterupload', this, xhr);
28932 xhrOnError : function(xhr)
28934 Roo.log('xhr on error');
28936 var response = Roo.decode(xhr.responseText);
28943 process : function(file)
28945 if(this.fireEvent('process', this, file) !== false){
28946 if(this.editable && file.type.indexOf('image') != -1){
28947 this.fireEvent('edit', this, file);
28951 this.uploadStart(file, false);
28958 uploadStart : function(file, crop)
28960 this.xhr = new XMLHttpRequest();
28962 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28967 file.xhr = this.xhr;
28969 this.managerEl.createChild({
28971 cls : 'roo-document-manager-loading',
28975 tooltip : file.name,
28976 cls : 'roo-document-manager-thumb',
28977 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28983 this.xhr.open(this.method, this.url, true);
28986 "Accept": "application/json",
28987 "Cache-Control": "no-cache",
28988 "X-Requested-With": "XMLHttpRequest"
28991 for (var headerName in headers) {
28992 var headerValue = headers[headerName];
28994 this.xhr.setRequestHeader(headerName, headerValue);
29000 this.xhr.onload = function()
29002 _this.xhrOnLoad(_this.xhr);
29005 this.xhr.onerror = function()
29007 _this.xhrOnError(_this.xhr);
29010 var formData = new FormData();
29012 formData.append('returnHTML', 'NO');
29015 formData.append('crop', crop);
29018 formData.append(this.paramName, file, file.name);
29025 if(this.fireEvent('prepare', this, formData, options) != false){
29027 if(options.manually){
29031 this.xhr.send(formData);
29035 this.uploadCancel();
29038 uploadCancel : function()
29044 this.delegates = [];
29046 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29053 renderPreview : function(file)
29055 if(typeof(file.target) != 'undefined' && file.target){
29059 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29061 var previewEl = this.managerEl.createChild({
29063 cls : 'roo-document-manager-preview',
29067 tooltip : file[this.toolTipName],
29068 cls : 'roo-document-manager-thumb',
29069 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29074 html : '<i class="fa fa-times-circle"></i>'
29079 var close = previewEl.select('button.close', true).first();
29081 close.on('click', this.onRemove, this, file);
29083 file.target = previewEl;
29085 var image = previewEl.select('img', true).first();
29089 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29091 image.on('click', this.onClick, this, file);
29093 this.fireEvent('previewrendered', this, file);
29099 onPreviewLoad : function(file, image)
29101 if(typeof(file.target) == 'undefined' || !file.target){
29105 var width = image.dom.naturalWidth || image.dom.width;
29106 var height = image.dom.naturalHeight || image.dom.height;
29108 if(width > height){
29109 file.target.addClass('wide');
29113 file.target.addClass('tall');
29118 uploadFromSource : function(file, crop)
29120 this.xhr = new XMLHttpRequest();
29122 this.managerEl.createChild({
29124 cls : 'roo-document-manager-loading',
29128 tooltip : file.name,
29129 cls : 'roo-document-manager-thumb',
29130 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29136 this.xhr.open(this.method, this.url, true);
29139 "Accept": "application/json",
29140 "Cache-Control": "no-cache",
29141 "X-Requested-With": "XMLHttpRequest"
29144 for (var headerName in headers) {
29145 var headerValue = headers[headerName];
29147 this.xhr.setRequestHeader(headerName, headerValue);
29153 this.xhr.onload = function()
29155 _this.xhrOnLoad(_this.xhr);
29158 this.xhr.onerror = function()
29160 _this.xhrOnError(_this.xhr);
29163 var formData = new FormData();
29165 formData.append('returnHTML', 'NO');
29167 formData.append('crop', crop);
29169 if(typeof(file.filename) != 'undefined'){
29170 formData.append('filename', file.filename);
29173 if(typeof(file.mimetype) != 'undefined'){
29174 formData.append('mimetype', file.mimetype);
29179 if(this.fireEvent('prepare', this, formData) != false){
29180 this.xhr.send(formData);
29190 * @class Roo.bootstrap.DocumentViewer
29191 * @extends Roo.bootstrap.Component
29192 * Bootstrap DocumentViewer class
29193 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29194 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29197 * Create a new DocumentViewer
29198 * @param {Object} config The config object
29201 Roo.bootstrap.DocumentViewer = function(config){
29202 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29207 * Fire after initEvent
29208 * @param {Roo.bootstrap.DocumentViewer} this
29214 * @param {Roo.bootstrap.DocumentViewer} this
29219 * Fire after download button
29220 * @param {Roo.bootstrap.DocumentViewer} this
29225 * Fire after trash button
29226 * @param {Roo.bootstrap.DocumentViewer} this
29233 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29235 showDownload : true,
29239 getAutoCreate : function()
29243 cls : 'roo-document-viewer',
29247 cls : 'roo-document-viewer-body',
29251 cls : 'roo-document-viewer-thumb',
29255 cls : 'roo-document-viewer-image'
29263 cls : 'roo-document-viewer-footer',
29266 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29270 cls : 'btn-group roo-document-viewer-download',
29274 cls : 'btn btn-default',
29275 html : '<i class="fa fa-download"></i>'
29281 cls : 'btn-group roo-document-viewer-trash',
29285 cls : 'btn btn-default',
29286 html : '<i class="fa fa-trash"></i>'
29299 initEvents : function()
29301 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29302 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29304 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29305 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29307 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29308 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29310 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29311 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29313 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29314 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29316 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29317 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29319 this.bodyEl.on('click', this.onClick, this);
29320 this.downloadBtn.on('click', this.onDownload, this);
29321 this.trashBtn.on('click', this.onTrash, this);
29323 this.downloadBtn.hide();
29324 this.trashBtn.hide();
29326 if(this.showDownload){
29327 this.downloadBtn.show();
29330 if(this.showTrash){
29331 this.trashBtn.show();
29334 if(!this.showDownload && !this.showTrash) {
29335 this.footerEl.hide();
29340 initial : function()
29342 this.fireEvent('initial', this);
29346 onClick : function(e)
29348 e.preventDefault();
29350 this.fireEvent('click', this);
29353 onDownload : function(e)
29355 e.preventDefault();
29357 this.fireEvent('download', this);
29360 onTrash : function(e)
29362 e.preventDefault();
29364 this.fireEvent('trash', this);
29376 * @class Roo.bootstrap.NavProgressBar
29377 * @extends Roo.bootstrap.Component
29378 * Bootstrap NavProgressBar class
29381 * Create a new nav progress bar
29382 * @param {Object} config The config object
29385 Roo.bootstrap.NavProgressBar = function(config){
29386 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29388 this.bullets = this.bullets || [];
29390 // Roo.bootstrap.NavProgressBar.register(this);
29394 * Fires when the active item changes
29395 * @param {Roo.bootstrap.NavProgressBar} this
29396 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29397 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29404 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29409 getAutoCreate : function()
29411 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29415 cls : 'roo-navigation-bar-group',
29419 cls : 'roo-navigation-top-bar'
29423 cls : 'roo-navigation-bullets-bar',
29427 cls : 'roo-navigation-bar'
29434 cls : 'roo-navigation-bottom-bar'
29444 initEvents: function()
29449 onRender : function(ct, position)
29451 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29453 if(this.bullets.length){
29454 Roo.each(this.bullets, function(b){
29463 addItem : function(cfg)
29465 var item = new Roo.bootstrap.NavProgressItem(cfg);
29467 item.parentId = this.id;
29468 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29471 var top = new Roo.bootstrap.Element({
29473 cls : 'roo-navigation-bar-text'
29476 var bottom = new Roo.bootstrap.Element({
29478 cls : 'roo-navigation-bar-text'
29481 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29482 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29484 var topText = new Roo.bootstrap.Element({
29486 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29489 var bottomText = new Roo.bootstrap.Element({
29491 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29494 topText.onRender(top.el, null);
29495 bottomText.onRender(bottom.el, null);
29498 item.bottomEl = bottom;
29501 this.barItems.push(item);
29506 getActive : function()
29508 var active = false;
29510 Roo.each(this.barItems, function(v){
29512 if (!v.isActive()) {
29524 setActiveItem : function(item)
29528 Roo.each(this.barItems, function(v){
29529 if (v.rid == item.rid) {
29533 if (v.isActive()) {
29534 v.setActive(false);
29539 item.setActive(true);
29541 this.fireEvent('changed', this, item, prev);
29544 getBarItem: function(rid)
29548 Roo.each(this.barItems, function(e) {
29549 if (e.rid != rid) {
29560 indexOfItem : function(item)
29564 Roo.each(this.barItems, function(v, i){
29566 if (v.rid != item.rid) {
29577 setActiveNext : function()
29579 var i = this.indexOfItem(this.getActive());
29581 if (i > this.barItems.length) {
29585 this.setActiveItem(this.barItems[i+1]);
29588 setActivePrev : function()
29590 var i = this.indexOfItem(this.getActive());
29596 this.setActiveItem(this.barItems[i-1]);
29599 format : function()
29601 if(!this.barItems.length){
29605 var width = 100 / this.barItems.length;
29607 Roo.each(this.barItems, function(i){
29608 i.el.setStyle('width', width + '%');
29609 i.topEl.el.setStyle('width', width + '%');
29610 i.bottomEl.el.setStyle('width', width + '%');
29619 * Nav Progress Item
29624 * @class Roo.bootstrap.NavProgressItem
29625 * @extends Roo.bootstrap.Component
29626 * Bootstrap NavProgressItem class
29627 * @cfg {String} rid the reference id
29628 * @cfg {Boolean} active (true|false) Is item active default false
29629 * @cfg {Boolean} disabled (true|false) Is item active default false
29630 * @cfg {String} html
29631 * @cfg {String} position (top|bottom) text position default bottom
29632 * @cfg {String} icon show icon instead of number
29635 * Create a new NavProgressItem
29636 * @param {Object} config The config object
29638 Roo.bootstrap.NavProgressItem = function(config){
29639 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29644 * The raw click event for the entire grid.
29645 * @param {Roo.bootstrap.NavProgressItem} this
29646 * @param {Roo.EventObject} e
29653 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29659 position : 'bottom',
29662 getAutoCreate : function()
29664 var iconCls = 'roo-navigation-bar-item-icon';
29666 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29670 cls: 'roo-navigation-bar-item',
29680 cfg.cls += ' active';
29683 cfg.cls += ' disabled';
29689 disable : function()
29691 this.setDisabled(true);
29694 enable : function()
29696 this.setDisabled(false);
29699 initEvents: function()
29701 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29703 this.iconEl.on('click', this.onClick, this);
29706 onClick : function(e)
29708 e.preventDefault();
29714 if(this.fireEvent('click', this, e) === false){
29718 this.parent().setActiveItem(this);
29721 isActive: function ()
29723 return this.active;
29726 setActive : function(state)
29728 if(this.active == state){
29732 this.active = state;
29735 this.el.addClass('active');
29739 this.el.removeClass('active');
29744 setDisabled : function(state)
29746 if(this.disabled == state){
29750 this.disabled = state;
29753 this.el.addClass('disabled');
29757 this.el.removeClass('disabled');
29760 tooltipEl : function()
29762 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29775 * @class Roo.bootstrap.FieldLabel
29776 * @extends Roo.bootstrap.Component
29777 * Bootstrap FieldLabel class
29778 * @cfg {String} html contents of the element
29779 * @cfg {String} tag tag of the element default label
29780 * @cfg {String} cls class of the element
29781 * @cfg {String} target label target
29782 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29783 * @cfg {String} invalidClass default "text-warning"
29784 * @cfg {String} validClass default "text-success"
29785 * @cfg {String} iconTooltip default "This field is required"
29786 * @cfg {String} indicatorpos (left|right) default left
29789 * Create a new FieldLabel
29790 * @param {Object} config The config object
29793 Roo.bootstrap.FieldLabel = function(config){
29794 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29799 * Fires after the field has been marked as invalid.
29800 * @param {Roo.form.FieldLabel} this
29801 * @param {String} msg The validation message
29806 * Fires after the field has been validated with no errors.
29807 * @param {Roo.form.FieldLabel} this
29813 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29820 invalidClass : 'has-warning',
29821 validClass : 'has-success',
29822 iconTooltip : 'This field is required',
29823 indicatorpos : 'left',
29825 getAutoCreate : function(){
29829 cls : 'roo-bootstrap-field-label ' + this.cls,
29834 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29835 tooltip : this.iconTooltip
29844 if(this.indicatorpos == 'right'){
29847 cls : 'roo-bootstrap-field-label ' + this.cls,
29856 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29857 tooltip : this.iconTooltip
29866 initEvents: function()
29868 Roo.bootstrap.Element.superclass.initEvents.call(this);
29870 this.indicator = this.indicatorEl();
29872 if(this.indicator){
29873 this.indicator.removeClass('visible');
29874 this.indicator.addClass('invisible');
29877 Roo.bootstrap.FieldLabel.register(this);
29880 indicatorEl : function()
29882 var indicator = this.el.select('i.roo-required-indicator',true).first();
29893 * Mark this field as valid
29895 markValid : function()
29897 if(this.indicator){
29898 this.indicator.removeClass('visible');
29899 this.indicator.addClass('invisible');
29902 this.el.removeClass(this.invalidClass);
29904 this.el.addClass(this.validClass);
29906 this.fireEvent('valid', this);
29910 * Mark this field as invalid
29911 * @param {String} msg The validation message
29913 markInvalid : function(msg)
29915 if(this.indicator){
29916 this.indicator.removeClass('invisible');
29917 this.indicator.addClass('visible');
29920 this.el.removeClass(this.validClass);
29922 this.el.addClass(this.invalidClass);
29924 this.fireEvent('invalid', this, msg);
29930 Roo.apply(Roo.bootstrap.FieldLabel, {
29935 * register a FieldLabel Group
29936 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29938 register : function(label)
29940 if(this.groups.hasOwnProperty(label.target)){
29944 this.groups[label.target] = label;
29948 * fetch a FieldLabel Group based on the target
29949 * @param {string} target
29950 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29952 get: function(target) {
29953 if (typeof(this.groups[target]) == 'undefined') {
29957 return this.groups[target] ;
29966 * page DateSplitField.
29972 * @class Roo.bootstrap.DateSplitField
29973 * @extends Roo.bootstrap.Component
29974 * Bootstrap DateSplitField class
29975 * @cfg {string} fieldLabel - the label associated
29976 * @cfg {Number} labelWidth set the width of label (0-12)
29977 * @cfg {String} labelAlign (top|left)
29978 * @cfg {Boolean} dayAllowBlank (true|false) default false
29979 * @cfg {Boolean} monthAllowBlank (true|false) default false
29980 * @cfg {Boolean} yearAllowBlank (true|false) default false
29981 * @cfg {string} dayPlaceholder
29982 * @cfg {string} monthPlaceholder
29983 * @cfg {string} yearPlaceholder
29984 * @cfg {string} dayFormat default 'd'
29985 * @cfg {string} monthFormat default 'm'
29986 * @cfg {string} yearFormat default 'Y'
29987 * @cfg {Number} labellg set the width of label (1-12)
29988 * @cfg {Number} labelmd set the width of label (1-12)
29989 * @cfg {Number} labelsm set the width of label (1-12)
29990 * @cfg {Number} labelxs set the width of label (1-12)
29994 * Create a new DateSplitField
29995 * @param {Object} config The config object
29998 Roo.bootstrap.DateSplitField = function(config){
29999 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30005 * getting the data of years
30006 * @param {Roo.bootstrap.DateSplitField} this
30007 * @param {Object} years
30012 * getting the data of days
30013 * @param {Roo.bootstrap.DateSplitField} this
30014 * @param {Object} days
30019 * Fires after the field has been marked as invalid.
30020 * @param {Roo.form.Field} this
30021 * @param {String} msg The validation message
30026 * Fires after the field has been validated with no errors.
30027 * @param {Roo.form.Field} this
30033 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30036 labelAlign : 'top',
30038 dayAllowBlank : false,
30039 monthAllowBlank : false,
30040 yearAllowBlank : false,
30041 dayPlaceholder : '',
30042 monthPlaceholder : '',
30043 yearPlaceholder : '',
30047 isFormField : true,
30053 getAutoCreate : function()
30057 cls : 'row roo-date-split-field-group',
30062 cls : 'form-hidden-field roo-date-split-field-group-value',
30068 var labelCls = 'col-md-12';
30069 var contentCls = 'col-md-4';
30071 if(this.fieldLabel){
30075 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30079 html : this.fieldLabel
30084 if(this.labelAlign == 'left'){
30086 if(this.labelWidth > 12){
30087 label.style = "width: " + this.labelWidth + 'px';
30090 if(this.labelWidth < 13 && this.labelmd == 0){
30091 this.labelmd = this.labelWidth;
30094 if(this.labellg > 0){
30095 labelCls = ' col-lg-' + this.labellg;
30096 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30099 if(this.labelmd > 0){
30100 labelCls = ' col-md-' + this.labelmd;
30101 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30104 if(this.labelsm > 0){
30105 labelCls = ' col-sm-' + this.labelsm;
30106 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30109 if(this.labelxs > 0){
30110 labelCls = ' col-xs-' + this.labelxs;
30111 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30115 label.cls += ' ' + labelCls;
30117 cfg.cn.push(label);
30120 Roo.each(['day', 'month', 'year'], function(t){
30123 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30130 inputEl: function ()
30132 return this.el.select('.roo-date-split-field-group-value', true).first();
30135 onRender : function(ct, position)
30139 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30141 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30143 this.dayField = new Roo.bootstrap.ComboBox({
30144 allowBlank : this.dayAllowBlank,
30145 alwaysQuery : true,
30146 displayField : 'value',
30149 forceSelection : true,
30151 placeholder : this.dayPlaceholder,
30152 selectOnFocus : true,
30153 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30154 triggerAction : 'all',
30156 valueField : 'value',
30157 store : new Roo.data.SimpleStore({
30158 data : (function() {
30160 _this.fireEvent('days', _this, days);
30163 fields : [ 'value' ]
30166 select : function (_self, record, index)
30168 _this.setValue(_this.getValue());
30173 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30175 this.monthField = new Roo.bootstrap.MonthField({
30176 after : '<i class=\"fa fa-calendar\"></i>',
30177 allowBlank : this.monthAllowBlank,
30178 placeholder : this.monthPlaceholder,
30181 render : function (_self)
30183 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30184 e.preventDefault();
30188 select : function (_self, oldvalue, newvalue)
30190 _this.setValue(_this.getValue());
30195 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30197 this.yearField = new Roo.bootstrap.ComboBox({
30198 allowBlank : this.yearAllowBlank,
30199 alwaysQuery : true,
30200 displayField : 'value',
30203 forceSelection : true,
30205 placeholder : this.yearPlaceholder,
30206 selectOnFocus : true,
30207 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30208 triggerAction : 'all',
30210 valueField : 'value',
30211 store : new Roo.data.SimpleStore({
30212 data : (function() {
30214 _this.fireEvent('years', _this, years);
30217 fields : [ 'value' ]
30220 select : function (_self, record, index)
30222 _this.setValue(_this.getValue());
30227 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30230 setValue : function(v, format)
30232 this.inputEl.dom.value = v;
30234 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30236 var d = Date.parseDate(v, f);
30243 this.setDay(d.format(this.dayFormat));
30244 this.setMonth(d.format(this.monthFormat));
30245 this.setYear(d.format(this.yearFormat));
30252 setDay : function(v)
30254 this.dayField.setValue(v);
30255 this.inputEl.dom.value = this.getValue();
30260 setMonth : function(v)
30262 this.monthField.setValue(v, true);
30263 this.inputEl.dom.value = this.getValue();
30268 setYear : function(v)
30270 this.yearField.setValue(v);
30271 this.inputEl.dom.value = this.getValue();
30276 getDay : function()
30278 return this.dayField.getValue();
30281 getMonth : function()
30283 return this.monthField.getValue();
30286 getYear : function()
30288 return this.yearField.getValue();
30291 getValue : function()
30293 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30295 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30305 this.inputEl.dom.value = '';
30310 validate : function()
30312 var d = this.dayField.validate();
30313 var m = this.monthField.validate();
30314 var y = this.yearField.validate();
30319 (!this.dayAllowBlank && !d) ||
30320 (!this.monthAllowBlank && !m) ||
30321 (!this.yearAllowBlank && !y)
30326 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30335 this.markInvalid();
30340 markValid : function()
30343 var label = this.el.select('label', true).first();
30344 var icon = this.el.select('i.fa-star', true).first();
30350 this.fireEvent('valid', this);
30354 * Mark this field as invalid
30355 * @param {String} msg The validation message
30357 markInvalid : function(msg)
30360 var label = this.el.select('label', true).first();
30361 var icon = this.el.select('i.fa-star', true).first();
30363 if(label && !icon){
30364 this.el.select('.roo-date-split-field-label', true).createChild({
30366 cls : 'text-danger fa fa-lg fa-star',
30367 tooltip : 'This field is required',
30368 style : 'margin-right:5px;'
30372 this.fireEvent('invalid', this, msg);
30375 clearInvalid : function()
30377 var label = this.el.select('label', true).first();
30378 var icon = this.el.select('i.fa-star', true).first();
30384 this.fireEvent('valid', this);
30387 getName: function()
30397 * http://masonry.desandro.com
30399 * The idea is to render all the bricks based on vertical width...
30401 * The original code extends 'outlayer' - we might need to use that....
30407 * @class Roo.bootstrap.LayoutMasonry
30408 * @extends Roo.bootstrap.Component
30409 * Bootstrap Layout Masonry class
30412 * Create a new Element
30413 * @param {Object} config The config object
30416 Roo.bootstrap.LayoutMasonry = function(config){
30418 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30422 Roo.bootstrap.LayoutMasonry.register(this);
30428 * Fire after layout the items
30429 * @param {Roo.bootstrap.LayoutMasonry} this
30430 * @param {Roo.EventObject} e
30437 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30440 * @cfg {Boolean} isLayoutInstant = no animation?
30442 isLayoutInstant : false, // needed?
30445 * @cfg {Number} boxWidth width of the columns
30450 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30455 * @cfg {Number} padWidth padding below box..
30460 * @cfg {Number} gutter gutter width..
30465 * @cfg {Number} maxCols maximum number of columns
30471 * @cfg {Boolean} isAutoInitial defalut true
30473 isAutoInitial : true,
30478 * @cfg {Boolean} isHorizontal defalut false
30480 isHorizontal : false,
30482 currentSize : null,
30488 bricks: null, //CompositeElement
30492 _isLayoutInited : false,
30494 // isAlternative : false, // only use for vertical layout...
30497 * @cfg {Number} alternativePadWidth padding below box..
30499 alternativePadWidth : 50,
30501 selectedBrick : [],
30503 getAutoCreate : function(){
30505 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30509 cls: 'blog-masonary-wrapper ' + this.cls,
30511 cls : 'mas-boxes masonary'
30518 getChildContainer: function( )
30520 if (this.boxesEl) {
30521 return this.boxesEl;
30524 this.boxesEl = this.el.select('.mas-boxes').first();
30526 return this.boxesEl;
30530 initEvents : function()
30534 if(this.isAutoInitial){
30535 Roo.log('hook children rendered');
30536 this.on('childrenrendered', function() {
30537 Roo.log('children rendered');
30543 initial : function()
30545 this.selectedBrick = [];
30547 this.currentSize = this.el.getBox(true);
30549 Roo.EventManager.onWindowResize(this.resize, this);
30551 if(!this.isAutoInitial){
30559 //this.layout.defer(500,this);
30563 resize : function()
30565 var cs = this.el.getBox(true);
30568 this.currentSize.width == cs.width &&
30569 this.currentSize.x == cs.x &&
30570 this.currentSize.height == cs.height &&
30571 this.currentSize.y == cs.y
30573 Roo.log("no change in with or X or Y");
30577 this.currentSize = cs;
30583 layout : function()
30585 this._resetLayout();
30587 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30589 this.layoutItems( isInstant );
30591 this._isLayoutInited = true;
30593 this.fireEvent('layout', this);
30597 _resetLayout : function()
30599 if(this.isHorizontal){
30600 this.horizontalMeasureColumns();
30604 this.verticalMeasureColumns();
30608 verticalMeasureColumns : function()
30610 this.getContainerWidth();
30612 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30613 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30617 var boxWidth = this.boxWidth + this.padWidth;
30619 if(this.containerWidth < this.boxWidth){
30620 boxWidth = this.containerWidth
30623 var containerWidth = this.containerWidth;
30625 var cols = Math.floor(containerWidth / boxWidth);
30627 this.cols = Math.max( cols, 1 );
30629 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30631 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30633 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30635 this.colWidth = boxWidth + avail - this.padWidth;
30637 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30638 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30641 horizontalMeasureColumns : function()
30643 this.getContainerWidth();
30645 var boxWidth = this.boxWidth;
30647 if(this.containerWidth < boxWidth){
30648 boxWidth = this.containerWidth;
30651 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30653 this.el.setHeight(boxWidth);
30657 getContainerWidth : function()
30659 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30662 layoutItems : function( isInstant )
30664 Roo.log(this.bricks);
30666 var items = Roo.apply([], this.bricks);
30668 if(this.isHorizontal){
30669 this._horizontalLayoutItems( items , isInstant );
30673 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30674 // this._verticalAlternativeLayoutItems( items , isInstant );
30678 this._verticalLayoutItems( items , isInstant );
30682 _verticalLayoutItems : function ( items , isInstant)
30684 if ( !items || !items.length ) {
30689 ['xs', 'xs', 'xs', 'tall'],
30690 ['xs', 'xs', 'tall'],
30691 ['xs', 'xs', 'sm'],
30692 ['xs', 'xs', 'xs'],
30698 ['sm', 'xs', 'xs'],
30702 ['tall', 'xs', 'xs', 'xs'],
30703 ['tall', 'xs', 'xs'],
30715 Roo.each(items, function(item, k){
30717 switch (item.size) {
30718 // these layouts take up a full box,
30729 boxes.push([item]);
30752 var filterPattern = function(box, length)
30760 var pattern = box.slice(0, length);
30764 Roo.each(pattern, function(i){
30765 format.push(i.size);
30768 Roo.each(standard, function(s){
30770 if(String(s) != String(format)){
30779 if(!match && length == 1){
30784 filterPattern(box, length - 1);
30788 queue.push(pattern);
30790 box = box.slice(length, box.length);
30792 filterPattern(box, 4);
30798 Roo.each(boxes, function(box, k){
30804 if(box.length == 1){
30809 filterPattern(box, 4);
30813 this._processVerticalLayoutQueue( queue, isInstant );
30817 // _verticalAlternativeLayoutItems : function( items , isInstant )
30819 // if ( !items || !items.length ) {
30823 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30827 _horizontalLayoutItems : function ( items , isInstant)
30829 if ( !items || !items.length || items.length < 3) {
30835 var eItems = items.slice(0, 3);
30837 items = items.slice(3, items.length);
30840 ['xs', 'xs', 'xs', 'wide'],
30841 ['xs', 'xs', 'wide'],
30842 ['xs', 'xs', 'sm'],
30843 ['xs', 'xs', 'xs'],
30849 ['sm', 'xs', 'xs'],
30853 ['wide', 'xs', 'xs', 'xs'],
30854 ['wide', 'xs', 'xs'],
30867 Roo.each(items, function(item, k){
30869 switch (item.size) {
30880 boxes.push([item]);
30904 var filterPattern = function(box, length)
30912 var pattern = box.slice(0, length);
30916 Roo.each(pattern, function(i){
30917 format.push(i.size);
30920 Roo.each(standard, function(s){
30922 if(String(s) != String(format)){
30931 if(!match && length == 1){
30936 filterPattern(box, length - 1);
30940 queue.push(pattern);
30942 box = box.slice(length, box.length);
30944 filterPattern(box, 4);
30950 Roo.each(boxes, function(box, k){
30956 if(box.length == 1){
30961 filterPattern(box, 4);
30968 var pos = this.el.getBox(true);
30972 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30974 var hit_end = false;
30976 Roo.each(queue, function(box){
30980 Roo.each(box, function(b){
30982 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30992 Roo.each(box, function(b){
30994 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30997 mx = Math.max(mx, b.x);
31001 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31005 Roo.each(box, function(b){
31007 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31021 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31024 /** Sets position of item in DOM
31025 * @param {Element} item
31026 * @param {Number} x - horizontal position
31027 * @param {Number} y - vertical position
31028 * @param {Boolean} isInstant - disables transitions
31030 _processVerticalLayoutQueue : function( queue, isInstant )
31032 var pos = this.el.getBox(true);
31037 for (var i = 0; i < this.cols; i++){
31041 Roo.each(queue, function(box, k){
31043 var col = k % this.cols;
31045 Roo.each(box, function(b,kk){
31047 b.el.position('absolute');
31049 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31050 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31052 if(b.size == 'md-left' || b.size == 'md-right'){
31053 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31054 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31057 b.el.setWidth(width);
31058 b.el.setHeight(height);
31060 b.el.select('iframe',true).setSize(width,height);
31064 for (var i = 0; i < this.cols; i++){
31066 if(maxY[i] < maxY[col]){
31071 col = Math.min(col, i);
31075 x = pos.x + col * (this.colWidth + this.padWidth);
31079 var positions = [];
31081 switch (box.length){
31083 positions = this.getVerticalOneBoxColPositions(x, y, box);
31086 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31089 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31092 positions = this.getVerticalFourBoxColPositions(x, y, box);
31098 Roo.each(box, function(b,kk){
31100 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31102 var sz = b.el.getSize();
31104 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31112 for (var i = 0; i < this.cols; i++){
31113 mY = Math.max(mY, maxY[i]);
31116 this.el.setHeight(mY - pos.y);
31120 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31122 // var pos = this.el.getBox(true);
31125 // var maxX = pos.right;
31127 // var maxHeight = 0;
31129 // Roo.each(items, function(item, k){
31133 // item.el.position('absolute');
31135 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31137 // item.el.setWidth(width);
31139 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31141 // item.el.setHeight(height);
31144 // item.el.setXY([x, y], isInstant ? false : true);
31146 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31149 // y = y + height + this.alternativePadWidth;
31151 // maxHeight = maxHeight + height + this.alternativePadWidth;
31155 // this.el.setHeight(maxHeight);
31159 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31161 var pos = this.el.getBox(true);
31166 var maxX = pos.right;
31168 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31170 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31172 Roo.each(queue, function(box, k){
31174 Roo.each(box, function(b, kk){
31176 b.el.position('absolute');
31178 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31179 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31181 if(b.size == 'md-left' || b.size == 'md-right'){
31182 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31183 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31186 b.el.setWidth(width);
31187 b.el.setHeight(height);
31195 var positions = [];
31197 switch (box.length){
31199 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31202 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31205 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31208 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31214 Roo.each(box, function(b,kk){
31216 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31218 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31226 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31228 Roo.each(eItems, function(b,k){
31230 b.size = (k == 0) ? 'sm' : 'xs';
31231 b.x = (k == 0) ? 2 : 1;
31232 b.y = (k == 0) ? 2 : 1;
31234 b.el.position('absolute');
31236 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31238 b.el.setWidth(width);
31240 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31242 b.el.setHeight(height);
31246 var positions = [];
31249 x : maxX - this.unitWidth * 2 - this.gutter,
31254 x : maxX - this.unitWidth,
31255 y : minY + (this.unitWidth + this.gutter) * 2
31259 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31263 Roo.each(eItems, function(b,k){
31265 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31271 getVerticalOneBoxColPositions : function(x, y, box)
31275 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31277 if(box[0].size == 'md-left'){
31281 if(box[0].size == 'md-right'){
31286 x : x + (this.unitWidth + this.gutter) * rand,
31293 getVerticalTwoBoxColPositions : function(x, y, box)
31297 if(box[0].size == 'xs'){
31301 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31305 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31319 x : x + (this.unitWidth + this.gutter) * 2,
31320 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31327 getVerticalThreeBoxColPositions : function(x, y, box)
31331 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31339 x : x + (this.unitWidth + this.gutter) * 1,
31344 x : x + (this.unitWidth + this.gutter) * 2,
31352 if(box[0].size == 'xs' && box[1].size == 'xs'){
31361 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31365 x : x + (this.unitWidth + this.gutter) * 1,
31379 x : x + (this.unitWidth + this.gutter) * 2,
31384 x : x + (this.unitWidth + this.gutter) * 2,
31385 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31392 getVerticalFourBoxColPositions : function(x, y, box)
31396 if(box[0].size == 'xs'){
31405 y : y + (this.unitHeight + this.gutter) * 1
31410 y : y + (this.unitHeight + this.gutter) * 2
31414 x : x + (this.unitWidth + this.gutter) * 1,
31428 x : x + (this.unitWidth + this.gutter) * 2,
31433 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31434 y : y + (this.unitHeight + this.gutter) * 1
31438 x : x + (this.unitWidth + this.gutter) * 2,
31439 y : y + (this.unitWidth + this.gutter) * 2
31446 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31450 if(box[0].size == 'md-left'){
31452 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31459 if(box[0].size == 'md-right'){
31461 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31462 y : minY + (this.unitWidth + this.gutter) * 1
31468 var rand = Math.floor(Math.random() * (4 - box[0].y));
31471 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31472 y : minY + (this.unitWidth + this.gutter) * rand
31479 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31483 if(box[0].size == 'xs'){
31486 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31491 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31492 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31500 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31505 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31506 y : minY + (this.unitWidth + this.gutter) * 2
31513 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31517 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31520 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31525 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31526 y : minY + (this.unitWidth + this.gutter) * 1
31530 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31531 y : minY + (this.unitWidth + this.gutter) * 2
31538 if(box[0].size == 'xs' && box[1].size == 'xs'){
31541 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31546 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31551 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31552 y : minY + (this.unitWidth + this.gutter) * 1
31560 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31565 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31566 y : minY + (this.unitWidth + this.gutter) * 2
31570 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31571 y : minY + (this.unitWidth + this.gutter) * 2
31578 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31582 if(box[0].size == 'xs'){
31585 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31590 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31595 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),
31600 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31601 y : minY + (this.unitWidth + this.gutter) * 1
31609 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31614 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31615 y : minY + (this.unitWidth + this.gutter) * 2
31619 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31620 y : minY + (this.unitWidth + this.gutter) * 2
31624 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),
31625 y : minY + (this.unitWidth + this.gutter) * 2
31633 * remove a Masonry Brick
31634 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31636 removeBrick : function(brick_id)
31642 for (var i = 0; i<this.bricks.length; i++) {
31643 if (this.bricks[i].id == brick_id) {
31644 this.bricks.splice(i,1);
31645 this.el.dom.removeChild(Roo.get(brick_id).dom);
31652 * adds a Masonry Brick
31653 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31655 addBrick : function(cfg)
31657 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31658 //this.register(cn);
31659 cn.parentId = this.id;
31660 cn.onRender(this.el, null);
31665 * register a Masonry Brick
31666 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31669 register : function(brick)
31671 this.bricks.push(brick);
31672 brick.masonryId = this.id;
31676 * clear all the Masonry Brick
31678 clearAll : function()
31681 //this.getChildContainer().dom.innerHTML = "";
31682 this.el.dom.innerHTML = '';
31685 getSelected : function()
31687 if (!this.selectedBrick) {
31691 return this.selectedBrick;
31695 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31699 * register a Masonry Layout
31700 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31703 register : function(layout)
31705 this.groups[layout.id] = layout;
31708 * fetch a Masonry Layout based on the masonry layout ID
31709 * @param {string} the masonry layout to add
31710 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31713 get: function(layout_id) {
31714 if (typeof(this.groups[layout_id]) == 'undefined') {
31717 return this.groups[layout_id] ;
31729 * http://masonry.desandro.com
31731 * The idea is to render all the bricks based on vertical width...
31733 * The original code extends 'outlayer' - we might need to use that....
31739 * @class Roo.bootstrap.LayoutMasonryAuto
31740 * @extends Roo.bootstrap.Component
31741 * Bootstrap Layout Masonry class
31744 * Create a new Element
31745 * @param {Object} config The config object
31748 Roo.bootstrap.LayoutMasonryAuto = function(config){
31749 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31752 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31755 * @cfg {Boolean} isFitWidth - resize the width..
31757 isFitWidth : false, // options..
31759 * @cfg {Boolean} isOriginLeft = left align?
31761 isOriginLeft : true,
31763 * @cfg {Boolean} isOriginTop = top align?
31765 isOriginTop : false,
31767 * @cfg {Boolean} isLayoutInstant = no animation?
31769 isLayoutInstant : false, // needed?
31771 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31773 isResizingContainer : true,
31775 * @cfg {Number} columnWidth width of the columns
31781 * @cfg {Number} maxCols maximum number of columns
31786 * @cfg {Number} padHeight padding below box..
31792 * @cfg {Boolean} isAutoInitial defalut true
31795 isAutoInitial : true,
31801 initialColumnWidth : 0,
31802 currentSize : null,
31804 colYs : null, // array.
31811 bricks: null, //CompositeElement
31812 cols : 0, // array?
31813 // element : null, // wrapped now this.el
31814 _isLayoutInited : null,
31817 getAutoCreate : function(){
31821 cls: 'blog-masonary-wrapper ' + this.cls,
31823 cls : 'mas-boxes masonary'
31830 getChildContainer: function( )
31832 if (this.boxesEl) {
31833 return this.boxesEl;
31836 this.boxesEl = this.el.select('.mas-boxes').first();
31838 return this.boxesEl;
31842 initEvents : function()
31846 if(this.isAutoInitial){
31847 Roo.log('hook children rendered');
31848 this.on('childrenrendered', function() {
31849 Roo.log('children rendered');
31856 initial : function()
31858 this.reloadItems();
31860 this.currentSize = this.el.getBox(true);
31862 /// was window resize... - let's see if this works..
31863 Roo.EventManager.onWindowResize(this.resize, this);
31865 if(!this.isAutoInitial){
31870 this.layout.defer(500,this);
31873 reloadItems: function()
31875 this.bricks = this.el.select('.masonry-brick', true);
31877 this.bricks.each(function(b) {
31878 //Roo.log(b.getSize());
31879 if (!b.attr('originalwidth')) {
31880 b.attr('originalwidth', b.getSize().width);
31885 Roo.log(this.bricks.elements.length);
31888 resize : function()
31891 var cs = this.el.getBox(true);
31893 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31894 Roo.log("no change in with or X");
31897 this.currentSize = cs;
31901 layout : function()
31904 this._resetLayout();
31905 //this._manageStamps();
31907 // don't animate first layout
31908 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31909 this.layoutItems( isInstant );
31911 // flag for initalized
31912 this._isLayoutInited = true;
31915 layoutItems : function( isInstant )
31917 //var items = this._getItemsForLayout( this.items );
31918 // original code supports filtering layout items.. we just ignore it..
31920 this._layoutItems( this.bricks , isInstant );
31922 this._postLayout();
31924 _layoutItems : function ( items , isInstant)
31926 //this.fireEvent( 'layout', this, items );
31929 if ( !items || !items.elements.length ) {
31930 // no items, emit event with empty array
31935 items.each(function(item) {
31936 Roo.log("layout item");
31938 // get x/y object from method
31939 var position = this._getItemLayoutPosition( item );
31941 position.item = item;
31942 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31943 queue.push( position );
31946 this._processLayoutQueue( queue );
31948 /** Sets position of item in DOM
31949 * @param {Element} item
31950 * @param {Number} x - horizontal position
31951 * @param {Number} y - vertical position
31952 * @param {Boolean} isInstant - disables transitions
31954 _processLayoutQueue : function( queue )
31956 for ( var i=0, len = queue.length; i < len; i++ ) {
31957 var obj = queue[i];
31958 obj.item.position('absolute');
31959 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31965 * Any logic you want to do after each layout,
31966 * i.e. size the container
31968 _postLayout : function()
31970 this.resizeContainer();
31973 resizeContainer : function()
31975 if ( !this.isResizingContainer ) {
31978 var size = this._getContainerSize();
31980 this.el.setSize(size.width,size.height);
31981 this.boxesEl.setSize(size.width,size.height);
31987 _resetLayout : function()
31989 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31990 this.colWidth = this.el.getWidth();
31991 //this.gutter = this.el.getWidth();
31993 this.measureColumns();
31999 this.colYs.push( 0 );
32005 measureColumns : function()
32007 this.getContainerWidth();
32008 // if columnWidth is 0, default to outerWidth of first item
32009 if ( !this.columnWidth ) {
32010 var firstItem = this.bricks.first();
32011 Roo.log(firstItem);
32012 this.columnWidth = this.containerWidth;
32013 if (firstItem && firstItem.attr('originalwidth') ) {
32014 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32016 // columnWidth fall back to item of first element
32017 Roo.log("set column width?");
32018 this.initialColumnWidth = this.columnWidth ;
32020 // if first elem has no width, default to size of container
32025 if (this.initialColumnWidth) {
32026 this.columnWidth = this.initialColumnWidth;
32031 // column width is fixed at the top - however if container width get's smaller we should
32034 // this bit calcs how man columns..
32036 var columnWidth = this.columnWidth += this.gutter;
32038 // calculate columns
32039 var containerWidth = this.containerWidth + this.gutter;
32041 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32042 // fix rounding errors, typically with gutters
32043 var excess = columnWidth - containerWidth % columnWidth;
32046 // if overshoot is less than a pixel, round up, otherwise floor it
32047 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32048 cols = Math[ mathMethod ]( cols );
32049 this.cols = Math.max( cols, 1 );
32050 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32052 // padding positioning..
32053 var totalColWidth = this.cols * this.columnWidth;
32054 var padavail = this.containerWidth - totalColWidth;
32055 // so for 2 columns - we need 3 'pads'
32057 var padNeeded = (1+this.cols) * this.padWidth;
32059 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32061 this.columnWidth += padExtra
32062 //this.padWidth = Math.floor(padavail / ( this.cols));
32064 // adjust colum width so that padding is fixed??
32066 // we have 3 columns ... total = width * 3
32067 // we have X left over... that should be used by
32069 //if (this.expandC) {
32077 getContainerWidth : function()
32079 /* // container is parent if fit width
32080 var container = this.isFitWidth ? this.element.parentNode : this.element;
32081 // check that this.size and size are there
32082 // IE8 triggers resize on body size change, so they might not be
32084 var size = getSize( container ); //FIXME
32085 this.containerWidth = size && size.innerWidth; //FIXME
32088 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32092 _getItemLayoutPosition : function( item ) // what is item?
32094 // we resize the item to our columnWidth..
32096 item.setWidth(this.columnWidth);
32097 item.autoBoxAdjust = false;
32099 var sz = item.getSize();
32101 // how many columns does this brick span
32102 var remainder = this.containerWidth % this.columnWidth;
32104 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32105 // round if off by 1 pixel, otherwise use ceil
32106 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32107 colSpan = Math.min( colSpan, this.cols );
32109 // normally this should be '1' as we dont' currently allow multi width columns..
32111 var colGroup = this._getColGroup( colSpan );
32112 // get the minimum Y value from the columns
32113 var minimumY = Math.min.apply( Math, colGroup );
32114 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32116 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32118 // position the brick
32120 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32121 y: this.currentSize.y + minimumY + this.padHeight
32125 // apply setHeight to necessary columns
32126 var setHeight = minimumY + sz.height + this.padHeight;
32127 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32129 var setSpan = this.cols + 1 - colGroup.length;
32130 for ( var i = 0; i < setSpan; i++ ) {
32131 this.colYs[ shortColIndex + i ] = setHeight ;
32138 * @param {Number} colSpan - number of columns the element spans
32139 * @returns {Array} colGroup
32141 _getColGroup : function( colSpan )
32143 if ( colSpan < 2 ) {
32144 // if brick spans only one column, use all the column Ys
32149 // how many different places could this brick fit horizontally
32150 var groupCount = this.cols + 1 - colSpan;
32151 // for each group potential horizontal position
32152 for ( var i = 0; i < groupCount; i++ ) {
32153 // make an array of colY values for that one group
32154 var groupColYs = this.colYs.slice( i, i + colSpan );
32155 // and get the max value of the array
32156 colGroup[i] = Math.max.apply( Math, groupColYs );
32161 _manageStamp : function( stamp )
32163 var stampSize = stamp.getSize();
32164 var offset = stamp.getBox();
32165 // get the columns that this stamp affects
32166 var firstX = this.isOriginLeft ? offset.x : offset.right;
32167 var lastX = firstX + stampSize.width;
32168 var firstCol = Math.floor( firstX / this.columnWidth );
32169 firstCol = Math.max( 0, firstCol );
32171 var lastCol = Math.floor( lastX / this.columnWidth );
32172 // lastCol should not go over if multiple of columnWidth #425
32173 lastCol -= lastX % this.columnWidth ? 0 : 1;
32174 lastCol = Math.min( this.cols - 1, lastCol );
32176 // set colYs to bottom of the stamp
32177 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32180 for ( var i = firstCol; i <= lastCol; i++ ) {
32181 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32186 _getContainerSize : function()
32188 this.maxY = Math.max.apply( Math, this.colYs );
32193 if ( this.isFitWidth ) {
32194 size.width = this._getContainerFitWidth();
32200 _getContainerFitWidth : function()
32202 var unusedCols = 0;
32203 // count unused columns
32206 if ( this.colYs[i] !== 0 ) {
32211 // fit container to columns that have been used
32212 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32215 needsResizeLayout : function()
32217 var previousWidth = this.containerWidth;
32218 this.getContainerWidth();
32219 return previousWidth !== this.containerWidth;
32234 * @class Roo.bootstrap.MasonryBrick
32235 * @extends Roo.bootstrap.Component
32236 * Bootstrap MasonryBrick class
32239 * Create a new MasonryBrick
32240 * @param {Object} config The config object
32243 Roo.bootstrap.MasonryBrick = function(config){
32245 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32247 Roo.bootstrap.MasonryBrick.register(this);
32253 * When a MasonryBrick is clcik
32254 * @param {Roo.bootstrap.MasonryBrick} this
32255 * @param {Roo.EventObject} e
32261 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32264 * @cfg {String} title
32268 * @cfg {String} html
32272 * @cfg {String} bgimage
32276 * @cfg {String} videourl
32280 * @cfg {String} cls
32284 * @cfg {String} href
32288 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32293 * @cfg {String} placetitle (center|bottom)
32298 * @cfg {Boolean} isFitContainer defalut true
32300 isFitContainer : true,
32303 * @cfg {Boolean} preventDefault defalut false
32305 preventDefault : false,
32308 * @cfg {Boolean} inverse defalut false
32310 maskInverse : false,
32312 getAutoCreate : function()
32314 if(!this.isFitContainer){
32315 return this.getSplitAutoCreate();
32318 var cls = 'masonry-brick masonry-brick-full';
32320 if(this.href.length){
32321 cls += ' masonry-brick-link';
32324 if(this.bgimage.length){
32325 cls += ' masonry-brick-image';
32328 if(this.maskInverse){
32329 cls += ' mask-inverse';
32332 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32333 cls += ' enable-mask';
32337 cls += ' masonry-' + this.size + '-brick';
32340 if(this.placetitle.length){
32342 switch (this.placetitle) {
32344 cls += ' masonry-center-title';
32347 cls += ' masonry-bottom-title';
32354 if(!this.html.length && !this.bgimage.length){
32355 cls += ' masonry-center-title';
32358 if(!this.html.length && this.bgimage.length){
32359 cls += ' masonry-bottom-title';
32364 cls += ' ' + this.cls;
32368 tag: (this.href.length) ? 'a' : 'div',
32373 cls: 'masonry-brick-mask'
32377 cls: 'masonry-brick-paragraph',
32383 if(this.href.length){
32384 cfg.href = this.href;
32387 var cn = cfg.cn[1].cn;
32389 if(this.title.length){
32392 cls: 'masonry-brick-title',
32397 if(this.html.length){
32400 cls: 'masonry-brick-text',
32405 if (!this.title.length && !this.html.length) {
32406 cfg.cn[1].cls += ' hide';
32409 if(this.bgimage.length){
32412 cls: 'masonry-brick-image-view',
32417 if(this.videourl.length){
32418 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32419 // youtube support only?
32422 cls: 'masonry-brick-image-view',
32425 allowfullscreen : true
32433 getSplitAutoCreate : function()
32435 var cls = 'masonry-brick masonry-brick-split';
32437 if(this.href.length){
32438 cls += ' masonry-brick-link';
32441 if(this.bgimage.length){
32442 cls += ' masonry-brick-image';
32446 cls += ' masonry-' + this.size + '-brick';
32449 switch (this.placetitle) {
32451 cls += ' masonry-center-title';
32454 cls += ' masonry-bottom-title';
32457 if(!this.bgimage.length){
32458 cls += ' masonry-center-title';
32461 if(this.bgimage.length){
32462 cls += ' masonry-bottom-title';
32468 cls += ' ' + this.cls;
32472 tag: (this.href.length) ? 'a' : 'div',
32477 cls: 'masonry-brick-split-head',
32481 cls: 'masonry-brick-paragraph',
32488 cls: 'masonry-brick-split-body',
32494 if(this.href.length){
32495 cfg.href = this.href;
32498 if(this.title.length){
32499 cfg.cn[0].cn[0].cn.push({
32501 cls: 'masonry-brick-title',
32506 if(this.html.length){
32507 cfg.cn[1].cn.push({
32509 cls: 'masonry-brick-text',
32514 if(this.bgimage.length){
32515 cfg.cn[0].cn.push({
32517 cls: 'masonry-brick-image-view',
32522 if(this.videourl.length){
32523 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32524 // youtube support only?
32525 cfg.cn[0].cn.cn.push({
32527 cls: 'masonry-brick-image-view',
32530 allowfullscreen : true
32537 initEvents: function()
32539 switch (this.size) {
32572 this.el.on('touchstart', this.onTouchStart, this);
32573 this.el.on('touchmove', this.onTouchMove, this);
32574 this.el.on('touchend', this.onTouchEnd, this);
32575 this.el.on('contextmenu', this.onContextMenu, this);
32577 this.el.on('mouseenter' ,this.enter, this);
32578 this.el.on('mouseleave', this.leave, this);
32579 this.el.on('click', this.onClick, this);
32582 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32583 this.parent().bricks.push(this);
32588 onClick: function(e, el)
32590 var time = this.endTimer - this.startTimer;
32591 // Roo.log(e.preventDefault());
32594 e.preventDefault();
32599 if(!this.preventDefault){
32603 e.preventDefault();
32605 if (this.activcClass != '') {
32606 this.selectBrick();
32609 this.fireEvent('click', this);
32612 enter: function(e, el)
32614 e.preventDefault();
32616 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32620 if(this.bgimage.length && this.html.length){
32621 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32625 leave: function(e, el)
32627 e.preventDefault();
32629 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32633 if(this.bgimage.length && this.html.length){
32634 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32638 onTouchStart: function(e, el)
32640 // e.preventDefault();
32642 this.touchmoved = false;
32644 if(!this.isFitContainer){
32648 if(!this.bgimage.length || !this.html.length){
32652 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32654 this.timer = new Date().getTime();
32658 onTouchMove: function(e, el)
32660 this.touchmoved = true;
32663 onContextMenu : function(e,el)
32665 e.preventDefault();
32666 e.stopPropagation();
32670 onTouchEnd: function(e, el)
32672 // e.preventDefault();
32674 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32681 if(!this.bgimage.length || !this.html.length){
32683 if(this.href.length){
32684 window.location.href = this.href;
32690 if(!this.isFitContainer){
32694 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32696 window.location.href = this.href;
32699 //selection on single brick only
32700 selectBrick : function() {
32702 if (!this.parentId) {
32706 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32707 var index = m.selectedBrick.indexOf(this.id);
32710 m.selectedBrick.splice(index,1);
32711 this.el.removeClass(this.activeClass);
32715 for(var i = 0; i < m.selectedBrick.length; i++) {
32716 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32717 b.el.removeClass(b.activeClass);
32720 m.selectedBrick = [];
32722 m.selectedBrick.push(this.id);
32723 this.el.addClass(this.activeClass);
32729 Roo.apply(Roo.bootstrap.MasonryBrick, {
32732 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32734 * register a Masonry Brick
32735 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32738 register : function(brick)
32740 //this.groups[brick.id] = brick;
32741 this.groups.add(brick.id, brick);
32744 * fetch a masonry brick based on the masonry brick ID
32745 * @param {string} the masonry brick to add
32746 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32749 get: function(brick_id)
32751 // if (typeof(this.groups[brick_id]) == 'undefined') {
32754 // return this.groups[brick_id] ;
32756 if(this.groups.key(brick_id)) {
32757 return this.groups.key(brick_id);
32775 * @class Roo.bootstrap.Brick
32776 * @extends Roo.bootstrap.Component
32777 * Bootstrap Brick class
32780 * Create a new Brick
32781 * @param {Object} config The config object
32784 Roo.bootstrap.Brick = function(config){
32785 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32791 * When a Brick is click
32792 * @param {Roo.bootstrap.Brick} this
32793 * @param {Roo.EventObject} e
32799 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32802 * @cfg {String} title
32806 * @cfg {String} html
32810 * @cfg {String} bgimage
32814 * @cfg {String} cls
32818 * @cfg {String} href
32822 * @cfg {String} video
32826 * @cfg {Boolean} square
32830 getAutoCreate : function()
32832 var cls = 'roo-brick';
32834 if(this.href.length){
32835 cls += ' roo-brick-link';
32838 if(this.bgimage.length){
32839 cls += ' roo-brick-image';
32842 if(!this.html.length && !this.bgimage.length){
32843 cls += ' roo-brick-center-title';
32846 if(!this.html.length && this.bgimage.length){
32847 cls += ' roo-brick-bottom-title';
32851 cls += ' ' + this.cls;
32855 tag: (this.href.length) ? 'a' : 'div',
32860 cls: 'roo-brick-paragraph',
32866 if(this.href.length){
32867 cfg.href = this.href;
32870 var cn = cfg.cn[0].cn;
32872 if(this.title.length){
32875 cls: 'roo-brick-title',
32880 if(this.html.length){
32883 cls: 'roo-brick-text',
32890 if(this.bgimage.length){
32893 cls: 'roo-brick-image-view',
32901 initEvents: function()
32903 if(this.title.length || this.html.length){
32904 this.el.on('mouseenter' ,this.enter, this);
32905 this.el.on('mouseleave', this.leave, this);
32908 Roo.EventManager.onWindowResize(this.resize, this);
32910 if(this.bgimage.length){
32911 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32912 this.imageEl.on('load', this.onImageLoad, this);
32919 onImageLoad : function()
32924 resize : function()
32926 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32928 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32930 if(this.bgimage.length){
32931 var image = this.el.select('.roo-brick-image-view', true).first();
32933 image.setWidth(paragraph.getWidth());
32936 image.setHeight(paragraph.getWidth());
32939 this.el.setHeight(image.getHeight());
32940 paragraph.setHeight(image.getHeight());
32946 enter: function(e, el)
32948 e.preventDefault();
32950 if(this.bgimage.length){
32951 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32952 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32956 leave: function(e, el)
32958 e.preventDefault();
32960 if(this.bgimage.length){
32961 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32962 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32978 * @class Roo.bootstrap.NumberField
32979 * @extends Roo.bootstrap.Input
32980 * Bootstrap NumberField class
32986 * Create a new NumberField
32987 * @param {Object} config The config object
32990 Roo.bootstrap.NumberField = function(config){
32991 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32994 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32997 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
32999 allowDecimals : true,
33001 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33003 decimalSeparator : ".",
33005 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33007 decimalPrecision : 2,
33009 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33011 allowNegative : true,
33013 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33015 minValue : Number.NEGATIVE_INFINITY,
33017 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33019 maxValue : Number.MAX_VALUE,
33021 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33023 minText : "The minimum value for this field is {0}",
33025 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33027 maxText : "The maximum value for this field is {0}",
33029 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33030 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33032 nanText : "{0} is not a valid number",
33034 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
33038 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33040 thousandsDelimiter : false,
33042 * @cfg {String} valueAlign alignment of value
33044 valueAlign : "left",
33046 getAutoCreate : function()
33048 var hiddenInput = {
33052 cls: 'hidden-number-input'
33056 hiddenInput.name = this.name;
33061 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33063 this.name = hiddenInput.name;
33065 if(cfg.cn.length > 0) {
33066 cfg.cn.push(hiddenInput);
33073 initEvents : function()
33075 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33077 var allowed = "0123456789";
33079 if(this.allowDecimals){
33080 allowed += this.decimalSeparator;
33083 if(this.allowNegative){
33087 if(this.thousandsDelimiter) {
33091 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33093 var keyPress = function(e){
33095 var k = e.getKey();
33097 var c = e.getCharCode();
33100 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33101 allowed.indexOf(String.fromCharCode(c)) === -1
33107 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33111 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33116 this.el.on("keypress", keyPress, this);
33119 validateValue : function(value)
33122 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33126 var num = this.parseValue(value);
33129 this.markInvalid(String.format(this.nanText, value));
33133 if(num < this.minValue){
33134 this.markInvalid(String.format(this.minText, this.minValue));
33138 if(num > this.maxValue){
33139 this.markInvalid(String.format(this.maxText, this.maxValue));
33146 getValue : function()
33148 var v = this.hiddenEl().getValue();
33150 return this.fixPrecision(this.parseValue(v));
33153 parseValue : function(value)
33155 if(this.thousandsDelimiter) {
33157 r = new RegExp(",", "g");
33158 value = value.replace(r, "");
33161 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33162 return isNaN(value) ? '' : value;
33165 fixPrecision : function(value)
33167 if(this.thousandsDelimiter) {
33169 r = new RegExp(",", "g");
33170 value = value.replace(r, "");
33173 var nan = isNaN(value);
33175 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33176 return nan ? '' : value;
33178 return parseFloat(value).toFixed(this.decimalPrecision);
33181 setValue : function(v)
33183 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33189 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33191 this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
33192 this.thousandsDelimiter || ''
33195 if(this.allowBlank && !v) {
33196 this.inputEl().dom.value = '';
33203 decimalPrecisionFcn : function(v)
33205 return Math.floor(v);
33208 beforeBlur : function()
33214 var v = this.parseValue(this.getRawValue());
33220 hiddenEl : function()
33222 return this.el.select('input.hidden-number-input',true).first();
33234 * @class Roo.bootstrap.DocumentSlider
33235 * @extends Roo.bootstrap.Component
33236 * Bootstrap DocumentSlider class
33239 * Create a new DocumentViewer
33240 * @param {Object} config The config object
33243 Roo.bootstrap.DocumentSlider = function(config){
33244 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33251 * Fire after initEvent
33252 * @param {Roo.bootstrap.DocumentSlider} this
33257 * Fire after update
33258 * @param {Roo.bootstrap.DocumentSlider} this
33264 * @param {Roo.bootstrap.DocumentSlider} this
33270 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33276 getAutoCreate : function()
33280 cls : 'roo-document-slider',
33284 cls : 'roo-document-slider-header',
33288 cls : 'roo-document-slider-header-title'
33294 cls : 'roo-document-slider-body',
33298 cls : 'roo-document-slider-prev',
33302 cls : 'fa fa-chevron-left'
33308 cls : 'roo-document-slider-thumb',
33312 cls : 'roo-document-slider-image'
33318 cls : 'roo-document-slider-next',
33322 cls : 'fa fa-chevron-right'
33334 initEvents : function()
33336 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33337 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33339 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33340 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33342 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33343 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33345 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33346 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33348 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33349 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33351 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33352 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33354 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33355 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33357 this.thumbEl.on('click', this.onClick, this);
33359 this.prevIndicator.on('click', this.prev, this);
33361 this.nextIndicator.on('click', this.next, this);
33365 initial : function()
33367 if(this.files.length){
33368 this.indicator = 1;
33372 this.fireEvent('initial', this);
33375 update : function()
33377 this.imageEl.attr('src', this.files[this.indicator - 1]);
33379 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33381 this.prevIndicator.show();
33383 if(this.indicator == 1){
33384 this.prevIndicator.hide();
33387 this.nextIndicator.show();
33389 if(this.indicator == this.files.length){
33390 this.nextIndicator.hide();
33393 this.thumbEl.scrollTo('top');
33395 this.fireEvent('update', this);
33398 onClick : function(e)
33400 e.preventDefault();
33402 this.fireEvent('click', this);
33407 e.preventDefault();
33409 this.indicator = Math.max(1, this.indicator - 1);
33416 e.preventDefault();
33418 this.indicator = Math.min(this.files.length, this.indicator + 1);
33432 * @class Roo.bootstrap.RadioSet
33433 * @extends Roo.bootstrap.Input
33434 * Bootstrap RadioSet class
33435 * @cfg {String} indicatorpos (left|right) default left
33436 * @cfg {Boolean} inline (true|false) inline the element (default true)
33437 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33439 * Create a new RadioSet
33440 * @param {Object} config The config object
33443 Roo.bootstrap.RadioSet = function(config){
33445 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33449 Roo.bootstrap.RadioSet.register(this);
33454 * Fires when the element is checked or unchecked.
33455 * @param {Roo.bootstrap.RadioSet} this This radio
33456 * @param {Roo.bootstrap.Radio} item The checked item
33463 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33471 indicatorpos : 'left',
33473 getAutoCreate : function()
33477 cls : 'roo-radio-set-label',
33481 html : this.fieldLabel
33486 if(this.indicatorpos == 'left'){
33489 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33490 tooltip : 'This field is required'
33495 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33496 tooltip : 'This field is required'
33502 cls : 'roo-radio-set-items'
33505 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33507 if (align === 'left' && this.fieldLabel.length) {
33510 cls : "roo-radio-set-right",
33516 if(this.labelWidth > 12){
33517 label.style = "width: " + this.labelWidth + 'px';
33520 if(this.labelWidth < 13 && this.labelmd == 0){
33521 this.labelmd = this.labelWidth;
33524 if(this.labellg > 0){
33525 label.cls += ' col-lg-' + this.labellg;
33526 items.cls += ' col-lg-' + (12 - this.labellg);
33529 if(this.labelmd > 0){
33530 label.cls += ' col-md-' + this.labelmd;
33531 items.cls += ' col-md-' + (12 - this.labelmd);
33534 if(this.labelsm > 0){
33535 label.cls += ' col-sm-' + this.labelsm;
33536 items.cls += ' col-sm-' + (12 - this.labelsm);
33539 if(this.labelxs > 0){
33540 label.cls += ' col-xs-' + this.labelxs;
33541 items.cls += ' col-xs-' + (12 - this.labelxs);
33547 cls : 'roo-radio-set',
33551 cls : 'roo-radio-set-input',
33554 value : this.value ? this.value : ''
33561 if(this.weight.length){
33562 cfg.cls += ' roo-radio-' + this.weight;
33566 cfg.cls += ' roo-radio-set-inline';
33570 ['xs','sm','md','lg'].map(function(size){
33571 if (settings[size]) {
33572 cfg.cls += ' col-' + size + '-' + settings[size];
33580 initEvents : function()
33582 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33583 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33585 if(!this.fieldLabel.length){
33586 this.labelEl.hide();
33589 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33590 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33592 this.indicatorEl().addClass('invisible');
33594 this.originalValue = this.getValue();
33598 inputEl: function ()
33600 return this.el.select('.roo-radio-set-input', true).first();
33603 getChildContainer : function()
33605 return this.itemsEl;
33608 register : function(item)
33610 this.radioes.push(item);
33614 validate : function()
33618 Roo.each(this.radioes, function(i){
33627 if(this.allowBlank) {
33631 if(this.disabled || valid){
33636 this.markInvalid();
33641 markValid : function()
33643 if(this.labelEl.isVisible(true)){
33644 this.indicatorEl().removeClass('visible');
33645 this.indicatorEl().addClass('invisible');
33648 this.el.removeClass([this.invalidClass, this.validClass]);
33649 this.el.addClass(this.validClass);
33651 this.fireEvent('valid', this);
33654 markInvalid : function(msg)
33656 if(this.allowBlank || this.disabled){
33660 if(this.labelEl.isVisible(true)){
33661 this.indicatorEl().removeClass('invisible');
33662 this.indicatorEl().addClass('visible');
33665 this.el.removeClass([this.invalidClass, this.validClass]);
33666 this.el.addClass(this.invalidClass);
33668 this.fireEvent('invalid', this, msg);
33672 setValue : function(v, suppressEvent)
33674 if(this.value === v){
33681 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33684 Roo.each(this.radioes, function(i){
33686 i.el.removeClass('checked');
33689 Roo.each(this.radioes, function(i){
33691 if(i.value === v || i.value.toString() === v.toString()){
33693 i.el.addClass('checked');
33695 if(suppressEvent !== true){
33696 this.fireEvent('check', this, i);
33707 clearInvalid : function(){
33709 if(!this.el || this.preventMark){
33713 this.el.removeClass([this.invalidClass]);
33715 this.fireEvent('valid', this);
33720 Roo.apply(Roo.bootstrap.RadioSet, {
33724 register : function(set)
33726 this.groups[set.name] = set;
33729 get: function(name)
33731 if (typeof(this.groups[name]) == 'undefined') {
33735 return this.groups[name] ;
33741 * Ext JS Library 1.1.1
33742 * Copyright(c) 2006-2007, Ext JS, LLC.
33744 * Originally Released Under LGPL - original licence link has changed is not relivant.
33747 * <script type="text/javascript">
33752 * @class Roo.bootstrap.SplitBar
33753 * @extends Roo.util.Observable
33754 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33758 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33759 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33760 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33761 split.minSize = 100;
33762 split.maxSize = 600;
33763 split.animate = true;
33764 split.on('moved', splitterMoved);
33767 * Create a new SplitBar
33768 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33769 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33770 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33771 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33772 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33773 position of the SplitBar).
33775 Roo.bootstrap.SplitBar = function(cfg){
33780 // dragElement : elm
33781 // resizingElement: el,
33783 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33784 // placement : Roo.bootstrap.SplitBar.LEFT ,
33785 // existingProxy ???
33788 this.el = Roo.get(cfg.dragElement, true);
33789 this.el.dom.unselectable = "on";
33791 this.resizingEl = Roo.get(cfg.resizingElement, true);
33795 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33796 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33799 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33802 * The minimum size of the resizing element. (Defaults to 0)
33808 * The maximum size of the resizing element. (Defaults to 2000)
33811 this.maxSize = 2000;
33814 * Whether to animate the transition to the new size
33817 this.animate = false;
33820 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33823 this.useShim = false;
33828 if(!cfg.existingProxy){
33830 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33832 this.proxy = Roo.get(cfg.existingProxy).dom;
33835 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33838 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33841 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33844 this.dragSpecs = {};
33847 * @private The adapter to use to positon and resize elements
33849 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33850 this.adapter.init(this);
33852 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33854 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33855 this.el.addClass("roo-splitbar-h");
33858 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33859 this.el.addClass("roo-splitbar-v");
33865 * Fires when the splitter is moved (alias for {@link #event-moved})
33866 * @param {Roo.bootstrap.SplitBar} this
33867 * @param {Number} newSize the new width or height
33872 * Fires when the splitter is moved
33873 * @param {Roo.bootstrap.SplitBar} this
33874 * @param {Number} newSize the new width or height
33878 * @event beforeresize
33879 * Fires before the splitter is dragged
33880 * @param {Roo.bootstrap.SplitBar} this
33882 "beforeresize" : true,
33884 "beforeapply" : true
33887 Roo.util.Observable.call(this);
33890 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33891 onStartProxyDrag : function(x, y){
33892 this.fireEvent("beforeresize", this);
33894 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33896 o.enableDisplayMode("block");
33897 // all splitbars share the same overlay
33898 Roo.bootstrap.SplitBar.prototype.overlay = o;
33900 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33901 this.overlay.show();
33902 Roo.get(this.proxy).setDisplayed("block");
33903 var size = this.adapter.getElementSize(this);
33904 this.activeMinSize = this.getMinimumSize();;
33905 this.activeMaxSize = this.getMaximumSize();;
33906 var c1 = size - this.activeMinSize;
33907 var c2 = Math.max(this.activeMaxSize - size, 0);
33908 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33909 this.dd.resetConstraints();
33910 this.dd.setXConstraint(
33911 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33912 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33914 this.dd.setYConstraint(0, 0);
33916 this.dd.resetConstraints();
33917 this.dd.setXConstraint(0, 0);
33918 this.dd.setYConstraint(
33919 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33920 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33923 this.dragSpecs.startSize = size;
33924 this.dragSpecs.startPoint = [x, y];
33925 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33929 * @private Called after the drag operation by the DDProxy
33931 onEndProxyDrag : function(e){
33932 Roo.get(this.proxy).setDisplayed(false);
33933 var endPoint = Roo.lib.Event.getXY(e);
33935 this.overlay.hide();
33938 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33939 newSize = this.dragSpecs.startSize +
33940 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33941 endPoint[0] - this.dragSpecs.startPoint[0] :
33942 this.dragSpecs.startPoint[0] - endPoint[0]
33945 newSize = this.dragSpecs.startSize +
33946 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33947 endPoint[1] - this.dragSpecs.startPoint[1] :
33948 this.dragSpecs.startPoint[1] - endPoint[1]
33951 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33952 if(newSize != this.dragSpecs.startSize){
33953 if(this.fireEvent('beforeapply', this, newSize) !== false){
33954 this.adapter.setElementSize(this, newSize);
33955 this.fireEvent("moved", this, newSize);
33956 this.fireEvent("resize", this, newSize);
33962 * Get the adapter this SplitBar uses
33963 * @return The adapter object
33965 getAdapter : function(){
33966 return this.adapter;
33970 * Set the adapter this SplitBar uses
33971 * @param {Object} adapter A SplitBar adapter object
33973 setAdapter : function(adapter){
33974 this.adapter = adapter;
33975 this.adapter.init(this);
33979 * Gets the minimum size for the resizing element
33980 * @return {Number} The minimum size
33982 getMinimumSize : function(){
33983 return this.minSize;
33987 * Sets the minimum size for the resizing element
33988 * @param {Number} minSize The minimum size
33990 setMinimumSize : function(minSize){
33991 this.minSize = minSize;
33995 * Gets the maximum size for the resizing element
33996 * @return {Number} The maximum size
33998 getMaximumSize : function(){
33999 return this.maxSize;
34003 * Sets the maximum size for the resizing element
34004 * @param {Number} maxSize The maximum size
34006 setMaximumSize : function(maxSize){
34007 this.maxSize = maxSize;
34011 * Sets the initialize size for the resizing element
34012 * @param {Number} size The initial size
34014 setCurrentSize : function(size){
34015 var oldAnimate = this.animate;
34016 this.animate = false;
34017 this.adapter.setElementSize(this, size);
34018 this.animate = oldAnimate;
34022 * Destroy this splitbar.
34023 * @param {Boolean} removeEl True to remove the element
34025 destroy : function(removeEl){
34027 this.shim.remove();
34030 this.proxy.parentNode.removeChild(this.proxy);
34038 * @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.
34040 Roo.bootstrap.SplitBar.createProxy = function(dir){
34041 var proxy = new Roo.Element(document.createElement("div"));
34042 proxy.unselectable();
34043 var cls = 'roo-splitbar-proxy';
34044 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34045 document.body.appendChild(proxy.dom);
34050 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34051 * Default Adapter. It assumes the splitter and resizing element are not positioned
34052 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34054 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34057 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34058 // do nothing for now
34059 init : function(s){
34063 * Called before drag operations to get the current size of the resizing element.
34064 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34066 getElementSize : function(s){
34067 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34068 return s.resizingEl.getWidth();
34070 return s.resizingEl.getHeight();
34075 * Called after drag operations to set the size of the resizing element.
34076 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34077 * @param {Number} newSize The new size to set
34078 * @param {Function} onComplete A function to be invoked when resizing is complete
34080 setElementSize : function(s, newSize, onComplete){
34081 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34083 s.resizingEl.setWidth(newSize);
34085 onComplete(s, newSize);
34088 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34093 s.resizingEl.setHeight(newSize);
34095 onComplete(s, newSize);
34098 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34105 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34106 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34107 * Adapter that moves the splitter element to align with the resized sizing element.
34108 * Used with an absolute positioned SplitBar.
34109 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34110 * document.body, make sure you assign an id to the body element.
34112 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34113 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34114 this.container = Roo.get(container);
34117 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34118 init : function(s){
34119 this.basic.init(s);
34122 getElementSize : function(s){
34123 return this.basic.getElementSize(s);
34126 setElementSize : function(s, newSize, onComplete){
34127 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34130 moveSplitter : function(s){
34131 var yes = Roo.bootstrap.SplitBar;
34132 switch(s.placement){
34134 s.el.setX(s.resizingEl.getRight());
34137 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34140 s.el.setY(s.resizingEl.getBottom());
34143 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34150 * Orientation constant - Create a vertical SplitBar
34154 Roo.bootstrap.SplitBar.VERTICAL = 1;
34157 * Orientation constant - Create a horizontal SplitBar
34161 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34164 * Placement constant - The resizing element is to the left of the splitter element
34168 Roo.bootstrap.SplitBar.LEFT = 1;
34171 * Placement constant - The resizing element is to the right of the splitter element
34175 Roo.bootstrap.SplitBar.RIGHT = 2;
34178 * Placement constant - The resizing element is positioned above the splitter element
34182 Roo.bootstrap.SplitBar.TOP = 3;
34185 * Placement constant - The resizing element is positioned under splitter element
34189 Roo.bootstrap.SplitBar.BOTTOM = 4;
34190 Roo.namespace("Roo.bootstrap.layout");/*
34192 * Ext JS Library 1.1.1
34193 * Copyright(c) 2006-2007, Ext JS, LLC.
34195 * Originally Released Under LGPL - original licence link has changed is not relivant.
34198 * <script type="text/javascript">
34202 * @class Roo.bootstrap.layout.Manager
34203 * @extends Roo.bootstrap.Component
34204 * Base class for layout managers.
34206 Roo.bootstrap.layout.Manager = function(config)
34208 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34214 /** false to disable window resize monitoring @type Boolean */
34215 this.monitorWindowResize = true;
34220 * Fires when a layout is performed.
34221 * @param {Roo.LayoutManager} this
34225 * @event regionresized
34226 * Fires when the user resizes a region.
34227 * @param {Roo.LayoutRegion} region The resized region
34228 * @param {Number} newSize The new size (width for east/west, height for north/south)
34230 "regionresized" : true,
34232 * @event regioncollapsed
34233 * Fires when a region is collapsed.
34234 * @param {Roo.LayoutRegion} region The collapsed region
34236 "regioncollapsed" : true,
34238 * @event regionexpanded
34239 * Fires when a region is expanded.
34240 * @param {Roo.LayoutRegion} region The expanded region
34242 "regionexpanded" : true
34244 this.updating = false;
34247 this.el = Roo.get(config.el);
34253 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34258 monitorWindowResize : true,
34264 onRender : function(ct, position)
34267 this.el = Roo.get(ct);
34270 //this.fireEvent('render',this);
34274 initEvents: function()
34278 // ie scrollbar fix
34279 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34280 document.body.scroll = "no";
34281 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34282 this.el.position('relative');
34284 this.id = this.el.id;
34285 this.el.addClass("roo-layout-container");
34286 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34287 if(this.el.dom != document.body ) {
34288 this.el.on('resize', this.layout,this);
34289 this.el.on('show', this.layout,this);
34295 * Returns true if this layout is currently being updated
34296 * @return {Boolean}
34298 isUpdating : function(){
34299 return this.updating;
34303 * Suspend the LayoutManager from doing auto-layouts while
34304 * making multiple add or remove calls
34306 beginUpdate : function(){
34307 this.updating = true;
34311 * Restore auto-layouts and optionally disable the manager from performing a layout
34312 * @param {Boolean} noLayout true to disable a layout update
34314 endUpdate : function(noLayout){
34315 this.updating = false;
34321 layout: function(){
34325 onRegionResized : function(region, newSize){
34326 this.fireEvent("regionresized", region, newSize);
34330 onRegionCollapsed : function(region){
34331 this.fireEvent("regioncollapsed", region);
34334 onRegionExpanded : function(region){
34335 this.fireEvent("regionexpanded", region);
34339 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34340 * performs box-model adjustments.
34341 * @return {Object} The size as an object {width: (the width), height: (the height)}
34343 getViewSize : function()
34346 if(this.el.dom != document.body){
34347 size = this.el.getSize();
34349 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34351 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34352 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34357 * Returns the Element this layout is bound to.
34358 * @return {Roo.Element}
34360 getEl : function(){
34365 * Returns the specified region.
34366 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34367 * @return {Roo.LayoutRegion}
34369 getRegion : function(target){
34370 return this.regions[target.toLowerCase()];
34373 onWindowResize : function(){
34374 if(this.monitorWindowResize){
34381 * Ext JS Library 1.1.1
34382 * Copyright(c) 2006-2007, Ext JS, LLC.
34384 * Originally Released Under LGPL - original licence link has changed is not relivant.
34387 * <script type="text/javascript">
34390 * @class Roo.bootstrap.layout.Border
34391 * @extends Roo.bootstrap.layout.Manager
34392 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34393 * please see: examples/bootstrap/nested.html<br><br>
34395 <b>The container the layout is rendered into can be either the body element or any other element.
34396 If it is not the body element, the container needs to either be an absolute positioned element,
34397 or you will need to add "position:relative" to the css of the container. You will also need to specify
34398 the container size if it is not the body element.</b>
34401 * Create a new Border
34402 * @param {Object} config Configuration options
34404 Roo.bootstrap.layout.Border = function(config){
34405 config = config || {};
34406 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34410 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34411 if(config[region]){
34412 config[region].region = region;
34413 this.addRegion(config[region]);
34419 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34421 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34423 * Creates and adds a new region if it doesn't already exist.
34424 * @param {String} target The target region key (north, south, east, west or center).
34425 * @param {Object} config The regions config object
34426 * @return {BorderLayoutRegion} The new region
34428 addRegion : function(config)
34430 if(!this.regions[config.region]){
34431 var r = this.factory(config);
34432 this.bindRegion(r);
34434 return this.regions[config.region];
34438 bindRegion : function(r){
34439 this.regions[r.config.region] = r;
34441 r.on("visibilitychange", this.layout, this);
34442 r.on("paneladded", this.layout, this);
34443 r.on("panelremoved", this.layout, this);
34444 r.on("invalidated", this.layout, this);
34445 r.on("resized", this.onRegionResized, this);
34446 r.on("collapsed", this.onRegionCollapsed, this);
34447 r.on("expanded", this.onRegionExpanded, this);
34451 * Performs a layout update.
34453 layout : function()
34455 if(this.updating) {
34459 // render all the rebions if they have not been done alreayd?
34460 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34461 if(this.regions[region] && !this.regions[region].bodyEl){
34462 this.regions[region].onRender(this.el)
34466 var size = this.getViewSize();
34467 var w = size.width;
34468 var h = size.height;
34473 //var x = 0, y = 0;
34475 var rs = this.regions;
34476 var north = rs["north"];
34477 var south = rs["south"];
34478 var west = rs["west"];
34479 var east = rs["east"];
34480 var center = rs["center"];
34481 //if(this.hideOnLayout){ // not supported anymore
34482 //c.el.setStyle("display", "none");
34484 if(north && north.isVisible()){
34485 var b = north.getBox();
34486 var m = north.getMargins();
34487 b.width = w - (m.left+m.right);
34490 centerY = b.height + b.y + m.bottom;
34491 centerH -= centerY;
34492 north.updateBox(this.safeBox(b));
34494 if(south && south.isVisible()){
34495 var b = south.getBox();
34496 var m = south.getMargins();
34497 b.width = w - (m.left+m.right);
34499 var totalHeight = (b.height + m.top + m.bottom);
34500 b.y = h - totalHeight + m.top;
34501 centerH -= totalHeight;
34502 south.updateBox(this.safeBox(b));
34504 if(west && west.isVisible()){
34505 var b = west.getBox();
34506 var m = west.getMargins();
34507 b.height = centerH - (m.top+m.bottom);
34509 b.y = centerY + m.top;
34510 var totalWidth = (b.width + m.left + m.right);
34511 centerX += totalWidth;
34512 centerW -= totalWidth;
34513 west.updateBox(this.safeBox(b));
34515 if(east && east.isVisible()){
34516 var b = east.getBox();
34517 var m = east.getMargins();
34518 b.height = centerH - (m.top+m.bottom);
34519 var totalWidth = (b.width + m.left + m.right);
34520 b.x = w - totalWidth + m.left;
34521 b.y = centerY + m.top;
34522 centerW -= totalWidth;
34523 east.updateBox(this.safeBox(b));
34526 var m = center.getMargins();
34528 x: centerX + m.left,
34529 y: centerY + m.top,
34530 width: centerW - (m.left+m.right),
34531 height: centerH - (m.top+m.bottom)
34533 //if(this.hideOnLayout){
34534 //center.el.setStyle("display", "block");
34536 center.updateBox(this.safeBox(centerBox));
34539 this.fireEvent("layout", this);
34543 safeBox : function(box){
34544 box.width = Math.max(0, box.width);
34545 box.height = Math.max(0, box.height);
34550 * Adds a ContentPanel (or subclass) to this layout.
34551 * @param {String} target The target region key (north, south, east, west or center).
34552 * @param {Roo.ContentPanel} panel The panel to add
34553 * @return {Roo.ContentPanel} The added panel
34555 add : function(target, panel){
34557 target = target.toLowerCase();
34558 return this.regions[target].add(panel);
34562 * Remove a ContentPanel (or subclass) to this layout.
34563 * @param {String} target The target region key (north, south, east, west or center).
34564 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34565 * @return {Roo.ContentPanel} The removed panel
34567 remove : function(target, panel){
34568 target = target.toLowerCase();
34569 return this.regions[target].remove(panel);
34573 * Searches all regions for a panel with the specified id
34574 * @param {String} panelId
34575 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34577 findPanel : function(panelId){
34578 var rs = this.regions;
34579 for(var target in rs){
34580 if(typeof rs[target] != "function"){
34581 var p = rs[target].getPanel(panelId);
34591 * Searches all regions for a panel with the specified id and activates (shows) it.
34592 * @param {String/ContentPanel} panelId The panels id or the panel itself
34593 * @return {Roo.ContentPanel} The shown panel or null
34595 showPanel : function(panelId) {
34596 var rs = this.regions;
34597 for(var target in rs){
34598 var r = rs[target];
34599 if(typeof r != "function"){
34600 if(r.hasPanel(panelId)){
34601 return r.showPanel(panelId);
34609 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34610 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34613 restoreState : function(provider){
34615 provider = Roo.state.Manager;
34617 var sm = new Roo.LayoutStateManager();
34618 sm.init(this, provider);
34624 * Adds a xtype elements to the layout.
34628 xtype : 'ContentPanel',
34635 xtype : 'NestedLayoutPanel',
34641 items : [ ... list of content panels or nested layout panels.. ]
34645 * @param {Object} cfg Xtype definition of item to add.
34647 addxtype : function(cfg)
34649 // basically accepts a pannel...
34650 // can accept a layout region..!?!?
34651 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34654 // theory? children can only be panels??
34656 //if (!cfg.xtype.match(/Panel$/)) {
34661 if (typeof(cfg.region) == 'undefined') {
34662 Roo.log("Failed to add Panel, region was not set");
34666 var region = cfg.region;
34672 xitems = cfg.items;
34679 case 'Content': // ContentPanel (el, cfg)
34680 case 'Scroll': // ContentPanel (el, cfg)
34682 cfg.autoCreate = true;
34683 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34685 // var el = this.el.createChild();
34686 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34689 this.add(region, ret);
34693 case 'TreePanel': // our new panel!
34694 cfg.el = this.el.createChild();
34695 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34696 this.add(region, ret);
34701 // create a new Layout (which is a Border Layout...
34703 var clayout = cfg.layout;
34704 clayout.el = this.el.createChild();
34705 clayout.items = clayout.items || [];
34709 // replace this exitems with the clayout ones..
34710 xitems = clayout.items;
34712 // force background off if it's in center...
34713 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34714 cfg.background = false;
34716 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34719 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34720 //console.log('adding nested layout panel ' + cfg.toSource());
34721 this.add(region, ret);
34722 nb = {}; /// find first...
34727 // needs grid and region
34729 //var el = this.getRegion(region).el.createChild();
34731 *var el = this.el.createChild();
34732 // create the grid first...
34733 cfg.grid.container = el;
34734 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34737 if (region == 'center' && this.active ) {
34738 cfg.background = false;
34741 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34743 this.add(region, ret);
34745 if (cfg.background) {
34746 // render grid on panel activation (if panel background)
34747 ret.on('activate', function(gp) {
34748 if (!gp.grid.rendered) {
34749 // gp.grid.render(el);
34753 // cfg.grid.render(el);
34759 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34760 // it was the old xcomponent building that caused this before.
34761 // espeically if border is the top element in the tree.
34771 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34773 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34774 this.add(region, ret);
34778 throw "Can not add '" + cfg.xtype + "' to Border";
34784 this.beginUpdate();
34788 Roo.each(xitems, function(i) {
34789 region = nb && i.region ? i.region : false;
34791 var add = ret.addxtype(i);
34794 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34795 if (!i.background) {
34796 abn[region] = nb[region] ;
34803 // make the last non-background panel active..
34804 //if (nb) { Roo.log(abn); }
34807 for(var r in abn) {
34808 region = this.getRegion(r);
34810 // tried using nb[r], but it does not work..
34812 region.showPanel(abn[r]);
34823 factory : function(cfg)
34826 var validRegions = Roo.bootstrap.layout.Border.regions;
34828 var target = cfg.region;
34831 var r = Roo.bootstrap.layout;
34835 return new r.North(cfg);
34837 return new r.South(cfg);
34839 return new r.East(cfg);
34841 return new r.West(cfg);
34843 return new r.Center(cfg);
34845 throw 'Layout region "'+target+'" not supported.';
34852 * Ext JS Library 1.1.1
34853 * Copyright(c) 2006-2007, Ext JS, LLC.
34855 * Originally Released Under LGPL - original licence link has changed is not relivant.
34858 * <script type="text/javascript">
34862 * @class Roo.bootstrap.layout.Basic
34863 * @extends Roo.util.Observable
34864 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34865 * and does not have a titlebar, tabs or any other features. All it does is size and position
34866 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34867 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34868 * @cfg {string} region the region that it inhabits..
34869 * @cfg {bool} skipConfig skip config?
34873 Roo.bootstrap.layout.Basic = function(config){
34875 this.mgr = config.mgr;
34877 this.position = config.region;
34879 var skipConfig = config.skipConfig;
34883 * @scope Roo.BasicLayoutRegion
34887 * @event beforeremove
34888 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34889 * @param {Roo.LayoutRegion} this
34890 * @param {Roo.ContentPanel} panel The panel
34891 * @param {Object} e The cancel event object
34893 "beforeremove" : true,
34895 * @event invalidated
34896 * Fires when the layout for this region is changed.
34897 * @param {Roo.LayoutRegion} this
34899 "invalidated" : true,
34901 * @event visibilitychange
34902 * Fires when this region is shown or hidden
34903 * @param {Roo.LayoutRegion} this
34904 * @param {Boolean} visibility true or false
34906 "visibilitychange" : true,
34908 * @event paneladded
34909 * Fires when a panel is added.
34910 * @param {Roo.LayoutRegion} this
34911 * @param {Roo.ContentPanel} panel The panel
34913 "paneladded" : true,
34915 * @event panelremoved
34916 * Fires when a panel is removed.
34917 * @param {Roo.LayoutRegion} this
34918 * @param {Roo.ContentPanel} panel The panel
34920 "panelremoved" : true,
34922 * @event beforecollapse
34923 * Fires when this region before collapse.
34924 * @param {Roo.LayoutRegion} this
34926 "beforecollapse" : true,
34929 * Fires when this region is collapsed.
34930 * @param {Roo.LayoutRegion} this
34932 "collapsed" : true,
34935 * Fires when this region is expanded.
34936 * @param {Roo.LayoutRegion} this
34941 * Fires when this region is slid into view.
34942 * @param {Roo.LayoutRegion} this
34944 "slideshow" : true,
34947 * Fires when this region slides out of view.
34948 * @param {Roo.LayoutRegion} this
34950 "slidehide" : true,
34952 * @event panelactivated
34953 * Fires when a panel is activated.
34954 * @param {Roo.LayoutRegion} this
34955 * @param {Roo.ContentPanel} panel The activated panel
34957 "panelactivated" : true,
34960 * Fires when the user resizes this region.
34961 * @param {Roo.LayoutRegion} this
34962 * @param {Number} newSize The new size (width for east/west, height for north/south)
34966 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34967 this.panels = new Roo.util.MixedCollection();
34968 this.panels.getKey = this.getPanelId.createDelegate(this);
34970 this.activePanel = null;
34971 // ensure listeners are added...
34973 if (config.listeners || config.events) {
34974 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34975 listeners : config.listeners || {},
34976 events : config.events || {}
34980 if(skipConfig !== true){
34981 this.applyConfig(config);
34985 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34987 getPanelId : function(p){
34991 applyConfig : function(config){
34992 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34993 this.config = config;
34998 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34999 * the width, for horizontal (north, south) the height.
35000 * @param {Number} newSize The new width or height
35002 resizeTo : function(newSize){
35003 var el = this.el ? this.el :
35004 (this.activePanel ? this.activePanel.getEl() : null);
35006 switch(this.position){
35009 el.setWidth(newSize);
35010 this.fireEvent("resized", this, newSize);
35014 el.setHeight(newSize);
35015 this.fireEvent("resized", this, newSize);
35021 getBox : function(){
35022 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35025 getMargins : function(){
35026 return this.margins;
35029 updateBox : function(box){
35031 var el = this.activePanel.getEl();
35032 el.dom.style.left = box.x + "px";
35033 el.dom.style.top = box.y + "px";
35034 this.activePanel.setSize(box.width, box.height);
35038 * Returns the container element for this region.
35039 * @return {Roo.Element}
35041 getEl : function(){
35042 return this.activePanel;
35046 * Returns true if this region is currently visible.
35047 * @return {Boolean}
35049 isVisible : function(){
35050 return this.activePanel ? true : false;
35053 setActivePanel : function(panel){
35054 panel = this.getPanel(panel);
35055 if(this.activePanel && this.activePanel != panel){
35056 this.activePanel.setActiveState(false);
35057 this.activePanel.getEl().setLeftTop(-10000,-10000);
35059 this.activePanel = panel;
35060 panel.setActiveState(true);
35062 panel.setSize(this.box.width, this.box.height);
35064 this.fireEvent("panelactivated", this, panel);
35065 this.fireEvent("invalidated");
35069 * Show the specified panel.
35070 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35071 * @return {Roo.ContentPanel} The shown panel or null
35073 showPanel : function(panel){
35074 panel = this.getPanel(panel);
35076 this.setActivePanel(panel);
35082 * Get the active panel for this region.
35083 * @return {Roo.ContentPanel} The active panel or null
35085 getActivePanel : function(){
35086 return this.activePanel;
35090 * Add the passed ContentPanel(s)
35091 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35092 * @return {Roo.ContentPanel} The panel added (if only one was added)
35094 add : function(panel){
35095 if(arguments.length > 1){
35096 for(var i = 0, len = arguments.length; i < len; i++) {
35097 this.add(arguments[i]);
35101 if(this.hasPanel(panel)){
35102 this.showPanel(panel);
35105 var el = panel.getEl();
35106 if(el.dom.parentNode != this.mgr.el.dom){
35107 this.mgr.el.dom.appendChild(el.dom);
35109 if(panel.setRegion){
35110 panel.setRegion(this);
35112 this.panels.add(panel);
35113 el.setStyle("position", "absolute");
35114 if(!panel.background){
35115 this.setActivePanel(panel);
35116 if(this.config.initialSize && this.panels.getCount()==1){
35117 this.resizeTo(this.config.initialSize);
35120 this.fireEvent("paneladded", this, panel);
35125 * Returns true if the panel is in this region.
35126 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35127 * @return {Boolean}
35129 hasPanel : function(panel){
35130 if(typeof panel == "object"){ // must be panel obj
35131 panel = panel.getId();
35133 return this.getPanel(panel) ? true : false;
35137 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35138 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35139 * @param {Boolean} preservePanel Overrides the config preservePanel option
35140 * @return {Roo.ContentPanel} The panel that was removed
35142 remove : function(panel, preservePanel){
35143 panel = this.getPanel(panel);
35148 this.fireEvent("beforeremove", this, panel, e);
35149 if(e.cancel === true){
35152 var panelId = panel.getId();
35153 this.panels.removeKey(panelId);
35158 * Returns the panel specified or null if it's not in this region.
35159 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35160 * @return {Roo.ContentPanel}
35162 getPanel : function(id){
35163 if(typeof id == "object"){ // must be panel obj
35166 return this.panels.get(id);
35170 * Returns this regions position (north/south/east/west/center).
35173 getPosition: function(){
35174 return this.position;
35178 * Ext JS Library 1.1.1
35179 * Copyright(c) 2006-2007, Ext JS, LLC.
35181 * Originally Released Under LGPL - original licence link has changed is not relivant.
35184 * <script type="text/javascript">
35188 * @class Roo.bootstrap.layout.Region
35189 * @extends Roo.bootstrap.layout.Basic
35190 * This class represents a region in a layout manager.
35192 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35193 * @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})
35194 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35195 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35196 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35197 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35198 * @cfg {String} title The title for the region (overrides panel titles)
35199 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35200 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35201 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35202 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35203 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35204 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35205 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35206 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35207 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35208 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35210 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35211 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35212 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35213 * @cfg {Number} width For East/West panels
35214 * @cfg {Number} height For North/South panels
35215 * @cfg {Boolean} split To show the splitter
35216 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35218 * @cfg {string} cls Extra CSS classes to add to region
35220 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35221 * @cfg {string} region the region that it inhabits..
35224 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35225 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35227 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35228 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35229 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35231 Roo.bootstrap.layout.Region = function(config)
35233 this.applyConfig(config);
35235 var mgr = config.mgr;
35236 var pos = config.region;
35237 config.skipConfig = true;
35238 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35241 this.onRender(mgr.el);
35244 this.visible = true;
35245 this.collapsed = false;
35246 this.unrendered_panels = [];
35249 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35251 position: '', // set by wrapper (eg. north/south etc..)
35252 unrendered_panels : null, // unrendered panels.
35253 createBody : function(){
35254 /** This region's body element
35255 * @type Roo.Element */
35256 this.bodyEl = this.el.createChild({
35258 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35262 onRender: function(ctr, pos)
35264 var dh = Roo.DomHelper;
35265 /** This region's container element
35266 * @type Roo.Element */
35267 this.el = dh.append(ctr.dom, {
35269 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35271 /** This region's title element
35272 * @type Roo.Element */
35274 this.titleEl = dh.append(this.el.dom,
35277 unselectable: "on",
35278 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35280 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35281 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35284 this.titleEl.enableDisplayMode();
35285 /** This region's title text element
35286 * @type HTMLElement */
35287 this.titleTextEl = this.titleEl.dom.firstChild;
35288 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35290 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35291 this.closeBtn.enableDisplayMode();
35292 this.closeBtn.on("click", this.closeClicked, this);
35293 this.closeBtn.hide();
35295 this.createBody(this.config);
35296 if(this.config.hideWhenEmpty){
35298 this.on("paneladded", this.validateVisibility, this);
35299 this.on("panelremoved", this.validateVisibility, this);
35301 if(this.autoScroll){
35302 this.bodyEl.setStyle("overflow", "auto");
35304 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35306 //if(c.titlebar !== false){
35307 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35308 this.titleEl.hide();
35310 this.titleEl.show();
35311 if(this.config.title){
35312 this.titleTextEl.innerHTML = this.config.title;
35316 if(this.config.collapsed){
35317 this.collapse(true);
35319 if(this.config.hidden){
35323 if (this.unrendered_panels && this.unrendered_panels.length) {
35324 for (var i =0;i< this.unrendered_panels.length; i++) {
35325 this.add(this.unrendered_panels[i]);
35327 this.unrendered_panels = null;
35333 applyConfig : function(c)
35336 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35337 var dh = Roo.DomHelper;
35338 if(c.titlebar !== false){
35339 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35340 this.collapseBtn.on("click", this.collapse, this);
35341 this.collapseBtn.enableDisplayMode();
35343 if(c.showPin === true || this.showPin){
35344 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35345 this.stickBtn.enableDisplayMode();
35346 this.stickBtn.on("click", this.expand, this);
35347 this.stickBtn.hide();
35352 /** This region's collapsed element
35353 * @type Roo.Element */
35356 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35357 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35360 if(c.floatable !== false){
35361 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35362 this.collapsedEl.on("click", this.collapseClick, this);
35365 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35366 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35367 id: "message", unselectable: "on", style:{"float":"left"}});
35368 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35370 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35371 this.expandBtn.on("click", this.expand, this);
35375 if(this.collapseBtn){
35376 this.collapseBtn.setVisible(c.collapsible == true);
35379 this.cmargins = c.cmargins || this.cmargins ||
35380 (this.position == "west" || this.position == "east" ?
35381 {top: 0, left: 2, right:2, bottom: 0} :
35382 {top: 2, left: 0, right:0, bottom: 2});
35384 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35387 this.bottomTabs = c.tabPosition != "top";
35389 this.autoScroll = c.autoScroll || false;
35394 this.duration = c.duration || .30;
35395 this.slideDuration = c.slideDuration || .45;
35400 * Returns true if this region is currently visible.
35401 * @return {Boolean}
35403 isVisible : function(){
35404 return this.visible;
35408 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35409 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35411 //setCollapsedTitle : function(title){
35412 // title = title || " ";
35413 // if(this.collapsedTitleTextEl){
35414 // this.collapsedTitleTextEl.innerHTML = title;
35418 getBox : function(){
35420 // if(!this.collapsed){
35421 b = this.el.getBox(false, true);
35423 // b = this.collapsedEl.getBox(false, true);
35428 getMargins : function(){
35429 return this.margins;
35430 //return this.collapsed ? this.cmargins : this.margins;
35433 highlight : function(){
35434 this.el.addClass("x-layout-panel-dragover");
35437 unhighlight : function(){
35438 this.el.removeClass("x-layout-panel-dragover");
35441 updateBox : function(box)
35443 if (!this.bodyEl) {
35444 return; // not rendered yet..
35448 if(!this.collapsed){
35449 this.el.dom.style.left = box.x + "px";
35450 this.el.dom.style.top = box.y + "px";
35451 this.updateBody(box.width, box.height);
35453 this.collapsedEl.dom.style.left = box.x + "px";
35454 this.collapsedEl.dom.style.top = box.y + "px";
35455 this.collapsedEl.setSize(box.width, box.height);
35458 this.tabs.autoSizeTabs();
35462 updateBody : function(w, h)
35465 this.el.setWidth(w);
35466 w -= this.el.getBorderWidth("rl");
35467 if(this.config.adjustments){
35468 w += this.config.adjustments[0];
35471 if(h !== null && h > 0){
35472 this.el.setHeight(h);
35473 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35474 h -= this.el.getBorderWidth("tb");
35475 if(this.config.adjustments){
35476 h += this.config.adjustments[1];
35478 this.bodyEl.setHeight(h);
35480 h = this.tabs.syncHeight(h);
35483 if(this.panelSize){
35484 w = w !== null ? w : this.panelSize.width;
35485 h = h !== null ? h : this.panelSize.height;
35487 if(this.activePanel){
35488 var el = this.activePanel.getEl();
35489 w = w !== null ? w : el.getWidth();
35490 h = h !== null ? h : el.getHeight();
35491 this.panelSize = {width: w, height: h};
35492 this.activePanel.setSize(w, h);
35494 if(Roo.isIE && this.tabs){
35495 this.tabs.el.repaint();
35500 * Returns the container element for this region.
35501 * @return {Roo.Element}
35503 getEl : function(){
35508 * Hides this region.
35511 //if(!this.collapsed){
35512 this.el.dom.style.left = "-2000px";
35515 // this.collapsedEl.dom.style.left = "-2000px";
35516 // this.collapsedEl.hide();
35518 this.visible = false;
35519 this.fireEvent("visibilitychange", this, false);
35523 * Shows this region if it was previously hidden.
35526 //if(!this.collapsed){
35529 // this.collapsedEl.show();
35531 this.visible = true;
35532 this.fireEvent("visibilitychange", this, true);
35535 closeClicked : function(){
35536 if(this.activePanel){
35537 this.remove(this.activePanel);
35541 collapseClick : function(e){
35543 e.stopPropagation();
35546 e.stopPropagation();
35552 * Collapses this region.
35553 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35556 collapse : function(skipAnim, skipCheck = false){
35557 if(this.collapsed) {
35561 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35563 this.collapsed = true;
35565 this.split.el.hide();
35567 if(this.config.animate && skipAnim !== true){
35568 this.fireEvent("invalidated", this);
35569 this.animateCollapse();
35571 this.el.setLocation(-20000,-20000);
35573 this.collapsedEl.show();
35574 this.fireEvent("collapsed", this);
35575 this.fireEvent("invalidated", this);
35581 animateCollapse : function(){
35586 * Expands this region if it was previously collapsed.
35587 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35588 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35591 expand : function(e, skipAnim){
35593 e.stopPropagation();
35595 if(!this.collapsed || this.el.hasActiveFx()) {
35599 this.afterSlideIn();
35602 this.collapsed = false;
35603 if(this.config.animate && skipAnim !== true){
35604 this.animateExpand();
35608 this.split.el.show();
35610 this.collapsedEl.setLocation(-2000,-2000);
35611 this.collapsedEl.hide();
35612 this.fireEvent("invalidated", this);
35613 this.fireEvent("expanded", this);
35617 animateExpand : function(){
35621 initTabs : function()
35623 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35625 var ts = new Roo.bootstrap.panel.Tabs({
35626 el: this.bodyEl.dom,
35627 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35628 disableTooltips: this.config.disableTabTips,
35629 toolbar : this.config.toolbar
35632 if(this.config.hideTabs){
35633 ts.stripWrap.setDisplayed(false);
35636 ts.resizeTabs = this.config.resizeTabs === true;
35637 ts.minTabWidth = this.config.minTabWidth || 40;
35638 ts.maxTabWidth = this.config.maxTabWidth || 250;
35639 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35640 ts.monitorResize = false;
35641 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35642 ts.bodyEl.addClass('roo-layout-tabs-body');
35643 this.panels.each(this.initPanelAsTab, this);
35646 initPanelAsTab : function(panel){
35647 var ti = this.tabs.addTab(
35651 this.config.closeOnTab && panel.isClosable(),
35654 if(panel.tabTip !== undefined){
35655 ti.setTooltip(panel.tabTip);
35657 ti.on("activate", function(){
35658 this.setActivePanel(panel);
35661 if(this.config.closeOnTab){
35662 ti.on("beforeclose", function(t, e){
35664 this.remove(panel);
35668 panel.tabItem = ti;
35673 updatePanelTitle : function(panel, title)
35675 if(this.activePanel == panel){
35676 this.updateTitle(title);
35679 var ti = this.tabs.getTab(panel.getEl().id);
35681 if(panel.tabTip !== undefined){
35682 ti.setTooltip(panel.tabTip);
35687 updateTitle : function(title){
35688 if(this.titleTextEl && !this.config.title){
35689 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35693 setActivePanel : function(panel)
35695 panel = this.getPanel(panel);
35696 if(this.activePanel && this.activePanel != panel){
35697 if(this.activePanel.setActiveState(false) === false){
35701 this.activePanel = panel;
35702 panel.setActiveState(true);
35703 if(this.panelSize){
35704 panel.setSize(this.panelSize.width, this.panelSize.height);
35707 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35709 this.updateTitle(panel.getTitle());
35711 this.fireEvent("invalidated", this);
35713 this.fireEvent("panelactivated", this, panel);
35717 * Shows the specified panel.
35718 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35719 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35721 showPanel : function(panel)
35723 panel = this.getPanel(panel);
35726 var tab = this.tabs.getTab(panel.getEl().id);
35727 if(tab.isHidden()){
35728 this.tabs.unhideTab(tab.id);
35732 this.setActivePanel(panel);
35739 * Get the active panel for this region.
35740 * @return {Roo.ContentPanel} The active panel or null
35742 getActivePanel : function(){
35743 return this.activePanel;
35746 validateVisibility : function(){
35747 if(this.panels.getCount() < 1){
35748 this.updateTitle(" ");
35749 this.closeBtn.hide();
35752 if(!this.isVisible()){
35759 * Adds the passed ContentPanel(s) to this region.
35760 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35761 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35763 add : function(panel)
35765 if(arguments.length > 1){
35766 for(var i = 0, len = arguments.length; i < len; i++) {
35767 this.add(arguments[i]);
35772 // if we have not been rendered yet, then we can not really do much of this..
35773 if (!this.bodyEl) {
35774 this.unrendered_panels.push(panel);
35781 if(this.hasPanel(panel)){
35782 this.showPanel(panel);
35785 panel.setRegion(this);
35786 this.panels.add(panel);
35787 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35788 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35789 // and hide them... ???
35790 this.bodyEl.dom.appendChild(panel.getEl().dom);
35791 if(panel.background !== true){
35792 this.setActivePanel(panel);
35794 this.fireEvent("paneladded", this, panel);
35801 this.initPanelAsTab(panel);
35805 if(panel.background !== true){
35806 this.tabs.activate(panel.getEl().id);
35808 this.fireEvent("paneladded", this, panel);
35813 * Hides the tab for the specified panel.
35814 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35816 hidePanel : function(panel){
35817 if(this.tabs && (panel = this.getPanel(panel))){
35818 this.tabs.hideTab(panel.getEl().id);
35823 * Unhides the tab for a previously hidden panel.
35824 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35826 unhidePanel : function(panel){
35827 if(this.tabs && (panel = this.getPanel(panel))){
35828 this.tabs.unhideTab(panel.getEl().id);
35832 clearPanels : function(){
35833 while(this.panels.getCount() > 0){
35834 this.remove(this.panels.first());
35839 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35840 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35841 * @param {Boolean} preservePanel Overrides the config preservePanel option
35842 * @return {Roo.ContentPanel} The panel that was removed
35844 remove : function(panel, preservePanel)
35846 panel = this.getPanel(panel);
35851 this.fireEvent("beforeremove", this, panel, e);
35852 if(e.cancel === true){
35855 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35856 var panelId = panel.getId();
35857 this.panels.removeKey(panelId);
35859 document.body.appendChild(panel.getEl().dom);
35862 this.tabs.removeTab(panel.getEl().id);
35863 }else if (!preservePanel){
35864 this.bodyEl.dom.removeChild(panel.getEl().dom);
35866 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35867 var p = this.panels.first();
35868 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35869 tempEl.appendChild(p.getEl().dom);
35870 this.bodyEl.update("");
35871 this.bodyEl.dom.appendChild(p.getEl().dom);
35873 this.updateTitle(p.getTitle());
35875 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35876 this.setActivePanel(p);
35878 panel.setRegion(null);
35879 if(this.activePanel == panel){
35880 this.activePanel = null;
35882 if(this.config.autoDestroy !== false && preservePanel !== true){
35883 try{panel.destroy();}catch(e){}
35885 this.fireEvent("panelremoved", this, panel);
35890 * Returns the TabPanel component used by this region
35891 * @return {Roo.TabPanel}
35893 getTabs : function(){
35897 createTool : function(parentEl, className){
35898 var btn = Roo.DomHelper.append(parentEl, {
35900 cls: "x-layout-tools-button",
35903 cls: "roo-layout-tools-button-inner " + className,
35907 btn.addClassOnOver("roo-layout-tools-button-over");
35912 * Ext JS Library 1.1.1
35913 * Copyright(c) 2006-2007, Ext JS, LLC.
35915 * Originally Released Under LGPL - original licence link has changed is not relivant.
35918 * <script type="text/javascript">
35924 * @class Roo.SplitLayoutRegion
35925 * @extends Roo.LayoutRegion
35926 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35928 Roo.bootstrap.layout.Split = function(config){
35929 this.cursor = config.cursor;
35930 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35933 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35935 splitTip : "Drag to resize.",
35936 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35937 useSplitTips : false,
35939 applyConfig : function(config){
35940 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35943 onRender : function(ctr,pos) {
35945 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35946 if(!this.config.split){
35951 var splitEl = Roo.DomHelper.append(ctr.dom, {
35953 id: this.el.id + "-split",
35954 cls: "roo-layout-split roo-layout-split-"+this.position,
35957 /** The SplitBar for this region
35958 * @type Roo.SplitBar */
35959 // does not exist yet...
35960 Roo.log([this.position, this.orientation]);
35962 this.split = new Roo.bootstrap.SplitBar({
35963 dragElement : splitEl,
35964 resizingElement: this.el,
35965 orientation : this.orientation
35968 this.split.on("moved", this.onSplitMove, this);
35969 this.split.useShim = this.config.useShim === true;
35970 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35971 if(this.useSplitTips){
35972 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35974 //if(config.collapsible){
35975 // this.split.el.on("dblclick", this.collapse, this);
35978 if(typeof this.config.minSize != "undefined"){
35979 this.split.minSize = this.config.minSize;
35981 if(typeof this.config.maxSize != "undefined"){
35982 this.split.maxSize = this.config.maxSize;
35984 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35985 this.hideSplitter();
35990 getHMaxSize : function(){
35991 var cmax = this.config.maxSize || 10000;
35992 var center = this.mgr.getRegion("center");
35993 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35996 getVMaxSize : function(){
35997 var cmax = this.config.maxSize || 10000;
35998 var center = this.mgr.getRegion("center");
35999 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36002 onSplitMove : function(split, newSize){
36003 this.fireEvent("resized", this, newSize);
36007 * Returns the {@link Roo.SplitBar} for this region.
36008 * @return {Roo.SplitBar}
36010 getSplitBar : function(){
36015 this.hideSplitter();
36016 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36019 hideSplitter : function(){
36021 this.split.el.setLocation(-2000,-2000);
36022 this.split.el.hide();
36028 this.split.el.show();
36030 Roo.bootstrap.layout.Split.superclass.show.call(this);
36033 beforeSlide: function(){
36034 if(Roo.isGecko){// firefox overflow auto bug workaround
36035 this.bodyEl.clip();
36037 this.tabs.bodyEl.clip();
36039 if(this.activePanel){
36040 this.activePanel.getEl().clip();
36042 if(this.activePanel.beforeSlide){
36043 this.activePanel.beforeSlide();
36049 afterSlide : function(){
36050 if(Roo.isGecko){// firefox overflow auto bug workaround
36051 this.bodyEl.unclip();
36053 this.tabs.bodyEl.unclip();
36055 if(this.activePanel){
36056 this.activePanel.getEl().unclip();
36057 if(this.activePanel.afterSlide){
36058 this.activePanel.afterSlide();
36064 initAutoHide : function(){
36065 if(this.autoHide !== false){
36066 if(!this.autoHideHd){
36067 var st = new Roo.util.DelayedTask(this.slideIn, this);
36068 this.autoHideHd = {
36069 "mouseout": function(e){
36070 if(!e.within(this.el, true)){
36074 "mouseover" : function(e){
36080 this.el.on(this.autoHideHd);
36084 clearAutoHide : function(){
36085 if(this.autoHide !== false){
36086 this.el.un("mouseout", this.autoHideHd.mouseout);
36087 this.el.un("mouseover", this.autoHideHd.mouseover);
36091 clearMonitor : function(){
36092 Roo.get(document).un("click", this.slideInIf, this);
36095 // these names are backwards but not changed for compat
36096 slideOut : function(){
36097 if(this.isSlid || this.el.hasActiveFx()){
36100 this.isSlid = true;
36101 if(this.collapseBtn){
36102 this.collapseBtn.hide();
36104 this.closeBtnState = this.closeBtn.getStyle('display');
36105 this.closeBtn.hide();
36107 this.stickBtn.show();
36110 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36111 this.beforeSlide();
36112 this.el.setStyle("z-index", 10001);
36113 this.el.slideIn(this.getSlideAnchor(), {
36114 callback: function(){
36116 this.initAutoHide();
36117 Roo.get(document).on("click", this.slideInIf, this);
36118 this.fireEvent("slideshow", this);
36125 afterSlideIn : function(){
36126 this.clearAutoHide();
36127 this.isSlid = false;
36128 this.clearMonitor();
36129 this.el.setStyle("z-index", "");
36130 if(this.collapseBtn){
36131 this.collapseBtn.show();
36133 this.closeBtn.setStyle('display', this.closeBtnState);
36135 this.stickBtn.hide();
36137 this.fireEvent("slidehide", this);
36140 slideIn : function(cb){
36141 if(!this.isSlid || this.el.hasActiveFx()){
36145 this.isSlid = false;
36146 this.beforeSlide();
36147 this.el.slideOut(this.getSlideAnchor(), {
36148 callback: function(){
36149 this.el.setLeftTop(-10000, -10000);
36151 this.afterSlideIn();
36159 slideInIf : function(e){
36160 if(!e.within(this.el)){
36165 animateCollapse : function(){
36166 this.beforeSlide();
36167 this.el.setStyle("z-index", 20000);
36168 var anchor = this.getSlideAnchor();
36169 this.el.slideOut(anchor, {
36170 callback : function(){
36171 this.el.setStyle("z-index", "");
36172 this.collapsedEl.slideIn(anchor, {duration:.3});
36174 this.el.setLocation(-10000,-10000);
36176 this.fireEvent("collapsed", this);
36183 animateExpand : function(){
36184 this.beforeSlide();
36185 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36186 this.el.setStyle("z-index", 20000);
36187 this.collapsedEl.hide({
36190 this.el.slideIn(this.getSlideAnchor(), {
36191 callback : function(){
36192 this.el.setStyle("z-index", "");
36195 this.split.el.show();
36197 this.fireEvent("invalidated", this);
36198 this.fireEvent("expanded", this);
36226 getAnchor : function(){
36227 return this.anchors[this.position];
36230 getCollapseAnchor : function(){
36231 return this.canchors[this.position];
36234 getSlideAnchor : function(){
36235 return this.sanchors[this.position];
36238 getAlignAdj : function(){
36239 var cm = this.cmargins;
36240 switch(this.position){
36256 getExpandAdj : function(){
36257 var c = this.collapsedEl, cm = this.cmargins;
36258 switch(this.position){
36260 return [-(cm.right+c.getWidth()+cm.left), 0];
36263 return [cm.right+c.getWidth()+cm.left, 0];
36266 return [0, -(cm.top+cm.bottom+c.getHeight())];
36269 return [0, cm.top+cm.bottom+c.getHeight()];
36275 * Ext JS Library 1.1.1
36276 * Copyright(c) 2006-2007, Ext JS, LLC.
36278 * Originally Released Under LGPL - original licence link has changed is not relivant.
36281 * <script type="text/javascript">
36284 * These classes are private internal classes
36286 Roo.bootstrap.layout.Center = function(config){
36287 config.region = "center";
36288 Roo.bootstrap.layout.Region.call(this, config);
36289 this.visible = true;
36290 this.minWidth = config.minWidth || 20;
36291 this.minHeight = config.minHeight || 20;
36294 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36296 // center panel can't be hidden
36300 // center panel can't be hidden
36303 getMinWidth: function(){
36304 return this.minWidth;
36307 getMinHeight: function(){
36308 return this.minHeight;
36321 Roo.bootstrap.layout.North = function(config)
36323 config.region = 'north';
36324 config.cursor = 'n-resize';
36326 Roo.bootstrap.layout.Split.call(this, config);
36330 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36331 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36332 this.split.el.addClass("roo-layout-split-v");
36334 var size = config.initialSize || config.height;
36335 if(typeof size != "undefined"){
36336 this.el.setHeight(size);
36339 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36341 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36345 getBox : function(){
36346 if(this.collapsed){
36347 return this.collapsedEl.getBox();
36349 var box = this.el.getBox();
36351 box.height += this.split.el.getHeight();
36356 updateBox : function(box){
36357 if(this.split && !this.collapsed){
36358 box.height -= this.split.el.getHeight();
36359 this.split.el.setLeft(box.x);
36360 this.split.el.setTop(box.y+box.height);
36361 this.split.el.setWidth(box.width);
36363 if(this.collapsed){
36364 this.updateBody(box.width, null);
36366 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36374 Roo.bootstrap.layout.South = function(config){
36375 config.region = 'south';
36376 config.cursor = 's-resize';
36377 Roo.bootstrap.layout.Split.call(this, config);
36379 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36380 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36381 this.split.el.addClass("roo-layout-split-v");
36383 var size = config.initialSize || config.height;
36384 if(typeof size != "undefined"){
36385 this.el.setHeight(size);
36389 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36390 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36391 getBox : function(){
36392 if(this.collapsed){
36393 return this.collapsedEl.getBox();
36395 var box = this.el.getBox();
36397 var sh = this.split.el.getHeight();
36404 updateBox : function(box){
36405 if(this.split && !this.collapsed){
36406 var sh = this.split.el.getHeight();
36409 this.split.el.setLeft(box.x);
36410 this.split.el.setTop(box.y-sh);
36411 this.split.el.setWidth(box.width);
36413 if(this.collapsed){
36414 this.updateBody(box.width, null);
36416 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36420 Roo.bootstrap.layout.East = function(config){
36421 config.region = "east";
36422 config.cursor = "e-resize";
36423 Roo.bootstrap.layout.Split.call(this, config);
36425 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36426 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36427 this.split.el.addClass("roo-layout-split-h");
36429 var size = config.initialSize || config.width;
36430 if(typeof size != "undefined"){
36431 this.el.setWidth(size);
36434 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36435 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36436 getBox : function(){
36437 if(this.collapsed){
36438 return this.collapsedEl.getBox();
36440 var box = this.el.getBox();
36442 var sw = this.split.el.getWidth();
36449 updateBox : function(box){
36450 if(this.split && !this.collapsed){
36451 var sw = this.split.el.getWidth();
36453 this.split.el.setLeft(box.x);
36454 this.split.el.setTop(box.y);
36455 this.split.el.setHeight(box.height);
36458 if(this.collapsed){
36459 this.updateBody(null, box.height);
36461 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36465 Roo.bootstrap.layout.West = function(config){
36466 config.region = "west";
36467 config.cursor = "w-resize";
36469 Roo.bootstrap.layout.Split.call(this, config);
36471 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36472 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36473 this.split.el.addClass("roo-layout-split-h");
36477 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36478 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36480 onRender: function(ctr, pos)
36482 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36483 var size = this.config.initialSize || this.config.width;
36484 if(typeof size != "undefined"){
36485 this.el.setWidth(size);
36489 getBox : function(){
36490 if(this.collapsed){
36491 return this.collapsedEl.getBox();
36493 var box = this.el.getBox();
36495 box.width += this.split.el.getWidth();
36500 updateBox : function(box){
36501 if(this.split && !this.collapsed){
36502 var sw = this.split.el.getWidth();
36504 this.split.el.setLeft(box.x+box.width);
36505 this.split.el.setTop(box.y);
36506 this.split.el.setHeight(box.height);
36508 if(this.collapsed){
36509 this.updateBody(null, box.height);
36511 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36514 Roo.namespace("Roo.bootstrap.panel");/*
36516 * Ext JS Library 1.1.1
36517 * Copyright(c) 2006-2007, Ext JS, LLC.
36519 * Originally Released Under LGPL - original licence link has changed is not relivant.
36522 * <script type="text/javascript">
36525 * @class Roo.ContentPanel
36526 * @extends Roo.util.Observable
36527 * A basic ContentPanel element.
36528 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36529 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36530 * @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
36531 * @cfg {Boolean} closable True if the panel can be closed/removed
36532 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36533 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36534 * @cfg {Toolbar} toolbar A toolbar for this panel
36535 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36536 * @cfg {String} title The title for this panel
36537 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36538 * @cfg {String} url Calls {@link #setUrl} with this value
36539 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36540 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36541 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36542 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36543 * @cfg {Boolean} badges render the badges
36546 * Create a new ContentPanel.
36547 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36548 * @param {String/Object} config A string to set only the title or a config object
36549 * @param {String} content (optional) Set the HTML content for this panel
36550 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36552 Roo.bootstrap.panel.Content = function( config){
36554 this.tpl = config.tpl || false;
36556 var el = config.el;
36557 var content = config.content;
36559 if(config.autoCreate){ // xtype is available if this is called from factory
36562 this.el = Roo.get(el);
36563 if(!this.el && config && config.autoCreate){
36564 if(typeof config.autoCreate == "object"){
36565 if(!config.autoCreate.id){
36566 config.autoCreate.id = config.id||el;
36568 this.el = Roo.DomHelper.append(document.body,
36569 config.autoCreate, true);
36571 var elcfg = { tag: "div",
36572 cls: "roo-layout-inactive-content",
36576 elcfg.html = config.html;
36580 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36583 this.closable = false;
36584 this.loaded = false;
36585 this.active = false;
36588 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36590 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36592 this.wrapEl = this.el; //this.el.wrap();
36594 if (config.toolbar.items) {
36595 ti = config.toolbar.items ;
36596 delete config.toolbar.items ;
36600 this.toolbar.render(this.wrapEl, 'before');
36601 for(var i =0;i < ti.length;i++) {
36602 // Roo.log(['add child', items[i]]);
36603 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36605 this.toolbar.items = nitems;
36606 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36607 delete config.toolbar;
36611 // xtype created footer. - not sure if will work as we normally have to render first..
36612 if (this.footer && !this.footer.el && this.footer.xtype) {
36613 if (!this.wrapEl) {
36614 this.wrapEl = this.el.wrap();
36617 this.footer.container = this.wrapEl.createChild();
36619 this.footer = Roo.factory(this.footer, Roo);
36624 if(typeof config == "string"){
36625 this.title = config;
36627 Roo.apply(this, config);
36631 this.resizeEl = Roo.get(this.resizeEl, true);
36633 this.resizeEl = this.el;
36635 // handle view.xtype
36643 * Fires when this panel is activated.
36644 * @param {Roo.ContentPanel} this
36648 * @event deactivate
36649 * Fires when this panel is activated.
36650 * @param {Roo.ContentPanel} this
36652 "deactivate" : true,
36656 * Fires when this panel is resized if fitToFrame is true.
36657 * @param {Roo.ContentPanel} this
36658 * @param {Number} width The width after any component adjustments
36659 * @param {Number} height The height after any component adjustments
36665 * Fires when this tab is created
36666 * @param {Roo.ContentPanel} this
36677 if(this.autoScroll){
36678 this.resizeEl.setStyle("overflow", "auto");
36680 // fix randome scrolling
36681 //this.el.on('scroll', function() {
36682 // Roo.log('fix random scolling');
36683 // this.scrollTo('top',0);
36686 content = content || this.content;
36688 this.setContent(content);
36690 if(config && config.url){
36691 this.setUrl(this.url, this.params, this.loadOnce);
36696 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36698 if (this.view && typeof(this.view.xtype) != 'undefined') {
36699 this.view.el = this.el.appendChild(document.createElement("div"));
36700 this.view = Roo.factory(this.view);
36701 this.view.render && this.view.render(false, '');
36705 this.fireEvent('render', this);
36708 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36712 setRegion : function(region){
36713 this.region = region;
36714 this.setActiveClass(region && !this.background);
36718 setActiveClass: function(state)
36721 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36722 this.el.setStyle('position','relative');
36724 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36725 this.el.setStyle('position', 'absolute');
36730 * Returns the toolbar for this Panel if one was configured.
36731 * @return {Roo.Toolbar}
36733 getToolbar : function(){
36734 return this.toolbar;
36737 setActiveState : function(active)
36739 this.active = active;
36740 this.setActiveClass(active);
36742 if(this.fireEvent("deactivate", this) === false){
36747 this.fireEvent("activate", this);
36751 * Updates this panel's element
36752 * @param {String} content The new content
36753 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36755 setContent : function(content, loadScripts){
36756 this.el.update(content, loadScripts);
36759 ignoreResize : function(w, h){
36760 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36763 this.lastSize = {width: w, height: h};
36768 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36769 * @return {Roo.UpdateManager} The UpdateManager
36771 getUpdateManager : function(){
36772 return this.el.getUpdateManager();
36775 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36776 * @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:
36779 url: "your-url.php",
36780 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36781 callback: yourFunction,
36782 scope: yourObject, //(optional scope)
36785 text: "Loading...",
36790 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36791 * 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.
36792 * @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}
36793 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36794 * @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.
36795 * @return {Roo.ContentPanel} this
36798 var um = this.el.getUpdateManager();
36799 um.update.apply(um, arguments);
36805 * 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.
36806 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36807 * @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)
36808 * @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)
36809 * @return {Roo.UpdateManager} The UpdateManager
36811 setUrl : function(url, params, loadOnce){
36812 if(this.refreshDelegate){
36813 this.removeListener("activate", this.refreshDelegate);
36815 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36816 this.on("activate", this.refreshDelegate);
36817 return this.el.getUpdateManager();
36820 _handleRefresh : function(url, params, loadOnce){
36821 if(!loadOnce || !this.loaded){
36822 var updater = this.el.getUpdateManager();
36823 updater.update(url, params, this._setLoaded.createDelegate(this));
36827 _setLoaded : function(){
36828 this.loaded = true;
36832 * Returns this panel's id
36835 getId : function(){
36840 * Returns this panel's element - used by regiosn to add.
36841 * @return {Roo.Element}
36843 getEl : function(){
36844 return this.wrapEl || this.el;
36849 adjustForComponents : function(width, height)
36851 //Roo.log('adjustForComponents ');
36852 if(this.resizeEl != this.el){
36853 width -= this.el.getFrameWidth('lr');
36854 height -= this.el.getFrameWidth('tb');
36857 var te = this.toolbar.getEl();
36858 te.setWidth(width);
36859 height -= te.getHeight();
36862 var te = this.footer.getEl();
36863 te.setWidth(width);
36864 height -= te.getHeight();
36868 if(this.adjustments){
36869 width += this.adjustments[0];
36870 height += this.adjustments[1];
36872 return {"width": width, "height": height};
36875 setSize : function(width, height){
36876 if(this.fitToFrame && !this.ignoreResize(width, height)){
36877 if(this.fitContainer && this.resizeEl != this.el){
36878 this.el.setSize(width, height);
36880 var size = this.adjustForComponents(width, height);
36881 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36882 this.fireEvent('resize', this, size.width, size.height);
36887 * Returns this panel's title
36890 getTitle : function(){
36892 if (typeof(this.title) != 'object') {
36897 for (var k in this.title) {
36898 if (!this.title.hasOwnProperty(k)) {
36902 if (k.indexOf('-') >= 0) {
36903 var s = k.split('-');
36904 for (var i = 0; i<s.length; i++) {
36905 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36908 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36915 * Set this panel's title
36916 * @param {String} title
36918 setTitle : function(title){
36919 this.title = title;
36921 this.region.updatePanelTitle(this, title);
36926 * Returns true is this panel was configured to be closable
36927 * @return {Boolean}
36929 isClosable : function(){
36930 return this.closable;
36933 beforeSlide : function(){
36935 this.resizeEl.clip();
36938 afterSlide : function(){
36940 this.resizeEl.unclip();
36944 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36945 * Will fail silently if the {@link #setUrl} method has not been called.
36946 * This does not activate the panel, just updates its content.
36948 refresh : function(){
36949 if(this.refreshDelegate){
36950 this.loaded = false;
36951 this.refreshDelegate();
36956 * Destroys this panel
36958 destroy : function(){
36959 this.el.removeAllListeners();
36960 var tempEl = document.createElement("span");
36961 tempEl.appendChild(this.el.dom);
36962 tempEl.innerHTML = "";
36968 * form - if the content panel contains a form - this is a reference to it.
36969 * @type {Roo.form.Form}
36973 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36974 * This contains a reference to it.
36980 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36990 * @param {Object} cfg Xtype definition of item to add.
36994 getChildContainer: function () {
36995 return this.getEl();
37000 var ret = new Roo.factory(cfg);
37005 if (cfg.xtype.match(/^Form$/)) {
37008 //if (this.footer) {
37009 // el = this.footer.container.insertSibling(false, 'before');
37011 el = this.el.createChild();
37014 this.form = new Roo.form.Form(cfg);
37017 if ( this.form.allItems.length) {
37018 this.form.render(el.dom);
37022 // should only have one of theses..
37023 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37024 // views.. should not be just added - used named prop 'view''
37026 cfg.el = this.el.appendChild(document.createElement("div"));
37029 var ret = new Roo.factory(cfg);
37031 ret.render && ret.render(false, ''); // render blank..
37041 * @class Roo.bootstrap.panel.Grid
37042 * @extends Roo.bootstrap.panel.Content
37044 * Create a new GridPanel.
37045 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37046 * @param {Object} config A the config object
37052 Roo.bootstrap.panel.Grid = function(config)
37056 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37057 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37059 config.el = this.wrapper;
37060 //this.el = this.wrapper;
37062 if (config.container) {
37063 // ctor'ed from a Border/panel.grid
37066 this.wrapper.setStyle("overflow", "hidden");
37067 this.wrapper.addClass('roo-grid-container');
37072 if(config.toolbar){
37073 var tool_el = this.wrapper.createChild();
37074 this.toolbar = Roo.factory(config.toolbar);
37076 if (config.toolbar.items) {
37077 ti = config.toolbar.items ;
37078 delete config.toolbar.items ;
37082 this.toolbar.render(tool_el);
37083 for(var i =0;i < ti.length;i++) {
37084 // Roo.log(['add child', items[i]]);
37085 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37087 this.toolbar.items = nitems;
37089 delete config.toolbar;
37092 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37093 config.grid.scrollBody = true;;
37094 config.grid.monitorWindowResize = false; // turn off autosizing
37095 config.grid.autoHeight = false;
37096 config.grid.autoWidth = false;
37098 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37100 if (config.background) {
37101 // render grid on panel activation (if panel background)
37102 this.on('activate', function(gp) {
37103 if (!gp.grid.rendered) {
37104 gp.grid.render(this.wrapper);
37105 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37110 this.grid.render(this.wrapper);
37111 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37114 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37115 // ??? needed ??? config.el = this.wrapper;
37120 // xtype created footer. - not sure if will work as we normally have to render first..
37121 if (this.footer && !this.footer.el && this.footer.xtype) {
37123 var ctr = this.grid.getView().getFooterPanel(true);
37124 this.footer.dataSource = this.grid.dataSource;
37125 this.footer = Roo.factory(this.footer, Roo);
37126 this.footer.render(ctr);
37136 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37137 getId : function(){
37138 return this.grid.id;
37142 * Returns the grid for this panel
37143 * @return {Roo.bootstrap.Table}
37145 getGrid : function(){
37149 setSize : function(width, height){
37150 if(!this.ignoreResize(width, height)){
37151 var grid = this.grid;
37152 var size = this.adjustForComponents(width, height);
37153 var gridel = grid.getGridEl();
37154 gridel.setSize(size.width, size.height);
37156 var thd = grid.getGridEl().select('thead',true).first();
37157 var tbd = grid.getGridEl().select('tbody', true).first();
37159 tbd.setSize(width, height - thd.getHeight());
37168 beforeSlide : function(){
37169 this.grid.getView().scroller.clip();
37172 afterSlide : function(){
37173 this.grid.getView().scroller.unclip();
37176 destroy : function(){
37177 this.grid.destroy();
37179 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37184 * @class Roo.bootstrap.panel.Nest
37185 * @extends Roo.bootstrap.panel.Content
37187 * Create a new Panel, that can contain a layout.Border.
37190 * @param {Roo.BorderLayout} layout The layout for this panel
37191 * @param {String/Object} config A string to set only the title or a config object
37193 Roo.bootstrap.panel.Nest = function(config)
37195 // construct with only one argument..
37196 /* FIXME - implement nicer consturctors
37197 if (layout.layout) {
37199 layout = config.layout;
37200 delete config.layout;
37202 if (layout.xtype && !layout.getEl) {
37203 // then layout needs constructing..
37204 layout = Roo.factory(layout, Roo);
37208 config.el = config.layout.getEl();
37210 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37212 config.layout.monitorWindowResize = false; // turn off autosizing
37213 this.layout = config.layout;
37214 this.layout.getEl().addClass("roo-layout-nested-layout");
37221 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37223 setSize : function(width, height){
37224 if(!this.ignoreResize(width, height)){
37225 var size = this.adjustForComponents(width, height);
37226 var el = this.layout.getEl();
37227 if (size.height < 1) {
37228 el.setWidth(size.width);
37230 el.setSize(size.width, size.height);
37232 var touch = el.dom.offsetWidth;
37233 this.layout.layout();
37234 // ie requires a double layout on the first pass
37235 if(Roo.isIE && !this.initialized){
37236 this.initialized = true;
37237 this.layout.layout();
37242 // activate all subpanels if not currently active..
37244 setActiveState : function(active){
37245 this.active = active;
37246 this.setActiveClass(active);
37249 this.fireEvent("deactivate", this);
37253 this.fireEvent("activate", this);
37254 // not sure if this should happen before or after..
37255 if (!this.layout) {
37256 return; // should not happen..
37259 for (var r in this.layout.regions) {
37260 reg = this.layout.getRegion(r);
37261 if (reg.getActivePanel()) {
37262 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37263 reg.setActivePanel(reg.getActivePanel());
37266 if (!reg.panels.length) {
37269 reg.showPanel(reg.getPanel(0));
37278 * Returns the nested BorderLayout for this panel
37279 * @return {Roo.BorderLayout}
37281 getLayout : function(){
37282 return this.layout;
37286 * Adds a xtype elements to the layout of the nested panel
37290 xtype : 'ContentPanel',
37297 xtype : 'NestedLayoutPanel',
37303 items : [ ... list of content panels or nested layout panels.. ]
37307 * @param {Object} cfg Xtype definition of item to add.
37309 addxtype : function(cfg) {
37310 return this.layout.addxtype(cfg);
37315 * Ext JS Library 1.1.1
37316 * Copyright(c) 2006-2007, Ext JS, LLC.
37318 * Originally Released Under LGPL - original licence link has changed is not relivant.
37321 * <script type="text/javascript">
37324 * @class Roo.TabPanel
37325 * @extends Roo.util.Observable
37326 * A lightweight tab container.
37330 // basic tabs 1, built from existing content
37331 var tabs = new Roo.TabPanel("tabs1");
37332 tabs.addTab("script", "View Script");
37333 tabs.addTab("markup", "View Markup");
37334 tabs.activate("script");
37336 // more advanced tabs, built from javascript
37337 var jtabs = new Roo.TabPanel("jtabs");
37338 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37340 // set up the UpdateManager
37341 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37342 var updater = tab2.getUpdateManager();
37343 updater.setDefaultUrl("ajax1.htm");
37344 tab2.on('activate', updater.refresh, updater, true);
37346 // Use setUrl for Ajax loading
37347 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37348 tab3.setUrl("ajax2.htm", null, true);
37351 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37354 jtabs.activate("jtabs-1");
37357 * Create a new TabPanel.
37358 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37359 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37361 Roo.bootstrap.panel.Tabs = function(config){
37363 * The container element for this TabPanel.
37364 * @type Roo.Element
37366 this.el = Roo.get(config.el);
37369 if(typeof config == "boolean"){
37370 this.tabPosition = config ? "bottom" : "top";
37372 Roo.apply(this, config);
37376 if(this.tabPosition == "bottom"){
37377 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37378 this.el.addClass("roo-tabs-bottom");
37380 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37381 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37382 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37384 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37386 if(this.tabPosition != "bottom"){
37387 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37388 * @type Roo.Element
37390 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37391 this.el.addClass("roo-tabs-top");
37395 this.bodyEl.setStyle("position", "relative");
37397 this.active = null;
37398 this.activateDelegate = this.activate.createDelegate(this);
37403 * Fires when the active tab changes
37404 * @param {Roo.TabPanel} this
37405 * @param {Roo.TabPanelItem} activePanel The new active tab
37409 * @event beforetabchange
37410 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37411 * @param {Roo.TabPanel} this
37412 * @param {Object} e Set cancel to true on this object to cancel the tab change
37413 * @param {Roo.TabPanelItem} tab The tab being changed to
37415 "beforetabchange" : true
37418 Roo.EventManager.onWindowResize(this.onResize, this);
37419 this.cpad = this.el.getPadding("lr");
37420 this.hiddenCount = 0;
37423 // toolbar on the tabbar support...
37424 if (this.toolbar) {
37425 alert("no toolbar support yet");
37426 this.toolbar = false;
37428 var tcfg = this.toolbar;
37429 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37430 this.toolbar = new Roo.Toolbar(tcfg);
37431 if (Roo.isSafari) {
37432 var tbl = tcfg.container.child('table', true);
37433 tbl.setAttribute('width', '100%');
37441 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37444 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37446 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37448 tabPosition : "top",
37450 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37452 currentTabWidth : 0,
37454 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37458 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37462 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37464 preferredTabWidth : 175,
37466 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37468 resizeTabs : false,
37470 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37472 monitorResize : true,
37474 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37479 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37480 * @param {String} id The id of the div to use <b>or create</b>
37481 * @param {String} text The text for the tab
37482 * @param {String} content (optional) Content to put in the TabPanelItem body
37483 * @param {Boolean} closable (optional) True to create a close icon on the tab
37484 * @return {Roo.TabPanelItem} The created TabPanelItem
37486 addTab : function(id, text, content, closable, tpl)
37488 var item = new Roo.bootstrap.panel.TabItem({
37492 closable : closable,
37495 this.addTabItem(item);
37497 item.setContent(content);
37503 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37504 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37505 * @return {Roo.TabPanelItem}
37507 getTab : function(id){
37508 return this.items[id];
37512 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37513 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37515 hideTab : function(id){
37516 var t = this.items[id];
37519 this.hiddenCount++;
37520 this.autoSizeTabs();
37525 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37526 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37528 unhideTab : function(id){
37529 var t = this.items[id];
37531 t.setHidden(false);
37532 this.hiddenCount--;
37533 this.autoSizeTabs();
37538 * Adds an existing {@link Roo.TabPanelItem}.
37539 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37541 addTabItem : function(item){
37542 this.items[item.id] = item;
37543 this.items.push(item);
37544 // if(this.resizeTabs){
37545 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37546 // this.autoSizeTabs();
37548 // item.autoSize();
37553 * Removes a {@link Roo.TabPanelItem}.
37554 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37556 removeTab : function(id){
37557 var items = this.items;
37558 var tab = items[id];
37559 if(!tab) { return; }
37560 var index = items.indexOf(tab);
37561 if(this.active == tab && items.length > 1){
37562 var newTab = this.getNextAvailable(index);
37567 this.stripEl.dom.removeChild(tab.pnode.dom);
37568 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37569 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37571 items.splice(index, 1);
37572 delete this.items[tab.id];
37573 tab.fireEvent("close", tab);
37574 tab.purgeListeners();
37575 this.autoSizeTabs();
37578 getNextAvailable : function(start){
37579 var items = this.items;
37581 // look for a next tab that will slide over to
37582 // replace the one being removed
37583 while(index < items.length){
37584 var item = items[++index];
37585 if(item && !item.isHidden()){
37589 // if one isn't found select the previous tab (on the left)
37592 var item = items[--index];
37593 if(item && !item.isHidden()){
37601 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37602 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37604 disableTab : function(id){
37605 var tab = this.items[id];
37606 if(tab && this.active != tab){
37612 * Enables a {@link Roo.TabPanelItem} that is disabled.
37613 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37615 enableTab : function(id){
37616 var tab = this.items[id];
37621 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37622 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37623 * @return {Roo.TabPanelItem} The TabPanelItem.
37625 activate : function(id){
37626 var tab = this.items[id];
37630 if(tab == this.active || tab.disabled){
37634 this.fireEvent("beforetabchange", this, e, tab);
37635 if(e.cancel !== true && !tab.disabled){
37637 this.active.hide();
37639 this.active = this.items[id];
37640 this.active.show();
37641 this.fireEvent("tabchange", this, this.active);
37647 * Gets the active {@link Roo.TabPanelItem}.
37648 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37650 getActiveTab : function(){
37651 return this.active;
37655 * Updates the tab body element to fit the height of the container element
37656 * for overflow scrolling
37657 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37659 syncHeight : function(targetHeight){
37660 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37661 var bm = this.bodyEl.getMargins();
37662 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37663 this.bodyEl.setHeight(newHeight);
37667 onResize : function(){
37668 if(this.monitorResize){
37669 this.autoSizeTabs();
37674 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37676 beginUpdate : function(){
37677 this.updating = true;
37681 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37683 endUpdate : function(){
37684 this.updating = false;
37685 this.autoSizeTabs();
37689 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37691 autoSizeTabs : function(){
37692 var count = this.items.length;
37693 var vcount = count - this.hiddenCount;
37694 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37697 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37698 var availWidth = Math.floor(w / vcount);
37699 var b = this.stripBody;
37700 if(b.getWidth() > w){
37701 var tabs = this.items;
37702 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37703 if(availWidth < this.minTabWidth){
37704 /*if(!this.sleft){ // incomplete scrolling code
37705 this.createScrollButtons();
37708 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37711 if(this.currentTabWidth < this.preferredTabWidth){
37712 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37718 * Returns the number of tabs in this TabPanel.
37721 getCount : function(){
37722 return this.items.length;
37726 * Resizes all the tabs to the passed width
37727 * @param {Number} The new width
37729 setTabWidth : function(width){
37730 this.currentTabWidth = width;
37731 for(var i = 0, len = this.items.length; i < len; i++) {
37732 if(!this.items[i].isHidden()) {
37733 this.items[i].setWidth(width);
37739 * Destroys this TabPanel
37740 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37742 destroy : function(removeEl){
37743 Roo.EventManager.removeResizeListener(this.onResize, this);
37744 for(var i = 0, len = this.items.length; i < len; i++){
37745 this.items[i].purgeListeners();
37747 if(removeEl === true){
37748 this.el.update("");
37753 createStrip : function(container)
37755 var strip = document.createElement("nav");
37756 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37757 container.appendChild(strip);
37761 createStripList : function(strip)
37763 // div wrapper for retard IE
37764 // returns the "tr" element.
37765 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37766 //'<div class="x-tabs-strip-wrap">'+
37767 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37768 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37769 return strip.firstChild; //.firstChild.firstChild.firstChild;
37771 createBody : function(container)
37773 var body = document.createElement("div");
37774 Roo.id(body, "tab-body");
37775 //Roo.fly(body).addClass("x-tabs-body");
37776 Roo.fly(body).addClass("tab-content");
37777 container.appendChild(body);
37780 createItemBody :function(bodyEl, id){
37781 var body = Roo.getDom(id);
37783 body = document.createElement("div");
37786 //Roo.fly(body).addClass("x-tabs-item-body");
37787 Roo.fly(body).addClass("tab-pane");
37788 bodyEl.insertBefore(body, bodyEl.firstChild);
37792 createStripElements : function(stripEl, text, closable, tpl)
37794 var td = document.createElement("li"); // was td..
37797 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37800 stripEl.appendChild(td);
37802 td.className = "x-tabs-closable";
37803 if(!this.closeTpl){
37804 this.closeTpl = new Roo.Template(
37805 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37806 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37807 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37810 var el = this.closeTpl.overwrite(td, {"text": text});
37811 var close = el.getElementsByTagName("div")[0];
37812 var inner = el.getElementsByTagName("em")[0];
37813 return {"el": el, "close": close, "inner": inner};
37816 // not sure what this is..
37817 // if(!this.tabTpl){
37818 //this.tabTpl = new Roo.Template(
37819 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37820 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37822 // this.tabTpl = new Roo.Template(
37823 // '<a href="#">' +
37824 // '<span unselectable="on"' +
37825 // (this.disableTooltips ? '' : ' title="{text}"') +
37826 // ' >{text}</span></a>'
37832 var template = tpl || this.tabTpl || false;
37836 template = new Roo.Template(
37838 '<span unselectable="on"' +
37839 (this.disableTooltips ? '' : ' title="{text}"') +
37840 ' >{text}</span></a>'
37844 switch (typeof(template)) {
37848 template = new Roo.Template(template);
37854 var el = template.overwrite(td, {"text": text});
37856 var inner = el.getElementsByTagName("span")[0];
37858 return {"el": el, "inner": inner};
37866 * @class Roo.TabPanelItem
37867 * @extends Roo.util.Observable
37868 * Represents an individual item (tab plus body) in a TabPanel.
37869 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37870 * @param {String} id The id of this TabPanelItem
37871 * @param {String} text The text for the tab of this TabPanelItem
37872 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37874 Roo.bootstrap.panel.TabItem = function(config){
37876 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37877 * @type Roo.TabPanel
37879 this.tabPanel = config.panel;
37881 * The id for this TabPanelItem
37884 this.id = config.id;
37886 this.disabled = false;
37888 this.text = config.text;
37890 this.loaded = false;
37891 this.closable = config.closable;
37894 * The body element for this TabPanelItem.
37895 * @type Roo.Element
37897 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37898 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37899 this.bodyEl.setStyle("display", "block");
37900 this.bodyEl.setStyle("zoom", "1");
37901 //this.hideAction();
37903 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37905 this.el = Roo.get(els.el);
37906 this.inner = Roo.get(els.inner, true);
37907 this.textEl = Roo.get(this.el.dom.firstChild, true);
37908 this.pnode = Roo.get(els.el.parentNode, true);
37909 // this.el.on("mousedown", this.onTabMouseDown, this);
37910 this.el.on("click", this.onTabClick, this);
37912 if(config.closable){
37913 var c = Roo.get(els.close, true);
37914 c.dom.title = this.closeText;
37915 c.addClassOnOver("close-over");
37916 c.on("click", this.closeClick, this);
37922 * Fires when this tab becomes the active tab.
37923 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37924 * @param {Roo.TabPanelItem} this
37928 * @event beforeclose
37929 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37930 * @param {Roo.TabPanelItem} this
37931 * @param {Object} e Set cancel to true on this object to cancel the close.
37933 "beforeclose": true,
37936 * Fires when this tab is closed.
37937 * @param {Roo.TabPanelItem} this
37941 * @event deactivate
37942 * Fires when this tab is no longer the active tab.
37943 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37944 * @param {Roo.TabPanelItem} this
37946 "deactivate" : true
37948 this.hidden = false;
37950 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37953 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37955 purgeListeners : function(){
37956 Roo.util.Observable.prototype.purgeListeners.call(this);
37957 this.el.removeAllListeners();
37960 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37963 this.pnode.addClass("active");
37966 this.tabPanel.stripWrap.repaint();
37968 this.fireEvent("activate", this.tabPanel, this);
37972 * Returns true if this tab is the active tab.
37973 * @return {Boolean}
37975 isActive : function(){
37976 return this.tabPanel.getActiveTab() == this;
37980 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37983 this.pnode.removeClass("active");
37985 this.fireEvent("deactivate", this.tabPanel, this);
37988 hideAction : function(){
37989 this.bodyEl.hide();
37990 this.bodyEl.setStyle("position", "absolute");
37991 this.bodyEl.setLeft("-20000px");
37992 this.bodyEl.setTop("-20000px");
37995 showAction : function(){
37996 this.bodyEl.setStyle("position", "relative");
37997 this.bodyEl.setTop("");
37998 this.bodyEl.setLeft("");
37999 this.bodyEl.show();
38003 * Set the tooltip for the tab.
38004 * @param {String} tooltip The tab's tooltip
38006 setTooltip : function(text){
38007 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38008 this.textEl.dom.qtip = text;
38009 this.textEl.dom.removeAttribute('title');
38011 this.textEl.dom.title = text;
38015 onTabClick : function(e){
38016 e.preventDefault();
38017 this.tabPanel.activate(this.id);
38020 onTabMouseDown : function(e){
38021 e.preventDefault();
38022 this.tabPanel.activate(this.id);
38025 getWidth : function(){
38026 return this.inner.getWidth();
38029 setWidth : function(width){
38030 var iwidth = width - this.pnode.getPadding("lr");
38031 this.inner.setWidth(iwidth);
38032 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38033 this.pnode.setWidth(width);
38037 * Show or hide the tab
38038 * @param {Boolean} hidden True to hide or false to show.
38040 setHidden : function(hidden){
38041 this.hidden = hidden;
38042 this.pnode.setStyle("display", hidden ? "none" : "");
38046 * Returns true if this tab is "hidden"
38047 * @return {Boolean}
38049 isHidden : function(){
38050 return this.hidden;
38054 * Returns the text for this tab
38057 getText : function(){
38061 autoSize : function(){
38062 //this.el.beginMeasure();
38063 this.textEl.setWidth(1);
38065 * #2804 [new] Tabs in Roojs
38066 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38068 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38069 //this.el.endMeasure();
38073 * Sets the text for the tab (Note: this also sets the tooltip text)
38074 * @param {String} text The tab's text and tooltip
38076 setText : function(text){
38078 this.textEl.update(text);
38079 this.setTooltip(text);
38080 //if(!this.tabPanel.resizeTabs){
38081 // this.autoSize();
38085 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38087 activate : function(){
38088 this.tabPanel.activate(this.id);
38092 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38094 disable : function(){
38095 if(this.tabPanel.active != this){
38096 this.disabled = true;
38097 this.pnode.addClass("disabled");
38102 * Enables this TabPanelItem if it was previously disabled.
38104 enable : function(){
38105 this.disabled = false;
38106 this.pnode.removeClass("disabled");
38110 * Sets the content for this TabPanelItem.
38111 * @param {String} content The content
38112 * @param {Boolean} loadScripts true to look for and load scripts
38114 setContent : function(content, loadScripts){
38115 this.bodyEl.update(content, loadScripts);
38119 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38120 * @return {Roo.UpdateManager} The UpdateManager
38122 getUpdateManager : function(){
38123 return this.bodyEl.getUpdateManager();
38127 * Set a URL to be used to load the content for this TabPanelItem.
38128 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38129 * @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)
38130 * @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)
38131 * @return {Roo.UpdateManager} The UpdateManager
38133 setUrl : function(url, params, loadOnce){
38134 if(this.refreshDelegate){
38135 this.un('activate', this.refreshDelegate);
38137 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38138 this.on("activate", this.refreshDelegate);
38139 return this.bodyEl.getUpdateManager();
38143 _handleRefresh : function(url, params, loadOnce){
38144 if(!loadOnce || !this.loaded){
38145 var updater = this.bodyEl.getUpdateManager();
38146 updater.update(url, params, this._setLoaded.createDelegate(this));
38151 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38152 * Will fail silently if the setUrl method has not been called.
38153 * This does not activate the panel, just updates its content.
38155 refresh : function(){
38156 if(this.refreshDelegate){
38157 this.loaded = false;
38158 this.refreshDelegate();
38163 _setLoaded : function(){
38164 this.loaded = true;
38168 closeClick : function(e){
38171 this.fireEvent("beforeclose", this, o);
38172 if(o.cancel !== true){
38173 this.tabPanel.removeTab(this.id);
38177 * The text displayed in the tooltip for the close icon.
38180 closeText : "Close this tab"
38183 * This script refer to:
38184 * Title: International Telephone Input
38185 * Author: Jack O'Connor
38186 * Code version: v12.1.12
38187 * Availability: https://github.com/jackocnr/intl-tel-input.git
38190 Roo.bootstrap.PhoneInputData = function() {
38193 "Afghanistan (افغانستان)",
38198 "Albania (Shqipëri)",
38203 "Algeria (الجزائر)",
38228 "Antigua and Barbuda",
38238 "Armenia (Հայաստան)",
38254 "Austria (Österreich)",
38259 "Azerbaijan (Azərbaycan)",
38269 "Bahrain (البحرين)",
38274 "Bangladesh (বাংলাদেশ)",
38284 "Belarus (Беларусь)",
38289 "Belgium (België)",
38319 "Bosnia and Herzegovina (Босна и Херцеговина)",
38334 "British Indian Ocean Territory",
38339 "British Virgin Islands",
38349 "Bulgaria (България)",
38359 "Burundi (Uburundi)",
38364 "Cambodia (កម្ពុជា)",
38369 "Cameroon (Cameroun)",
38378 ["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]
38381 "Cape Verde (Kabu Verdi)",
38386 "Caribbean Netherlands",
38397 "Central African Republic (République centrafricaine)",
38417 "Christmas Island",
38423 "Cocos (Keeling) Islands",
38434 "Comoros (جزر القمر)",
38439 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38444 "Congo (Republic) (Congo-Brazzaville)",
38464 "Croatia (Hrvatska)",
38485 "Czech Republic (Česká republika)",
38490 "Denmark (Danmark)",
38505 "Dominican Republic (República Dominicana)",
38509 ["809", "829", "849"]
38527 "Equatorial Guinea (Guinea Ecuatorial)",
38547 "Falkland Islands (Islas Malvinas)",
38552 "Faroe Islands (Føroyar)",
38573 "French Guiana (Guyane française)",
38578 "French Polynesia (Polynésie française)",
38593 "Georgia (საქართველო)",
38598 "Germany (Deutschland)",
38618 "Greenland (Kalaallit Nunaat)",
38655 "Guinea-Bissau (Guiné Bissau)",
38680 "Hungary (Magyarország)",
38685 "Iceland (Ísland)",
38705 "Iraq (العراق)",
38721 "Israel (ישראל)",
38748 "Jordan (الأردن)",
38753 "Kazakhstan (Казахстан)",
38774 "Kuwait (الكويت)",
38779 "Kyrgyzstan (Кыргызстан)",
38789 "Latvia (Latvija)",
38794 "Lebanon (لبنان)",
38809 "Libya (ليبيا)",
38819 "Lithuania (Lietuva)",
38834 "Macedonia (FYROM) (Македонија)",
38839 "Madagascar (Madagasikara)",
38869 "Marshall Islands",
38879 "Mauritania (موريتانيا)",
38884 "Mauritius (Moris)",
38905 "Moldova (Republica Moldova)",
38915 "Mongolia (Монгол)",
38920 "Montenegro (Crna Gora)",
38930 "Morocco (المغرب)",
38936 "Mozambique (Moçambique)",
38941 "Myanmar (Burma) (မြန်မာ)",
38946 "Namibia (Namibië)",
38961 "Netherlands (Nederland)",
38966 "New Caledonia (Nouvelle-Calédonie)",
39001 "North Korea (조선 민주주의 인민 공화국)",
39006 "Northern Mariana Islands",
39022 "Pakistan (پاکستان)",
39032 "Palestine (فلسطين)",
39042 "Papua New Guinea",
39084 "Réunion (La Réunion)",
39090 "Romania (România)",
39106 "Saint Barthélemy",
39117 "Saint Kitts and Nevis",
39127 "Saint Martin (Saint-Martin (partie française))",
39133 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39138 "Saint Vincent and the Grenadines",
39153 "São Tomé and Príncipe (São Tomé e Príncipe)",
39158 "Saudi Arabia (المملكة العربية السعودية)",
39163 "Senegal (Sénégal)",
39193 "Slovakia (Slovensko)",
39198 "Slovenia (Slovenija)",
39208 "Somalia (Soomaaliya)",
39218 "South Korea (대한민국)",
39223 "South Sudan (جنوب السودان)",
39233 "Sri Lanka (ශ්රී ලංකාව)",
39238 "Sudan (السودان)",
39248 "Svalbard and Jan Mayen",
39259 "Sweden (Sverige)",
39264 "Switzerland (Schweiz)",
39269 "Syria (سوريا)",
39314 "Trinidad and Tobago",
39319 "Tunisia (تونس)",
39324 "Turkey (Türkiye)",
39334 "Turks and Caicos Islands",
39344 "U.S. Virgin Islands",
39354 "Ukraine (Україна)",
39359 "United Arab Emirates (الإمارات العربية المتحدة)",
39381 "Uzbekistan (Oʻzbekiston)",
39391 "Vatican City (Città del Vaticano)",
39402 "Vietnam (Việt Nam)",
39407 "Wallis and Futuna (Wallis-et-Futuna)",
39412 "Western Sahara (الصحراء الغربية)",
39418 "Yemen (اليمن)",
39442 * This script refer to:
39443 * Title: International Telephone Input
39444 * Author: Jack O'Connor
39445 * Code version: v12.1.12
39446 * Availability: https://github.com/jackocnr/intl-tel-input.git
39450 * @class Roo.bootstrap.PhoneInput
39451 * @extends Roo.bootstrap.TriggerField
39452 * An input with International dial-code selection
39454 * @cfg {String} defaultDialCode default '+852'
39455 * @cfg {Array} preferedCountries default []
39458 * Create a new PhoneInput.
39459 * @param {Object} config Configuration options
39462 Roo.bootstrap.PhoneInput = function(config) {
39463 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39466 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39468 listWidth: undefined,
39470 selectedClass: 'active',
39472 invalidClass : "has-warning",
39474 validClass: 'has-success',
39476 allowed: '0123456789',
39479 * @cfg {String} defaultDialCode The default dial code when initializing the input
39481 defaultDialCode: '+852',
39484 * @cfg {Array} preferedCountries A list of iso2 in array (e.g. ['hk','us']). Those related countries will show at the top of the input's choices
39486 preferedCountries: false,
39488 getAutoCreate : function()
39490 var data = Roo.bootstrap.PhoneInputData();
39491 var align = this.labelAlign || this.parentLabelAlign();
39494 this.allCountries = [];
39495 this.dialCodeMapping = [];
39497 for (var i = 0; i < data.length; i++) {
39499 this.allCountries[i] = {
39503 priority: c[3] || 0,
39504 areaCodes: c[4] || null
39506 this.dialCodeMapping[c[2]] = {
39509 priority: c[3] || 0,
39510 areaCodes: c[4] || null
39522 cls : 'form-control tel-input',
39523 autocomplete: 'new-password'
39526 var hiddenInput = {
39529 cls: 'hidden-tel-input'
39533 hiddenInput.name = this.name;
39536 if (this.disabled) {
39537 input.disabled = true;
39540 var flag_container = {
39557 cls: this.hasFeedback ? 'has-feedback' : '',
39563 cls: 'dial-code-holder',
39570 cls: 'roo-select2-container input-group',
39577 if (this.fieldLabel.length) {
39580 tooltip: 'This field is required'
39586 cls: 'control-label',
39592 html: this.fieldLabel
39595 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39601 if(this.indicatorpos == 'right') {
39602 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39609 if(align == 'left') {
39617 if(this.labelWidth > 12){
39618 label.style = "width: " + this.labelWidth + 'px';
39620 if(this.labelWidth < 13 && this.labelmd == 0){
39621 this.labelmd = this.labelWidth;
39623 if(this.labellg > 0){
39624 label.cls += ' col-lg-' + this.labellg;
39625 input.cls += ' col-lg-' + (12 - this.labellg);
39627 if(this.labelmd > 0){
39628 label.cls += ' col-md-' + this.labelmd;
39629 container.cls += ' col-md-' + (12 - this.labelmd);
39631 if(this.labelsm > 0){
39632 label.cls += ' col-sm-' + this.labelsm;
39633 container.cls += ' col-sm-' + (12 - this.labelsm);
39635 if(this.labelxs > 0){
39636 label.cls += ' col-xs-' + this.labelxs;
39637 container.cls += ' col-xs-' + (12 - this.labelxs);
39647 var settings = this;
39649 ['xs','sm','md','lg'].map(function(size){
39650 if (settings[size]) {
39651 cfg.cls += ' col-' + size + '-' + settings[size];
39655 this.store = new Roo.data.Store({
39656 proxy : new Roo.data.MemoryProxy({}),
39657 reader : new Roo.data.JsonReader({
39668 'name' : 'dialCode',
39672 'name' : 'priority',
39676 'name' : 'areaCodes',
39683 if(!this.preferedCountries) {
39684 this.preferedCountries = [
39691 var p = this.preferedCountries.reverse();
39694 for (var i = 0; i < p.length; i++) {
39695 for (var j = 0; j < this.allCountries.length; j++) {
39696 if(this.allCountries[j].iso2 == p[i]) {
39697 var t = this.allCountries[j];
39698 this.allCountries.splice(j,1);
39699 this.allCountries.unshift(t);
39705 this.store.proxy.data = {
39707 data: this.allCountries
39713 initEvents : function()
39716 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39718 this.indicator = this.indicatorEl();
39719 this.flag = this.flagEl();
39720 this.dialCodeHolder = this.dialCodeHolderEl();
39722 this.trigger = this.el.select('div.flag-box',true).first();
39723 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39728 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39729 _this.list.setWidth(lw);
39732 this.list.on('mouseover', this.onViewOver, this);
39733 this.list.on('mousemove', this.onViewMove, this);
39734 this.inputEl().on("keyup", this.onKeyUp, this);
39736 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39738 this.view = new Roo.View(this.list, this.tpl, {
39739 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39742 this.view.on('click', this.onViewClick, this);
39743 this.setValue(this.defaultDialCode);
39746 onTriggerClick : function(e)
39748 Roo.log('trigger click');
39753 if(this.isExpanded()){
39755 this.hasFocus = false;
39757 this.store.load({});
39758 this.hasFocus = true;
39763 isExpanded : function()
39765 return this.list.isVisible();
39768 collapse : function()
39770 if(!this.isExpanded()){
39774 Roo.get(document).un('mousedown', this.collapseIf, this);
39775 Roo.get(document).un('mousewheel', this.collapseIf, this);
39776 this.fireEvent('collapse', this);
39780 expand : function()
39784 if(this.isExpanded() || !this.hasFocus){
39788 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39789 this.list.setWidth(lw);
39792 this.restrictHeight();
39794 Roo.get(document).on('mousedown', this.collapseIf, this);
39795 Roo.get(document).on('mousewheel', this.collapseIf, this);
39797 this.fireEvent('expand', this);
39800 restrictHeight : function()
39802 this.list.alignTo(this.inputEl(), this.listAlign);
39803 this.list.alignTo(this.inputEl(), this.listAlign);
39806 onViewOver : function(e, t)
39808 if(this.inKeyMode){
39811 var item = this.view.findItemFromChild(t);
39814 var index = this.view.indexOf(item);
39815 this.select(index, false);
39820 onViewClick : function(view, doFocus, el, e)
39822 var index = this.view.getSelectedIndexes()[0];
39824 var r = this.store.getAt(index);
39827 this.onSelect(r, index);
39829 if(doFocus !== false && !this.blockFocus){
39830 this.inputEl().focus();
39834 onViewMove : function(e, t)
39836 this.inKeyMode = false;
39839 select : function(index, scrollIntoView)
39841 this.selectedIndex = index;
39842 this.view.select(index);
39843 if(scrollIntoView !== false){
39844 var el = this.view.getNode(index);
39846 this.list.scrollChildIntoView(el, false);
39851 createList : function()
39853 this.list = Roo.get(document.body).createChild({
39855 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39856 style: 'display:none'
39858 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39861 collapseIf : function(e)
39863 var in_combo = e.within(this.el);
39864 var in_list = e.within(this.list);
39865 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39867 if (in_combo || in_list || is_list) {
39873 onSelect : function(record, index)
39875 if(this.fireEvent('beforeselect', this, record, index) !== false){
39877 this.setFlagClass(record.data.iso2);
39878 this.setDialCode(record.data.dialCode);
39879 this.hasFocus = false;
39881 this.fireEvent('select', this, record, index);
39885 flagEl : function()
39887 var flag = this.el.select('div.flag',true).first();
39894 dialCodeHolderEl : function()
39896 var d = this.el.select('input.dial-code-holder',true).first();
39903 setDialCode : function(v)
39905 this.dialCodeHolder.dom.value = '+'+v;
39908 setFlagClass : function(n)
39910 this.flag.dom.className = 'flag '+n;
39913 getValue : function()
39915 var v = this.inputEl().getValue();
39916 if(this.dialCodeHolder) {
39917 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
39922 setValue : function(v)
39924 var d = this.getDialCode(v);
39926 //invalid dial code
39927 if(v.length == 0 || !d || d.length == 0) {
39929 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
39930 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39936 this.setFlagClass(this.dialCodeMapping[d].iso2);
39937 this.setDialCode(d);
39938 this.inputEl().dom.value = v.replace('+'+d,'');
39939 this.hiddenEl().dom.value = this.getValue();
39944 getDialCode : function(v = '')
39946 if (v.length == 0) {
39947 return this.dialCodeHolder.dom.value;
39951 if (v.charAt(0) != "+") {
39954 var numericChars = "";
39955 for (var i = 1; i < v.length; i++) {
39956 var c = v.charAt(i);
39959 if (this.dialCodeMapping[numericChars]) {
39960 dialCode = v.substr(1, i);
39962 if (numericChars.length == 4) {
39972 this.setValue(this.defaultDialCode);
39976 hiddenEl : function()
39978 return this.el.select('input.hidden-tel-input',true).first();
39981 onKeyUp : function(e){
39983 var k = e.getKey();
39984 var c = e.getCharCode();
39987 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39988 this.allowed.indexOf(String.fromCharCode(c)) === -1
39993 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39996 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
40000 this.setValue(this.getValue());
40005 * @class Roo.bootstrap.MoneyField
40006 * @extends Roo.bootstrap.ComboBox
40007 * Bootstrap MoneyField class
40010 * Create a new MoneyField.
40011 * @param {Object} config Configuration options
40014 Roo.bootstrap.MoneyField = function(config) {
40016 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40020 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40023 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40025 allowDecimals : true,
40027 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40029 decimalSeparator : ".",
40031 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40033 decimalPrecision : 0,
40035 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40037 allowNegative : true,
40039 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40041 minValue : Number.NEGATIVE_INFINITY,
40043 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40045 maxValue : Number.MAX_VALUE,
40047 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40049 minText : "The minimum value for this field is {0}",
40051 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40053 maxText : "The maximum value for this field is {0}",
40055 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40056 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40058 nanText : "{0} is not a valid number",
40060 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40064 * @cfg {String} defaults currency of the MoneyField
40065 * value should be in lkey
40067 defaultCurrency : false,
40069 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40071 thousandsDelimiter : false,
40081 getAutoCreate : function()
40083 var align = this.labelAlign || this.parentLabelAlign();
40095 cls : 'form-control roo-money-amount-input',
40096 autocomplete: 'new-password'
40099 var hiddenInput = {
40103 cls: 'hidden-number-input'
40107 hiddenInput.name = this.name;
40110 if (this.disabled) {
40111 input.disabled = true;
40114 var clg = 12 - this.inputlg;
40115 var cmd = 12 - this.inputmd;
40116 var csm = 12 - this.inputsm;
40117 var cxs = 12 - this.inputxs;
40121 cls : 'row roo-money-field',
40125 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40129 cls: 'roo-select2-container input-group',
40133 cls : 'form-control roo-money-currency-input',
40134 autocomplete: 'new-password',
40136 name : this.currencyName
40140 cls : 'input-group-addon',
40154 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40158 cls: this.hasFeedback ? 'has-feedback' : '',
40169 if (this.fieldLabel.length) {
40172 tooltip: 'This field is required'
40178 cls: 'control-label',
40184 html: this.fieldLabel
40187 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40193 if(this.indicatorpos == 'right') {
40194 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40201 if(align == 'left') {
40209 if(this.labelWidth > 12){
40210 label.style = "width: " + this.labelWidth + 'px';
40212 if(this.labelWidth < 13 && this.labelmd == 0){
40213 this.labelmd = this.labelWidth;
40215 if(this.labellg > 0){
40216 label.cls += ' col-lg-' + this.labellg;
40217 input.cls += ' col-lg-' + (12 - this.labellg);
40219 if(this.labelmd > 0){
40220 label.cls += ' col-md-' + this.labelmd;
40221 container.cls += ' col-md-' + (12 - this.labelmd);
40223 if(this.labelsm > 0){
40224 label.cls += ' col-sm-' + this.labelsm;
40225 container.cls += ' col-sm-' + (12 - this.labelsm);
40227 if(this.labelxs > 0){
40228 label.cls += ' col-xs-' + this.labelxs;
40229 container.cls += ' col-xs-' + (12 - this.labelxs);
40240 var settings = this;
40242 ['xs','sm','md','lg'].map(function(size){
40243 if (settings[size]) {
40244 cfg.cls += ' col-' + size + '-' + settings[size];
40251 initEvents : function()
40253 this.indicator = this.indicatorEl();
40255 this.initCurrencyEvent();
40257 this.initNumberEvent();
40260 initCurrencyEvent : function()
40263 throw "can not find store for combo";
40266 this.store = Roo.factory(this.store, Roo.data);
40267 this.store.parent = this;
40271 this.triggerEl = this.el.select('.input-group-addon', true).first();
40273 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40278 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40279 _this.list.setWidth(lw);
40282 this.list.on('mouseover', this.onViewOver, this);
40283 this.list.on('mousemove', this.onViewMove, this);
40284 this.list.on('scroll', this.onViewScroll, this);
40287 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40290 this.view = new Roo.View(this.list, this.tpl, {
40291 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40294 this.view.on('click', this.onViewClick, this);
40296 this.store.on('beforeload', this.onBeforeLoad, this);
40297 this.store.on('load', this.onLoad, this);
40298 this.store.on('loadexception', this.onLoadException, this);
40300 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40301 "up" : function(e){
40302 this.inKeyMode = true;
40306 "down" : function(e){
40307 if(!this.isExpanded()){
40308 this.onTriggerClick();
40310 this.inKeyMode = true;
40315 "enter" : function(e){
40318 if(this.fireEvent("specialkey", this, e)){
40319 this.onViewClick(false);
40325 "esc" : function(e){
40329 "tab" : function(e){
40332 if(this.fireEvent("specialkey", this, e)){
40333 this.onViewClick(false);
40341 doRelay : function(foo, bar, hname){
40342 if(hname == 'down' || this.scope.isExpanded()){
40343 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40351 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40355 initNumberEvent : function(e)
40357 this.inputEl().on("keydown" , this.fireKey, this);
40358 this.inputEl().on("focus", this.onFocus, this);
40359 this.inputEl().on("blur", this.onBlur, this);
40361 this.inputEl().relayEvent('keyup', this);
40363 if(this.indicator){
40364 this.indicator.addClass('invisible');
40367 this.originalValue = this.getValue();
40369 if(this.validationEvent == 'keyup'){
40370 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40371 this.inputEl().on('keyup', this.filterValidation, this);
40373 else if(this.validationEvent !== false){
40374 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40377 if(this.selectOnFocus){
40378 this.on("focus", this.preFocus, this);
40381 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40382 this.inputEl().on("keypress", this.filterKeys, this);
40384 this.inputEl().relayEvent('keypress', this);
40387 var allowed = "0123456789";
40389 if(this.allowDecimals){
40390 allowed += this.decimalSeparator;
40393 if(this.allowNegative){
40397 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40399 var keyPress = function(e){
40401 var k = e.getKey();
40403 var c = e.getCharCode();
40406 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40407 allowed.indexOf(String.fromCharCode(c)) === -1
40413 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40417 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40422 this.inputEl().on("keypress", keyPress, this);
40426 onTriggerClick : function(e)
40433 this.loadNext = false;
40435 if(this.isExpanded()){
40440 this.hasFocus = true;
40442 if(this.triggerAction == 'all') {
40443 this.doQuery(this.allQuery, true);
40447 this.doQuery(this.getRawValue());
40450 getCurrency : function()
40452 var v = this.currencyEl().getValue();
40457 restrictHeight : function()
40459 this.list.alignTo(this.currencyEl(), this.listAlign);
40460 this.list.alignTo(this.currencyEl(), this.listAlign);
40463 onViewClick : function(view, doFocus, el, e)
40465 var index = this.view.getSelectedIndexes()[0];
40467 var r = this.store.getAt(index);
40470 this.onSelect(r, index);
40474 onSelect : function(record, index){
40476 if(this.fireEvent('beforeselect', this, record, index) !== false){
40478 this.setFromCurrencyData(index > -1 ? record.data : false);
40482 this.fireEvent('select', this, record, index);
40486 setFromCurrencyData : function(o)
40490 this.lastCurrency = o;
40492 if (this.currencyField) {
40493 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40495 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40498 this.lastSelectionText = currency;
40500 //setting default currency
40501 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40502 this.setCurrency(this.defaultCurrency);
40506 this.setCurrency(currency);
40509 setFromData : function(o)
40513 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40515 this.setFromCurrencyData(c);
40520 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40522 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40525 this.setValue(value);
40529 setCurrency : function(v)
40531 this.currencyValue = v;
40534 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40539 setValue : function(v)
40541 v = this.fixPrecision(v);
40543 v = String(v).replace(".", this.decimalSeparator);
40549 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40551 this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
40552 this.thousandsDelimiter || ','
40555 if(this.allowBlank && !v) {
40556 this.inputEl().dom.value = '';
40563 getRawValue : function()
40565 var v = this.inputEl().getValue();
40570 getValue : function()
40572 return this.fixPrecision(this.parseValue(this.getRawValue()));
40575 parseValue : function(value)
40577 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40578 return isNaN(value) ? '' : value;
40581 fixPrecision : function(value)
40583 var nan = isNaN(value);
40585 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40586 return nan ? '' : value;
40589 return parseFloat(value).toFixed(this.decimalPrecision);
40592 decimalPrecisionFcn : function(v)
40594 return Math.floor(v);
40597 validateValue : function(value)
40599 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40603 var num = this.parseValue(value);
40606 this.markInvalid(String.format(this.nanText, value));
40610 if(num < this.minValue){
40611 this.markInvalid(String.format(this.minText, this.minValue));
40615 if(num > this.maxValue){
40616 this.markInvalid(String.format(this.maxText, this.maxValue));
40623 validate : function()
40625 if(this.disabled || this.allowBlank){
40630 var currency = this.getCurrency();
40632 if(this.validateValue(this.getRawValue()) && currency.length){
40637 this.markInvalid();
40641 getName: function()
40646 beforeBlur : function()
40652 var v = this.parseValue(this.getRawValue());
40659 onBlur : function()
40663 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40664 //this.el.removeClass(this.focusClass);
40667 this.hasFocus = false;
40669 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40673 var v = this.getValue();
40675 if(String(v) !== String(this.startValue)){
40676 this.fireEvent('change', this, v, this.startValue);
40679 this.fireEvent("blur", this);
40682 inputEl : function()
40684 return this.el.select('.roo-money-amount-input', true).first();
40687 currencyEl : function()
40689 return this.el.select('.roo-money-currency-input', true).first();
40692 hiddenEl : function()
40694 return this.el.select('input.hidden-number-input',true).first();