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){
7560 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7562 Roo.bootstrap.Form.popover.apply();
7566 * @event clientvalidation
7567 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7568 * @param {Form} this
7569 * @param {Boolean} valid true if the form has passed client-side validation
7571 clientvalidation: true,
7573 * @event beforeaction
7574 * Fires before any action is performed. Return false to cancel the action.
7575 * @param {Form} this
7576 * @param {Action} action The action to be performed
7580 * @event actionfailed
7581 * Fires when an action fails.
7582 * @param {Form} this
7583 * @param {Action} action The action that failed
7585 actionfailed : true,
7587 * @event actioncomplete
7588 * Fires when an action is completed.
7589 * @param {Form} this
7590 * @param {Action} action The action that completed
7592 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){
8073 * @return {BasicForm} this
8076 var items = this.getItems();
8077 items.each(function(f){
8081 Roo.each(this.childForms || [], function (f) {
8089 getItems : function()
8091 var r=new Roo.util.MixedCollection(false, function(o){
8092 return o.id || (o.id = Roo.id());
8094 var iter = function(el) {
8101 Roo.each(el.items,function(e) {
8115 Roo.apply(Roo.bootstrap.Form, {
8142 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8143 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8144 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8145 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8148 this.maskEl.top.enableDisplayMode("block");
8149 this.maskEl.left.enableDisplayMode("block");
8150 this.maskEl.bottom.enableDisplayMode("block");
8151 this.maskEl.right.enableDisplayMode("block");
8153 this.toolTip = new Roo.bootstrap.Tooltip({
8154 cls : 'roo-form-error-popover',
8156 'left' : ['r-l', [-2,0], 'right'],
8157 'right' : ['l-r', [2,0], 'left'],
8158 'bottom' : ['tl-bl', [0,2], 'top'],
8159 'top' : [ 'bl-tl', [0,-2], 'bottom']
8163 this.toolTip.render(Roo.get(document.body));
8165 this.toolTip.el.enableDisplayMode("block");
8167 Roo.get(document.body).on('click', function(){
8171 Roo.get(document.body).on('touchstart', function(){
8175 this.isApplied = true
8178 mask : function(form, target)
8182 this.target = target;
8184 if(!this.form.errorMask || !target.el){
8188 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8190 Roo.log(scrollable);
8192 var ot = this.target.el.calcOffsetsTo(scrollable);
8194 var scrollTo = ot[1] - this.form.maskOffset;
8196 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8198 scrollable.scrollTo('top', scrollTo);
8200 var box = this.target.el.getBox();
8202 var zIndex = Roo.bootstrap.Modal.zIndex++;
8205 this.maskEl.top.setStyle('position', 'absolute');
8206 this.maskEl.top.setStyle('z-index', zIndex);
8207 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8208 this.maskEl.top.setLeft(0);
8209 this.maskEl.top.setTop(0);
8210 this.maskEl.top.show();
8212 this.maskEl.left.setStyle('position', 'absolute');
8213 this.maskEl.left.setStyle('z-index', zIndex);
8214 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8215 this.maskEl.left.setLeft(0);
8216 this.maskEl.left.setTop(box.y - this.padding);
8217 this.maskEl.left.show();
8219 this.maskEl.bottom.setStyle('position', 'absolute');
8220 this.maskEl.bottom.setStyle('z-index', zIndex);
8221 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8222 this.maskEl.bottom.setLeft(0);
8223 this.maskEl.bottom.setTop(box.bottom + this.padding);
8224 this.maskEl.bottom.show();
8226 this.maskEl.right.setStyle('position', 'absolute');
8227 this.maskEl.right.setStyle('z-index', zIndex);
8228 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8229 this.maskEl.right.setLeft(box.right + this.padding);
8230 this.maskEl.right.setTop(box.y - this.padding);
8231 this.maskEl.right.show();
8233 this.toolTip.bindEl = this.target.el;
8235 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8237 var tip = this.target.blankText;
8239 if(this.target.getValue() !== '' ) {
8241 if (this.target.invalidText.length) {
8242 tip = this.target.invalidText;
8243 } else if (this.target.regexText.length){
8244 tip = this.target.regexText;
8248 this.toolTip.show(tip);
8250 this.intervalID = window.setInterval(function() {
8251 Roo.bootstrap.Form.popover.unmask();
8254 window.onwheel = function(){ return false;};
8256 (function(){ this.isMasked = true; }).defer(500, this);
8262 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8266 this.maskEl.top.setStyle('position', 'absolute');
8267 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8268 this.maskEl.top.hide();
8270 this.maskEl.left.setStyle('position', 'absolute');
8271 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8272 this.maskEl.left.hide();
8274 this.maskEl.bottom.setStyle('position', 'absolute');
8275 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8276 this.maskEl.bottom.hide();
8278 this.maskEl.right.setStyle('position', 'absolute');
8279 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8280 this.maskEl.right.hide();
8282 this.toolTip.hide();
8284 this.toolTip.el.hide();
8286 window.onwheel = function(){ return true;};
8288 if(this.intervalID){
8289 window.clearInterval(this.intervalID);
8290 this.intervalID = false;
8293 this.isMasked = false;
8303 * Ext JS Library 1.1.1
8304 * Copyright(c) 2006-2007, Ext JS, LLC.
8306 * Originally Released Under LGPL - original licence link has changed is not relivant.
8309 * <script type="text/javascript">
8312 * @class Roo.form.VTypes
8313 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8316 Roo.form.VTypes = function(){
8317 // closure these in so they are only created once.
8318 var alpha = /^[a-zA-Z_]+$/;
8319 var alphanum = /^[a-zA-Z0-9_]+$/;
8320 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8321 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8323 // All these messages and functions are configurable
8326 * The function used to validate email addresses
8327 * @param {String} value The email address
8329 'email' : function(v){
8330 return email.test(v);
8333 * The error text to display when the email validation function returns false
8336 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8338 * The keystroke filter mask to be applied on email input
8341 'emailMask' : /[a-z0-9_\.\-@]/i,
8344 * The function used to validate URLs
8345 * @param {String} value The URL
8347 'url' : function(v){
8351 * The error text to display when the url validation function returns false
8354 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8357 * The function used to validate alpha values
8358 * @param {String} value The value
8360 'alpha' : function(v){
8361 return alpha.test(v);
8364 * The error text to display when the alpha validation function returns false
8367 'alphaText' : 'This field should only contain letters and _',
8369 * The keystroke filter mask to be applied on alpha input
8372 'alphaMask' : /[a-z_]/i,
8375 * The function used to validate alphanumeric values
8376 * @param {String} value The value
8378 'alphanum' : function(v){
8379 return alphanum.test(v);
8382 * The error text to display when the alphanumeric validation function returns false
8385 'alphanumText' : 'This field should only contain letters, numbers and _',
8387 * The keystroke filter mask to be applied on alphanumeric input
8390 'alphanumMask' : /[a-z0-9_]/i
8400 * @class Roo.bootstrap.Input
8401 * @extends Roo.bootstrap.Component
8402 * Bootstrap Input class
8403 * @cfg {Boolean} disabled is it disabled
8404 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8405 * @cfg {String} name name of the input
8406 * @cfg {string} fieldLabel - the label associated
8407 * @cfg {string} placeholder - placeholder to put in text.
8408 * @cfg {string} before - input group add on before
8409 * @cfg {string} after - input group add on after
8410 * @cfg {string} size - (lg|sm) or leave empty..
8411 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8412 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8413 * @cfg {Number} md colspan out of 12 for computer-sized screens
8414 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8415 * @cfg {string} value default value of the input
8416 * @cfg {Number} labelWidth set the width of label
8417 * @cfg {Number} labellg set the width of label (1-12)
8418 * @cfg {Number} labelmd set the width of label (1-12)
8419 * @cfg {Number} labelsm set the width of label (1-12)
8420 * @cfg {Number} labelxs set the width of label (1-12)
8421 * @cfg {String} labelAlign (top|left)
8422 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8423 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8424 * @cfg {String} indicatorpos (left|right) default left
8426 * @cfg {String} align (left|center|right) Default left
8427 * @cfg {Boolean} forceFeedback (true|false) Default false
8433 * Create a new Input
8434 * @param {Object} config The config object
8437 Roo.bootstrap.Input = function(config){
8439 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8444 * Fires when this field receives input focus.
8445 * @param {Roo.form.Field} this
8450 * Fires when this field loses input focus.
8451 * @param {Roo.form.Field} this
8456 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8457 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8458 * @param {Roo.form.Field} this
8459 * @param {Roo.EventObject} e The event object
8464 * Fires just before the field blurs if the field value has changed.
8465 * @param {Roo.form.Field} this
8466 * @param {Mixed} newValue The new value
8467 * @param {Mixed} oldValue The original value
8472 * Fires after the field has been marked as invalid.
8473 * @param {Roo.form.Field} this
8474 * @param {String} msg The validation message
8479 * Fires after the field has been validated with no errors.
8480 * @param {Roo.form.Field} this
8485 * Fires after the key up
8486 * @param {Roo.form.Field} this
8487 * @param {Roo.EventObject} e The event Object
8493 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8495 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8496 automatic validation (defaults to "keyup").
8498 validationEvent : "keyup",
8500 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8502 validateOnBlur : true,
8504 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8506 validationDelay : 250,
8508 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8510 focusClass : "x-form-focus", // not needed???
8514 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8516 invalidClass : "has-warning",
8519 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8521 validClass : "has-success",
8524 * @cfg {Boolean} hasFeedback (true|false) default true
8529 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8531 invalidFeedbackClass : "glyphicon-warning-sign",
8534 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8536 validFeedbackClass : "glyphicon-ok",
8539 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8541 selectOnFocus : false,
8544 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8548 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8553 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8555 disableKeyFilter : false,
8558 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8562 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8566 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8568 blankText : "Please complete this mandatory field",
8571 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8575 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8577 maxLength : Number.MAX_VALUE,
8579 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8581 minLengthText : "The minimum length for this field is {0}",
8583 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8585 maxLengthText : "The maximum length for this field is {0}",
8589 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8590 * If available, this function will be called only after the basic validators all return true, and will be passed the
8591 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8595 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8596 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8597 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8601 * @cfg {String} regexText -- Depricated - use Invalid Text
8606 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8612 autocomplete: false,
8631 formatedValue : false,
8632 forceFeedback : false,
8634 indicatorpos : 'left',
8641 parentLabelAlign : function()
8644 while (parent.parent()) {
8645 parent = parent.parent();
8646 if (typeof(parent.labelAlign) !='undefined') {
8647 return parent.labelAlign;
8654 getAutoCreate : function()
8656 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8662 if(this.inputType != 'hidden'){
8663 cfg.cls = 'form-group' //input-group
8669 type : this.inputType,
8671 cls : 'form-control',
8672 placeholder : this.placeholder || '',
8673 autocomplete : this.autocomplete || 'new-password'
8677 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8680 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8681 input.maxLength = this.maxLength;
8684 if (this.disabled) {
8685 input.disabled=true;
8688 if (this.readOnly) {
8689 input.readonly=true;
8693 input.name = this.name;
8697 input.cls += ' input-' + this.size;
8701 ['xs','sm','md','lg'].map(function(size){
8702 if (settings[size]) {
8703 cfg.cls += ' col-' + size + '-' + settings[size];
8707 var inputblock = input;
8711 cls: 'glyphicon form-control-feedback'
8714 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8717 cls : 'has-feedback',
8725 if (this.before || this.after) {
8728 cls : 'input-group',
8732 if (this.before && typeof(this.before) == 'string') {
8734 inputblock.cn.push({
8736 cls : 'roo-input-before input-group-addon',
8740 if (this.before && typeof(this.before) == 'object') {
8741 this.before = Roo.factory(this.before);
8743 inputblock.cn.push({
8745 cls : 'roo-input-before input-group-' +
8746 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8750 inputblock.cn.push(input);
8752 if (this.after && typeof(this.after) == 'string') {
8753 inputblock.cn.push({
8755 cls : 'roo-input-after input-group-addon',
8759 if (this.after && typeof(this.after) == 'object') {
8760 this.after = Roo.factory(this.after);
8762 inputblock.cn.push({
8764 cls : 'roo-input-after input-group-' +
8765 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8769 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8770 inputblock.cls += ' has-feedback';
8771 inputblock.cn.push(feedback);
8775 if (align ==='left' && this.fieldLabel.length) {
8777 cfg.cls += ' roo-form-group-label-left';
8782 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8783 tooltip : 'This field is required'
8788 cls : 'control-label',
8789 html : this.fieldLabel
8800 var labelCfg = cfg.cn[1];
8801 var contentCfg = cfg.cn[2];
8803 if(this.indicatorpos == 'right'){
8808 cls : 'control-label',
8812 html : this.fieldLabel
8816 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8817 tooltip : 'This field is required'
8830 labelCfg = cfg.cn[0];
8831 contentCfg = cfg.cn[1];
8835 if(this.labelWidth > 12){
8836 labelCfg.style = "width: " + this.labelWidth + 'px';
8839 if(this.labelWidth < 13 && this.labelmd == 0){
8840 this.labelmd = this.labelWidth;
8843 if(this.labellg > 0){
8844 labelCfg.cls += ' col-lg-' + this.labellg;
8845 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8848 if(this.labelmd > 0){
8849 labelCfg.cls += ' col-md-' + this.labelmd;
8850 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8853 if(this.labelsm > 0){
8854 labelCfg.cls += ' col-sm-' + this.labelsm;
8855 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8858 if(this.labelxs > 0){
8859 labelCfg.cls += ' col-xs-' + this.labelxs;
8860 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8864 } else if ( this.fieldLabel.length) {
8869 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8870 tooltip : 'This field is required'
8874 //cls : 'input-group-addon',
8875 html : this.fieldLabel
8883 if(this.indicatorpos == 'right'){
8888 //cls : 'input-group-addon',
8889 html : this.fieldLabel
8894 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8895 tooltip : 'This field is required'
8915 if (this.parentType === 'Navbar' && this.parent().bar) {
8916 cfg.cls += ' navbar-form';
8919 if (this.parentType === 'NavGroup') {
8920 cfg.cls += ' navbar-form';
8928 * return the real input element.
8930 inputEl: function ()
8932 return this.el.select('input.form-control',true).first();
8935 tooltipEl : function()
8937 return this.inputEl();
8940 indicatorEl : function()
8942 var indicator = this.el.select('i.roo-required-indicator',true).first();
8952 setDisabled : function(v)
8954 var i = this.inputEl().dom;
8956 i.removeAttribute('disabled');
8960 i.setAttribute('disabled','true');
8962 initEvents : function()
8965 this.inputEl().on("keydown" , this.fireKey, this);
8966 this.inputEl().on("focus", this.onFocus, this);
8967 this.inputEl().on("blur", this.onBlur, this);
8969 this.inputEl().relayEvent('keyup', this);
8971 this.indicator = this.indicatorEl();
8974 this.indicator.addClass('invisible');
8978 // reference to original value for reset
8979 this.originalValue = this.getValue();
8980 //Roo.form.TextField.superclass.initEvents.call(this);
8981 if(this.validationEvent == 'keyup'){
8982 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8983 this.inputEl().on('keyup', this.filterValidation, this);
8985 else if(this.validationEvent !== false){
8986 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8989 if(this.selectOnFocus){
8990 this.on("focus", this.preFocus, this);
8993 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8994 this.inputEl().on("keypress", this.filterKeys, this);
8996 this.inputEl().relayEvent('keypress', this);
8999 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9000 this.el.on("click", this.autoSize, this);
9003 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9004 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9007 if (typeof(this.before) == 'object') {
9008 this.before.render(this.el.select('.roo-input-before',true).first());
9010 if (typeof(this.after) == 'object') {
9011 this.after.render(this.el.select('.roo-input-after',true).first());
9016 filterValidation : function(e){
9017 if(!e.isNavKeyPress()){
9018 this.validationTask.delay(this.validationDelay);
9022 * Validates the field value
9023 * @return {Boolean} True if the value is valid, else false
9025 validate : function(){
9026 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9027 if(this.disabled || this.validateValue(this.getRawValue())){
9038 * Validates a value according to the field's validation rules and marks the field as invalid
9039 * if the validation fails
9040 * @param {Mixed} value The value to validate
9041 * @return {Boolean} True if the value is valid, else false
9043 validateValue : function(value){
9044 if(value.length < 1) { // if it's blank
9045 if(this.allowBlank){
9048 return this.inputEl().hasClass('hide') ? true : false;
9051 if(value.length < this.minLength){
9054 if(value.length > this.maxLength){
9058 var vt = Roo.form.VTypes;
9059 if(!vt[this.vtype](value, this)){
9063 if(typeof this.validator == "function"){
9064 var msg = this.validator(value);
9068 if (typeof(msg) == 'string') {
9069 this.invalidText = msg;
9073 if(this.regex && !this.regex.test(value)){
9083 fireKey : function(e){
9084 //Roo.log('field ' + e.getKey());
9085 if(e.isNavKeyPress()){
9086 this.fireEvent("specialkey", this, e);
9089 focus : function (selectText){
9091 this.inputEl().focus();
9092 if(selectText === true){
9093 this.inputEl().dom.select();
9099 onFocus : function(){
9100 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9101 // this.el.addClass(this.focusClass);
9104 this.hasFocus = true;
9105 this.startValue = this.getValue();
9106 this.fireEvent("focus", this);
9110 beforeBlur : Roo.emptyFn,
9114 onBlur : function(){
9116 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9117 //this.el.removeClass(this.focusClass);
9119 this.hasFocus = false;
9120 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9123 var v = this.getValue();
9124 if(String(v) !== String(this.startValue)){
9125 this.fireEvent('change', this, v, this.startValue);
9127 this.fireEvent("blur", this);
9131 * Resets the current field value to the originally loaded value and clears any validation messages
9134 this.setValue(this.originalValue);
9138 * Returns the name of the field
9139 * @return {Mixed} name The name field
9141 getName: function(){
9145 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9146 * @return {Mixed} value The field value
9148 getValue : function(){
9150 var v = this.inputEl().getValue();
9155 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9156 * @return {Mixed} value The field value
9158 getRawValue : function(){
9159 var v = this.inputEl().getValue();
9165 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9166 * @param {Mixed} value The value to set
9168 setRawValue : function(v){
9169 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9172 selectText : function(start, end){
9173 var v = this.getRawValue();
9175 start = start === undefined ? 0 : start;
9176 end = end === undefined ? v.length : end;
9177 var d = this.inputEl().dom;
9178 if(d.setSelectionRange){
9179 d.setSelectionRange(start, end);
9180 }else if(d.createTextRange){
9181 var range = d.createTextRange();
9182 range.moveStart("character", start);
9183 range.moveEnd("character", v.length-end);
9190 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9191 * @param {Mixed} value The value to set
9193 setValue : function(v){
9196 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9202 processValue : function(value){
9203 if(this.stripCharsRe){
9204 var newValue = value.replace(this.stripCharsRe, '');
9205 if(newValue !== value){
9206 this.setRawValue(newValue);
9213 preFocus : function(){
9215 if(this.selectOnFocus){
9216 this.inputEl().dom.select();
9219 filterKeys : function(e){
9221 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9224 var c = e.getCharCode(), cc = String.fromCharCode(c);
9225 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9228 if(!this.maskRe.test(cc)){
9233 * Clear any invalid styles/messages for this field
9235 clearInvalid : function(){
9237 if(!this.el || this.preventMark){ // not rendered
9242 this.el.removeClass(this.invalidClass);
9244 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9246 var feedback = this.el.select('.form-control-feedback', true).first();
9249 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9254 this.fireEvent('valid', this);
9258 * Mark this field as valid
9260 markValid : function()
9262 if(!this.el || this.preventMark){ // not rendered...
9266 this.el.removeClass([this.invalidClass, this.validClass]);
9268 var feedback = this.el.select('.form-control-feedback', true).first();
9271 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9275 this.indicator.removeClass('visible');
9276 this.indicator.addClass('invisible');
9283 if(this.allowBlank && !this.getRawValue().length){
9287 this.el.addClass(this.validClass);
9289 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9291 var feedback = this.el.select('.form-control-feedback', true).first();
9294 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9295 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9300 this.fireEvent('valid', this);
9304 * Mark this field as invalid
9305 * @param {String} msg The validation message
9307 markInvalid : function(msg)
9309 if(!this.el || this.preventMark){ // not rendered
9313 this.el.removeClass([this.invalidClass, this.validClass]);
9315 var feedback = this.el.select('.form-control-feedback', true).first();
9318 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9325 if(this.allowBlank && !this.getRawValue().length){
9330 this.indicator.removeClass('invisible');
9331 this.indicator.addClass('visible');
9334 this.el.addClass(this.invalidClass);
9336 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9338 var feedback = this.el.select('.form-control-feedback', true).first();
9341 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9343 if(this.getValue().length || this.forceFeedback){
9344 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9351 this.fireEvent('invalid', this, msg);
9354 SafariOnKeyDown : function(event)
9356 // this is a workaround for a password hang bug on chrome/ webkit.
9357 if (this.inputEl().dom.type != 'password') {
9361 var isSelectAll = false;
9363 if(this.inputEl().dom.selectionEnd > 0){
9364 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9366 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9367 event.preventDefault();
9372 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9374 event.preventDefault();
9375 // this is very hacky as keydown always get's upper case.
9377 var cc = String.fromCharCode(event.getCharCode());
9378 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9382 adjustWidth : function(tag, w){
9383 tag = tag.toLowerCase();
9384 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9385 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9389 if(tag == 'textarea'){
9392 }else if(Roo.isOpera){
9396 if(tag == 'textarea'){
9404 setFieldLabel : function(v)
9411 var ar = this.el.select('label > span',true);
9413 if (ar.elements.length) {
9414 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9415 this.fieldLabel = v;
9419 var br = this.el.select('label',true);
9421 if(br.elements.length) {
9422 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9423 this.fieldLabel = v;
9427 Roo.log('Cannot Found any of label > span || label in input');
9431 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9432 this.fieldLabel = v;
9447 * @class Roo.bootstrap.TextArea
9448 * @extends Roo.bootstrap.Input
9449 * Bootstrap TextArea class
9450 * @cfg {Number} cols Specifies the visible width of a text area
9451 * @cfg {Number} rows Specifies the visible number of lines in a text area
9452 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9453 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9454 * @cfg {string} html text
9457 * Create a new TextArea
9458 * @param {Object} config The config object
9461 Roo.bootstrap.TextArea = function(config){
9462 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9466 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9476 getAutoCreate : function(){
9478 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9484 if(this.inputType != 'hidden'){
9485 cfg.cls = 'form-group' //input-group
9493 value : this.value || '',
9494 html: this.html || '',
9495 cls : 'form-control',
9496 placeholder : this.placeholder || ''
9500 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9501 input.maxLength = this.maxLength;
9505 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9509 input.cols = this.cols;
9512 if (this.readOnly) {
9513 input.readonly = true;
9517 input.name = this.name;
9521 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9525 ['xs','sm','md','lg'].map(function(size){
9526 if (settings[size]) {
9527 cfg.cls += ' col-' + size + '-' + settings[size];
9531 var inputblock = input;
9533 if(this.hasFeedback && !this.allowBlank){
9537 cls: 'glyphicon form-control-feedback'
9541 cls : 'has-feedback',
9550 if (this.before || this.after) {
9553 cls : 'input-group',
9557 inputblock.cn.push({
9559 cls : 'input-group-addon',
9564 inputblock.cn.push(input);
9566 if(this.hasFeedback && !this.allowBlank){
9567 inputblock.cls += ' has-feedback';
9568 inputblock.cn.push(feedback);
9572 inputblock.cn.push({
9574 cls : 'input-group-addon',
9581 if (align ==='left' && this.fieldLabel.length) {
9586 cls : 'control-label',
9587 html : this.fieldLabel
9598 if(this.labelWidth > 12){
9599 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9602 if(this.labelWidth < 13 && this.labelmd == 0){
9603 this.labelmd = this.labelWidth;
9606 if(this.labellg > 0){
9607 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9608 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9611 if(this.labelmd > 0){
9612 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9613 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9616 if(this.labelsm > 0){
9617 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9618 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9621 if(this.labelxs > 0){
9622 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9623 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9626 } else if ( this.fieldLabel.length) {
9631 //cls : 'input-group-addon',
9632 html : this.fieldLabel
9650 if (this.disabled) {
9651 input.disabled=true;
9658 * return the real textarea element.
9660 inputEl: function ()
9662 return this.el.select('textarea.form-control',true).first();
9666 * Clear any invalid styles/messages for this field
9668 clearInvalid : function()
9671 if(!this.el || this.preventMark){ // not rendered
9675 var label = this.el.select('label', true).first();
9676 var icon = this.el.select('i.fa-star', true).first();
9682 this.el.removeClass(this.invalidClass);
9684 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9686 var feedback = this.el.select('.form-control-feedback', true).first();
9689 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9694 this.fireEvent('valid', this);
9698 * Mark this field as valid
9700 markValid : function()
9702 if(!this.el || this.preventMark){ // not rendered
9706 this.el.removeClass([this.invalidClass, this.validClass]);
9708 var feedback = this.el.select('.form-control-feedback', true).first();
9711 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9714 if(this.disabled || this.allowBlank){
9718 var label = this.el.select('label', true).first();
9719 var icon = this.el.select('i.fa-star', true).first();
9725 this.el.addClass(this.validClass);
9727 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9729 var feedback = this.el.select('.form-control-feedback', true).first();
9732 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9733 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9738 this.fireEvent('valid', this);
9742 * Mark this field as invalid
9743 * @param {String} msg The validation message
9745 markInvalid : function(msg)
9747 if(!this.el || this.preventMark){ // not rendered
9751 this.el.removeClass([this.invalidClass, this.validClass]);
9753 var feedback = this.el.select('.form-control-feedback', true).first();
9756 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9759 if(this.disabled || this.allowBlank){
9763 var label = this.el.select('label', true).first();
9764 var icon = this.el.select('i.fa-star', true).first();
9766 if(!this.getValue().length && label && !icon){
9767 this.el.createChild({
9769 cls : 'text-danger fa fa-lg fa-star',
9770 tooltip : 'This field is required',
9771 style : 'margin-right:5px;'
9775 this.el.addClass(this.invalidClass);
9777 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9779 var feedback = this.el.select('.form-control-feedback', true).first();
9782 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9784 if(this.getValue().length || this.forceFeedback){
9785 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9792 this.fireEvent('invalid', this, msg);
9800 * trigger field - base class for combo..
9805 * @class Roo.bootstrap.TriggerField
9806 * @extends Roo.bootstrap.Input
9807 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9808 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9809 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9810 * for which you can provide a custom implementation. For example:
9812 var trigger = new Roo.bootstrap.TriggerField();
9813 trigger.onTriggerClick = myTriggerFn;
9814 trigger.applyTo('my-field');
9817 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9818 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9819 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9820 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9821 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9824 * Create a new TriggerField.
9825 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9826 * to the base TextField)
9828 Roo.bootstrap.TriggerField = function(config){
9829 this.mimicing = false;
9830 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9833 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9835 * @cfg {String} triggerClass A CSS class to apply to the trigger
9838 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9843 * @cfg {Boolean} removable (true|false) special filter default false
9847 /** @cfg {Boolean} grow @hide */
9848 /** @cfg {Number} growMin @hide */
9849 /** @cfg {Number} growMax @hide */
9855 autoSize: Roo.emptyFn,
9862 actionMode : 'wrap',
9867 getAutoCreate : function(){
9869 var align = this.labelAlign || this.parentLabelAlign();
9874 cls: 'form-group' //input-group
9881 type : this.inputType,
9882 cls : 'form-control',
9883 autocomplete: 'new-password',
9884 placeholder : this.placeholder || ''
9888 input.name = this.name;
9891 input.cls += ' input-' + this.size;
9894 if (this.disabled) {
9895 input.disabled=true;
9898 var inputblock = input;
9900 if(this.hasFeedback && !this.allowBlank){
9904 cls: 'glyphicon form-control-feedback'
9907 if(this.removable && !this.editable && !this.tickable){
9909 cls : 'has-feedback',
9915 cls : 'roo-combo-removable-btn close'
9922 cls : 'has-feedback',
9931 if(this.removable && !this.editable && !this.tickable){
9933 cls : 'roo-removable',
9939 cls : 'roo-combo-removable-btn close'
9946 if (this.before || this.after) {
9949 cls : 'input-group',
9953 inputblock.cn.push({
9955 cls : 'input-group-addon',
9960 inputblock.cn.push(input);
9962 if(this.hasFeedback && !this.allowBlank){
9963 inputblock.cls += ' has-feedback';
9964 inputblock.cn.push(feedback);
9968 inputblock.cn.push({
9970 cls : 'input-group-addon',
9983 cls: 'form-hidden-field'
9997 cls: 'form-hidden-field'
10001 cls: 'roo-select2-choices',
10005 cls: 'roo-select2-search-field',
10018 cls: 'roo-select2-container input-group',
10023 // cls: 'typeahead typeahead-long dropdown-menu',
10024 // style: 'display:none'
10029 if(!this.multiple && this.showToggleBtn){
10035 if (this.caret != false) {
10038 cls: 'fa fa-' + this.caret
10045 cls : 'input-group-addon btn dropdown-toggle',
10050 cls: 'combobox-clear',
10064 combobox.cls += ' roo-select2-container-multi';
10067 if (align ==='left' && this.fieldLabel.length) {
10069 cfg.cls += ' roo-form-group-label-left';
10074 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10075 tooltip : 'This field is required'
10080 cls : 'control-label',
10081 html : this.fieldLabel
10093 var labelCfg = cfg.cn[1];
10094 var contentCfg = cfg.cn[2];
10096 if(this.indicatorpos == 'right'){
10101 cls : 'control-label',
10105 html : this.fieldLabel
10109 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10110 tooltip : 'This field is required'
10123 labelCfg = cfg.cn[0];
10124 contentCfg = cfg.cn[1];
10127 if(this.labelWidth > 12){
10128 labelCfg.style = "width: " + this.labelWidth + 'px';
10131 if(this.labelWidth < 13 && this.labelmd == 0){
10132 this.labelmd = this.labelWidth;
10135 if(this.labellg > 0){
10136 labelCfg.cls += ' col-lg-' + this.labellg;
10137 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10140 if(this.labelmd > 0){
10141 labelCfg.cls += ' col-md-' + this.labelmd;
10142 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10145 if(this.labelsm > 0){
10146 labelCfg.cls += ' col-sm-' + this.labelsm;
10147 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10150 if(this.labelxs > 0){
10151 labelCfg.cls += ' col-xs-' + this.labelxs;
10152 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10155 } else if ( this.fieldLabel.length) {
10156 // Roo.log(" label");
10160 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10161 tooltip : 'This field is required'
10165 //cls : 'input-group-addon',
10166 html : this.fieldLabel
10174 if(this.indicatorpos == 'right'){
10182 html : this.fieldLabel
10186 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10187 tooltip : 'This field is required'
10200 // Roo.log(" no label && no align");
10207 ['xs','sm','md','lg'].map(function(size){
10208 if (settings[size]) {
10209 cfg.cls += ' col-' + size + '-' + settings[size];
10220 onResize : function(w, h){
10221 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10222 // if(typeof w == 'number'){
10223 // var x = w - this.trigger.getWidth();
10224 // this.inputEl().setWidth(this.adjustWidth('input', x));
10225 // this.trigger.setStyle('left', x+'px');
10230 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10233 getResizeEl : function(){
10234 return this.inputEl();
10238 getPositionEl : function(){
10239 return this.inputEl();
10243 alignErrorIcon : function(){
10244 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10248 initEvents : function(){
10252 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10253 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10254 if(!this.multiple && this.showToggleBtn){
10255 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10256 if(this.hideTrigger){
10257 this.trigger.setDisplayed(false);
10259 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10263 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10266 if(this.removable && !this.editable && !this.tickable){
10267 var close = this.closeTriggerEl();
10270 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10271 close.on('click', this.removeBtnClick, this, close);
10275 //this.trigger.addClassOnOver('x-form-trigger-over');
10276 //this.trigger.addClassOnClick('x-form-trigger-click');
10279 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10283 closeTriggerEl : function()
10285 var close = this.el.select('.roo-combo-removable-btn', true).first();
10286 return close ? close : false;
10289 removeBtnClick : function(e, h, el)
10291 e.preventDefault();
10293 if(this.fireEvent("remove", this) !== false){
10295 this.fireEvent("afterremove", this)
10299 createList : function()
10301 this.list = Roo.get(document.body).createChild({
10303 cls: 'typeahead typeahead-long dropdown-menu',
10304 style: 'display:none'
10307 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10312 initTrigger : function(){
10317 onDestroy : function(){
10319 this.trigger.removeAllListeners();
10320 // this.trigger.remove();
10323 // this.wrap.remove();
10325 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10329 onFocus : function(){
10330 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10332 if(!this.mimicing){
10333 this.wrap.addClass('x-trigger-wrap-focus');
10334 this.mimicing = true;
10335 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10336 if(this.monitorTab){
10337 this.el.on("keydown", this.checkTab, this);
10344 checkTab : function(e){
10345 if(e.getKey() == e.TAB){
10346 this.triggerBlur();
10351 onBlur : function(){
10356 mimicBlur : function(e, t){
10358 if(!this.wrap.contains(t) && this.validateBlur()){
10359 this.triggerBlur();
10365 triggerBlur : function(){
10366 this.mimicing = false;
10367 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10368 if(this.monitorTab){
10369 this.el.un("keydown", this.checkTab, this);
10371 //this.wrap.removeClass('x-trigger-wrap-focus');
10372 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10376 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10377 validateBlur : function(e, t){
10382 onDisable : function(){
10383 this.inputEl().dom.disabled = true;
10384 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10386 // this.wrap.addClass('x-item-disabled');
10391 onEnable : function(){
10392 this.inputEl().dom.disabled = false;
10393 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10395 // this.el.removeClass('x-item-disabled');
10400 onShow : function(){
10401 var ae = this.getActionEl();
10404 ae.dom.style.display = '';
10405 ae.dom.style.visibility = 'visible';
10411 onHide : function(){
10412 var ae = this.getActionEl();
10413 ae.dom.style.display = 'none';
10417 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10418 * by an implementing function.
10420 * @param {EventObject} e
10422 onTriggerClick : Roo.emptyFn
10426 * Ext JS Library 1.1.1
10427 * Copyright(c) 2006-2007, Ext JS, LLC.
10429 * Originally Released Under LGPL - original licence link has changed is not relivant.
10432 * <script type="text/javascript">
10437 * @class Roo.data.SortTypes
10439 * Defines the default sorting (casting?) comparison functions used when sorting data.
10441 Roo.data.SortTypes = {
10443 * Default sort that does nothing
10444 * @param {Mixed} s The value being converted
10445 * @return {Mixed} The comparison value
10447 none : function(s){
10452 * The regular expression used to strip tags
10456 stripTagsRE : /<\/?[^>]+>/gi,
10459 * Strips all HTML tags to sort on text only
10460 * @param {Mixed} s The value being converted
10461 * @return {String} The comparison value
10463 asText : function(s){
10464 return String(s).replace(this.stripTagsRE, "");
10468 * Strips all HTML tags to sort on text only - Case insensitive
10469 * @param {Mixed} s The value being converted
10470 * @return {String} The comparison value
10472 asUCText : function(s){
10473 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10477 * Case insensitive string
10478 * @param {Mixed} s The value being converted
10479 * @return {String} The comparison value
10481 asUCString : function(s) {
10482 return String(s).toUpperCase();
10487 * @param {Mixed} s The value being converted
10488 * @return {Number} The comparison value
10490 asDate : function(s) {
10494 if(s instanceof Date){
10495 return s.getTime();
10497 return Date.parse(String(s));
10502 * @param {Mixed} s The value being converted
10503 * @return {Float} The comparison value
10505 asFloat : function(s) {
10506 var val = parseFloat(String(s).replace(/,/g, ""));
10515 * @param {Mixed} s The value being converted
10516 * @return {Number} The comparison value
10518 asInt : function(s) {
10519 var val = parseInt(String(s).replace(/,/g, ""));
10527 * Ext JS Library 1.1.1
10528 * Copyright(c) 2006-2007, Ext JS, LLC.
10530 * Originally Released Under LGPL - original licence link has changed is not relivant.
10533 * <script type="text/javascript">
10537 * @class Roo.data.Record
10538 * Instances of this class encapsulate both record <em>definition</em> information, and record
10539 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10540 * to access Records cached in an {@link Roo.data.Store} object.<br>
10542 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10543 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10546 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10548 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10549 * {@link #create}. The parameters are the same.
10550 * @param {Array} data An associative Array of data values keyed by the field name.
10551 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10552 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10553 * not specified an integer id is generated.
10555 Roo.data.Record = function(data, id){
10556 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10561 * Generate a constructor for a specific record layout.
10562 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10563 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10564 * Each field definition object may contain the following properties: <ul>
10565 * <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,
10566 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10567 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10568 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10569 * is being used, then this is a string containing the javascript expression to reference the data relative to
10570 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10571 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10572 * this may be omitted.</p></li>
10573 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10574 * <ul><li>auto (Default, implies no conversion)</li>
10579 * <li>date</li></ul></p></li>
10580 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10581 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10582 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10583 * by the Reader into an object that will be stored in the Record. It is passed the
10584 * following parameters:<ul>
10585 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10587 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10589 * <br>usage:<br><pre><code>
10590 var TopicRecord = Roo.data.Record.create(
10591 {name: 'title', mapping: 'topic_title'},
10592 {name: 'author', mapping: 'username'},
10593 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10594 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10595 {name: 'lastPoster', mapping: 'user2'},
10596 {name: 'excerpt', mapping: 'post_text'}
10599 var myNewRecord = new TopicRecord({
10600 title: 'Do my job please',
10603 lastPost: new Date(),
10604 lastPoster: 'Animal',
10605 excerpt: 'No way dude!'
10607 myStore.add(myNewRecord);
10612 Roo.data.Record.create = function(o){
10613 var f = function(){
10614 f.superclass.constructor.apply(this, arguments);
10616 Roo.extend(f, Roo.data.Record);
10617 var p = f.prototype;
10618 p.fields = new Roo.util.MixedCollection(false, function(field){
10621 for(var i = 0, len = o.length; i < len; i++){
10622 p.fields.add(new Roo.data.Field(o[i]));
10624 f.getField = function(name){
10625 return p.fields.get(name);
10630 Roo.data.Record.AUTO_ID = 1000;
10631 Roo.data.Record.EDIT = 'edit';
10632 Roo.data.Record.REJECT = 'reject';
10633 Roo.data.Record.COMMIT = 'commit';
10635 Roo.data.Record.prototype = {
10637 * Readonly flag - true if this record has been modified.
10646 join : function(store){
10647 this.store = store;
10651 * Set the named field to the specified value.
10652 * @param {String} name The name of the field to set.
10653 * @param {Object} value The value to set the field to.
10655 set : function(name, value){
10656 if(this.data[name] == value){
10660 if(!this.modified){
10661 this.modified = {};
10663 if(typeof this.modified[name] == 'undefined'){
10664 this.modified[name] = this.data[name];
10666 this.data[name] = value;
10667 if(!this.editing && this.store){
10668 this.store.afterEdit(this);
10673 * Get the value of the named field.
10674 * @param {String} name The name of the field to get the value of.
10675 * @return {Object} The value of the field.
10677 get : function(name){
10678 return this.data[name];
10682 beginEdit : function(){
10683 this.editing = true;
10684 this.modified = {};
10688 cancelEdit : function(){
10689 this.editing = false;
10690 delete this.modified;
10694 endEdit : function(){
10695 this.editing = false;
10696 if(this.dirty && this.store){
10697 this.store.afterEdit(this);
10702 * Usually called by the {@link Roo.data.Store} which owns the Record.
10703 * Rejects all changes made to the Record since either creation, or the last commit operation.
10704 * Modified fields are reverted to their original values.
10706 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10707 * of reject operations.
10709 reject : function(){
10710 var m = this.modified;
10712 if(typeof m[n] != "function"){
10713 this.data[n] = m[n];
10716 this.dirty = false;
10717 delete this.modified;
10718 this.editing = false;
10720 this.store.afterReject(this);
10725 * Usually called by the {@link Roo.data.Store} which owns the Record.
10726 * Commits all changes made to the Record since either creation, or the last commit operation.
10728 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10729 * of commit operations.
10731 commit : function(){
10732 this.dirty = false;
10733 delete this.modified;
10734 this.editing = false;
10736 this.store.afterCommit(this);
10741 hasError : function(){
10742 return this.error != null;
10746 clearError : function(){
10751 * Creates a copy of this record.
10752 * @param {String} id (optional) A new record id if you don't want to use this record's id
10755 copy : function(newId) {
10756 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10760 * Ext JS Library 1.1.1
10761 * Copyright(c) 2006-2007, Ext JS, LLC.
10763 * Originally Released Under LGPL - original licence link has changed is not relivant.
10766 * <script type="text/javascript">
10772 * @class Roo.data.Store
10773 * @extends Roo.util.Observable
10774 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10775 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10777 * 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
10778 * has no knowledge of the format of the data returned by the Proxy.<br>
10780 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10781 * instances from the data object. These records are cached and made available through accessor functions.
10783 * Creates a new Store.
10784 * @param {Object} config A config object containing the objects needed for the Store to access data,
10785 * and read the data into Records.
10787 Roo.data.Store = function(config){
10788 this.data = new Roo.util.MixedCollection(false);
10789 this.data.getKey = function(o){
10792 this.baseParams = {};
10794 this.paramNames = {
10799 "multisort" : "_multisort"
10802 if(config && config.data){
10803 this.inlineData = config.data;
10804 delete config.data;
10807 Roo.apply(this, config);
10809 if(this.reader){ // reader passed
10810 this.reader = Roo.factory(this.reader, Roo.data);
10811 this.reader.xmodule = this.xmodule || false;
10812 if(!this.recordType){
10813 this.recordType = this.reader.recordType;
10815 if(this.reader.onMetaChange){
10816 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10820 if(this.recordType){
10821 this.fields = this.recordType.prototype.fields;
10823 this.modified = [];
10827 * @event datachanged
10828 * Fires when the data cache has changed, and a widget which is using this Store
10829 * as a Record cache should refresh its view.
10830 * @param {Store} this
10832 datachanged : true,
10834 * @event metachange
10835 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10836 * @param {Store} this
10837 * @param {Object} meta The JSON metadata
10842 * Fires when Records have been added to the Store
10843 * @param {Store} this
10844 * @param {Roo.data.Record[]} records The array of Records added
10845 * @param {Number} index The index at which the record(s) were added
10850 * Fires when a Record has been removed from the Store
10851 * @param {Store} this
10852 * @param {Roo.data.Record} record The Record that was removed
10853 * @param {Number} index The index at which the record was removed
10858 * Fires when a Record has been updated
10859 * @param {Store} this
10860 * @param {Roo.data.Record} record The Record that was updated
10861 * @param {String} operation The update operation being performed. Value may be one of:
10863 Roo.data.Record.EDIT
10864 Roo.data.Record.REJECT
10865 Roo.data.Record.COMMIT
10871 * Fires when the data cache has been cleared.
10872 * @param {Store} this
10876 * @event beforeload
10877 * Fires before a request is made for a new data object. If the beforeload handler returns false
10878 * the load action will be canceled.
10879 * @param {Store} this
10880 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10884 * @event beforeloadadd
10885 * Fires after a new set of Records has been loaded.
10886 * @param {Store} this
10887 * @param {Roo.data.Record[]} records The Records that were loaded
10888 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10890 beforeloadadd : true,
10893 * Fires after a new set of Records has been loaded, before they are added to the store.
10894 * @param {Store} this
10895 * @param {Roo.data.Record[]} records The Records that were loaded
10896 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10897 * @params {Object} return from reader
10901 * @event loadexception
10902 * Fires if an exception occurs in the Proxy during loading.
10903 * Called with the signature of the Proxy's "loadexception" event.
10904 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10907 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10908 * @param {Object} load options
10909 * @param {Object} jsonData from your request (normally this contains the Exception)
10911 loadexception : true
10915 this.proxy = Roo.factory(this.proxy, Roo.data);
10916 this.proxy.xmodule = this.xmodule || false;
10917 this.relayEvents(this.proxy, ["loadexception"]);
10919 this.sortToggle = {};
10920 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10922 Roo.data.Store.superclass.constructor.call(this);
10924 if(this.inlineData){
10925 this.loadData(this.inlineData);
10926 delete this.inlineData;
10930 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10932 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10933 * without a remote query - used by combo/forms at present.
10937 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10940 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10943 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10944 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10947 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10948 * on any HTTP request
10951 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10954 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10958 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10959 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10961 remoteSort : false,
10964 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10965 * loaded or when a record is removed. (defaults to false).
10967 pruneModifiedRecords : false,
10970 lastOptions : null,
10973 * Add Records to the Store and fires the add event.
10974 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10976 add : function(records){
10977 records = [].concat(records);
10978 for(var i = 0, len = records.length; i < len; i++){
10979 records[i].join(this);
10981 var index = this.data.length;
10982 this.data.addAll(records);
10983 this.fireEvent("add", this, records, index);
10987 * Remove a Record from the Store and fires the remove event.
10988 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10990 remove : function(record){
10991 var index = this.data.indexOf(record);
10992 this.data.removeAt(index);
10993 if(this.pruneModifiedRecords){
10994 this.modified.remove(record);
10996 this.fireEvent("remove", this, record, index);
11000 * Remove all Records from the Store and fires the clear event.
11002 removeAll : function(){
11004 if(this.pruneModifiedRecords){
11005 this.modified = [];
11007 this.fireEvent("clear", this);
11011 * Inserts Records to the Store at the given index and fires the add event.
11012 * @param {Number} index The start index at which to insert the passed Records.
11013 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11015 insert : function(index, records){
11016 records = [].concat(records);
11017 for(var i = 0, len = records.length; i < len; i++){
11018 this.data.insert(index, records[i]);
11019 records[i].join(this);
11021 this.fireEvent("add", this, records, index);
11025 * Get the index within the cache of the passed Record.
11026 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11027 * @return {Number} The index of the passed Record. Returns -1 if not found.
11029 indexOf : function(record){
11030 return this.data.indexOf(record);
11034 * Get the index within the cache of the Record with the passed id.
11035 * @param {String} id The id of the Record to find.
11036 * @return {Number} The index of the Record. Returns -1 if not found.
11038 indexOfId : function(id){
11039 return this.data.indexOfKey(id);
11043 * Get the Record with the specified id.
11044 * @param {String} id The id of the Record to find.
11045 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11047 getById : function(id){
11048 return this.data.key(id);
11052 * Get the Record at the specified index.
11053 * @param {Number} index The index of the Record to find.
11054 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11056 getAt : function(index){
11057 return this.data.itemAt(index);
11061 * Returns a range of Records between specified indices.
11062 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11063 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11064 * @return {Roo.data.Record[]} An array of Records
11066 getRange : function(start, end){
11067 return this.data.getRange(start, end);
11071 storeOptions : function(o){
11072 o = Roo.apply({}, o);
11075 this.lastOptions = o;
11079 * Loads the Record cache from the configured Proxy using the configured Reader.
11081 * If using remote paging, then the first load call must specify the <em>start</em>
11082 * and <em>limit</em> properties in the options.params property to establish the initial
11083 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11085 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11086 * and this call will return before the new data has been loaded. Perform any post-processing
11087 * in a callback function, or in a "load" event handler.</strong>
11089 * @param {Object} options An object containing properties which control loading options:<ul>
11090 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11091 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11092 * passed the following arguments:<ul>
11093 * <li>r : Roo.data.Record[]</li>
11094 * <li>options: Options object from the load call</li>
11095 * <li>success: Boolean success indicator</li></ul></li>
11096 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11097 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11100 load : function(options){
11101 options = options || {};
11102 if(this.fireEvent("beforeload", this, options) !== false){
11103 this.storeOptions(options);
11104 var p = Roo.apply(options.params || {}, this.baseParams);
11105 // if meta was not loaded from remote source.. try requesting it.
11106 if (!this.reader.metaFromRemote) {
11107 p._requestMeta = 1;
11109 if(this.sortInfo && this.remoteSort){
11110 var pn = this.paramNames;
11111 p[pn["sort"]] = this.sortInfo.field;
11112 p[pn["dir"]] = this.sortInfo.direction;
11114 if (this.multiSort) {
11115 var pn = this.paramNames;
11116 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11119 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11124 * Reloads the Record cache from the configured Proxy using the configured Reader and
11125 * the options from the last load operation performed.
11126 * @param {Object} options (optional) An object containing properties which may override the options
11127 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11128 * the most recently used options are reused).
11130 reload : function(options){
11131 this.load(Roo.applyIf(options||{}, this.lastOptions));
11135 // Called as a callback by the Reader during a load operation.
11136 loadRecords : function(o, options, success){
11137 if(!o || success === false){
11138 if(success !== false){
11139 this.fireEvent("load", this, [], options, o);
11141 if(options.callback){
11142 options.callback.call(options.scope || this, [], options, false);
11146 // if data returned failure - throw an exception.
11147 if (o.success === false) {
11148 // show a message if no listener is registered.
11149 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11150 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11152 // loadmask wil be hooked into this..
11153 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11156 var r = o.records, t = o.totalRecords || r.length;
11158 this.fireEvent("beforeloadadd", this, r, options, o);
11160 if(!options || options.add !== true){
11161 if(this.pruneModifiedRecords){
11162 this.modified = [];
11164 for(var i = 0, len = r.length; i < len; i++){
11168 this.data = this.snapshot;
11169 delete this.snapshot;
11172 this.data.addAll(r);
11173 this.totalLength = t;
11175 this.fireEvent("datachanged", this);
11177 this.totalLength = Math.max(t, this.data.length+r.length);
11181 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11183 var e = new Roo.data.Record({});
11185 e.set(this.parent.displayField, this.parent.emptyTitle);
11186 e.set(this.parent.valueField, '');
11191 this.fireEvent("load", this, r, options, o);
11192 if(options.callback){
11193 options.callback.call(options.scope || this, r, options, true);
11199 * Loads data from a passed data block. A Reader which understands the format of the data
11200 * must have been configured in the constructor.
11201 * @param {Object} data The data block from which to read the Records. The format of the data expected
11202 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11203 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11205 loadData : function(o, append){
11206 var r = this.reader.readRecords(o);
11207 this.loadRecords(r, {add: append}, true);
11211 * Gets the number of cached records.
11213 * <em>If using paging, this may not be the total size of the dataset. If the data object
11214 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11215 * the data set size</em>
11217 getCount : function(){
11218 return this.data.length || 0;
11222 * Gets the total number of records in the dataset as returned by the server.
11224 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11225 * the dataset size</em>
11227 getTotalCount : function(){
11228 return this.totalLength || 0;
11232 * Returns the sort state of the Store as an object with two properties:
11234 field {String} The name of the field by which the Records are sorted
11235 direction {String} The sort order, "ASC" or "DESC"
11238 getSortState : function(){
11239 return this.sortInfo;
11243 applySort : function(){
11244 if(this.sortInfo && !this.remoteSort){
11245 var s = this.sortInfo, f = s.field;
11246 var st = this.fields.get(f).sortType;
11247 var fn = function(r1, r2){
11248 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11249 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11251 this.data.sort(s.direction, fn);
11252 if(this.snapshot && this.snapshot != this.data){
11253 this.snapshot.sort(s.direction, fn);
11259 * Sets the default sort column and order to be used by the next load operation.
11260 * @param {String} fieldName The name of the field to sort by.
11261 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11263 setDefaultSort : function(field, dir){
11264 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11268 * Sort the Records.
11269 * If remote sorting is used, the sort is performed on the server, and the cache is
11270 * reloaded. If local sorting is used, the cache is sorted internally.
11271 * @param {String} fieldName The name of the field to sort by.
11272 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11274 sort : function(fieldName, dir){
11275 var f = this.fields.get(fieldName);
11277 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11279 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11280 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11285 this.sortToggle[f.name] = dir;
11286 this.sortInfo = {field: f.name, direction: dir};
11287 if(!this.remoteSort){
11289 this.fireEvent("datachanged", this);
11291 this.load(this.lastOptions);
11296 * Calls the specified function for each of the Records in the cache.
11297 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11298 * Returning <em>false</em> aborts and exits the iteration.
11299 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11301 each : function(fn, scope){
11302 this.data.each(fn, scope);
11306 * Gets all records modified since the last commit. Modified records are persisted across load operations
11307 * (e.g., during paging).
11308 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11310 getModifiedRecords : function(){
11311 return this.modified;
11315 createFilterFn : function(property, value, anyMatch){
11316 if(!value.exec){ // not a regex
11317 value = String(value);
11318 if(value.length == 0){
11321 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11323 return function(r){
11324 return value.test(r.data[property]);
11329 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11330 * @param {String} property A field on your records
11331 * @param {Number} start The record index to start at (defaults to 0)
11332 * @param {Number} end The last record index to include (defaults to length - 1)
11333 * @return {Number} The sum
11335 sum : function(property, start, end){
11336 var rs = this.data.items, v = 0;
11337 start = start || 0;
11338 end = (end || end === 0) ? end : rs.length-1;
11340 for(var i = start; i <= end; i++){
11341 v += (rs[i].data[property] || 0);
11347 * Filter the records by a specified property.
11348 * @param {String} field A field on your records
11349 * @param {String/RegExp} value Either a string that the field
11350 * should start with or a RegExp to test against the field
11351 * @param {Boolean} anyMatch True to match any part not just the beginning
11353 filter : function(property, value, anyMatch){
11354 var fn = this.createFilterFn(property, value, anyMatch);
11355 return fn ? this.filterBy(fn) : this.clearFilter();
11359 * Filter by a function. The specified function will be called with each
11360 * record in this data source. If the function returns true the record is included,
11361 * otherwise it is filtered.
11362 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11363 * @param {Object} scope (optional) The scope of the function (defaults to this)
11365 filterBy : function(fn, scope){
11366 this.snapshot = this.snapshot || this.data;
11367 this.data = this.queryBy(fn, scope||this);
11368 this.fireEvent("datachanged", this);
11372 * Query the records by a specified property.
11373 * @param {String} field A field on your records
11374 * @param {String/RegExp} value Either a string that the field
11375 * should start with or a RegExp to test against the field
11376 * @param {Boolean} anyMatch True to match any part not just the beginning
11377 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11379 query : function(property, value, anyMatch){
11380 var fn = this.createFilterFn(property, value, anyMatch);
11381 return fn ? this.queryBy(fn) : this.data.clone();
11385 * Query by a function. The specified function will be called with each
11386 * record in this data source. If the function returns true the record is included
11388 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11389 * @param {Object} scope (optional) The scope of the function (defaults to this)
11390 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11392 queryBy : function(fn, scope){
11393 var data = this.snapshot || this.data;
11394 return data.filterBy(fn, scope||this);
11398 * Collects unique values for a particular dataIndex from this store.
11399 * @param {String} dataIndex The property to collect
11400 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11401 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11402 * @return {Array} An array of the unique values
11404 collect : function(dataIndex, allowNull, bypassFilter){
11405 var d = (bypassFilter === true && this.snapshot) ?
11406 this.snapshot.items : this.data.items;
11407 var v, sv, r = [], l = {};
11408 for(var i = 0, len = d.length; i < len; i++){
11409 v = d[i].data[dataIndex];
11411 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11420 * Revert to a view of the Record cache with no filtering applied.
11421 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11423 clearFilter : function(suppressEvent){
11424 if(this.snapshot && this.snapshot != this.data){
11425 this.data = this.snapshot;
11426 delete this.snapshot;
11427 if(suppressEvent !== true){
11428 this.fireEvent("datachanged", this);
11434 afterEdit : function(record){
11435 if(this.modified.indexOf(record) == -1){
11436 this.modified.push(record);
11438 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11442 afterReject : function(record){
11443 this.modified.remove(record);
11444 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11448 afterCommit : function(record){
11449 this.modified.remove(record);
11450 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11454 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11455 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11457 commitChanges : function(){
11458 var m = this.modified.slice(0);
11459 this.modified = [];
11460 for(var i = 0, len = m.length; i < len; i++){
11466 * Cancel outstanding changes on all changed records.
11468 rejectChanges : function(){
11469 var m = this.modified.slice(0);
11470 this.modified = [];
11471 for(var i = 0, len = m.length; i < len; i++){
11476 onMetaChange : function(meta, rtype, o){
11477 this.recordType = rtype;
11478 this.fields = rtype.prototype.fields;
11479 delete this.snapshot;
11480 this.sortInfo = meta.sortInfo || this.sortInfo;
11481 this.modified = [];
11482 this.fireEvent('metachange', this, this.reader.meta);
11485 moveIndex : function(data, type)
11487 var index = this.indexOf(data);
11489 var newIndex = index + type;
11493 this.insert(newIndex, data);
11498 * Ext JS Library 1.1.1
11499 * Copyright(c) 2006-2007, Ext JS, LLC.
11501 * Originally Released Under LGPL - original licence link has changed is not relivant.
11504 * <script type="text/javascript">
11508 * @class Roo.data.SimpleStore
11509 * @extends Roo.data.Store
11510 * Small helper class to make creating Stores from Array data easier.
11511 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11512 * @cfg {Array} fields An array of field definition objects, or field name strings.
11513 * @cfg {Array} data The multi-dimensional array of data
11515 * @param {Object} config
11517 Roo.data.SimpleStore = function(config){
11518 Roo.data.SimpleStore.superclass.constructor.call(this, {
11520 reader: new Roo.data.ArrayReader({
11523 Roo.data.Record.create(config.fields)
11525 proxy : new Roo.data.MemoryProxy(config.data)
11529 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11531 * Ext JS Library 1.1.1
11532 * Copyright(c) 2006-2007, Ext JS, LLC.
11534 * Originally Released Under LGPL - original licence link has changed is not relivant.
11537 * <script type="text/javascript">
11542 * @extends Roo.data.Store
11543 * @class Roo.data.JsonStore
11544 * Small helper class to make creating Stores for JSON data easier. <br/>
11546 var store = new Roo.data.JsonStore({
11547 url: 'get-images.php',
11549 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11552 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11553 * JsonReader and HttpProxy (unless inline data is provided).</b>
11554 * @cfg {Array} fields An array of field definition objects, or field name strings.
11556 * @param {Object} config
11558 Roo.data.JsonStore = function(c){
11559 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11560 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11561 reader: new Roo.data.JsonReader(c, c.fields)
11564 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11566 * Ext JS Library 1.1.1
11567 * Copyright(c) 2006-2007, Ext JS, LLC.
11569 * Originally Released Under LGPL - original licence link has changed is not relivant.
11572 * <script type="text/javascript">
11576 Roo.data.Field = function(config){
11577 if(typeof config == "string"){
11578 config = {name: config};
11580 Roo.apply(this, config);
11583 this.type = "auto";
11586 var st = Roo.data.SortTypes;
11587 // named sortTypes are supported, here we look them up
11588 if(typeof this.sortType == "string"){
11589 this.sortType = st[this.sortType];
11592 // set default sortType for strings and dates
11593 if(!this.sortType){
11596 this.sortType = st.asUCString;
11599 this.sortType = st.asDate;
11602 this.sortType = st.none;
11607 var stripRe = /[\$,%]/g;
11609 // prebuilt conversion function for this field, instead of
11610 // switching every time we're reading a value
11612 var cv, dateFormat = this.dateFormat;
11617 cv = function(v){ return v; };
11620 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11624 return v !== undefined && v !== null && v !== '' ?
11625 parseInt(String(v).replace(stripRe, ""), 10) : '';
11630 return v !== undefined && v !== null && v !== '' ?
11631 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11636 cv = function(v){ return v === true || v === "true" || v == 1; };
11643 if(v instanceof Date){
11647 if(dateFormat == "timestamp"){
11648 return new Date(v*1000);
11650 return Date.parseDate(v, dateFormat);
11652 var parsed = Date.parse(v);
11653 return parsed ? new Date(parsed) : null;
11662 Roo.data.Field.prototype = {
11670 * Ext JS Library 1.1.1
11671 * Copyright(c) 2006-2007, Ext JS, LLC.
11673 * Originally Released Under LGPL - original licence link has changed is not relivant.
11676 * <script type="text/javascript">
11679 // Base class for reading structured data from a data source. This class is intended to be
11680 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11683 * @class Roo.data.DataReader
11684 * Base class for reading structured data from a data source. This class is intended to be
11685 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11688 Roo.data.DataReader = function(meta, recordType){
11692 this.recordType = recordType instanceof Array ?
11693 Roo.data.Record.create(recordType) : recordType;
11696 Roo.data.DataReader.prototype = {
11698 * Create an empty record
11699 * @param {Object} data (optional) - overlay some values
11700 * @return {Roo.data.Record} record created.
11702 newRow : function(d) {
11704 this.recordType.prototype.fields.each(function(c) {
11706 case 'int' : da[c.name] = 0; break;
11707 case 'date' : da[c.name] = new Date(); break;
11708 case 'float' : da[c.name] = 0.0; break;
11709 case 'boolean' : da[c.name] = false; break;
11710 default : da[c.name] = ""; break;
11714 return new this.recordType(Roo.apply(da, d));
11719 * Ext JS Library 1.1.1
11720 * Copyright(c) 2006-2007, Ext JS, LLC.
11722 * Originally Released Under LGPL - original licence link has changed is not relivant.
11725 * <script type="text/javascript">
11729 * @class Roo.data.DataProxy
11730 * @extends Roo.data.Observable
11731 * This class is an abstract base class for implementations which provide retrieval of
11732 * unformatted data objects.<br>
11734 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11735 * (of the appropriate type which knows how to parse the data object) to provide a block of
11736 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11738 * Custom implementations must implement the load method as described in
11739 * {@link Roo.data.HttpProxy#load}.
11741 Roo.data.DataProxy = function(){
11744 * @event beforeload
11745 * Fires before a network request is made to retrieve a data object.
11746 * @param {Object} This DataProxy object.
11747 * @param {Object} params The params parameter to the load function.
11752 * Fires before the load method's callback is called.
11753 * @param {Object} This DataProxy object.
11754 * @param {Object} o The data object.
11755 * @param {Object} arg The callback argument object passed to the load function.
11759 * @event loadexception
11760 * Fires if an Exception occurs during data retrieval.
11761 * @param {Object} This DataProxy object.
11762 * @param {Object} o The data object.
11763 * @param {Object} arg The callback argument object passed to the load function.
11764 * @param {Object} e The Exception.
11766 loadexception : true
11768 Roo.data.DataProxy.superclass.constructor.call(this);
11771 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11774 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11778 * Ext JS Library 1.1.1
11779 * Copyright(c) 2006-2007, Ext JS, LLC.
11781 * Originally Released Under LGPL - original licence link has changed is not relivant.
11784 * <script type="text/javascript">
11787 * @class Roo.data.MemoryProxy
11788 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11789 * to the Reader when its load method is called.
11791 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11793 Roo.data.MemoryProxy = function(data){
11797 Roo.data.MemoryProxy.superclass.constructor.call(this);
11801 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11804 * Load data from the requested source (in this case an in-memory
11805 * data object passed to the constructor), read the data object into
11806 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11807 * process that block using the passed callback.
11808 * @param {Object} params This parameter is not used by the MemoryProxy class.
11809 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11810 * object into a block of Roo.data.Records.
11811 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11812 * The function must be passed <ul>
11813 * <li>The Record block object</li>
11814 * <li>The "arg" argument from the load function</li>
11815 * <li>A boolean success indicator</li>
11817 * @param {Object} scope The scope in which to call the callback
11818 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11820 load : function(params, reader, callback, scope, arg){
11821 params = params || {};
11824 result = reader.readRecords(this.data);
11826 this.fireEvent("loadexception", this, arg, null, e);
11827 callback.call(scope, null, arg, false);
11830 callback.call(scope, result, arg, true);
11834 update : function(params, records){
11839 * Ext JS Library 1.1.1
11840 * Copyright(c) 2006-2007, Ext JS, LLC.
11842 * Originally Released Under LGPL - original licence link has changed is not relivant.
11845 * <script type="text/javascript">
11848 * @class Roo.data.HttpProxy
11849 * @extends Roo.data.DataProxy
11850 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11851 * configured to reference a certain URL.<br><br>
11853 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11854 * from which the running page was served.<br><br>
11856 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11858 * Be aware that to enable the browser to parse an XML document, the server must set
11859 * the Content-Type header in the HTTP response to "text/xml".
11861 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11862 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11863 * will be used to make the request.
11865 Roo.data.HttpProxy = function(conn){
11866 Roo.data.HttpProxy.superclass.constructor.call(this);
11867 // is conn a conn config or a real conn?
11869 this.useAjax = !conn || !conn.events;
11873 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11874 // thse are take from connection...
11877 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11880 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11881 * extra parameters to each request made by this object. (defaults to undefined)
11884 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11885 * to each request made by this object. (defaults to undefined)
11888 * @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)
11891 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11894 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11900 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11904 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11905 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11906 * a finer-grained basis than the DataProxy events.
11908 getConnection : function(){
11909 return this.useAjax ? Roo.Ajax : this.conn;
11913 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11914 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11915 * process that block using the passed callback.
11916 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11917 * for the request to the remote server.
11918 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11919 * object into a block of Roo.data.Records.
11920 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11921 * The function must be passed <ul>
11922 * <li>The Record block object</li>
11923 * <li>The "arg" argument from the load function</li>
11924 * <li>A boolean success indicator</li>
11926 * @param {Object} scope The scope in which to call the callback
11927 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11929 load : function(params, reader, callback, scope, arg){
11930 if(this.fireEvent("beforeload", this, params) !== false){
11932 params : params || {},
11934 callback : callback,
11939 callback : this.loadResponse,
11943 Roo.applyIf(o, this.conn);
11944 if(this.activeRequest){
11945 Roo.Ajax.abort(this.activeRequest);
11947 this.activeRequest = Roo.Ajax.request(o);
11949 this.conn.request(o);
11952 callback.call(scope||this, null, arg, false);
11957 loadResponse : function(o, success, response){
11958 delete this.activeRequest;
11960 this.fireEvent("loadexception", this, o, response);
11961 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11966 result = o.reader.read(response);
11968 this.fireEvent("loadexception", this, o, response, e);
11969 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11973 this.fireEvent("load", this, o, o.request.arg);
11974 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11978 update : function(dataSet){
11983 updateResponse : function(dataSet){
11988 * Ext JS Library 1.1.1
11989 * Copyright(c) 2006-2007, Ext JS, LLC.
11991 * Originally Released Under LGPL - original licence link has changed is not relivant.
11994 * <script type="text/javascript">
11998 * @class Roo.data.ScriptTagProxy
11999 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12000 * other than the originating domain of the running page.<br><br>
12002 * <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
12003 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12005 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12006 * source code that is used as the source inside a <script> tag.<br><br>
12008 * In order for the browser to process the returned data, the server must wrap the data object
12009 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12010 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12011 * depending on whether the callback name was passed:
12014 boolean scriptTag = false;
12015 String cb = request.getParameter("callback");
12018 response.setContentType("text/javascript");
12020 response.setContentType("application/x-json");
12022 Writer out = response.getWriter();
12024 out.write(cb + "(");
12026 out.print(dataBlock.toJsonString());
12033 * @param {Object} config A configuration object.
12035 Roo.data.ScriptTagProxy = function(config){
12036 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12037 Roo.apply(this, config);
12038 this.head = document.getElementsByTagName("head")[0];
12041 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12043 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12045 * @cfg {String} url The URL from which to request the data object.
12048 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12052 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12053 * the server the name of the callback function set up by the load call to process the returned data object.
12054 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12055 * javascript output which calls this named function passing the data object as its only parameter.
12057 callbackParam : "callback",
12059 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12060 * name to the request.
12065 * Load data from the configured URL, read the data object into
12066 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12067 * process that block using the passed callback.
12068 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12069 * for the request to the remote server.
12070 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12071 * object into a block of Roo.data.Records.
12072 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12073 * The function must be passed <ul>
12074 * <li>The Record block object</li>
12075 * <li>The "arg" argument from the load function</li>
12076 * <li>A boolean success indicator</li>
12078 * @param {Object} scope The scope in which to call the callback
12079 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12081 load : function(params, reader, callback, scope, arg){
12082 if(this.fireEvent("beforeload", this, params) !== false){
12084 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12086 var url = this.url;
12087 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12089 url += "&_dc=" + (new Date().getTime());
12091 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12094 cb : "stcCallback"+transId,
12095 scriptId : "stcScript"+transId,
12099 callback : callback,
12105 window[trans.cb] = function(o){
12106 conn.handleResponse(o, trans);
12109 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12111 if(this.autoAbort !== false){
12115 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12117 var script = document.createElement("script");
12118 script.setAttribute("src", url);
12119 script.setAttribute("type", "text/javascript");
12120 script.setAttribute("id", trans.scriptId);
12121 this.head.appendChild(script);
12123 this.trans = trans;
12125 callback.call(scope||this, null, arg, false);
12130 isLoading : function(){
12131 return this.trans ? true : false;
12135 * Abort the current server request.
12137 abort : function(){
12138 if(this.isLoading()){
12139 this.destroyTrans(this.trans);
12144 destroyTrans : function(trans, isLoaded){
12145 this.head.removeChild(document.getElementById(trans.scriptId));
12146 clearTimeout(trans.timeoutId);
12148 window[trans.cb] = undefined;
12150 delete window[trans.cb];
12153 // if hasn't been loaded, wait for load to remove it to prevent script error
12154 window[trans.cb] = function(){
12155 window[trans.cb] = undefined;
12157 delete window[trans.cb];
12164 handleResponse : function(o, trans){
12165 this.trans = false;
12166 this.destroyTrans(trans, true);
12169 result = trans.reader.readRecords(o);
12171 this.fireEvent("loadexception", this, o, trans.arg, e);
12172 trans.callback.call(trans.scope||window, null, trans.arg, false);
12175 this.fireEvent("load", this, o, trans.arg);
12176 trans.callback.call(trans.scope||window, result, trans.arg, true);
12180 handleFailure : function(trans){
12181 this.trans = false;
12182 this.destroyTrans(trans, false);
12183 this.fireEvent("loadexception", this, null, trans.arg);
12184 trans.callback.call(trans.scope||window, null, trans.arg, false);
12188 * Ext JS Library 1.1.1
12189 * Copyright(c) 2006-2007, Ext JS, LLC.
12191 * Originally Released Under LGPL - original licence link has changed is not relivant.
12194 * <script type="text/javascript">
12198 * @class Roo.data.JsonReader
12199 * @extends Roo.data.DataReader
12200 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12201 * based on mappings in a provided Roo.data.Record constructor.
12203 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12204 * in the reply previously.
12209 var RecordDef = Roo.data.Record.create([
12210 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12211 {name: 'occupation'} // This field will use "occupation" as the mapping.
12213 var myReader = new Roo.data.JsonReader({
12214 totalProperty: "results", // The property which contains the total dataset size (optional)
12215 root: "rows", // The property which contains an Array of row objects
12216 id: "id" // The property within each row object that provides an ID for the record (optional)
12220 * This would consume a JSON file like this:
12222 { 'results': 2, 'rows': [
12223 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12224 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12227 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12228 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12229 * paged from the remote server.
12230 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12231 * @cfg {String} root name of the property which contains the Array of row objects.
12232 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12233 * @cfg {Array} fields Array of field definition objects
12235 * Create a new JsonReader
12236 * @param {Object} meta Metadata configuration options
12237 * @param {Object} recordType Either an Array of field definition objects,
12238 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12240 Roo.data.JsonReader = function(meta, recordType){
12243 // set some defaults:
12244 Roo.applyIf(meta, {
12245 totalProperty: 'total',
12246 successProperty : 'success',
12251 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12253 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12256 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12257 * Used by Store query builder to append _requestMeta to params.
12260 metaFromRemote : false,
12262 * This method is only used by a DataProxy which has retrieved data from a remote server.
12263 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12264 * @return {Object} data A data block which is used by an Roo.data.Store object as
12265 * a cache of Roo.data.Records.
12267 read : function(response){
12268 var json = response.responseText;
12270 var o = /* eval:var:o */ eval("("+json+")");
12272 throw {message: "JsonReader.read: Json object not found"};
12278 this.metaFromRemote = true;
12279 this.meta = o.metaData;
12280 this.recordType = Roo.data.Record.create(o.metaData.fields);
12281 this.onMetaChange(this.meta, this.recordType, o);
12283 return this.readRecords(o);
12286 // private function a store will implement
12287 onMetaChange : function(meta, recordType, o){
12294 simpleAccess: function(obj, subsc) {
12301 getJsonAccessor: function(){
12303 return function(expr) {
12305 return(re.test(expr))
12306 ? new Function("obj", "return obj." + expr)
12311 return Roo.emptyFn;
12316 * Create a data block containing Roo.data.Records from an XML document.
12317 * @param {Object} o An object which contains an Array of row objects in the property specified
12318 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12319 * which contains the total size of the dataset.
12320 * @return {Object} data A data block which is used by an Roo.data.Store object as
12321 * a cache of Roo.data.Records.
12323 readRecords : function(o){
12325 * After any data loads, the raw JSON data is available for further custom processing.
12329 var s = this.meta, Record = this.recordType,
12330 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12332 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12334 if(s.totalProperty) {
12335 this.getTotal = this.getJsonAccessor(s.totalProperty);
12337 if(s.successProperty) {
12338 this.getSuccess = this.getJsonAccessor(s.successProperty);
12340 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12342 var g = this.getJsonAccessor(s.id);
12343 this.getId = function(rec) {
12345 return (r === undefined || r === "") ? null : r;
12348 this.getId = function(){return null;};
12351 for(var jj = 0; jj < fl; jj++){
12353 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12354 this.ef[jj] = this.getJsonAccessor(map);
12358 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12359 if(s.totalProperty){
12360 var vt = parseInt(this.getTotal(o), 10);
12365 if(s.successProperty){
12366 var vs = this.getSuccess(o);
12367 if(vs === false || vs === 'false'){
12372 for(var i = 0; i < c; i++){
12375 var id = this.getId(n);
12376 for(var j = 0; j < fl; j++){
12378 var v = this.ef[j](n);
12380 Roo.log('missing convert for ' + f.name);
12384 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12386 var record = new Record(values, id);
12388 records[i] = record;
12394 totalRecords : totalRecords
12399 * Ext JS Library 1.1.1
12400 * Copyright(c) 2006-2007, Ext JS, LLC.
12402 * Originally Released Under LGPL - original licence link has changed is not relivant.
12405 * <script type="text/javascript">
12409 * @class Roo.data.ArrayReader
12410 * @extends Roo.data.DataReader
12411 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12412 * Each element of that Array represents a row of data fields. The
12413 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12414 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12418 var RecordDef = Roo.data.Record.create([
12419 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12420 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12422 var myReader = new Roo.data.ArrayReader({
12423 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12427 * This would consume an Array like this:
12429 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12431 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12433 * Create a new JsonReader
12434 * @param {Object} meta Metadata configuration options.
12435 * @param {Object} recordType Either an Array of field definition objects
12436 * as specified to {@link Roo.data.Record#create},
12437 * or an {@link Roo.data.Record} object
12438 * created using {@link Roo.data.Record#create}.
12440 Roo.data.ArrayReader = function(meta, recordType){
12441 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12444 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12446 * Create a data block containing Roo.data.Records from an XML document.
12447 * @param {Object} o An Array of row objects which represents the dataset.
12448 * @return {Object} data A data block which is used by an Roo.data.Store object as
12449 * a cache of Roo.data.Records.
12451 readRecords : function(o){
12452 var sid = this.meta ? this.meta.id : null;
12453 var recordType = this.recordType, fields = recordType.prototype.fields;
12456 for(var i = 0; i < root.length; i++){
12459 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12460 for(var j = 0, jlen = fields.length; j < jlen; j++){
12461 var f = fields.items[j];
12462 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12463 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12465 values[f.name] = v;
12467 var record = new recordType(values, id);
12469 records[records.length] = record;
12473 totalRecords : records.length
12482 * @class Roo.bootstrap.ComboBox
12483 * @extends Roo.bootstrap.TriggerField
12484 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12485 * @cfg {Boolean} append (true|false) default false
12486 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12487 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12488 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12489 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12490 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12491 * @cfg {Boolean} animate default true
12492 * @cfg {Boolean} emptyResultText only for touch device
12493 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12494 * @cfg {String} emptyTitle default ''
12496 * Create a new ComboBox.
12497 * @param {Object} config Configuration options
12499 Roo.bootstrap.ComboBox = function(config){
12500 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12504 * Fires when the dropdown list is expanded
12505 * @param {Roo.bootstrap.ComboBox} combo This combo box
12510 * Fires when the dropdown list is collapsed
12511 * @param {Roo.bootstrap.ComboBox} combo This combo box
12515 * @event beforeselect
12516 * Fires before a list item is selected. Return false to cancel the selection.
12517 * @param {Roo.bootstrap.ComboBox} combo This combo box
12518 * @param {Roo.data.Record} record The data record returned from the underlying store
12519 * @param {Number} index The index of the selected item in the dropdown list
12521 'beforeselect' : true,
12524 * Fires when a list item is selected
12525 * @param {Roo.bootstrap.ComboBox} combo This combo box
12526 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12527 * @param {Number} index The index of the selected item in the dropdown list
12531 * @event beforequery
12532 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12533 * The event object passed has these properties:
12534 * @param {Roo.bootstrap.ComboBox} combo This combo box
12535 * @param {String} query The query
12536 * @param {Boolean} forceAll true to force "all" query
12537 * @param {Boolean} cancel true to cancel the query
12538 * @param {Object} e The query event object
12540 'beforequery': true,
12543 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12544 * @param {Roo.bootstrap.ComboBox} combo This combo box
12549 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12550 * @param {Roo.bootstrap.ComboBox} combo This combo box
12551 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12556 * Fires when the remove value from the combobox array
12557 * @param {Roo.bootstrap.ComboBox} combo This combo box
12561 * @event afterremove
12562 * Fires when the remove value from the combobox array
12563 * @param {Roo.bootstrap.ComboBox} combo This combo box
12565 'afterremove' : true,
12567 * @event specialfilter
12568 * Fires when specialfilter
12569 * @param {Roo.bootstrap.ComboBox} combo This combo box
12571 'specialfilter' : true,
12574 * Fires when tick the element
12575 * @param {Roo.bootstrap.ComboBox} combo This combo box
12579 * @event touchviewdisplay
12580 * Fires when touch view require special display (default is using displayField)
12581 * @param {Roo.bootstrap.ComboBox} combo This combo box
12582 * @param {Object} cfg set html .
12584 'touchviewdisplay' : true
12589 this.tickItems = [];
12591 this.selectedIndex = -1;
12592 if(this.mode == 'local'){
12593 if(config.queryDelay === undefined){
12594 this.queryDelay = 10;
12596 if(config.minChars === undefined){
12602 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12605 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12606 * rendering into an Roo.Editor, defaults to false)
12609 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12610 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12613 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12616 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12617 * the dropdown list (defaults to undefined, with no header element)
12621 * @cfg {String/Roo.Template} tpl The template to use to render the output
12625 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12627 listWidth: undefined,
12629 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12630 * mode = 'remote' or 'text' if mode = 'local')
12632 displayField: undefined,
12635 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12636 * mode = 'remote' or 'value' if mode = 'local').
12637 * Note: use of a valueField requires the user make a selection
12638 * in order for a value to be mapped.
12640 valueField: undefined,
12642 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12647 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12648 * field's data value (defaults to the underlying DOM element's name)
12650 hiddenName: undefined,
12652 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12656 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12658 selectedClass: 'active',
12661 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12665 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12666 * anchor positions (defaults to 'tl-bl')
12668 listAlign: 'tl-bl?',
12670 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12674 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12675 * query specified by the allQuery config option (defaults to 'query')
12677 triggerAction: 'query',
12679 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12680 * (defaults to 4, does not apply if editable = false)
12684 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12685 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12689 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12690 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12694 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12695 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12699 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12700 * when editable = true (defaults to false)
12702 selectOnFocus:false,
12704 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12706 queryParam: 'query',
12708 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12709 * when mode = 'remote' (defaults to 'Loading...')
12711 loadingText: 'Loading...',
12713 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12717 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12721 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12722 * traditional select (defaults to true)
12726 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12730 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12734 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12735 * listWidth has a higher value)
12739 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12740 * allow the user to set arbitrary text into the field (defaults to false)
12742 forceSelection:false,
12744 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12745 * if typeAhead = true (defaults to 250)
12747 typeAheadDelay : 250,
12749 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12750 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12752 valueNotFoundText : undefined,
12754 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12756 blockFocus : false,
12759 * @cfg {Boolean} disableClear Disable showing of clear button.
12761 disableClear : false,
12763 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12765 alwaysQuery : false,
12768 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12773 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12775 invalidClass : "has-warning",
12778 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12780 validClass : "has-success",
12783 * @cfg {Boolean} specialFilter (true|false) special filter default false
12785 specialFilter : false,
12788 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12790 mobileTouchView : true,
12793 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12795 useNativeIOS : false,
12797 ios_options : false,
12809 btnPosition : 'right',
12810 triggerList : true,
12811 showToggleBtn : true,
12813 emptyResultText: 'Empty',
12814 triggerText : 'Select',
12817 // element that contains real text value.. (when hidden is used..)
12819 getAutoCreate : function()
12824 * Render classic select for iso
12827 if(Roo.isIOS && this.useNativeIOS){
12828 cfg = this.getAutoCreateNativeIOS();
12836 if(Roo.isTouch && this.mobileTouchView){
12837 cfg = this.getAutoCreateTouchView();
12844 if(!this.tickable){
12845 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12850 * ComboBox with tickable selections
12853 var align = this.labelAlign || this.parentLabelAlign();
12856 cls : 'form-group roo-combobox-tickable' //input-group
12859 var btn_text_select = '';
12860 var btn_text_done = '';
12861 var btn_text_cancel = '';
12863 if (this.btn_text_show) {
12864 btn_text_select = 'Select';
12865 btn_text_done = 'Done';
12866 btn_text_cancel = 'Cancel';
12871 cls : 'tickable-buttons',
12876 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12877 //html : this.triggerText
12878 html: btn_text_select
12884 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12886 html: btn_text_done
12892 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12894 html: btn_text_cancel
12900 buttons.cn.unshift({
12902 cls: 'roo-select2-search-field-input'
12908 Roo.each(buttons.cn, function(c){
12910 c.cls += ' btn-' + _this.size;
12913 if (_this.disabled) {
12924 cls: 'form-hidden-field'
12928 cls: 'roo-select2-choices',
12932 cls: 'roo-select2-search-field',
12943 cls: 'roo-select2-container input-group roo-select2-container-multi',
12948 // cls: 'typeahead typeahead-long dropdown-menu',
12949 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12954 if(this.hasFeedback && !this.allowBlank){
12958 cls: 'glyphicon form-control-feedback'
12961 combobox.cn.push(feedback);
12965 if (align ==='left' && this.fieldLabel.length) {
12967 cfg.cls += ' roo-form-group-label-left';
12972 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12973 tooltip : 'This field is required'
12978 cls : 'control-label',
12979 html : this.fieldLabel
12991 var labelCfg = cfg.cn[1];
12992 var contentCfg = cfg.cn[2];
12995 if(this.indicatorpos == 'right'){
13001 cls : 'control-label',
13005 html : this.fieldLabel
13009 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13010 tooltip : 'This field is required'
13025 labelCfg = cfg.cn[0];
13026 contentCfg = cfg.cn[1];
13030 if(this.labelWidth > 12){
13031 labelCfg.style = "width: " + this.labelWidth + 'px';
13034 if(this.labelWidth < 13 && this.labelmd == 0){
13035 this.labelmd = this.labelWidth;
13038 if(this.labellg > 0){
13039 labelCfg.cls += ' col-lg-' + this.labellg;
13040 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13043 if(this.labelmd > 0){
13044 labelCfg.cls += ' col-md-' + this.labelmd;
13045 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13048 if(this.labelsm > 0){
13049 labelCfg.cls += ' col-sm-' + this.labelsm;
13050 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13053 if(this.labelxs > 0){
13054 labelCfg.cls += ' col-xs-' + this.labelxs;
13055 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13059 } else if ( this.fieldLabel.length) {
13060 // Roo.log(" label");
13064 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13065 tooltip : 'This field is required'
13069 //cls : 'input-group-addon',
13070 html : this.fieldLabel
13075 if(this.indicatorpos == 'right'){
13079 //cls : 'input-group-addon',
13080 html : this.fieldLabel
13084 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13085 tooltip : 'This field is required'
13094 // Roo.log(" no label && no align");
13101 ['xs','sm','md','lg'].map(function(size){
13102 if (settings[size]) {
13103 cfg.cls += ' col-' + size + '-' + settings[size];
13111 _initEventsCalled : false,
13114 initEvents: function()
13116 if (this._initEventsCalled) { // as we call render... prevent looping...
13119 this._initEventsCalled = true;
13122 throw "can not find store for combo";
13125 this.indicator = this.indicatorEl();
13127 this.store = Roo.factory(this.store, Roo.data);
13128 this.store.parent = this;
13130 // if we are building from html. then this element is so complex, that we can not really
13131 // use the rendered HTML.
13132 // so we have to trash and replace the previous code.
13133 if (Roo.XComponent.build_from_html) {
13134 // remove this element....
13135 var e = this.el.dom, k=0;
13136 while (e ) { e = e.previousSibling; ++k;}
13141 this.rendered = false;
13143 this.render(this.parent().getChildContainer(true), k);
13146 if(Roo.isIOS && this.useNativeIOS){
13147 this.initIOSView();
13155 if(Roo.isTouch && this.mobileTouchView){
13156 this.initTouchView();
13161 this.initTickableEvents();
13165 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13167 if(this.hiddenName){
13169 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13171 this.hiddenField.dom.value =
13172 this.hiddenValue !== undefined ? this.hiddenValue :
13173 this.value !== undefined ? this.value : '';
13175 // prevent input submission
13176 this.el.dom.removeAttribute('name');
13177 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13182 // this.el.dom.setAttribute('autocomplete', 'off');
13185 var cls = 'x-combo-list';
13187 //this.list = new Roo.Layer({
13188 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13194 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13195 _this.list.setWidth(lw);
13198 this.list.on('mouseover', this.onViewOver, this);
13199 this.list.on('mousemove', this.onViewMove, this);
13200 this.list.on('scroll', this.onViewScroll, this);
13203 this.list.swallowEvent('mousewheel');
13204 this.assetHeight = 0;
13207 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13208 this.assetHeight += this.header.getHeight();
13211 this.innerList = this.list.createChild({cls:cls+'-inner'});
13212 this.innerList.on('mouseover', this.onViewOver, this);
13213 this.innerList.on('mousemove', this.onViewMove, this);
13214 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13216 if(this.allowBlank && !this.pageSize && !this.disableClear){
13217 this.footer = this.list.createChild({cls:cls+'-ft'});
13218 this.pageTb = new Roo.Toolbar(this.footer);
13222 this.footer = this.list.createChild({cls:cls+'-ft'});
13223 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13224 {pageSize: this.pageSize});
13228 if (this.pageTb && this.allowBlank && !this.disableClear) {
13230 this.pageTb.add(new Roo.Toolbar.Fill(), {
13231 cls: 'x-btn-icon x-btn-clear',
13233 handler: function()
13236 _this.clearValue();
13237 _this.onSelect(false, -1);
13242 this.assetHeight += this.footer.getHeight();
13247 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13250 this.view = new Roo.View(this.list, this.tpl, {
13251 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13253 //this.view.wrapEl.setDisplayed(false);
13254 this.view.on('click', this.onViewClick, this);
13257 this.store.on('beforeload', this.onBeforeLoad, this);
13258 this.store.on('load', this.onLoad, this);
13259 this.store.on('loadexception', this.onLoadException, this);
13261 if(this.resizable){
13262 this.resizer = new Roo.Resizable(this.list, {
13263 pinned:true, handles:'se'
13265 this.resizer.on('resize', function(r, w, h){
13266 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13267 this.listWidth = w;
13268 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13269 this.restrictHeight();
13271 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13274 if(!this.editable){
13275 this.editable = true;
13276 this.setEditable(false);
13281 if (typeof(this.events.add.listeners) != 'undefined') {
13283 this.addicon = this.wrap.createChild(
13284 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13286 this.addicon.on('click', function(e) {
13287 this.fireEvent('add', this);
13290 if (typeof(this.events.edit.listeners) != 'undefined') {
13292 this.editicon = this.wrap.createChild(
13293 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13294 if (this.addicon) {
13295 this.editicon.setStyle('margin-left', '40px');
13297 this.editicon.on('click', function(e) {
13299 // we fire even if inothing is selected..
13300 this.fireEvent('edit', this, this.lastData );
13306 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13307 "up" : function(e){
13308 this.inKeyMode = true;
13312 "down" : function(e){
13313 if(!this.isExpanded()){
13314 this.onTriggerClick();
13316 this.inKeyMode = true;
13321 "enter" : function(e){
13322 // this.onViewClick();
13326 if(this.fireEvent("specialkey", this, e)){
13327 this.onViewClick(false);
13333 "esc" : function(e){
13337 "tab" : function(e){
13340 if(this.fireEvent("specialkey", this, e)){
13341 this.onViewClick(false);
13349 doRelay : function(foo, bar, hname){
13350 if(hname == 'down' || this.scope.isExpanded()){
13351 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13360 this.queryDelay = Math.max(this.queryDelay || 10,
13361 this.mode == 'local' ? 10 : 250);
13364 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13366 if(this.typeAhead){
13367 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13369 if(this.editable !== false){
13370 this.inputEl().on("keyup", this.onKeyUp, this);
13372 if(this.forceSelection){
13373 this.inputEl().on('blur', this.doForce, this);
13377 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13378 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13382 initTickableEvents: function()
13386 if(this.hiddenName){
13388 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13390 this.hiddenField.dom.value =
13391 this.hiddenValue !== undefined ? this.hiddenValue :
13392 this.value !== undefined ? this.value : '';
13394 // prevent input submission
13395 this.el.dom.removeAttribute('name');
13396 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13401 // this.list = this.el.select('ul.dropdown-menu',true).first();
13403 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13404 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13405 if(this.triggerList){
13406 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13409 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13410 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13412 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13413 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13415 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13416 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13418 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13419 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13420 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13423 this.cancelBtn.hide();
13428 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13429 _this.list.setWidth(lw);
13432 this.list.on('mouseover', this.onViewOver, this);
13433 this.list.on('mousemove', this.onViewMove, this);
13435 this.list.on('scroll', this.onViewScroll, this);
13438 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>';
13441 this.view = new Roo.View(this.list, this.tpl, {
13442 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13445 //this.view.wrapEl.setDisplayed(false);
13446 this.view.on('click', this.onViewClick, this);
13450 this.store.on('beforeload', this.onBeforeLoad, this);
13451 this.store.on('load', this.onLoad, this);
13452 this.store.on('loadexception', this.onLoadException, this);
13455 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13456 "up" : function(e){
13457 this.inKeyMode = true;
13461 "down" : function(e){
13462 this.inKeyMode = true;
13466 "enter" : function(e){
13467 if(this.fireEvent("specialkey", this, e)){
13468 this.onViewClick(false);
13474 "esc" : function(e){
13475 this.onTickableFooterButtonClick(e, false, false);
13478 "tab" : function(e){
13479 this.fireEvent("specialkey", this, e);
13481 this.onTickableFooterButtonClick(e, false, false);
13488 doRelay : function(e, fn, key){
13489 if(this.scope.isExpanded()){
13490 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13499 this.queryDelay = Math.max(this.queryDelay || 10,
13500 this.mode == 'local' ? 10 : 250);
13503 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13505 if(this.typeAhead){
13506 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13509 if(this.editable !== false){
13510 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13513 this.indicator = this.indicatorEl();
13515 if(this.indicator){
13516 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13517 this.indicator.hide();
13522 onDestroy : function(){
13524 this.view.setStore(null);
13525 this.view.el.removeAllListeners();
13526 this.view.el.remove();
13527 this.view.purgeListeners();
13530 this.list.dom.innerHTML = '';
13534 this.store.un('beforeload', this.onBeforeLoad, this);
13535 this.store.un('load', this.onLoad, this);
13536 this.store.un('loadexception', this.onLoadException, this);
13538 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13542 fireKey : function(e){
13543 if(e.isNavKeyPress() && !this.list.isVisible()){
13544 this.fireEvent("specialkey", this, e);
13549 onResize: function(w, h){
13550 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13552 // if(typeof w != 'number'){
13553 // // we do not handle it!?!?
13556 // var tw = this.trigger.getWidth();
13557 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13558 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13560 // this.inputEl().setWidth( this.adjustWidth('input', x));
13562 // //this.trigger.setStyle('left', x+'px');
13564 // if(this.list && this.listWidth === undefined){
13565 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13566 // this.list.setWidth(lw);
13567 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13575 * Allow or prevent the user from directly editing the field text. If false is passed,
13576 * the user will only be able to select from the items defined in the dropdown list. This method
13577 * is the runtime equivalent of setting the 'editable' config option at config time.
13578 * @param {Boolean} value True to allow the user to directly edit the field text
13580 setEditable : function(value){
13581 if(value == this.editable){
13584 this.editable = value;
13586 this.inputEl().dom.setAttribute('readOnly', true);
13587 this.inputEl().on('mousedown', this.onTriggerClick, this);
13588 this.inputEl().addClass('x-combo-noedit');
13590 this.inputEl().dom.setAttribute('readOnly', false);
13591 this.inputEl().un('mousedown', this.onTriggerClick, this);
13592 this.inputEl().removeClass('x-combo-noedit');
13598 onBeforeLoad : function(combo,opts){
13599 if(!this.hasFocus){
13603 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13605 this.restrictHeight();
13606 this.selectedIndex = -1;
13610 onLoad : function(){
13612 this.hasQuery = false;
13614 if(!this.hasFocus){
13618 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13619 this.loading.hide();
13622 if(this.store.getCount() > 0){
13625 this.restrictHeight();
13626 if(this.lastQuery == this.allQuery){
13627 if(this.editable && !this.tickable){
13628 this.inputEl().dom.select();
13632 !this.selectByValue(this.value, true) &&
13635 !this.store.lastOptions ||
13636 typeof(this.store.lastOptions.add) == 'undefined' ||
13637 this.store.lastOptions.add != true
13640 this.select(0, true);
13643 if(this.autoFocus){
13646 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13647 this.taTask.delay(this.typeAheadDelay);
13651 this.onEmptyResults();
13657 onLoadException : function()
13659 this.hasQuery = false;
13661 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13662 this.loading.hide();
13665 if(this.tickable && this.editable){
13670 // only causes errors at present
13671 //Roo.log(this.store.reader.jsonData);
13672 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13674 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13680 onTypeAhead : function(){
13681 if(this.store.getCount() > 0){
13682 var r = this.store.getAt(0);
13683 var newValue = r.data[this.displayField];
13684 var len = newValue.length;
13685 var selStart = this.getRawValue().length;
13687 if(selStart != len){
13688 this.setRawValue(newValue);
13689 this.selectText(selStart, newValue.length);
13695 onSelect : function(record, index){
13697 if(this.fireEvent('beforeselect', this, record, index) !== false){
13699 this.setFromData(index > -1 ? record.data : false);
13702 this.fireEvent('select', this, record, index);
13707 * Returns the currently selected field value or empty string if no value is set.
13708 * @return {String} value The selected value
13710 getValue : function()
13712 if(Roo.isIOS && this.useNativeIOS){
13713 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13717 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13720 if(this.valueField){
13721 return typeof this.value != 'undefined' ? this.value : '';
13723 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13727 getRawValue : function()
13729 if(Roo.isIOS && this.useNativeIOS){
13730 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13733 var v = this.inputEl().getValue();
13739 * Clears any text/value currently set in the field
13741 clearValue : function(){
13743 if(this.hiddenField){
13744 this.hiddenField.dom.value = '';
13747 this.setRawValue('');
13748 this.lastSelectionText = '';
13749 this.lastData = false;
13751 var close = this.closeTriggerEl();
13762 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13763 * will be displayed in the field. If the value does not match the data value of an existing item,
13764 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13765 * Otherwise the field will be blank (although the value will still be set).
13766 * @param {String} value The value to match
13768 setValue : function(v)
13770 if(Roo.isIOS && this.useNativeIOS){
13771 this.setIOSValue(v);
13781 if(this.valueField){
13782 var r = this.findRecord(this.valueField, v);
13784 text = r.data[this.displayField];
13785 }else if(this.valueNotFoundText !== undefined){
13786 text = this.valueNotFoundText;
13789 this.lastSelectionText = text;
13790 if(this.hiddenField){
13791 this.hiddenField.dom.value = v;
13793 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13796 var close = this.closeTriggerEl();
13799 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13805 * @property {Object} the last set data for the element
13810 * Sets the value of the field based on a object which is related to the record format for the store.
13811 * @param {Object} value the value to set as. or false on reset?
13813 setFromData : function(o){
13820 var dv = ''; // display value
13821 var vv = ''; // value value..
13823 if (this.displayField) {
13824 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13826 // this is an error condition!!!
13827 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13830 if(this.valueField){
13831 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13834 var close = this.closeTriggerEl();
13837 if(dv.length || vv * 1 > 0){
13839 this.blockFocus=true;
13845 if(this.hiddenField){
13846 this.hiddenField.dom.value = vv;
13848 this.lastSelectionText = dv;
13849 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13853 // no hidden field.. - we store the value in 'value', but still display
13854 // display field!!!!
13855 this.lastSelectionText = dv;
13856 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13863 reset : function(){
13864 // overridden so that last data is reset..
13871 this.setValue(this.originalValue);
13872 //this.clearInvalid();
13873 this.lastData = false;
13875 this.view.clearSelections();
13881 findRecord : function(prop, value){
13883 if(this.store.getCount() > 0){
13884 this.store.each(function(r){
13885 if(r.data[prop] == value){
13895 getName: function()
13897 // returns hidden if it's set..
13898 if (!this.rendered) {return ''};
13899 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13903 onViewMove : function(e, t){
13904 this.inKeyMode = false;
13908 onViewOver : function(e, t){
13909 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13912 var item = this.view.findItemFromChild(t);
13915 var index = this.view.indexOf(item);
13916 this.select(index, false);
13921 onViewClick : function(view, doFocus, el, e)
13923 var index = this.view.getSelectedIndexes()[0];
13925 var r = this.store.getAt(index);
13929 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13936 Roo.each(this.tickItems, function(v,k){
13938 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13940 _this.tickItems.splice(k, 1);
13942 if(typeof(e) == 'undefined' && view == false){
13943 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13955 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13956 this.tickItems.push(r.data);
13959 if(typeof(e) == 'undefined' && view == false){
13960 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13967 this.onSelect(r, index);
13969 if(doFocus !== false && !this.blockFocus){
13970 this.inputEl().focus();
13975 restrictHeight : function(){
13976 //this.innerList.dom.style.height = '';
13977 //var inner = this.innerList.dom;
13978 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13979 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13980 //this.list.beginUpdate();
13981 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13982 this.list.alignTo(this.inputEl(), this.listAlign);
13983 this.list.alignTo(this.inputEl(), this.listAlign);
13984 //this.list.endUpdate();
13988 onEmptyResults : function(){
13990 if(this.tickable && this.editable){
13991 this.hasFocus = false;
13992 this.restrictHeight();
14000 * Returns true if the dropdown list is expanded, else false.
14002 isExpanded : function(){
14003 return this.list.isVisible();
14007 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14008 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14009 * @param {String} value The data value of the item to select
14010 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14011 * selected item if it is not currently in view (defaults to true)
14012 * @return {Boolean} True if the value matched an item in the list, else false
14014 selectByValue : function(v, scrollIntoView){
14015 if(v !== undefined && v !== null){
14016 var r = this.findRecord(this.valueField || this.displayField, v);
14018 this.select(this.store.indexOf(r), scrollIntoView);
14026 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14027 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14028 * @param {Number} index The zero-based index of the list item to select
14029 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14030 * selected item if it is not currently in view (defaults to true)
14032 select : function(index, scrollIntoView){
14033 this.selectedIndex = index;
14034 this.view.select(index);
14035 if(scrollIntoView !== false){
14036 var el = this.view.getNode(index);
14038 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14041 this.list.scrollChildIntoView(el, false);
14047 selectNext : function(){
14048 var ct = this.store.getCount();
14050 if(this.selectedIndex == -1){
14052 }else if(this.selectedIndex < ct-1){
14053 this.select(this.selectedIndex+1);
14059 selectPrev : function(){
14060 var ct = this.store.getCount();
14062 if(this.selectedIndex == -1){
14064 }else if(this.selectedIndex != 0){
14065 this.select(this.selectedIndex-1);
14071 onKeyUp : function(e){
14072 if(this.editable !== false && !e.isSpecialKey()){
14073 this.lastKey = e.getKey();
14074 this.dqTask.delay(this.queryDelay);
14079 validateBlur : function(){
14080 return !this.list || !this.list.isVisible();
14084 initQuery : function(){
14086 var v = this.getRawValue();
14088 if(this.tickable && this.editable){
14089 v = this.tickableInputEl().getValue();
14096 doForce : function(){
14097 if(this.inputEl().dom.value.length > 0){
14098 this.inputEl().dom.value =
14099 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14105 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14106 * query allowing the query action to be canceled if needed.
14107 * @param {String} query The SQL query to execute
14108 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14109 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14110 * saved in the current store (defaults to false)
14112 doQuery : function(q, forceAll){
14114 if(q === undefined || q === null){
14119 forceAll: forceAll,
14123 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14128 forceAll = qe.forceAll;
14129 if(forceAll === true || (q.length >= this.minChars)){
14131 this.hasQuery = true;
14133 if(this.lastQuery != q || this.alwaysQuery){
14134 this.lastQuery = q;
14135 if(this.mode == 'local'){
14136 this.selectedIndex = -1;
14138 this.store.clearFilter();
14141 if(this.specialFilter){
14142 this.fireEvent('specialfilter', this);
14147 this.store.filter(this.displayField, q);
14150 this.store.fireEvent("datachanged", this.store);
14157 this.store.baseParams[this.queryParam] = q;
14159 var options = {params : this.getParams(q)};
14162 options.add = true;
14163 options.params.start = this.page * this.pageSize;
14166 this.store.load(options);
14169 * this code will make the page width larger, at the beginning, the list not align correctly,
14170 * we should expand the list on onLoad
14171 * so command out it
14176 this.selectedIndex = -1;
14181 this.loadNext = false;
14185 getParams : function(q){
14187 //p[this.queryParam] = q;
14191 p.limit = this.pageSize;
14197 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14199 collapse : function(){
14200 if(!this.isExpanded()){
14206 this.hasFocus = false;
14210 this.cancelBtn.hide();
14211 this.trigger.show();
14214 this.tickableInputEl().dom.value = '';
14215 this.tickableInputEl().blur();
14220 Roo.get(document).un('mousedown', this.collapseIf, this);
14221 Roo.get(document).un('mousewheel', this.collapseIf, this);
14222 if (!this.editable) {
14223 Roo.get(document).un('keydown', this.listKeyPress, this);
14225 this.fireEvent('collapse', this);
14231 collapseIf : function(e){
14232 var in_combo = e.within(this.el);
14233 var in_list = e.within(this.list);
14234 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14236 if (in_combo || in_list || is_list) {
14237 //e.stopPropagation();
14242 this.onTickableFooterButtonClick(e, false, false);
14250 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14252 expand : function(){
14254 if(this.isExpanded() || !this.hasFocus){
14258 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14259 this.list.setWidth(lw);
14265 this.restrictHeight();
14269 this.tickItems = Roo.apply([], this.item);
14272 this.cancelBtn.show();
14273 this.trigger.hide();
14276 this.tickableInputEl().focus();
14281 Roo.get(document).on('mousedown', this.collapseIf, this);
14282 Roo.get(document).on('mousewheel', this.collapseIf, this);
14283 if (!this.editable) {
14284 Roo.get(document).on('keydown', this.listKeyPress, this);
14287 this.fireEvent('expand', this);
14291 // Implements the default empty TriggerField.onTriggerClick function
14292 onTriggerClick : function(e)
14294 Roo.log('trigger click');
14296 if(this.disabled || !this.triggerList){
14301 this.loadNext = false;
14303 if(this.isExpanded()){
14305 if (!this.blockFocus) {
14306 this.inputEl().focus();
14310 this.hasFocus = true;
14311 if(this.triggerAction == 'all') {
14312 this.doQuery(this.allQuery, true);
14314 this.doQuery(this.getRawValue());
14316 if (!this.blockFocus) {
14317 this.inputEl().focus();
14322 onTickableTriggerClick : function(e)
14329 this.loadNext = false;
14330 this.hasFocus = true;
14332 if(this.triggerAction == 'all') {
14333 this.doQuery(this.allQuery, true);
14335 this.doQuery(this.getRawValue());
14339 onSearchFieldClick : function(e)
14341 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14342 this.onTickableFooterButtonClick(e, false, false);
14346 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14351 this.loadNext = false;
14352 this.hasFocus = true;
14354 if(this.triggerAction == 'all') {
14355 this.doQuery(this.allQuery, true);
14357 this.doQuery(this.getRawValue());
14361 listKeyPress : function(e)
14363 //Roo.log('listkeypress');
14364 // scroll to first matching element based on key pres..
14365 if (e.isSpecialKey()) {
14368 var k = String.fromCharCode(e.getKey()).toUpperCase();
14371 var csel = this.view.getSelectedNodes();
14372 var cselitem = false;
14374 var ix = this.view.indexOf(csel[0]);
14375 cselitem = this.store.getAt(ix);
14376 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14382 this.store.each(function(v) {
14384 // start at existing selection.
14385 if (cselitem.id == v.id) {
14391 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14392 match = this.store.indexOf(v);
14398 if (match === false) {
14399 return true; // no more action?
14402 this.view.select(match);
14403 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14404 sn.scrollIntoView(sn.dom.parentNode, false);
14407 onViewScroll : function(e, t){
14409 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){
14413 this.hasQuery = true;
14415 this.loading = this.list.select('.loading', true).first();
14417 if(this.loading === null){
14418 this.list.createChild({
14420 cls: 'loading roo-select2-more-results roo-select2-active',
14421 html: 'Loading more results...'
14424 this.loading = this.list.select('.loading', true).first();
14426 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14428 this.loading.hide();
14431 this.loading.show();
14436 this.loadNext = true;
14438 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14443 addItem : function(o)
14445 var dv = ''; // display value
14447 if (this.displayField) {
14448 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14450 // this is an error condition!!!
14451 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14458 var choice = this.choices.createChild({
14460 cls: 'roo-select2-search-choice',
14469 cls: 'roo-select2-search-choice-close fa fa-times',
14474 }, this.searchField);
14476 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14478 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14486 this.inputEl().dom.value = '';
14491 onRemoveItem : function(e, _self, o)
14493 e.preventDefault();
14495 this.lastItem = Roo.apply([], this.item);
14497 var index = this.item.indexOf(o.data) * 1;
14500 Roo.log('not this item?!');
14504 this.item.splice(index, 1);
14509 this.fireEvent('remove', this, e);
14515 syncValue : function()
14517 if(!this.item.length){
14524 Roo.each(this.item, function(i){
14525 if(_this.valueField){
14526 value.push(i[_this.valueField]);
14533 this.value = value.join(',');
14535 if(this.hiddenField){
14536 this.hiddenField.dom.value = this.value;
14539 this.store.fireEvent("datachanged", this.store);
14544 clearItem : function()
14546 if(!this.multiple){
14552 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14560 if(this.tickable && !Roo.isTouch){
14561 this.view.refresh();
14565 inputEl: function ()
14567 if(Roo.isIOS && this.useNativeIOS){
14568 return this.el.select('select.roo-ios-select', true).first();
14571 if(Roo.isTouch && this.mobileTouchView){
14572 return this.el.select('input.form-control',true).first();
14576 return this.searchField;
14579 return this.el.select('input.form-control',true).first();
14582 onTickableFooterButtonClick : function(e, btn, el)
14584 e.preventDefault();
14586 this.lastItem = Roo.apply([], this.item);
14588 if(btn && btn.name == 'cancel'){
14589 this.tickItems = Roo.apply([], this.item);
14598 Roo.each(this.tickItems, function(o){
14606 validate : function()
14608 var v = this.getRawValue();
14611 v = this.getValue();
14614 if(this.disabled || this.allowBlank || v.length){
14619 this.markInvalid();
14623 tickableInputEl : function()
14625 if(!this.tickable || !this.editable){
14626 return this.inputEl();
14629 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14633 getAutoCreateTouchView : function()
14638 cls: 'form-group' //input-group
14644 type : this.inputType,
14645 cls : 'form-control x-combo-noedit',
14646 autocomplete: 'new-password',
14647 placeholder : this.placeholder || '',
14652 input.name = this.name;
14656 input.cls += ' input-' + this.size;
14659 if (this.disabled) {
14660 input.disabled = true;
14671 inputblock.cls += ' input-group';
14673 inputblock.cn.unshift({
14675 cls : 'input-group-addon',
14680 if(this.removable && !this.multiple){
14681 inputblock.cls += ' roo-removable';
14683 inputblock.cn.push({
14686 cls : 'roo-combo-removable-btn close'
14690 if(this.hasFeedback && !this.allowBlank){
14692 inputblock.cls += ' has-feedback';
14694 inputblock.cn.push({
14696 cls: 'glyphicon form-control-feedback'
14703 inputblock.cls += (this.before) ? '' : ' input-group';
14705 inputblock.cn.push({
14707 cls : 'input-group-addon',
14718 cls: 'form-hidden-field'
14732 cls: 'form-hidden-field'
14736 cls: 'roo-select2-choices',
14740 cls: 'roo-select2-search-field',
14753 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14759 if(!this.multiple && this.showToggleBtn){
14766 if (this.caret != false) {
14769 cls: 'fa fa-' + this.caret
14776 cls : 'input-group-addon btn dropdown-toggle',
14781 cls: 'combobox-clear',
14795 combobox.cls += ' roo-select2-container-multi';
14798 var align = this.labelAlign || this.parentLabelAlign();
14800 if (align ==='left' && this.fieldLabel.length) {
14805 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14806 tooltip : 'This field is required'
14810 cls : 'control-label',
14811 html : this.fieldLabel
14822 var labelCfg = cfg.cn[1];
14823 var contentCfg = cfg.cn[2];
14826 if(this.indicatorpos == 'right'){
14831 cls : 'control-label',
14835 html : this.fieldLabel
14839 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14840 tooltip : 'This field is required'
14853 labelCfg = cfg.cn[0];
14854 contentCfg = cfg.cn[1];
14859 if(this.labelWidth > 12){
14860 labelCfg.style = "width: " + this.labelWidth + 'px';
14863 if(this.labelWidth < 13 && this.labelmd == 0){
14864 this.labelmd = this.labelWidth;
14867 if(this.labellg > 0){
14868 labelCfg.cls += ' col-lg-' + this.labellg;
14869 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14872 if(this.labelmd > 0){
14873 labelCfg.cls += ' col-md-' + this.labelmd;
14874 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14877 if(this.labelsm > 0){
14878 labelCfg.cls += ' col-sm-' + this.labelsm;
14879 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14882 if(this.labelxs > 0){
14883 labelCfg.cls += ' col-xs-' + this.labelxs;
14884 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14888 } else if ( this.fieldLabel.length) {
14892 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14893 tooltip : 'This field is required'
14897 cls : 'control-label',
14898 html : this.fieldLabel
14909 if(this.indicatorpos == 'right'){
14913 cls : 'control-label',
14914 html : this.fieldLabel,
14918 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14919 tooltip : 'This field is required'
14936 var settings = this;
14938 ['xs','sm','md','lg'].map(function(size){
14939 if (settings[size]) {
14940 cfg.cls += ' col-' + size + '-' + settings[size];
14947 initTouchView : function()
14949 this.renderTouchView();
14951 this.touchViewEl.on('scroll', function(){
14952 this.el.dom.scrollTop = 0;
14955 this.originalValue = this.getValue();
14957 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14959 this.inputEl().on("click", this.showTouchView, this);
14960 if (this.triggerEl) {
14961 this.triggerEl.on("click", this.showTouchView, this);
14965 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14966 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14968 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14970 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14971 this.store.on('load', this.onTouchViewLoad, this);
14972 this.store.on('loadexception', this.onTouchViewLoadException, this);
14974 if(this.hiddenName){
14976 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14978 this.hiddenField.dom.value =
14979 this.hiddenValue !== undefined ? this.hiddenValue :
14980 this.value !== undefined ? this.value : '';
14982 this.el.dom.removeAttribute('name');
14983 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14987 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14988 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14991 if(this.removable && !this.multiple){
14992 var close = this.closeTriggerEl();
14994 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14995 close.on('click', this.removeBtnClick, this, close);
14999 * fix the bug in Safari iOS8
15001 this.inputEl().on("focus", function(e){
15002 document.activeElement.blur();
15010 renderTouchView : function()
15012 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15013 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15015 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15016 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15018 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15019 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15020 this.touchViewBodyEl.setStyle('overflow', 'auto');
15022 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15023 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15025 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15026 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15030 showTouchView : function()
15036 this.touchViewHeaderEl.hide();
15038 if(this.modalTitle.length){
15039 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15040 this.touchViewHeaderEl.show();
15043 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15044 this.touchViewEl.show();
15046 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15048 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15049 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15051 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15053 if(this.modalTitle.length){
15054 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15057 this.touchViewBodyEl.setHeight(bodyHeight);
15061 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15063 this.touchViewEl.addClass('in');
15066 this.doTouchViewQuery();
15070 hideTouchView : function()
15072 this.touchViewEl.removeClass('in');
15076 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15078 this.touchViewEl.setStyle('display', 'none');
15083 setTouchViewValue : function()
15090 Roo.each(this.tickItems, function(o){
15095 this.hideTouchView();
15098 doTouchViewQuery : function()
15107 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15111 if(!this.alwaysQuery || this.mode == 'local'){
15112 this.onTouchViewLoad();
15119 onTouchViewBeforeLoad : function(combo,opts)
15125 onTouchViewLoad : function()
15127 if(this.store.getCount() < 1){
15128 this.onTouchViewEmptyResults();
15132 this.clearTouchView();
15134 var rawValue = this.getRawValue();
15136 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15138 this.tickItems = [];
15140 this.store.data.each(function(d, rowIndex){
15141 var row = this.touchViewListGroup.createChild(template);
15143 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15144 row.addClass(d.data.cls);
15147 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15150 html : d.data[this.displayField]
15153 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15154 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15157 row.removeClass('selected');
15158 if(!this.multiple && this.valueField &&
15159 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15162 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15163 row.addClass('selected');
15166 if(this.multiple && this.valueField &&
15167 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15171 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15172 this.tickItems.push(d.data);
15175 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15179 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15181 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15183 if(this.modalTitle.length){
15184 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15187 var listHeight = this.touchViewListGroup.getHeight();
15191 if(firstChecked && listHeight > bodyHeight){
15192 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15197 onTouchViewLoadException : function()
15199 this.hideTouchView();
15202 onTouchViewEmptyResults : function()
15204 this.clearTouchView();
15206 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15208 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15212 clearTouchView : function()
15214 this.touchViewListGroup.dom.innerHTML = '';
15217 onTouchViewClick : function(e, el, o)
15219 e.preventDefault();
15222 var rowIndex = o.rowIndex;
15224 var r = this.store.getAt(rowIndex);
15226 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15228 if(!this.multiple){
15229 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15230 c.dom.removeAttribute('checked');
15233 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15235 this.setFromData(r.data);
15237 var close = this.closeTriggerEl();
15243 this.hideTouchView();
15245 this.fireEvent('select', this, r, rowIndex);
15250 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15251 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15252 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15256 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15257 this.addItem(r.data);
15258 this.tickItems.push(r.data);
15262 getAutoCreateNativeIOS : function()
15265 cls: 'form-group' //input-group,
15270 cls : 'roo-ios-select'
15274 combobox.name = this.name;
15277 if (this.disabled) {
15278 combobox.disabled = true;
15281 var settings = this;
15283 ['xs','sm','md','lg'].map(function(size){
15284 if (settings[size]) {
15285 cfg.cls += ' col-' + size + '-' + settings[size];
15295 initIOSView : function()
15297 this.store.on('load', this.onIOSViewLoad, this);
15302 onIOSViewLoad : function()
15304 if(this.store.getCount() < 1){
15308 this.clearIOSView();
15310 if(this.allowBlank) {
15312 var default_text = '-- SELECT --';
15314 if(this.placeholder.length){
15315 default_text = this.placeholder;
15318 if(this.emptyTitle.length){
15319 default_text += ' - ' + this.emptyTitle + ' -';
15322 var opt = this.inputEl().createChild({
15325 html : default_text
15329 o[this.valueField] = 0;
15330 o[this.displayField] = default_text;
15332 this.ios_options.push({
15339 this.store.data.each(function(d, rowIndex){
15343 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15344 html = d.data[this.displayField];
15349 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15350 value = d.data[this.valueField];
15359 if(this.value == d.data[this.valueField]){
15360 option['selected'] = true;
15363 var opt = this.inputEl().createChild(option);
15365 this.ios_options.push({
15372 this.inputEl().on('change', function(){
15373 this.fireEvent('select', this);
15378 clearIOSView: function()
15380 this.inputEl().dom.innerHTML = '';
15382 this.ios_options = [];
15385 setIOSValue: function(v)
15389 if(!this.ios_options){
15393 Roo.each(this.ios_options, function(opts){
15395 opts.el.dom.removeAttribute('selected');
15397 if(opts.data[this.valueField] != v){
15401 opts.el.dom.setAttribute('selected', true);
15407 * @cfg {Boolean} grow
15411 * @cfg {Number} growMin
15415 * @cfg {Number} growMax
15424 Roo.apply(Roo.bootstrap.ComboBox, {
15428 cls: 'modal-header',
15450 cls: 'list-group-item',
15454 cls: 'roo-combobox-list-group-item-value'
15458 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15472 listItemCheckbox : {
15474 cls: 'list-group-item',
15478 cls: 'roo-combobox-list-group-item-value'
15482 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15498 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15503 cls: 'modal-footer',
15511 cls: 'col-xs-6 text-left',
15514 cls: 'btn btn-danger roo-touch-view-cancel',
15520 cls: 'col-xs-6 text-right',
15523 cls: 'btn btn-success roo-touch-view-ok',
15534 Roo.apply(Roo.bootstrap.ComboBox, {
15536 touchViewTemplate : {
15538 cls: 'modal fade roo-combobox-touch-view',
15542 cls: 'modal-dialog',
15543 style : 'position:fixed', // we have to fix position....
15547 cls: 'modal-content',
15549 Roo.bootstrap.ComboBox.header,
15550 Roo.bootstrap.ComboBox.body,
15551 Roo.bootstrap.ComboBox.footer
15560 * Ext JS Library 1.1.1
15561 * Copyright(c) 2006-2007, Ext JS, LLC.
15563 * Originally Released Under LGPL - original licence link has changed is not relivant.
15566 * <script type="text/javascript">
15571 * @extends Roo.util.Observable
15572 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15573 * This class also supports single and multi selection modes. <br>
15574 * Create a data model bound view:
15576 var store = new Roo.data.Store(...);
15578 var view = new Roo.View({
15580 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15582 singleSelect: true,
15583 selectedClass: "ydataview-selected",
15587 // listen for node click?
15588 view.on("click", function(vw, index, node, e){
15589 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15593 dataModel.load("foobar.xml");
15595 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15597 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15598 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15600 * Note: old style constructor is still suported (container, template, config)
15603 * Create a new View
15604 * @param {Object} config The config object
15607 Roo.View = function(config, depreciated_tpl, depreciated_config){
15609 this.parent = false;
15611 if (typeof(depreciated_tpl) == 'undefined') {
15612 // new way.. - universal constructor.
15613 Roo.apply(this, config);
15614 this.el = Roo.get(this.el);
15617 this.el = Roo.get(config);
15618 this.tpl = depreciated_tpl;
15619 Roo.apply(this, depreciated_config);
15621 this.wrapEl = this.el.wrap().wrap();
15622 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15625 if(typeof(this.tpl) == "string"){
15626 this.tpl = new Roo.Template(this.tpl);
15628 // support xtype ctors..
15629 this.tpl = new Roo.factory(this.tpl, Roo);
15633 this.tpl.compile();
15638 * @event beforeclick
15639 * Fires before a click is processed. Returns false to cancel the default action.
15640 * @param {Roo.View} this
15641 * @param {Number} index The index of the target node
15642 * @param {HTMLElement} node The target node
15643 * @param {Roo.EventObject} e The raw event object
15645 "beforeclick" : true,
15648 * Fires when a template node is clicked.
15649 * @param {Roo.View} this
15650 * @param {Number} index The index of the target node
15651 * @param {HTMLElement} node The target node
15652 * @param {Roo.EventObject} e The raw event object
15657 * Fires when a template node is double clicked.
15658 * @param {Roo.View} this
15659 * @param {Number} index The index of the target node
15660 * @param {HTMLElement} node The target node
15661 * @param {Roo.EventObject} e The raw event object
15665 * @event contextmenu
15666 * Fires when a template node is right clicked.
15667 * @param {Roo.View} this
15668 * @param {Number} index The index of the target node
15669 * @param {HTMLElement} node The target node
15670 * @param {Roo.EventObject} e The raw event object
15672 "contextmenu" : true,
15674 * @event selectionchange
15675 * Fires when the selected nodes change.
15676 * @param {Roo.View} this
15677 * @param {Array} selections Array of the selected nodes
15679 "selectionchange" : true,
15682 * @event beforeselect
15683 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15684 * @param {Roo.View} this
15685 * @param {HTMLElement} node The node to be selected
15686 * @param {Array} selections Array of currently selected nodes
15688 "beforeselect" : true,
15690 * @event preparedata
15691 * Fires on every row to render, to allow you to change the data.
15692 * @param {Roo.View} this
15693 * @param {Object} data to be rendered (change this)
15695 "preparedata" : true
15703 "click": this.onClick,
15704 "dblclick": this.onDblClick,
15705 "contextmenu": this.onContextMenu,
15709 this.selections = [];
15711 this.cmp = new Roo.CompositeElementLite([]);
15713 this.store = Roo.factory(this.store, Roo.data);
15714 this.setStore(this.store, true);
15717 if ( this.footer && this.footer.xtype) {
15719 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15721 this.footer.dataSource = this.store;
15722 this.footer.container = fctr;
15723 this.footer = Roo.factory(this.footer, Roo);
15724 fctr.insertFirst(this.el);
15726 // this is a bit insane - as the paging toolbar seems to detach the el..
15727 // dom.parentNode.parentNode.parentNode
15728 // they get detached?
15732 Roo.View.superclass.constructor.call(this);
15737 Roo.extend(Roo.View, Roo.util.Observable, {
15740 * @cfg {Roo.data.Store} store Data store to load data from.
15745 * @cfg {String|Roo.Element} el The container element.
15750 * @cfg {String|Roo.Template} tpl The template used by this View
15754 * @cfg {String} dataName the named area of the template to use as the data area
15755 * Works with domtemplates roo-name="name"
15759 * @cfg {String} selectedClass The css class to add to selected nodes
15761 selectedClass : "x-view-selected",
15763 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15768 * @cfg {String} text to display on mask (default Loading)
15772 * @cfg {Boolean} multiSelect Allow multiple selection
15774 multiSelect : false,
15776 * @cfg {Boolean} singleSelect Allow single selection
15778 singleSelect: false,
15781 * @cfg {Boolean} toggleSelect - selecting
15783 toggleSelect : false,
15786 * @cfg {Boolean} tickable - selecting
15791 * Returns the element this view is bound to.
15792 * @return {Roo.Element}
15794 getEl : function(){
15795 return this.wrapEl;
15801 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15803 refresh : function(){
15804 //Roo.log('refresh');
15807 // if we are using something like 'domtemplate', then
15808 // the what gets used is:
15809 // t.applySubtemplate(NAME, data, wrapping data..)
15810 // the outer template then get' applied with
15811 // the store 'extra data'
15812 // and the body get's added to the
15813 // roo-name="data" node?
15814 // <span class='roo-tpl-{name}'></span> ?????
15818 this.clearSelections();
15819 this.el.update("");
15821 var records = this.store.getRange();
15822 if(records.length < 1) {
15824 // is this valid?? = should it render a template??
15826 this.el.update(this.emptyText);
15830 if (this.dataName) {
15831 this.el.update(t.apply(this.store.meta)); //????
15832 el = this.el.child('.roo-tpl-' + this.dataName);
15835 for(var i = 0, len = records.length; i < len; i++){
15836 var data = this.prepareData(records[i].data, i, records[i]);
15837 this.fireEvent("preparedata", this, data, i, records[i]);
15839 var d = Roo.apply({}, data);
15842 Roo.apply(d, {'roo-id' : Roo.id()});
15846 Roo.each(this.parent.item, function(item){
15847 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15850 Roo.apply(d, {'roo-data-checked' : 'checked'});
15854 html[html.length] = Roo.util.Format.trim(
15856 t.applySubtemplate(this.dataName, d, this.store.meta) :
15863 el.update(html.join(""));
15864 this.nodes = el.dom.childNodes;
15865 this.updateIndexes(0);
15870 * Function to override to reformat the data that is sent to
15871 * the template for each node.
15872 * DEPRICATED - use the preparedata event handler.
15873 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15874 * a JSON object for an UpdateManager bound view).
15876 prepareData : function(data, index, record)
15878 this.fireEvent("preparedata", this, data, index, record);
15882 onUpdate : function(ds, record){
15883 // Roo.log('on update');
15884 this.clearSelections();
15885 var index = this.store.indexOf(record);
15886 var n = this.nodes[index];
15887 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15888 n.parentNode.removeChild(n);
15889 this.updateIndexes(index, index);
15895 onAdd : function(ds, records, index)
15897 //Roo.log(['on Add', ds, records, index] );
15898 this.clearSelections();
15899 if(this.nodes.length == 0){
15903 var n = this.nodes[index];
15904 for(var i = 0, len = records.length; i < len; i++){
15905 var d = this.prepareData(records[i].data, i, records[i]);
15907 this.tpl.insertBefore(n, d);
15910 this.tpl.append(this.el, d);
15913 this.updateIndexes(index);
15916 onRemove : function(ds, record, index){
15917 // Roo.log('onRemove');
15918 this.clearSelections();
15919 var el = this.dataName ?
15920 this.el.child('.roo-tpl-' + this.dataName) :
15923 el.dom.removeChild(this.nodes[index]);
15924 this.updateIndexes(index);
15928 * Refresh an individual node.
15929 * @param {Number} index
15931 refreshNode : function(index){
15932 this.onUpdate(this.store, this.store.getAt(index));
15935 updateIndexes : function(startIndex, endIndex){
15936 var ns = this.nodes;
15937 startIndex = startIndex || 0;
15938 endIndex = endIndex || ns.length - 1;
15939 for(var i = startIndex; i <= endIndex; i++){
15940 ns[i].nodeIndex = i;
15945 * Changes the data store this view uses and refresh the view.
15946 * @param {Store} store
15948 setStore : function(store, initial){
15949 if(!initial && this.store){
15950 this.store.un("datachanged", this.refresh);
15951 this.store.un("add", this.onAdd);
15952 this.store.un("remove", this.onRemove);
15953 this.store.un("update", this.onUpdate);
15954 this.store.un("clear", this.refresh);
15955 this.store.un("beforeload", this.onBeforeLoad);
15956 this.store.un("load", this.onLoad);
15957 this.store.un("loadexception", this.onLoad);
15961 store.on("datachanged", this.refresh, this);
15962 store.on("add", this.onAdd, this);
15963 store.on("remove", this.onRemove, this);
15964 store.on("update", this.onUpdate, this);
15965 store.on("clear", this.refresh, this);
15966 store.on("beforeload", this.onBeforeLoad, this);
15967 store.on("load", this.onLoad, this);
15968 store.on("loadexception", this.onLoad, this);
15976 * onbeforeLoad - masks the loading area.
15979 onBeforeLoad : function(store,opts)
15981 //Roo.log('onBeforeLoad');
15983 this.el.update("");
15985 this.el.mask(this.mask ? this.mask : "Loading" );
15987 onLoad : function ()
15994 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15995 * @param {HTMLElement} node
15996 * @return {HTMLElement} The template node
15998 findItemFromChild : function(node){
15999 var el = this.dataName ?
16000 this.el.child('.roo-tpl-' + this.dataName,true) :
16003 if(!node || node.parentNode == el){
16006 var p = node.parentNode;
16007 while(p && p != el){
16008 if(p.parentNode == el){
16017 onClick : function(e){
16018 var item = this.findItemFromChild(e.getTarget());
16020 var index = this.indexOf(item);
16021 if(this.onItemClick(item, index, e) !== false){
16022 this.fireEvent("click", this, index, item, e);
16025 this.clearSelections();
16030 onContextMenu : function(e){
16031 var item = this.findItemFromChild(e.getTarget());
16033 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16038 onDblClick : function(e){
16039 var item = this.findItemFromChild(e.getTarget());
16041 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16045 onItemClick : function(item, index, e)
16047 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16050 if (this.toggleSelect) {
16051 var m = this.isSelected(item) ? 'unselect' : 'select';
16054 _t[m](item, true, false);
16057 if(this.multiSelect || this.singleSelect){
16058 if(this.multiSelect && e.shiftKey && this.lastSelection){
16059 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16061 this.select(item, this.multiSelect && e.ctrlKey);
16062 this.lastSelection = item;
16065 if(!this.tickable){
16066 e.preventDefault();
16074 * Get the number of selected nodes.
16077 getSelectionCount : function(){
16078 return this.selections.length;
16082 * Get the currently selected nodes.
16083 * @return {Array} An array of HTMLElements
16085 getSelectedNodes : function(){
16086 return this.selections;
16090 * Get the indexes of the selected nodes.
16093 getSelectedIndexes : function(){
16094 var indexes = [], s = this.selections;
16095 for(var i = 0, len = s.length; i < len; i++){
16096 indexes.push(s[i].nodeIndex);
16102 * Clear all selections
16103 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16105 clearSelections : function(suppressEvent){
16106 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16107 this.cmp.elements = this.selections;
16108 this.cmp.removeClass(this.selectedClass);
16109 this.selections = [];
16110 if(!suppressEvent){
16111 this.fireEvent("selectionchange", this, this.selections);
16117 * Returns true if the passed node is selected
16118 * @param {HTMLElement/Number} node The node or node index
16119 * @return {Boolean}
16121 isSelected : function(node){
16122 var s = this.selections;
16126 node = this.getNode(node);
16127 return s.indexOf(node) !== -1;
16132 * @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
16133 * @param {Boolean} keepExisting (optional) true to keep existing selections
16134 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16136 select : function(nodeInfo, keepExisting, suppressEvent){
16137 if(nodeInfo instanceof Array){
16139 this.clearSelections(true);
16141 for(var i = 0, len = nodeInfo.length; i < len; i++){
16142 this.select(nodeInfo[i], true, true);
16146 var node = this.getNode(nodeInfo);
16147 if(!node || this.isSelected(node)){
16148 return; // already selected.
16151 this.clearSelections(true);
16154 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16155 Roo.fly(node).addClass(this.selectedClass);
16156 this.selections.push(node);
16157 if(!suppressEvent){
16158 this.fireEvent("selectionchange", this, this.selections);
16166 * @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
16167 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16168 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16170 unselect : function(nodeInfo, keepExisting, suppressEvent)
16172 if(nodeInfo instanceof Array){
16173 Roo.each(this.selections, function(s) {
16174 this.unselect(s, nodeInfo);
16178 var node = this.getNode(nodeInfo);
16179 if(!node || !this.isSelected(node)){
16180 //Roo.log("not selected");
16181 return; // not selected.
16185 Roo.each(this.selections, function(s) {
16187 Roo.fly(node).removeClass(this.selectedClass);
16194 this.selections= ns;
16195 this.fireEvent("selectionchange", this, this.selections);
16199 * Gets a template node.
16200 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16201 * @return {HTMLElement} The node or null if it wasn't found
16203 getNode : function(nodeInfo){
16204 if(typeof nodeInfo == "string"){
16205 return document.getElementById(nodeInfo);
16206 }else if(typeof nodeInfo == "number"){
16207 return this.nodes[nodeInfo];
16213 * Gets a range template nodes.
16214 * @param {Number} startIndex
16215 * @param {Number} endIndex
16216 * @return {Array} An array of nodes
16218 getNodes : function(start, end){
16219 var ns = this.nodes;
16220 start = start || 0;
16221 end = typeof end == "undefined" ? ns.length - 1 : end;
16224 for(var i = start; i <= end; i++){
16228 for(var i = start; i >= end; i--){
16236 * Finds the index of the passed node
16237 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16238 * @return {Number} The index of the node or -1
16240 indexOf : function(node){
16241 node = this.getNode(node);
16242 if(typeof node.nodeIndex == "number"){
16243 return node.nodeIndex;
16245 var ns = this.nodes;
16246 for(var i = 0, len = ns.length; i < len; i++){
16257 * based on jquery fullcalendar
16261 Roo.bootstrap = Roo.bootstrap || {};
16263 * @class Roo.bootstrap.Calendar
16264 * @extends Roo.bootstrap.Component
16265 * Bootstrap Calendar class
16266 * @cfg {Boolean} loadMask (true|false) default false
16267 * @cfg {Object} header generate the user specific header of the calendar, default false
16270 * Create a new Container
16271 * @param {Object} config The config object
16276 Roo.bootstrap.Calendar = function(config){
16277 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16281 * Fires when a date is selected
16282 * @param {DatePicker} this
16283 * @param {Date} date The selected date
16287 * @event monthchange
16288 * Fires when the displayed month changes
16289 * @param {DatePicker} this
16290 * @param {Date} date The selected month
16292 'monthchange': true,
16294 * @event evententer
16295 * Fires when mouse over an event
16296 * @param {Calendar} this
16297 * @param {event} Event
16299 'evententer': true,
16301 * @event eventleave
16302 * Fires when the mouse leaves an
16303 * @param {Calendar} this
16306 'eventleave': true,
16308 * @event eventclick
16309 * Fires when the mouse click an
16310 * @param {Calendar} this
16319 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16322 * @cfg {Number} startDay
16323 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16331 getAutoCreate : function(){
16334 var fc_button = function(name, corner, style, content ) {
16335 return Roo.apply({},{
16337 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16339 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16342 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16353 style : 'width:100%',
16360 cls : 'fc-header-left',
16362 fc_button('prev', 'left', 'arrow', '‹' ),
16363 fc_button('next', 'right', 'arrow', '›' ),
16364 { tag: 'span', cls: 'fc-header-space' },
16365 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16373 cls : 'fc-header-center',
16377 cls: 'fc-header-title',
16380 html : 'month / year'
16388 cls : 'fc-header-right',
16390 /* fc_button('month', 'left', '', 'month' ),
16391 fc_button('week', '', '', 'week' ),
16392 fc_button('day', 'right', '', 'day' )
16404 header = this.header;
16407 var cal_heads = function() {
16409 // fixme - handle this.
16411 for (var i =0; i < Date.dayNames.length; i++) {
16412 var d = Date.dayNames[i];
16415 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16416 html : d.substring(0,3)
16420 ret[0].cls += ' fc-first';
16421 ret[6].cls += ' fc-last';
16424 var cal_cell = function(n) {
16427 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16432 cls: 'fc-day-number',
16436 cls: 'fc-day-content',
16440 style: 'position: relative;' // height: 17px;
16452 var cal_rows = function() {
16455 for (var r = 0; r < 6; r++) {
16462 for (var i =0; i < Date.dayNames.length; i++) {
16463 var d = Date.dayNames[i];
16464 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16467 row.cn[0].cls+=' fc-first';
16468 row.cn[0].cn[0].style = 'min-height:90px';
16469 row.cn[6].cls+=' fc-last';
16473 ret[0].cls += ' fc-first';
16474 ret[4].cls += ' fc-prev-last';
16475 ret[5].cls += ' fc-last';
16482 cls: 'fc-border-separate',
16483 style : 'width:100%',
16491 cls : 'fc-first fc-last',
16509 cls : 'fc-content',
16510 style : "position: relative;",
16513 cls : 'fc-view fc-view-month fc-grid',
16514 style : 'position: relative',
16515 unselectable : 'on',
16518 cls : 'fc-event-container',
16519 style : 'position:absolute;z-index:8;top:0;left:0;'
16537 initEvents : function()
16540 throw "can not find store for calendar";
16546 style: "text-align:center",
16550 style: "background-color:white;width:50%;margin:250 auto",
16554 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16565 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16567 var size = this.el.select('.fc-content', true).first().getSize();
16568 this.maskEl.setSize(size.width, size.height);
16569 this.maskEl.enableDisplayMode("block");
16570 if(!this.loadMask){
16571 this.maskEl.hide();
16574 this.store = Roo.factory(this.store, Roo.data);
16575 this.store.on('load', this.onLoad, this);
16576 this.store.on('beforeload', this.onBeforeLoad, this);
16580 this.cells = this.el.select('.fc-day',true);
16581 //Roo.log(this.cells);
16582 this.textNodes = this.el.query('.fc-day-number');
16583 this.cells.addClassOnOver('fc-state-hover');
16585 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16586 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16587 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16588 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16590 this.on('monthchange', this.onMonthChange, this);
16592 this.update(new Date().clearTime());
16595 resize : function() {
16596 var sz = this.el.getSize();
16598 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16599 this.el.select('.fc-day-content div',true).setHeight(34);
16604 showPrevMonth : function(e){
16605 this.update(this.activeDate.add("mo", -1));
16607 showToday : function(e){
16608 this.update(new Date().clearTime());
16611 showNextMonth : function(e){
16612 this.update(this.activeDate.add("mo", 1));
16616 showPrevYear : function(){
16617 this.update(this.activeDate.add("y", -1));
16621 showNextYear : function(){
16622 this.update(this.activeDate.add("y", 1));
16627 update : function(date)
16629 var vd = this.activeDate;
16630 this.activeDate = date;
16631 // if(vd && this.el){
16632 // var t = date.getTime();
16633 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16634 // Roo.log('using add remove');
16636 // this.fireEvent('monthchange', this, date);
16638 // this.cells.removeClass("fc-state-highlight");
16639 // this.cells.each(function(c){
16640 // if(c.dateValue == t){
16641 // c.addClass("fc-state-highlight");
16642 // setTimeout(function(){
16643 // try{c.dom.firstChild.focus();}catch(e){}
16653 var days = date.getDaysInMonth();
16655 var firstOfMonth = date.getFirstDateOfMonth();
16656 var startingPos = firstOfMonth.getDay()-this.startDay;
16658 if(startingPos < this.startDay){
16662 var pm = date.add(Date.MONTH, -1);
16663 var prevStart = pm.getDaysInMonth()-startingPos;
16665 this.cells = this.el.select('.fc-day',true);
16666 this.textNodes = this.el.query('.fc-day-number');
16667 this.cells.addClassOnOver('fc-state-hover');
16669 var cells = this.cells.elements;
16670 var textEls = this.textNodes;
16672 Roo.each(cells, function(cell){
16673 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16676 days += startingPos;
16678 // convert everything to numbers so it's fast
16679 var day = 86400000;
16680 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16683 //Roo.log(prevStart);
16685 var today = new Date().clearTime().getTime();
16686 var sel = date.clearTime().getTime();
16687 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16688 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16689 var ddMatch = this.disabledDatesRE;
16690 var ddText = this.disabledDatesText;
16691 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16692 var ddaysText = this.disabledDaysText;
16693 var format = this.format;
16695 var setCellClass = function(cal, cell){
16699 //Roo.log('set Cell Class');
16701 var t = d.getTime();
16705 cell.dateValue = t;
16707 cell.className += " fc-today";
16708 cell.className += " fc-state-highlight";
16709 cell.title = cal.todayText;
16712 // disable highlight in other month..
16713 //cell.className += " fc-state-highlight";
16718 cell.className = " fc-state-disabled";
16719 cell.title = cal.minText;
16723 cell.className = " fc-state-disabled";
16724 cell.title = cal.maxText;
16728 if(ddays.indexOf(d.getDay()) != -1){
16729 cell.title = ddaysText;
16730 cell.className = " fc-state-disabled";
16733 if(ddMatch && format){
16734 var fvalue = d.dateFormat(format);
16735 if(ddMatch.test(fvalue)){
16736 cell.title = ddText.replace("%0", fvalue);
16737 cell.className = " fc-state-disabled";
16741 if (!cell.initialClassName) {
16742 cell.initialClassName = cell.dom.className;
16745 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16750 for(; i < startingPos; i++) {
16751 textEls[i].innerHTML = (++prevStart);
16752 d.setDate(d.getDate()+1);
16754 cells[i].className = "fc-past fc-other-month";
16755 setCellClass(this, cells[i]);
16760 for(; i < days; i++){
16761 intDay = i - startingPos + 1;
16762 textEls[i].innerHTML = (intDay);
16763 d.setDate(d.getDate()+1);
16765 cells[i].className = ''; // "x-date-active";
16766 setCellClass(this, cells[i]);
16770 for(; i < 42; i++) {
16771 textEls[i].innerHTML = (++extraDays);
16772 d.setDate(d.getDate()+1);
16774 cells[i].className = "fc-future fc-other-month";
16775 setCellClass(this, cells[i]);
16778 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16780 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16782 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16783 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16785 if(totalRows != 6){
16786 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16787 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16790 this.fireEvent('monthchange', this, date);
16794 if(!this.internalRender){
16795 var main = this.el.dom.firstChild;
16796 var w = main.offsetWidth;
16797 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16798 Roo.fly(main).setWidth(w);
16799 this.internalRender = true;
16800 // opera does not respect the auto grow header center column
16801 // then, after it gets a width opera refuses to recalculate
16802 // without a second pass
16803 if(Roo.isOpera && !this.secondPass){
16804 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16805 this.secondPass = true;
16806 this.update.defer(10, this, [date]);
16813 findCell : function(dt) {
16814 dt = dt.clearTime().getTime();
16816 this.cells.each(function(c){
16817 //Roo.log("check " +c.dateValue + '?=' + dt);
16818 if(c.dateValue == dt){
16828 findCells : function(ev) {
16829 var s = ev.start.clone().clearTime().getTime();
16831 var e= ev.end.clone().clearTime().getTime();
16834 this.cells.each(function(c){
16835 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16837 if(c.dateValue > e){
16840 if(c.dateValue < s){
16849 // findBestRow: function(cells)
16853 // for (var i =0 ; i < cells.length;i++) {
16854 // ret = Math.max(cells[i].rows || 0,ret);
16861 addItem : function(ev)
16863 // look for vertical location slot in
16864 var cells = this.findCells(ev);
16866 // ev.row = this.findBestRow(cells);
16868 // work out the location.
16872 for(var i =0; i < cells.length; i++) {
16874 cells[i].row = cells[0].row;
16877 cells[i].row = cells[i].row + 1;
16887 if (crow.start.getY() == cells[i].getY()) {
16889 crow.end = cells[i];
16906 cells[0].events.push(ev);
16908 this.calevents.push(ev);
16911 clearEvents: function() {
16913 if(!this.calevents){
16917 Roo.each(this.cells.elements, function(c){
16923 Roo.each(this.calevents, function(e) {
16924 Roo.each(e.els, function(el) {
16925 el.un('mouseenter' ,this.onEventEnter, this);
16926 el.un('mouseleave' ,this.onEventLeave, this);
16931 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16937 renderEvents: function()
16941 this.cells.each(function(c) {
16950 if(c.row != c.events.length){
16951 r = 4 - (4 - (c.row - c.events.length));
16954 c.events = ev.slice(0, r);
16955 c.more = ev.slice(r);
16957 if(c.more.length && c.more.length == 1){
16958 c.events.push(c.more.pop());
16961 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16965 this.cells.each(function(c) {
16967 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16970 for (var e = 0; e < c.events.length; e++){
16971 var ev = c.events[e];
16972 var rows = ev.rows;
16974 for(var i = 0; i < rows.length; i++) {
16976 // how many rows should it span..
16979 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16980 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16982 unselectable : "on",
16985 cls: 'fc-event-inner',
16989 // cls: 'fc-event-time',
16990 // html : cells.length > 1 ? '' : ev.time
16994 cls: 'fc-event-title',
16995 html : String.format('{0}', ev.title)
17002 cls: 'ui-resizable-handle ui-resizable-e',
17003 html : '  '
17010 cfg.cls += ' fc-event-start';
17012 if ((i+1) == rows.length) {
17013 cfg.cls += ' fc-event-end';
17016 var ctr = _this.el.select('.fc-event-container',true).first();
17017 var cg = ctr.createChild(cfg);
17019 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17020 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17022 var r = (c.more.length) ? 1 : 0;
17023 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17024 cg.setWidth(ebox.right - sbox.x -2);
17026 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17027 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17028 cg.on('click', _this.onEventClick, _this, ev);
17039 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17040 style : 'position: absolute',
17041 unselectable : "on",
17044 cls: 'fc-event-inner',
17048 cls: 'fc-event-title',
17056 cls: 'ui-resizable-handle ui-resizable-e',
17057 html : '  '
17063 var ctr = _this.el.select('.fc-event-container',true).first();
17064 var cg = ctr.createChild(cfg);
17066 var sbox = c.select('.fc-day-content',true).first().getBox();
17067 var ebox = c.select('.fc-day-content',true).first().getBox();
17069 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17070 cg.setWidth(ebox.right - sbox.x -2);
17072 cg.on('click', _this.onMoreEventClick, _this, c.more);
17082 onEventEnter: function (e, el,event,d) {
17083 this.fireEvent('evententer', this, el, event);
17086 onEventLeave: function (e, el,event,d) {
17087 this.fireEvent('eventleave', this, el, event);
17090 onEventClick: function (e, el,event,d) {
17091 this.fireEvent('eventclick', this, el, event);
17094 onMonthChange: function () {
17098 onMoreEventClick: function(e, el, more)
17102 this.calpopover.placement = 'right';
17103 this.calpopover.setTitle('More');
17105 this.calpopover.setContent('');
17107 var ctr = this.calpopover.el.select('.popover-content', true).first();
17109 Roo.each(more, function(m){
17111 cls : 'fc-event-hori fc-event-draggable',
17114 var cg = ctr.createChild(cfg);
17116 cg.on('click', _this.onEventClick, _this, m);
17119 this.calpopover.show(el);
17124 onLoad: function ()
17126 this.calevents = [];
17129 if(this.store.getCount() > 0){
17130 this.store.data.each(function(d){
17133 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17134 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17135 time : d.data.start_time,
17136 title : d.data.title,
17137 description : d.data.description,
17138 venue : d.data.venue
17143 this.renderEvents();
17145 if(this.calevents.length && this.loadMask){
17146 this.maskEl.hide();
17150 onBeforeLoad: function()
17152 this.clearEvents();
17154 this.maskEl.show();
17168 * @class Roo.bootstrap.Popover
17169 * @extends Roo.bootstrap.Component
17170 * Bootstrap Popover class
17171 * @cfg {String} html contents of the popover (or false to use children..)
17172 * @cfg {String} title of popover (or false to hide)
17173 * @cfg {String} placement how it is placed
17174 * @cfg {String} trigger click || hover (or false to trigger manually)
17175 * @cfg {String} over what (parent or false to trigger manually.)
17176 * @cfg {Number} delay - delay before showing
17179 * Create a new Popover
17180 * @param {Object} config The config object
17183 Roo.bootstrap.Popover = function(config){
17184 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17190 * After the popover show
17192 * @param {Roo.bootstrap.Popover} this
17197 * After the popover hide
17199 * @param {Roo.bootstrap.Popover} this
17205 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17207 title: 'Fill in a title',
17210 placement : 'right',
17211 trigger : 'hover', // hover
17217 can_build_overlaid : false,
17219 getChildContainer : function()
17221 return this.el.select('.popover-content',true).first();
17224 getAutoCreate : function(){
17227 cls : 'popover roo-dynamic',
17228 style: 'display:block',
17234 cls : 'popover-inner',
17238 cls: 'popover-title',
17242 cls : 'popover-content',
17253 setTitle: function(str)
17256 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17258 setContent: function(str)
17261 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17263 // as it get's added to the bottom of the page.
17264 onRender : function(ct, position)
17266 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17268 var cfg = Roo.apply({}, this.getAutoCreate());
17272 cfg.cls += ' ' + this.cls;
17275 cfg.style = this.style;
17277 //Roo.log("adding to ");
17278 this.el = Roo.get(document.body).createChild(cfg, position);
17279 // Roo.log(this.el);
17284 initEvents : function()
17286 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17287 this.el.enableDisplayMode('block');
17289 if (this.over === false) {
17292 if (this.triggers === false) {
17295 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17296 var triggers = this.trigger ? this.trigger.split(' ') : [];
17297 Roo.each(triggers, function(trigger) {
17299 if (trigger == 'click') {
17300 on_el.on('click', this.toggle, this);
17301 } else if (trigger != 'manual') {
17302 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17303 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17305 on_el.on(eventIn ,this.enter, this);
17306 on_el.on(eventOut, this.leave, this);
17317 toggle : function () {
17318 this.hoverState == 'in' ? this.leave() : this.enter();
17321 enter : function () {
17323 clearTimeout(this.timeout);
17325 this.hoverState = 'in';
17327 if (!this.delay || !this.delay.show) {
17332 this.timeout = setTimeout(function () {
17333 if (_t.hoverState == 'in') {
17336 }, this.delay.show)
17339 leave : function() {
17340 clearTimeout(this.timeout);
17342 this.hoverState = 'out';
17344 if (!this.delay || !this.delay.hide) {
17349 this.timeout = setTimeout(function () {
17350 if (_t.hoverState == 'out') {
17353 }, this.delay.hide)
17356 show : function (on_el)
17359 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17363 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17364 if (this.html !== false) {
17365 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17367 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17368 if (!this.title.length) {
17369 this.el.select('.popover-title',true).hide();
17372 var placement = typeof this.placement == 'function' ?
17373 this.placement.call(this, this.el, on_el) :
17376 var autoToken = /\s?auto?\s?/i;
17377 var autoPlace = autoToken.test(placement);
17379 placement = placement.replace(autoToken, '') || 'top';
17383 //this.el.setXY([0,0]);
17385 this.el.dom.style.display='block';
17386 this.el.addClass(placement);
17388 //this.el.appendTo(on_el);
17390 var p = this.getPosition();
17391 var box = this.el.getBox();
17396 var align = Roo.bootstrap.Popover.alignment[placement];
17399 this.el.alignTo(on_el, align[0],align[1]);
17400 //var arrow = this.el.select('.arrow',true).first();
17401 //arrow.set(align[2],
17403 this.el.addClass('in');
17406 if (this.el.hasClass('fade')) {
17410 this.hoverState = 'in';
17412 this.fireEvent('show', this);
17417 this.el.setXY([0,0]);
17418 this.el.removeClass('in');
17420 this.hoverState = null;
17422 this.fireEvent('hide', this);
17427 Roo.bootstrap.Popover.alignment = {
17428 'left' : ['r-l', [-10,0], 'right'],
17429 'right' : ['l-r', [10,0], 'left'],
17430 'bottom' : ['t-b', [0,10], 'top'],
17431 'top' : [ 'b-t', [0,-10], 'bottom']
17442 * @class Roo.bootstrap.Progress
17443 * @extends Roo.bootstrap.Component
17444 * Bootstrap Progress class
17445 * @cfg {Boolean} striped striped of the progress bar
17446 * @cfg {Boolean} active animated of the progress bar
17450 * Create a new Progress
17451 * @param {Object} config The config object
17454 Roo.bootstrap.Progress = function(config){
17455 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17458 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17463 getAutoCreate : function(){
17471 cfg.cls += ' progress-striped';
17475 cfg.cls += ' active';
17494 * @class Roo.bootstrap.ProgressBar
17495 * @extends Roo.bootstrap.Component
17496 * Bootstrap ProgressBar class
17497 * @cfg {Number} aria_valuenow aria-value now
17498 * @cfg {Number} aria_valuemin aria-value min
17499 * @cfg {Number} aria_valuemax aria-value max
17500 * @cfg {String} label label for the progress bar
17501 * @cfg {String} panel (success | info | warning | danger )
17502 * @cfg {String} role role of the progress bar
17503 * @cfg {String} sr_only text
17507 * Create a new ProgressBar
17508 * @param {Object} config The config object
17511 Roo.bootstrap.ProgressBar = function(config){
17512 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17515 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17519 aria_valuemax : 100,
17525 getAutoCreate : function()
17530 cls: 'progress-bar',
17531 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17543 cfg.role = this.role;
17546 if(this.aria_valuenow){
17547 cfg['aria-valuenow'] = this.aria_valuenow;
17550 if(this.aria_valuemin){
17551 cfg['aria-valuemin'] = this.aria_valuemin;
17554 if(this.aria_valuemax){
17555 cfg['aria-valuemax'] = this.aria_valuemax;
17558 if(this.label && !this.sr_only){
17559 cfg.html = this.label;
17563 cfg.cls += ' progress-bar-' + this.panel;
17569 update : function(aria_valuenow)
17571 this.aria_valuenow = aria_valuenow;
17573 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17588 * @class Roo.bootstrap.TabGroup
17589 * @extends Roo.bootstrap.Column
17590 * Bootstrap Column class
17591 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17592 * @cfg {Boolean} carousel true to make the group behave like a carousel
17593 * @cfg {Boolean} bullets show bullets for the panels
17594 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17595 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17596 * @cfg {Boolean} showarrow (true|false) show arrow default true
17599 * Create a new TabGroup
17600 * @param {Object} config The config object
17603 Roo.bootstrap.TabGroup = function(config){
17604 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17606 this.navId = Roo.id();
17609 Roo.bootstrap.TabGroup.register(this);
17613 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17616 transition : false,
17621 slideOnTouch : false,
17624 getAutoCreate : function()
17626 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17628 cfg.cls += ' tab-content';
17630 if (this.carousel) {
17631 cfg.cls += ' carousel slide';
17634 cls : 'carousel-inner',
17638 if(this.bullets && !Roo.isTouch){
17641 cls : 'carousel-bullets',
17645 if(this.bullets_cls){
17646 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17653 cfg.cn[0].cn.push(bullets);
17656 if(this.showarrow){
17657 cfg.cn[0].cn.push({
17659 class : 'carousel-arrow',
17663 class : 'carousel-prev',
17667 class : 'fa fa-chevron-left'
17673 class : 'carousel-next',
17677 class : 'fa fa-chevron-right'
17690 initEvents: function()
17692 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17693 // this.el.on("touchstart", this.onTouchStart, this);
17696 if(this.autoslide){
17699 this.slideFn = window.setInterval(function() {
17700 _this.showPanelNext();
17704 if(this.showarrow){
17705 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17706 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17712 // onTouchStart : function(e, el, o)
17714 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17718 // this.showPanelNext();
17722 getChildContainer : function()
17724 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17728 * register a Navigation item
17729 * @param {Roo.bootstrap.NavItem} the navitem to add
17731 register : function(item)
17733 this.tabs.push( item);
17734 item.navId = this.navId; // not really needed..
17739 getActivePanel : function()
17742 Roo.each(this.tabs, function(t) {
17752 getPanelByName : function(n)
17755 Roo.each(this.tabs, function(t) {
17756 if (t.tabId == n) {
17764 indexOfPanel : function(p)
17767 Roo.each(this.tabs, function(t,i) {
17768 if (t.tabId == p.tabId) {
17777 * show a specific panel
17778 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17779 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17781 showPanel : function (pan)
17783 if(this.transition || typeof(pan) == 'undefined'){
17784 Roo.log("waiting for the transitionend");
17788 if (typeof(pan) == 'number') {
17789 pan = this.tabs[pan];
17792 if (typeof(pan) == 'string') {
17793 pan = this.getPanelByName(pan);
17796 var cur = this.getActivePanel();
17799 Roo.log('pan or acitve pan is undefined');
17803 if (pan.tabId == this.getActivePanel().tabId) {
17807 if (false === cur.fireEvent('beforedeactivate')) {
17811 if(this.bullets > 0 && !Roo.isTouch){
17812 this.setActiveBullet(this.indexOfPanel(pan));
17815 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17817 this.transition = true;
17818 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17819 var lr = dir == 'next' ? 'left' : 'right';
17820 pan.el.addClass(dir); // or prev
17821 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17822 cur.el.addClass(lr); // or right
17823 pan.el.addClass(lr);
17826 cur.el.on('transitionend', function() {
17827 Roo.log("trans end?");
17829 pan.el.removeClass([lr,dir]);
17830 pan.setActive(true);
17832 cur.el.removeClass([lr]);
17833 cur.setActive(false);
17835 _this.transition = false;
17837 }, this, { single: true } );
17842 cur.setActive(false);
17843 pan.setActive(true);
17848 showPanelNext : function()
17850 var i = this.indexOfPanel(this.getActivePanel());
17852 if (i >= this.tabs.length - 1 && !this.autoslide) {
17856 if (i >= this.tabs.length - 1 && this.autoslide) {
17860 this.showPanel(this.tabs[i+1]);
17863 showPanelPrev : function()
17865 var i = this.indexOfPanel(this.getActivePanel());
17867 if (i < 1 && !this.autoslide) {
17871 if (i < 1 && this.autoslide) {
17872 i = this.tabs.length;
17875 this.showPanel(this.tabs[i-1]);
17879 addBullet: function()
17881 if(!this.bullets || Roo.isTouch){
17884 var ctr = this.el.select('.carousel-bullets',true).first();
17885 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17886 var bullet = ctr.createChild({
17887 cls : 'bullet bullet-' + i
17888 },ctr.dom.lastChild);
17893 bullet.on('click', (function(e, el, o, ii, t){
17895 e.preventDefault();
17897 this.showPanel(ii);
17899 if(this.autoslide && this.slideFn){
17900 clearInterval(this.slideFn);
17901 this.slideFn = window.setInterval(function() {
17902 _this.showPanelNext();
17906 }).createDelegate(this, [i, bullet], true));
17911 setActiveBullet : function(i)
17917 Roo.each(this.el.select('.bullet', true).elements, function(el){
17918 el.removeClass('selected');
17921 var bullet = this.el.select('.bullet-' + i, true).first();
17927 bullet.addClass('selected');
17938 Roo.apply(Roo.bootstrap.TabGroup, {
17942 * register a Navigation Group
17943 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17945 register : function(navgrp)
17947 this.groups[navgrp.navId] = navgrp;
17951 * fetch a Navigation Group based on the navigation ID
17952 * if one does not exist , it will get created.
17953 * @param {string} the navgroup to add
17954 * @returns {Roo.bootstrap.NavGroup} the navgroup
17956 get: function(navId) {
17957 if (typeof(this.groups[navId]) == 'undefined') {
17958 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17960 return this.groups[navId] ;
17975 * @class Roo.bootstrap.TabPanel
17976 * @extends Roo.bootstrap.Component
17977 * Bootstrap TabPanel class
17978 * @cfg {Boolean} active panel active
17979 * @cfg {String} html panel content
17980 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17981 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17982 * @cfg {String} href click to link..
17986 * Create a new TabPanel
17987 * @param {Object} config The config object
17990 Roo.bootstrap.TabPanel = function(config){
17991 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17995 * Fires when the active status changes
17996 * @param {Roo.bootstrap.TabPanel} this
17997 * @param {Boolean} state the new state
18002 * @event beforedeactivate
18003 * Fires before a tab is de-activated - can be used to do validation on a form.
18004 * @param {Roo.bootstrap.TabPanel} this
18005 * @return {Boolean} false if there is an error
18008 'beforedeactivate': true
18011 this.tabId = this.tabId || Roo.id();
18015 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18023 getAutoCreate : function(){
18026 // item is needed for carousel - not sure if it has any effect otherwise
18027 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18028 html: this.html || ''
18032 cfg.cls += ' active';
18036 cfg.tabId = this.tabId;
18043 initEvents: function()
18045 var p = this.parent();
18047 this.navId = this.navId || p.navId;
18049 if (typeof(this.navId) != 'undefined') {
18050 // not really needed.. but just in case.. parent should be a NavGroup.
18051 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18055 var i = tg.tabs.length - 1;
18057 if(this.active && tg.bullets > 0 && i < tg.bullets){
18058 tg.setActiveBullet(i);
18062 this.el.on('click', this.onClick, this);
18065 this.el.on("touchstart", this.onTouchStart, this);
18066 this.el.on("touchmove", this.onTouchMove, this);
18067 this.el.on("touchend", this.onTouchEnd, this);
18072 onRender : function(ct, position)
18074 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18077 setActive : function(state)
18079 Roo.log("panel - set active " + this.tabId + "=" + state);
18081 this.active = state;
18083 this.el.removeClass('active');
18085 } else if (!this.el.hasClass('active')) {
18086 this.el.addClass('active');
18089 this.fireEvent('changed', this, state);
18092 onClick : function(e)
18094 e.preventDefault();
18096 if(!this.href.length){
18100 window.location.href = this.href;
18109 onTouchStart : function(e)
18111 this.swiping = false;
18113 this.startX = e.browserEvent.touches[0].clientX;
18114 this.startY = e.browserEvent.touches[0].clientY;
18117 onTouchMove : function(e)
18119 this.swiping = true;
18121 this.endX = e.browserEvent.touches[0].clientX;
18122 this.endY = e.browserEvent.touches[0].clientY;
18125 onTouchEnd : function(e)
18132 var tabGroup = this.parent();
18134 if(this.endX > this.startX){ // swiping right
18135 tabGroup.showPanelPrev();
18139 if(this.startX > this.endX){ // swiping left
18140 tabGroup.showPanelNext();
18159 * @class Roo.bootstrap.DateField
18160 * @extends Roo.bootstrap.Input
18161 * Bootstrap DateField class
18162 * @cfg {Number} weekStart default 0
18163 * @cfg {String} viewMode default empty, (months|years)
18164 * @cfg {String} minViewMode default empty, (months|years)
18165 * @cfg {Number} startDate default -Infinity
18166 * @cfg {Number} endDate default Infinity
18167 * @cfg {Boolean} todayHighlight default false
18168 * @cfg {Boolean} todayBtn default false
18169 * @cfg {Boolean} calendarWeeks default false
18170 * @cfg {Object} daysOfWeekDisabled default empty
18171 * @cfg {Boolean} singleMode default false (true | false)
18173 * @cfg {Boolean} keyboardNavigation default true
18174 * @cfg {String} language default en
18177 * Create a new DateField
18178 * @param {Object} config The config object
18181 Roo.bootstrap.DateField = function(config){
18182 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18186 * Fires when this field show.
18187 * @param {Roo.bootstrap.DateField} this
18188 * @param {Mixed} date The date value
18193 * Fires when this field hide.
18194 * @param {Roo.bootstrap.DateField} this
18195 * @param {Mixed} date The date value
18200 * Fires when select a date.
18201 * @param {Roo.bootstrap.DateField} this
18202 * @param {Mixed} date The date value
18206 * @event beforeselect
18207 * Fires when before select a date.
18208 * @param {Roo.bootstrap.DateField} this
18209 * @param {Mixed} date The date value
18211 beforeselect : true
18215 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18218 * @cfg {String} format
18219 * The default date format string which can be overriden for localization support. The format must be
18220 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18224 * @cfg {String} altFormats
18225 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18226 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18228 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18236 todayHighlight : false,
18242 keyboardNavigation: true,
18244 calendarWeeks: false,
18246 startDate: -Infinity,
18250 daysOfWeekDisabled: [],
18254 singleMode : false,
18256 UTCDate: function()
18258 return new Date(Date.UTC.apply(Date, arguments));
18261 UTCToday: function()
18263 var today = new Date();
18264 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18267 getDate: function() {
18268 var d = this.getUTCDate();
18269 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18272 getUTCDate: function() {
18276 setDate: function(d) {
18277 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18280 setUTCDate: function(d) {
18282 this.setValue(this.formatDate(this.date));
18285 onRender: function(ct, position)
18288 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18290 this.language = this.language || 'en';
18291 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18292 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18294 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18295 this.format = this.format || 'm/d/y';
18296 this.isInline = false;
18297 this.isInput = true;
18298 this.component = this.el.select('.add-on', true).first() || false;
18299 this.component = (this.component && this.component.length === 0) ? false : this.component;
18300 this.hasInput = this.component && this.inputEl().length;
18302 if (typeof(this.minViewMode === 'string')) {
18303 switch (this.minViewMode) {
18305 this.minViewMode = 1;
18308 this.minViewMode = 2;
18311 this.minViewMode = 0;
18316 if (typeof(this.viewMode === 'string')) {
18317 switch (this.viewMode) {
18330 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18332 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18334 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18336 this.picker().on('mousedown', this.onMousedown, this);
18337 this.picker().on('click', this.onClick, this);
18339 this.picker().addClass('datepicker-dropdown');
18341 this.startViewMode = this.viewMode;
18343 if(this.singleMode){
18344 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18345 v.setVisibilityMode(Roo.Element.DISPLAY);
18349 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18350 v.setStyle('width', '189px');
18354 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18355 if(!this.calendarWeeks){
18360 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18361 v.attr('colspan', function(i, val){
18362 return parseInt(val) + 1;
18367 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18369 this.setStartDate(this.startDate);
18370 this.setEndDate(this.endDate);
18372 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18379 if(this.isInline) {
18384 picker : function()
18386 return this.pickerEl;
18387 // return this.el.select('.datepicker', true).first();
18390 fillDow: function()
18392 var dowCnt = this.weekStart;
18401 if(this.calendarWeeks){
18409 while (dowCnt < this.weekStart + 7) {
18413 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18417 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18420 fillMonths: function()
18423 var months = this.picker().select('>.datepicker-months td', true).first();
18425 months.dom.innerHTML = '';
18431 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18434 months.createChild(month);
18441 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;
18443 if (this.date < this.startDate) {
18444 this.viewDate = new Date(this.startDate);
18445 } else if (this.date > this.endDate) {
18446 this.viewDate = new Date(this.endDate);
18448 this.viewDate = new Date(this.date);
18456 var d = new Date(this.viewDate),
18457 year = d.getUTCFullYear(),
18458 month = d.getUTCMonth(),
18459 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18460 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18461 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18462 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18463 currentDate = this.date && this.date.valueOf(),
18464 today = this.UTCToday();
18466 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18468 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18470 // this.picker.select('>tfoot th.today').
18471 // .text(dates[this.language].today)
18472 // .toggle(this.todayBtn !== false);
18474 this.updateNavArrows();
18477 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18479 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18481 prevMonth.setUTCDate(day);
18483 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18485 var nextMonth = new Date(prevMonth);
18487 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18489 nextMonth = nextMonth.valueOf();
18491 var fillMonths = false;
18493 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18495 while(prevMonth.valueOf() < nextMonth) {
18498 if (prevMonth.getUTCDay() === this.weekStart) {
18500 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18508 if(this.calendarWeeks){
18509 // ISO 8601: First week contains first thursday.
18510 // ISO also states week starts on Monday, but we can be more abstract here.
18512 // Start of current week: based on weekstart/current date
18513 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18514 // Thursday of this week
18515 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18516 // First Thursday of year, year from thursday
18517 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18518 // Calendar week: ms between thursdays, div ms per day, div 7 days
18519 calWeek = (th - yth) / 864e5 / 7 + 1;
18521 fillMonths.cn.push({
18529 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18531 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18534 if (this.todayHighlight &&
18535 prevMonth.getUTCFullYear() == today.getFullYear() &&
18536 prevMonth.getUTCMonth() == today.getMonth() &&
18537 prevMonth.getUTCDate() == today.getDate()) {
18538 clsName += ' today';
18541 if (currentDate && prevMonth.valueOf() === currentDate) {
18542 clsName += ' active';
18545 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18546 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18547 clsName += ' disabled';
18550 fillMonths.cn.push({
18552 cls: 'day ' + clsName,
18553 html: prevMonth.getDate()
18556 prevMonth.setDate(prevMonth.getDate()+1);
18559 var currentYear = this.date && this.date.getUTCFullYear();
18560 var currentMonth = this.date && this.date.getUTCMonth();
18562 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18564 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18565 v.removeClass('active');
18567 if(currentYear === year && k === currentMonth){
18568 v.addClass('active');
18571 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18572 v.addClass('disabled');
18578 year = parseInt(year/10, 10) * 10;
18580 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18582 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18585 for (var i = -1; i < 11; i++) {
18586 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18588 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18596 showMode: function(dir)
18599 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18602 Roo.each(this.picker().select('>div',true).elements, function(v){
18603 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18606 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18611 if(this.isInline) {
18615 this.picker().removeClass(['bottom', 'top']);
18617 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18619 * place to the top of element!
18623 this.picker().addClass('top');
18624 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18629 this.picker().addClass('bottom');
18631 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18634 parseDate : function(value)
18636 if(!value || value instanceof Date){
18639 var v = Date.parseDate(value, this.format);
18640 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18641 v = Date.parseDate(value, 'Y-m-d');
18643 if(!v && this.altFormats){
18644 if(!this.altFormatsArray){
18645 this.altFormatsArray = this.altFormats.split("|");
18647 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18648 v = Date.parseDate(value, this.altFormatsArray[i]);
18654 formatDate : function(date, fmt)
18656 return (!date || !(date instanceof Date)) ?
18657 date : date.dateFormat(fmt || this.format);
18660 onFocus : function()
18662 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18666 onBlur : function()
18668 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18670 var d = this.inputEl().getValue();
18679 this.picker().show();
18683 this.fireEvent('show', this, this.date);
18688 if(this.isInline) {
18691 this.picker().hide();
18692 this.viewMode = this.startViewMode;
18695 this.fireEvent('hide', this, this.date);
18699 onMousedown: function(e)
18701 e.stopPropagation();
18702 e.preventDefault();
18707 Roo.bootstrap.DateField.superclass.keyup.call(this);
18711 setValue: function(v)
18713 if(this.fireEvent('beforeselect', this, v) !== false){
18714 var d = new Date(this.parseDate(v) ).clearTime();
18716 if(isNaN(d.getTime())){
18717 this.date = this.viewDate = '';
18718 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18722 v = this.formatDate(d);
18724 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18726 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18730 this.fireEvent('select', this, this.date);
18734 getValue: function()
18736 return this.formatDate(this.date);
18739 fireKey: function(e)
18741 if (!this.picker().isVisible()){
18742 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18748 var dateChanged = false,
18750 newDate, newViewDate;
18755 e.preventDefault();
18759 if (!this.keyboardNavigation) {
18762 dir = e.keyCode == 37 ? -1 : 1;
18765 newDate = this.moveYear(this.date, dir);
18766 newViewDate = this.moveYear(this.viewDate, dir);
18767 } else if (e.shiftKey){
18768 newDate = this.moveMonth(this.date, dir);
18769 newViewDate = this.moveMonth(this.viewDate, dir);
18771 newDate = new Date(this.date);
18772 newDate.setUTCDate(this.date.getUTCDate() + dir);
18773 newViewDate = new Date(this.viewDate);
18774 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18776 if (this.dateWithinRange(newDate)){
18777 this.date = newDate;
18778 this.viewDate = newViewDate;
18779 this.setValue(this.formatDate(this.date));
18781 e.preventDefault();
18782 dateChanged = true;
18787 if (!this.keyboardNavigation) {
18790 dir = e.keyCode == 38 ? -1 : 1;
18792 newDate = this.moveYear(this.date, dir);
18793 newViewDate = this.moveYear(this.viewDate, dir);
18794 } else if (e.shiftKey){
18795 newDate = this.moveMonth(this.date, dir);
18796 newViewDate = this.moveMonth(this.viewDate, dir);
18798 newDate = new Date(this.date);
18799 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18800 newViewDate = new Date(this.viewDate);
18801 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18803 if (this.dateWithinRange(newDate)){
18804 this.date = newDate;
18805 this.viewDate = newViewDate;
18806 this.setValue(this.formatDate(this.date));
18808 e.preventDefault();
18809 dateChanged = true;
18813 this.setValue(this.formatDate(this.date));
18815 e.preventDefault();
18818 this.setValue(this.formatDate(this.date));
18832 onClick: function(e)
18834 e.stopPropagation();
18835 e.preventDefault();
18837 var target = e.getTarget();
18839 if(target.nodeName.toLowerCase() === 'i'){
18840 target = Roo.get(target).dom.parentNode;
18843 var nodeName = target.nodeName;
18844 var className = target.className;
18845 var html = target.innerHTML;
18846 //Roo.log(nodeName);
18848 switch(nodeName.toLowerCase()) {
18850 switch(className) {
18856 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18857 switch(this.viewMode){
18859 this.viewDate = this.moveMonth(this.viewDate, dir);
18863 this.viewDate = this.moveYear(this.viewDate, dir);
18869 var date = new Date();
18870 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18872 this.setValue(this.formatDate(this.date));
18879 if (className.indexOf('disabled') < 0) {
18880 this.viewDate.setUTCDate(1);
18881 if (className.indexOf('month') > -1) {
18882 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18884 var year = parseInt(html, 10) || 0;
18885 this.viewDate.setUTCFullYear(year);
18889 if(this.singleMode){
18890 this.setValue(this.formatDate(this.viewDate));
18901 //Roo.log(className);
18902 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18903 var day = parseInt(html, 10) || 1;
18904 var year = this.viewDate.getUTCFullYear(),
18905 month = this.viewDate.getUTCMonth();
18907 if (className.indexOf('old') > -1) {
18914 } else if (className.indexOf('new') > -1) {
18922 //Roo.log([year,month,day]);
18923 this.date = this.UTCDate(year, month, day,0,0,0,0);
18924 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18926 //Roo.log(this.formatDate(this.date));
18927 this.setValue(this.formatDate(this.date));
18934 setStartDate: function(startDate)
18936 this.startDate = startDate || -Infinity;
18937 if (this.startDate !== -Infinity) {
18938 this.startDate = this.parseDate(this.startDate);
18941 this.updateNavArrows();
18944 setEndDate: function(endDate)
18946 this.endDate = endDate || Infinity;
18947 if (this.endDate !== Infinity) {
18948 this.endDate = this.parseDate(this.endDate);
18951 this.updateNavArrows();
18954 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18956 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18957 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18958 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18960 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18961 return parseInt(d, 10);
18964 this.updateNavArrows();
18967 updateNavArrows: function()
18969 if(this.singleMode){
18973 var d = new Date(this.viewDate),
18974 year = d.getUTCFullYear(),
18975 month = d.getUTCMonth();
18977 Roo.each(this.picker().select('.prev', true).elements, function(v){
18979 switch (this.viewMode) {
18982 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18988 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18995 Roo.each(this.picker().select('.next', true).elements, function(v){
18997 switch (this.viewMode) {
19000 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19006 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19014 moveMonth: function(date, dir)
19019 var new_date = new Date(date.valueOf()),
19020 day = new_date.getUTCDate(),
19021 month = new_date.getUTCMonth(),
19022 mag = Math.abs(dir),
19024 dir = dir > 0 ? 1 : -1;
19027 // If going back one month, make sure month is not current month
19028 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19030 return new_date.getUTCMonth() == month;
19032 // If going forward one month, make sure month is as expected
19033 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19035 return new_date.getUTCMonth() != new_month;
19037 new_month = month + dir;
19038 new_date.setUTCMonth(new_month);
19039 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19040 if (new_month < 0 || new_month > 11) {
19041 new_month = (new_month + 12) % 12;
19044 // For magnitudes >1, move one month at a time...
19045 for (var i=0; i<mag; i++) {
19046 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19047 new_date = this.moveMonth(new_date, dir);
19049 // ...then reset the day, keeping it in the new month
19050 new_month = new_date.getUTCMonth();
19051 new_date.setUTCDate(day);
19053 return new_month != new_date.getUTCMonth();
19056 // Common date-resetting loop -- if date is beyond end of month, make it
19059 new_date.setUTCDate(--day);
19060 new_date.setUTCMonth(new_month);
19065 moveYear: function(date, dir)
19067 return this.moveMonth(date, dir*12);
19070 dateWithinRange: function(date)
19072 return date >= this.startDate && date <= this.endDate;
19078 this.picker().remove();
19081 validateValue : function(value)
19083 if(value.length < 1) {
19084 if(this.allowBlank){
19090 if(value.length < this.minLength){
19093 if(value.length > this.maxLength){
19097 var vt = Roo.form.VTypes;
19098 if(!vt[this.vtype](value, this)){
19102 if(typeof this.validator == "function"){
19103 var msg = this.validator(value);
19109 if(this.regex && !this.regex.test(value)){
19113 if(typeof(this.parseDate(value)) == 'undefined'){
19117 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19121 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19131 Roo.apply(Roo.bootstrap.DateField, {
19142 html: '<i class="fa fa-arrow-left"/>'
19152 html: '<i class="fa fa-arrow-right"/>'
19194 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19195 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19196 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19197 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19198 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19211 navFnc: 'FullYear',
19216 navFnc: 'FullYear',
19221 Roo.apply(Roo.bootstrap.DateField, {
19225 cls: 'datepicker dropdown-menu roo-dynamic',
19229 cls: 'datepicker-days',
19233 cls: 'table-condensed',
19235 Roo.bootstrap.DateField.head,
19239 Roo.bootstrap.DateField.footer
19246 cls: 'datepicker-months',
19250 cls: 'table-condensed',
19252 Roo.bootstrap.DateField.head,
19253 Roo.bootstrap.DateField.content,
19254 Roo.bootstrap.DateField.footer
19261 cls: 'datepicker-years',
19265 cls: 'table-condensed',
19267 Roo.bootstrap.DateField.head,
19268 Roo.bootstrap.DateField.content,
19269 Roo.bootstrap.DateField.footer
19288 * @class Roo.bootstrap.TimeField
19289 * @extends Roo.bootstrap.Input
19290 * Bootstrap DateField class
19294 * Create a new TimeField
19295 * @param {Object} config The config object
19298 Roo.bootstrap.TimeField = function(config){
19299 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19303 * Fires when this field show.
19304 * @param {Roo.bootstrap.DateField} thisthis
19305 * @param {Mixed} date The date value
19310 * Fires when this field hide.
19311 * @param {Roo.bootstrap.DateField} this
19312 * @param {Mixed} date The date value
19317 * Fires when select a date.
19318 * @param {Roo.bootstrap.DateField} this
19319 * @param {Mixed} date The date value
19325 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19328 * @cfg {String} format
19329 * The default time format string which can be overriden for localization support. The format must be
19330 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19334 onRender: function(ct, position)
19337 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19339 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19341 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19343 this.pop = this.picker().select('>.datepicker-time',true).first();
19344 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19346 this.picker().on('mousedown', this.onMousedown, this);
19347 this.picker().on('click', this.onClick, this);
19349 this.picker().addClass('datepicker-dropdown');
19354 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19355 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19356 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19357 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19358 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19359 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19363 fireKey: function(e){
19364 if (!this.picker().isVisible()){
19365 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19371 e.preventDefault();
19379 this.onTogglePeriod();
19382 this.onIncrementMinutes();
19385 this.onDecrementMinutes();
19394 onClick: function(e) {
19395 e.stopPropagation();
19396 e.preventDefault();
19399 picker : function()
19401 return this.el.select('.datepicker', true).first();
19404 fillTime: function()
19406 var time = this.pop.select('tbody', true).first();
19408 time.dom.innerHTML = '';
19423 cls: 'hours-up glyphicon glyphicon-chevron-up'
19443 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19464 cls: 'timepicker-hour',
19479 cls: 'timepicker-minute',
19494 cls: 'btn btn-primary period',
19516 cls: 'hours-down glyphicon glyphicon-chevron-down'
19536 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19554 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19561 var hours = this.time.getHours();
19562 var minutes = this.time.getMinutes();
19575 hours = hours - 12;
19579 hours = '0' + hours;
19583 minutes = '0' + minutes;
19586 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19587 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19588 this.pop.select('button', true).first().dom.innerHTML = period;
19594 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19596 var cls = ['bottom'];
19598 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19605 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19610 this.picker().addClass(cls.join('-'));
19614 Roo.each(cls, function(c){
19616 _this.picker().setTop(_this.inputEl().getHeight());
19620 _this.picker().setTop(0 - _this.picker().getHeight());
19625 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19629 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19636 onFocus : function()
19638 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19642 onBlur : function()
19644 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19650 this.picker().show();
19655 this.fireEvent('show', this, this.date);
19660 this.picker().hide();
19663 this.fireEvent('hide', this, this.date);
19666 setTime : function()
19669 this.setValue(this.time.format(this.format));
19671 this.fireEvent('select', this, this.date);
19676 onMousedown: function(e){
19677 e.stopPropagation();
19678 e.preventDefault();
19681 onIncrementHours: function()
19683 Roo.log('onIncrementHours');
19684 this.time = this.time.add(Date.HOUR, 1);
19689 onDecrementHours: function()
19691 Roo.log('onDecrementHours');
19692 this.time = this.time.add(Date.HOUR, -1);
19696 onIncrementMinutes: function()
19698 Roo.log('onIncrementMinutes');
19699 this.time = this.time.add(Date.MINUTE, 1);
19703 onDecrementMinutes: function()
19705 Roo.log('onDecrementMinutes');
19706 this.time = this.time.add(Date.MINUTE, -1);
19710 onTogglePeriod: function()
19712 Roo.log('onTogglePeriod');
19713 this.time = this.time.add(Date.HOUR, 12);
19720 Roo.apply(Roo.bootstrap.TimeField, {
19750 cls: 'btn btn-info ok',
19762 Roo.apply(Roo.bootstrap.TimeField, {
19766 cls: 'datepicker dropdown-menu',
19770 cls: 'datepicker-time',
19774 cls: 'table-condensed',
19776 Roo.bootstrap.TimeField.content,
19777 Roo.bootstrap.TimeField.footer
19796 * @class Roo.bootstrap.MonthField
19797 * @extends Roo.bootstrap.Input
19798 * Bootstrap MonthField class
19800 * @cfg {String} language default en
19803 * Create a new MonthField
19804 * @param {Object} config The config object
19807 Roo.bootstrap.MonthField = function(config){
19808 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19813 * Fires when this field show.
19814 * @param {Roo.bootstrap.MonthField} this
19815 * @param {Mixed} date The date value
19820 * Fires when this field hide.
19821 * @param {Roo.bootstrap.MonthField} this
19822 * @param {Mixed} date The date value
19827 * Fires when select a date.
19828 * @param {Roo.bootstrap.MonthField} this
19829 * @param {String} oldvalue The old value
19830 * @param {String} newvalue The new value
19836 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19838 onRender: function(ct, position)
19841 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19843 this.language = this.language || 'en';
19844 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19845 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19847 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19848 this.isInline = false;
19849 this.isInput = true;
19850 this.component = this.el.select('.add-on', true).first() || false;
19851 this.component = (this.component && this.component.length === 0) ? false : this.component;
19852 this.hasInput = this.component && this.inputEL().length;
19854 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19856 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19858 this.picker().on('mousedown', this.onMousedown, this);
19859 this.picker().on('click', this.onClick, this);
19861 this.picker().addClass('datepicker-dropdown');
19863 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19864 v.setStyle('width', '189px');
19871 if(this.isInline) {
19877 setValue: function(v, suppressEvent)
19879 var o = this.getValue();
19881 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19885 if(suppressEvent !== true){
19886 this.fireEvent('select', this, o, v);
19891 getValue: function()
19896 onClick: function(e)
19898 e.stopPropagation();
19899 e.preventDefault();
19901 var target = e.getTarget();
19903 if(target.nodeName.toLowerCase() === 'i'){
19904 target = Roo.get(target).dom.parentNode;
19907 var nodeName = target.nodeName;
19908 var className = target.className;
19909 var html = target.innerHTML;
19911 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19915 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19917 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19923 picker : function()
19925 return this.pickerEl;
19928 fillMonths: function()
19931 var months = this.picker().select('>.datepicker-months td', true).first();
19933 months.dom.innerHTML = '';
19939 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19942 months.createChild(month);
19951 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19952 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19955 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19956 e.removeClass('active');
19958 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19959 e.addClass('active');
19966 if(this.isInline) {
19970 this.picker().removeClass(['bottom', 'top']);
19972 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19974 * place to the top of element!
19978 this.picker().addClass('top');
19979 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19984 this.picker().addClass('bottom');
19986 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19989 onFocus : function()
19991 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19995 onBlur : function()
19997 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19999 var d = this.inputEl().getValue();
20008 this.picker().show();
20009 this.picker().select('>.datepicker-months', true).first().show();
20013 this.fireEvent('show', this, this.date);
20018 if(this.isInline) {
20021 this.picker().hide();
20022 this.fireEvent('hide', this, this.date);
20026 onMousedown: function(e)
20028 e.stopPropagation();
20029 e.preventDefault();
20034 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20038 fireKey: function(e)
20040 if (!this.picker().isVisible()){
20041 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20052 e.preventDefault();
20056 dir = e.keyCode == 37 ? -1 : 1;
20058 this.vIndex = this.vIndex + dir;
20060 if(this.vIndex < 0){
20064 if(this.vIndex > 11){
20068 if(isNaN(this.vIndex)){
20072 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20078 dir = e.keyCode == 38 ? -1 : 1;
20080 this.vIndex = this.vIndex + dir * 4;
20082 if(this.vIndex < 0){
20086 if(this.vIndex > 11){
20090 if(isNaN(this.vIndex)){
20094 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20099 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20100 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20104 e.preventDefault();
20107 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20108 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20124 this.picker().remove();
20129 Roo.apply(Roo.bootstrap.MonthField, {
20148 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20149 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20154 Roo.apply(Roo.bootstrap.MonthField, {
20158 cls: 'datepicker dropdown-menu roo-dynamic',
20162 cls: 'datepicker-months',
20166 cls: 'table-condensed',
20168 Roo.bootstrap.DateField.content
20188 * @class Roo.bootstrap.CheckBox
20189 * @extends Roo.bootstrap.Input
20190 * Bootstrap CheckBox class
20192 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20193 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20194 * @cfg {String} boxLabel The text that appears beside the checkbox
20195 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20196 * @cfg {Boolean} checked initnal the element
20197 * @cfg {Boolean} inline inline the element (default false)
20198 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20199 * @cfg {String} tooltip label tooltip
20202 * Create a new CheckBox
20203 * @param {Object} config The config object
20206 Roo.bootstrap.CheckBox = function(config){
20207 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20212 * Fires when the element is checked or unchecked.
20213 * @param {Roo.bootstrap.CheckBox} this This input
20214 * @param {Boolean} checked The new checked value
20219 * Fires when the element is click.
20220 * @param {Roo.bootstrap.CheckBox} this This input
20227 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20229 inputType: 'checkbox',
20238 getAutoCreate : function()
20240 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20246 cfg.cls = 'form-group ' + this.inputType; //input-group
20249 cfg.cls += ' ' + this.inputType + '-inline';
20255 type : this.inputType,
20256 value : this.inputValue,
20257 cls : 'roo-' + this.inputType, //'form-box',
20258 placeholder : this.placeholder || ''
20262 if(this.inputType != 'radio'){
20266 cls : 'roo-hidden-value',
20267 value : this.checked ? this.inputValue : this.valueOff
20272 if (this.weight) { // Validity check?
20273 cfg.cls += " " + this.inputType + "-" + this.weight;
20276 if (this.disabled) {
20277 input.disabled=true;
20281 input.checked = this.checked;
20286 input.name = this.name;
20288 if(this.inputType != 'radio'){
20289 hidden.name = this.name;
20290 input.name = '_hidden_' + this.name;
20295 input.cls += ' input-' + this.size;
20300 ['xs','sm','md','lg'].map(function(size){
20301 if (settings[size]) {
20302 cfg.cls += ' col-' + size + '-' + settings[size];
20306 var inputblock = input;
20308 if (this.before || this.after) {
20311 cls : 'input-group',
20316 inputblock.cn.push({
20318 cls : 'input-group-addon',
20323 inputblock.cn.push(input);
20325 if(this.inputType != 'radio'){
20326 inputblock.cn.push(hidden);
20330 inputblock.cn.push({
20332 cls : 'input-group-addon',
20339 if (align ==='left' && this.fieldLabel.length) {
20340 // Roo.log("left and has label");
20345 cls : 'control-label',
20346 html : this.fieldLabel
20356 if(this.labelWidth > 12){
20357 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20360 if(this.labelWidth < 13 && this.labelmd == 0){
20361 this.labelmd = this.labelWidth;
20364 if(this.labellg > 0){
20365 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20366 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20369 if(this.labelmd > 0){
20370 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20371 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20374 if(this.labelsm > 0){
20375 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20376 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20379 if(this.labelxs > 0){
20380 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20381 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20384 } else if ( this.fieldLabel.length) {
20385 // Roo.log(" label");
20389 tag: this.boxLabel ? 'span' : 'label',
20391 cls: 'control-label box-input-label',
20392 //cls : 'input-group-addon',
20393 html : this.fieldLabel
20402 // Roo.log(" no label && no align");
20403 cfg.cn = [ inputblock ] ;
20409 var boxLabelCfg = {
20411 //'for': id, // box label is handled by onclick - so no for...
20413 html: this.boxLabel
20417 boxLabelCfg.tooltip = this.tooltip;
20420 cfg.cn.push(boxLabelCfg);
20423 if(this.inputType != 'radio'){
20424 cfg.cn.push(hidden);
20432 * return the real input element.
20434 inputEl: function ()
20436 return this.el.select('input.roo-' + this.inputType,true).first();
20438 hiddenEl: function ()
20440 return this.el.select('input.roo-hidden-value',true).first();
20443 labelEl: function()
20445 return this.el.select('label.control-label',true).first();
20447 /* depricated... */
20451 return this.labelEl();
20454 boxLabelEl: function()
20456 return this.el.select('label.box-label',true).first();
20459 initEvents : function()
20461 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20463 this.inputEl().on('click', this.onClick, this);
20465 if (this.boxLabel) {
20466 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20469 this.startValue = this.getValue();
20472 Roo.bootstrap.CheckBox.register(this);
20476 onClick : function(e)
20478 if(this.fireEvent('click', this, e) !== false){
20479 this.setChecked(!this.checked);
20484 setChecked : function(state,suppressEvent)
20486 this.startValue = this.getValue();
20488 if(this.inputType == 'radio'){
20490 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20491 e.dom.checked = false;
20494 this.inputEl().dom.checked = true;
20496 this.inputEl().dom.value = this.inputValue;
20498 if(suppressEvent !== true){
20499 this.fireEvent('check', this, true);
20507 this.checked = state;
20509 this.inputEl().dom.checked = state;
20512 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20514 if(suppressEvent !== true){
20515 this.fireEvent('check', this, state);
20521 getValue : function()
20523 if(this.inputType == 'radio'){
20524 return this.getGroupValue();
20527 return this.hiddenEl().dom.value;
20531 getGroupValue : function()
20533 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20537 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20540 setValue : function(v,suppressEvent)
20542 if(this.inputType == 'radio'){
20543 this.setGroupValue(v, suppressEvent);
20547 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20552 setGroupValue : function(v, suppressEvent)
20554 this.startValue = this.getValue();
20556 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20557 e.dom.checked = false;
20559 if(e.dom.value == v){
20560 e.dom.checked = true;
20564 if(suppressEvent !== true){
20565 this.fireEvent('check', this, true);
20573 validate : function()
20577 (this.inputType == 'radio' && this.validateRadio()) ||
20578 (this.inputType == 'checkbox' && this.validateCheckbox())
20584 this.markInvalid();
20588 validateRadio : function()
20590 if(this.allowBlank){
20596 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20597 if(!e.dom.checked){
20609 validateCheckbox : function()
20612 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20613 //return (this.getValue() == this.inputValue) ? true : false;
20616 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20624 for(var i in group){
20625 if(group[i].el.isVisible(true)){
20633 for(var i in group){
20638 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20645 * Mark this field as valid
20647 markValid : function()
20651 this.fireEvent('valid', this);
20653 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20656 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20663 if(this.inputType == 'radio'){
20664 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20665 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20666 e.findParent('.form-group', false, true).addClass(_this.validClass);
20673 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20674 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20678 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20684 for(var i in group){
20685 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20686 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20691 * Mark this field as invalid
20692 * @param {String} msg The validation message
20694 markInvalid : function(msg)
20696 if(this.allowBlank){
20702 this.fireEvent('invalid', this, msg);
20704 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20707 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20711 label.markInvalid();
20714 if(this.inputType == 'radio'){
20715 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20716 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20717 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20724 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20725 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20729 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20735 for(var i in group){
20736 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20737 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20742 clearInvalid : function()
20744 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20746 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20748 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20750 if (label && label.iconEl) {
20751 label.iconEl.removeClass(label.validClass);
20752 label.iconEl.removeClass(label.invalidClass);
20756 disable : function()
20758 if(this.inputType != 'radio'){
20759 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20766 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20767 _this.getActionEl().addClass(this.disabledClass);
20768 e.dom.disabled = true;
20772 this.disabled = true;
20773 this.fireEvent("disable", this);
20777 enable : function()
20779 if(this.inputType != 'radio'){
20780 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20787 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20788 _this.getActionEl().removeClass(this.disabledClass);
20789 e.dom.disabled = false;
20793 this.disabled = false;
20794 this.fireEvent("enable", this);
20798 setBoxLabel : function(v)
20803 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20809 Roo.apply(Roo.bootstrap.CheckBox, {
20814 * register a CheckBox Group
20815 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20817 register : function(checkbox)
20819 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20820 this.groups[checkbox.groupId] = {};
20823 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20827 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20831 * fetch a CheckBox Group based on the group ID
20832 * @param {string} the group ID
20833 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20835 get: function(groupId) {
20836 if (typeof(this.groups[groupId]) == 'undefined') {
20840 return this.groups[groupId] ;
20853 * @class Roo.bootstrap.Radio
20854 * @extends Roo.bootstrap.Component
20855 * Bootstrap Radio class
20856 * @cfg {String} boxLabel - the label associated
20857 * @cfg {String} value - the value of radio
20860 * Create a new Radio
20861 * @param {Object} config The config object
20863 Roo.bootstrap.Radio = function(config){
20864 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20868 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20874 getAutoCreate : function()
20878 cls : 'form-group radio',
20883 html : this.boxLabel
20891 initEvents : function()
20893 this.parent().register(this);
20895 this.el.on('click', this.onClick, this);
20899 onClick : function()
20901 this.setChecked(true);
20904 setChecked : function(state, suppressEvent)
20906 this.parent().setValue(this.value, suppressEvent);
20910 setBoxLabel : function(v)
20915 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20930 * @class Roo.bootstrap.SecurePass
20931 * @extends Roo.bootstrap.Input
20932 * Bootstrap SecurePass class
20936 * Create a new SecurePass
20937 * @param {Object} config The config object
20940 Roo.bootstrap.SecurePass = function (config) {
20941 // these go here, so the translation tool can replace them..
20943 PwdEmpty: "Please type a password, and then retype it to confirm.",
20944 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20945 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20946 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20947 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20948 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20949 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20950 TooWeak: "Your password is Too Weak."
20952 this.meterLabel = "Password strength:";
20953 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20954 this.meterClass = [
20955 "roo-password-meter-tooweak",
20956 "roo-password-meter-weak",
20957 "roo-password-meter-medium",
20958 "roo-password-meter-strong",
20959 "roo-password-meter-grey"
20964 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20967 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20969 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20971 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20972 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20973 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20974 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20975 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20976 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20977 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20987 * @cfg {String/Object} Label for the strength meter (defaults to
20988 * 'Password strength:')
20993 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20994 * ['Weak', 'Medium', 'Strong'])
20997 pwdStrengths: false,
21010 initEvents: function ()
21012 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21014 if (this.el.is('input[type=password]') && Roo.isSafari) {
21015 this.el.on('keydown', this.SafariOnKeyDown, this);
21018 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21021 onRender: function (ct, position)
21023 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21024 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21025 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21027 this.trigger.createChild({
21032 cls: 'roo-password-meter-grey col-xs-12',
21035 //width: this.meterWidth + 'px'
21039 cls: 'roo-password-meter-text'
21045 if (this.hideTrigger) {
21046 this.trigger.setDisplayed(false);
21048 this.setSize(this.width || '', this.height || '');
21051 onDestroy: function ()
21053 if (this.trigger) {
21054 this.trigger.removeAllListeners();
21055 this.trigger.remove();
21058 this.wrap.remove();
21060 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21063 checkStrength: function ()
21065 var pwd = this.inputEl().getValue();
21066 if (pwd == this._lastPwd) {
21071 if (this.ClientSideStrongPassword(pwd)) {
21073 } else if (this.ClientSideMediumPassword(pwd)) {
21075 } else if (this.ClientSideWeakPassword(pwd)) {
21081 Roo.log('strength1: ' + strength);
21083 //var pm = this.trigger.child('div/div/div').dom;
21084 var pm = this.trigger.child('div/div');
21085 pm.removeClass(this.meterClass);
21086 pm.addClass(this.meterClass[strength]);
21089 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21091 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21093 this._lastPwd = pwd;
21097 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21099 this._lastPwd = '';
21101 var pm = this.trigger.child('div/div');
21102 pm.removeClass(this.meterClass);
21103 pm.addClass('roo-password-meter-grey');
21106 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21109 this.inputEl().dom.type='password';
21112 validateValue: function (value)
21115 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21118 if (value.length == 0) {
21119 if (this.allowBlank) {
21120 this.clearInvalid();
21124 this.markInvalid(this.errors.PwdEmpty);
21125 this.errorMsg = this.errors.PwdEmpty;
21133 if ('[\x21-\x7e]*'.match(value)) {
21134 this.markInvalid(this.errors.PwdBadChar);
21135 this.errorMsg = this.errors.PwdBadChar;
21138 if (value.length < 6) {
21139 this.markInvalid(this.errors.PwdShort);
21140 this.errorMsg = this.errors.PwdShort;
21143 if (value.length > 16) {
21144 this.markInvalid(this.errors.PwdLong);
21145 this.errorMsg = this.errors.PwdLong;
21149 if (this.ClientSideStrongPassword(value)) {
21151 } else if (this.ClientSideMediumPassword(value)) {
21153 } else if (this.ClientSideWeakPassword(value)) {
21160 if (strength < 2) {
21161 //this.markInvalid(this.errors.TooWeak);
21162 this.errorMsg = this.errors.TooWeak;
21167 console.log('strength2: ' + strength);
21169 //var pm = this.trigger.child('div/div/div').dom;
21171 var pm = this.trigger.child('div/div');
21172 pm.removeClass(this.meterClass);
21173 pm.addClass(this.meterClass[strength]);
21175 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21177 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21179 this.errorMsg = '';
21183 CharacterSetChecks: function (type)
21186 this.fResult = false;
21189 isctype: function (character, type)
21192 case this.kCapitalLetter:
21193 if (character >= 'A' && character <= 'Z') {
21198 case this.kSmallLetter:
21199 if (character >= 'a' && character <= 'z') {
21205 if (character >= '0' && character <= '9') {
21210 case this.kPunctuation:
21211 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21222 IsLongEnough: function (pwd, size)
21224 return !(pwd == null || isNaN(size) || pwd.length < size);
21227 SpansEnoughCharacterSets: function (word, nb)
21229 if (!this.IsLongEnough(word, nb))
21234 var characterSetChecks = new Array(
21235 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21236 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21239 for (var index = 0; index < word.length; ++index) {
21240 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21241 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21242 characterSetChecks[nCharSet].fResult = true;
21249 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21250 if (characterSetChecks[nCharSet].fResult) {
21255 if (nCharSets < nb) {
21261 ClientSideStrongPassword: function (pwd)
21263 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21266 ClientSideMediumPassword: function (pwd)
21268 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21271 ClientSideWeakPassword: function (pwd)
21273 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21276 })//<script type="text/javascript">
21279 * Based Ext JS Library 1.1.1
21280 * Copyright(c) 2006-2007, Ext JS, LLC.
21286 * @class Roo.HtmlEditorCore
21287 * @extends Roo.Component
21288 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21290 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21293 Roo.HtmlEditorCore = function(config){
21296 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21301 * @event initialize
21302 * Fires when the editor is fully initialized (including the iframe)
21303 * @param {Roo.HtmlEditorCore} this
21308 * Fires when the editor is first receives the focus. Any insertion must wait
21309 * until after this event.
21310 * @param {Roo.HtmlEditorCore} this
21314 * @event beforesync
21315 * Fires before the textarea is updated with content from the editor iframe. Return false
21316 * to cancel the sync.
21317 * @param {Roo.HtmlEditorCore} this
21318 * @param {String} html
21322 * @event beforepush
21323 * Fires before the iframe editor is updated with content from the textarea. Return false
21324 * to cancel the push.
21325 * @param {Roo.HtmlEditorCore} this
21326 * @param {String} html
21331 * Fires when the textarea is updated with content from the editor iframe.
21332 * @param {Roo.HtmlEditorCore} this
21333 * @param {String} html
21338 * Fires when the iframe editor is updated with content from the textarea.
21339 * @param {Roo.HtmlEditorCore} this
21340 * @param {String} html
21345 * @event editorevent
21346 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21347 * @param {Roo.HtmlEditorCore} this
21353 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21355 // defaults : white / black...
21356 this.applyBlacklists();
21363 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21367 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21373 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21378 * @cfg {Number} height (in pixels)
21382 * @cfg {Number} width (in pixels)
21387 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21390 stylesheets: false,
21395 // private properties
21396 validationEvent : false,
21398 initialized : false,
21400 sourceEditMode : false,
21401 onFocus : Roo.emptyFn,
21403 hideMode:'offsets',
21407 // blacklist + whitelisted elements..
21414 * Protected method that will not generally be called directly. It
21415 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21416 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21418 getDocMarkup : function(){
21422 // inherit styels from page...??
21423 if (this.stylesheets === false) {
21425 Roo.get(document.head).select('style').each(function(node) {
21426 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21429 Roo.get(document.head).select('link').each(function(node) {
21430 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21433 } else if (!this.stylesheets.length) {
21435 st = '<style type="text/css">' +
21436 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21439 st = '<style type="text/css">' +
21444 st += '<style type="text/css">' +
21445 'IMG { cursor: pointer } ' +
21448 var cls = 'roo-htmleditor-body';
21450 if(this.bodyCls.length){
21451 cls += ' ' + this.bodyCls;
21454 return '<html><head>' + st +
21455 //<style type="text/css">' +
21456 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21458 ' </head><body class="' + cls + '"></body></html>';
21462 onRender : function(ct, position)
21465 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21466 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21469 this.el.dom.style.border = '0 none';
21470 this.el.dom.setAttribute('tabIndex', -1);
21471 this.el.addClass('x-hidden hide');
21475 if(Roo.isIE){ // fix IE 1px bogus margin
21476 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21480 this.frameId = Roo.id();
21484 var iframe = this.owner.wrap.createChild({
21486 cls: 'form-control', // bootstrap..
21488 name: this.frameId,
21489 frameBorder : 'no',
21490 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21495 this.iframe = iframe.dom;
21497 this.assignDocWin();
21499 this.doc.designMode = 'on';
21502 this.doc.write(this.getDocMarkup());
21506 var task = { // must defer to wait for browser to be ready
21508 //console.log("run task?" + this.doc.readyState);
21509 this.assignDocWin();
21510 if(this.doc.body || this.doc.readyState == 'complete'){
21512 this.doc.designMode="on";
21516 Roo.TaskMgr.stop(task);
21517 this.initEditor.defer(10, this);
21524 Roo.TaskMgr.start(task);
21529 onResize : function(w, h)
21531 Roo.log('resize: ' +w + ',' + h );
21532 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21536 if(typeof w == 'number'){
21538 this.iframe.style.width = w + 'px';
21540 if(typeof h == 'number'){
21542 this.iframe.style.height = h + 'px';
21544 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21551 * Toggles the editor between standard and source edit mode.
21552 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21554 toggleSourceEdit : function(sourceEditMode){
21556 this.sourceEditMode = sourceEditMode === true;
21558 if(this.sourceEditMode){
21560 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21563 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21564 //this.iframe.className = '';
21567 //this.setSize(this.owner.wrap.getSize());
21568 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21575 * Protected method that will not generally be called directly. If you need/want
21576 * custom HTML cleanup, this is the method you should override.
21577 * @param {String} html The HTML to be cleaned
21578 * return {String} The cleaned HTML
21580 cleanHtml : function(html){
21581 html = String(html);
21582 if(html.length > 5){
21583 if(Roo.isSafari){ // strip safari nonsense
21584 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21587 if(html == ' '){
21594 * HTML Editor -> Textarea
21595 * Protected method that will not generally be called directly. Syncs the contents
21596 * of the editor iframe with the textarea.
21598 syncValue : function(){
21599 if(this.initialized){
21600 var bd = (this.doc.body || this.doc.documentElement);
21601 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21602 var html = bd.innerHTML;
21604 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21605 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21607 html = '<div style="'+m[0]+'">' + html + '</div>';
21610 html = this.cleanHtml(html);
21611 // fix up the special chars.. normaly like back quotes in word...
21612 // however we do not want to do this with chinese..
21613 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21614 var cc = b.charCodeAt();
21616 (cc >= 0x4E00 && cc < 0xA000 ) ||
21617 (cc >= 0x3400 && cc < 0x4E00 ) ||
21618 (cc >= 0xf900 && cc < 0xfb00 )
21624 if(this.owner.fireEvent('beforesync', this, html) !== false){
21625 this.el.dom.value = html;
21626 this.owner.fireEvent('sync', this, html);
21632 * Protected method that will not generally be called directly. Pushes the value of the textarea
21633 * into the iframe editor.
21635 pushValue : function(){
21636 if(this.initialized){
21637 var v = this.el.dom.value.trim();
21639 // if(v.length < 1){
21643 if(this.owner.fireEvent('beforepush', this, v) !== false){
21644 var d = (this.doc.body || this.doc.documentElement);
21646 this.cleanUpPaste();
21647 this.el.dom.value = d.innerHTML;
21648 this.owner.fireEvent('push', this, v);
21654 deferFocus : function(){
21655 this.focus.defer(10, this);
21659 focus : function(){
21660 if(this.win && !this.sourceEditMode){
21667 assignDocWin: function()
21669 var iframe = this.iframe;
21672 this.doc = iframe.contentWindow.document;
21673 this.win = iframe.contentWindow;
21675 // if (!Roo.get(this.frameId)) {
21678 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21679 // this.win = Roo.get(this.frameId).dom.contentWindow;
21681 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21685 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21686 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21691 initEditor : function(){
21692 //console.log("INIT EDITOR");
21693 this.assignDocWin();
21697 this.doc.designMode="on";
21699 this.doc.write(this.getDocMarkup());
21702 var dbody = (this.doc.body || this.doc.documentElement);
21703 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21704 // this copies styles from the containing element into thsi one..
21705 // not sure why we need all of this..
21706 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21708 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21709 //ss['background-attachment'] = 'fixed'; // w3c
21710 dbody.bgProperties = 'fixed'; // ie
21711 //Roo.DomHelper.applyStyles(dbody, ss);
21712 Roo.EventManager.on(this.doc, {
21713 //'mousedown': this.onEditorEvent,
21714 'mouseup': this.onEditorEvent,
21715 'dblclick': this.onEditorEvent,
21716 'click': this.onEditorEvent,
21717 'keyup': this.onEditorEvent,
21722 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21724 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21725 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21727 this.initialized = true;
21729 this.owner.fireEvent('initialize', this);
21734 onDestroy : function(){
21740 //for (var i =0; i < this.toolbars.length;i++) {
21741 // // fixme - ask toolbars for heights?
21742 // this.toolbars[i].onDestroy();
21745 //this.wrap.dom.innerHTML = '';
21746 //this.wrap.remove();
21751 onFirstFocus : function(){
21753 this.assignDocWin();
21756 this.activated = true;
21759 if(Roo.isGecko){ // prevent silly gecko errors
21761 var s = this.win.getSelection();
21762 if(!s.focusNode || s.focusNode.nodeType != 3){
21763 var r = s.getRangeAt(0);
21764 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21769 this.execCmd('useCSS', true);
21770 this.execCmd('styleWithCSS', false);
21773 this.owner.fireEvent('activate', this);
21777 adjustFont: function(btn){
21778 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21779 //if(Roo.isSafari){ // safari
21782 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21783 if(Roo.isSafari){ // safari
21784 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21785 v = (v < 10) ? 10 : v;
21786 v = (v > 48) ? 48 : v;
21787 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21792 v = Math.max(1, v+adjust);
21794 this.execCmd('FontSize', v );
21797 onEditorEvent : function(e)
21799 this.owner.fireEvent('editorevent', this, e);
21800 // this.updateToolbar();
21801 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21804 insertTag : function(tg)
21806 // could be a bit smarter... -> wrap the current selected tRoo..
21807 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21809 range = this.createRange(this.getSelection());
21810 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21811 wrappingNode.appendChild(range.extractContents());
21812 range.insertNode(wrappingNode);
21819 this.execCmd("formatblock", tg);
21823 insertText : function(txt)
21827 var range = this.createRange();
21828 range.deleteContents();
21829 //alert(Sender.getAttribute('label'));
21831 range.insertNode(this.doc.createTextNode(txt));
21837 * Executes a Midas editor command on the editor document and performs necessary focus and
21838 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21839 * @param {String} cmd The Midas command
21840 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21842 relayCmd : function(cmd, value){
21844 this.execCmd(cmd, value);
21845 this.owner.fireEvent('editorevent', this);
21846 //this.updateToolbar();
21847 this.owner.deferFocus();
21851 * Executes a Midas editor command directly on the editor document.
21852 * For visual commands, you should use {@link #relayCmd} instead.
21853 * <b>This should only be called after the editor is initialized.</b>
21854 * @param {String} cmd The Midas command
21855 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21857 execCmd : function(cmd, value){
21858 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21865 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21867 * @param {String} text | dom node..
21869 insertAtCursor : function(text)
21872 if(!this.activated){
21878 var r = this.doc.selection.createRange();
21889 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21893 // from jquery ui (MIT licenced)
21895 var win = this.win;
21897 if (win.getSelection && win.getSelection().getRangeAt) {
21898 range = win.getSelection().getRangeAt(0);
21899 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21900 range.insertNode(node);
21901 } else if (win.document.selection && win.document.selection.createRange) {
21902 // no firefox support
21903 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21904 win.document.selection.createRange().pasteHTML(txt);
21906 // no firefox support
21907 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21908 this.execCmd('InsertHTML', txt);
21917 mozKeyPress : function(e){
21919 var c = e.getCharCode(), cmd;
21922 c = String.fromCharCode(c).toLowerCase();
21936 this.cleanUpPaste.defer(100, this);
21944 e.preventDefault();
21952 fixKeys : function(){ // load time branching for fastest keydown performance
21954 return function(e){
21955 var k = e.getKey(), r;
21958 r = this.doc.selection.createRange();
21961 r.pasteHTML('    ');
21968 r = this.doc.selection.createRange();
21970 var target = r.parentElement();
21971 if(!target || target.tagName.toLowerCase() != 'li'){
21973 r.pasteHTML('<br />');
21979 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21980 this.cleanUpPaste.defer(100, this);
21986 }else if(Roo.isOpera){
21987 return function(e){
21988 var k = e.getKey();
21992 this.execCmd('InsertHTML','    ');
21995 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21996 this.cleanUpPaste.defer(100, this);
22001 }else if(Roo.isSafari){
22002 return function(e){
22003 var k = e.getKey();
22007 this.execCmd('InsertText','\t');
22011 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22012 this.cleanUpPaste.defer(100, this);
22020 getAllAncestors: function()
22022 var p = this.getSelectedNode();
22025 a.push(p); // push blank onto stack..
22026 p = this.getParentElement();
22030 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22034 a.push(this.doc.body);
22038 lastSelNode : false,
22041 getSelection : function()
22043 this.assignDocWin();
22044 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22047 getSelectedNode: function()
22049 // this may only work on Gecko!!!
22051 // should we cache this!!!!
22056 var range = this.createRange(this.getSelection()).cloneRange();
22059 var parent = range.parentElement();
22061 var testRange = range.duplicate();
22062 testRange.moveToElementText(parent);
22063 if (testRange.inRange(range)) {
22066 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22069 parent = parent.parentElement;
22074 // is ancestor a text element.
22075 var ac = range.commonAncestorContainer;
22076 if (ac.nodeType == 3) {
22077 ac = ac.parentNode;
22080 var ar = ac.childNodes;
22083 var other_nodes = [];
22084 var has_other_nodes = false;
22085 for (var i=0;i<ar.length;i++) {
22086 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22089 // fullly contained node.
22091 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22096 // probably selected..
22097 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22098 other_nodes.push(ar[i]);
22102 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22107 has_other_nodes = true;
22109 if (!nodes.length && other_nodes.length) {
22110 nodes= other_nodes;
22112 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22118 createRange: function(sel)
22120 // this has strange effects when using with
22121 // top toolbar - not sure if it's a great idea.
22122 //this.editor.contentWindow.focus();
22123 if (typeof sel != "undefined") {
22125 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22127 return this.doc.createRange();
22130 return this.doc.createRange();
22133 getParentElement: function()
22136 this.assignDocWin();
22137 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22139 var range = this.createRange(sel);
22142 var p = range.commonAncestorContainer;
22143 while (p.nodeType == 3) { // text node
22154 * Range intersection.. the hard stuff...
22158 * [ -- selected range --- ]
22162 * if end is before start or hits it. fail.
22163 * if start is after end or hits it fail.
22165 * if either hits (but other is outside. - then it's not
22171 // @see http://www.thismuchiknow.co.uk/?p=64.
22172 rangeIntersectsNode : function(range, node)
22174 var nodeRange = node.ownerDocument.createRange();
22176 nodeRange.selectNode(node);
22178 nodeRange.selectNodeContents(node);
22181 var rangeStartRange = range.cloneRange();
22182 rangeStartRange.collapse(true);
22184 var rangeEndRange = range.cloneRange();
22185 rangeEndRange.collapse(false);
22187 var nodeStartRange = nodeRange.cloneRange();
22188 nodeStartRange.collapse(true);
22190 var nodeEndRange = nodeRange.cloneRange();
22191 nodeEndRange.collapse(false);
22193 return rangeStartRange.compareBoundaryPoints(
22194 Range.START_TO_START, nodeEndRange) == -1 &&
22195 rangeEndRange.compareBoundaryPoints(
22196 Range.START_TO_START, nodeStartRange) == 1;
22200 rangeCompareNode : function(range, node)
22202 var nodeRange = node.ownerDocument.createRange();
22204 nodeRange.selectNode(node);
22206 nodeRange.selectNodeContents(node);
22210 range.collapse(true);
22212 nodeRange.collapse(true);
22214 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22215 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22217 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22219 var nodeIsBefore = ss == 1;
22220 var nodeIsAfter = ee == -1;
22222 if (nodeIsBefore && nodeIsAfter) {
22225 if (!nodeIsBefore && nodeIsAfter) {
22226 return 1; //right trailed.
22229 if (nodeIsBefore && !nodeIsAfter) {
22230 return 2; // left trailed.
22236 // private? - in a new class?
22237 cleanUpPaste : function()
22239 // cleans up the whole document..
22240 Roo.log('cleanuppaste');
22242 this.cleanUpChildren(this.doc.body);
22243 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22244 if (clean != this.doc.body.innerHTML) {
22245 this.doc.body.innerHTML = clean;
22250 cleanWordChars : function(input) {// change the chars to hex code
22251 var he = Roo.HtmlEditorCore;
22253 var output = input;
22254 Roo.each(he.swapCodes, function(sw) {
22255 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22257 output = output.replace(swapper, sw[1]);
22264 cleanUpChildren : function (n)
22266 if (!n.childNodes.length) {
22269 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22270 this.cleanUpChild(n.childNodes[i]);
22277 cleanUpChild : function (node)
22280 //console.log(node);
22281 if (node.nodeName == "#text") {
22282 // clean up silly Windows -- stuff?
22285 if (node.nodeName == "#comment") {
22286 node.parentNode.removeChild(node);
22287 // clean up silly Windows -- stuff?
22290 var lcname = node.tagName.toLowerCase();
22291 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22292 // whitelist of tags..
22294 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22296 node.parentNode.removeChild(node);
22301 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22303 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22304 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22306 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22307 // remove_keep_children = true;
22310 if (remove_keep_children) {
22311 this.cleanUpChildren(node);
22312 // inserts everything just before this node...
22313 while (node.childNodes.length) {
22314 var cn = node.childNodes[0];
22315 node.removeChild(cn);
22316 node.parentNode.insertBefore(cn, node);
22318 node.parentNode.removeChild(node);
22322 if (!node.attributes || !node.attributes.length) {
22323 this.cleanUpChildren(node);
22327 function cleanAttr(n,v)
22330 if (v.match(/^\./) || v.match(/^\//)) {
22333 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22336 if (v.match(/^#/)) {
22339 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22340 node.removeAttribute(n);
22344 var cwhite = this.cwhite;
22345 var cblack = this.cblack;
22347 function cleanStyle(n,v)
22349 if (v.match(/expression/)) { //XSS?? should we even bother..
22350 node.removeAttribute(n);
22354 var parts = v.split(/;/);
22357 Roo.each(parts, function(p) {
22358 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22362 var l = p.split(':').shift().replace(/\s+/g,'');
22363 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22365 if ( cwhite.length && cblack.indexOf(l) > -1) {
22366 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22367 //node.removeAttribute(n);
22371 // only allow 'c whitelisted system attributes'
22372 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22373 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22374 //node.removeAttribute(n);
22384 if (clean.length) {
22385 node.setAttribute(n, clean.join(';'));
22387 node.removeAttribute(n);
22393 for (var i = node.attributes.length-1; i > -1 ; i--) {
22394 var a = node.attributes[i];
22397 if (a.name.toLowerCase().substr(0,2)=='on') {
22398 node.removeAttribute(a.name);
22401 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22402 node.removeAttribute(a.name);
22405 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22406 cleanAttr(a.name,a.value); // fixme..
22409 if (a.name == 'style') {
22410 cleanStyle(a.name,a.value);
22413 /// clean up MS crap..
22414 // tecnically this should be a list of valid class'es..
22417 if (a.name == 'class') {
22418 if (a.value.match(/^Mso/)) {
22419 node.className = '';
22422 if (a.value.match(/^body$/)) {
22423 node.className = '';
22434 this.cleanUpChildren(node);
22440 * Clean up MS wordisms...
22442 cleanWord : function(node)
22447 this.cleanWord(this.doc.body);
22450 if (node.nodeName == "#text") {
22451 // clean up silly Windows -- stuff?
22454 if (node.nodeName == "#comment") {
22455 node.parentNode.removeChild(node);
22456 // clean up silly Windows -- stuff?
22460 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22461 node.parentNode.removeChild(node);
22465 // remove - but keep children..
22466 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22467 while (node.childNodes.length) {
22468 var cn = node.childNodes[0];
22469 node.removeChild(cn);
22470 node.parentNode.insertBefore(cn, node);
22472 node.parentNode.removeChild(node);
22473 this.iterateChildren(node, this.cleanWord);
22477 if (node.className.length) {
22479 var cn = node.className.split(/\W+/);
22481 Roo.each(cn, function(cls) {
22482 if (cls.match(/Mso[a-zA-Z]+/)) {
22487 node.className = cna.length ? cna.join(' ') : '';
22489 node.removeAttribute("class");
22493 if (node.hasAttribute("lang")) {
22494 node.removeAttribute("lang");
22497 if (node.hasAttribute("style")) {
22499 var styles = node.getAttribute("style").split(";");
22501 Roo.each(styles, function(s) {
22502 if (!s.match(/:/)) {
22505 var kv = s.split(":");
22506 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22509 // what ever is left... we allow.
22512 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22513 if (!nstyle.length) {
22514 node.removeAttribute('style');
22517 this.iterateChildren(node, this.cleanWord);
22523 * iterateChildren of a Node, calling fn each time, using this as the scole..
22524 * @param {DomNode} node node to iterate children of.
22525 * @param {Function} fn method of this class to call on each item.
22527 iterateChildren : function(node, fn)
22529 if (!node.childNodes.length) {
22532 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22533 fn.call(this, node.childNodes[i])
22539 * cleanTableWidths.
22541 * Quite often pasting from word etc.. results in tables with column and widths.
22542 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22545 cleanTableWidths : function(node)
22550 this.cleanTableWidths(this.doc.body);
22555 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22558 Roo.log(node.tagName);
22559 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22560 this.iterateChildren(node, this.cleanTableWidths);
22563 if (node.hasAttribute('width')) {
22564 node.removeAttribute('width');
22568 if (node.hasAttribute("style")) {
22571 var styles = node.getAttribute("style").split(";");
22573 Roo.each(styles, function(s) {
22574 if (!s.match(/:/)) {
22577 var kv = s.split(":");
22578 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22581 // what ever is left... we allow.
22584 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22585 if (!nstyle.length) {
22586 node.removeAttribute('style');
22590 this.iterateChildren(node, this.cleanTableWidths);
22598 domToHTML : function(currentElement, depth, nopadtext) {
22600 depth = depth || 0;
22601 nopadtext = nopadtext || false;
22603 if (!currentElement) {
22604 return this.domToHTML(this.doc.body);
22607 //Roo.log(currentElement);
22609 var allText = false;
22610 var nodeName = currentElement.nodeName;
22611 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22613 if (nodeName == '#text') {
22615 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22620 if (nodeName != 'BODY') {
22623 // Prints the node tagName, such as <A>, <IMG>, etc
22626 for(i = 0; i < currentElement.attributes.length;i++) {
22628 var aname = currentElement.attributes.item(i).name;
22629 if (!currentElement.attributes.item(i).value.length) {
22632 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22635 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22644 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22647 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22652 // Traverse the tree
22654 var currentElementChild = currentElement.childNodes.item(i);
22655 var allText = true;
22656 var innerHTML = '';
22658 while (currentElementChild) {
22659 // Formatting code (indent the tree so it looks nice on the screen)
22660 var nopad = nopadtext;
22661 if (lastnode == 'SPAN') {
22665 if (currentElementChild.nodeName == '#text') {
22666 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22667 toadd = nopadtext ? toadd : toadd.trim();
22668 if (!nopad && toadd.length > 80) {
22669 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22671 innerHTML += toadd;
22674 currentElementChild = currentElement.childNodes.item(i);
22680 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22682 // Recursively traverse the tree structure of the child node
22683 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22684 lastnode = currentElementChild.nodeName;
22686 currentElementChild=currentElement.childNodes.item(i);
22692 // The remaining code is mostly for formatting the tree
22693 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22698 ret+= "</"+tagName+">";
22704 applyBlacklists : function()
22706 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22707 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22711 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22712 if (b.indexOf(tag) > -1) {
22715 this.white.push(tag);
22719 Roo.each(w, function(tag) {
22720 if (b.indexOf(tag) > -1) {
22723 if (this.white.indexOf(tag) > -1) {
22726 this.white.push(tag);
22731 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22732 if (w.indexOf(tag) > -1) {
22735 this.black.push(tag);
22739 Roo.each(b, function(tag) {
22740 if (w.indexOf(tag) > -1) {
22743 if (this.black.indexOf(tag) > -1) {
22746 this.black.push(tag);
22751 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22752 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22756 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22757 if (b.indexOf(tag) > -1) {
22760 this.cwhite.push(tag);
22764 Roo.each(w, function(tag) {
22765 if (b.indexOf(tag) > -1) {
22768 if (this.cwhite.indexOf(tag) > -1) {
22771 this.cwhite.push(tag);
22776 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22777 if (w.indexOf(tag) > -1) {
22780 this.cblack.push(tag);
22784 Roo.each(b, function(tag) {
22785 if (w.indexOf(tag) > -1) {
22788 if (this.cblack.indexOf(tag) > -1) {
22791 this.cblack.push(tag);
22796 setStylesheets : function(stylesheets)
22798 if(typeof(stylesheets) == 'string'){
22799 Roo.get(this.iframe.contentDocument.head).createChild({
22801 rel : 'stylesheet',
22810 Roo.each(stylesheets, function(s) {
22815 Roo.get(_this.iframe.contentDocument.head).createChild({
22817 rel : 'stylesheet',
22826 removeStylesheets : function()
22830 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22835 setStyle : function(style)
22837 Roo.get(this.iframe.contentDocument.head).createChild({
22846 // hide stuff that is not compatible
22860 * @event specialkey
22864 * @cfg {String} fieldClass @hide
22867 * @cfg {String} focusClass @hide
22870 * @cfg {String} autoCreate @hide
22873 * @cfg {String} inputType @hide
22876 * @cfg {String} invalidClass @hide
22879 * @cfg {String} invalidText @hide
22882 * @cfg {String} msgFx @hide
22885 * @cfg {String} validateOnBlur @hide
22889 Roo.HtmlEditorCore.white = [
22890 'area', 'br', 'img', 'input', 'hr', 'wbr',
22892 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22893 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22894 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22895 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22896 'table', 'ul', 'xmp',
22898 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22901 'dir', 'menu', 'ol', 'ul', 'dl',
22907 Roo.HtmlEditorCore.black = [
22908 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22910 'base', 'basefont', 'bgsound', 'blink', 'body',
22911 'frame', 'frameset', 'head', 'html', 'ilayer',
22912 'iframe', 'layer', 'link', 'meta', 'object',
22913 'script', 'style' ,'title', 'xml' // clean later..
22915 Roo.HtmlEditorCore.clean = [
22916 'script', 'style', 'title', 'xml'
22918 Roo.HtmlEditorCore.remove = [
22923 Roo.HtmlEditorCore.ablack = [
22927 Roo.HtmlEditorCore.aclean = [
22928 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22932 Roo.HtmlEditorCore.pwhite= [
22933 'http', 'https', 'mailto'
22936 // white listed style attributes.
22937 Roo.HtmlEditorCore.cwhite= [
22938 // 'text-align', /// default is to allow most things..
22944 // black listed style attributes.
22945 Roo.HtmlEditorCore.cblack= [
22946 // 'font-size' -- this can be set by the project
22950 Roo.HtmlEditorCore.swapCodes =[
22969 * @class Roo.bootstrap.HtmlEditor
22970 * @extends Roo.bootstrap.TextArea
22971 * Bootstrap HtmlEditor class
22974 * Create a new HtmlEditor
22975 * @param {Object} config The config object
22978 Roo.bootstrap.HtmlEditor = function(config){
22979 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22980 if (!this.toolbars) {
22981 this.toolbars = [];
22984 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22987 * @event initialize
22988 * Fires when the editor is fully initialized (including the iframe)
22989 * @param {HtmlEditor} this
22994 * Fires when the editor is first receives the focus. Any insertion must wait
22995 * until after this event.
22996 * @param {HtmlEditor} this
23000 * @event beforesync
23001 * Fires before the textarea is updated with content from the editor iframe. Return false
23002 * to cancel the sync.
23003 * @param {HtmlEditor} this
23004 * @param {String} html
23008 * @event beforepush
23009 * Fires before the iframe editor is updated with content from the textarea. Return false
23010 * to cancel the push.
23011 * @param {HtmlEditor} this
23012 * @param {String} html
23017 * Fires when the textarea is updated with content from the editor iframe.
23018 * @param {HtmlEditor} this
23019 * @param {String} html
23024 * Fires when the iframe editor is updated with content from the textarea.
23025 * @param {HtmlEditor} this
23026 * @param {String} html
23030 * @event editmodechange
23031 * Fires when the editor switches edit modes
23032 * @param {HtmlEditor} this
23033 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23035 editmodechange: true,
23037 * @event editorevent
23038 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23039 * @param {HtmlEditor} this
23043 * @event firstfocus
23044 * Fires when on first focus - needed by toolbars..
23045 * @param {HtmlEditor} this
23050 * Auto save the htmlEditor value as a file into Events
23051 * @param {HtmlEditor} this
23055 * @event savedpreview
23056 * preview the saved version of htmlEditor
23057 * @param {HtmlEditor} this
23064 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23068 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23073 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23078 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23083 * @cfg {Number} height (in pixels)
23087 * @cfg {Number} width (in pixels)
23092 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23095 stylesheets: false,
23100 // private properties
23101 validationEvent : false,
23103 initialized : false,
23106 onFocus : Roo.emptyFn,
23108 hideMode:'offsets',
23110 tbContainer : false,
23114 toolbarContainer :function() {
23115 return this.wrap.select('.x-html-editor-tb',true).first();
23119 * Protected method that will not generally be called directly. It
23120 * is called when the editor creates its toolbar. Override this method if you need to
23121 * add custom toolbar buttons.
23122 * @param {HtmlEditor} editor
23124 createToolbar : function(){
23125 Roo.log('renewing');
23126 Roo.log("create toolbars");
23128 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23129 this.toolbars[0].render(this.toolbarContainer());
23133 // if (!editor.toolbars || !editor.toolbars.length) {
23134 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23137 // for (var i =0 ; i < editor.toolbars.length;i++) {
23138 // editor.toolbars[i] = Roo.factory(
23139 // typeof(editor.toolbars[i]) == 'string' ?
23140 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23141 // Roo.bootstrap.HtmlEditor);
23142 // editor.toolbars[i].init(editor);
23148 onRender : function(ct, position)
23150 // Roo.log("Call onRender: " + this.xtype);
23152 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23154 this.wrap = this.inputEl().wrap({
23155 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23158 this.editorcore.onRender(ct, position);
23160 if (this.resizable) {
23161 this.resizeEl = new Roo.Resizable(this.wrap, {
23165 minHeight : this.height,
23166 height: this.height,
23167 handles : this.resizable,
23170 resize : function(r, w, h) {
23171 _t.onResize(w,h); // -something
23177 this.createToolbar(this);
23180 if(!this.width && this.resizable){
23181 this.setSize(this.wrap.getSize());
23183 if (this.resizeEl) {
23184 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23185 // should trigger onReize..
23191 onResize : function(w, h)
23193 Roo.log('resize: ' +w + ',' + h );
23194 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23198 if(this.inputEl() ){
23199 if(typeof w == 'number'){
23200 var aw = w - this.wrap.getFrameWidth('lr');
23201 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23204 if(typeof h == 'number'){
23205 var tbh = -11; // fixme it needs to tool bar size!
23206 for (var i =0; i < this.toolbars.length;i++) {
23207 // fixme - ask toolbars for heights?
23208 tbh += this.toolbars[i].el.getHeight();
23209 //if (this.toolbars[i].footer) {
23210 // tbh += this.toolbars[i].footer.el.getHeight();
23218 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23219 ah -= 5; // knock a few pixes off for look..
23220 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23224 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23225 this.editorcore.onResize(ew,eh);
23230 * Toggles the editor between standard and source edit mode.
23231 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23233 toggleSourceEdit : function(sourceEditMode)
23235 this.editorcore.toggleSourceEdit(sourceEditMode);
23237 if(this.editorcore.sourceEditMode){
23238 Roo.log('editor - showing textarea');
23241 // Roo.log(this.syncValue());
23243 this.inputEl().removeClass(['hide', 'x-hidden']);
23244 this.inputEl().dom.removeAttribute('tabIndex');
23245 this.inputEl().focus();
23247 Roo.log('editor - hiding textarea');
23249 // Roo.log(this.pushValue());
23252 this.inputEl().addClass(['hide', 'x-hidden']);
23253 this.inputEl().dom.setAttribute('tabIndex', -1);
23254 //this.deferFocus();
23257 if(this.resizable){
23258 this.setSize(this.wrap.getSize());
23261 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23264 // private (for BoxComponent)
23265 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23267 // private (for BoxComponent)
23268 getResizeEl : function(){
23272 // private (for BoxComponent)
23273 getPositionEl : function(){
23278 initEvents : function(){
23279 this.originalValue = this.getValue();
23283 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23286 // markInvalid : Roo.emptyFn,
23288 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23291 // clearInvalid : Roo.emptyFn,
23293 setValue : function(v){
23294 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23295 this.editorcore.pushValue();
23300 deferFocus : function(){
23301 this.focus.defer(10, this);
23305 focus : function(){
23306 this.editorcore.focus();
23312 onDestroy : function(){
23318 for (var i =0; i < this.toolbars.length;i++) {
23319 // fixme - ask toolbars for heights?
23320 this.toolbars[i].onDestroy();
23323 this.wrap.dom.innerHTML = '';
23324 this.wrap.remove();
23329 onFirstFocus : function(){
23330 //Roo.log("onFirstFocus");
23331 this.editorcore.onFirstFocus();
23332 for (var i =0; i < this.toolbars.length;i++) {
23333 this.toolbars[i].onFirstFocus();
23339 syncValue : function()
23341 this.editorcore.syncValue();
23344 pushValue : function()
23346 this.editorcore.pushValue();
23350 // hide stuff that is not compatible
23364 * @event specialkey
23368 * @cfg {String} fieldClass @hide
23371 * @cfg {String} focusClass @hide
23374 * @cfg {String} autoCreate @hide
23377 * @cfg {String} inputType @hide
23380 * @cfg {String} invalidClass @hide
23383 * @cfg {String} invalidText @hide
23386 * @cfg {String} msgFx @hide
23389 * @cfg {String} validateOnBlur @hide
23398 Roo.namespace('Roo.bootstrap.htmleditor');
23400 * @class Roo.bootstrap.HtmlEditorToolbar1
23405 new Roo.bootstrap.HtmlEditor({
23408 new Roo.bootstrap.HtmlEditorToolbar1({
23409 disable : { fonts: 1 , format: 1, ..., ... , ...],
23415 * @cfg {Object} disable List of elements to disable..
23416 * @cfg {Array} btns List of additional buttons.
23420 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23423 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23426 Roo.apply(this, config);
23428 // default disabled, based on 'good practice'..
23429 this.disable = this.disable || {};
23430 Roo.applyIf(this.disable, {
23433 specialElements : true
23435 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23437 this.editor = config.editor;
23438 this.editorcore = config.editor.editorcore;
23440 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23442 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23443 // dont call parent... till later.
23445 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23450 editorcore : false,
23455 "h1","h2","h3","h4","h5","h6",
23457 "abbr", "acronym", "address", "cite", "samp", "var",
23461 onRender : function(ct, position)
23463 // Roo.log("Call onRender: " + this.xtype);
23465 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23467 this.el.dom.style.marginBottom = '0';
23469 var editorcore = this.editorcore;
23470 var editor= this.editor;
23473 var btn = function(id,cmd , toggle, handler, html){
23475 var event = toggle ? 'toggle' : 'click';
23480 xns: Roo.bootstrap,
23483 enableToggle:toggle !== false,
23485 pressed : toggle ? false : null,
23488 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23489 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23495 // var cb_box = function...
23500 xns: Roo.bootstrap,
23501 glyphicon : 'font',
23505 xns: Roo.bootstrap,
23509 Roo.each(this.formats, function(f) {
23510 style.menu.items.push({
23512 xns: Roo.bootstrap,
23513 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23518 editorcore.insertTag(this.tagname);
23525 children.push(style);
23527 btn('bold',false,true);
23528 btn('italic',false,true);
23529 btn('align-left', 'justifyleft',true);
23530 btn('align-center', 'justifycenter',true);
23531 btn('align-right' , 'justifyright',true);
23532 btn('link', false, false, function(btn) {
23533 //Roo.log("create link?");
23534 var url = prompt(this.createLinkText, this.defaultLinkValue);
23535 if(url && url != 'http:/'+'/'){
23536 this.editorcore.relayCmd('createlink', url);
23539 btn('list','insertunorderedlist',true);
23540 btn('pencil', false,true, function(btn){
23542 this.toggleSourceEdit(btn.pressed);
23545 if (this.editor.btns.length > 0) {
23546 for (var i = 0; i<this.editor.btns.length; i++) {
23547 children.push(this.editor.btns[i]);
23555 xns: Roo.bootstrap,
23560 xns: Roo.bootstrap,
23565 cog.menu.items.push({
23567 xns: Roo.bootstrap,
23568 html : Clean styles,
23573 editorcore.insertTag(this.tagname);
23582 this.xtype = 'NavSimplebar';
23584 for(var i=0;i< children.length;i++) {
23586 this.buttons.add(this.addxtypeChild(children[i]));
23590 editor.on('editorevent', this.updateToolbar, this);
23592 onBtnClick : function(id)
23594 this.editorcore.relayCmd(id);
23595 this.editorcore.focus();
23599 * Protected method that will not generally be called directly. It triggers
23600 * a toolbar update by reading the markup state of the current selection in the editor.
23602 updateToolbar: function(){
23604 if(!this.editorcore.activated){
23605 this.editor.onFirstFocus(); // is this neeed?
23609 var btns = this.buttons;
23610 var doc = this.editorcore.doc;
23611 btns.get('bold').setActive(doc.queryCommandState('bold'));
23612 btns.get('italic').setActive(doc.queryCommandState('italic'));
23613 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23615 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23616 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23617 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23619 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23620 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23623 var ans = this.editorcore.getAllAncestors();
23624 if (this.formatCombo) {
23627 var store = this.formatCombo.store;
23628 this.formatCombo.setValue("");
23629 for (var i =0; i < ans.length;i++) {
23630 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23632 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23640 // hides menus... - so this cant be on a menu...
23641 Roo.bootstrap.MenuMgr.hideAll();
23643 Roo.bootstrap.MenuMgr.hideAll();
23644 //this.editorsyncValue();
23646 onFirstFocus: function() {
23647 this.buttons.each(function(item){
23651 toggleSourceEdit : function(sourceEditMode){
23654 if(sourceEditMode){
23655 Roo.log("disabling buttons");
23656 this.buttons.each( function(item){
23657 if(item.cmd != 'pencil'){
23663 Roo.log("enabling buttons");
23664 if(this.editorcore.initialized){
23665 this.buttons.each( function(item){
23671 Roo.log("calling toggole on editor");
23672 // tell the editor that it's been pressed..
23673 this.editor.toggleSourceEdit(sourceEditMode);
23683 * @class Roo.bootstrap.Table.AbstractSelectionModel
23684 * @extends Roo.util.Observable
23685 * Abstract base class for grid SelectionModels. It provides the interface that should be
23686 * implemented by descendant classes. This class should not be directly instantiated.
23689 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23690 this.locked = false;
23691 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23695 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23696 /** @ignore Called by the grid automatically. Do not call directly. */
23697 init : function(grid){
23703 * Locks the selections.
23706 this.locked = true;
23710 * Unlocks the selections.
23712 unlock : function(){
23713 this.locked = false;
23717 * Returns true if the selections are locked.
23718 * @return {Boolean}
23720 isLocked : function(){
23721 return this.locked;
23725 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23726 * @class Roo.bootstrap.Table.RowSelectionModel
23727 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23728 * It supports multiple selections and keyboard selection/navigation.
23730 * @param {Object} config
23733 Roo.bootstrap.Table.RowSelectionModel = function(config){
23734 Roo.apply(this, config);
23735 this.selections = new Roo.util.MixedCollection(false, function(o){
23740 this.lastActive = false;
23744 * @event selectionchange
23745 * Fires when the selection changes
23746 * @param {SelectionModel} this
23748 "selectionchange" : true,
23750 * @event afterselectionchange
23751 * Fires after the selection changes (eg. by key press or clicking)
23752 * @param {SelectionModel} this
23754 "afterselectionchange" : true,
23756 * @event beforerowselect
23757 * Fires when a row is selected being selected, return false to cancel.
23758 * @param {SelectionModel} this
23759 * @param {Number} rowIndex The selected index
23760 * @param {Boolean} keepExisting False if other selections will be cleared
23762 "beforerowselect" : true,
23765 * Fires when a row is selected.
23766 * @param {SelectionModel} this
23767 * @param {Number} rowIndex The selected index
23768 * @param {Roo.data.Record} r The record
23770 "rowselect" : true,
23772 * @event rowdeselect
23773 * Fires when a row is deselected.
23774 * @param {SelectionModel} this
23775 * @param {Number} rowIndex The selected index
23777 "rowdeselect" : true
23779 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23780 this.locked = false;
23783 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23785 * @cfg {Boolean} singleSelect
23786 * True to allow selection of only one row at a time (defaults to false)
23788 singleSelect : false,
23791 initEvents : function()
23794 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23795 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23796 //}else{ // allow click to work like normal
23797 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23799 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23800 this.grid.on("rowclick", this.handleMouseDown, this);
23802 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23803 "up" : function(e){
23805 this.selectPrevious(e.shiftKey);
23806 }else if(this.last !== false && this.lastActive !== false){
23807 var last = this.last;
23808 this.selectRange(this.last, this.lastActive-1);
23809 this.grid.getView().focusRow(this.lastActive);
23810 if(last !== false){
23814 this.selectFirstRow();
23816 this.fireEvent("afterselectionchange", this);
23818 "down" : function(e){
23820 this.selectNext(e.shiftKey);
23821 }else if(this.last !== false && this.lastActive !== false){
23822 var last = this.last;
23823 this.selectRange(this.last, this.lastActive+1);
23824 this.grid.getView().focusRow(this.lastActive);
23825 if(last !== false){
23829 this.selectFirstRow();
23831 this.fireEvent("afterselectionchange", this);
23835 this.grid.store.on('load', function(){
23836 this.selections.clear();
23839 var view = this.grid.view;
23840 view.on("refresh", this.onRefresh, this);
23841 view.on("rowupdated", this.onRowUpdated, this);
23842 view.on("rowremoved", this.onRemove, this);
23847 onRefresh : function()
23849 var ds = this.grid.store, i, v = this.grid.view;
23850 var s = this.selections;
23851 s.each(function(r){
23852 if((i = ds.indexOfId(r.id)) != -1){
23861 onRemove : function(v, index, r){
23862 this.selections.remove(r);
23866 onRowUpdated : function(v, index, r){
23867 if(this.isSelected(r)){
23868 v.onRowSelect(index);
23874 * @param {Array} records The records to select
23875 * @param {Boolean} keepExisting (optional) True to keep existing selections
23877 selectRecords : function(records, keepExisting)
23880 this.clearSelections();
23882 var ds = this.grid.store;
23883 for(var i = 0, len = records.length; i < len; i++){
23884 this.selectRow(ds.indexOf(records[i]), true);
23889 * Gets the number of selected rows.
23892 getCount : function(){
23893 return this.selections.length;
23897 * Selects the first row in the grid.
23899 selectFirstRow : function(){
23904 * Select the last row.
23905 * @param {Boolean} keepExisting (optional) True to keep existing selections
23907 selectLastRow : function(keepExisting){
23908 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23909 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23913 * Selects the row immediately following the last selected row.
23914 * @param {Boolean} keepExisting (optional) True to keep existing selections
23916 selectNext : function(keepExisting)
23918 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23919 this.selectRow(this.last+1, keepExisting);
23920 this.grid.getView().focusRow(this.last);
23925 * Selects the row that precedes the last selected row.
23926 * @param {Boolean} keepExisting (optional) True to keep existing selections
23928 selectPrevious : function(keepExisting){
23930 this.selectRow(this.last-1, keepExisting);
23931 this.grid.getView().focusRow(this.last);
23936 * Returns the selected records
23937 * @return {Array} Array of selected records
23939 getSelections : function(){
23940 return [].concat(this.selections.items);
23944 * Returns the first selected record.
23947 getSelected : function(){
23948 return this.selections.itemAt(0);
23953 * Clears all selections.
23955 clearSelections : function(fast)
23961 var ds = this.grid.store;
23962 var s = this.selections;
23963 s.each(function(r){
23964 this.deselectRow(ds.indexOfId(r.id));
23968 this.selections.clear();
23975 * Selects all rows.
23977 selectAll : function(){
23981 this.selections.clear();
23982 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23983 this.selectRow(i, true);
23988 * Returns True if there is a selection.
23989 * @return {Boolean}
23991 hasSelection : function(){
23992 return this.selections.length > 0;
23996 * Returns True if the specified row is selected.
23997 * @param {Number/Record} record The record or index of the record to check
23998 * @return {Boolean}
24000 isSelected : function(index){
24001 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24002 return (r && this.selections.key(r.id) ? true : false);
24006 * Returns True if the specified record id is selected.
24007 * @param {String} id The id of record to check
24008 * @return {Boolean}
24010 isIdSelected : function(id){
24011 return (this.selections.key(id) ? true : false);
24016 handleMouseDBClick : function(e, t){
24020 handleMouseDown : function(e, t)
24022 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24023 if(this.isLocked() || rowIndex < 0 ){
24026 if(e.shiftKey && this.last !== false){
24027 var last = this.last;
24028 this.selectRange(last, rowIndex, e.ctrlKey);
24029 this.last = last; // reset the last
24033 var isSelected = this.isSelected(rowIndex);
24034 //Roo.log("select row:" + rowIndex);
24036 this.deselectRow(rowIndex);
24038 this.selectRow(rowIndex, true);
24042 if(e.button !== 0 && isSelected){
24043 alert('rowIndex 2: ' + rowIndex);
24044 view.focusRow(rowIndex);
24045 }else if(e.ctrlKey && isSelected){
24046 this.deselectRow(rowIndex);
24047 }else if(!isSelected){
24048 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24049 view.focusRow(rowIndex);
24053 this.fireEvent("afterselectionchange", this);
24056 handleDragableRowClick : function(grid, rowIndex, e)
24058 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24059 this.selectRow(rowIndex, false);
24060 grid.view.focusRow(rowIndex);
24061 this.fireEvent("afterselectionchange", this);
24066 * Selects multiple rows.
24067 * @param {Array} rows Array of the indexes of the row to select
24068 * @param {Boolean} keepExisting (optional) True to keep existing selections
24070 selectRows : function(rows, keepExisting){
24072 this.clearSelections();
24074 for(var i = 0, len = rows.length; i < len; i++){
24075 this.selectRow(rows[i], true);
24080 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24081 * @param {Number} startRow The index of the first row in the range
24082 * @param {Number} endRow The index of the last row in the range
24083 * @param {Boolean} keepExisting (optional) True to retain existing selections
24085 selectRange : function(startRow, endRow, keepExisting){
24090 this.clearSelections();
24092 if(startRow <= endRow){
24093 for(var i = startRow; i <= endRow; i++){
24094 this.selectRow(i, true);
24097 for(var i = startRow; i >= endRow; i--){
24098 this.selectRow(i, true);
24104 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24105 * @param {Number} startRow The index of the first row in the range
24106 * @param {Number} endRow The index of the last row in the range
24108 deselectRange : function(startRow, endRow, preventViewNotify){
24112 for(var i = startRow; i <= endRow; i++){
24113 this.deselectRow(i, preventViewNotify);
24119 * @param {Number} row The index of the row to select
24120 * @param {Boolean} keepExisting (optional) True to keep existing selections
24122 selectRow : function(index, keepExisting, preventViewNotify)
24124 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24127 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24128 if(!keepExisting || this.singleSelect){
24129 this.clearSelections();
24132 var r = this.grid.store.getAt(index);
24133 //console.log('selectRow - record id :' + r.id);
24135 this.selections.add(r);
24136 this.last = this.lastActive = index;
24137 if(!preventViewNotify){
24138 var proxy = new Roo.Element(
24139 this.grid.getRowDom(index)
24141 proxy.addClass('bg-info info');
24143 this.fireEvent("rowselect", this, index, r);
24144 this.fireEvent("selectionchange", this);
24150 * @param {Number} row The index of the row to deselect
24152 deselectRow : function(index, preventViewNotify)
24157 if(this.last == index){
24160 if(this.lastActive == index){
24161 this.lastActive = false;
24164 var r = this.grid.store.getAt(index);
24169 this.selections.remove(r);
24170 //.console.log('deselectRow - record id :' + r.id);
24171 if(!preventViewNotify){
24173 var proxy = new Roo.Element(
24174 this.grid.getRowDom(index)
24176 proxy.removeClass('bg-info info');
24178 this.fireEvent("rowdeselect", this, index);
24179 this.fireEvent("selectionchange", this);
24183 restoreLast : function(){
24185 this.last = this._last;
24190 acceptsNav : function(row, col, cm){
24191 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24195 onEditorKey : function(field, e){
24196 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24201 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24203 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24205 }else if(k == e.ENTER && !e.ctrlKey){
24209 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24211 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24213 }else if(k == e.ESC){
24217 g.startEditing(newCell[0], newCell[1]);
24223 * Ext JS Library 1.1.1
24224 * Copyright(c) 2006-2007, Ext JS, LLC.
24226 * Originally Released Under LGPL - original licence link has changed is not relivant.
24229 * <script type="text/javascript">
24233 * @class Roo.bootstrap.PagingToolbar
24234 * @extends Roo.bootstrap.NavSimplebar
24235 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24237 * Create a new PagingToolbar
24238 * @param {Object} config The config object
24239 * @param {Roo.data.Store} store
24241 Roo.bootstrap.PagingToolbar = function(config)
24243 // old args format still supported... - xtype is prefered..
24244 // created from xtype...
24246 this.ds = config.dataSource;
24248 if (config.store && !this.ds) {
24249 this.store= Roo.factory(config.store, Roo.data);
24250 this.ds = this.store;
24251 this.ds.xmodule = this.xmodule || false;
24254 this.toolbarItems = [];
24255 if (config.items) {
24256 this.toolbarItems = config.items;
24259 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24264 this.bind(this.ds);
24267 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24271 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24273 * @cfg {Roo.data.Store} dataSource
24274 * The underlying data store providing the paged data
24277 * @cfg {String/HTMLElement/Element} container
24278 * container The id or element that will contain the toolbar
24281 * @cfg {Boolean} displayInfo
24282 * True to display the displayMsg (defaults to false)
24285 * @cfg {Number} pageSize
24286 * The number of records to display per page (defaults to 20)
24290 * @cfg {String} displayMsg
24291 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24293 displayMsg : 'Displaying {0} - {1} of {2}',
24295 * @cfg {String} emptyMsg
24296 * The message to display when no records are found (defaults to "No data to display")
24298 emptyMsg : 'No data to display',
24300 * Customizable piece of the default paging text (defaults to "Page")
24303 beforePageText : "Page",
24305 * Customizable piece of the default paging text (defaults to "of %0")
24308 afterPageText : "of {0}",
24310 * Customizable piece of the default paging text (defaults to "First Page")
24313 firstText : "First Page",
24315 * Customizable piece of the default paging text (defaults to "Previous Page")
24318 prevText : "Previous Page",
24320 * Customizable piece of the default paging text (defaults to "Next Page")
24323 nextText : "Next Page",
24325 * Customizable piece of the default paging text (defaults to "Last Page")
24328 lastText : "Last Page",
24330 * Customizable piece of the default paging text (defaults to "Refresh")
24333 refreshText : "Refresh",
24337 onRender : function(ct, position)
24339 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24340 this.navgroup.parentId = this.id;
24341 this.navgroup.onRender(this.el, null);
24342 // add the buttons to the navgroup
24344 if(this.displayInfo){
24345 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24346 this.displayEl = this.el.select('.x-paging-info', true).first();
24347 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24348 // this.displayEl = navel.el.select('span',true).first();
24354 Roo.each(_this.buttons, function(e){ // this might need to use render????
24355 Roo.factory(e).onRender(_this.el, null);
24359 Roo.each(_this.toolbarItems, function(e) {
24360 _this.navgroup.addItem(e);
24364 this.first = this.navgroup.addItem({
24365 tooltip: this.firstText,
24367 icon : 'fa fa-backward',
24369 preventDefault: true,
24370 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24373 this.prev = this.navgroup.addItem({
24374 tooltip: this.prevText,
24376 icon : 'fa fa-step-backward',
24378 preventDefault: true,
24379 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24381 //this.addSeparator();
24384 var field = this.navgroup.addItem( {
24386 cls : 'x-paging-position',
24388 html : this.beforePageText +
24389 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24390 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24393 this.field = field.el.select('input', true).first();
24394 this.field.on("keydown", this.onPagingKeydown, this);
24395 this.field.on("focus", function(){this.dom.select();});
24398 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24399 //this.field.setHeight(18);
24400 //this.addSeparator();
24401 this.next = this.navgroup.addItem({
24402 tooltip: this.nextText,
24404 html : ' <i class="fa fa-step-forward">',
24406 preventDefault: true,
24407 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24409 this.last = this.navgroup.addItem({
24410 tooltip: this.lastText,
24411 icon : 'fa fa-forward',
24414 preventDefault: true,
24415 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24417 //this.addSeparator();
24418 this.loading = this.navgroup.addItem({
24419 tooltip: this.refreshText,
24420 icon: 'fa fa-refresh',
24421 preventDefault: true,
24422 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24428 updateInfo : function(){
24429 if(this.displayEl){
24430 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24431 var msg = count == 0 ?
24435 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24437 this.displayEl.update(msg);
24442 onLoad : function(ds, r, o)
24444 this.cursor = o.params ? o.params.start : 0;
24445 var d = this.getPageData(),
24450 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24451 this.field.dom.value = ap;
24452 this.first.setDisabled(ap == 1);
24453 this.prev.setDisabled(ap == 1);
24454 this.next.setDisabled(ap == ps);
24455 this.last.setDisabled(ap == ps);
24456 this.loading.enable();
24461 getPageData : function(){
24462 var total = this.ds.getTotalCount();
24465 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24466 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24471 onLoadError : function(){
24472 this.loading.enable();
24476 onPagingKeydown : function(e){
24477 var k = e.getKey();
24478 var d = this.getPageData();
24480 var v = this.field.dom.value, pageNum;
24481 if(!v || isNaN(pageNum = parseInt(v, 10))){
24482 this.field.dom.value = d.activePage;
24485 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24486 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24489 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))
24491 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24492 this.field.dom.value = pageNum;
24493 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24496 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24498 var v = this.field.dom.value, pageNum;
24499 var increment = (e.shiftKey) ? 10 : 1;
24500 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24503 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24504 this.field.dom.value = d.activePage;
24507 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24509 this.field.dom.value = parseInt(v, 10) + increment;
24510 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24511 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24518 beforeLoad : function(){
24520 this.loading.disable();
24525 onClick : function(which){
24534 ds.load({params:{start: 0, limit: this.pageSize}});
24537 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24540 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24543 var total = ds.getTotalCount();
24544 var extra = total % this.pageSize;
24545 var lastStart = extra ? (total - extra) : total-this.pageSize;
24546 ds.load({params:{start: lastStart, limit: this.pageSize}});
24549 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24555 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24556 * @param {Roo.data.Store} store The data store to unbind
24558 unbind : function(ds){
24559 ds.un("beforeload", this.beforeLoad, this);
24560 ds.un("load", this.onLoad, this);
24561 ds.un("loadexception", this.onLoadError, this);
24562 ds.un("remove", this.updateInfo, this);
24563 ds.un("add", this.updateInfo, this);
24564 this.ds = undefined;
24568 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24569 * @param {Roo.data.Store} store The data store to bind
24571 bind : function(ds){
24572 ds.on("beforeload", this.beforeLoad, this);
24573 ds.on("load", this.onLoad, this);
24574 ds.on("loadexception", this.onLoadError, this);
24575 ds.on("remove", this.updateInfo, this);
24576 ds.on("add", this.updateInfo, this);
24587 * @class Roo.bootstrap.MessageBar
24588 * @extends Roo.bootstrap.Component
24589 * Bootstrap MessageBar class
24590 * @cfg {String} html contents of the MessageBar
24591 * @cfg {String} weight (info | success | warning | danger) default info
24592 * @cfg {String} beforeClass insert the bar before the given class
24593 * @cfg {Boolean} closable (true | false) default false
24594 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24597 * Create a new Element
24598 * @param {Object} config The config object
24601 Roo.bootstrap.MessageBar = function(config){
24602 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24605 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24611 beforeClass: 'bootstrap-sticky-wrap',
24613 getAutoCreate : function(){
24617 cls: 'alert alert-dismissable alert-' + this.weight,
24622 html: this.html || ''
24628 cfg.cls += ' alert-messages-fixed';
24642 onRender : function(ct, position)
24644 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24647 var cfg = Roo.apply({}, this.getAutoCreate());
24651 cfg.cls += ' ' + this.cls;
24654 cfg.style = this.style;
24656 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24658 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24661 this.el.select('>button.close').on('click', this.hide, this);
24667 if (!this.rendered) {
24673 this.fireEvent('show', this);
24679 if (!this.rendered) {
24685 this.fireEvent('hide', this);
24688 update : function()
24690 // var e = this.el.dom.firstChild;
24692 // if(this.closable){
24693 // e = e.nextSibling;
24696 // e.data = this.html || '';
24698 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24714 * @class Roo.bootstrap.Graph
24715 * @extends Roo.bootstrap.Component
24716 * Bootstrap Graph class
24720 @cfg {String} graphtype bar | vbar | pie
24721 @cfg {number} g_x coodinator | centre x (pie)
24722 @cfg {number} g_y coodinator | centre y (pie)
24723 @cfg {number} g_r radius (pie)
24724 @cfg {number} g_height height of the chart (respected by all elements in the set)
24725 @cfg {number} g_width width of the chart (respected by all elements in the set)
24726 @cfg {Object} title The title of the chart
24729 -opts (object) options for the chart
24731 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24732 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24734 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.
24735 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24737 o stretch (boolean)
24739 -opts (object) options for the pie
24742 o startAngle (number)
24743 o endAngle (number)
24747 * Create a new Input
24748 * @param {Object} config The config object
24751 Roo.bootstrap.Graph = function(config){
24752 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24758 * The img click event for the img.
24759 * @param {Roo.EventObject} e
24765 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24776 //g_colors: this.colors,
24783 getAutoCreate : function(){
24794 onRender : function(ct,position){
24797 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24799 if (typeof(Raphael) == 'undefined') {
24800 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24804 this.raphael = Raphael(this.el.dom);
24806 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24807 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24808 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24809 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24811 r.text(160, 10, "Single Series Chart").attr(txtattr);
24812 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24813 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24814 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24816 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24817 r.barchart(330, 10, 300, 220, data1);
24818 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24819 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24822 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24823 // r.barchart(30, 30, 560, 250, xdata, {
24824 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24825 // axis : "0 0 1 1",
24826 // axisxlabels : xdata
24827 // //yvalues : cols,
24830 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24832 // this.load(null,xdata,{
24833 // axis : "0 0 1 1",
24834 // axisxlabels : xdata
24839 load : function(graphtype,xdata,opts)
24841 this.raphael.clear();
24843 graphtype = this.graphtype;
24848 var r = this.raphael,
24849 fin = function () {
24850 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24852 fout = function () {
24853 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24855 pfin = function() {
24856 this.sector.stop();
24857 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24860 this.label[0].stop();
24861 this.label[0].attr({ r: 7.5 });
24862 this.label[1].attr({ "font-weight": 800 });
24865 pfout = function() {
24866 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24869 this.label[0].animate({ r: 5 }, 500, "bounce");
24870 this.label[1].attr({ "font-weight": 400 });
24876 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24879 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24882 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24883 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24885 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24892 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24897 setTitle: function(o)
24902 initEvents: function() {
24905 this.el.on('click', this.onClick, this);
24909 onClick : function(e)
24911 Roo.log('img onclick');
24912 this.fireEvent('click', this, e);
24924 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24927 * @class Roo.bootstrap.dash.NumberBox
24928 * @extends Roo.bootstrap.Component
24929 * Bootstrap NumberBox class
24930 * @cfg {String} headline Box headline
24931 * @cfg {String} content Box content
24932 * @cfg {String} icon Box icon
24933 * @cfg {String} footer Footer text
24934 * @cfg {String} fhref Footer href
24937 * Create a new NumberBox
24938 * @param {Object} config The config object
24942 Roo.bootstrap.dash.NumberBox = function(config){
24943 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24947 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24956 getAutoCreate : function(){
24960 cls : 'small-box ',
24968 cls : 'roo-headline',
24969 html : this.headline
24973 cls : 'roo-content',
24974 html : this.content
24988 cls : 'ion ' + this.icon
24997 cls : 'small-box-footer',
24998 href : this.fhref || '#',
25002 cfg.cn.push(footer);
25009 onRender : function(ct,position){
25010 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25017 setHeadline: function (value)
25019 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25022 setFooter: function (value, href)
25024 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25027 this.el.select('a.small-box-footer',true).first().attr('href', href);
25032 setContent: function (value)
25034 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25037 initEvents: function()
25051 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25054 * @class Roo.bootstrap.dash.TabBox
25055 * @extends Roo.bootstrap.Component
25056 * Bootstrap TabBox class
25057 * @cfg {String} title Title of the TabBox
25058 * @cfg {String} icon Icon of the TabBox
25059 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25060 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25063 * Create a new TabBox
25064 * @param {Object} config The config object
25068 Roo.bootstrap.dash.TabBox = function(config){
25069 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25074 * When a pane is added
25075 * @param {Roo.bootstrap.dash.TabPane} pane
25079 * @event activatepane
25080 * When a pane is activated
25081 * @param {Roo.bootstrap.dash.TabPane} pane
25083 "activatepane" : true
25091 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25096 tabScrollable : false,
25098 getChildContainer : function()
25100 return this.el.select('.tab-content', true).first();
25103 getAutoCreate : function(){
25107 cls: 'pull-left header',
25115 cls: 'fa ' + this.icon
25121 cls: 'nav nav-tabs pull-right',
25127 if(this.tabScrollable){
25134 cls: 'nav nav-tabs pull-right',
25145 cls: 'nav-tabs-custom',
25150 cls: 'tab-content no-padding',
25158 initEvents : function()
25160 //Roo.log('add add pane handler');
25161 this.on('addpane', this.onAddPane, this);
25164 * Updates the box title
25165 * @param {String} html to set the title to.
25167 setTitle : function(value)
25169 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25171 onAddPane : function(pane)
25173 this.panes.push(pane);
25174 //Roo.log('addpane');
25176 // tabs are rendere left to right..
25177 if(!this.showtabs){
25181 var ctr = this.el.select('.nav-tabs', true).first();
25184 var existing = ctr.select('.nav-tab',true);
25185 var qty = existing.getCount();;
25188 var tab = ctr.createChild({
25190 cls : 'nav-tab' + (qty ? '' : ' active'),
25198 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25201 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25203 pane.el.addClass('active');
25208 onTabClick : function(ev,un,ob,pane)
25210 //Roo.log('tab - prev default');
25211 ev.preventDefault();
25214 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25215 pane.tab.addClass('active');
25216 //Roo.log(pane.title);
25217 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25218 // technically we should have a deactivate event.. but maybe add later.
25219 // and it should not de-activate the selected tab...
25220 this.fireEvent('activatepane', pane);
25221 pane.el.addClass('active');
25222 pane.fireEvent('activate');
25227 getActivePane : function()
25230 Roo.each(this.panes, function(p) {
25231 if(p.el.hasClass('active')){
25252 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25254 * @class Roo.bootstrap.TabPane
25255 * @extends Roo.bootstrap.Component
25256 * Bootstrap TabPane class
25257 * @cfg {Boolean} active (false | true) Default false
25258 * @cfg {String} title title of panel
25262 * Create a new TabPane
25263 * @param {Object} config The config object
25266 Roo.bootstrap.dash.TabPane = function(config){
25267 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25273 * When a pane is activated
25274 * @param {Roo.bootstrap.dash.TabPane} pane
25281 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25286 // the tabBox that this is attached to.
25289 getAutoCreate : function()
25297 cfg.cls += ' active';
25302 initEvents : function()
25304 //Roo.log('trigger add pane handler');
25305 this.parent().fireEvent('addpane', this)
25309 * Updates the tab title
25310 * @param {String} html to set the title to.
25312 setTitle: function(str)
25318 this.tab.select('a', true).first().dom.innerHTML = str;
25335 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25338 * @class Roo.bootstrap.menu.Menu
25339 * @extends Roo.bootstrap.Component
25340 * Bootstrap Menu class - container for Menu
25341 * @cfg {String} html Text of the menu
25342 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25343 * @cfg {String} icon Font awesome icon
25344 * @cfg {String} pos Menu align to (top | bottom) default bottom
25348 * Create a new Menu
25349 * @param {Object} config The config object
25353 Roo.bootstrap.menu.Menu = function(config){
25354 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25358 * @event beforeshow
25359 * Fires before this menu is displayed
25360 * @param {Roo.bootstrap.menu.Menu} this
25364 * @event beforehide
25365 * Fires before this menu is hidden
25366 * @param {Roo.bootstrap.menu.Menu} this
25371 * Fires after this menu is displayed
25372 * @param {Roo.bootstrap.menu.Menu} this
25377 * Fires after this menu is hidden
25378 * @param {Roo.bootstrap.menu.Menu} this
25383 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25384 * @param {Roo.bootstrap.menu.Menu} this
25385 * @param {Roo.EventObject} e
25392 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25396 weight : 'default',
25401 getChildContainer : function() {
25402 if(this.isSubMenu){
25406 return this.el.select('ul.dropdown-menu', true).first();
25409 getAutoCreate : function()
25414 cls : 'roo-menu-text',
25422 cls : 'fa ' + this.icon
25433 cls : 'dropdown-button btn btn-' + this.weight,
25438 cls : 'dropdown-toggle btn btn-' + this.weight,
25448 cls : 'dropdown-menu'
25454 if(this.pos == 'top'){
25455 cfg.cls += ' dropup';
25458 if(this.isSubMenu){
25461 cls : 'dropdown-menu'
25468 onRender : function(ct, position)
25470 this.isSubMenu = ct.hasClass('dropdown-submenu');
25472 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25475 initEvents : function()
25477 if(this.isSubMenu){
25481 this.hidden = true;
25483 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25484 this.triggerEl.on('click', this.onTriggerPress, this);
25486 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25487 this.buttonEl.on('click', this.onClick, this);
25493 if(this.isSubMenu){
25497 return this.el.select('ul.dropdown-menu', true).first();
25500 onClick : function(e)
25502 this.fireEvent("click", this, e);
25505 onTriggerPress : function(e)
25507 if (this.isVisible()) {
25514 isVisible : function(){
25515 return !this.hidden;
25520 this.fireEvent("beforeshow", this);
25522 this.hidden = false;
25523 this.el.addClass('open');
25525 Roo.get(document).on("mouseup", this.onMouseUp, this);
25527 this.fireEvent("show", this);
25534 this.fireEvent("beforehide", this);
25536 this.hidden = true;
25537 this.el.removeClass('open');
25539 Roo.get(document).un("mouseup", this.onMouseUp);
25541 this.fireEvent("hide", this);
25544 onMouseUp : function()
25558 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25561 * @class Roo.bootstrap.menu.Item
25562 * @extends Roo.bootstrap.Component
25563 * Bootstrap MenuItem class
25564 * @cfg {Boolean} submenu (true | false) default false
25565 * @cfg {String} html text of the item
25566 * @cfg {String} href the link
25567 * @cfg {Boolean} disable (true | false) default false
25568 * @cfg {Boolean} preventDefault (true | false) default true
25569 * @cfg {String} icon Font awesome icon
25570 * @cfg {String} pos Submenu align to (left | right) default right
25574 * Create a new Item
25575 * @param {Object} config The config object
25579 Roo.bootstrap.menu.Item = function(config){
25580 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25584 * Fires when the mouse is hovering over this menu
25585 * @param {Roo.bootstrap.menu.Item} this
25586 * @param {Roo.EventObject} e
25591 * Fires when the mouse exits this menu
25592 * @param {Roo.bootstrap.menu.Item} this
25593 * @param {Roo.EventObject} e
25599 * The raw click event for the entire grid.
25600 * @param {Roo.EventObject} e
25606 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25611 preventDefault: true,
25616 getAutoCreate : function()
25621 cls : 'roo-menu-item-text',
25629 cls : 'fa ' + this.icon
25638 href : this.href || '#',
25645 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25649 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25651 if(this.pos == 'left'){
25652 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25659 initEvents : function()
25661 this.el.on('mouseover', this.onMouseOver, this);
25662 this.el.on('mouseout', this.onMouseOut, this);
25664 this.el.select('a', true).first().on('click', this.onClick, this);
25668 onClick : function(e)
25670 if(this.preventDefault){
25671 e.preventDefault();
25674 this.fireEvent("click", this, e);
25677 onMouseOver : function(e)
25679 if(this.submenu && this.pos == 'left'){
25680 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25683 this.fireEvent("mouseover", this, e);
25686 onMouseOut : function(e)
25688 this.fireEvent("mouseout", this, e);
25700 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25703 * @class Roo.bootstrap.menu.Separator
25704 * @extends Roo.bootstrap.Component
25705 * Bootstrap Separator class
25708 * Create a new Separator
25709 * @param {Object} config The config object
25713 Roo.bootstrap.menu.Separator = function(config){
25714 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25717 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25719 getAutoCreate : function(){
25740 * @class Roo.bootstrap.Tooltip
25741 * Bootstrap Tooltip class
25742 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25743 * to determine which dom element triggers the tooltip.
25745 * It needs to add support for additional attributes like tooltip-position
25748 * Create a new Toolti
25749 * @param {Object} config The config object
25752 Roo.bootstrap.Tooltip = function(config){
25753 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25755 this.alignment = Roo.bootstrap.Tooltip.alignment;
25757 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25758 this.alignment = config.alignment;
25763 Roo.apply(Roo.bootstrap.Tooltip, {
25765 * @function init initialize tooltip monitoring.
25769 currentTip : false,
25770 currentRegion : false,
25776 Roo.get(document).on('mouseover', this.enter ,this);
25777 Roo.get(document).on('mouseout', this.leave, this);
25780 this.currentTip = new Roo.bootstrap.Tooltip();
25783 enter : function(ev)
25785 var dom = ev.getTarget();
25787 //Roo.log(['enter',dom]);
25788 var el = Roo.fly(dom);
25789 if (this.currentEl) {
25791 //Roo.log(this.currentEl);
25792 //Roo.log(this.currentEl.contains(dom));
25793 if (this.currentEl == el) {
25796 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25802 if (this.currentTip.el) {
25803 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25807 if(!el || el.dom == document){
25813 // you can not look for children, as if el is the body.. then everythign is the child..
25814 if (!el.attr('tooltip')) { //
25815 if (!el.select("[tooltip]").elements.length) {
25818 // is the mouse over this child...?
25819 bindEl = el.select("[tooltip]").first();
25820 var xy = ev.getXY();
25821 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25822 //Roo.log("not in region.");
25825 //Roo.log("child element over..");
25828 this.currentEl = bindEl;
25829 this.currentTip.bind(bindEl);
25830 this.currentRegion = Roo.lib.Region.getRegion(dom);
25831 this.currentTip.enter();
25834 leave : function(ev)
25836 var dom = ev.getTarget();
25837 //Roo.log(['leave',dom]);
25838 if (!this.currentEl) {
25843 if (dom != this.currentEl.dom) {
25846 var xy = ev.getXY();
25847 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25850 // only activate leave if mouse cursor is outside... bounding box..
25855 if (this.currentTip) {
25856 this.currentTip.leave();
25858 //Roo.log('clear currentEl');
25859 this.currentEl = false;
25864 'left' : ['r-l', [-2,0], 'right'],
25865 'right' : ['l-r', [2,0], 'left'],
25866 'bottom' : ['t-b', [0,2], 'top'],
25867 'top' : [ 'b-t', [0,-2], 'bottom']
25873 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25878 delay : null, // can be { show : 300 , hide: 500}
25882 hoverState : null, //???
25884 placement : 'bottom',
25888 getAutoCreate : function(){
25895 cls : 'tooltip-arrow'
25898 cls : 'tooltip-inner'
25905 bind : function(el)
25911 enter : function () {
25913 if (this.timeout != null) {
25914 clearTimeout(this.timeout);
25917 this.hoverState = 'in';
25918 //Roo.log("enter - show");
25919 if (!this.delay || !this.delay.show) {
25924 this.timeout = setTimeout(function () {
25925 if (_t.hoverState == 'in') {
25928 }, this.delay.show);
25932 clearTimeout(this.timeout);
25934 this.hoverState = 'out';
25935 if (!this.delay || !this.delay.hide) {
25941 this.timeout = setTimeout(function () {
25942 //Roo.log("leave - timeout");
25944 if (_t.hoverState == 'out') {
25946 Roo.bootstrap.Tooltip.currentEl = false;
25951 show : function (msg)
25954 this.render(document.body);
25957 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25959 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25961 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25963 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25965 var placement = typeof this.placement == 'function' ?
25966 this.placement.call(this, this.el, on_el) :
25969 var autoToken = /\s?auto?\s?/i;
25970 var autoPlace = autoToken.test(placement);
25972 placement = placement.replace(autoToken, '') || 'top';
25976 //this.el.setXY([0,0]);
25978 //this.el.dom.style.display='block';
25980 //this.el.appendTo(on_el);
25982 var p = this.getPosition();
25983 var box = this.el.getBox();
25989 var align = this.alignment[placement];
25991 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25993 if(placement == 'top' || placement == 'bottom'){
25995 placement = 'right';
25998 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25999 placement = 'left';
26002 var scroll = Roo.select('body', true).first().getScroll();
26004 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26010 this.el.alignTo(this.bindEl, align[0],align[1]);
26011 //var arrow = this.el.select('.arrow',true).first();
26012 //arrow.set(align[2],
26014 this.el.addClass(placement);
26016 this.el.addClass('in fade');
26018 this.hoverState = null;
26020 if (this.el.hasClass('fade')) {
26031 //this.el.setXY([0,0]);
26032 this.el.removeClass('in');
26048 * @class Roo.bootstrap.LocationPicker
26049 * @extends Roo.bootstrap.Component
26050 * Bootstrap LocationPicker class
26051 * @cfg {Number} latitude Position when init default 0
26052 * @cfg {Number} longitude Position when init default 0
26053 * @cfg {Number} zoom default 15
26054 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26055 * @cfg {Boolean} mapTypeControl default false
26056 * @cfg {Boolean} disableDoubleClickZoom default false
26057 * @cfg {Boolean} scrollwheel default true
26058 * @cfg {Boolean} streetViewControl default false
26059 * @cfg {Number} radius default 0
26060 * @cfg {String} locationName
26061 * @cfg {Boolean} draggable default true
26062 * @cfg {Boolean} enableAutocomplete default false
26063 * @cfg {Boolean} enableReverseGeocode default true
26064 * @cfg {String} markerTitle
26067 * Create a new LocationPicker
26068 * @param {Object} config The config object
26072 Roo.bootstrap.LocationPicker = function(config){
26074 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26079 * Fires when the picker initialized.
26080 * @param {Roo.bootstrap.LocationPicker} this
26081 * @param {Google Location} location
26085 * @event positionchanged
26086 * Fires when the picker position changed.
26087 * @param {Roo.bootstrap.LocationPicker} this
26088 * @param {Google Location} location
26090 positionchanged : true,
26093 * Fires when the map resize.
26094 * @param {Roo.bootstrap.LocationPicker} this
26099 * Fires when the map show.
26100 * @param {Roo.bootstrap.LocationPicker} this
26105 * Fires when the map hide.
26106 * @param {Roo.bootstrap.LocationPicker} this
26111 * Fires when click the map.
26112 * @param {Roo.bootstrap.LocationPicker} this
26113 * @param {Map event} e
26117 * @event mapRightClick
26118 * Fires when right click the map.
26119 * @param {Roo.bootstrap.LocationPicker} this
26120 * @param {Map event} e
26122 mapRightClick : true,
26124 * @event markerClick
26125 * Fires when click the marker.
26126 * @param {Roo.bootstrap.LocationPicker} this
26127 * @param {Map event} e
26129 markerClick : true,
26131 * @event markerRightClick
26132 * Fires when right click the marker.
26133 * @param {Roo.bootstrap.LocationPicker} this
26134 * @param {Map event} e
26136 markerRightClick : true,
26138 * @event OverlayViewDraw
26139 * Fires when OverlayView Draw
26140 * @param {Roo.bootstrap.LocationPicker} this
26142 OverlayViewDraw : true,
26144 * @event OverlayViewOnAdd
26145 * Fires when OverlayView Draw
26146 * @param {Roo.bootstrap.LocationPicker} this
26148 OverlayViewOnAdd : true,
26150 * @event OverlayViewOnRemove
26151 * Fires when OverlayView Draw
26152 * @param {Roo.bootstrap.LocationPicker} this
26154 OverlayViewOnRemove : true,
26156 * @event OverlayViewShow
26157 * Fires when OverlayView Draw
26158 * @param {Roo.bootstrap.LocationPicker} this
26159 * @param {Pixel} cpx
26161 OverlayViewShow : true,
26163 * @event OverlayViewHide
26164 * Fires when OverlayView Draw
26165 * @param {Roo.bootstrap.LocationPicker} this
26167 OverlayViewHide : true,
26169 * @event loadexception
26170 * Fires when load google lib failed.
26171 * @param {Roo.bootstrap.LocationPicker} this
26173 loadexception : true
26178 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26180 gMapContext: false,
26186 mapTypeControl: false,
26187 disableDoubleClickZoom: false,
26189 streetViewControl: false,
26193 enableAutocomplete: false,
26194 enableReverseGeocode: true,
26197 getAutoCreate: function()
26202 cls: 'roo-location-picker'
26208 initEvents: function(ct, position)
26210 if(!this.el.getWidth() || this.isApplied()){
26214 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26219 initial: function()
26221 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26222 this.fireEvent('loadexception', this);
26226 if(!this.mapTypeId){
26227 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26230 this.gMapContext = this.GMapContext();
26232 this.initOverlayView();
26234 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26238 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26239 _this.setPosition(_this.gMapContext.marker.position);
26242 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26243 _this.fireEvent('mapClick', this, event);
26247 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26248 _this.fireEvent('mapRightClick', this, event);
26252 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26253 _this.fireEvent('markerClick', this, event);
26257 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26258 _this.fireEvent('markerRightClick', this, event);
26262 this.setPosition(this.gMapContext.location);
26264 this.fireEvent('initial', this, this.gMapContext.location);
26267 initOverlayView: function()
26271 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26275 _this.fireEvent('OverlayViewDraw', _this);
26280 _this.fireEvent('OverlayViewOnAdd', _this);
26283 onRemove: function()
26285 _this.fireEvent('OverlayViewOnRemove', _this);
26288 show: function(cpx)
26290 _this.fireEvent('OverlayViewShow', _this, cpx);
26295 _this.fireEvent('OverlayViewHide', _this);
26301 fromLatLngToContainerPixel: function(event)
26303 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26306 isApplied: function()
26308 return this.getGmapContext() == false ? false : true;
26311 getGmapContext: function()
26313 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26316 GMapContext: function()
26318 var position = new google.maps.LatLng(this.latitude, this.longitude);
26320 var _map = new google.maps.Map(this.el.dom, {
26323 mapTypeId: this.mapTypeId,
26324 mapTypeControl: this.mapTypeControl,
26325 disableDoubleClickZoom: this.disableDoubleClickZoom,
26326 scrollwheel: this.scrollwheel,
26327 streetViewControl: this.streetViewControl,
26328 locationName: this.locationName,
26329 draggable: this.draggable,
26330 enableAutocomplete: this.enableAutocomplete,
26331 enableReverseGeocode: this.enableReverseGeocode
26334 var _marker = new google.maps.Marker({
26335 position: position,
26337 title: this.markerTitle,
26338 draggable: this.draggable
26345 location: position,
26346 radius: this.radius,
26347 locationName: this.locationName,
26348 addressComponents: {
26349 formatted_address: null,
26350 addressLine1: null,
26351 addressLine2: null,
26353 streetNumber: null,
26357 stateOrProvince: null
26360 domContainer: this.el.dom,
26361 geodecoder: new google.maps.Geocoder()
26365 drawCircle: function(center, radius, options)
26367 if (this.gMapContext.circle != null) {
26368 this.gMapContext.circle.setMap(null);
26372 options = Roo.apply({}, options, {
26373 strokeColor: "#0000FF",
26374 strokeOpacity: .35,
26376 fillColor: "#0000FF",
26380 options.map = this.gMapContext.map;
26381 options.radius = radius;
26382 options.center = center;
26383 this.gMapContext.circle = new google.maps.Circle(options);
26384 return this.gMapContext.circle;
26390 setPosition: function(location)
26392 this.gMapContext.location = location;
26393 this.gMapContext.marker.setPosition(location);
26394 this.gMapContext.map.panTo(location);
26395 this.drawCircle(location, this.gMapContext.radius, {});
26399 if (this.gMapContext.settings.enableReverseGeocode) {
26400 this.gMapContext.geodecoder.geocode({
26401 latLng: this.gMapContext.location
26402 }, function(results, status) {
26404 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26405 _this.gMapContext.locationName = results[0].formatted_address;
26406 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26408 _this.fireEvent('positionchanged', this, location);
26415 this.fireEvent('positionchanged', this, location);
26420 google.maps.event.trigger(this.gMapContext.map, "resize");
26422 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26424 this.fireEvent('resize', this);
26427 setPositionByLatLng: function(latitude, longitude)
26429 this.setPosition(new google.maps.LatLng(latitude, longitude));
26432 getCurrentPosition: function()
26435 latitude: this.gMapContext.location.lat(),
26436 longitude: this.gMapContext.location.lng()
26440 getAddressName: function()
26442 return this.gMapContext.locationName;
26445 getAddressComponents: function()
26447 return this.gMapContext.addressComponents;
26450 address_component_from_google_geocode: function(address_components)
26454 for (var i = 0; i < address_components.length; i++) {
26455 var component = address_components[i];
26456 if (component.types.indexOf("postal_code") >= 0) {
26457 result.postalCode = component.short_name;
26458 } else if (component.types.indexOf("street_number") >= 0) {
26459 result.streetNumber = component.short_name;
26460 } else if (component.types.indexOf("route") >= 0) {
26461 result.streetName = component.short_name;
26462 } else if (component.types.indexOf("neighborhood") >= 0) {
26463 result.city = component.short_name;
26464 } else if (component.types.indexOf("locality") >= 0) {
26465 result.city = component.short_name;
26466 } else if (component.types.indexOf("sublocality") >= 0) {
26467 result.district = component.short_name;
26468 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26469 result.stateOrProvince = component.short_name;
26470 } else if (component.types.indexOf("country") >= 0) {
26471 result.country = component.short_name;
26475 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26476 result.addressLine2 = "";
26480 setZoomLevel: function(zoom)
26482 this.gMapContext.map.setZoom(zoom);
26495 this.fireEvent('show', this);
26506 this.fireEvent('hide', this);
26511 Roo.apply(Roo.bootstrap.LocationPicker, {
26513 OverlayView : function(map, options)
26515 options = options || {};
26529 * @class Roo.bootstrap.Alert
26530 * @extends Roo.bootstrap.Component
26531 * Bootstrap Alert class
26532 * @cfg {String} title The title of alert
26533 * @cfg {String} html The content of alert
26534 * @cfg {String} weight ( success | info | warning | danger )
26535 * @cfg {String} faicon font-awesomeicon
26538 * Create a new alert
26539 * @param {Object} config The config object
26543 Roo.bootstrap.Alert = function(config){
26544 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26548 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26555 getAutoCreate : function()
26564 cls : 'roo-alert-icon'
26569 cls : 'roo-alert-title',
26574 cls : 'roo-alert-text',
26581 cfg.cn[0].cls += ' fa ' + this.faicon;
26585 cfg.cls += ' alert-' + this.weight;
26591 initEvents: function()
26593 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26596 setTitle : function(str)
26598 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26601 setText : function(str)
26603 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26606 setWeight : function(weight)
26609 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26612 this.weight = weight;
26614 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26617 setIcon : function(icon)
26620 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26623 this.faicon = icon;
26625 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26646 * @class Roo.bootstrap.UploadCropbox
26647 * @extends Roo.bootstrap.Component
26648 * Bootstrap UploadCropbox class
26649 * @cfg {String} emptyText show when image has been loaded
26650 * @cfg {String} rotateNotify show when image too small to rotate
26651 * @cfg {Number} errorTimeout default 3000
26652 * @cfg {Number} minWidth default 300
26653 * @cfg {Number} minHeight default 300
26654 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26655 * @cfg {Boolean} isDocument (true|false) default false
26656 * @cfg {String} url action url
26657 * @cfg {String} paramName default 'imageUpload'
26658 * @cfg {String} method default POST
26659 * @cfg {Boolean} loadMask (true|false) default true
26660 * @cfg {Boolean} loadingText default 'Loading...'
26663 * Create a new UploadCropbox
26664 * @param {Object} config The config object
26667 Roo.bootstrap.UploadCropbox = function(config){
26668 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26672 * @event beforeselectfile
26673 * Fire before select file
26674 * @param {Roo.bootstrap.UploadCropbox} this
26676 "beforeselectfile" : true,
26679 * Fire after initEvent
26680 * @param {Roo.bootstrap.UploadCropbox} this
26685 * Fire after initEvent
26686 * @param {Roo.bootstrap.UploadCropbox} this
26687 * @param {String} data
26692 * Fire when preparing the file data
26693 * @param {Roo.bootstrap.UploadCropbox} this
26694 * @param {Object} file
26699 * Fire when get exception
26700 * @param {Roo.bootstrap.UploadCropbox} this
26701 * @param {XMLHttpRequest} xhr
26703 "exception" : true,
26705 * @event beforeloadcanvas
26706 * Fire before load the canvas
26707 * @param {Roo.bootstrap.UploadCropbox} this
26708 * @param {String} src
26710 "beforeloadcanvas" : true,
26713 * Fire when trash image
26714 * @param {Roo.bootstrap.UploadCropbox} this
26719 * Fire when download the image
26720 * @param {Roo.bootstrap.UploadCropbox} this
26724 * @event footerbuttonclick
26725 * Fire when footerbuttonclick
26726 * @param {Roo.bootstrap.UploadCropbox} this
26727 * @param {String} type
26729 "footerbuttonclick" : true,
26733 * @param {Roo.bootstrap.UploadCropbox} this
26738 * Fire when rotate the image
26739 * @param {Roo.bootstrap.UploadCropbox} this
26740 * @param {String} pos
26745 * Fire when inspect the file
26746 * @param {Roo.bootstrap.UploadCropbox} this
26747 * @param {Object} file
26752 * Fire when xhr upload the file
26753 * @param {Roo.bootstrap.UploadCropbox} this
26754 * @param {Object} data
26759 * Fire when arrange the file data
26760 * @param {Roo.bootstrap.UploadCropbox} this
26761 * @param {Object} formData
26766 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26769 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26771 emptyText : 'Click to upload image',
26772 rotateNotify : 'Image is too small to rotate',
26773 errorTimeout : 3000,
26787 cropType : 'image/jpeg',
26789 canvasLoaded : false,
26790 isDocument : false,
26792 paramName : 'imageUpload',
26794 loadingText : 'Loading...',
26797 getAutoCreate : function()
26801 cls : 'roo-upload-cropbox',
26805 cls : 'roo-upload-cropbox-selector',
26810 cls : 'roo-upload-cropbox-body',
26811 style : 'cursor:pointer',
26815 cls : 'roo-upload-cropbox-preview'
26819 cls : 'roo-upload-cropbox-thumb'
26823 cls : 'roo-upload-cropbox-empty-notify',
26824 html : this.emptyText
26828 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26829 html : this.rotateNotify
26835 cls : 'roo-upload-cropbox-footer',
26838 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26848 onRender : function(ct, position)
26850 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26852 if (this.buttons.length) {
26854 Roo.each(this.buttons, function(bb) {
26856 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26858 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26864 this.maskEl = this.el;
26868 initEvents : function()
26870 this.urlAPI = (window.createObjectURL && window) ||
26871 (window.URL && URL.revokeObjectURL && URL) ||
26872 (window.webkitURL && webkitURL);
26874 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26875 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26877 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26878 this.selectorEl.hide();
26880 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26881 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26883 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26884 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26885 this.thumbEl.hide();
26887 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26888 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26890 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26891 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26892 this.errorEl.hide();
26894 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26895 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26896 this.footerEl.hide();
26898 this.setThumbBoxSize();
26904 this.fireEvent('initial', this);
26911 window.addEventListener("resize", function() { _this.resize(); } );
26913 this.bodyEl.on('click', this.beforeSelectFile, this);
26916 this.bodyEl.on('touchstart', this.onTouchStart, this);
26917 this.bodyEl.on('touchmove', this.onTouchMove, this);
26918 this.bodyEl.on('touchend', this.onTouchEnd, this);
26922 this.bodyEl.on('mousedown', this.onMouseDown, this);
26923 this.bodyEl.on('mousemove', this.onMouseMove, this);
26924 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26925 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26926 Roo.get(document).on('mouseup', this.onMouseUp, this);
26929 this.selectorEl.on('change', this.onFileSelected, this);
26935 this.baseScale = 1;
26937 this.baseRotate = 1;
26938 this.dragable = false;
26939 this.pinching = false;
26942 this.cropData = false;
26943 this.notifyEl.dom.innerHTML = this.emptyText;
26945 this.selectorEl.dom.value = '';
26949 resize : function()
26951 if(this.fireEvent('resize', this) != false){
26952 this.setThumbBoxPosition();
26953 this.setCanvasPosition();
26957 onFooterButtonClick : function(e, el, o, type)
26960 case 'rotate-left' :
26961 this.onRotateLeft(e);
26963 case 'rotate-right' :
26964 this.onRotateRight(e);
26967 this.beforeSelectFile(e);
26982 this.fireEvent('footerbuttonclick', this, type);
26985 beforeSelectFile : function(e)
26987 e.preventDefault();
26989 if(this.fireEvent('beforeselectfile', this) != false){
26990 this.selectorEl.dom.click();
26994 onFileSelected : function(e)
26996 e.preventDefault();
26998 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27002 var file = this.selectorEl.dom.files[0];
27004 if(this.fireEvent('inspect', this, file) != false){
27005 this.prepare(file);
27010 trash : function(e)
27012 this.fireEvent('trash', this);
27015 download : function(e)
27017 this.fireEvent('download', this);
27020 loadCanvas : function(src)
27022 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27026 this.imageEl = document.createElement('img');
27030 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27032 this.imageEl.src = src;
27036 onLoadCanvas : function()
27038 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27039 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27041 this.bodyEl.un('click', this.beforeSelectFile, this);
27043 this.notifyEl.hide();
27044 this.thumbEl.show();
27045 this.footerEl.show();
27047 this.baseRotateLevel();
27049 if(this.isDocument){
27050 this.setThumbBoxSize();
27053 this.setThumbBoxPosition();
27055 this.baseScaleLevel();
27061 this.canvasLoaded = true;
27064 this.maskEl.unmask();
27069 setCanvasPosition : function()
27071 if(!this.canvasEl){
27075 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27076 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27078 this.previewEl.setLeft(pw);
27079 this.previewEl.setTop(ph);
27083 onMouseDown : function(e)
27087 this.dragable = true;
27088 this.pinching = false;
27090 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27091 this.dragable = false;
27095 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27096 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27100 onMouseMove : function(e)
27104 if(!this.canvasLoaded){
27108 if (!this.dragable){
27112 var minX = Math.ceil(this.thumbEl.getLeft(true));
27113 var minY = Math.ceil(this.thumbEl.getTop(true));
27115 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27116 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27118 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27119 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27121 x = x - this.mouseX;
27122 y = y - this.mouseY;
27124 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27125 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27127 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27128 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27130 this.previewEl.setLeft(bgX);
27131 this.previewEl.setTop(bgY);
27133 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27134 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27137 onMouseUp : function(e)
27141 this.dragable = false;
27144 onMouseWheel : function(e)
27148 this.startScale = this.scale;
27150 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27152 if(!this.zoomable()){
27153 this.scale = this.startScale;
27162 zoomable : function()
27164 var minScale = this.thumbEl.getWidth() / this.minWidth;
27166 if(this.minWidth < this.minHeight){
27167 minScale = this.thumbEl.getHeight() / this.minHeight;
27170 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27171 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27175 (this.rotate == 0 || this.rotate == 180) &&
27177 width > this.imageEl.OriginWidth ||
27178 height > this.imageEl.OriginHeight ||
27179 (width < this.minWidth && height < this.minHeight)
27187 (this.rotate == 90 || this.rotate == 270) &&
27189 width > this.imageEl.OriginWidth ||
27190 height > this.imageEl.OriginHeight ||
27191 (width < this.minHeight && height < this.minWidth)
27198 !this.isDocument &&
27199 (this.rotate == 0 || this.rotate == 180) &&
27201 width < this.minWidth ||
27202 width > this.imageEl.OriginWidth ||
27203 height < this.minHeight ||
27204 height > this.imageEl.OriginHeight
27211 !this.isDocument &&
27212 (this.rotate == 90 || this.rotate == 270) &&
27214 width < this.minHeight ||
27215 width > this.imageEl.OriginWidth ||
27216 height < this.minWidth ||
27217 height > this.imageEl.OriginHeight
27227 onRotateLeft : function(e)
27229 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27231 var minScale = this.thumbEl.getWidth() / this.minWidth;
27233 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27234 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27236 this.startScale = this.scale;
27238 while (this.getScaleLevel() < minScale){
27240 this.scale = this.scale + 1;
27242 if(!this.zoomable()){
27247 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27248 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27253 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27260 this.scale = this.startScale;
27262 this.onRotateFail();
27267 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27269 if(this.isDocument){
27270 this.setThumbBoxSize();
27271 this.setThumbBoxPosition();
27272 this.setCanvasPosition();
27277 this.fireEvent('rotate', this, 'left');
27281 onRotateRight : function(e)
27283 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27285 var minScale = this.thumbEl.getWidth() / this.minWidth;
27287 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27288 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27290 this.startScale = this.scale;
27292 while (this.getScaleLevel() < minScale){
27294 this.scale = this.scale + 1;
27296 if(!this.zoomable()){
27301 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27302 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27307 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27314 this.scale = this.startScale;
27316 this.onRotateFail();
27321 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27323 if(this.isDocument){
27324 this.setThumbBoxSize();
27325 this.setThumbBoxPosition();
27326 this.setCanvasPosition();
27331 this.fireEvent('rotate', this, 'right');
27334 onRotateFail : function()
27336 this.errorEl.show(true);
27340 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27345 this.previewEl.dom.innerHTML = '';
27347 var canvasEl = document.createElement("canvas");
27349 var contextEl = canvasEl.getContext("2d");
27351 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27352 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27353 var center = this.imageEl.OriginWidth / 2;
27355 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27356 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27357 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27358 center = this.imageEl.OriginHeight / 2;
27361 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27363 contextEl.translate(center, center);
27364 contextEl.rotate(this.rotate * Math.PI / 180);
27366 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27368 this.canvasEl = document.createElement("canvas");
27370 this.contextEl = this.canvasEl.getContext("2d");
27372 switch (this.rotate) {
27375 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27376 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27378 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27383 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27384 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27386 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27387 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);
27391 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27396 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27397 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27399 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27400 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);
27404 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);
27409 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27410 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27412 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27413 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27417 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);
27424 this.previewEl.appendChild(this.canvasEl);
27426 this.setCanvasPosition();
27431 if(!this.canvasLoaded){
27435 var imageCanvas = document.createElement("canvas");
27437 var imageContext = imageCanvas.getContext("2d");
27439 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27440 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27442 var center = imageCanvas.width / 2;
27444 imageContext.translate(center, center);
27446 imageContext.rotate(this.rotate * Math.PI / 180);
27448 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27450 var canvas = document.createElement("canvas");
27452 var context = canvas.getContext("2d");
27454 canvas.width = this.minWidth;
27455 canvas.height = this.minHeight;
27457 switch (this.rotate) {
27460 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27461 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27463 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27464 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27466 var targetWidth = this.minWidth - 2 * x;
27467 var targetHeight = this.minHeight - 2 * y;
27471 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27472 scale = targetWidth / width;
27475 if(x > 0 && y == 0){
27476 scale = targetHeight / height;
27479 if(x > 0 && y > 0){
27480 scale = targetWidth / width;
27482 if(width < height){
27483 scale = targetHeight / height;
27487 context.scale(scale, scale);
27489 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27490 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27492 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27493 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27495 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27500 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27501 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27503 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27504 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27506 var targetWidth = this.minWidth - 2 * x;
27507 var targetHeight = this.minHeight - 2 * y;
27511 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27512 scale = targetWidth / width;
27515 if(x > 0 && y == 0){
27516 scale = targetHeight / height;
27519 if(x > 0 && y > 0){
27520 scale = targetWidth / width;
27522 if(width < height){
27523 scale = targetHeight / height;
27527 context.scale(scale, scale);
27529 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27530 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27532 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27533 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27535 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27537 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27542 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27543 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27545 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27546 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27548 var targetWidth = this.minWidth - 2 * x;
27549 var targetHeight = this.minHeight - 2 * y;
27553 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27554 scale = targetWidth / width;
27557 if(x > 0 && y == 0){
27558 scale = targetHeight / height;
27561 if(x > 0 && y > 0){
27562 scale = targetWidth / width;
27564 if(width < height){
27565 scale = targetHeight / height;
27569 context.scale(scale, scale);
27571 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27572 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27574 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27575 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27577 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27578 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27580 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27585 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27586 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27588 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27589 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27591 var targetWidth = this.minWidth - 2 * x;
27592 var targetHeight = this.minHeight - 2 * y;
27596 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27597 scale = targetWidth / width;
27600 if(x > 0 && y == 0){
27601 scale = targetHeight / height;
27604 if(x > 0 && y > 0){
27605 scale = targetWidth / width;
27607 if(width < height){
27608 scale = targetHeight / height;
27612 context.scale(scale, scale);
27614 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27615 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27617 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27618 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27620 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27622 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27629 this.cropData = canvas.toDataURL(this.cropType);
27631 if(this.fireEvent('crop', this, this.cropData) !== false){
27632 this.process(this.file, this.cropData);
27639 setThumbBoxSize : function()
27643 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27644 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27645 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27647 this.minWidth = width;
27648 this.minHeight = height;
27650 if(this.rotate == 90 || this.rotate == 270){
27651 this.minWidth = height;
27652 this.minHeight = width;
27657 width = Math.ceil(this.minWidth * height / this.minHeight);
27659 if(this.minWidth > this.minHeight){
27661 height = Math.ceil(this.minHeight * width / this.minWidth);
27664 this.thumbEl.setStyle({
27665 width : width + 'px',
27666 height : height + 'px'
27673 setThumbBoxPosition : function()
27675 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27676 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27678 this.thumbEl.setLeft(x);
27679 this.thumbEl.setTop(y);
27683 baseRotateLevel : function()
27685 this.baseRotate = 1;
27688 typeof(this.exif) != 'undefined' &&
27689 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27690 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27692 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27695 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27699 baseScaleLevel : function()
27703 if(this.isDocument){
27705 if(this.baseRotate == 6 || this.baseRotate == 8){
27707 height = this.thumbEl.getHeight();
27708 this.baseScale = height / this.imageEl.OriginWidth;
27710 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27711 width = this.thumbEl.getWidth();
27712 this.baseScale = width / this.imageEl.OriginHeight;
27718 height = this.thumbEl.getHeight();
27719 this.baseScale = height / this.imageEl.OriginHeight;
27721 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27722 width = this.thumbEl.getWidth();
27723 this.baseScale = width / this.imageEl.OriginWidth;
27729 if(this.baseRotate == 6 || this.baseRotate == 8){
27731 width = this.thumbEl.getHeight();
27732 this.baseScale = width / this.imageEl.OriginHeight;
27734 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27735 height = this.thumbEl.getWidth();
27736 this.baseScale = height / this.imageEl.OriginHeight;
27739 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27740 height = this.thumbEl.getWidth();
27741 this.baseScale = height / this.imageEl.OriginHeight;
27743 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27744 width = this.thumbEl.getHeight();
27745 this.baseScale = width / this.imageEl.OriginWidth;
27752 width = this.thumbEl.getWidth();
27753 this.baseScale = width / this.imageEl.OriginWidth;
27755 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27756 height = this.thumbEl.getHeight();
27757 this.baseScale = height / this.imageEl.OriginHeight;
27760 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27762 height = this.thumbEl.getHeight();
27763 this.baseScale = height / this.imageEl.OriginHeight;
27765 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27766 width = this.thumbEl.getWidth();
27767 this.baseScale = width / this.imageEl.OriginWidth;
27775 getScaleLevel : function()
27777 return this.baseScale * Math.pow(1.1, this.scale);
27780 onTouchStart : function(e)
27782 if(!this.canvasLoaded){
27783 this.beforeSelectFile(e);
27787 var touches = e.browserEvent.touches;
27793 if(touches.length == 1){
27794 this.onMouseDown(e);
27798 if(touches.length != 2){
27804 for(var i = 0, finger; finger = touches[i]; i++){
27805 coords.push(finger.pageX, finger.pageY);
27808 var x = Math.pow(coords[0] - coords[2], 2);
27809 var y = Math.pow(coords[1] - coords[3], 2);
27811 this.startDistance = Math.sqrt(x + y);
27813 this.startScale = this.scale;
27815 this.pinching = true;
27816 this.dragable = false;
27820 onTouchMove : function(e)
27822 if(!this.pinching && !this.dragable){
27826 var touches = e.browserEvent.touches;
27833 this.onMouseMove(e);
27839 for(var i = 0, finger; finger = touches[i]; i++){
27840 coords.push(finger.pageX, finger.pageY);
27843 var x = Math.pow(coords[0] - coords[2], 2);
27844 var y = Math.pow(coords[1] - coords[3], 2);
27846 this.endDistance = Math.sqrt(x + y);
27848 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27850 if(!this.zoomable()){
27851 this.scale = this.startScale;
27859 onTouchEnd : function(e)
27861 this.pinching = false;
27862 this.dragable = false;
27866 process : function(file, crop)
27869 this.maskEl.mask(this.loadingText);
27872 this.xhr = new XMLHttpRequest();
27874 file.xhr = this.xhr;
27876 this.xhr.open(this.method, this.url, true);
27879 "Accept": "application/json",
27880 "Cache-Control": "no-cache",
27881 "X-Requested-With": "XMLHttpRequest"
27884 for (var headerName in headers) {
27885 var headerValue = headers[headerName];
27887 this.xhr.setRequestHeader(headerName, headerValue);
27893 this.xhr.onload = function()
27895 _this.xhrOnLoad(_this.xhr);
27898 this.xhr.onerror = function()
27900 _this.xhrOnError(_this.xhr);
27903 var formData = new FormData();
27905 formData.append('returnHTML', 'NO');
27908 formData.append('crop', crop);
27911 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27912 formData.append(this.paramName, file, file.name);
27915 if(typeof(file.filename) != 'undefined'){
27916 formData.append('filename', file.filename);
27919 if(typeof(file.mimetype) != 'undefined'){
27920 formData.append('mimetype', file.mimetype);
27923 if(this.fireEvent('arrange', this, formData) != false){
27924 this.xhr.send(formData);
27928 xhrOnLoad : function(xhr)
27931 this.maskEl.unmask();
27934 if (xhr.readyState !== 4) {
27935 this.fireEvent('exception', this, xhr);
27939 var response = Roo.decode(xhr.responseText);
27941 if(!response.success){
27942 this.fireEvent('exception', this, xhr);
27946 var response = Roo.decode(xhr.responseText);
27948 this.fireEvent('upload', this, response);
27952 xhrOnError : function()
27955 this.maskEl.unmask();
27958 Roo.log('xhr on error');
27960 var response = Roo.decode(xhr.responseText);
27966 prepare : function(file)
27969 this.maskEl.mask(this.loadingText);
27975 if(typeof(file) === 'string'){
27976 this.loadCanvas(file);
27980 if(!file || !this.urlAPI){
27985 this.cropType = file.type;
27989 if(this.fireEvent('prepare', this, this.file) != false){
27991 var reader = new FileReader();
27993 reader.onload = function (e) {
27994 if (e.target.error) {
27995 Roo.log(e.target.error);
27999 var buffer = e.target.result,
28000 dataView = new DataView(buffer),
28002 maxOffset = dataView.byteLength - 4,
28006 if (dataView.getUint16(0) === 0xffd8) {
28007 while (offset < maxOffset) {
28008 markerBytes = dataView.getUint16(offset);
28010 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28011 markerLength = dataView.getUint16(offset + 2) + 2;
28012 if (offset + markerLength > dataView.byteLength) {
28013 Roo.log('Invalid meta data: Invalid segment size.');
28017 if(markerBytes == 0xffe1){
28018 _this.parseExifData(
28025 offset += markerLength;
28035 var url = _this.urlAPI.createObjectURL(_this.file);
28037 _this.loadCanvas(url);
28042 reader.readAsArrayBuffer(this.file);
28048 parseExifData : function(dataView, offset, length)
28050 var tiffOffset = offset + 10,
28054 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28055 // No Exif data, might be XMP data instead
28059 // Check for the ASCII code for "Exif" (0x45786966):
28060 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28061 // No Exif data, might be XMP data instead
28064 if (tiffOffset + 8 > dataView.byteLength) {
28065 Roo.log('Invalid Exif data: Invalid segment size.');
28068 // Check for the two null bytes:
28069 if (dataView.getUint16(offset + 8) !== 0x0000) {
28070 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28073 // Check the byte alignment:
28074 switch (dataView.getUint16(tiffOffset)) {
28076 littleEndian = true;
28079 littleEndian = false;
28082 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28085 // Check for the TIFF tag marker (0x002A):
28086 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28087 Roo.log('Invalid Exif data: Missing TIFF marker.');
28090 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28091 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28093 this.parseExifTags(
28096 tiffOffset + dirOffset,
28101 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28106 if (dirOffset + 6 > dataView.byteLength) {
28107 Roo.log('Invalid Exif data: Invalid directory offset.');
28110 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28111 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28112 if (dirEndOffset + 4 > dataView.byteLength) {
28113 Roo.log('Invalid Exif data: Invalid directory size.');
28116 for (i = 0; i < tagsNumber; i += 1) {
28120 dirOffset + 2 + 12 * i, // tag offset
28124 // Return the offset to the next directory:
28125 return dataView.getUint32(dirEndOffset, littleEndian);
28128 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28130 var tag = dataView.getUint16(offset, littleEndian);
28132 this.exif[tag] = this.getExifValue(
28136 dataView.getUint16(offset + 2, littleEndian), // tag type
28137 dataView.getUint32(offset + 4, littleEndian), // tag length
28142 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28144 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28153 Roo.log('Invalid Exif data: Invalid tag type.');
28157 tagSize = tagType.size * length;
28158 // Determine if the value is contained in the dataOffset bytes,
28159 // or if the value at the dataOffset is a pointer to the actual data:
28160 dataOffset = tagSize > 4 ?
28161 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28162 if (dataOffset + tagSize > dataView.byteLength) {
28163 Roo.log('Invalid Exif data: Invalid data offset.');
28166 if (length === 1) {
28167 return tagType.getValue(dataView, dataOffset, littleEndian);
28170 for (i = 0; i < length; i += 1) {
28171 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28174 if (tagType.ascii) {
28176 // Concatenate the chars:
28177 for (i = 0; i < values.length; i += 1) {
28179 // Ignore the terminating NULL byte(s):
28180 if (c === '\u0000') {
28192 Roo.apply(Roo.bootstrap.UploadCropbox, {
28194 'Orientation': 0x0112
28198 1: 0, //'top-left',
28200 3: 180, //'bottom-right',
28201 // 4: 'bottom-left',
28203 6: 90, //'right-top',
28204 // 7: 'right-bottom',
28205 8: 270 //'left-bottom'
28209 // byte, 8-bit unsigned int:
28211 getValue: function (dataView, dataOffset) {
28212 return dataView.getUint8(dataOffset);
28216 // ascii, 8-bit byte:
28218 getValue: function (dataView, dataOffset) {
28219 return String.fromCharCode(dataView.getUint8(dataOffset));
28224 // short, 16 bit int:
28226 getValue: function (dataView, dataOffset, littleEndian) {
28227 return dataView.getUint16(dataOffset, littleEndian);
28231 // long, 32 bit int:
28233 getValue: function (dataView, dataOffset, littleEndian) {
28234 return dataView.getUint32(dataOffset, littleEndian);
28238 // rational = two long values, first is numerator, second is denominator:
28240 getValue: function (dataView, dataOffset, littleEndian) {
28241 return dataView.getUint32(dataOffset, littleEndian) /
28242 dataView.getUint32(dataOffset + 4, littleEndian);
28246 // slong, 32 bit signed int:
28248 getValue: function (dataView, dataOffset, littleEndian) {
28249 return dataView.getInt32(dataOffset, littleEndian);
28253 // srational, two slongs, first is numerator, second is denominator:
28255 getValue: function (dataView, dataOffset, littleEndian) {
28256 return dataView.getInt32(dataOffset, littleEndian) /
28257 dataView.getInt32(dataOffset + 4, littleEndian);
28267 cls : 'btn-group roo-upload-cropbox-rotate-left',
28268 action : 'rotate-left',
28272 cls : 'btn btn-default',
28273 html : '<i class="fa fa-undo"></i>'
28279 cls : 'btn-group roo-upload-cropbox-picture',
28280 action : 'picture',
28284 cls : 'btn btn-default',
28285 html : '<i class="fa fa-picture-o"></i>'
28291 cls : 'btn-group roo-upload-cropbox-rotate-right',
28292 action : 'rotate-right',
28296 cls : 'btn btn-default',
28297 html : '<i class="fa fa-repeat"></i>'
28305 cls : 'btn-group roo-upload-cropbox-rotate-left',
28306 action : 'rotate-left',
28310 cls : 'btn btn-default',
28311 html : '<i class="fa fa-undo"></i>'
28317 cls : 'btn-group roo-upload-cropbox-download',
28318 action : 'download',
28322 cls : 'btn btn-default',
28323 html : '<i class="fa fa-download"></i>'
28329 cls : 'btn-group roo-upload-cropbox-crop',
28334 cls : 'btn btn-default',
28335 html : '<i class="fa fa-crop"></i>'
28341 cls : 'btn-group roo-upload-cropbox-trash',
28346 cls : 'btn btn-default',
28347 html : '<i class="fa fa-trash"></i>'
28353 cls : 'btn-group roo-upload-cropbox-rotate-right',
28354 action : 'rotate-right',
28358 cls : 'btn btn-default',
28359 html : '<i class="fa fa-repeat"></i>'
28367 cls : 'btn-group roo-upload-cropbox-rotate-left',
28368 action : 'rotate-left',
28372 cls : 'btn btn-default',
28373 html : '<i class="fa fa-undo"></i>'
28379 cls : 'btn-group roo-upload-cropbox-rotate-right',
28380 action : 'rotate-right',
28384 cls : 'btn btn-default',
28385 html : '<i class="fa fa-repeat"></i>'
28398 * @class Roo.bootstrap.DocumentManager
28399 * @extends Roo.bootstrap.Component
28400 * Bootstrap DocumentManager class
28401 * @cfg {String} paramName default 'imageUpload'
28402 * @cfg {String} toolTipName default 'filename'
28403 * @cfg {String} method default POST
28404 * @cfg {String} url action url
28405 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28406 * @cfg {Boolean} multiple multiple upload default true
28407 * @cfg {Number} thumbSize default 300
28408 * @cfg {String} fieldLabel
28409 * @cfg {Number} labelWidth default 4
28410 * @cfg {String} labelAlign (left|top) default left
28411 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28412 * @cfg {Number} labellg set the width of label (1-12)
28413 * @cfg {Number} labelmd set the width of label (1-12)
28414 * @cfg {Number} labelsm set the width of label (1-12)
28415 * @cfg {Number} labelxs set the width of label (1-12)
28418 * Create a new DocumentManager
28419 * @param {Object} config The config object
28422 Roo.bootstrap.DocumentManager = function(config){
28423 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28426 this.delegates = [];
28431 * Fire when initial the DocumentManager
28432 * @param {Roo.bootstrap.DocumentManager} this
28437 * inspect selected file
28438 * @param {Roo.bootstrap.DocumentManager} this
28439 * @param {File} file
28444 * Fire when xhr load exception
28445 * @param {Roo.bootstrap.DocumentManager} this
28446 * @param {XMLHttpRequest} xhr
28448 "exception" : true,
28450 * @event afterupload
28451 * Fire when xhr load exception
28452 * @param {Roo.bootstrap.DocumentManager} this
28453 * @param {XMLHttpRequest} xhr
28455 "afterupload" : true,
28458 * prepare the form data
28459 * @param {Roo.bootstrap.DocumentManager} this
28460 * @param {Object} formData
28465 * Fire when remove the file
28466 * @param {Roo.bootstrap.DocumentManager} this
28467 * @param {Object} file
28472 * Fire after refresh the file
28473 * @param {Roo.bootstrap.DocumentManager} this
28478 * Fire after click the image
28479 * @param {Roo.bootstrap.DocumentManager} this
28480 * @param {Object} file
28485 * Fire when upload a image and editable set to true
28486 * @param {Roo.bootstrap.DocumentManager} this
28487 * @param {Object} file
28491 * @event beforeselectfile
28492 * Fire before select file
28493 * @param {Roo.bootstrap.DocumentManager} this
28495 "beforeselectfile" : true,
28498 * Fire before process file
28499 * @param {Roo.bootstrap.DocumentManager} this
28500 * @param {Object} file
28504 * @event previewrendered
28505 * Fire when preview rendered
28506 * @param {Roo.bootstrap.DocumentManager} this
28507 * @param {Object} file
28509 "previewrendered" : true
28514 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28523 paramName : 'imageUpload',
28524 toolTipName : 'filename',
28527 labelAlign : 'left',
28537 getAutoCreate : function()
28539 var managerWidget = {
28541 cls : 'roo-document-manager',
28545 cls : 'roo-document-manager-selector',
28550 cls : 'roo-document-manager-uploader',
28554 cls : 'roo-document-manager-upload-btn',
28555 html : '<i class="fa fa-plus"></i>'
28566 cls : 'column col-md-12',
28571 if(this.fieldLabel.length){
28576 cls : 'column col-md-12',
28577 html : this.fieldLabel
28581 cls : 'column col-md-12',
28586 if(this.labelAlign == 'left'){
28591 html : this.fieldLabel
28600 if(this.labelWidth > 12){
28601 content[0].style = "width: " + this.labelWidth + 'px';
28604 if(this.labelWidth < 13 && this.labelmd == 0){
28605 this.labelmd = this.labelWidth;
28608 if(this.labellg > 0){
28609 content[0].cls += ' col-lg-' + this.labellg;
28610 content[1].cls += ' col-lg-' + (12 - this.labellg);
28613 if(this.labelmd > 0){
28614 content[0].cls += ' col-md-' + this.labelmd;
28615 content[1].cls += ' col-md-' + (12 - this.labelmd);
28618 if(this.labelsm > 0){
28619 content[0].cls += ' col-sm-' + this.labelsm;
28620 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28623 if(this.labelxs > 0){
28624 content[0].cls += ' col-xs-' + this.labelxs;
28625 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28633 cls : 'row clearfix',
28641 initEvents : function()
28643 this.managerEl = this.el.select('.roo-document-manager', true).first();
28644 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28646 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28647 this.selectorEl.hide();
28650 this.selectorEl.attr('multiple', 'multiple');
28653 this.selectorEl.on('change', this.onFileSelected, this);
28655 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28656 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28658 this.uploader.on('click', this.onUploaderClick, this);
28660 this.renderProgressDialog();
28664 window.addEventListener("resize", function() { _this.refresh(); } );
28666 this.fireEvent('initial', this);
28669 renderProgressDialog : function()
28673 this.progressDialog = new Roo.bootstrap.Modal({
28674 cls : 'roo-document-manager-progress-dialog',
28675 allow_close : false,
28685 btnclick : function() {
28686 _this.uploadCancel();
28692 this.progressDialog.render(Roo.get(document.body));
28694 this.progress = new Roo.bootstrap.Progress({
28695 cls : 'roo-document-manager-progress',
28700 this.progress.render(this.progressDialog.getChildContainer());
28702 this.progressBar = new Roo.bootstrap.ProgressBar({
28703 cls : 'roo-document-manager-progress-bar',
28706 aria_valuemax : 12,
28710 this.progressBar.render(this.progress.getChildContainer());
28713 onUploaderClick : function(e)
28715 e.preventDefault();
28717 if(this.fireEvent('beforeselectfile', this) != false){
28718 this.selectorEl.dom.click();
28723 onFileSelected : function(e)
28725 e.preventDefault();
28727 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28731 Roo.each(this.selectorEl.dom.files, function(file){
28732 if(this.fireEvent('inspect', this, file) != false){
28733 this.files.push(file);
28743 this.selectorEl.dom.value = '';
28745 if(!this.files || !this.files.length){
28749 if(this.boxes > 0 && this.files.length > this.boxes){
28750 this.files = this.files.slice(0, this.boxes);
28753 this.uploader.show();
28755 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28756 this.uploader.hide();
28765 Roo.each(this.files, function(file){
28767 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28768 var f = this.renderPreview(file);
28773 if(file.type.indexOf('image') != -1){
28774 this.delegates.push(
28776 _this.process(file);
28777 }).createDelegate(this)
28785 _this.process(file);
28786 }).createDelegate(this)
28791 this.files = files;
28793 this.delegates = this.delegates.concat(docs);
28795 if(!this.delegates.length){
28800 this.progressBar.aria_valuemax = this.delegates.length;
28807 arrange : function()
28809 if(!this.delegates.length){
28810 this.progressDialog.hide();
28815 var delegate = this.delegates.shift();
28817 this.progressDialog.show();
28819 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28821 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28826 refresh : function()
28828 this.uploader.show();
28830 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28831 this.uploader.hide();
28834 Roo.isTouch ? this.closable(false) : this.closable(true);
28836 this.fireEvent('refresh', this);
28839 onRemove : function(e, el, o)
28841 e.preventDefault();
28843 this.fireEvent('remove', this, o);
28847 remove : function(o)
28851 Roo.each(this.files, function(file){
28852 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28861 this.files = files;
28868 Roo.each(this.files, function(file){
28873 file.target.remove();
28882 onClick : function(e, el, o)
28884 e.preventDefault();
28886 this.fireEvent('click', this, o);
28890 closable : function(closable)
28892 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28894 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28906 xhrOnLoad : function(xhr)
28908 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28912 if (xhr.readyState !== 4) {
28914 this.fireEvent('exception', this, xhr);
28918 var response = Roo.decode(xhr.responseText);
28920 if(!response.success){
28922 this.fireEvent('exception', this, xhr);
28926 var file = this.renderPreview(response.data);
28928 this.files.push(file);
28932 this.fireEvent('afterupload', this, xhr);
28936 xhrOnError : function(xhr)
28938 Roo.log('xhr on error');
28940 var response = Roo.decode(xhr.responseText);
28947 process : function(file)
28949 if(this.fireEvent('process', this, file) !== false){
28950 if(this.editable && file.type.indexOf('image') != -1){
28951 this.fireEvent('edit', this, file);
28955 this.uploadStart(file, false);
28962 uploadStart : function(file, crop)
28964 this.xhr = new XMLHttpRequest();
28966 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28971 file.xhr = this.xhr;
28973 this.managerEl.createChild({
28975 cls : 'roo-document-manager-loading',
28979 tooltip : file.name,
28980 cls : 'roo-document-manager-thumb',
28981 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28987 this.xhr.open(this.method, this.url, true);
28990 "Accept": "application/json",
28991 "Cache-Control": "no-cache",
28992 "X-Requested-With": "XMLHttpRequest"
28995 for (var headerName in headers) {
28996 var headerValue = headers[headerName];
28998 this.xhr.setRequestHeader(headerName, headerValue);
29004 this.xhr.onload = function()
29006 _this.xhrOnLoad(_this.xhr);
29009 this.xhr.onerror = function()
29011 _this.xhrOnError(_this.xhr);
29014 var formData = new FormData();
29016 formData.append('returnHTML', 'NO');
29019 formData.append('crop', crop);
29022 formData.append(this.paramName, file, file.name);
29029 if(this.fireEvent('prepare', this, formData, options) != false){
29031 if(options.manually){
29035 this.xhr.send(formData);
29039 this.uploadCancel();
29042 uploadCancel : function()
29048 this.delegates = [];
29050 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29057 renderPreview : function(file)
29059 if(typeof(file.target) != 'undefined' && file.target){
29063 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29065 var previewEl = this.managerEl.createChild({
29067 cls : 'roo-document-manager-preview',
29071 tooltip : file[this.toolTipName],
29072 cls : 'roo-document-manager-thumb',
29073 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29078 html : '<i class="fa fa-times-circle"></i>'
29083 var close = previewEl.select('button.close', true).first();
29085 close.on('click', this.onRemove, this, file);
29087 file.target = previewEl;
29089 var image = previewEl.select('img', true).first();
29093 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29095 image.on('click', this.onClick, this, file);
29097 this.fireEvent('previewrendered', this, file);
29103 onPreviewLoad : function(file, image)
29105 if(typeof(file.target) == 'undefined' || !file.target){
29109 var width = image.dom.naturalWidth || image.dom.width;
29110 var height = image.dom.naturalHeight || image.dom.height;
29112 if(width > height){
29113 file.target.addClass('wide');
29117 file.target.addClass('tall');
29122 uploadFromSource : function(file, crop)
29124 this.xhr = new XMLHttpRequest();
29126 this.managerEl.createChild({
29128 cls : 'roo-document-manager-loading',
29132 tooltip : file.name,
29133 cls : 'roo-document-manager-thumb',
29134 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29140 this.xhr.open(this.method, this.url, true);
29143 "Accept": "application/json",
29144 "Cache-Control": "no-cache",
29145 "X-Requested-With": "XMLHttpRequest"
29148 for (var headerName in headers) {
29149 var headerValue = headers[headerName];
29151 this.xhr.setRequestHeader(headerName, headerValue);
29157 this.xhr.onload = function()
29159 _this.xhrOnLoad(_this.xhr);
29162 this.xhr.onerror = function()
29164 _this.xhrOnError(_this.xhr);
29167 var formData = new FormData();
29169 formData.append('returnHTML', 'NO');
29171 formData.append('crop', crop);
29173 if(typeof(file.filename) != 'undefined'){
29174 formData.append('filename', file.filename);
29177 if(typeof(file.mimetype) != 'undefined'){
29178 formData.append('mimetype', file.mimetype);
29183 if(this.fireEvent('prepare', this, formData) != false){
29184 this.xhr.send(formData);
29194 * @class Roo.bootstrap.DocumentViewer
29195 * @extends Roo.bootstrap.Component
29196 * Bootstrap DocumentViewer class
29197 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29198 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29201 * Create a new DocumentViewer
29202 * @param {Object} config The config object
29205 Roo.bootstrap.DocumentViewer = function(config){
29206 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29211 * Fire after initEvent
29212 * @param {Roo.bootstrap.DocumentViewer} this
29218 * @param {Roo.bootstrap.DocumentViewer} this
29223 * Fire after download button
29224 * @param {Roo.bootstrap.DocumentViewer} this
29229 * Fire after trash button
29230 * @param {Roo.bootstrap.DocumentViewer} this
29237 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29239 showDownload : true,
29243 getAutoCreate : function()
29247 cls : 'roo-document-viewer',
29251 cls : 'roo-document-viewer-body',
29255 cls : 'roo-document-viewer-thumb',
29259 cls : 'roo-document-viewer-image'
29267 cls : 'roo-document-viewer-footer',
29270 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29274 cls : 'btn-group roo-document-viewer-download',
29278 cls : 'btn btn-default',
29279 html : '<i class="fa fa-download"></i>'
29285 cls : 'btn-group roo-document-viewer-trash',
29289 cls : 'btn btn-default',
29290 html : '<i class="fa fa-trash"></i>'
29303 initEvents : function()
29305 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29306 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29308 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29309 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29311 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29312 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29314 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29315 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29317 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29318 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29320 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29321 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29323 this.bodyEl.on('click', this.onClick, this);
29324 this.downloadBtn.on('click', this.onDownload, this);
29325 this.trashBtn.on('click', this.onTrash, this);
29327 this.downloadBtn.hide();
29328 this.trashBtn.hide();
29330 if(this.showDownload){
29331 this.downloadBtn.show();
29334 if(this.showTrash){
29335 this.trashBtn.show();
29338 if(!this.showDownload && !this.showTrash) {
29339 this.footerEl.hide();
29344 initial : function()
29346 this.fireEvent('initial', this);
29350 onClick : function(e)
29352 e.preventDefault();
29354 this.fireEvent('click', this);
29357 onDownload : function(e)
29359 e.preventDefault();
29361 this.fireEvent('download', this);
29364 onTrash : function(e)
29366 e.preventDefault();
29368 this.fireEvent('trash', this);
29380 * @class Roo.bootstrap.NavProgressBar
29381 * @extends Roo.bootstrap.Component
29382 * Bootstrap NavProgressBar class
29385 * Create a new nav progress bar
29386 * @param {Object} config The config object
29389 Roo.bootstrap.NavProgressBar = function(config){
29390 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29392 this.bullets = this.bullets || [];
29394 // Roo.bootstrap.NavProgressBar.register(this);
29398 * Fires when the active item changes
29399 * @param {Roo.bootstrap.NavProgressBar} this
29400 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29401 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29408 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29413 getAutoCreate : function()
29415 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29419 cls : 'roo-navigation-bar-group',
29423 cls : 'roo-navigation-top-bar'
29427 cls : 'roo-navigation-bullets-bar',
29431 cls : 'roo-navigation-bar'
29438 cls : 'roo-navigation-bottom-bar'
29448 initEvents: function()
29453 onRender : function(ct, position)
29455 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29457 if(this.bullets.length){
29458 Roo.each(this.bullets, function(b){
29467 addItem : function(cfg)
29469 var item = new Roo.bootstrap.NavProgressItem(cfg);
29471 item.parentId = this.id;
29472 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29475 var top = new Roo.bootstrap.Element({
29477 cls : 'roo-navigation-bar-text'
29480 var bottom = new Roo.bootstrap.Element({
29482 cls : 'roo-navigation-bar-text'
29485 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29486 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29488 var topText = new Roo.bootstrap.Element({
29490 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29493 var bottomText = new Roo.bootstrap.Element({
29495 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29498 topText.onRender(top.el, null);
29499 bottomText.onRender(bottom.el, null);
29502 item.bottomEl = bottom;
29505 this.barItems.push(item);
29510 getActive : function()
29512 var active = false;
29514 Roo.each(this.barItems, function(v){
29516 if (!v.isActive()) {
29528 setActiveItem : function(item)
29532 Roo.each(this.barItems, function(v){
29533 if (v.rid == item.rid) {
29537 if (v.isActive()) {
29538 v.setActive(false);
29543 item.setActive(true);
29545 this.fireEvent('changed', this, item, prev);
29548 getBarItem: function(rid)
29552 Roo.each(this.barItems, function(e) {
29553 if (e.rid != rid) {
29564 indexOfItem : function(item)
29568 Roo.each(this.barItems, function(v, i){
29570 if (v.rid != item.rid) {
29581 setActiveNext : function()
29583 var i = this.indexOfItem(this.getActive());
29585 if (i > this.barItems.length) {
29589 this.setActiveItem(this.barItems[i+1]);
29592 setActivePrev : function()
29594 var i = this.indexOfItem(this.getActive());
29600 this.setActiveItem(this.barItems[i-1]);
29603 format : function()
29605 if(!this.barItems.length){
29609 var width = 100 / this.barItems.length;
29611 Roo.each(this.barItems, function(i){
29612 i.el.setStyle('width', width + '%');
29613 i.topEl.el.setStyle('width', width + '%');
29614 i.bottomEl.el.setStyle('width', width + '%');
29623 * Nav Progress Item
29628 * @class Roo.bootstrap.NavProgressItem
29629 * @extends Roo.bootstrap.Component
29630 * Bootstrap NavProgressItem class
29631 * @cfg {String} rid the reference id
29632 * @cfg {Boolean} active (true|false) Is item active default false
29633 * @cfg {Boolean} disabled (true|false) Is item active default false
29634 * @cfg {String} html
29635 * @cfg {String} position (top|bottom) text position default bottom
29636 * @cfg {String} icon show icon instead of number
29639 * Create a new NavProgressItem
29640 * @param {Object} config The config object
29642 Roo.bootstrap.NavProgressItem = function(config){
29643 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29648 * The raw click event for the entire grid.
29649 * @param {Roo.bootstrap.NavProgressItem} this
29650 * @param {Roo.EventObject} e
29657 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29663 position : 'bottom',
29666 getAutoCreate : function()
29668 var iconCls = 'roo-navigation-bar-item-icon';
29670 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29674 cls: 'roo-navigation-bar-item',
29684 cfg.cls += ' active';
29687 cfg.cls += ' disabled';
29693 disable : function()
29695 this.setDisabled(true);
29698 enable : function()
29700 this.setDisabled(false);
29703 initEvents: function()
29705 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29707 this.iconEl.on('click', this.onClick, this);
29710 onClick : function(e)
29712 e.preventDefault();
29718 if(this.fireEvent('click', this, e) === false){
29722 this.parent().setActiveItem(this);
29725 isActive: function ()
29727 return this.active;
29730 setActive : function(state)
29732 if(this.active == state){
29736 this.active = state;
29739 this.el.addClass('active');
29743 this.el.removeClass('active');
29748 setDisabled : function(state)
29750 if(this.disabled == state){
29754 this.disabled = state;
29757 this.el.addClass('disabled');
29761 this.el.removeClass('disabled');
29764 tooltipEl : function()
29766 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29779 * @class Roo.bootstrap.FieldLabel
29780 * @extends Roo.bootstrap.Component
29781 * Bootstrap FieldLabel class
29782 * @cfg {String} html contents of the element
29783 * @cfg {String} tag tag of the element default label
29784 * @cfg {String} cls class of the element
29785 * @cfg {String} target label target
29786 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29787 * @cfg {String} invalidClass default "text-warning"
29788 * @cfg {String} validClass default "text-success"
29789 * @cfg {String} iconTooltip default "This field is required"
29790 * @cfg {String} indicatorpos (left|right) default left
29793 * Create a new FieldLabel
29794 * @param {Object} config The config object
29797 Roo.bootstrap.FieldLabel = function(config){
29798 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29803 * Fires after the field has been marked as invalid.
29804 * @param {Roo.form.FieldLabel} this
29805 * @param {String} msg The validation message
29810 * Fires after the field has been validated with no errors.
29811 * @param {Roo.form.FieldLabel} this
29817 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29824 invalidClass : 'has-warning',
29825 validClass : 'has-success',
29826 iconTooltip : 'This field is required',
29827 indicatorpos : 'left',
29829 getAutoCreate : function(){
29833 cls : 'roo-bootstrap-field-label ' + this.cls,
29838 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29839 tooltip : this.iconTooltip
29848 if(this.indicatorpos == 'right'){
29851 cls : 'roo-bootstrap-field-label ' + this.cls,
29860 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29861 tooltip : this.iconTooltip
29870 initEvents: function()
29872 Roo.bootstrap.Element.superclass.initEvents.call(this);
29874 this.indicator = this.indicatorEl();
29876 if(this.indicator){
29877 this.indicator.removeClass('visible');
29878 this.indicator.addClass('invisible');
29881 Roo.bootstrap.FieldLabel.register(this);
29884 indicatorEl : function()
29886 var indicator = this.el.select('i.roo-required-indicator',true).first();
29897 * Mark this field as valid
29899 markValid : function()
29901 if(this.indicator){
29902 this.indicator.removeClass('visible');
29903 this.indicator.addClass('invisible');
29906 this.el.removeClass(this.invalidClass);
29908 this.el.addClass(this.validClass);
29910 this.fireEvent('valid', this);
29914 * Mark this field as invalid
29915 * @param {String} msg The validation message
29917 markInvalid : function(msg)
29919 if(this.indicator){
29920 this.indicator.removeClass('invisible');
29921 this.indicator.addClass('visible');
29924 this.el.removeClass(this.validClass);
29926 this.el.addClass(this.invalidClass);
29928 this.fireEvent('invalid', this, msg);
29934 Roo.apply(Roo.bootstrap.FieldLabel, {
29939 * register a FieldLabel Group
29940 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29942 register : function(label)
29944 if(this.groups.hasOwnProperty(label.target)){
29948 this.groups[label.target] = label;
29952 * fetch a FieldLabel Group based on the target
29953 * @param {string} target
29954 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29956 get: function(target) {
29957 if (typeof(this.groups[target]) == 'undefined') {
29961 return this.groups[target] ;
29970 * page DateSplitField.
29976 * @class Roo.bootstrap.DateSplitField
29977 * @extends Roo.bootstrap.Component
29978 * Bootstrap DateSplitField class
29979 * @cfg {string} fieldLabel - the label associated
29980 * @cfg {Number} labelWidth set the width of label (0-12)
29981 * @cfg {String} labelAlign (top|left)
29982 * @cfg {Boolean} dayAllowBlank (true|false) default false
29983 * @cfg {Boolean} monthAllowBlank (true|false) default false
29984 * @cfg {Boolean} yearAllowBlank (true|false) default false
29985 * @cfg {string} dayPlaceholder
29986 * @cfg {string} monthPlaceholder
29987 * @cfg {string} yearPlaceholder
29988 * @cfg {string} dayFormat default 'd'
29989 * @cfg {string} monthFormat default 'm'
29990 * @cfg {string} yearFormat default 'Y'
29991 * @cfg {Number} labellg set the width of label (1-12)
29992 * @cfg {Number} labelmd set the width of label (1-12)
29993 * @cfg {Number} labelsm set the width of label (1-12)
29994 * @cfg {Number} labelxs set the width of label (1-12)
29998 * Create a new DateSplitField
29999 * @param {Object} config The config object
30002 Roo.bootstrap.DateSplitField = function(config){
30003 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30009 * getting the data of years
30010 * @param {Roo.bootstrap.DateSplitField} this
30011 * @param {Object} years
30016 * getting the data of days
30017 * @param {Roo.bootstrap.DateSplitField} this
30018 * @param {Object} days
30023 * Fires after the field has been marked as invalid.
30024 * @param {Roo.form.Field} this
30025 * @param {String} msg The validation message
30030 * Fires after the field has been validated with no errors.
30031 * @param {Roo.form.Field} this
30037 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30040 labelAlign : 'top',
30042 dayAllowBlank : false,
30043 monthAllowBlank : false,
30044 yearAllowBlank : false,
30045 dayPlaceholder : '',
30046 monthPlaceholder : '',
30047 yearPlaceholder : '',
30051 isFormField : true,
30057 getAutoCreate : function()
30061 cls : 'row roo-date-split-field-group',
30066 cls : 'form-hidden-field roo-date-split-field-group-value',
30072 var labelCls = 'col-md-12';
30073 var contentCls = 'col-md-4';
30075 if(this.fieldLabel){
30079 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30083 html : this.fieldLabel
30088 if(this.labelAlign == 'left'){
30090 if(this.labelWidth > 12){
30091 label.style = "width: " + this.labelWidth + 'px';
30094 if(this.labelWidth < 13 && this.labelmd == 0){
30095 this.labelmd = this.labelWidth;
30098 if(this.labellg > 0){
30099 labelCls = ' col-lg-' + this.labellg;
30100 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30103 if(this.labelmd > 0){
30104 labelCls = ' col-md-' + this.labelmd;
30105 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30108 if(this.labelsm > 0){
30109 labelCls = ' col-sm-' + this.labelsm;
30110 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30113 if(this.labelxs > 0){
30114 labelCls = ' col-xs-' + this.labelxs;
30115 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30119 label.cls += ' ' + labelCls;
30121 cfg.cn.push(label);
30124 Roo.each(['day', 'month', 'year'], function(t){
30127 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30134 inputEl: function ()
30136 return this.el.select('.roo-date-split-field-group-value', true).first();
30139 onRender : function(ct, position)
30143 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30145 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30147 this.dayField = new Roo.bootstrap.ComboBox({
30148 allowBlank : this.dayAllowBlank,
30149 alwaysQuery : true,
30150 displayField : 'value',
30153 forceSelection : true,
30155 placeholder : this.dayPlaceholder,
30156 selectOnFocus : true,
30157 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30158 triggerAction : 'all',
30160 valueField : 'value',
30161 store : new Roo.data.SimpleStore({
30162 data : (function() {
30164 _this.fireEvent('days', _this, days);
30167 fields : [ 'value' ]
30170 select : function (_self, record, index)
30172 _this.setValue(_this.getValue());
30177 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30179 this.monthField = new Roo.bootstrap.MonthField({
30180 after : '<i class=\"fa fa-calendar\"></i>',
30181 allowBlank : this.monthAllowBlank,
30182 placeholder : this.monthPlaceholder,
30185 render : function (_self)
30187 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30188 e.preventDefault();
30192 select : function (_self, oldvalue, newvalue)
30194 _this.setValue(_this.getValue());
30199 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30201 this.yearField = new Roo.bootstrap.ComboBox({
30202 allowBlank : this.yearAllowBlank,
30203 alwaysQuery : true,
30204 displayField : 'value',
30207 forceSelection : true,
30209 placeholder : this.yearPlaceholder,
30210 selectOnFocus : true,
30211 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30212 triggerAction : 'all',
30214 valueField : 'value',
30215 store : new Roo.data.SimpleStore({
30216 data : (function() {
30218 _this.fireEvent('years', _this, years);
30221 fields : [ 'value' ]
30224 select : function (_self, record, index)
30226 _this.setValue(_this.getValue());
30231 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30234 setValue : function(v, format)
30236 this.inputEl.dom.value = v;
30238 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30240 var d = Date.parseDate(v, f);
30247 this.setDay(d.format(this.dayFormat));
30248 this.setMonth(d.format(this.monthFormat));
30249 this.setYear(d.format(this.yearFormat));
30256 setDay : function(v)
30258 this.dayField.setValue(v);
30259 this.inputEl.dom.value = this.getValue();
30264 setMonth : function(v)
30266 this.monthField.setValue(v, true);
30267 this.inputEl.dom.value = this.getValue();
30272 setYear : function(v)
30274 this.yearField.setValue(v);
30275 this.inputEl.dom.value = this.getValue();
30280 getDay : function()
30282 return this.dayField.getValue();
30285 getMonth : function()
30287 return this.monthField.getValue();
30290 getYear : function()
30292 return this.yearField.getValue();
30295 getValue : function()
30297 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30299 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30309 this.inputEl.dom.value = '';
30314 validate : function()
30316 var d = this.dayField.validate();
30317 var m = this.monthField.validate();
30318 var y = this.yearField.validate();
30323 (!this.dayAllowBlank && !d) ||
30324 (!this.monthAllowBlank && !m) ||
30325 (!this.yearAllowBlank && !y)
30330 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30339 this.markInvalid();
30344 markValid : function()
30347 var label = this.el.select('label', true).first();
30348 var icon = this.el.select('i.fa-star', true).first();
30354 this.fireEvent('valid', this);
30358 * Mark this field as invalid
30359 * @param {String} msg The validation message
30361 markInvalid : function(msg)
30364 var label = this.el.select('label', true).first();
30365 var icon = this.el.select('i.fa-star', true).first();
30367 if(label && !icon){
30368 this.el.select('.roo-date-split-field-label', true).createChild({
30370 cls : 'text-danger fa fa-lg fa-star',
30371 tooltip : 'This field is required',
30372 style : 'margin-right:5px;'
30376 this.fireEvent('invalid', this, msg);
30379 clearInvalid : function()
30381 var label = this.el.select('label', true).first();
30382 var icon = this.el.select('i.fa-star', true).first();
30388 this.fireEvent('valid', this);
30391 getName: function()
30401 * http://masonry.desandro.com
30403 * The idea is to render all the bricks based on vertical width...
30405 * The original code extends 'outlayer' - we might need to use that....
30411 * @class Roo.bootstrap.LayoutMasonry
30412 * @extends Roo.bootstrap.Component
30413 * Bootstrap Layout Masonry class
30416 * Create a new Element
30417 * @param {Object} config The config object
30420 Roo.bootstrap.LayoutMasonry = function(config){
30422 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30426 Roo.bootstrap.LayoutMasonry.register(this);
30432 * Fire after layout the items
30433 * @param {Roo.bootstrap.LayoutMasonry} this
30434 * @param {Roo.EventObject} e
30441 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30444 * @cfg {Boolean} isLayoutInstant = no animation?
30446 isLayoutInstant : false, // needed?
30449 * @cfg {Number} boxWidth width of the columns
30454 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30459 * @cfg {Number} padWidth padding below box..
30464 * @cfg {Number} gutter gutter width..
30469 * @cfg {Number} maxCols maximum number of columns
30475 * @cfg {Boolean} isAutoInitial defalut true
30477 isAutoInitial : true,
30482 * @cfg {Boolean} isHorizontal defalut false
30484 isHorizontal : false,
30486 currentSize : null,
30492 bricks: null, //CompositeElement
30496 _isLayoutInited : false,
30498 // isAlternative : false, // only use for vertical layout...
30501 * @cfg {Number} alternativePadWidth padding below box..
30503 alternativePadWidth : 50,
30505 selectedBrick : [],
30507 getAutoCreate : function(){
30509 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30513 cls: 'blog-masonary-wrapper ' + this.cls,
30515 cls : 'mas-boxes masonary'
30522 getChildContainer: function( )
30524 if (this.boxesEl) {
30525 return this.boxesEl;
30528 this.boxesEl = this.el.select('.mas-boxes').first();
30530 return this.boxesEl;
30534 initEvents : function()
30538 if(this.isAutoInitial){
30539 Roo.log('hook children rendered');
30540 this.on('childrenrendered', function() {
30541 Roo.log('children rendered');
30547 initial : function()
30549 this.selectedBrick = [];
30551 this.currentSize = this.el.getBox(true);
30553 Roo.EventManager.onWindowResize(this.resize, this);
30555 if(!this.isAutoInitial){
30563 //this.layout.defer(500,this);
30567 resize : function()
30569 var cs = this.el.getBox(true);
30572 this.currentSize.width == cs.width &&
30573 this.currentSize.x == cs.x &&
30574 this.currentSize.height == cs.height &&
30575 this.currentSize.y == cs.y
30577 Roo.log("no change in with or X or Y");
30581 this.currentSize = cs;
30587 layout : function()
30589 this._resetLayout();
30591 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30593 this.layoutItems( isInstant );
30595 this._isLayoutInited = true;
30597 this.fireEvent('layout', this);
30601 _resetLayout : function()
30603 if(this.isHorizontal){
30604 this.horizontalMeasureColumns();
30608 this.verticalMeasureColumns();
30612 verticalMeasureColumns : function()
30614 this.getContainerWidth();
30616 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30617 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30621 var boxWidth = this.boxWidth + this.padWidth;
30623 if(this.containerWidth < this.boxWidth){
30624 boxWidth = this.containerWidth
30627 var containerWidth = this.containerWidth;
30629 var cols = Math.floor(containerWidth / boxWidth);
30631 this.cols = Math.max( cols, 1 );
30633 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30635 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30637 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30639 this.colWidth = boxWidth + avail - this.padWidth;
30641 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30642 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30645 horizontalMeasureColumns : function()
30647 this.getContainerWidth();
30649 var boxWidth = this.boxWidth;
30651 if(this.containerWidth < boxWidth){
30652 boxWidth = this.containerWidth;
30655 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30657 this.el.setHeight(boxWidth);
30661 getContainerWidth : function()
30663 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30666 layoutItems : function( isInstant )
30668 Roo.log(this.bricks);
30670 var items = Roo.apply([], this.bricks);
30672 if(this.isHorizontal){
30673 this._horizontalLayoutItems( items , isInstant );
30677 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30678 // this._verticalAlternativeLayoutItems( items , isInstant );
30682 this._verticalLayoutItems( items , isInstant );
30686 _verticalLayoutItems : function ( items , isInstant)
30688 if ( !items || !items.length ) {
30693 ['xs', 'xs', 'xs', 'tall'],
30694 ['xs', 'xs', 'tall'],
30695 ['xs', 'xs', 'sm'],
30696 ['xs', 'xs', 'xs'],
30702 ['sm', 'xs', 'xs'],
30706 ['tall', 'xs', 'xs', 'xs'],
30707 ['tall', 'xs', 'xs'],
30719 Roo.each(items, function(item, k){
30721 switch (item.size) {
30722 // these layouts take up a full box,
30733 boxes.push([item]);
30756 var filterPattern = function(box, length)
30764 var pattern = box.slice(0, length);
30768 Roo.each(pattern, function(i){
30769 format.push(i.size);
30772 Roo.each(standard, function(s){
30774 if(String(s) != String(format)){
30783 if(!match && length == 1){
30788 filterPattern(box, length - 1);
30792 queue.push(pattern);
30794 box = box.slice(length, box.length);
30796 filterPattern(box, 4);
30802 Roo.each(boxes, function(box, k){
30808 if(box.length == 1){
30813 filterPattern(box, 4);
30817 this._processVerticalLayoutQueue( queue, isInstant );
30821 // _verticalAlternativeLayoutItems : function( items , isInstant )
30823 // if ( !items || !items.length ) {
30827 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30831 _horizontalLayoutItems : function ( items , isInstant)
30833 if ( !items || !items.length || items.length < 3) {
30839 var eItems = items.slice(0, 3);
30841 items = items.slice(3, items.length);
30844 ['xs', 'xs', 'xs', 'wide'],
30845 ['xs', 'xs', 'wide'],
30846 ['xs', 'xs', 'sm'],
30847 ['xs', 'xs', 'xs'],
30853 ['sm', 'xs', 'xs'],
30857 ['wide', 'xs', 'xs', 'xs'],
30858 ['wide', 'xs', 'xs'],
30871 Roo.each(items, function(item, k){
30873 switch (item.size) {
30884 boxes.push([item]);
30908 var filterPattern = function(box, length)
30916 var pattern = box.slice(0, length);
30920 Roo.each(pattern, function(i){
30921 format.push(i.size);
30924 Roo.each(standard, function(s){
30926 if(String(s) != String(format)){
30935 if(!match && length == 1){
30940 filterPattern(box, length - 1);
30944 queue.push(pattern);
30946 box = box.slice(length, box.length);
30948 filterPattern(box, 4);
30954 Roo.each(boxes, function(box, k){
30960 if(box.length == 1){
30965 filterPattern(box, 4);
30972 var pos = this.el.getBox(true);
30976 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30978 var hit_end = false;
30980 Roo.each(queue, function(box){
30984 Roo.each(box, function(b){
30986 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30996 Roo.each(box, function(b){
30998 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31001 mx = Math.max(mx, b.x);
31005 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31009 Roo.each(box, function(b){
31011 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31025 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31028 /** Sets position of item in DOM
31029 * @param {Element} item
31030 * @param {Number} x - horizontal position
31031 * @param {Number} y - vertical position
31032 * @param {Boolean} isInstant - disables transitions
31034 _processVerticalLayoutQueue : function( queue, isInstant )
31036 var pos = this.el.getBox(true);
31041 for (var i = 0; i < this.cols; i++){
31045 Roo.each(queue, function(box, k){
31047 var col = k % this.cols;
31049 Roo.each(box, function(b,kk){
31051 b.el.position('absolute');
31053 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31054 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31056 if(b.size == 'md-left' || b.size == 'md-right'){
31057 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31058 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31061 b.el.setWidth(width);
31062 b.el.setHeight(height);
31064 b.el.select('iframe',true).setSize(width,height);
31068 for (var i = 0; i < this.cols; i++){
31070 if(maxY[i] < maxY[col]){
31075 col = Math.min(col, i);
31079 x = pos.x + col * (this.colWidth + this.padWidth);
31083 var positions = [];
31085 switch (box.length){
31087 positions = this.getVerticalOneBoxColPositions(x, y, box);
31090 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31093 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31096 positions = this.getVerticalFourBoxColPositions(x, y, box);
31102 Roo.each(box, function(b,kk){
31104 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31106 var sz = b.el.getSize();
31108 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31116 for (var i = 0; i < this.cols; i++){
31117 mY = Math.max(mY, maxY[i]);
31120 this.el.setHeight(mY - pos.y);
31124 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31126 // var pos = this.el.getBox(true);
31129 // var maxX = pos.right;
31131 // var maxHeight = 0;
31133 // Roo.each(items, function(item, k){
31137 // item.el.position('absolute');
31139 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31141 // item.el.setWidth(width);
31143 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31145 // item.el.setHeight(height);
31148 // item.el.setXY([x, y], isInstant ? false : true);
31150 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31153 // y = y + height + this.alternativePadWidth;
31155 // maxHeight = maxHeight + height + this.alternativePadWidth;
31159 // this.el.setHeight(maxHeight);
31163 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31165 var pos = this.el.getBox(true);
31170 var maxX = pos.right;
31172 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31174 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31176 Roo.each(queue, function(box, k){
31178 Roo.each(box, function(b, kk){
31180 b.el.position('absolute');
31182 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31183 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31185 if(b.size == 'md-left' || b.size == 'md-right'){
31186 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31187 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31190 b.el.setWidth(width);
31191 b.el.setHeight(height);
31199 var positions = [];
31201 switch (box.length){
31203 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31206 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31209 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31212 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31218 Roo.each(box, function(b,kk){
31220 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31222 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31230 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31232 Roo.each(eItems, function(b,k){
31234 b.size = (k == 0) ? 'sm' : 'xs';
31235 b.x = (k == 0) ? 2 : 1;
31236 b.y = (k == 0) ? 2 : 1;
31238 b.el.position('absolute');
31240 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31242 b.el.setWidth(width);
31244 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31246 b.el.setHeight(height);
31250 var positions = [];
31253 x : maxX - this.unitWidth * 2 - this.gutter,
31258 x : maxX - this.unitWidth,
31259 y : minY + (this.unitWidth + this.gutter) * 2
31263 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31267 Roo.each(eItems, function(b,k){
31269 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31275 getVerticalOneBoxColPositions : function(x, y, box)
31279 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31281 if(box[0].size == 'md-left'){
31285 if(box[0].size == 'md-right'){
31290 x : x + (this.unitWidth + this.gutter) * rand,
31297 getVerticalTwoBoxColPositions : function(x, y, box)
31301 if(box[0].size == 'xs'){
31305 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31309 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31323 x : x + (this.unitWidth + this.gutter) * 2,
31324 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31331 getVerticalThreeBoxColPositions : function(x, y, box)
31335 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31343 x : x + (this.unitWidth + this.gutter) * 1,
31348 x : x + (this.unitWidth + this.gutter) * 2,
31356 if(box[0].size == 'xs' && box[1].size == 'xs'){
31365 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31369 x : x + (this.unitWidth + this.gutter) * 1,
31383 x : x + (this.unitWidth + this.gutter) * 2,
31388 x : x + (this.unitWidth + this.gutter) * 2,
31389 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31396 getVerticalFourBoxColPositions : function(x, y, box)
31400 if(box[0].size == 'xs'){
31409 y : y + (this.unitHeight + this.gutter) * 1
31414 y : y + (this.unitHeight + this.gutter) * 2
31418 x : x + (this.unitWidth + this.gutter) * 1,
31432 x : x + (this.unitWidth + this.gutter) * 2,
31437 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31438 y : y + (this.unitHeight + this.gutter) * 1
31442 x : x + (this.unitWidth + this.gutter) * 2,
31443 y : y + (this.unitWidth + this.gutter) * 2
31450 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31454 if(box[0].size == 'md-left'){
31456 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31463 if(box[0].size == 'md-right'){
31465 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31466 y : minY + (this.unitWidth + this.gutter) * 1
31472 var rand = Math.floor(Math.random() * (4 - box[0].y));
31475 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31476 y : minY + (this.unitWidth + this.gutter) * rand
31483 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31487 if(box[0].size == 'xs'){
31490 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31495 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31496 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31504 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31509 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31510 y : minY + (this.unitWidth + this.gutter) * 2
31517 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31521 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31524 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31529 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31530 y : minY + (this.unitWidth + this.gutter) * 1
31534 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31535 y : minY + (this.unitWidth + this.gutter) * 2
31542 if(box[0].size == 'xs' && box[1].size == 'xs'){
31545 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31550 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31555 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31556 y : minY + (this.unitWidth + this.gutter) * 1
31564 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31569 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31570 y : minY + (this.unitWidth + this.gutter) * 2
31574 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31575 y : minY + (this.unitWidth + this.gutter) * 2
31582 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31586 if(box[0].size == 'xs'){
31589 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31594 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31599 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),
31604 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31605 y : minY + (this.unitWidth + this.gutter) * 1
31613 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31618 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31619 y : minY + (this.unitWidth + this.gutter) * 2
31623 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31624 y : minY + (this.unitWidth + this.gutter) * 2
31628 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),
31629 y : minY + (this.unitWidth + this.gutter) * 2
31637 * remove a Masonry Brick
31638 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31640 removeBrick : function(brick_id)
31646 for (var i = 0; i<this.bricks.length; i++) {
31647 if (this.bricks[i].id == brick_id) {
31648 this.bricks.splice(i,1);
31649 this.el.dom.removeChild(Roo.get(brick_id).dom);
31656 * adds a Masonry Brick
31657 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31659 addBrick : function(cfg)
31661 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31662 //this.register(cn);
31663 cn.parentId = this.id;
31664 cn.onRender(this.el, null);
31669 * register a Masonry Brick
31670 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31673 register : function(brick)
31675 this.bricks.push(brick);
31676 brick.masonryId = this.id;
31680 * clear all the Masonry Brick
31682 clearAll : function()
31685 //this.getChildContainer().dom.innerHTML = "";
31686 this.el.dom.innerHTML = '';
31689 getSelected : function()
31691 if (!this.selectedBrick) {
31695 return this.selectedBrick;
31699 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31703 * register a Masonry Layout
31704 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31707 register : function(layout)
31709 this.groups[layout.id] = layout;
31712 * fetch a Masonry Layout based on the masonry layout ID
31713 * @param {string} the masonry layout to add
31714 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31717 get: function(layout_id) {
31718 if (typeof(this.groups[layout_id]) == 'undefined') {
31721 return this.groups[layout_id] ;
31733 * http://masonry.desandro.com
31735 * The idea is to render all the bricks based on vertical width...
31737 * The original code extends 'outlayer' - we might need to use that....
31743 * @class Roo.bootstrap.LayoutMasonryAuto
31744 * @extends Roo.bootstrap.Component
31745 * Bootstrap Layout Masonry class
31748 * Create a new Element
31749 * @param {Object} config The config object
31752 Roo.bootstrap.LayoutMasonryAuto = function(config){
31753 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31756 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31759 * @cfg {Boolean} isFitWidth - resize the width..
31761 isFitWidth : false, // options..
31763 * @cfg {Boolean} isOriginLeft = left align?
31765 isOriginLeft : true,
31767 * @cfg {Boolean} isOriginTop = top align?
31769 isOriginTop : false,
31771 * @cfg {Boolean} isLayoutInstant = no animation?
31773 isLayoutInstant : false, // needed?
31775 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31777 isResizingContainer : true,
31779 * @cfg {Number} columnWidth width of the columns
31785 * @cfg {Number} maxCols maximum number of columns
31790 * @cfg {Number} padHeight padding below box..
31796 * @cfg {Boolean} isAutoInitial defalut true
31799 isAutoInitial : true,
31805 initialColumnWidth : 0,
31806 currentSize : null,
31808 colYs : null, // array.
31815 bricks: null, //CompositeElement
31816 cols : 0, // array?
31817 // element : null, // wrapped now this.el
31818 _isLayoutInited : null,
31821 getAutoCreate : function(){
31825 cls: 'blog-masonary-wrapper ' + this.cls,
31827 cls : 'mas-boxes masonary'
31834 getChildContainer: function( )
31836 if (this.boxesEl) {
31837 return this.boxesEl;
31840 this.boxesEl = this.el.select('.mas-boxes').first();
31842 return this.boxesEl;
31846 initEvents : function()
31850 if(this.isAutoInitial){
31851 Roo.log('hook children rendered');
31852 this.on('childrenrendered', function() {
31853 Roo.log('children rendered');
31860 initial : function()
31862 this.reloadItems();
31864 this.currentSize = this.el.getBox(true);
31866 /// was window resize... - let's see if this works..
31867 Roo.EventManager.onWindowResize(this.resize, this);
31869 if(!this.isAutoInitial){
31874 this.layout.defer(500,this);
31877 reloadItems: function()
31879 this.bricks = this.el.select('.masonry-brick', true);
31881 this.bricks.each(function(b) {
31882 //Roo.log(b.getSize());
31883 if (!b.attr('originalwidth')) {
31884 b.attr('originalwidth', b.getSize().width);
31889 Roo.log(this.bricks.elements.length);
31892 resize : function()
31895 var cs = this.el.getBox(true);
31897 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31898 Roo.log("no change in with or X");
31901 this.currentSize = cs;
31905 layout : function()
31908 this._resetLayout();
31909 //this._manageStamps();
31911 // don't animate first layout
31912 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31913 this.layoutItems( isInstant );
31915 // flag for initalized
31916 this._isLayoutInited = true;
31919 layoutItems : function( isInstant )
31921 //var items = this._getItemsForLayout( this.items );
31922 // original code supports filtering layout items.. we just ignore it..
31924 this._layoutItems( this.bricks , isInstant );
31926 this._postLayout();
31928 _layoutItems : function ( items , isInstant)
31930 //this.fireEvent( 'layout', this, items );
31933 if ( !items || !items.elements.length ) {
31934 // no items, emit event with empty array
31939 items.each(function(item) {
31940 Roo.log("layout item");
31942 // get x/y object from method
31943 var position = this._getItemLayoutPosition( item );
31945 position.item = item;
31946 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31947 queue.push( position );
31950 this._processLayoutQueue( queue );
31952 /** Sets position of item in DOM
31953 * @param {Element} item
31954 * @param {Number} x - horizontal position
31955 * @param {Number} y - vertical position
31956 * @param {Boolean} isInstant - disables transitions
31958 _processLayoutQueue : function( queue )
31960 for ( var i=0, len = queue.length; i < len; i++ ) {
31961 var obj = queue[i];
31962 obj.item.position('absolute');
31963 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31969 * Any logic you want to do after each layout,
31970 * i.e. size the container
31972 _postLayout : function()
31974 this.resizeContainer();
31977 resizeContainer : function()
31979 if ( !this.isResizingContainer ) {
31982 var size = this._getContainerSize();
31984 this.el.setSize(size.width,size.height);
31985 this.boxesEl.setSize(size.width,size.height);
31991 _resetLayout : function()
31993 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31994 this.colWidth = this.el.getWidth();
31995 //this.gutter = this.el.getWidth();
31997 this.measureColumns();
32003 this.colYs.push( 0 );
32009 measureColumns : function()
32011 this.getContainerWidth();
32012 // if columnWidth is 0, default to outerWidth of first item
32013 if ( !this.columnWidth ) {
32014 var firstItem = this.bricks.first();
32015 Roo.log(firstItem);
32016 this.columnWidth = this.containerWidth;
32017 if (firstItem && firstItem.attr('originalwidth') ) {
32018 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32020 // columnWidth fall back to item of first element
32021 Roo.log("set column width?");
32022 this.initialColumnWidth = this.columnWidth ;
32024 // if first elem has no width, default to size of container
32029 if (this.initialColumnWidth) {
32030 this.columnWidth = this.initialColumnWidth;
32035 // column width is fixed at the top - however if container width get's smaller we should
32038 // this bit calcs how man columns..
32040 var columnWidth = this.columnWidth += this.gutter;
32042 // calculate columns
32043 var containerWidth = this.containerWidth + this.gutter;
32045 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32046 // fix rounding errors, typically with gutters
32047 var excess = columnWidth - containerWidth % columnWidth;
32050 // if overshoot is less than a pixel, round up, otherwise floor it
32051 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32052 cols = Math[ mathMethod ]( cols );
32053 this.cols = Math.max( cols, 1 );
32054 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32056 // padding positioning..
32057 var totalColWidth = this.cols * this.columnWidth;
32058 var padavail = this.containerWidth - totalColWidth;
32059 // so for 2 columns - we need 3 'pads'
32061 var padNeeded = (1+this.cols) * this.padWidth;
32063 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32065 this.columnWidth += padExtra
32066 //this.padWidth = Math.floor(padavail / ( this.cols));
32068 // adjust colum width so that padding is fixed??
32070 // we have 3 columns ... total = width * 3
32071 // we have X left over... that should be used by
32073 //if (this.expandC) {
32081 getContainerWidth : function()
32083 /* // container is parent if fit width
32084 var container = this.isFitWidth ? this.element.parentNode : this.element;
32085 // check that this.size and size are there
32086 // IE8 triggers resize on body size change, so they might not be
32088 var size = getSize( container ); //FIXME
32089 this.containerWidth = size && size.innerWidth; //FIXME
32092 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32096 _getItemLayoutPosition : function( item ) // what is item?
32098 // we resize the item to our columnWidth..
32100 item.setWidth(this.columnWidth);
32101 item.autoBoxAdjust = false;
32103 var sz = item.getSize();
32105 // how many columns does this brick span
32106 var remainder = this.containerWidth % this.columnWidth;
32108 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32109 // round if off by 1 pixel, otherwise use ceil
32110 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32111 colSpan = Math.min( colSpan, this.cols );
32113 // normally this should be '1' as we dont' currently allow multi width columns..
32115 var colGroup = this._getColGroup( colSpan );
32116 // get the minimum Y value from the columns
32117 var minimumY = Math.min.apply( Math, colGroup );
32118 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32120 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32122 // position the brick
32124 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32125 y: this.currentSize.y + minimumY + this.padHeight
32129 // apply setHeight to necessary columns
32130 var setHeight = minimumY + sz.height + this.padHeight;
32131 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32133 var setSpan = this.cols + 1 - colGroup.length;
32134 for ( var i = 0; i < setSpan; i++ ) {
32135 this.colYs[ shortColIndex + i ] = setHeight ;
32142 * @param {Number} colSpan - number of columns the element spans
32143 * @returns {Array} colGroup
32145 _getColGroup : function( colSpan )
32147 if ( colSpan < 2 ) {
32148 // if brick spans only one column, use all the column Ys
32153 // how many different places could this brick fit horizontally
32154 var groupCount = this.cols + 1 - colSpan;
32155 // for each group potential horizontal position
32156 for ( var i = 0; i < groupCount; i++ ) {
32157 // make an array of colY values for that one group
32158 var groupColYs = this.colYs.slice( i, i + colSpan );
32159 // and get the max value of the array
32160 colGroup[i] = Math.max.apply( Math, groupColYs );
32165 _manageStamp : function( stamp )
32167 var stampSize = stamp.getSize();
32168 var offset = stamp.getBox();
32169 // get the columns that this stamp affects
32170 var firstX = this.isOriginLeft ? offset.x : offset.right;
32171 var lastX = firstX + stampSize.width;
32172 var firstCol = Math.floor( firstX / this.columnWidth );
32173 firstCol = Math.max( 0, firstCol );
32175 var lastCol = Math.floor( lastX / this.columnWidth );
32176 // lastCol should not go over if multiple of columnWidth #425
32177 lastCol -= lastX % this.columnWidth ? 0 : 1;
32178 lastCol = Math.min( this.cols - 1, lastCol );
32180 // set colYs to bottom of the stamp
32181 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32184 for ( var i = firstCol; i <= lastCol; i++ ) {
32185 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32190 _getContainerSize : function()
32192 this.maxY = Math.max.apply( Math, this.colYs );
32197 if ( this.isFitWidth ) {
32198 size.width = this._getContainerFitWidth();
32204 _getContainerFitWidth : function()
32206 var unusedCols = 0;
32207 // count unused columns
32210 if ( this.colYs[i] !== 0 ) {
32215 // fit container to columns that have been used
32216 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32219 needsResizeLayout : function()
32221 var previousWidth = this.containerWidth;
32222 this.getContainerWidth();
32223 return previousWidth !== this.containerWidth;
32238 * @class Roo.bootstrap.MasonryBrick
32239 * @extends Roo.bootstrap.Component
32240 * Bootstrap MasonryBrick class
32243 * Create a new MasonryBrick
32244 * @param {Object} config The config object
32247 Roo.bootstrap.MasonryBrick = function(config){
32249 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32251 Roo.bootstrap.MasonryBrick.register(this);
32257 * When a MasonryBrick is clcik
32258 * @param {Roo.bootstrap.MasonryBrick} this
32259 * @param {Roo.EventObject} e
32265 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32268 * @cfg {String} title
32272 * @cfg {String} html
32276 * @cfg {String} bgimage
32280 * @cfg {String} videourl
32284 * @cfg {String} cls
32288 * @cfg {String} href
32292 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32297 * @cfg {String} placetitle (center|bottom)
32302 * @cfg {Boolean} isFitContainer defalut true
32304 isFitContainer : true,
32307 * @cfg {Boolean} preventDefault defalut false
32309 preventDefault : false,
32312 * @cfg {Boolean} inverse defalut false
32314 maskInverse : false,
32316 getAutoCreate : function()
32318 if(!this.isFitContainer){
32319 return this.getSplitAutoCreate();
32322 var cls = 'masonry-brick masonry-brick-full';
32324 if(this.href.length){
32325 cls += ' masonry-brick-link';
32328 if(this.bgimage.length){
32329 cls += ' masonry-brick-image';
32332 if(this.maskInverse){
32333 cls += ' mask-inverse';
32336 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32337 cls += ' enable-mask';
32341 cls += ' masonry-' + this.size + '-brick';
32344 if(this.placetitle.length){
32346 switch (this.placetitle) {
32348 cls += ' masonry-center-title';
32351 cls += ' masonry-bottom-title';
32358 if(!this.html.length && !this.bgimage.length){
32359 cls += ' masonry-center-title';
32362 if(!this.html.length && this.bgimage.length){
32363 cls += ' masonry-bottom-title';
32368 cls += ' ' + this.cls;
32372 tag: (this.href.length) ? 'a' : 'div',
32377 cls: 'masonry-brick-mask'
32381 cls: 'masonry-brick-paragraph',
32387 if(this.href.length){
32388 cfg.href = this.href;
32391 var cn = cfg.cn[1].cn;
32393 if(this.title.length){
32396 cls: 'masonry-brick-title',
32401 if(this.html.length){
32404 cls: 'masonry-brick-text',
32409 if (!this.title.length && !this.html.length) {
32410 cfg.cn[1].cls += ' hide';
32413 if(this.bgimage.length){
32416 cls: 'masonry-brick-image-view',
32421 if(this.videourl.length){
32422 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32423 // youtube support only?
32426 cls: 'masonry-brick-image-view',
32429 allowfullscreen : true
32437 getSplitAutoCreate : function()
32439 var cls = 'masonry-brick masonry-brick-split';
32441 if(this.href.length){
32442 cls += ' masonry-brick-link';
32445 if(this.bgimage.length){
32446 cls += ' masonry-brick-image';
32450 cls += ' masonry-' + this.size + '-brick';
32453 switch (this.placetitle) {
32455 cls += ' masonry-center-title';
32458 cls += ' masonry-bottom-title';
32461 if(!this.bgimage.length){
32462 cls += ' masonry-center-title';
32465 if(this.bgimage.length){
32466 cls += ' masonry-bottom-title';
32472 cls += ' ' + this.cls;
32476 tag: (this.href.length) ? 'a' : 'div',
32481 cls: 'masonry-brick-split-head',
32485 cls: 'masonry-brick-paragraph',
32492 cls: 'masonry-brick-split-body',
32498 if(this.href.length){
32499 cfg.href = this.href;
32502 if(this.title.length){
32503 cfg.cn[0].cn[0].cn.push({
32505 cls: 'masonry-brick-title',
32510 if(this.html.length){
32511 cfg.cn[1].cn.push({
32513 cls: 'masonry-brick-text',
32518 if(this.bgimage.length){
32519 cfg.cn[0].cn.push({
32521 cls: 'masonry-brick-image-view',
32526 if(this.videourl.length){
32527 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32528 // youtube support only?
32529 cfg.cn[0].cn.cn.push({
32531 cls: 'masonry-brick-image-view',
32534 allowfullscreen : true
32541 initEvents: function()
32543 switch (this.size) {
32576 this.el.on('touchstart', this.onTouchStart, this);
32577 this.el.on('touchmove', this.onTouchMove, this);
32578 this.el.on('touchend', this.onTouchEnd, this);
32579 this.el.on('contextmenu', this.onContextMenu, this);
32581 this.el.on('mouseenter' ,this.enter, this);
32582 this.el.on('mouseleave', this.leave, this);
32583 this.el.on('click', this.onClick, this);
32586 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32587 this.parent().bricks.push(this);
32592 onClick: function(e, el)
32594 var time = this.endTimer - this.startTimer;
32595 // Roo.log(e.preventDefault());
32598 e.preventDefault();
32603 if(!this.preventDefault){
32607 e.preventDefault();
32609 if (this.activcClass != '') {
32610 this.selectBrick();
32613 this.fireEvent('click', this);
32616 enter: function(e, el)
32618 e.preventDefault();
32620 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32624 if(this.bgimage.length && this.html.length){
32625 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32629 leave: function(e, el)
32631 e.preventDefault();
32633 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32637 if(this.bgimage.length && this.html.length){
32638 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32642 onTouchStart: function(e, el)
32644 // e.preventDefault();
32646 this.touchmoved = false;
32648 if(!this.isFitContainer){
32652 if(!this.bgimage.length || !this.html.length){
32656 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32658 this.timer = new Date().getTime();
32662 onTouchMove: function(e, el)
32664 this.touchmoved = true;
32667 onContextMenu : function(e,el)
32669 e.preventDefault();
32670 e.stopPropagation();
32674 onTouchEnd: function(e, el)
32676 // e.preventDefault();
32678 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32685 if(!this.bgimage.length || !this.html.length){
32687 if(this.href.length){
32688 window.location.href = this.href;
32694 if(!this.isFitContainer){
32698 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32700 window.location.href = this.href;
32703 //selection on single brick only
32704 selectBrick : function() {
32706 if (!this.parentId) {
32710 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32711 var index = m.selectedBrick.indexOf(this.id);
32714 m.selectedBrick.splice(index,1);
32715 this.el.removeClass(this.activeClass);
32719 for(var i = 0; i < m.selectedBrick.length; i++) {
32720 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32721 b.el.removeClass(b.activeClass);
32724 m.selectedBrick = [];
32726 m.selectedBrick.push(this.id);
32727 this.el.addClass(this.activeClass);
32733 Roo.apply(Roo.bootstrap.MasonryBrick, {
32736 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32738 * register a Masonry Brick
32739 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32742 register : function(brick)
32744 //this.groups[brick.id] = brick;
32745 this.groups.add(brick.id, brick);
32748 * fetch a masonry brick based on the masonry brick ID
32749 * @param {string} the masonry brick to add
32750 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32753 get: function(brick_id)
32755 // if (typeof(this.groups[brick_id]) == 'undefined') {
32758 // return this.groups[brick_id] ;
32760 if(this.groups.key(brick_id)) {
32761 return this.groups.key(brick_id);
32779 * @class Roo.bootstrap.Brick
32780 * @extends Roo.bootstrap.Component
32781 * Bootstrap Brick class
32784 * Create a new Brick
32785 * @param {Object} config The config object
32788 Roo.bootstrap.Brick = function(config){
32789 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32795 * When a Brick is click
32796 * @param {Roo.bootstrap.Brick} this
32797 * @param {Roo.EventObject} e
32803 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32806 * @cfg {String} title
32810 * @cfg {String} html
32814 * @cfg {String} bgimage
32818 * @cfg {String} cls
32822 * @cfg {String} href
32826 * @cfg {String} video
32830 * @cfg {Boolean} square
32834 getAutoCreate : function()
32836 var cls = 'roo-brick';
32838 if(this.href.length){
32839 cls += ' roo-brick-link';
32842 if(this.bgimage.length){
32843 cls += ' roo-brick-image';
32846 if(!this.html.length && !this.bgimage.length){
32847 cls += ' roo-brick-center-title';
32850 if(!this.html.length && this.bgimage.length){
32851 cls += ' roo-brick-bottom-title';
32855 cls += ' ' + this.cls;
32859 tag: (this.href.length) ? 'a' : 'div',
32864 cls: 'roo-brick-paragraph',
32870 if(this.href.length){
32871 cfg.href = this.href;
32874 var cn = cfg.cn[0].cn;
32876 if(this.title.length){
32879 cls: 'roo-brick-title',
32884 if(this.html.length){
32887 cls: 'roo-brick-text',
32894 if(this.bgimage.length){
32897 cls: 'roo-brick-image-view',
32905 initEvents: function()
32907 if(this.title.length || this.html.length){
32908 this.el.on('mouseenter' ,this.enter, this);
32909 this.el.on('mouseleave', this.leave, this);
32912 Roo.EventManager.onWindowResize(this.resize, this);
32914 if(this.bgimage.length){
32915 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32916 this.imageEl.on('load', this.onImageLoad, this);
32923 onImageLoad : function()
32928 resize : function()
32930 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32932 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32934 if(this.bgimage.length){
32935 var image = this.el.select('.roo-brick-image-view', true).first();
32937 image.setWidth(paragraph.getWidth());
32940 image.setHeight(paragraph.getWidth());
32943 this.el.setHeight(image.getHeight());
32944 paragraph.setHeight(image.getHeight());
32950 enter: function(e, el)
32952 e.preventDefault();
32954 if(this.bgimage.length){
32955 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32956 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32960 leave: function(e, el)
32962 e.preventDefault();
32964 if(this.bgimage.length){
32965 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32966 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32982 * @class Roo.bootstrap.NumberField
32983 * @extends Roo.bootstrap.Input
32984 * Bootstrap NumberField class
32990 * Create a new NumberField
32991 * @param {Object} config The config object
32994 Roo.bootstrap.NumberField = function(config){
32995 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32998 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33001 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33003 allowDecimals : true,
33005 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33007 decimalSeparator : ".",
33009 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33011 decimalPrecision : 2,
33013 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33015 allowNegative : true,
33017 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33019 minValue : Number.NEGATIVE_INFINITY,
33021 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33023 maxValue : Number.MAX_VALUE,
33025 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33027 minText : "The minimum value for this field is {0}",
33029 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33031 maxText : "The maximum value for this field is {0}",
33033 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33034 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33036 nanText : "{0} is not a valid number",
33038 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
33042 * @cfg {Boolean} allowThousandsDelimiter (true|false) display thousands delimiter if true (e.g. "100,000") (defalut false)
33044 allowThousandsDelimiter : false,
33046 * @cfg {String} symbol of thousandsDelimiter
33048 thousandsDelimiter : ",",
33050 getAutoCreate : function()
33056 initEvents : function()
33058 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33060 var allowed = "0123456789";
33062 if(this.allowDecimals){
33063 allowed += this.decimalSeparator;
33066 if(this.allowNegative){
33070 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33072 var keyPress = function(e){
33074 var k = e.getKey();
33076 var c = e.getCharCode();
33079 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33080 allowed.indexOf(String.fromCharCode(c)) === -1
33086 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33090 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33095 this.el.on("keypress", keyPress, this);
33098 validateValue : function(value)
33101 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33105 var num = this.parseValue(value);
33108 this.markInvalid(String.format(this.nanText, value));
33112 if(num < this.minValue){
33113 this.markInvalid(String.format(this.minText, this.minValue));
33117 if(num > this.maxValue){
33118 this.markInvalid(String.format(this.maxText, this.maxValue));
33125 getValue : function()
33127 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
33130 parseValue : function(value)
33132 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33133 return isNaN(value) ? '' : value;
33136 fixPrecision : function(value)
33138 var nan = isNaN(value);
33140 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33141 return nan ? '' : value;
33143 return parseFloat(value).toFixed(this.decimalPrecision);
33146 setValue : function(v)
33148 v = this.fixPrecision(v);
33149 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
33152 decimalPrecisionFcn : function(v)
33154 return Math.floor(v);
33157 beforeBlur : function()
33163 var v = this.parseValue(this.getRawValue());
33169 addThousandsDelimiter : function(v)
33171 if(!this.allowThousandsDelimiter) {
33177 var x = v.split(".");
33181 var x2 = x.length > 1 ? "." + x[1] : "";
33183 var rgx = /(\d+)(\d{3})/;
33185 while (rgx.test(x1)) {
33186 x1 = x1.replace(rgx, "$1" + this.thousandsDelimiter + "$2");
33201 * @class Roo.bootstrap.DocumentSlider
33202 * @extends Roo.bootstrap.Component
33203 * Bootstrap DocumentSlider class
33206 * Create a new DocumentViewer
33207 * @param {Object} config The config object
33210 Roo.bootstrap.DocumentSlider = function(config){
33211 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33218 * Fire after initEvent
33219 * @param {Roo.bootstrap.DocumentSlider} this
33224 * Fire after update
33225 * @param {Roo.bootstrap.DocumentSlider} this
33231 * @param {Roo.bootstrap.DocumentSlider} this
33237 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33243 getAutoCreate : function()
33247 cls : 'roo-document-slider',
33251 cls : 'roo-document-slider-header',
33255 cls : 'roo-document-slider-header-title'
33261 cls : 'roo-document-slider-body',
33265 cls : 'roo-document-slider-prev',
33269 cls : 'fa fa-chevron-left'
33275 cls : 'roo-document-slider-thumb',
33279 cls : 'roo-document-slider-image'
33285 cls : 'roo-document-slider-next',
33289 cls : 'fa fa-chevron-right'
33301 initEvents : function()
33303 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33304 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33306 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33307 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33309 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33310 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33312 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33313 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33315 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33316 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33318 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33319 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33321 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33322 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33324 this.thumbEl.on('click', this.onClick, this);
33326 this.prevIndicator.on('click', this.prev, this);
33328 this.nextIndicator.on('click', this.next, this);
33332 initial : function()
33334 if(this.files.length){
33335 this.indicator = 1;
33339 this.fireEvent('initial', this);
33342 update : function()
33344 this.imageEl.attr('src', this.files[this.indicator - 1]);
33346 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33348 this.prevIndicator.show();
33350 if(this.indicator == 1){
33351 this.prevIndicator.hide();
33354 this.nextIndicator.show();
33356 if(this.indicator == this.files.length){
33357 this.nextIndicator.hide();
33360 this.thumbEl.scrollTo('top');
33362 this.fireEvent('update', this);
33365 onClick : function(e)
33367 e.preventDefault();
33369 this.fireEvent('click', this);
33374 e.preventDefault();
33376 this.indicator = Math.max(1, this.indicator - 1);
33383 e.preventDefault();
33385 this.indicator = Math.min(this.files.length, this.indicator + 1);
33399 * @class Roo.bootstrap.RadioSet
33400 * @extends Roo.bootstrap.Input
33401 * Bootstrap RadioSet class
33402 * @cfg {String} indicatorpos (left|right) default left
33403 * @cfg {Boolean} inline (true|false) inline the element (default true)
33404 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33406 * Create a new RadioSet
33407 * @param {Object} config The config object
33410 Roo.bootstrap.RadioSet = function(config){
33412 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33416 Roo.bootstrap.RadioSet.register(this);
33421 * Fires when the element is checked or unchecked.
33422 * @param {Roo.bootstrap.RadioSet} this This radio
33423 * @param {Roo.bootstrap.Radio} item The checked item
33430 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33438 indicatorpos : 'left',
33440 getAutoCreate : function()
33444 cls : 'roo-radio-set-label',
33448 html : this.fieldLabel
33453 if(this.indicatorpos == 'left'){
33456 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33457 tooltip : 'This field is required'
33462 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33463 tooltip : 'This field is required'
33469 cls : 'roo-radio-set-items'
33472 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33474 if (align === 'left' && this.fieldLabel.length) {
33477 cls : "roo-radio-set-right",
33483 if(this.labelWidth > 12){
33484 label.style = "width: " + this.labelWidth + 'px';
33487 if(this.labelWidth < 13 && this.labelmd == 0){
33488 this.labelmd = this.labelWidth;
33491 if(this.labellg > 0){
33492 label.cls += ' col-lg-' + this.labellg;
33493 items.cls += ' col-lg-' + (12 - this.labellg);
33496 if(this.labelmd > 0){
33497 label.cls += ' col-md-' + this.labelmd;
33498 items.cls += ' col-md-' + (12 - this.labelmd);
33501 if(this.labelsm > 0){
33502 label.cls += ' col-sm-' + this.labelsm;
33503 items.cls += ' col-sm-' + (12 - this.labelsm);
33506 if(this.labelxs > 0){
33507 label.cls += ' col-xs-' + this.labelxs;
33508 items.cls += ' col-xs-' + (12 - this.labelxs);
33514 cls : 'roo-radio-set',
33518 cls : 'roo-radio-set-input',
33521 value : this.value ? this.value : ''
33528 if(this.weight.length){
33529 cfg.cls += ' roo-radio-' + this.weight;
33533 cfg.cls += ' roo-radio-set-inline';
33537 ['xs','sm','md','lg'].map(function(size){
33538 if (settings[size]) {
33539 cfg.cls += ' col-' + size + '-' + settings[size];
33547 initEvents : function()
33549 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33550 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33552 if(!this.fieldLabel.length){
33553 this.labelEl.hide();
33556 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33557 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33559 this.indicatorEl().addClass('invisible');
33561 this.originalValue = this.getValue();
33565 inputEl: function ()
33567 return this.el.select('.roo-radio-set-input', true).first();
33570 getChildContainer : function()
33572 return this.itemsEl;
33575 register : function(item)
33577 this.radioes.push(item);
33581 validate : function()
33585 Roo.each(this.radioes, function(i){
33594 if(this.allowBlank) {
33598 if(this.disabled || valid){
33603 this.markInvalid();
33608 markValid : function()
33610 if(this.labelEl.isVisible(true)){
33611 this.indicatorEl().removeClass('visible');
33612 this.indicatorEl().addClass('invisible');
33615 this.el.removeClass([this.invalidClass, this.validClass]);
33616 this.el.addClass(this.validClass);
33618 this.fireEvent('valid', this);
33621 markInvalid : function(msg)
33623 if(this.allowBlank || this.disabled){
33627 if(this.labelEl.isVisible(true)){
33628 this.indicatorEl().removeClass('invisible');
33629 this.indicatorEl().addClass('visible');
33632 this.el.removeClass([this.invalidClass, this.validClass]);
33633 this.el.addClass(this.invalidClass);
33635 this.fireEvent('invalid', this, msg);
33639 setValue : function(v, suppressEvent)
33641 if(this.value === v){
33648 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33651 Roo.each(this.radioes, function(i){
33653 i.el.removeClass('checked');
33656 Roo.each(this.radioes, function(i){
33658 if(i.value === v || i.value.toString() === v.toString()){
33660 i.el.addClass('checked');
33662 if(suppressEvent !== true){
33663 this.fireEvent('check', this, i);
33674 clearInvalid : function(){
33676 if(!this.el || this.preventMark){
33680 this.el.removeClass([this.invalidClass]);
33682 this.fireEvent('valid', this);
33687 Roo.apply(Roo.bootstrap.RadioSet, {
33691 register : function(set)
33693 this.groups[set.name] = set;
33696 get: function(name)
33698 if (typeof(this.groups[name]) == 'undefined') {
33702 return this.groups[name] ;
33708 * Ext JS Library 1.1.1
33709 * Copyright(c) 2006-2007, Ext JS, LLC.
33711 * Originally Released Under LGPL - original licence link has changed is not relivant.
33714 * <script type="text/javascript">
33719 * @class Roo.bootstrap.SplitBar
33720 * @extends Roo.util.Observable
33721 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33725 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33726 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33727 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33728 split.minSize = 100;
33729 split.maxSize = 600;
33730 split.animate = true;
33731 split.on('moved', splitterMoved);
33734 * Create a new SplitBar
33735 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33736 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33737 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33738 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33739 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33740 position of the SplitBar).
33742 Roo.bootstrap.SplitBar = function(cfg){
33747 // dragElement : elm
33748 // resizingElement: el,
33750 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33751 // placement : Roo.bootstrap.SplitBar.LEFT ,
33752 // existingProxy ???
33755 this.el = Roo.get(cfg.dragElement, true);
33756 this.el.dom.unselectable = "on";
33758 this.resizingEl = Roo.get(cfg.resizingElement, true);
33762 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33763 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33766 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33769 * The minimum size of the resizing element. (Defaults to 0)
33775 * The maximum size of the resizing element. (Defaults to 2000)
33778 this.maxSize = 2000;
33781 * Whether to animate the transition to the new size
33784 this.animate = false;
33787 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33790 this.useShim = false;
33795 if(!cfg.existingProxy){
33797 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33799 this.proxy = Roo.get(cfg.existingProxy).dom;
33802 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33805 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33808 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33811 this.dragSpecs = {};
33814 * @private The adapter to use to positon and resize elements
33816 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33817 this.adapter.init(this);
33819 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33821 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33822 this.el.addClass("roo-splitbar-h");
33825 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33826 this.el.addClass("roo-splitbar-v");
33832 * Fires when the splitter is moved (alias for {@link #event-moved})
33833 * @param {Roo.bootstrap.SplitBar} this
33834 * @param {Number} newSize the new width or height
33839 * Fires when the splitter is moved
33840 * @param {Roo.bootstrap.SplitBar} this
33841 * @param {Number} newSize the new width or height
33845 * @event beforeresize
33846 * Fires before the splitter is dragged
33847 * @param {Roo.bootstrap.SplitBar} this
33849 "beforeresize" : true,
33851 "beforeapply" : true
33854 Roo.util.Observable.call(this);
33857 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33858 onStartProxyDrag : function(x, y){
33859 this.fireEvent("beforeresize", this);
33861 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33863 o.enableDisplayMode("block");
33864 // all splitbars share the same overlay
33865 Roo.bootstrap.SplitBar.prototype.overlay = o;
33867 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33868 this.overlay.show();
33869 Roo.get(this.proxy).setDisplayed("block");
33870 var size = this.adapter.getElementSize(this);
33871 this.activeMinSize = this.getMinimumSize();;
33872 this.activeMaxSize = this.getMaximumSize();;
33873 var c1 = size - this.activeMinSize;
33874 var c2 = Math.max(this.activeMaxSize - size, 0);
33875 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33876 this.dd.resetConstraints();
33877 this.dd.setXConstraint(
33878 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33879 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33881 this.dd.setYConstraint(0, 0);
33883 this.dd.resetConstraints();
33884 this.dd.setXConstraint(0, 0);
33885 this.dd.setYConstraint(
33886 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33887 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33890 this.dragSpecs.startSize = size;
33891 this.dragSpecs.startPoint = [x, y];
33892 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33896 * @private Called after the drag operation by the DDProxy
33898 onEndProxyDrag : function(e){
33899 Roo.get(this.proxy).setDisplayed(false);
33900 var endPoint = Roo.lib.Event.getXY(e);
33902 this.overlay.hide();
33905 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33906 newSize = this.dragSpecs.startSize +
33907 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33908 endPoint[0] - this.dragSpecs.startPoint[0] :
33909 this.dragSpecs.startPoint[0] - endPoint[0]
33912 newSize = this.dragSpecs.startSize +
33913 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33914 endPoint[1] - this.dragSpecs.startPoint[1] :
33915 this.dragSpecs.startPoint[1] - endPoint[1]
33918 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33919 if(newSize != this.dragSpecs.startSize){
33920 if(this.fireEvent('beforeapply', this, newSize) !== false){
33921 this.adapter.setElementSize(this, newSize);
33922 this.fireEvent("moved", this, newSize);
33923 this.fireEvent("resize", this, newSize);
33929 * Get the adapter this SplitBar uses
33930 * @return The adapter object
33932 getAdapter : function(){
33933 return this.adapter;
33937 * Set the adapter this SplitBar uses
33938 * @param {Object} adapter A SplitBar adapter object
33940 setAdapter : function(adapter){
33941 this.adapter = adapter;
33942 this.adapter.init(this);
33946 * Gets the minimum size for the resizing element
33947 * @return {Number} The minimum size
33949 getMinimumSize : function(){
33950 return this.minSize;
33954 * Sets the minimum size for the resizing element
33955 * @param {Number} minSize The minimum size
33957 setMinimumSize : function(minSize){
33958 this.minSize = minSize;
33962 * Gets the maximum size for the resizing element
33963 * @return {Number} The maximum size
33965 getMaximumSize : function(){
33966 return this.maxSize;
33970 * Sets the maximum size for the resizing element
33971 * @param {Number} maxSize The maximum size
33973 setMaximumSize : function(maxSize){
33974 this.maxSize = maxSize;
33978 * Sets the initialize size for the resizing element
33979 * @param {Number} size The initial size
33981 setCurrentSize : function(size){
33982 var oldAnimate = this.animate;
33983 this.animate = false;
33984 this.adapter.setElementSize(this, size);
33985 this.animate = oldAnimate;
33989 * Destroy this splitbar.
33990 * @param {Boolean} removeEl True to remove the element
33992 destroy : function(removeEl){
33994 this.shim.remove();
33997 this.proxy.parentNode.removeChild(this.proxy);
34005 * @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.
34007 Roo.bootstrap.SplitBar.createProxy = function(dir){
34008 var proxy = new Roo.Element(document.createElement("div"));
34009 proxy.unselectable();
34010 var cls = 'roo-splitbar-proxy';
34011 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34012 document.body.appendChild(proxy.dom);
34017 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34018 * Default Adapter. It assumes the splitter and resizing element are not positioned
34019 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34021 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34024 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34025 // do nothing for now
34026 init : function(s){
34030 * Called before drag operations to get the current size of the resizing element.
34031 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34033 getElementSize : function(s){
34034 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34035 return s.resizingEl.getWidth();
34037 return s.resizingEl.getHeight();
34042 * Called after drag operations to set the size of the resizing element.
34043 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34044 * @param {Number} newSize The new size to set
34045 * @param {Function} onComplete A function to be invoked when resizing is complete
34047 setElementSize : function(s, newSize, onComplete){
34048 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34050 s.resizingEl.setWidth(newSize);
34052 onComplete(s, newSize);
34055 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34060 s.resizingEl.setHeight(newSize);
34062 onComplete(s, newSize);
34065 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34072 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34073 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34074 * Adapter that moves the splitter element to align with the resized sizing element.
34075 * Used with an absolute positioned SplitBar.
34076 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34077 * document.body, make sure you assign an id to the body element.
34079 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34080 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34081 this.container = Roo.get(container);
34084 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34085 init : function(s){
34086 this.basic.init(s);
34089 getElementSize : function(s){
34090 return this.basic.getElementSize(s);
34093 setElementSize : function(s, newSize, onComplete){
34094 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34097 moveSplitter : function(s){
34098 var yes = Roo.bootstrap.SplitBar;
34099 switch(s.placement){
34101 s.el.setX(s.resizingEl.getRight());
34104 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34107 s.el.setY(s.resizingEl.getBottom());
34110 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34117 * Orientation constant - Create a vertical SplitBar
34121 Roo.bootstrap.SplitBar.VERTICAL = 1;
34124 * Orientation constant - Create a horizontal SplitBar
34128 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34131 * Placement constant - The resizing element is to the left of the splitter element
34135 Roo.bootstrap.SplitBar.LEFT = 1;
34138 * Placement constant - The resizing element is to the right of the splitter element
34142 Roo.bootstrap.SplitBar.RIGHT = 2;
34145 * Placement constant - The resizing element is positioned above the splitter element
34149 Roo.bootstrap.SplitBar.TOP = 3;
34152 * Placement constant - The resizing element is positioned under splitter element
34156 Roo.bootstrap.SplitBar.BOTTOM = 4;
34157 Roo.namespace("Roo.bootstrap.layout");/*
34159 * Ext JS Library 1.1.1
34160 * Copyright(c) 2006-2007, Ext JS, LLC.
34162 * Originally Released Under LGPL - original licence link has changed is not relivant.
34165 * <script type="text/javascript">
34169 * @class Roo.bootstrap.layout.Manager
34170 * @extends Roo.bootstrap.Component
34171 * Base class for layout managers.
34173 Roo.bootstrap.layout.Manager = function(config)
34175 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34181 /** false to disable window resize monitoring @type Boolean */
34182 this.monitorWindowResize = true;
34187 * Fires when a layout is performed.
34188 * @param {Roo.LayoutManager} this
34192 * @event regionresized
34193 * Fires when the user resizes a region.
34194 * @param {Roo.LayoutRegion} region The resized region
34195 * @param {Number} newSize The new size (width for east/west, height for north/south)
34197 "regionresized" : true,
34199 * @event regioncollapsed
34200 * Fires when a region is collapsed.
34201 * @param {Roo.LayoutRegion} region The collapsed region
34203 "regioncollapsed" : true,
34205 * @event regionexpanded
34206 * Fires when a region is expanded.
34207 * @param {Roo.LayoutRegion} region The expanded region
34209 "regionexpanded" : true
34211 this.updating = false;
34214 this.el = Roo.get(config.el);
34220 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34225 monitorWindowResize : true,
34231 onRender : function(ct, position)
34234 this.el = Roo.get(ct);
34237 //this.fireEvent('render',this);
34241 initEvents: function()
34245 // ie scrollbar fix
34246 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34247 document.body.scroll = "no";
34248 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34249 this.el.position('relative');
34251 this.id = this.el.id;
34252 this.el.addClass("roo-layout-container");
34253 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34254 if(this.el.dom != document.body ) {
34255 this.el.on('resize', this.layout,this);
34256 this.el.on('show', this.layout,this);
34262 * Returns true if this layout is currently being updated
34263 * @return {Boolean}
34265 isUpdating : function(){
34266 return this.updating;
34270 * Suspend the LayoutManager from doing auto-layouts while
34271 * making multiple add or remove calls
34273 beginUpdate : function(){
34274 this.updating = true;
34278 * Restore auto-layouts and optionally disable the manager from performing a layout
34279 * @param {Boolean} noLayout true to disable a layout update
34281 endUpdate : function(noLayout){
34282 this.updating = false;
34288 layout: function(){
34292 onRegionResized : function(region, newSize){
34293 this.fireEvent("regionresized", region, newSize);
34297 onRegionCollapsed : function(region){
34298 this.fireEvent("regioncollapsed", region);
34301 onRegionExpanded : function(region){
34302 this.fireEvent("regionexpanded", region);
34306 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34307 * performs box-model adjustments.
34308 * @return {Object} The size as an object {width: (the width), height: (the height)}
34310 getViewSize : function()
34313 if(this.el.dom != document.body){
34314 size = this.el.getSize();
34316 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34318 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34319 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34324 * Returns the Element this layout is bound to.
34325 * @return {Roo.Element}
34327 getEl : function(){
34332 * Returns the specified region.
34333 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34334 * @return {Roo.LayoutRegion}
34336 getRegion : function(target){
34337 return this.regions[target.toLowerCase()];
34340 onWindowResize : function(){
34341 if(this.monitorWindowResize){
34348 * Ext JS Library 1.1.1
34349 * Copyright(c) 2006-2007, Ext JS, LLC.
34351 * Originally Released Under LGPL - original licence link has changed is not relivant.
34354 * <script type="text/javascript">
34357 * @class Roo.bootstrap.layout.Border
34358 * @extends Roo.bootstrap.layout.Manager
34359 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34360 * please see: examples/bootstrap/nested.html<br><br>
34362 <b>The container the layout is rendered into can be either the body element or any other element.
34363 If it is not the body element, the container needs to either be an absolute positioned element,
34364 or you will need to add "position:relative" to the css of the container. You will also need to specify
34365 the container size if it is not the body element.</b>
34368 * Create a new Border
34369 * @param {Object} config Configuration options
34371 Roo.bootstrap.layout.Border = function(config){
34372 config = config || {};
34373 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34377 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34378 if(config[region]){
34379 config[region].region = region;
34380 this.addRegion(config[region]);
34386 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34388 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34390 * Creates and adds a new region if it doesn't already exist.
34391 * @param {String} target The target region key (north, south, east, west or center).
34392 * @param {Object} config The regions config object
34393 * @return {BorderLayoutRegion} The new region
34395 addRegion : function(config)
34397 if(!this.regions[config.region]){
34398 var r = this.factory(config);
34399 this.bindRegion(r);
34401 return this.regions[config.region];
34405 bindRegion : function(r){
34406 this.regions[r.config.region] = r;
34408 r.on("visibilitychange", this.layout, this);
34409 r.on("paneladded", this.layout, this);
34410 r.on("panelremoved", this.layout, this);
34411 r.on("invalidated", this.layout, this);
34412 r.on("resized", this.onRegionResized, this);
34413 r.on("collapsed", this.onRegionCollapsed, this);
34414 r.on("expanded", this.onRegionExpanded, this);
34418 * Performs a layout update.
34420 layout : function()
34422 if(this.updating) {
34426 // render all the rebions if they have not been done alreayd?
34427 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34428 if(this.regions[region] && !this.regions[region].bodyEl){
34429 this.regions[region].onRender(this.el)
34433 var size = this.getViewSize();
34434 var w = size.width;
34435 var h = size.height;
34440 //var x = 0, y = 0;
34442 var rs = this.regions;
34443 var north = rs["north"];
34444 var south = rs["south"];
34445 var west = rs["west"];
34446 var east = rs["east"];
34447 var center = rs["center"];
34448 //if(this.hideOnLayout){ // not supported anymore
34449 //c.el.setStyle("display", "none");
34451 if(north && north.isVisible()){
34452 var b = north.getBox();
34453 var m = north.getMargins();
34454 b.width = w - (m.left+m.right);
34457 centerY = b.height + b.y + m.bottom;
34458 centerH -= centerY;
34459 north.updateBox(this.safeBox(b));
34461 if(south && south.isVisible()){
34462 var b = south.getBox();
34463 var m = south.getMargins();
34464 b.width = w - (m.left+m.right);
34466 var totalHeight = (b.height + m.top + m.bottom);
34467 b.y = h - totalHeight + m.top;
34468 centerH -= totalHeight;
34469 south.updateBox(this.safeBox(b));
34471 if(west && west.isVisible()){
34472 var b = west.getBox();
34473 var m = west.getMargins();
34474 b.height = centerH - (m.top+m.bottom);
34476 b.y = centerY + m.top;
34477 var totalWidth = (b.width + m.left + m.right);
34478 centerX += totalWidth;
34479 centerW -= totalWidth;
34480 west.updateBox(this.safeBox(b));
34482 if(east && east.isVisible()){
34483 var b = east.getBox();
34484 var m = east.getMargins();
34485 b.height = centerH - (m.top+m.bottom);
34486 var totalWidth = (b.width + m.left + m.right);
34487 b.x = w - totalWidth + m.left;
34488 b.y = centerY + m.top;
34489 centerW -= totalWidth;
34490 east.updateBox(this.safeBox(b));
34493 var m = center.getMargins();
34495 x: centerX + m.left,
34496 y: centerY + m.top,
34497 width: centerW - (m.left+m.right),
34498 height: centerH - (m.top+m.bottom)
34500 //if(this.hideOnLayout){
34501 //center.el.setStyle("display", "block");
34503 center.updateBox(this.safeBox(centerBox));
34506 this.fireEvent("layout", this);
34510 safeBox : function(box){
34511 box.width = Math.max(0, box.width);
34512 box.height = Math.max(0, box.height);
34517 * Adds a ContentPanel (or subclass) to this layout.
34518 * @param {String} target The target region key (north, south, east, west or center).
34519 * @param {Roo.ContentPanel} panel The panel to add
34520 * @return {Roo.ContentPanel} The added panel
34522 add : function(target, panel){
34524 target = target.toLowerCase();
34525 return this.regions[target].add(panel);
34529 * Remove a ContentPanel (or subclass) to this layout.
34530 * @param {String} target The target region key (north, south, east, west or center).
34531 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34532 * @return {Roo.ContentPanel} The removed panel
34534 remove : function(target, panel){
34535 target = target.toLowerCase();
34536 return this.regions[target].remove(panel);
34540 * Searches all regions for a panel with the specified id
34541 * @param {String} panelId
34542 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34544 findPanel : function(panelId){
34545 var rs = this.regions;
34546 for(var target in rs){
34547 if(typeof rs[target] != "function"){
34548 var p = rs[target].getPanel(panelId);
34558 * Searches all regions for a panel with the specified id and activates (shows) it.
34559 * @param {String/ContentPanel} panelId The panels id or the panel itself
34560 * @return {Roo.ContentPanel} The shown panel or null
34562 showPanel : function(panelId) {
34563 var rs = this.regions;
34564 for(var target in rs){
34565 var r = rs[target];
34566 if(typeof r != "function"){
34567 if(r.hasPanel(panelId)){
34568 return r.showPanel(panelId);
34576 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34577 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34580 restoreState : function(provider){
34582 provider = Roo.state.Manager;
34584 var sm = new Roo.LayoutStateManager();
34585 sm.init(this, provider);
34591 * Adds a xtype elements to the layout.
34595 xtype : 'ContentPanel',
34602 xtype : 'NestedLayoutPanel',
34608 items : [ ... list of content panels or nested layout panels.. ]
34612 * @param {Object} cfg Xtype definition of item to add.
34614 addxtype : function(cfg)
34616 // basically accepts a pannel...
34617 // can accept a layout region..!?!?
34618 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34621 // theory? children can only be panels??
34623 //if (!cfg.xtype.match(/Panel$/)) {
34628 if (typeof(cfg.region) == 'undefined') {
34629 Roo.log("Failed to add Panel, region was not set");
34633 var region = cfg.region;
34639 xitems = cfg.items;
34646 case 'Content': // ContentPanel (el, cfg)
34647 case 'Scroll': // ContentPanel (el, cfg)
34649 cfg.autoCreate = true;
34650 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34652 // var el = this.el.createChild();
34653 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34656 this.add(region, ret);
34660 case 'TreePanel': // our new panel!
34661 cfg.el = this.el.createChild();
34662 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34663 this.add(region, ret);
34668 // create a new Layout (which is a Border Layout...
34670 var clayout = cfg.layout;
34671 clayout.el = this.el.createChild();
34672 clayout.items = clayout.items || [];
34676 // replace this exitems with the clayout ones..
34677 xitems = clayout.items;
34679 // force background off if it's in center...
34680 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34681 cfg.background = false;
34683 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34686 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34687 //console.log('adding nested layout panel ' + cfg.toSource());
34688 this.add(region, ret);
34689 nb = {}; /// find first...
34694 // needs grid and region
34696 //var el = this.getRegion(region).el.createChild();
34698 *var el = this.el.createChild();
34699 // create the grid first...
34700 cfg.grid.container = el;
34701 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34704 if (region == 'center' && this.active ) {
34705 cfg.background = false;
34708 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34710 this.add(region, ret);
34712 if (cfg.background) {
34713 // render grid on panel activation (if panel background)
34714 ret.on('activate', function(gp) {
34715 if (!gp.grid.rendered) {
34716 // gp.grid.render(el);
34720 // cfg.grid.render(el);
34726 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34727 // it was the old xcomponent building that caused this before.
34728 // espeically if border is the top element in the tree.
34738 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34740 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34741 this.add(region, ret);
34745 throw "Can not add '" + cfg.xtype + "' to Border";
34751 this.beginUpdate();
34755 Roo.each(xitems, function(i) {
34756 region = nb && i.region ? i.region : false;
34758 var add = ret.addxtype(i);
34761 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34762 if (!i.background) {
34763 abn[region] = nb[region] ;
34770 // make the last non-background panel active..
34771 //if (nb) { Roo.log(abn); }
34774 for(var r in abn) {
34775 region = this.getRegion(r);
34777 // tried using nb[r], but it does not work..
34779 region.showPanel(abn[r]);
34790 factory : function(cfg)
34793 var validRegions = Roo.bootstrap.layout.Border.regions;
34795 var target = cfg.region;
34798 var r = Roo.bootstrap.layout;
34802 return new r.North(cfg);
34804 return new r.South(cfg);
34806 return new r.East(cfg);
34808 return new r.West(cfg);
34810 return new r.Center(cfg);
34812 throw 'Layout region "'+target+'" not supported.';
34819 * Ext JS Library 1.1.1
34820 * Copyright(c) 2006-2007, Ext JS, LLC.
34822 * Originally Released Under LGPL - original licence link has changed is not relivant.
34825 * <script type="text/javascript">
34829 * @class Roo.bootstrap.layout.Basic
34830 * @extends Roo.util.Observable
34831 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34832 * and does not have a titlebar, tabs or any other features. All it does is size and position
34833 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34834 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34835 * @cfg {string} region the region that it inhabits..
34836 * @cfg {bool} skipConfig skip config?
34840 Roo.bootstrap.layout.Basic = function(config){
34842 this.mgr = config.mgr;
34844 this.position = config.region;
34846 var skipConfig = config.skipConfig;
34850 * @scope Roo.BasicLayoutRegion
34854 * @event beforeremove
34855 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34856 * @param {Roo.LayoutRegion} this
34857 * @param {Roo.ContentPanel} panel The panel
34858 * @param {Object} e The cancel event object
34860 "beforeremove" : true,
34862 * @event invalidated
34863 * Fires when the layout for this region is changed.
34864 * @param {Roo.LayoutRegion} this
34866 "invalidated" : true,
34868 * @event visibilitychange
34869 * Fires when this region is shown or hidden
34870 * @param {Roo.LayoutRegion} this
34871 * @param {Boolean} visibility true or false
34873 "visibilitychange" : true,
34875 * @event paneladded
34876 * Fires when a panel is added.
34877 * @param {Roo.LayoutRegion} this
34878 * @param {Roo.ContentPanel} panel The panel
34880 "paneladded" : true,
34882 * @event panelremoved
34883 * Fires when a panel is removed.
34884 * @param {Roo.LayoutRegion} this
34885 * @param {Roo.ContentPanel} panel The panel
34887 "panelremoved" : true,
34889 * @event beforecollapse
34890 * Fires when this region before collapse.
34891 * @param {Roo.LayoutRegion} this
34893 "beforecollapse" : true,
34896 * Fires when this region is collapsed.
34897 * @param {Roo.LayoutRegion} this
34899 "collapsed" : true,
34902 * Fires when this region is expanded.
34903 * @param {Roo.LayoutRegion} this
34908 * Fires when this region is slid into view.
34909 * @param {Roo.LayoutRegion} this
34911 "slideshow" : true,
34914 * Fires when this region slides out of view.
34915 * @param {Roo.LayoutRegion} this
34917 "slidehide" : true,
34919 * @event panelactivated
34920 * Fires when a panel is activated.
34921 * @param {Roo.LayoutRegion} this
34922 * @param {Roo.ContentPanel} panel The activated panel
34924 "panelactivated" : true,
34927 * Fires when the user resizes this region.
34928 * @param {Roo.LayoutRegion} this
34929 * @param {Number} newSize The new size (width for east/west, height for north/south)
34933 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34934 this.panels = new Roo.util.MixedCollection();
34935 this.panels.getKey = this.getPanelId.createDelegate(this);
34937 this.activePanel = null;
34938 // ensure listeners are added...
34940 if (config.listeners || config.events) {
34941 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34942 listeners : config.listeners || {},
34943 events : config.events || {}
34947 if(skipConfig !== true){
34948 this.applyConfig(config);
34952 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34954 getPanelId : function(p){
34958 applyConfig : function(config){
34959 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34960 this.config = config;
34965 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34966 * the width, for horizontal (north, south) the height.
34967 * @param {Number} newSize The new width or height
34969 resizeTo : function(newSize){
34970 var el = this.el ? this.el :
34971 (this.activePanel ? this.activePanel.getEl() : null);
34973 switch(this.position){
34976 el.setWidth(newSize);
34977 this.fireEvent("resized", this, newSize);
34981 el.setHeight(newSize);
34982 this.fireEvent("resized", this, newSize);
34988 getBox : function(){
34989 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34992 getMargins : function(){
34993 return this.margins;
34996 updateBox : function(box){
34998 var el = this.activePanel.getEl();
34999 el.dom.style.left = box.x + "px";
35000 el.dom.style.top = box.y + "px";
35001 this.activePanel.setSize(box.width, box.height);
35005 * Returns the container element for this region.
35006 * @return {Roo.Element}
35008 getEl : function(){
35009 return this.activePanel;
35013 * Returns true if this region is currently visible.
35014 * @return {Boolean}
35016 isVisible : function(){
35017 return this.activePanel ? true : false;
35020 setActivePanel : function(panel){
35021 panel = this.getPanel(panel);
35022 if(this.activePanel && this.activePanel != panel){
35023 this.activePanel.setActiveState(false);
35024 this.activePanel.getEl().setLeftTop(-10000,-10000);
35026 this.activePanel = panel;
35027 panel.setActiveState(true);
35029 panel.setSize(this.box.width, this.box.height);
35031 this.fireEvent("panelactivated", this, panel);
35032 this.fireEvent("invalidated");
35036 * Show the specified panel.
35037 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35038 * @return {Roo.ContentPanel} The shown panel or null
35040 showPanel : function(panel){
35041 panel = this.getPanel(panel);
35043 this.setActivePanel(panel);
35049 * Get the active panel for this region.
35050 * @return {Roo.ContentPanel} The active panel or null
35052 getActivePanel : function(){
35053 return this.activePanel;
35057 * Add the passed ContentPanel(s)
35058 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35059 * @return {Roo.ContentPanel} The panel added (if only one was added)
35061 add : function(panel){
35062 if(arguments.length > 1){
35063 for(var i = 0, len = arguments.length; i < len; i++) {
35064 this.add(arguments[i]);
35068 if(this.hasPanel(panel)){
35069 this.showPanel(panel);
35072 var el = panel.getEl();
35073 if(el.dom.parentNode != this.mgr.el.dom){
35074 this.mgr.el.dom.appendChild(el.dom);
35076 if(panel.setRegion){
35077 panel.setRegion(this);
35079 this.panels.add(panel);
35080 el.setStyle("position", "absolute");
35081 if(!panel.background){
35082 this.setActivePanel(panel);
35083 if(this.config.initialSize && this.panels.getCount()==1){
35084 this.resizeTo(this.config.initialSize);
35087 this.fireEvent("paneladded", this, panel);
35092 * Returns true if the panel is in this region.
35093 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35094 * @return {Boolean}
35096 hasPanel : function(panel){
35097 if(typeof panel == "object"){ // must be panel obj
35098 panel = panel.getId();
35100 return this.getPanel(panel) ? true : false;
35104 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35105 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35106 * @param {Boolean} preservePanel Overrides the config preservePanel option
35107 * @return {Roo.ContentPanel} The panel that was removed
35109 remove : function(panel, preservePanel){
35110 panel = this.getPanel(panel);
35115 this.fireEvent("beforeremove", this, panel, e);
35116 if(e.cancel === true){
35119 var panelId = panel.getId();
35120 this.panels.removeKey(panelId);
35125 * Returns the panel specified or null if it's not in this region.
35126 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35127 * @return {Roo.ContentPanel}
35129 getPanel : function(id){
35130 if(typeof id == "object"){ // must be panel obj
35133 return this.panels.get(id);
35137 * Returns this regions position (north/south/east/west/center).
35140 getPosition: function(){
35141 return this.position;
35145 * Ext JS Library 1.1.1
35146 * Copyright(c) 2006-2007, Ext JS, LLC.
35148 * Originally Released Under LGPL - original licence link has changed is not relivant.
35151 * <script type="text/javascript">
35155 * @class Roo.bootstrap.layout.Region
35156 * @extends Roo.bootstrap.layout.Basic
35157 * This class represents a region in a layout manager.
35159 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35160 * @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})
35161 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35162 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35163 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35164 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35165 * @cfg {String} title The title for the region (overrides panel titles)
35166 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35167 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35168 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35169 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35170 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35171 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35172 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35173 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35174 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35175 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35177 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35178 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35179 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35180 * @cfg {Number} width For East/West panels
35181 * @cfg {Number} height For North/South panels
35182 * @cfg {Boolean} split To show the splitter
35183 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35185 * @cfg {string} cls Extra CSS classes to add to region
35187 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35188 * @cfg {string} region the region that it inhabits..
35191 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35192 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35194 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35195 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35196 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35198 Roo.bootstrap.layout.Region = function(config)
35200 this.applyConfig(config);
35202 var mgr = config.mgr;
35203 var pos = config.region;
35204 config.skipConfig = true;
35205 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35208 this.onRender(mgr.el);
35211 this.visible = true;
35212 this.collapsed = false;
35213 this.unrendered_panels = [];
35216 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35218 position: '', // set by wrapper (eg. north/south etc..)
35219 unrendered_panels : null, // unrendered panels.
35220 createBody : function(){
35221 /** This region's body element
35222 * @type Roo.Element */
35223 this.bodyEl = this.el.createChild({
35225 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35229 onRender: function(ctr, pos)
35231 var dh = Roo.DomHelper;
35232 /** This region's container element
35233 * @type Roo.Element */
35234 this.el = dh.append(ctr.dom, {
35236 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35238 /** This region's title element
35239 * @type Roo.Element */
35241 this.titleEl = dh.append(this.el.dom,
35244 unselectable: "on",
35245 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35247 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35248 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35251 this.titleEl.enableDisplayMode();
35252 /** This region's title text element
35253 * @type HTMLElement */
35254 this.titleTextEl = this.titleEl.dom.firstChild;
35255 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35257 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35258 this.closeBtn.enableDisplayMode();
35259 this.closeBtn.on("click", this.closeClicked, this);
35260 this.closeBtn.hide();
35262 this.createBody(this.config);
35263 if(this.config.hideWhenEmpty){
35265 this.on("paneladded", this.validateVisibility, this);
35266 this.on("panelremoved", this.validateVisibility, this);
35268 if(this.autoScroll){
35269 this.bodyEl.setStyle("overflow", "auto");
35271 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35273 //if(c.titlebar !== false){
35274 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35275 this.titleEl.hide();
35277 this.titleEl.show();
35278 if(this.config.title){
35279 this.titleTextEl.innerHTML = this.config.title;
35283 if(this.config.collapsed){
35284 this.collapse(true);
35286 if(this.config.hidden){
35290 if (this.unrendered_panels && this.unrendered_panels.length) {
35291 for (var i =0;i< this.unrendered_panels.length; i++) {
35292 this.add(this.unrendered_panels[i]);
35294 this.unrendered_panels = null;
35300 applyConfig : function(c)
35303 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35304 var dh = Roo.DomHelper;
35305 if(c.titlebar !== false){
35306 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35307 this.collapseBtn.on("click", this.collapse, this);
35308 this.collapseBtn.enableDisplayMode();
35310 if(c.showPin === true || this.showPin){
35311 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35312 this.stickBtn.enableDisplayMode();
35313 this.stickBtn.on("click", this.expand, this);
35314 this.stickBtn.hide();
35319 /** This region's collapsed element
35320 * @type Roo.Element */
35323 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35324 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35327 if(c.floatable !== false){
35328 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35329 this.collapsedEl.on("click", this.collapseClick, this);
35332 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35333 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35334 id: "message", unselectable: "on", style:{"float":"left"}});
35335 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35337 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35338 this.expandBtn.on("click", this.expand, this);
35342 if(this.collapseBtn){
35343 this.collapseBtn.setVisible(c.collapsible == true);
35346 this.cmargins = c.cmargins || this.cmargins ||
35347 (this.position == "west" || this.position == "east" ?
35348 {top: 0, left: 2, right:2, bottom: 0} :
35349 {top: 2, left: 0, right:0, bottom: 2});
35351 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35354 this.bottomTabs = c.tabPosition != "top";
35356 this.autoScroll = c.autoScroll || false;
35361 this.duration = c.duration || .30;
35362 this.slideDuration = c.slideDuration || .45;
35367 * Returns true if this region is currently visible.
35368 * @return {Boolean}
35370 isVisible : function(){
35371 return this.visible;
35375 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35376 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35378 //setCollapsedTitle : function(title){
35379 // title = title || " ";
35380 // if(this.collapsedTitleTextEl){
35381 // this.collapsedTitleTextEl.innerHTML = title;
35385 getBox : function(){
35387 // if(!this.collapsed){
35388 b = this.el.getBox(false, true);
35390 // b = this.collapsedEl.getBox(false, true);
35395 getMargins : function(){
35396 return this.margins;
35397 //return this.collapsed ? this.cmargins : this.margins;
35400 highlight : function(){
35401 this.el.addClass("x-layout-panel-dragover");
35404 unhighlight : function(){
35405 this.el.removeClass("x-layout-panel-dragover");
35408 updateBox : function(box)
35410 if (!this.bodyEl) {
35411 return; // not rendered yet..
35415 if(!this.collapsed){
35416 this.el.dom.style.left = box.x + "px";
35417 this.el.dom.style.top = box.y + "px";
35418 this.updateBody(box.width, box.height);
35420 this.collapsedEl.dom.style.left = box.x + "px";
35421 this.collapsedEl.dom.style.top = box.y + "px";
35422 this.collapsedEl.setSize(box.width, box.height);
35425 this.tabs.autoSizeTabs();
35429 updateBody : function(w, h)
35432 this.el.setWidth(w);
35433 w -= this.el.getBorderWidth("rl");
35434 if(this.config.adjustments){
35435 w += this.config.adjustments[0];
35438 if(h !== null && h > 0){
35439 this.el.setHeight(h);
35440 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35441 h -= this.el.getBorderWidth("tb");
35442 if(this.config.adjustments){
35443 h += this.config.adjustments[1];
35445 this.bodyEl.setHeight(h);
35447 h = this.tabs.syncHeight(h);
35450 if(this.panelSize){
35451 w = w !== null ? w : this.panelSize.width;
35452 h = h !== null ? h : this.panelSize.height;
35454 if(this.activePanel){
35455 var el = this.activePanel.getEl();
35456 w = w !== null ? w : el.getWidth();
35457 h = h !== null ? h : el.getHeight();
35458 this.panelSize = {width: w, height: h};
35459 this.activePanel.setSize(w, h);
35461 if(Roo.isIE && this.tabs){
35462 this.tabs.el.repaint();
35467 * Returns the container element for this region.
35468 * @return {Roo.Element}
35470 getEl : function(){
35475 * Hides this region.
35478 //if(!this.collapsed){
35479 this.el.dom.style.left = "-2000px";
35482 // this.collapsedEl.dom.style.left = "-2000px";
35483 // this.collapsedEl.hide();
35485 this.visible = false;
35486 this.fireEvent("visibilitychange", this, false);
35490 * Shows this region if it was previously hidden.
35493 //if(!this.collapsed){
35496 // this.collapsedEl.show();
35498 this.visible = true;
35499 this.fireEvent("visibilitychange", this, true);
35502 closeClicked : function(){
35503 if(this.activePanel){
35504 this.remove(this.activePanel);
35508 collapseClick : function(e){
35510 e.stopPropagation();
35513 e.stopPropagation();
35519 * Collapses this region.
35520 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35523 collapse : function(skipAnim, skipCheck = false){
35524 if(this.collapsed) {
35528 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35530 this.collapsed = true;
35532 this.split.el.hide();
35534 if(this.config.animate && skipAnim !== true){
35535 this.fireEvent("invalidated", this);
35536 this.animateCollapse();
35538 this.el.setLocation(-20000,-20000);
35540 this.collapsedEl.show();
35541 this.fireEvent("collapsed", this);
35542 this.fireEvent("invalidated", this);
35548 animateCollapse : function(){
35553 * Expands this region if it was previously collapsed.
35554 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35555 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35558 expand : function(e, skipAnim){
35560 e.stopPropagation();
35562 if(!this.collapsed || this.el.hasActiveFx()) {
35566 this.afterSlideIn();
35569 this.collapsed = false;
35570 if(this.config.animate && skipAnim !== true){
35571 this.animateExpand();
35575 this.split.el.show();
35577 this.collapsedEl.setLocation(-2000,-2000);
35578 this.collapsedEl.hide();
35579 this.fireEvent("invalidated", this);
35580 this.fireEvent("expanded", this);
35584 animateExpand : function(){
35588 initTabs : function()
35590 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35592 var ts = new Roo.bootstrap.panel.Tabs({
35593 el: this.bodyEl.dom,
35594 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35595 disableTooltips: this.config.disableTabTips,
35596 toolbar : this.config.toolbar
35599 if(this.config.hideTabs){
35600 ts.stripWrap.setDisplayed(false);
35603 ts.resizeTabs = this.config.resizeTabs === true;
35604 ts.minTabWidth = this.config.minTabWidth || 40;
35605 ts.maxTabWidth = this.config.maxTabWidth || 250;
35606 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35607 ts.monitorResize = false;
35608 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35609 ts.bodyEl.addClass('roo-layout-tabs-body');
35610 this.panels.each(this.initPanelAsTab, this);
35613 initPanelAsTab : function(panel){
35614 var ti = this.tabs.addTab(
35618 this.config.closeOnTab && panel.isClosable(),
35621 if(panel.tabTip !== undefined){
35622 ti.setTooltip(panel.tabTip);
35624 ti.on("activate", function(){
35625 this.setActivePanel(panel);
35628 if(this.config.closeOnTab){
35629 ti.on("beforeclose", function(t, e){
35631 this.remove(panel);
35635 panel.tabItem = ti;
35640 updatePanelTitle : function(panel, title)
35642 if(this.activePanel == panel){
35643 this.updateTitle(title);
35646 var ti = this.tabs.getTab(panel.getEl().id);
35648 if(panel.tabTip !== undefined){
35649 ti.setTooltip(panel.tabTip);
35654 updateTitle : function(title){
35655 if(this.titleTextEl && !this.config.title){
35656 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35660 setActivePanel : function(panel)
35662 panel = this.getPanel(panel);
35663 if(this.activePanel && this.activePanel != panel){
35664 if(this.activePanel.setActiveState(false) === false){
35668 this.activePanel = panel;
35669 panel.setActiveState(true);
35670 if(this.panelSize){
35671 panel.setSize(this.panelSize.width, this.panelSize.height);
35674 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35676 this.updateTitle(panel.getTitle());
35678 this.fireEvent("invalidated", this);
35680 this.fireEvent("panelactivated", this, panel);
35684 * Shows the specified panel.
35685 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35686 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35688 showPanel : function(panel)
35690 panel = this.getPanel(panel);
35693 var tab = this.tabs.getTab(panel.getEl().id);
35694 if(tab.isHidden()){
35695 this.tabs.unhideTab(tab.id);
35699 this.setActivePanel(panel);
35706 * Get the active panel for this region.
35707 * @return {Roo.ContentPanel} The active panel or null
35709 getActivePanel : function(){
35710 return this.activePanel;
35713 validateVisibility : function(){
35714 if(this.panels.getCount() < 1){
35715 this.updateTitle(" ");
35716 this.closeBtn.hide();
35719 if(!this.isVisible()){
35726 * Adds the passed ContentPanel(s) to this region.
35727 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35728 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35730 add : function(panel)
35732 if(arguments.length > 1){
35733 for(var i = 0, len = arguments.length; i < len; i++) {
35734 this.add(arguments[i]);
35739 // if we have not been rendered yet, then we can not really do much of this..
35740 if (!this.bodyEl) {
35741 this.unrendered_panels.push(panel);
35748 if(this.hasPanel(panel)){
35749 this.showPanel(panel);
35752 panel.setRegion(this);
35753 this.panels.add(panel);
35754 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35755 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35756 // and hide them... ???
35757 this.bodyEl.dom.appendChild(panel.getEl().dom);
35758 if(panel.background !== true){
35759 this.setActivePanel(panel);
35761 this.fireEvent("paneladded", this, panel);
35768 this.initPanelAsTab(panel);
35772 if(panel.background !== true){
35773 this.tabs.activate(panel.getEl().id);
35775 this.fireEvent("paneladded", this, panel);
35780 * Hides the tab for the specified panel.
35781 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35783 hidePanel : function(panel){
35784 if(this.tabs && (panel = this.getPanel(panel))){
35785 this.tabs.hideTab(panel.getEl().id);
35790 * Unhides the tab for a previously hidden panel.
35791 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35793 unhidePanel : function(panel){
35794 if(this.tabs && (panel = this.getPanel(panel))){
35795 this.tabs.unhideTab(panel.getEl().id);
35799 clearPanels : function(){
35800 while(this.panels.getCount() > 0){
35801 this.remove(this.panels.first());
35806 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35807 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35808 * @param {Boolean} preservePanel Overrides the config preservePanel option
35809 * @return {Roo.ContentPanel} The panel that was removed
35811 remove : function(panel, preservePanel)
35813 panel = this.getPanel(panel);
35818 this.fireEvent("beforeremove", this, panel, e);
35819 if(e.cancel === true){
35822 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35823 var panelId = panel.getId();
35824 this.panels.removeKey(panelId);
35826 document.body.appendChild(panel.getEl().dom);
35829 this.tabs.removeTab(panel.getEl().id);
35830 }else if (!preservePanel){
35831 this.bodyEl.dom.removeChild(panel.getEl().dom);
35833 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35834 var p = this.panels.first();
35835 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35836 tempEl.appendChild(p.getEl().dom);
35837 this.bodyEl.update("");
35838 this.bodyEl.dom.appendChild(p.getEl().dom);
35840 this.updateTitle(p.getTitle());
35842 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35843 this.setActivePanel(p);
35845 panel.setRegion(null);
35846 if(this.activePanel == panel){
35847 this.activePanel = null;
35849 if(this.config.autoDestroy !== false && preservePanel !== true){
35850 try{panel.destroy();}catch(e){}
35852 this.fireEvent("panelremoved", this, panel);
35857 * Returns the TabPanel component used by this region
35858 * @return {Roo.TabPanel}
35860 getTabs : function(){
35864 createTool : function(parentEl, className){
35865 var btn = Roo.DomHelper.append(parentEl, {
35867 cls: "x-layout-tools-button",
35870 cls: "roo-layout-tools-button-inner " + className,
35874 btn.addClassOnOver("roo-layout-tools-button-over");
35879 * Ext JS Library 1.1.1
35880 * Copyright(c) 2006-2007, Ext JS, LLC.
35882 * Originally Released Under LGPL - original licence link has changed is not relivant.
35885 * <script type="text/javascript">
35891 * @class Roo.SplitLayoutRegion
35892 * @extends Roo.LayoutRegion
35893 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35895 Roo.bootstrap.layout.Split = function(config){
35896 this.cursor = config.cursor;
35897 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35900 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35902 splitTip : "Drag to resize.",
35903 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35904 useSplitTips : false,
35906 applyConfig : function(config){
35907 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35910 onRender : function(ctr,pos) {
35912 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35913 if(!this.config.split){
35918 var splitEl = Roo.DomHelper.append(ctr.dom, {
35920 id: this.el.id + "-split",
35921 cls: "roo-layout-split roo-layout-split-"+this.position,
35924 /** The SplitBar for this region
35925 * @type Roo.SplitBar */
35926 // does not exist yet...
35927 Roo.log([this.position, this.orientation]);
35929 this.split = new Roo.bootstrap.SplitBar({
35930 dragElement : splitEl,
35931 resizingElement: this.el,
35932 orientation : this.orientation
35935 this.split.on("moved", this.onSplitMove, this);
35936 this.split.useShim = this.config.useShim === true;
35937 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35938 if(this.useSplitTips){
35939 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35941 //if(config.collapsible){
35942 // this.split.el.on("dblclick", this.collapse, this);
35945 if(typeof this.config.minSize != "undefined"){
35946 this.split.minSize = this.config.minSize;
35948 if(typeof this.config.maxSize != "undefined"){
35949 this.split.maxSize = this.config.maxSize;
35951 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35952 this.hideSplitter();
35957 getHMaxSize : function(){
35958 var cmax = this.config.maxSize || 10000;
35959 var center = this.mgr.getRegion("center");
35960 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35963 getVMaxSize : function(){
35964 var cmax = this.config.maxSize || 10000;
35965 var center = this.mgr.getRegion("center");
35966 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35969 onSplitMove : function(split, newSize){
35970 this.fireEvent("resized", this, newSize);
35974 * Returns the {@link Roo.SplitBar} for this region.
35975 * @return {Roo.SplitBar}
35977 getSplitBar : function(){
35982 this.hideSplitter();
35983 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35986 hideSplitter : function(){
35988 this.split.el.setLocation(-2000,-2000);
35989 this.split.el.hide();
35995 this.split.el.show();
35997 Roo.bootstrap.layout.Split.superclass.show.call(this);
36000 beforeSlide: function(){
36001 if(Roo.isGecko){// firefox overflow auto bug workaround
36002 this.bodyEl.clip();
36004 this.tabs.bodyEl.clip();
36006 if(this.activePanel){
36007 this.activePanel.getEl().clip();
36009 if(this.activePanel.beforeSlide){
36010 this.activePanel.beforeSlide();
36016 afterSlide : function(){
36017 if(Roo.isGecko){// firefox overflow auto bug workaround
36018 this.bodyEl.unclip();
36020 this.tabs.bodyEl.unclip();
36022 if(this.activePanel){
36023 this.activePanel.getEl().unclip();
36024 if(this.activePanel.afterSlide){
36025 this.activePanel.afterSlide();
36031 initAutoHide : function(){
36032 if(this.autoHide !== false){
36033 if(!this.autoHideHd){
36034 var st = new Roo.util.DelayedTask(this.slideIn, this);
36035 this.autoHideHd = {
36036 "mouseout": function(e){
36037 if(!e.within(this.el, true)){
36041 "mouseover" : function(e){
36047 this.el.on(this.autoHideHd);
36051 clearAutoHide : function(){
36052 if(this.autoHide !== false){
36053 this.el.un("mouseout", this.autoHideHd.mouseout);
36054 this.el.un("mouseover", this.autoHideHd.mouseover);
36058 clearMonitor : function(){
36059 Roo.get(document).un("click", this.slideInIf, this);
36062 // these names are backwards but not changed for compat
36063 slideOut : function(){
36064 if(this.isSlid || this.el.hasActiveFx()){
36067 this.isSlid = true;
36068 if(this.collapseBtn){
36069 this.collapseBtn.hide();
36071 this.closeBtnState = this.closeBtn.getStyle('display');
36072 this.closeBtn.hide();
36074 this.stickBtn.show();
36077 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36078 this.beforeSlide();
36079 this.el.setStyle("z-index", 10001);
36080 this.el.slideIn(this.getSlideAnchor(), {
36081 callback: function(){
36083 this.initAutoHide();
36084 Roo.get(document).on("click", this.slideInIf, this);
36085 this.fireEvent("slideshow", this);
36092 afterSlideIn : function(){
36093 this.clearAutoHide();
36094 this.isSlid = false;
36095 this.clearMonitor();
36096 this.el.setStyle("z-index", "");
36097 if(this.collapseBtn){
36098 this.collapseBtn.show();
36100 this.closeBtn.setStyle('display', this.closeBtnState);
36102 this.stickBtn.hide();
36104 this.fireEvent("slidehide", this);
36107 slideIn : function(cb){
36108 if(!this.isSlid || this.el.hasActiveFx()){
36112 this.isSlid = false;
36113 this.beforeSlide();
36114 this.el.slideOut(this.getSlideAnchor(), {
36115 callback: function(){
36116 this.el.setLeftTop(-10000, -10000);
36118 this.afterSlideIn();
36126 slideInIf : function(e){
36127 if(!e.within(this.el)){
36132 animateCollapse : function(){
36133 this.beforeSlide();
36134 this.el.setStyle("z-index", 20000);
36135 var anchor = this.getSlideAnchor();
36136 this.el.slideOut(anchor, {
36137 callback : function(){
36138 this.el.setStyle("z-index", "");
36139 this.collapsedEl.slideIn(anchor, {duration:.3});
36141 this.el.setLocation(-10000,-10000);
36143 this.fireEvent("collapsed", this);
36150 animateExpand : function(){
36151 this.beforeSlide();
36152 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36153 this.el.setStyle("z-index", 20000);
36154 this.collapsedEl.hide({
36157 this.el.slideIn(this.getSlideAnchor(), {
36158 callback : function(){
36159 this.el.setStyle("z-index", "");
36162 this.split.el.show();
36164 this.fireEvent("invalidated", this);
36165 this.fireEvent("expanded", this);
36193 getAnchor : function(){
36194 return this.anchors[this.position];
36197 getCollapseAnchor : function(){
36198 return this.canchors[this.position];
36201 getSlideAnchor : function(){
36202 return this.sanchors[this.position];
36205 getAlignAdj : function(){
36206 var cm = this.cmargins;
36207 switch(this.position){
36223 getExpandAdj : function(){
36224 var c = this.collapsedEl, cm = this.cmargins;
36225 switch(this.position){
36227 return [-(cm.right+c.getWidth()+cm.left), 0];
36230 return [cm.right+c.getWidth()+cm.left, 0];
36233 return [0, -(cm.top+cm.bottom+c.getHeight())];
36236 return [0, cm.top+cm.bottom+c.getHeight()];
36242 * Ext JS Library 1.1.1
36243 * Copyright(c) 2006-2007, Ext JS, LLC.
36245 * Originally Released Under LGPL - original licence link has changed is not relivant.
36248 * <script type="text/javascript">
36251 * These classes are private internal classes
36253 Roo.bootstrap.layout.Center = function(config){
36254 config.region = "center";
36255 Roo.bootstrap.layout.Region.call(this, config);
36256 this.visible = true;
36257 this.minWidth = config.minWidth || 20;
36258 this.minHeight = config.minHeight || 20;
36261 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36263 // center panel can't be hidden
36267 // center panel can't be hidden
36270 getMinWidth: function(){
36271 return this.minWidth;
36274 getMinHeight: function(){
36275 return this.minHeight;
36288 Roo.bootstrap.layout.North = function(config)
36290 config.region = 'north';
36291 config.cursor = 'n-resize';
36293 Roo.bootstrap.layout.Split.call(this, config);
36297 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36298 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36299 this.split.el.addClass("roo-layout-split-v");
36301 var size = config.initialSize || config.height;
36302 if(typeof size != "undefined"){
36303 this.el.setHeight(size);
36306 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36308 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36312 getBox : function(){
36313 if(this.collapsed){
36314 return this.collapsedEl.getBox();
36316 var box = this.el.getBox();
36318 box.height += this.split.el.getHeight();
36323 updateBox : function(box){
36324 if(this.split && !this.collapsed){
36325 box.height -= this.split.el.getHeight();
36326 this.split.el.setLeft(box.x);
36327 this.split.el.setTop(box.y+box.height);
36328 this.split.el.setWidth(box.width);
36330 if(this.collapsed){
36331 this.updateBody(box.width, null);
36333 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36341 Roo.bootstrap.layout.South = function(config){
36342 config.region = 'south';
36343 config.cursor = 's-resize';
36344 Roo.bootstrap.layout.Split.call(this, config);
36346 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36347 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36348 this.split.el.addClass("roo-layout-split-v");
36350 var size = config.initialSize || config.height;
36351 if(typeof size != "undefined"){
36352 this.el.setHeight(size);
36356 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36357 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36358 getBox : function(){
36359 if(this.collapsed){
36360 return this.collapsedEl.getBox();
36362 var box = this.el.getBox();
36364 var sh = this.split.el.getHeight();
36371 updateBox : function(box){
36372 if(this.split && !this.collapsed){
36373 var sh = this.split.el.getHeight();
36376 this.split.el.setLeft(box.x);
36377 this.split.el.setTop(box.y-sh);
36378 this.split.el.setWidth(box.width);
36380 if(this.collapsed){
36381 this.updateBody(box.width, null);
36383 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36387 Roo.bootstrap.layout.East = function(config){
36388 config.region = "east";
36389 config.cursor = "e-resize";
36390 Roo.bootstrap.layout.Split.call(this, config);
36392 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36393 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36394 this.split.el.addClass("roo-layout-split-h");
36396 var size = config.initialSize || config.width;
36397 if(typeof size != "undefined"){
36398 this.el.setWidth(size);
36401 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36402 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36403 getBox : function(){
36404 if(this.collapsed){
36405 return this.collapsedEl.getBox();
36407 var box = this.el.getBox();
36409 var sw = this.split.el.getWidth();
36416 updateBox : function(box){
36417 if(this.split && !this.collapsed){
36418 var sw = this.split.el.getWidth();
36420 this.split.el.setLeft(box.x);
36421 this.split.el.setTop(box.y);
36422 this.split.el.setHeight(box.height);
36425 if(this.collapsed){
36426 this.updateBody(null, box.height);
36428 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36432 Roo.bootstrap.layout.West = function(config){
36433 config.region = "west";
36434 config.cursor = "w-resize";
36436 Roo.bootstrap.layout.Split.call(this, config);
36438 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36439 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36440 this.split.el.addClass("roo-layout-split-h");
36444 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36445 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36447 onRender: function(ctr, pos)
36449 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36450 var size = this.config.initialSize || this.config.width;
36451 if(typeof size != "undefined"){
36452 this.el.setWidth(size);
36456 getBox : function(){
36457 if(this.collapsed){
36458 return this.collapsedEl.getBox();
36460 var box = this.el.getBox();
36462 box.width += this.split.el.getWidth();
36467 updateBox : function(box){
36468 if(this.split && !this.collapsed){
36469 var sw = this.split.el.getWidth();
36471 this.split.el.setLeft(box.x+box.width);
36472 this.split.el.setTop(box.y);
36473 this.split.el.setHeight(box.height);
36475 if(this.collapsed){
36476 this.updateBody(null, box.height);
36478 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36481 Roo.namespace("Roo.bootstrap.panel");/*
36483 * Ext JS Library 1.1.1
36484 * Copyright(c) 2006-2007, Ext JS, LLC.
36486 * Originally Released Under LGPL - original licence link has changed is not relivant.
36489 * <script type="text/javascript">
36492 * @class Roo.ContentPanel
36493 * @extends Roo.util.Observable
36494 * A basic ContentPanel element.
36495 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36496 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36497 * @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
36498 * @cfg {Boolean} closable True if the panel can be closed/removed
36499 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36500 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36501 * @cfg {Toolbar} toolbar A toolbar for this panel
36502 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36503 * @cfg {String} title The title for this panel
36504 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36505 * @cfg {String} url Calls {@link #setUrl} with this value
36506 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36507 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36508 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36509 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36510 * @cfg {Boolean} badges render the badges
36513 * Create a new ContentPanel.
36514 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36515 * @param {String/Object} config A string to set only the title or a config object
36516 * @param {String} content (optional) Set the HTML content for this panel
36517 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36519 Roo.bootstrap.panel.Content = function( config){
36521 this.tpl = config.tpl || false;
36523 var el = config.el;
36524 var content = config.content;
36526 if(config.autoCreate){ // xtype is available if this is called from factory
36529 this.el = Roo.get(el);
36530 if(!this.el && config && config.autoCreate){
36531 if(typeof config.autoCreate == "object"){
36532 if(!config.autoCreate.id){
36533 config.autoCreate.id = config.id||el;
36535 this.el = Roo.DomHelper.append(document.body,
36536 config.autoCreate, true);
36538 var elcfg = { tag: "div",
36539 cls: "roo-layout-inactive-content",
36543 elcfg.html = config.html;
36547 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36550 this.closable = false;
36551 this.loaded = false;
36552 this.active = false;
36555 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36557 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36559 this.wrapEl = this.el; //this.el.wrap();
36561 if (config.toolbar.items) {
36562 ti = config.toolbar.items ;
36563 delete config.toolbar.items ;
36567 this.toolbar.render(this.wrapEl, 'before');
36568 for(var i =0;i < ti.length;i++) {
36569 // Roo.log(['add child', items[i]]);
36570 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36572 this.toolbar.items = nitems;
36573 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36574 delete config.toolbar;
36578 // xtype created footer. - not sure if will work as we normally have to render first..
36579 if (this.footer && !this.footer.el && this.footer.xtype) {
36580 if (!this.wrapEl) {
36581 this.wrapEl = this.el.wrap();
36584 this.footer.container = this.wrapEl.createChild();
36586 this.footer = Roo.factory(this.footer, Roo);
36591 if(typeof config == "string"){
36592 this.title = config;
36594 Roo.apply(this, config);
36598 this.resizeEl = Roo.get(this.resizeEl, true);
36600 this.resizeEl = this.el;
36602 // handle view.xtype
36610 * Fires when this panel is activated.
36611 * @param {Roo.ContentPanel} this
36615 * @event deactivate
36616 * Fires when this panel is activated.
36617 * @param {Roo.ContentPanel} this
36619 "deactivate" : true,
36623 * Fires when this panel is resized if fitToFrame is true.
36624 * @param {Roo.ContentPanel} this
36625 * @param {Number} width The width after any component adjustments
36626 * @param {Number} height The height after any component adjustments
36632 * Fires when this tab is created
36633 * @param {Roo.ContentPanel} this
36644 if(this.autoScroll){
36645 this.resizeEl.setStyle("overflow", "auto");
36647 // fix randome scrolling
36648 //this.el.on('scroll', function() {
36649 // Roo.log('fix random scolling');
36650 // this.scrollTo('top',0);
36653 content = content || this.content;
36655 this.setContent(content);
36657 if(config && config.url){
36658 this.setUrl(this.url, this.params, this.loadOnce);
36663 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36665 if (this.view && typeof(this.view.xtype) != 'undefined') {
36666 this.view.el = this.el.appendChild(document.createElement("div"));
36667 this.view = Roo.factory(this.view);
36668 this.view.render && this.view.render(false, '');
36672 this.fireEvent('render', this);
36675 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36679 setRegion : function(region){
36680 this.region = region;
36681 this.setActiveClass(region && !this.background);
36685 setActiveClass: function(state)
36688 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36689 this.el.setStyle('position','relative');
36691 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36692 this.el.setStyle('position', 'absolute');
36697 * Returns the toolbar for this Panel if one was configured.
36698 * @return {Roo.Toolbar}
36700 getToolbar : function(){
36701 return this.toolbar;
36704 setActiveState : function(active)
36706 this.active = active;
36707 this.setActiveClass(active);
36709 if(this.fireEvent("deactivate", this) === false){
36714 this.fireEvent("activate", this);
36718 * Updates this panel's element
36719 * @param {String} content The new content
36720 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36722 setContent : function(content, loadScripts){
36723 this.el.update(content, loadScripts);
36726 ignoreResize : function(w, h){
36727 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36730 this.lastSize = {width: w, height: h};
36735 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36736 * @return {Roo.UpdateManager} The UpdateManager
36738 getUpdateManager : function(){
36739 return this.el.getUpdateManager();
36742 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36743 * @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:
36746 url: "your-url.php",
36747 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36748 callback: yourFunction,
36749 scope: yourObject, //(optional scope)
36752 text: "Loading...",
36757 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36758 * 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.
36759 * @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}
36760 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36761 * @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.
36762 * @return {Roo.ContentPanel} this
36765 var um = this.el.getUpdateManager();
36766 um.update.apply(um, arguments);
36772 * 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.
36773 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36774 * @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)
36775 * @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)
36776 * @return {Roo.UpdateManager} The UpdateManager
36778 setUrl : function(url, params, loadOnce){
36779 if(this.refreshDelegate){
36780 this.removeListener("activate", this.refreshDelegate);
36782 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36783 this.on("activate", this.refreshDelegate);
36784 return this.el.getUpdateManager();
36787 _handleRefresh : function(url, params, loadOnce){
36788 if(!loadOnce || !this.loaded){
36789 var updater = this.el.getUpdateManager();
36790 updater.update(url, params, this._setLoaded.createDelegate(this));
36794 _setLoaded : function(){
36795 this.loaded = true;
36799 * Returns this panel's id
36802 getId : function(){
36807 * Returns this panel's element - used by regiosn to add.
36808 * @return {Roo.Element}
36810 getEl : function(){
36811 return this.wrapEl || this.el;
36816 adjustForComponents : function(width, height)
36818 //Roo.log('adjustForComponents ');
36819 if(this.resizeEl != this.el){
36820 width -= this.el.getFrameWidth('lr');
36821 height -= this.el.getFrameWidth('tb');
36824 var te = this.toolbar.getEl();
36825 te.setWidth(width);
36826 height -= te.getHeight();
36829 var te = this.footer.getEl();
36830 te.setWidth(width);
36831 height -= te.getHeight();
36835 if(this.adjustments){
36836 width += this.adjustments[0];
36837 height += this.adjustments[1];
36839 return {"width": width, "height": height};
36842 setSize : function(width, height){
36843 if(this.fitToFrame && !this.ignoreResize(width, height)){
36844 if(this.fitContainer && this.resizeEl != this.el){
36845 this.el.setSize(width, height);
36847 var size = this.adjustForComponents(width, height);
36848 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36849 this.fireEvent('resize', this, size.width, size.height);
36854 * Returns this panel's title
36857 getTitle : function(){
36859 if (typeof(this.title) != 'object') {
36864 for (var k in this.title) {
36865 if (!this.title.hasOwnProperty(k)) {
36869 if (k.indexOf('-') >= 0) {
36870 var s = k.split('-');
36871 for (var i = 0; i<s.length; i++) {
36872 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36875 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36882 * Set this panel's title
36883 * @param {String} title
36885 setTitle : function(title){
36886 this.title = title;
36888 this.region.updatePanelTitle(this, title);
36893 * Returns true is this panel was configured to be closable
36894 * @return {Boolean}
36896 isClosable : function(){
36897 return this.closable;
36900 beforeSlide : function(){
36902 this.resizeEl.clip();
36905 afterSlide : function(){
36907 this.resizeEl.unclip();
36911 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36912 * Will fail silently if the {@link #setUrl} method has not been called.
36913 * This does not activate the panel, just updates its content.
36915 refresh : function(){
36916 if(this.refreshDelegate){
36917 this.loaded = false;
36918 this.refreshDelegate();
36923 * Destroys this panel
36925 destroy : function(){
36926 this.el.removeAllListeners();
36927 var tempEl = document.createElement("span");
36928 tempEl.appendChild(this.el.dom);
36929 tempEl.innerHTML = "";
36935 * form - if the content panel contains a form - this is a reference to it.
36936 * @type {Roo.form.Form}
36940 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36941 * This contains a reference to it.
36947 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36957 * @param {Object} cfg Xtype definition of item to add.
36961 getChildContainer: function () {
36962 return this.getEl();
36967 var ret = new Roo.factory(cfg);
36972 if (cfg.xtype.match(/^Form$/)) {
36975 //if (this.footer) {
36976 // el = this.footer.container.insertSibling(false, 'before');
36978 el = this.el.createChild();
36981 this.form = new Roo.form.Form(cfg);
36984 if ( this.form.allItems.length) {
36985 this.form.render(el.dom);
36989 // should only have one of theses..
36990 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36991 // views.. should not be just added - used named prop 'view''
36993 cfg.el = this.el.appendChild(document.createElement("div"));
36996 var ret = new Roo.factory(cfg);
36998 ret.render && ret.render(false, ''); // render blank..
37008 * @class Roo.bootstrap.panel.Grid
37009 * @extends Roo.bootstrap.panel.Content
37011 * Create a new GridPanel.
37012 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37013 * @param {Object} config A the config object
37019 Roo.bootstrap.panel.Grid = function(config)
37023 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37024 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37026 config.el = this.wrapper;
37027 //this.el = this.wrapper;
37029 if (config.container) {
37030 // ctor'ed from a Border/panel.grid
37033 this.wrapper.setStyle("overflow", "hidden");
37034 this.wrapper.addClass('roo-grid-container');
37039 if(config.toolbar){
37040 var tool_el = this.wrapper.createChild();
37041 this.toolbar = Roo.factory(config.toolbar);
37043 if (config.toolbar.items) {
37044 ti = config.toolbar.items ;
37045 delete config.toolbar.items ;
37049 this.toolbar.render(tool_el);
37050 for(var i =0;i < ti.length;i++) {
37051 // Roo.log(['add child', items[i]]);
37052 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37054 this.toolbar.items = nitems;
37056 delete config.toolbar;
37059 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37060 config.grid.scrollBody = true;;
37061 config.grid.monitorWindowResize = false; // turn off autosizing
37062 config.grid.autoHeight = false;
37063 config.grid.autoWidth = false;
37065 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37067 if (config.background) {
37068 // render grid on panel activation (if panel background)
37069 this.on('activate', function(gp) {
37070 if (!gp.grid.rendered) {
37071 gp.grid.render(this.wrapper);
37072 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37077 this.grid.render(this.wrapper);
37078 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37081 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37082 // ??? needed ??? config.el = this.wrapper;
37087 // xtype created footer. - not sure if will work as we normally have to render first..
37088 if (this.footer && !this.footer.el && this.footer.xtype) {
37090 var ctr = this.grid.getView().getFooterPanel(true);
37091 this.footer.dataSource = this.grid.dataSource;
37092 this.footer = Roo.factory(this.footer, Roo);
37093 this.footer.render(ctr);
37103 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37104 getId : function(){
37105 return this.grid.id;
37109 * Returns the grid for this panel
37110 * @return {Roo.bootstrap.Table}
37112 getGrid : function(){
37116 setSize : function(width, height){
37117 if(!this.ignoreResize(width, height)){
37118 var grid = this.grid;
37119 var size = this.adjustForComponents(width, height);
37120 var gridel = grid.getGridEl();
37121 gridel.setSize(size.width, size.height);
37123 var thd = grid.getGridEl().select('thead',true).first();
37124 var tbd = grid.getGridEl().select('tbody', true).first();
37126 tbd.setSize(width, height - thd.getHeight());
37135 beforeSlide : function(){
37136 this.grid.getView().scroller.clip();
37139 afterSlide : function(){
37140 this.grid.getView().scroller.unclip();
37143 destroy : function(){
37144 this.grid.destroy();
37146 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37151 * @class Roo.bootstrap.panel.Nest
37152 * @extends Roo.bootstrap.panel.Content
37154 * Create a new Panel, that can contain a layout.Border.
37157 * @param {Roo.BorderLayout} layout The layout for this panel
37158 * @param {String/Object} config A string to set only the title or a config object
37160 Roo.bootstrap.panel.Nest = function(config)
37162 // construct with only one argument..
37163 /* FIXME - implement nicer consturctors
37164 if (layout.layout) {
37166 layout = config.layout;
37167 delete config.layout;
37169 if (layout.xtype && !layout.getEl) {
37170 // then layout needs constructing..
37171 layout = Roo.factory(layout, Roo);
37175 config.el = config.layout.getEl();
37177 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37179 config.layout.monitorWindowResize = false; // turn off autosizing
37180 this.layout = config.layout;
37181 this.layout.getEl().addClass("roo-layout-nested-layout");
37188 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37190 setSize : function(width, height){
37191 if(!this.ignoreResize(width, height)){
37192 var size = this.adjustForComponents(width, height);
37193 var el = this.layout.getEl();
37194 if (size.height < 1) {
37195 el.setWidth(size.width);
37197 el.setSize(size.width, size.height);
37199 var touch = el.dom.offsetWidth;
37200 this.layout.layout();
37201 // ie requires a double layout on the first pass
37202 if(Roo.isIE && !this.initialized){
37203 this.initialized = true;
37204 this.layout.layout();
37209 // activate all subpanels if not currently active..
37211 setActiveState : function(active){
37212 this.active = active;
37213 this.setActiveClass(active);
37216 this.fireEvent("deactivate", this);
37220 this.fireEvent("activate", this);
37221 // not sure if this should happen before or after..
37222 if (!this.layout) {
37223 return; // should not happen..
37226 for (var r in this.layout.regions) {
37227 reg = this.layout.getRegion(r);
37228 if (reg.getActivePanel()) {
37229 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37230 reg.setActivePanel(reg.getActivePanel());
37233 if (!reg.panels.length) {
37236 reg.showPanel(reg.getPanel(0));
37245 * Returns the nested BorderLayout for this panel
37246 * @return {Roo.BorderLayout}
37248 getLayout : function(){
37249 return this.layout;
37253 * Adds a xtype elements to the layout of the nested panel
37257 xtype : 'ContentPanel',
37264 xtype : 'NestedLayoutPanel',
37270 items : [ ... list of content panels or nested layout panels.. ]
37274 * @param {Object} cfg Xtype definition of item to add.
37276 addxtype : function(cfg) {
37277 return this.layout.addxtype(cfg);
37282 * Ext JS Library 1.1.1
37283 * Copyright(c) 2006-2007, Ext JS, LLC.
37285 * Originally Released Under LGPL - original licence link has changed is not relivant.
37288 * <script type="text/javascript">
37291 * @class Roo.TabPanel
37292 * @extends Roo.util.Observable
37293 * A lightweight tab container.
37297 // basic tabs 1, built from existing content
37298 var tabs = new Roo.TabPanel("tabs1");
37299 tabs.addTab("script", "View Script");
37300 tabs.addTab("markup", "View Markup");
37301 tabs.activate("script");
37303 // more advanced tabs, built from javascript
37304 var jtabs = new Roo.TabPanel("jtabs");
37305 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37307 // set up the UpdateManager
37308 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37309 var updater = tab2.getUpdateManager();
37310 updater.setDefaultUrl("ajax1.htm");
37311 tab2.on('activate', updater.refresh, updater, true);
37313 // Use setUrl for Ajax loading
37314 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37315 tab3.setUrl("ajax2.htm", null, true);
37318 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37321 jtabs.activate("jtabs-1");
37324 * Create a new TabPanel.
37325 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37326 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37328 Roo.bootstrap.panel.Tabs = function(config){
37330 * The container element for this TabPanel.
37331 * @type Roo.Element
37333 this.el = Roo.get(config.el);
37336 if(typeof config == "boolean"){
37337 this.tabPosition = config ? "bottom" : "top";
37339 Roo.apply(this, config);
37343 if(this.tabPosition == "bottom"){
37344 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37345 this.el.addClass("roo-tabs-bottom");
37347 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37348 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37349 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37351 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37353 if(this.tabPosition != "bottom"){
37354 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37355 * @type Roo.Element
37357 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37358 this.el.addClass("roo-tabs-top");
37362 this.bodyEl.setStyle("position", "relative");
37364 this.active = null;
37365 this.activateDelegate = this.activate.createDelegate(this);
37370 * Fires when the active tab changes
37371 * @param {Roo.TabPanel} this
37372 * @param {Roo.TabPanelItem} activePanel The new active tab
37376 * @event beforetabchange
37377 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37378 * @param {Roo.TabPanel} this
37379 * @param {Object} e Set cancel to true on this object to cancel the tab change
37380 * @param {Roo.TabPanelItem} tab The tab being changed to
37382 "beforetabchange" : true
37385 Roo.EventManager.onWindowResize(this.onResize, this);
37386 this.cpad = this.el.getPadding("lr");
37387 this.hiddenCount = 0;
37390 // toolbar on the tabbar support...
37391 if (this.toolbar) {
37392 alert("no toolbar support yet");
37393 this.toolbar = false;
37395 var tcfg = this.toolbar;
37396 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37397 this.toolbar = new Roo.Toolbar(tcfg);
37398 if (Roo.isSafari) {
37399 var tbl = tcfg.container.child('table', true);
37400 tbl.setAttribute('width', '100%');
37408 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37411 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37413 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37415 tabPosition : "top",
37417 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37419 currentTabWidth : 0,
37421 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37425 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37429 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37431 preferredTabWidth : 175,
37433 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37435 resizeTabs : false,
37437 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37439 monitorResize : true,
37441 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37446 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37447 * @param {String} id The id of the div to use <b>or create</b>
37448 * @param {String} text The text for the tab
37449 * @param {String} content (optional) Content to put in the TabPanelItem body
37450 * @param {Boolean} closable (optional) True to create a close icon on the tab
37451 * @return {Roo.TabPanelItem} The created TabPanelItem
37453 addTab : function(id, text, content, closable, tpl)
37455 var item = new Roo.bootstrap.panel.TabItem({
37459 closable : closable,
37462 this.addTabItem(item);
37464 item.setContent(content);
37470 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37471 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37472 * @return {Roo.TabPanelItem}
37474 getTab : function(id){
37475 return this.items[id];
37479 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37480 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37482 hideTab : function(id){
37483 var t = this.items[id];
37486 this.hiddenCount++;
37487 this.autoSizeTabs();
37492 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37493 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37495 unhideTab : function(id){
37496 var t = this.items[id];
37498 t.setHidden(false);
37499 this.hiddenCount--;
37500 this.autoSizeTabs();
37505 * Adds an existing {@link Roo.TabPanelItem}.
37506 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37508 addTabItem : function(item){
37509 this.items[item.id] = item;
37510 this.items.push(item);
37511 // if(this.resizeTabs){
37512 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37513 // this.autoSizeTabs();
37515 // item.autoSize();
37520 * Removes a {@link Roo.TabPanelItem}.
37521 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37523 removeTab : function(id){
37524 var items = this.items;
37525 var tab = items[id];
37526 if(!tab) { return; }
37527 var index = items.indexOf(tab);
37528 if(this.active == tab && items.length > 1){
37529 var newTab = this.getNextAvailable(index);
37534 this.stripEl.dom.removeChild(tab.pnode.dom);
37535 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37536 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37538 items.splice(index, 1);
37539 delete this.items[tab.id];
37540 tab.fireEvent("close", tab);
37541 tab.purgeListeners();
37542 this.autoSizeTabs();
37545 getNextAvailable : function(start){
37546 var items = this.items;
37548 // look for a next tab that will slide over to
37549 // replace the one being removed
37550 while(index < items.length){
37551 var item = items[++index];
37552 if(item && !item.isHidden()){
37556 // if one isn't found select the previous tab (on the left)
37559 var item = items[--index];
37560 if(item && !item.isHidden()){
37568 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37569 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37571 disableTab : function(id){
37572 var tab = this.items[id];
37573 if(tab && this.active != tab){
37579 * Enables a {@link Roo.TabPanelItem} that is disabled.
37580 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37582 enableTab : function(id){
37583 var tab = this.items[id];
37588 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37589 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37590 * @return {Roo.TabPanelItem} The TabPanelItem.
37592 activate : function(id){
37593 var tab = this.items[id];
37597 if(tab == this.active || tab.disabled){
37601 this.fireEvent("beforetabchange", this, e, tab);
37602 if(e.cancel !== true && !tab.disabled){
37604 this.active.hide();
37606 this.active = this.items[id];
37607 this.active.show();
37608 this.fireEvent("tabchange", this, this.active);
37614 * Gets the active {@link Roo.TabPanelItem}.
37615 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37617 getActiveTab : function(){
37618 return this.active;
37622 * Updates the tab body element to fit the height of the container element
37623 * for overflow scrolling
37624 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37626 syncHeight : function(targetHeight){
37627 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37628 var bm = this.bodyEl.getMargins();
37629 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37630 this.bodyEl.setHeight(newHeight);
37634 onResize : function(){
37635 if(this.monitorResize){
37636 this.autoSizeTabs();
37641 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37643 beginUpdate : function(){
37644 this.updating = true;
37648 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37650 endUpdate : function(){
37651 this.updating = false;
37652 this.autoSizeTabs();
37656 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37658 autoSizeTabs : function(){
37659 var count = this.items.length;
37660 var vcount = count - this.hiddenCount;
37661 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37664 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37665 var availWidth = Math.floor(w / vcount);
37666 var b = this.stripBody;
37667 if(b.getWidth() > w){
37668 var tabs = this.items;
37669 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37670 if(availWidth < this.minTabWidth){
37671 /*if(!this.sleft){ // incomplete scrolling code
37672 this.createScrollButtons();
37675 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37678 if(this.currentTabWidth < this.preferredTabWidth){
37679 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37685 * Returns the number of tabs in this TabPanel.
37688 getCount : function(){
37689 return this.items.length;
37693 * Resizes all the tabs to the passed width
37694 * @param {Number} The new width
37696 setTabWidth : function(width){
37697 this.currentTabWidth = width;
37698 for(var i = 0, len = this.items.length; i < len; i++) {
37699 if(!this.items[i].isHidden()) {
37700 this.items[i].setWidth(width);
37706 * Destroys this TabPanel
37707 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37709 destroy : function(removeEl){
37710 Roo.EventManager.removeResizeListener(this.onResize, this);
37711 for(var i = 0, len = this.items.length; i < len; i++){
37712 this.items[i].purgeListeners();
37714 if(removeEl === true){
37715 this.el.update("");
37720 createStrip : function(container)
37722 var strip = document.createElement("nav");
37723 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37724 container.appendChild(strip);
37728 createStripList : function(strip)
37730 // div wrapper for retard IE
37731 // returns the "tr" element.
37732 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37733 //'<div class="x-tabs-strip-wrap">'+
37734 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37735 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37736 return strip.firstChild; //.firstChild.firstChild.firstChild;
37738 createBody : function(container)
37740 var body = document.createElement("div");
37741 Roo.id(body, "tab-body");
37742 //Roo.fly(body).addClass("x-tabs-body");
37743 Roo.fly(body).addClass("tab-content");
37744 container.appendChild(body);
37747 createItemBody :function(bodyEl, id){
37748 var body = Roo.getDom(id);
37750 body = document.createElement("div");
37753 //Roo.fly(body).addClass("x-tabs-item-body");
37754 Roo.fly(body).addClass("tab-pane");
37755 bodyEl.insertBefore(body, bodyEl.firstChild);
37759 createStripElements : function(stripEl, text, closable, tpl)
37761 var td = document.createElement("li"); // was td..
37764 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37767 stripEl.appendChild(td);
37769 td.className = "x-tabs-closable";
37770 if(!this.closeTpl){
37771 this.closeTpl = new Roo.Template(
37772 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37773 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37774 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37777 var el = this.closeTpl.overwrite(td, {"text": text});
37778 var close = el.getElementsByTagName("div")[0];
37779 var inner = el.getElementsByTagName("em")[0];
37780 return {"el": el, "close": close, "inner": inner};
37783 // not sure what this is..
37784 // if(!this.tabTpl){
37785 //this.tabTpl = new Roo.Template(
37786 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37787 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37789 // this.tabTpl = new Roo.Template(
37790 // '<a href="#">' +
37791 // '<span unselectable="on"' +
37792 // (this.disableTooltips ? '' : ' title="{text}"') +
37793 // ' >{text}</span></a>'
37799 var template = tpl || this.tabTpl || false;
37803 template = new Roo.Template(
37805 '<span unselectable="on"' +
37806 (this.disableTooltips ? '' : ' title="{text}"') +
37807 ' >{text}</span></a>'
37811 switch (typeof(template)) {
37815 template = new Roo.Template(template);
37821 var el = template.overwrite(td, {"text": text});
37823 var inner = el.getElementsByTagName("span")[0];
37825 return {"el": el, "inner": inner};
37833 * @class Roo.TabPanelItem
37834 * @extends Roo.util.Observable
37835 * Represents an individual item (tab plus body) in a TabPanel.
37836 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37837 * @param {String} id The id of this TabPanelItem
37838 * @param {String} text The text for the tab of this TabPanelItem
37839 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37841 Roo.bootstrap.panel.TabItem = function(config){
37843 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37844 * @type Roo.TabPanel
37846 this.tabPanel = config.panel;
37848 * The id for this TabPanelItem
37851 this.id = config.id;
37853 this.disabled = false;
37855 this.text = config.text;
37857 this.loaded = false;
37858 this.closable = config.closable;
37861 * The body element for this TabPanelItem.
37862 * @type Roo.Element
37864 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37865 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37866 this.bodyEl.setStyle("display", "block");
37867 this.bodyEl.setStyle("zoom", "1");
37868 //this.hideAction();
37870 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37872 this.el = Roo.get(els.el);
37873 this.inner = Roo.get(els.inner, true);
37874 this.textEl = Roo.get(this.el.dom.firstChild, true);
37875 this.pnode = Roo.get(els.el.parentNode, true);
37876 // this.el.on("mousedown", this.onTabMouseDown, this);
37877 this.el.on("click", this.onTabClick, this);
37879 if(config.closable){
37880 var c = Roo.get(els.close, true);
37881 c.dom.title = this.closeText;
37882 c.addClassOnOver("close-over");
37883 c.on("click", this.closeClick, this);
37889 * Fires when this tab becomes the active tab.
37890 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37891 * @param {Roo.TabPanelItem} this
37895 * @event beforeclose
37896 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37897 * @param {Roo.TabPanelItem} this
37898 * @param {Object} e Set cancel to true on this object to cancel the close.
37900 "beforeclose": true,
37903 * Fires when this tab is closed.
37904 * @param {Roo.TabPanelItem} this
37908 * @event deactivate
37909 * Fires when this tab is no longer the active tab.
37910 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37911 * @param {Roo.TabPanelItem} this
37913 "deactivate" : true
37915 this.hidden = false;
37917 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37920 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37922 purgeListeners : function(){
37923 Roo.util.Observable.prototype.purgeListeners.call(this);
37924 this.el.removeAllListeners();
37927 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37930 this.pnode.addClass("active");
37933 this.tabPanel.stripWrap.repaint();
37935 this.fireEvent("activate", this.tabPanel, this);
37939 * Returns true if this tab is the active tab.
37940 * @return {Boolean}
37942 isActive : function(){
37943 return this.tabPanel.getActiveTab() == this;
37947 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37950 this.pnode.removeClass("active");
37952 this.fireEvent("deactivate", this.tabPanel, this);
37955 hideAction : function(){
37956 this.bodyEl.hide();
37957 this.bodyEl.setStyle("position", "absolute");
37958 this.bodyEl.setLeft("-20000px");
37959 this.bodyEl.setTop("-20000px");
37962 showAction : function(){
37963 this.bodyEl.setStyle("position", "relative");
37964 this.bodyEl.setTop("");
37965 this.bodyEl.setLeft("");
37966 this.bodyEl.show();
37970 * Set the tooltip for the tab.
37971 * @param {String} tooltip The tab's tooltip
37973 setTooltip : function(text){
37974 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37975 this.textEl.dom.qtip = text;
37976 this.textEl.dom.removeAttribute('title');
37978 this.textEl.dom.title = text;
37982 onTabClick : function(e){
37983 e.preventDefault();
37984 this.tabPanel.activate(this.id);
37987 onTabMouseDown : function(e){
37988 e.preventDefault();
37989 this.tabPanel.activate(this.id);
37992 getWidth : function(){
37993 return this.inner.getWidth();
37996 setWidth : function(width){
37997 var iwidth = width - this.pnode.getPadding("lr");
37998 this.inner.setWidth(iwidth);
37999 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38000 this.pnode.setWidth(width);
38004 * Show or hide the tab
38005 * @param {Boolean} hidden True to hide or false to show.
38007 setHidden : function(hidden){
38008 this.hidden = hidden;
38009 this.pnode.setStyle("display", hidden ? "none" : "");
38013 * Returns true if this tab is "hidden"
38014 * @return {Boolean}
38016 isHidden : function(){
38017 return this.hidden;
38021 * Returns the text for this tab
38024 getText : function(){
38028 autoSize : function(){
38029 //this.el.beginMeasure();
38030 this.textEl.setWidth(1);
38032 * #2804 [new] Tabs in Roojs
38033 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38035 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38036 //this.el.endMeasure();
38040 * Sets the text for the tab (Note: this also sets the tooltip text)
38041 * @param {String} text The tab's text and tooltip
38043 setText : function(text){
38045 this.textEl.update(text);
38046 this.setTooltip(text);
38047 //if(!this.tabPanel.resizeTabs){
38048 // this.autoSize();
38052 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38054 activate : function(){
38055 this.tabPanel.activate(this.id);
38059 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38061 disable : function(){
38062 if(this.tabPanel.active != this){
38063 this.disabled = true;
38064 this.pnode.addClass("disabled");
38069 * Enables this TabPanelItem if it was previously disabled.
38071 enable : function(){
38072 this.disabled = false;
38073 this.pnode.removeClass("disabled");
38077 * Sets the content for this TabPanelItem.
38078 * @param {String} content The content
38079 * @param {Boolean} loadScripts true to look for and load scripts
38081 setContent : function(content, loadScripts){
38082 this.bodyEl.update(content, loadScripts);
38086 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38087 * @return {Roo.UpdateManager} The UpdateManager
38089 getUpdateManager : function(){
38090 return this.bodyEl.getUpdateManager();
38094 * Set a URL to be used to load the content for this TabPanelItem.
38095 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38096 * @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)
38097 * @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)
38098 * @return {Roo.UpdateManager} The UpdateManager
38100 setUrl : function(url, params, loadOnce){
38101 if(this.refreshDelegate){
38102 this.un('activate', this.refreshDelegate);
38104 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38105 this.on("activate", this.refreshDelegate);
38106 return this.bodyEl.getUpdateManager();
38110 _handleRefresh : function(url, params, loadOnce){
38111 if(!loadOnce || !this.loaded){
38112 var updater = this.bodyEl.getUpdateManager();
38113 updater.update(url, params, this._setLoaded.createDelegate(this));
38118 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38119 * Will fail silently if the setUrl method has not been called.
38120 * This does not activate the panel, just updates its content.
38122 refresh : function(){
38123 if(this.refreshDelegate){
38124 this.loaded = false;
38125 this.refreshDelegate();
38130 _setLoaded : function(){
38131 this.loaded = true;
38135 closeClick : function(e){
38138 this.fireEvent("beforeclose", this, o);
38139 if(o.cancel !== true){
38140 this.tabPanel.removeTab(this.id);
38144 * The text displayed in the tooltip for the close icon.
38147 closeText : "Close this tab"
38150 * This script refer to:
38151 * Title: International Telephone Input
38152 * Author: Jack O'Connor
38153 * Code version: v12.1.12
38154 * Availability: https://github.com/jackocnr/intl-tel-input.git
38157 Roo.bootstrap.PhoneInputData = function() {
38160 "Afghanistan (افغانستان)",
38165 "Albania (Shqipëri)",
38170 "Algeria (الجزائر)",
38195 "Antigua and Barbuda",
38205 "Armenia (Հայաստան)",
38221 "Austria (Österreich)",
38226 "Azerbaijan (Azərbaycan)",
38236 "Bahrain (البحرين)",
38241 "Bangladesh (বাংলাদেশ)",
38251 "Belarus (Беларусь)",
38256 "Belgium (België)",
38286 "Bosnia and Herzegovina (Босна и Херцеговина)",
38301 "British Indian Ocean Territory",
38306 "British Virgin Islands",
38316 "Bulgaria (България)",
38326 "Burundi (Uburundi)",
38331 "Cambodia (កម្ពុជា)",
38336 "Cameroon (Cameroun)",
38345 ["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"]
38348 "Cape Verde (Kabu Verdi)",
38353 "Caribbean Netherlands",
38364 "Central African Republic (République centrafricaine)",
38384 "Christmas Island",
38390 "Cocos (Keeling) Islands",
38401 "Comoros (جزر القمر)",
38406 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38411 "Congo (Republic) (Congo-Brazzaville)",
38431 "Croatia (Hrvatska)",
38452 "Czech Republic (Česká republika)",
38457 "Denmark (Danmark)",
38472 "Dominican Republic (República Dominicana)",
38476 ["809", "829", "849"]
38494 "Equatorial Guinea (Guinea Ecuatorial)",
38514 "Falkland Islands (Islas Malvinas)",
38519 "Faroe Islands (Føroyar)",
38540 "French Guiana (Guyane française)",
38545 "French Polynesia (Polynésie française)",
38560 "Georgia (საქართველო)",
38565 "Germany (Deutschland)",
38585 "Greenland (Kalaallit Nunaat)",
38622 "Guinea-Bissau (Guiné Bissau)",
38647 "Hungary (Magyarország)",
38652 "Iceland (Ísland)",
38672 "Iraq (العراق)",
38688 "Israel (ישראל)",
38715 "Jordan (الأردن)",
38720 "Kazakhstan (Казахстан)",
38741 "Kuwait (الكويت)",
38746 "Kyrgyzstan (Кыргызстан)",
38756 "Latvia (Latvija)",
38761 "Lebanon (لبنان)",
38776 "Libya (ليبيا)",
38786 "Lithuania (Lietuva)",
38801 "Macedonia (FYROM) (Македонија)",
38806 "Madagascar (Madagasikara)",
38836 "Marshall Islands",
38846 "Mauritania (موريتانيا)",
38851 "Mauritius (Moris)",
38872 "Moldova (Republica Moldova)",
38882 "Mongolia (Монгол)",
38887 "Montenegro (Crna Gora)",
38897 "Morocco (المغرب)",
38903 "Mozambique (Moçambique)",
38908 "Myanmar (Burma) (မြန်မာ)",
38913 "Namibia (Namibië)",
38928 "Netherlands (Nederland)",
38933 "New Caledonia (Nouvelle-Calédonie)",
38968 "North Korea (조선 민주주의 인민 공화국)",
38973 "Northern Mariana Islands",
38989 "Pakistan (پاکستان)",
38999 "Palestine (فلسطين)",
39009 "Papua New Guinea",
39051 "Réunion (La Réunion)",
39057 "Romania (România)",
39073 "Saint Barthélemy",
39084 "Saint Kitts and Nevis",
39094 "Saint Martin (Saint-Martin (partie française))",
39100 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39105 "Saint Vincent and the Grenadines",
39120 "São Tomé and Príncipe (São Tomé e Príncipe)",
39125 "Saudi Arabia (المملكة العربية السعودية)",
39130 "Senegal (Sénégal)",
39160 "Slovakia (Slovensko)",
39165 "Slovenia (Slovenija)",
39175 "Somalia (Soomaaliya)",
39185 "South Korea (대한민국)",
39190 "South Sudan (جنوب السودان)",
39200 "Sri Lanka (ශ්රී ලංකාව)",
39205 "Sudan (السودان)",
39215 "Svalbard and Jan Mayen",
39226 "Sweden (Sverige)",
39231 "Switzerland (Schweiz)",
39236 "Syria (سوريا)",
39281 "Trinidad and Tobago",
39286 "Tunisia (تونس)",
39291 "Turkey (Türkiye)",
39301 "Turks and Caicos Islands",
39311 "U.S. Virgin Islands",
39321 "Ukraine (Україна)",
39326 "United Arab Emirates (الإمارات العربية المتحدة)",
39348 "Uzbekistan (Oʻzbekiston)",
39358 "Vatican City (Città del Vaticano)",
39369 "Vietnam (Việt Nam)",
39374 "Wallis and Futuna (Wallis-et-Futuna)",
39379 "Western Sahara (الصحراء الغربية)",
39385 "Yemen (اليمن)",
39409 * This script refer to:
39410 * Title: International Telephone Input
39411 * Author: Jack O'Connor
39412 * Code version: v12.1.12
39413 * Availability: https://github.com/jackocnr/intl-tel-input.git
39417 * @class Roo.bootstrap.PhoneInput
39418 * @extends Roo.bootstrap.TriggerField
39419 * An input with International dial-code selection
39421 * @cfg {String} defaultDialCode default '+852'
39422 * @cfg {Array} preferedCountries default []
39425 * Create a new PhoneInput.
39426 * @param {Object} config Configuration options
39429 Roo.bootstrap.PhoneInput = function(config) {
39430 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39433 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39435 listWidth: undefined,
39437 selectedClass: 'active',
39439 invalidClass : "has-warning",
39441 validClass: 'has-success',
39443 allowed: '0123456789',
39446 * @cfg {String} defaultDialCode The default dial code when initializing the input
39448 defaultDialCode: '+852',
39451 * @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
39453 preferedCountries: false,
39455 getAutoCreate : function()
39457 var data = Roo.bootstrap.PhoneInputData();
39458 var align = this.labelAlign || this.parentLabelAlign();
39461 this.allCountries = [];
39462 this.dialCodeMapping = [];
39464 for (var i = 0; i < data.length; i++) {
39466 this.allCountries[i] = {
39470 priority: c[3] || 0,
39471 areaCodes: c[4] || null
39473 this.dialCodeMapping[c[2]] = {
39476 priority: c[3] || 0,
39477 areaCodes: c[4] || null
39489 cls : 'form-control tel-input',
39490 autocomplete: 'new-password'
39493 var hiddenInput = {
39496 cls: 'hidden-tel-input'
39500 hiddenInput.name = this.name;
39503 if (this.disabled) {
39504 input.disabled = true;
39507 var flag_container = {
39524 cls: this.hasFeedback ? 'has-feedback' : '',
39530 cls: 'dial-code-holder',
39537 cls: 'roo-select2-container input-group',
39544 if (this.fieldLabel.length) {
39547 tooltip: 'This field is required'
39553 cls: 'control-label',
39559 html: this.fieldLabel
39562 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39568 if(this.indicatorpos == 'right') {
39569 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39576 if(align == 'left') {
39584 if(this.labelWidth > 12){
39585 label.style = "width: " + this.labelWidth + 'px';
39587 if(this.labelWidth < 13 && this.labelmd == 0){
39588 this.labelmd = this.labelWidth;
39590 if(this.labellg > 0){
39591 label.cls += ' col-lg-' + this.labellg;
39592 input.cls += ' col-lg-' + (12 - this.labellg);
39594 if(this.labelmd > 0){
39595 label.cls += ' col-md-' + this.labelmd;
39596 container.cls += ' col-md-' + (12 - this.labelmd);
39598 if(this.labelsm > 0){
39599 label.cls += ' col-sm-' + this.labelsm;
39600 container.cls += ' col-sm-' + (12 - this.labelsm);
39602 if(this.labelxs > 0){
39603 label.cls += ' col-xs-' + this.labelxs;
39604 container.cls += ' col-xs-' + (12 - this.labelxs);
39614 var settings = this;
39616 ['xs','sm','md','lg'].map(function(size){
39617 if (settings[size]) {
39618 cfg.cls += ' col-' + size + '-' + settings[size];
39622 this.store = new Roo.data.Store({
39623 proxy : new Roo.data.MemoryProxy({}),
39624 reader : new Roo.data.JsonReader({
39635 'name' : 'dialCode',
39639 'name' : 'priority',
39643 'name' : 'areaCodes',
39650 if(!this.preferedCountries) {
39651 this.preferedCountries = [
39658 var p = this.preferedCountries.reverse();
39661 for (var i = 0; i < p.length; i++) {
39662 for (var j = 0; j < this.allCountries.length; j++) {
39663 if(this.allCountries[j].iso2 == p[i]) {
39664 var t = this.allCountries[j];
39665 this.allCountries.splice(j,1);
39666 this.allCountries.unshift(t);
39672 this.store.proxy.data = {
39674 data: this.allCountries
39680 initEvents : function()
39683 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39685 this.indicator = this.indicatorEl();
39686 this.flag = this.flagEl();
39687 this.dialCodeHolder = this.dialCodeHolderEl();
39689 this.trigger = this.el.select('div.flag-box',true).first();
39690 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39695 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39696 _this.list.setWidth(lw);
39699 this.list.on('mouseover', this.onViewOver, this);
39700 this.list.on('mousemove', this.onViewMove, this);
39701 this.inputEl().on("keyup", this.onKeyUp, this);
39703 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39705 this.view = new Roo.View(this.list, this.tpl, {
39706 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39709 this.view.on('click', this.onViewClick, this);
39710 this.setValue(this.defaultDialCode);
39713 onTriggerClick : function(e)
39715 Roo.log('trigger click');
39720 if(this.isExpanded()){
39722 this.hasFocus = false;
39724 this.store.load({});
39725 this.hasFocus = true;
39730 isExpanded : function()
39732 return this.list.isVisible();
39735 collapse : function()
39737 if(!this.isExpanded()){
39741 Roo.get(document).un('mousedown', this.collapseIf, this);
39742 Roo.get(document).un('mousewheel', this.collapseIf, this);
39743 this.fireEvent('collapse', this);
39747 expand : function()
39751 if(this.isExpanded() || !this.hasFocus){
39755 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39756 this.list.setWidth(lw);
39759 this.restrictHeight();
39761 Roo.get(document).on('mousedown', this.collapseIf, this);
39762 Roo.get(document).on('mousewheel', this.collapseIf, this);
39764 this.fireEvent('expand', this);
39767 restrictHeight : function()
39769 this.list.alignTo(this.inputEl(), this.listAlign);
39770 this.list.alignTo(this.inputEl(), this.listAlign);
39773 onViewOver : function(e, t)
39775 if(this.inKeyMode){
39778 var item = this.view.findItemFromChild(t);
39781 var index = this.view.indexOf(item);
39782 this.select(index, false);
39787 onViewClick : function(view, doFocus, el, e)
39789 var index = this.view.getSelectedIndexes()[0];
39791 var r = this.store.getAt(index);
39794 this.onSelect(r, index);
39796 if(doFocus !== false && !this.blockFocus){
39797 this.inputEl().focus();
39801 onViewMove : function(e, t)
39803 this.inKeyMode = false;
39806 select : function(index, scrollIntoView)
39808 this.selectedIndex = index;
39809 this.view.select(index);
39810 if(scrollIntoView !== false){
39811 var el = this.view.getNode(index);
39813 this.list.scrollChildIntoView(el, false);
39818 createList : function()
39820 this.list = Roo.get(document.body).createChild({
39822 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39823 style: 'display:none'
39825 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39828 collapseIf : function(e)
39830 var in_combo = e.within(this.el);
39831 var in_list = e.within(this.list);
39832 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39834 if (in_combo || in_list || is_list) {
39840 onSelect : function(record, index)
39842 if(this.fireEvent('beforeselect', this, record, index) !== false){
39844 this.setFlagClass(record.data.iso2);
39845 this.setDialCode(record.data.dialCode);
39846 this.hasFocus = false;
39848 this.fireEvent('select', this, record, index);
39852 flagEl : function()
39854 var flag = this.el.select('div.flag',true).first();
39861 dialCodeHolderEl : function()
39863 var d = this.el.select('input.dial-code-holder',true).first();
39870 setDialCode : function(v)
39872 this.dialCodeHolder.dom.value = '+'+v;
39875 setFlagClass : function(n)
39877 this.flag.dom.className = 'flag '+n;
39880 getValue : function()
39882 var v = this.inputEl().getValue();
39883 if(this.dialCodeHolder) {
39884 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
39889 setValue : function(v)
39891 var d = this.getDialCode(v);
39893 //invalid dial code
39894 if(v.length == 0 || !d || d.length == 0) {
39896 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
39897 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39903 this.setFlagClass(this.dialCodeMapping[d].iso2);
39904 this.setDialCode(d);
39905 this.inputEl().dom.value = v.replace('+'+d,'');
39906 this.hiddenEl().dom.value = this.getValue();
39911 getDialCode : function(v = '')
39913 if (v.length == 0) {
39914 return this.dialCodeHolder.dom.value;
39918 if (v.charAt(0) != "+") {
39921 var numericChars = "";
39922 for (var i = 1; i < v.length; i++) {
39923 var c = v.charAt(i);
39926 if (this.dialCodeMapping[numericChars]) {
39927 dialCode = v.substr(1, i);
39929 if (numericChars.length == 4) {
39939 this.setValue(this.defaultDialCode);
39943 hiddenEl : function()
39945 return this.el.select('input.hidden-tel-input',true).first();
39948 onKeyUp : function(e){
39950 var k = e.getKey();
39951 var c = e.getCharCode();
39954 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39955 this.allowed.indexOf(String.fromCharCode(c)) === -1
39960 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39963 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
39967 this.setValue(this.getValue());
39972 * @class Roo.bootstrap.MoneyField
39973 * @extends Roo.bootstrap.ComboBox
39974 * Bootstrap MoneyField class
39977 * Create a new MoneyField.
39978 * @param {Object} config Configuration options
39981 Roo.bootstrap.MoneyField = function(config) {
39983 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
39987 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
39990 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
39992 allowDecimals : true,
39994 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
39996 decimalSeparator : ".",
39998 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40000 decimalPrecision : 2,
40002 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40004 allowNegative : true,
40006 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40008 minValue : Number.NEGATIVE_INFINITY,
40010 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40012 maxValue : Number.MAX_VALUE,
40014 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40016 minText : "The minimum value for this field is {0}",
40018 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40020 maxText : "The maximum value for this field is {0}",
40022 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40023 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40025 nanText : "{0} is not a valid number",
40027 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40031 * @cfg {String} defaults currency of the MoneyField
40032 * value should be in lkey
40034 defaultCurrency : false,
40044 getAutoCreate : function()
40046 var align = this.labelAlign || this.parentLabelAlign();
40058 cls : 'form-control roo-money-amount-input',
40059 autocomplete: 'new-password'
40063 input.name = this.name;
40066 if (this.disabled) {
40067 input.disabled = true;
40070 var clg = 12 - this.inputlg;
40071 var cmd = 12 - this.inputmd;
40072 var csm = 12 - this.inputsm;
40073 var cxs = 12 - this.inputxs;
40077 cls : 'row roo-money-field',
40081 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40085 cls: 'roo-select2-container input-group',
40089 cls : 'form-control roo-money-currency-input',
40090 autocomplete: 'new-password',
40092 name : this.currencyName
40096 cls : 'input-group-addon',
40110 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40114 cls: this.hasFeedback ? 'has-feedback' : '',
40125 if (this.fieldLabel.length) {
40128 tooltip: 'This field is required'
40134 cls: 'control-label',
40140 html: this.fieldLabel
40143 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40149 if(this.indicatorpos == 'right') {
40150 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40157 if(align == 'left') {
40165 if(this.labelWidth > 12){
40166 label.style = "width: " + this.labelWidth + 'px';
40168 if(this.labelWidth < 13 && this.labelmd == 0){
40169 this.labelmd = this.labelWidth;
40171 if(this.labellg > 0){
40172 label.cls += ' col-lg-' + this.labellg;
40173 input.cls += ' col-lg-' + (12 - this.labellg);
40175 if(this.labelmd > 0){
40176 label.cls += ' col-md-' + this.labelmd;
40177 container.cls += ' col-md-' + (12 - this.labelmd);
40179 if(this.labelsm > 0){
40180 label.cls += ' col-sm-' + this.labelsm;
40181 container.cls += ' col-sm-' + (12 - this.labelsm);
40183 if(this.labelxs > 0){
40184 label.cls += ' col-xs-' + this.labelxs;
40185 container.cls += ' col-xs-' + (12 - this.labelxs);
40195 var settings = this;
40197 ['xs','sm','md','lg'].map(function(size){
40198 if (settings[size]) {
40199 cfg.cls += ' col-' + size + '-' + settings[size];
40207 initEvents : function()
40209 this.indicator = this.indicatorEl();
40211 this.initCurrencyEvent();
40213 this.initNumberEvent();
40217 initCurrencyEvent : function()
40220 throw "can not find store for combo";
40223 this.store = Roo.factory(this.store, Roo.data);
40224 this.store.parent = this;
40228 this.triggerEl = this.el.select('.input-group-addon', true).first();
40230 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40235 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40236 _this.list.setWidth(lw);
40239 this.list.on('mouseover', this.onViewOver, this);
40240 this.list.on('mousemove', this.onViewMove, this);
40241 this.list.on('scroll', this.onViewScroll, this);
40244 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40247 this.view = new Roo.View(this.list, this.tpl, {
40248 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40251 this.view.on('click', this.onViewClick, this);
40253 this.store.on('beforeload', this.onBeforeLoad, this);
40254 this.store.on('load', this.onLoad, this);
40255 this.store.on('loadexception', this.onLoadException, this);
40257 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40258 "up" : function(e){
40259 this.inKeyMode = true;
40263 "down" : function(e){
40264 if(!this.isExpanded()){
40265 this.onTriggerClick();
40267 this.inKeyMode = true;
40272 "enter" : function(e){
40275 if(this.fireEvent("specialkey", this, e)){
40276 this.onViewClick(false);
40282 "esc" : function(e){
40286 "tab" : function(e){
40289 if(this.fireEvent("specialkey", this, e)){
40290 this.onViewClick(false);
40298 doRelay : function(foo, bar, hname){
40299 if(hname == 'down' || this.scope.isExpanded()){
40300 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40308 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40312 initNumberEvent : function(e)
40314 this.inputEl().on("keydown" , this.fireKey, this);
40315 this.inputEl().on("focus", this.onFocus, this);
40316 this.inputEl().on("blur", this.onBlur, this);
40318 this.inputEl().relayEvent('keyup', this);
40320 if(this.indicator){
40321 this.indicator.addClass('invisible');
40324 this.originalValue = this.getValue();
40326 if(this.validationEvent == 'keyup'){
40327 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40328 this.inputEl().on('keyup', this.filterValidation, this);
40330 else if(this.validationEvent !== false){
40331 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40334 if(this.selectOnFocus){
40335 this.on("focus", this.preFocus, this);
40338 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40339 this.inputEl().on("keypress", this.filterKeys, this);
40341 this.inputEl().relayEvent('keypress', this);
40344 var allowed = "0123456789";
40346 if(this.allowDecimals){
40347 allowed += this.decimalSeparator;
40350 if(this.allowNegative){
40354 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40356 var keyPress = function(e){
40358 var k = e.getKey();
40360 var c = e.getCharCode();
40363 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40364 allowed.indexOf(String.fromCharCode(c)) === -1
40370 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40374 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40379 this.inputEl().on("keypress", keyPress, this);
40383 onTriggerClick : function(e)
40390 this.loadNext = false;
40392 if(this.isExpanded()){
40397 this.hasFocus = true;
40399 if(this.triggerAction == 'all') {
40400 this.doQuery(this.allQuery, true);
40404 this.doQuery(this.getRawValue());
40407 getCurrency : function()
40409 var v = this.currencyEl().getValue();
40414 restrictHeight : function()
40416 this.list.alignTo(this.currencyEl(), this.listAlign);
40417 this.list.alignTo(this.currencyEl(), this.listAlign);
40420 onViewClick : function(view, doFocus, el, e)
40422 var index = this.view.getSelectedIndexes()[0];
40424 var r = this.store.getAt(index);
40427 this.onSelect(r, index);
40431 onSelect : function(record, index){
40433 if(this.fireEvent('beforeselect', this, record, index) !== false){
40435 this.setFromCurrencyData(index > -1 ? record.data : false);
40439 this.fireEvent('select', this, record, index);
40443 setFromCurrencyData : function(o)
40447 this.lastCurrency = o;
40449 if (this.currencyField) {
40450 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40452 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40455 this.lastSelectionText = currency;
40457 //setting default currency
40458 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40459 this.setCurrency(this.defaultCurrency);
40463 this.setCurrency(currency);
40466 setFromData : function(o)
40470 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40472 this.setFromCurrencyData(c);
40477 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40479 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40482 this.setValue(value);
40486 setCurrency : function(v)
40488 this.currencyValue = v;
40491 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40496 setValue : function(v)
40498 v = this.fixPrecision(v);
40500 v = String(v).replace(".", this.decimalSeparator);
40505 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40510 getRawValue : function()
40512 var v = this.inputEl().getValue();
40517 getValue : function()
40519 return this.fixPrecision(this.parseValue(this.getRawValue()));
40522 parseValue : function(value)
40524 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40525 return isNaN(value) ? '' : value;
40528 fixPrecision : function(value)
40530 var nan = isNaN(value);
40532 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40533 return nan ? '' : value;
40536 return parseFloat(value).toFixed(this.decimalPrecision);
40539 decimalPrecisionFcn : function(v)
40541 return Math.floor(v);
40544 validateValue : function(value)
40546 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40550 var num = this.parseValue(value);
40553 this.markInvalid(String.format(this.nanText, value));
40557 if(num < this.minValue){
40558 this.markInvalid(String.format(this.minText, this.minValue));
40562 if(num > this.maxValue){
40563 this.markInvalid(String.format(this.maxText, this.maxValue));
40570 validate : function()
40572 if(this.disabled || this.allowBlank){
40577 var currency = this.getCurrency();
40579 if(this.validateValue(this.getRawValue()) && currency.length){
40584 this.markInvalid();
40588 getName: function()
40593 beforeBlur : function()
40599 var v = this.parseValue(this.getRawValue());
40606 onBlur : function()
40610 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40611 //this.el.removeClass(this.focusClass);
40614 this.hasFocus = false;
40616 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40620 var v = this.getValue();
40622 if(String(v) !== String(this.startValue)){
40623 this.fireEvent('change', this, v, this.startValue);
40626 this.fireEvent("blur", this);
40629 inputEl : function()
40631 return this.el.select('.roo-money-amount-input', true).first();
40634 currencyEl : function()
40636 return this.el.select('.roo-money-currency-input', true).first();