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);
6865 this.mainHead.setStyle({
6866 'position' : 'relative',
6867 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6872 var scrollHeight = this.mainBody.dom.scrollHeight;
6874 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
6876 var height = this.mainBody.getHeight();
6878 if(scrollHeight - height == scrollTop) {
6880 var total = this.ds.getTotalCount();
6882 if(this.footer.cursor + this.footer.pageSize < total){
6884 this.footer.ds.load({
6886 start : this.footer.cursor + this.footer.pageSize,
6887 limit : this.footer.pageSize
6897 onHeaderChange : function()
6899 this.updateHeaders.apply(this, arguments);
6902 updateHeaders : function()
6904 var html = this.renderHeader();
6905 // this.mainHead.update(html);
6919 * @class Roo.bootstrap.TableCell
6920 * @extends Roo.bootstrap.Component
6921 * Bootstrap TableCell class
6922 * @cfg {String} html cell contain text
6923 * @cfg {String} cls cell class
6924 * @cfg {String} tag cell tag (td|th) default td
6925 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6926 * @cfg {String} align Aligns the content in a cell
6927 * @cfg {String} axis Categorizes cells
6928 * @cfg {String} bgcolor Specifies the background color of a cell
6929 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6930 * @cfg {Number} colspan Specifies the number of columns a cell should span
6931 * @cfg {String} headers Specifies one or more header cells a cell is related to
6932 * @cfg {Number} height Sets the height of a cell
6933 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
6934 * @cfg {Number} rowspan Sets the number of rows a cell should span
6935 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
6936 * @cfg {String} valign Vertical aligns the content in a cell
6937 * @cfg {Number} width Specifies the width of a cell
6940 * Create a new TableCell
6941 * @param {Object} config The config object
6944 Roo.bootstrap.TableCell = function(config){
6945 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
6948 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
6968 getAutoCreate : function(){
6969 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
6989 cfg.align=this.align
6995 cfg.bgcolor=this.bgcolor
6998 cfg.charoff=this.charoff
7001 cfg.colspan=this.colspan
7004 cfg.headers=this.headers
7007 cfg.height=this.height
7010 cfg.nowrap=this.nowrap
7013 cfg.rowspan=this.rowspan
7016 cfg.scope=this.scope
7019 cfg.valign=this.valign
7022 cfg.width=this.width
7041 * @class Roo.bootstrap.TableRow
7042 * @extends Roo.bootstrap.Component
7043 * Bootstrap TableRow class
7044 * @cfg {String} cls row class
7045 * @cfg {String} align Aligns the content in a table row
7046 * @cfg {String} bgcolor Specifies a background color for a table row
7047 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7048 * @cfg {String} valign Vertical aligns the content in a table row
7051 * Create a new TableRow
7052 * @param {Object} config The config object
7055 Roo.bootstrap.TableRow = function(config){
7056 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7059 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7067 getAutoCreate : function(){
7068 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7078 cfg.align = this.align;
7081 cfg.bgcolor = this.bgcolor;
7084 cfg.charoff = this.charoff;
7087 cfg.valign = this.valign;
7105 * @class Roo.bootstrap.TableBody
7106 * @extends Roo.bootstrap.Component
7107 * Bootstrap TableBody class
7108 * @cfg {String} cls element class
7109 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7110 * @cfg {String} align Aligns the content inside the element
7111 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7112 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7115 * Create a new TableBody
7116 * @param {Object} config The config object
7119 Roo.bootstrap.TableBody = function(config){
7120 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7123 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7131 getAutoCreate : function(){
7132 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7146 cfg.align = this.align;
7149 cfg.charoff = this.charoff;
7152 cfg.valign = this.valign;
7159 // initEvents : function()
7166 // this.store = Roo.factory(this.store, Roo.data);
7167 // this.store.on('load', this.onLoad, this);
7169 // this.store.load();
7173 // onLoad: function ()
7175 // this.fireEvent('load', this);
7185 * Ext JS Library 1.1.1
7186 * Copyright(c) 2006-2007, Ext JS, LLC.
7188 * Originally Released Under LGPL - original licence link has changed is not relivant.
7191 * <script type="text/javascript">
7194 // as we use this in bootstrap.
7195 Roo.namespace('Roo.form');
7197 * @class Roo.form.Action
7198 * Internal Class used to handle form actions
7200 * @param {Roo.form.BasicForm} el The form element or its id
7201 * @param {Object} config Configuration options
7206 // define the action interface
7207 Roo.form.Action = function(form, options){
7209 this.options = options || {};
7212 * Client Validation Failed
7215 Roo.form.Action.CLIENT_INVALID = 'client';
7217 * Server Validation Failed
7220 Roo.form.Action.SERVER_INVALID = 'server';
7222 * Connect to Server Failed
7225 Roo.form.Action.CONNECT_FAILURE = 'connect';
7227 * Reading Data from Server Failed
7230 Roo.form.Action.LOAD_FAILURE = 'load';
7232 Roo.form.Action.prototype = {
7234 failureType : undefined,
7235 response : undefined,
7239 run : function(options){
7244 success : function(response){
7249 handleResponse : function(response){
7253 // default connection failure
7254 failure : function(response){
7256 this.response = response;
7257 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7258 this.form.afterAction(this, false);
7261 processResponse : function(response){
7262 this.response = response;
7263 if(!response.responseText){
7266 this.result = this.handleResponse(response);
7270 // utility functions used internally
7271 getUrl : function(appendParams){
7272 var url = this.options.url || this.form.url || this.form.el.dom.action;
7274 var p = this.getParams();
7276 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7282 getMethod : function(){
7283 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7286 getParams : function(){
7287 var bp = this.form.baseParams;
7288 var p = this.options.params;
7290 if(typeof p == "object"){
7291 p = Roo.urlEncode(Roo.applyIf(p, bp));
7292 }else if(typeof p == 'string' && bp){
7293 p += '&' + Roo.urlEncode(bp);
7296 p = Roo.urlEncode(bp);
7301 createCallback : function(){
7303 success: this.success,
7304 failure: this.failure,
7306 timeout: (this.form.timeout*1000),
7307 upload: this.form.fileUpload ? this.success : undefined
7312 Roo.form.Action.Submit = function(form, options){
7313 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7316 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7319 haveProgress : false,
7320 uploadComplete : false,
7322 // uploadProgress indicator.
7323 uploadProgress : function()
7325 if (!this.form.progressUrl) {
7329 if (!this.haveProgress) {
7330 Roo.MessageBox.progress("Uploading", "Uploading");
7332 if (this.uploadComplete) {
7333 Roo.MessageBox.hide();
7337 this.haveProgress = true;
7339 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7341 var c = new Roo.data.Connection();
7343 url : this.form.progressUrl,
7348 success : function(req){
7349 //console.log(data);
7353 rdata = Roo.decode(req.responseText)
7355 Roo.log("Invalid data from server..");
7359 if (!rdata || !rdata.success) {
7361 Roo.MessageBox.alert(Roo.encode(rdata));
7364 var data = rdata.data;
7366 if (this.uploadComplete) {
7367 Roo.MessageBox.hide();
7372 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7373 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7376 this.uploadProgress.defer(2000,this);
7379 failure: function(data) {
7380 Roo.log('progress url failed ');
7391 // run get Values on the form, so it syncs any secondary forms.
7392 this.form.getValues();
7394 var o = this.options;
7395 var method = this.getMethod();
7396 var isPost = method == 'POST';
7397 if(o.clientValidation === false || this.form.isValid()){
7399 if (this.form.progressUrl) {
7400 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7401 (new Date() * 1) + '' + Math.random());
7406 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7407 form:this.form.el.dom,
7408 url:this.getUrl(!isPost),
7410 params:isPost ? this.getParams() : null,
7411 isUpload: this.form.fileUpload
7414 this.uploadProgress();
7416 }else if (o.clientValidation !== false){ // client validation failed
7417 this.failureType = Roo.form.Action.CLIENT_INVALID;
7418 this.form.afterAction(this, false);
7422 success : function(response)
7424 this.uploadComplete= true;
7425 if (this.haveProgress) {
7426 Roo.MessageBox.hide();
7430 var result = this.processResponse(response);
7431 if(result === true || result.success){
7432 this.form.afterAction(this, true);
7436 this.form.markInvalid(result.errors);
7437 this.failureType = Roo.form.Action.SERVER_INVALID;
7439 this.form.afterAction(this, false);
7441 failure : function(response)
7443 this.uploadComplete= true;
7444 if (this.haveProgress) {
7445 Roo.MessageBox.hide();
7448 this.response = response;
7449 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7450 this.form.afterAction(this, false);
7453 handleResponse : function(response){
7454 if(this.form.errorReader){
7455 var rs = this.form.errorReader.read(response);
7458 for(var i = 0, len = rs.records.length; i < len; i++) {
7459 var r = rs.records[i];
7463 if(errors.length < 1){
7467 success : rs.success,
7473 ret = Roo.decode(response.responseText);
7477 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7487 Roo.form.Action.Load = function(form, options){
7488 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7489 this.reader = this.form.reader;
7492 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7497 Roo.Ajax.request(Roo.apply(
7498 this.createCallback(), {
7499 method:this.getMethod(),
7500 url:this.getUrl(false),
7501 params:this.getParams()
7505 success : function(response){
7507 var result = this.processResponse(response);
7508 if(result === true || !result.success || !result.data){
7509 this.failureType = Roo.form.Action.LOAD_FAILURE;
7510 this.form.afterAction(this, false);
7513 this.form.clearInvalid();
7514 this.form.setValues(result.data);
7515 this.form.afterAction(this, true);
7518 handleResponse : function(response){
7519 if(this.form.reader){
7520 var rs = this.form.reader.read(response);
7521 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7523 success : rs.success,
7527 return Roo.decode(response.responseText);
7531 Roo.form.Action.ACTION_TYPES = {
7532 'load' : Roo.form.Action.Load,
7533 'submit' : Roo.form.Action.Submit
7542 * @class Roo.bootstrap.Form
7543 * @extends Roo.bootstrap.Component
7544 * Bootstrap Form class
7545 * @cfg {String} method GET | POST (default POST)
7546 * @cfg {String} labelAlign top | left (default top)
7547 * @cfg {String} align left | right - for navbars
7548 * @cfg {Boolean} loadMask load mask when submit (default true)
7553 * @param {Object} config The config object
7557 Roo.bootstrap.Form = function(config){
7558 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7560 Roo.bootstrap.Form.popover.apply();
7564 * @event clientvalidation
7565 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7566 * @param {Form} this
7567 * @param {Boolean} valid true if the form has passed client-side validation
7569 clientvalidation: true,
7571 * @event beforeaction
7572 * Fires before any action is performed. Return false to cancel the action.
7573 * @param {Form} this
7574 * @param {Action} action The action to be performed
7578 * @event actionfailed
7579 * Fires when an action fails.
7580 * @param {Form} this
7581 * @param {Action} action The action that failed
7583 actionfailed : true,
7585 * @event actioncomplete
7586 * Fires when an action is completed.
7587 * @param {Form} this
7588 * @param {Action} action The action that completed
7590 actioncomplete : true
7595 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7598 * @cfg {String} method
7599 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7604 * The URL to use for form actions if one isn't supplied in the action options.
7607 * @cfg {Boolean} fileUpload
7608 * Set to true if this form is a file upload.
7612 * @cfg {Object} baseParams
7613 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7617 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7621 * @cfg {Sting} align (left|right) for navbar forms
7626 activeAction : null,
7629 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7630 * element by passing it or its id or mask the form itself by passing in true.
7633 waitMsgTarget : false,
7638 * @cfg {Boolean} errorMask (true|false) default false
7643 * @cfg {Number} maskOffset Default 100
7648 * @cfg {Boolean} maskBody
7652 getAutoCreate : function(){
7656 method : this.method || 'POST',
7657 id : this.id || Roo.id(),
7660 if (this.parent().xtype.match(/^Nav/)) {
7661 cfg.cls = 'navbar-form navbar-' + this.align;
7665 if (this.labelAlign == 'left' ) {
7666 cfg.cls += ' form-horizontal';
7672 initEvents : function()
7674 this.el.on('submit', this.onSubmit, this);
7675 // this was added as random key presses on the form where triggering form submit.
7676 this.el.on('keypress', function(e) {
7677 if (e.getCharCode() != 13) {
7680 // we might need to allow it for textareas.. and some other items.
7681 // check e.getTarget().
7683 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7687 Roo.log("keypress blocked");
7695 onSubmit : function(e){
7700 * Returns true if client-side validation on the form is successful.
7703 isValid : function(){
7704 var items = this.getItems();
7708 items.each(function(f){
7714 if(!target && f.el.isVisible(true)){
7720 if(this.errorMask && !valid){
7721 Roo.bootstrap.Form.popover.mask(this, target);
7728 * Returns true if any fields in this form have changed since their original load.
7731 isDirty : function(){
7733 var items = this.getItems();
7734 items.each(function(f){
7744 * Performs a predefined action (submit or load) or custom actions you define on this form.
7745 * @param {String} actionName The name of the action type
7746 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7747 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7748 * accept other config options):
7750 Property Type Description
7751 ---------------- --------------- ----------------------------------------------------------------------------------
7752 url String The url for the action (defaults to the form's url)
7753 method String The form method to use (defaults to the form's method, or POST if not defined)
7754 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7755 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7756 validate the form on the client (defaults to false)
7758 * @return {BasicForm} this
7760 doAction : function(action, options){
7761 if(typeof action == 'string'){
7762 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7764 if(this.fireEvent('beforeaction', this, action) !== false){
7765 this.beforeAction(action);
7766 action.run.defer(100, action);
7772 beforeAction : function(action){
7773 var o = action.options;
7778 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
7780 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7783 // not really supported yet.. ??
7785 //if(this.waitMsgTarget === true){
7786 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7787 //}else if(this.waitMsgTarget){
7788 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7789 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7791 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7797 afterAction : function(action, success){
7798 this.activeAction = null;
7799 var o = action.options;
7804 Roo.get(document.body).unmask();
7810 //if(this.waitMsgTarget === true){
7811 // this.el.unmask();
7812 //}else if(this.waitMsgTarget){
7813 // this.waitMsgTarget.unmask();
7815 // Roo.MessageBox.updateProgress(1);
7816 // Roo.MessageBox.hide();
7823 Roo.callback(o.success, o.scope, [this, action]);
7824 this.fireEvent('actioncomplete', this, action);
7828 // failure condition..
7829 // we have a scenario where updates need confirming.
7830 // eg. if a locking scenario exists..
7831 // we look for { errors : { needs_confirm : true }} in the response.
7833 (typeof(action.result) != 'undefined') &&
7834 (typeof(action.result.errors) != 'undefined') &&
7835 (typeof(action.result.errors.needs_confirm) != 'undefined')
7838 Roo.log("not supported yet");
7841 Roo.MessageBox.confirm(
7842 "Change requires confirmation",
7843 action.result.errorMsg,
7848 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7858 Roo.callback(o.failure, o.scope, [this, action]);
7859 // show an error message if no failed handler is set..
7860 if (!this.hasListener('actionfailed')) {
7861 Roo.log("need to add dialog support");
7863 Roo.MessageBox.alert("Error",
7864 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7865 action.result.errorMsg :
7866 "Saving Failed, please check your entries or try again"
7871 this.fireEvent('actionfailed', this, action);
7876 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7877 * @param {String} id The value to search for
7880 findField : function(id){
7881 var items = this.getItems();
7882 var field = items.get(id);
7884 items.each(function(f){
7885 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7892 return field || null;
7895 * Mark fields in this form invalid in bulk.
7896 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7897 * @return {BasicForm} this
7899 markInvalid : function(errors){
7900 if(errors instanceof Array){
7901 for(var i = 0, len = errors.length; i < len; i++){
7902 var fieldError = errors[i];
7903 var f = this.findField(fieldError.id);
7905 f.markInvalid(fieldError.msg);
7911 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7912 field.markInvalid(errors[id]);
7916 //Roo.each(this.childForms || [], function (f) {
7917 // f.markInvalid(errors);
7924 * Set values for fields in this form in bulk.
7925 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7926 * @return {BasicForm} this
7928 setValues : function(values){
7929 if(values instanceof Array){ // array of objects
7930 for(var i = 0, len = values.length; i < len; i++){
7932 var f = this.findField(v.id);
7934 f.setValue(v.value);
7935 if(this.trackResetOnLoad){
7936 f.originalValue = f.getValue();
7940 }else{ // object hash
7943 if(typeof values[id] != 'function' && (field = this.findField(id))){
7945 if (field.setFromData &&
7947 field.displayField &&
7948 // combos' with local stores can
7949 // be queried via setValue()
7950 // to set their value..
7951 (field.store && !field.store.isLocal)
7955 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
7956 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
7957 field.setFromData(sd);
7959 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
7961 field.setFromData(values);
7964 field.setValue(values[id]);
7968 if(this.trackResetOnLoad){
7969 field.originalValue = field.getValue();
7975 //Roo.each(this.childForms || [], function (f) {
7976 // f.setValues(values);
7983 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
7984 * they are returned as an array.
7985 * @param {Boolean} asString
7988 getValues : function(asString){
7989 //if (this.childForms) {
7990 // copy values from the child forms
7991 // Roo.each(this.childForms, function (f) {
7992 // this.setValues(f.getValues());
7998 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
7999 if(asString === true){
8002 return Roo.urlDecode(fs);
8006 * Returns the fields in this form as an object with key/value pairs.
8007 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8010 getFieldValues : function(with_hidden)
8012 var items = this.getItems();
8014 items.each(function(f){
8020 var v = f.getValue();
8022 if (f.inputType =='radio') {
8023 if (typeof(ret[f.getName()]) == 'undefined') {
8024 ret[f.getName()] = ''; // empty..
8027 if (!f.el.dom.checked) {
8035 if(f.xtype == 'MoneyField'){
8036 ret[f.currencyName] = f.getCurrency();
8039 // not sure if this supported any more..
8040 if ((typeof(v) == 'object') && f.getRawValue) {
8041 v = f.getRawValue() ; // dates..
8043 // combo boxes where name != hiddenName...
8044 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8045 ret[f.name] = f.getRawValue();
8047 ret[f.getName()] = v;
8054 * Clears all invalid messages in this form.
8055 * @return {BasicForm} this
8057 clearInvalid : function(){
8058 var items = this.getItems();
8060 items.each(function(f){
8071 * @return {BasicForm} this
8074 var items = this.getItems();
8075 items.each(function(f){
8079 Roo.each(this.childForms || [], function (f) {
8087 getItems : function()
8089 var r=new Roo.util.MixedCollection(false, function(o){
8090 return o.id || (o.id = Roo.id());
8092 var iter = function(el) {
8099 Roo.each(el.items,function(e) {
8113 Roo.apply(Roo.bootstrap.Form, {
8140 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8141 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8142 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8143 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8146 this.maskEl.top.enableDisplayMode("block");
8147 this.maskEl.left.enableDisplayMode("block");
8148 this.maskEl.bottom.enableDisplayMode("block");
8149 this.maskEl.right.enableDisplayMode("block");
8151 this.toolTip = new Roo.bootstrap.Tooltip({
8152 cls : 'roo-form-error-popover',
8154 'left' : ['r-l', [-2,0], 'right'],
8155 'right' : ['l-r', [2,0], 'left'],
8156 'bottom' : ['tl-bl', [0,2], 'top'],
8157 'top' : [ 'bl-tl', [0,-2], 'bottom']
8161 this.toolTip.render(Roo.get(document.body));
8163 this.toolTip.el.enableDisplayMode("block");
8165 Roo.get(document.body).on('click', function(){
8169 Roo.get(document.body).on('touchstart', function(){
8173 this.isApplied = true
8176 mask : function(form, target)
8180 this.target = target;
8182 if(!this.form.errorMask || !target.el){
8186 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8188 Roo.log(scrollable);
8190 var ot = this.target.el.calcOffsetsTo(scrollable);
8192 var scrollTo = ot[1] - this.form.maskOffset;
8194 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8196 scrollable.scrollTo('top', scrollTo);
8198 var box = this.target.el.getBox();
8200 var zIndex = Roo.bootstrap.Modal.zIndex++;
8203 this.maskEl.top.setStyle('position', 'absolute');
8204 this.maskEl.top.setStyle('z-index', zIndex);
8205 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8206 this.maskEl.top.setLeft(0);
8207 this.maskEl.top.setTop(0);
8208 this.maskEl.top.show();
8210 this.maskEl.left.setStyle('position', 'absolute');
8211 this.maskEl.left.setStyle('z-index', zIndex);
8212 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8213 this.maskEl.left.setLeft(0);
8214 this.maskEl.left.setTop(box.y - this.padding);
8215 this.maskEl.left.show();
8217 this.maskEl.bottom.setStyle('position', 'absolute');
8218 this.maskEl.bottom.setStyle('z-index', zIndex);
8219 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8220 this.maskEl.bottom.setLeft(0);
8221 this.maskEl.bottom.setTop(box.bottom + this.padding);
8222 this.maskEl.bottom.show();
8224 this.maskEl.right.setStyle('position', 'absolute');
8225 this.maskEl.right.setStyle('z-index', zIndex);
8226 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8227 this.maskEl.right.setLeft(box.right + this.padding);
8228 this.maskEl.right.setTop(box.y - this.padding);
8229 this.maskEl.right.show();
8231 this.toolTip.bindEl = this.target.el;
8233 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8235 var tip = this.target.blankText;
8237 if(this.target.getValue() !== '' ) {
8239 if (this.target.invalidText.length) {
8240 tip = this.target.invalidText;
8241 } else if (this.target.regexText.length){
8242 tip = this.target.regexText;
8246 this.toolTip.show(tip);
8248 this.intervalID = window.setInterval(function() {
8249 Roo.bootstrap.Form.popover.unmask();
8252 window.onwheel = function(){ return false;};
8254 (function(){ this.isMasked = true; }).defer(500, this);
8260 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8264 this.maskEl.top.setStyle('position', 'absolute');
8265 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8266 this.maskEl.top.hide();
8268 this.maskEl.left.setStyle('position', 'absolute');
8269 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8270 this.maskEl.left.hide();
8272 this.maskEl.bottom.setStyle('position', 'absolute');
8273 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8274 this.maskEl.bottom.hide();
8276 this.maskEl.right.setStyle('position', 'absolute');
8277 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8278 this.maskEl.right.hide();
8280 this.toolTip.hide();
8282 this.toolTip.el.hide();
8284 window.onwheel = function(){ return true;};
8286 if(this.intervalID){
8287 window.clearInterval(this.intervalID);
8288 this.intervalID = false;
8291 this.isMasked = false;
8301 * Ext JS Library 1.1.1
8302 * Copyright(c) 2006-2007, Ext JS, LLC.
8304 * Originally Released Under LGPL - original licence link has changed is not relivant.
8307 * <script type="text/javascript">
8310 * @class Roo.form.VTypes
8311 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8314 Roo.form.VTypes = function(){
8315 // closure these in so they are only created once.
8316 var alpha = /^[a-zA-Z_]+$/;
8317 var alphanum = /^[a-zA-Z0-9_]+$/;
8318 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8319 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8321 // All these messages and functions are configurable
8324 * The function used to validate email addresses
8325 * @param {String} value The email address
8327 'email' : function(v){
8328 return email.test(v);
8331 * The error text to display when the email validation function returns false
8334 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8336 * The keystroke filter mask to be applied on email input
8339 'emailMask' : /[a-z0-9_\.\-@]/i,
8342 * The function used to validate URLs
8343 * @param {String} value The URL
8345 'url' : function(v){
8349 * The error text to display when the url validation function returns false
8352 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8355 * The function used to validate alpha values
8356 * @param {String} value The value
8358 'alpha' : function(v){
8359 return alpha.test(v);
8362 * The error text to display when the alpha validation function returns false
8365 'alphaText' : 'This field should only contain letters and _',
8367 * The keystroke filter mask to be applied on alpha input
8370 'alphaMask' : /[a-z_]/i,
8373 * The function used to validate alphanumeric values
8374 * @param {String} value The value
8376 'alphanum' : function(v){
8377 return alphanum.test(v);
8380 * The error text to display when the alphanumeric validation function returns false
8383 'alphanumText' : 'This field should only contain letters, numbers and _',
8385 * The keystroke filter mask to be applied on alphanumeric input
8388 'alphanumMask' : /[a-z0-9_]/i
8398 * @class Roo.bootstrap.Input
8399 * @extends Roo.bootstrap.Component
8400 * Bootstrap Input class
8401 * @cfg {Boolean} disabled is it disabled
8402 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8403 * @cfg {String} name name of the input
8404 * @cfg {string} fieldLabel - the label associated
8405 * @cfg {string} placeholder - placeholder to put in text.
8406 * @cfg {string} before - input group add on before
8407 * @cfg {string} after - input group add on after
8408 * @cfg {string} size - (lg|sm) or leave empty..
8409 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8410 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8411 * @cfg {Number} md colspan out of 12 for computer-sized screens
8412 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8413 * @cfg {string} value default value of the input
8414 * @cfg {Number} labelWidth set the width of label
8415 * @cfg {Number} labellg set the width of label (1-12)
8416 * @cfg {Number} labelmd set the width of label (1-12)
8417 * @cfg {Number} labelsm set the width of label (1-12)
8418 * @cfg {Number} labelxs set the width of label (1-12)
8419 * @cfg {String} labelAlign (top|left)
8420 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8421 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8422 * @cfg {String} indicatorpos (left|right) default left
8424 * @cfg {String} align (left|center|right) Default left
8425 * @cfg {Boolean} forceFeedback (true|false) Default false
8431 * Create a new Input
8432 * @param {Object} config The config object
8435 Roo.bootstrap.Input = function(config){
8437 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8442 * Fires when this field receives input focus.
8443 * @param {Roo.form.Field} this
8448 * Fires when this field loses input focus.
8449 * @param {Roo.form.Field} this
8454 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8455 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8456 * @param {Roo.form.Field} this
8457 * @param {Roo.EventObject} e The event object
8462 * Fires just before the field blurs if the field value has changed.
8463 * @param {Roo.form.Field} this
8464 * @param {Mixed} newValue The new value
8465 * @param {Mixed} oldValue The original value
8470 * Fires after the field has been marked as invalid.
8471 * @param {Roo.form.Field} this
8472 * @param {String} msg The validation message
8477 * Fires after the field has been validated with no errors.
8478 * @param {Roo.form.Field} this
8483 * Fires after the key up
8484 * @param {Roo.form.Field} this
8485 * @param {Roo.EventObject} e The event Object
8491 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8493 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8494 automatic validation (defaults to "keyup").
8496 validationEvent : "keyup",
8498 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8500 validateOnBlur : true,
8502 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8504 validationDelay : 250,
8506 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8508 focusClass : "x-form-focus", // not needed???
8512 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8514 invalidClass : "has-warning",
8517 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8519 validClass : "has-success",
8522 * @cfg {Boolean} hasFeedback (true|false) default true
8527 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8529 invalidFeedbackClass : "glyphicon-warning-sign",
8532 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8534 validFeedbackClass : "glyphicon-ok",
8537 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8539 selectOnFocus : false,
8542 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8546 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8551 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8553 disableKeyFilter : false,
8556 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8560 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8564 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8566 blankText : "Please complete this mandatory field",
8569 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8573 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8575 maxLength : Number.MAX_VALUE,
8577 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8579 minLengthText : "The minimum length for this field is {0}",
8581 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8583 maxLengthText : "The maximum length for this field is {0}",
8587 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8588 * If available, this function will be called only after the basic validators all return true, and will be passed the
8589 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8593 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8594 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8595 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8599 * @cfg {String} regexText -- Depricated - use Invalid Text
8604 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8610 autocomplete: false,
8629 formatedValue : false,
8630 forceFeedback : false,
8632 indicatorpos : 'left',
8639 parentLabelAlign : function()
8642 while (parent.parent()) {
8643 parent = parent.parent();
8644 if (typeof(parent.labelAlign) !='undefined') {
8645 return parent.labelAlign;
8652 getAutoCreate : function()
8654 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8660 if(this.inputType != 'hidden'){
8661 cfg.cls = 'form-group' //input-group
8667 type : this.inputType,
8669 cls : 'form-control',
8670 placeholder : this.placeholder || '',
8671 autocomplete : this.autocomplete || 'new-password'
8675 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8678 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8679 input.maxLength = this.maxLength;
8682 if (this.disabled) {
8683 input.disabled=true;
8686 if (this.readOnly) {
8687 input.readonly=true;
8691 input.name = this.name;
8695 input.cls += ' input-' + this.size;
8699 ['xs','sm','md','lg'].map(function(size){
8700 if (settings[size]) {
8701 cfg.cls += ' col-' + size + '-' + settings[size];
8705 var inputblock = input;
8709 cls: 'glyphicon form-control-feedback'
8712 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8715 cls : 'has-feedback',
8723 if (this.before || this.after) {
8726 cls : 'input-group',
8730 if (this.before && typeof(this.before) == 'string') {
8732 inputblock.cn.push({
8734 cls : 'roo-input-before input-group-addon',
8738 if (this.before && typeof(this.before) == 'object') {
8739 this.before = Roo.factory(this.before);
8741 inputblock.cn.push({
8743 cls : 'roo-input-before input-group-' +
8744 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8748 inputblock.cn.push(input);
8750 if (this.after && typeof(this.after) == 'string') {
8751 inputblock.cn.push({
8753 cls : 'roo-input-after input-group-addon',
8757 if (this.after && typeof(this.after) == 'object') {
8758 this.after = Roo.factory(this.after);
8760 inputblock.cn.push({
8762 cls : 'roo-input-after input-group-' +
8763 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8767 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8768 inputblock.cls += ' has-feedback';
8769 inputblock.cn.push(feedback);
8773 if (align ==='left' && this.fieldLabel.length) {
8775 cfg.cls += ' roo-form-group-label-left';
8780 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8781 tooltip : 'This field is required'
8786 cls : 'control-label',
8787 html : this.fieldLabel
8798 var labelCfg = cfg.cn[1];
8799 var contentCfg = cfg.cn[2];
8801 if(this.indicatorpos == 'right'){
8806 cls : 'control-label',
8810 html : this.fieldLabel
8814 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8815 tooltip : 'This field is required'
8828 labelCfg = cfg.cn[0];
8829 contentCfg = cfg.cn[1];
8833 if(this.labelWidth > 12){
8834 labelCfg.style = "width: " + this.labelWidth + 'px';
8837 if(this.labelWidth < 13 && this.labelmd == 0){
8838 this.labelmd = this.labelWidth;
8841 if(this.labellg > 0){
8842 labelCfg.cls += ' col-lg-' + this.labellg;
8843 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8846 if(this.labelmd > 0){
8847 labelCfg.cls += ' col-md-' + this.labelmd;
8848 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8851 if(this.labelsm > 0){
8852 labelCfg.cls += ' col-sm-' + this.labelsm;
8853 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8856 if(this.labelxs > 0){
8857 labelCfg.cls += ' col-xs-' + this.labelxs;
8858 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8862 } else if ( this.fieldLabel.length) {
8867 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8868 tooltip : 'This field is required'
8872 //cls : 'input-group-addon',
8873 html : this.fieldLabel
8881 if(this.indicatorpos == 'right'){
8886 //cls : 'input-group-addon',
8887 html : this.fieldLabel
8892 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8893 tooltip : 'This field is required'
8913 if (this.parentType === 'Navbar' && this.parent().bar) {
8914 cfg.cls += ' navbar-form';
8917 if (this.parentType === 'NavGroup') {
8918 cfg.cls += ' navbar-form';
8926 * return the real input element.
8928 inputEl: function ()
8930 return this.el.select('input.form-control',true).first();
8933 tooltipEl : function()
8935 return this.inputEl();
8938 indicatorEl : function()
8940 var indicator = this.el.select('i.roo-required-indicator',true).first();
8950 setDisabled : function(v)
8952 var i = this.inputEl().dom;
8954 i.removeAttribute('disabled');
8958 i.setAttribute('disabled','true');
8960 initEvents : function()
8963 this.inputEl().on("keydown" , this.fireKey, this);
8964 this.inputEl().on("focus", this.onFocus, this);
8965 this.inputEl().on("blur", this.onBlur, this);
8967 this.inputEl().relayEvent('keyup', this);
8969 this.indicator = this.indicatorEl();
8972 this.indicator.addClass('invisible');
8976 // reference to original value for reset
8977 this.originalValue = this.getValue();
8978 //Roo.form.TextField.superclass.initEvents.call(this);
8979 if(this.validationEvent == 'keyup'){
8980 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8981 this.inputEl().on('keyup', this.filterValidation, this);
8983 else if(this.validationEvent !== false){
8984 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8987 if(this.selectOnFocus){
8988 this.on("focus", this.preFocus, this);
8991 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8992 this.inputEl().on("keypress", this.filterKeys, this);
8994 this.inputEl().relayEvent('keypress', this);
8997 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8998 this.el.on("click", this.autoSize, this);
9001 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9002 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9005 if (typeof(this.before) == 'object') {
9006 this.before.render(this.el.select('.roo-input-before',true).first());
9008 if (typeof(this.after) == 'object') {
9009 this.after.render(this.el.select('.roo-input-after',true).first());
9014 filterValidation : function(e){
9015 if(!e.isNavKeyPress()){
9016 this.validationTask.delay(this.validationDelay);
9020 * Validates the field value
9021 * @return {Boolean} True if the value is valid, else false
9023 validate : function(){
9024 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9025 if(this.disabled || this.validateValue(this.getRawValue())){
9036 * Validates a value according to the field's validation rules and marks the field as invalid
9037 * if the validation fails
9038 * @param {Mixed} value The value to validate
9039 * @return {Boolean} True if the value is valid, else false
9041 validateValue : function(value){
9042 if(value.length < 1) { // if it's blank
9043 if(this.allowBlank){
9046 return this.inputEl().hasClass('hide') ? true : false;
9049 if(value.length < this.minLength){
9052 if(value.length > this.maxLength){
9056 var vt = Roo.form.VTypes;
9057 if(!vt[this.vtype](value, this)){
9061 if(typeof this.validator == "function"){
9062 var msg = this.validator(value);
9066 if (typeof(msg) == 'string') {
9067 this.invalidText = msg;
9071 if(this.regex && !this.regex.test(value)){
9081 fireKey : function(e){
9082 //Roo.log('field ' + e.getKey());
9083 if(e.isNavKeyPress()){
9084 this.fireEvent("specialkey", this, e);
9087 focus : function (selectText){
9089 this.inputEl().focus();
9090 if(selectText === true){
9091 this.inputEl().dom.select();
9097 onFocus : function(){
9098 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9099 // this.el.addClass(this.focusClass);
9102 this.hasFocus = true;
9103 this.startValue = this.getValue();
9104 this.fireEvent("focus", this);
9108 beforeBlur : Roo.emptyFn,
9112 onBlur : function(){
9114 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9115 //this.el.removeClass(this.focusClass);
9117 this.hasFocus = false;
9118 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9121 var v = this.getValue();
9122 if(String(v) !== String(this.startValue)){
9123 this.fireEvent('change', this, v, this.startValue);
9125 this.fireEvent("blur", this);
9129 * Resets the current field value to the originally loaded value and clears any validation messages
9132 this.setValue(this.originalValue);
9136 * Returns the name of the field
9137 * @return {Mixed} name The name field
9139 getName: function(){
9143 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9144 * @return {Mixed} value The field value
9146 getValue : function(){
9148 var v = this.inputEl().getValue();
9153 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9154 * @return {Mixed} value The field value
9156 getRawValue : function(){
9157 var v = this.inputEl().getValue();
9163 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9164 * @param {Mixed} value The value to set
9166 setRawValue : function(v){
9167 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9170 selectText : function(start, end){
9171 var v = this.getRawValue();
9173 start = start === undefined ? 0 : start;
9174 end = end === undefined ? v.length : end;
9175 var d = this.inputEl().dom;
9176 if(d.setSelectionRange){
9177 d.setSelectionRange(start, end);
9178 }else if(d.createTextRange){
9179 var range = d.createTextRange();
9180 range.moveStart("character", start);
9181 range.moveEnd("character", v.length-end);
9188 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9189 * @param {Mixed} value The value to set
9191 setValue : function(v){
9194 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9200 processValue : function(value){
9201 if(this.stripCharsRe){
9202 var newValue = value.replace(this.stripCharsRe, '');
9203 if(newValue !== value){
9204 this.setRawValue(newValue);
9211 preFocus : function(){
9213 if(this.selectOnFocus){
9214 this.inputEl().dom.select();
9217 filterKeys : function(e){
9219 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9222 var c = e.getCharCode(), cc = String.fromCharCode(c);
9223 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9226 if(!this.maskRe.test(cc)){
9231 * Clear any invalid styles/messages for this field
9233 clearInvalid : function(){
9235 if(!this.el || this.preventMark){ // not rendered
9240 this.el.removeClass(this.invalidClass);
9242 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9244 var feedback = this.el.select('.form-control-feedback', true).first();
9247 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9252 this.fireEvent('valid', this);
9256 * Mark this field as valid
9258 markValid : function()
9260 if(!this.el || this.preventMark){ // not rendered...
9264 this.el.removeClass([this.invalidClass, this.validClass]);
9266 var feedback = this.el.select('.form-control-feedback', true).first();
9269 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9273 this.indicator.removeClass('visible');
9274 this.indicator.addClass('invisible');
9281 if(this.allowBlank && !this.getRawValue().length){
9285 this.el.addClass(this.validClass);
9287 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9289 var feedback = this.el.select('.form-control-feedback', true).first();
9292 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9293 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9298 this.fireEvent('valid', this);
9302 * Mark this field as invalid
9303 * @param {String} msg The validation message
9305 markInvalid : function(msg)
9307 if(!this.el || this.preventMark){ // not rendered
9311 this.el.removeClass([this.invalidClass, this.validClass]);
9313 var feedback = this.el.select('.form-control-feedback', true).first();
9316 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9323 if(this.allowBlank && !this.getRawValue().length){
9328 this.indicator.removeClass('invisible');
9329 this.indicator.addClass('visible');
9332 this.el.addClass(this.invalidClass);
9334 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9336 var feedback = this.el.select('.form-control-feedback', true).first();
9339 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9341 if(this.getValue().length || this.forceFeedback){
9342 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9349 this.fireEvent('invalid', this, msg);
9352 SafariOnKeyDown : function(event)
9354 // this is a workaround for a password hang bug on chrome/ webkit.
9355 if (this.inputEl().dom.type != 'password') {
9359 var isSelectAll = false;
9361 if(this.inputEl().dom.selectionEnd > 0){
9362 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9364 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9365 event.preventDefault();
9370 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9372 event.preventDefault();
9373 // this is very hacky as keydown always get's upper case.
9375 var cc = String.fromCharCode(event.getCharCode());
9376 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9380 adjustWidth : function(tag, w){
9381 tag = tag.toLowerCase();
9382 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9383 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9387 if(tag == 'textarea'){
9390 }else if(Roo.isOpera){
9394 if(tag == 'textarea'){
9402 setFieldLabel : function(v)
9409 var ar = this.el.select('label > span',true);
9411 if (ar.elements.length) {
9412 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9413 this.fieldLabel = v;
9417 var br = this.el.select('label',true);
9419 if(br.elements.length) {
9420 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9421 this.fieldLabel = v;
9425 Roo.log('Cannot Found any of label > span || label in input');
9429 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9430 this.fieldLabel = v;
9445 * @class Roo.bootstrap.TextArea
9446 * @extends Roo.bootstrap.Input
9447 * Bootstrap TextArea class
9448 * @cfg {Number} cols Specifies the visible width of a text area
9449 * @cfg {Number} rows Specifies the visible number of lines in a text area
9450 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9451 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9452 * @cfg {string} html text
9455 * Create a new TextArea
9456 * @param {Object} config The config object
9459 Roo.bootstrap.TextArea = function(config){
9460 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9464 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9474 getAutoCreate : function(){
9476 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9482 if(this.inputType != 'hidden'){
9483 cfg.cls = 'form-group' //input-group
9491 value : this.value || '',
9492 html: this.html || '',
9493 cls : 'form-control',
9494 placeholder : this.placeholder || ''
9498 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9499 input.maxLength = this.maxLength;
9503 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9507 input.cols = this.cols;
9510 if (this.readOnly) {
9511 input.readonly = true;
9515 input.name = this.name;
9519 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9523 ['xs','sm','md','lg'].map(function(size){
9524 if (settings[size]) {
9525 cfg.cls += ' col-' + size + '-' + settings[size];
9529 var inputblock = input;
9531 if(this.hasFeedback && !this.allowBlank){
9535 cls: 'glyphicon form-control-feedback'
9539 cls : 'has-feedback',
9548 if (this.before || this.after) {
9551 cls : 'input-group',
9555 inputblock.cn.push({
9557 cls : 'input-group-addon',
9562 inputblock.cn.push(input);
9564 if(this.hasFeedback && !this.allowBlank){
9565 inputblock.cls += ' has-feedback';
9566 inputblock.cn.push(feedback);
9570 inputblock.cn.push({
9572 cls : 'input-group-addon',
9579 if (align ==='left' && this.fieldLabel.length) {
9584 cls : 'control-label',
9585 html : this.fieldLabel
9596 if(this.labelWidth > 12){
9597 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9600 if(this.labelWidth < 13 && this.labelmd == 0){
9601 this.labelmd = this.labelWidth;
9604 if(this.labellg > 0){
9605 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9606 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9609 if(this.labelmd > 0){
9610 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9611 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9614 if(this.labelsm > 0){
9615 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9616 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9619 if(this.labelxs > 0){
9620 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9621 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9624 } else if ( this.fieldLabel.length) {
9629 //cls : 'input-group-addon',
9630 html : this.fieldLabel
9648 if (this.disabled) {
9649 input.disabled=true;
9656 * return the real textarea element.
9658 inputEl: function ()
9660 return this.el.select('textarea.form-control',true).first();
9664 * Clear any invalid styles/messages for this field
9666 clearInvalid : function()
9669 if(!this.el || this.preventMark){ // not rendered
9673 var label = this.el.select('label', true).first();
9674 var icon = this.el.select('i.fa-star', true).first();
9680 this.el.removeClass(this.invalidClass);
9682 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9684 var feedback = this.el.select('.form-control-feedback', true).first();
9687 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9692 this.fireEvent('valid', this);
9696 * Mark this field as valid
9698 markValid : function()
9700 if(!this.el || this.preventMark){ // not rendered
9704 this.el.removeClass([this.invalidClass, this.validClass]);
9706 var feedback = this.el.select('.form-control-feedback', true).first();
9709 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9712 if(this.disabled || this.allowBlank){
9716 var label = this.el.select('label', true).first();
9717 var icon = this.el.select('i.fa-star', true).first();
9723 this.el.addClass(this.validClass);
9725 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9727 var feedback = this.el.select('.form-control-feedback', true).first();
9730 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9731 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9736 this.fireEvent('valid', this);
9740 * Mark this field as invalid
9741 * @param {String} msg The validation message
9743 markInvalid : function(msg)
9745 if(!this.el || this.preventMark){ // not rendered
9749 this.el.removeClass([this.invalidClass, this.validClass]);
9751 var feedback = this.el.select('.form-control-feedback', true).first();
9754 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9757 if(this.disabled || this.allowBlank){
9761 var label = this.el.select('label', true).first();
9762 var icon = this.el.select('i.fa-star', true).first();
9764 if(!this.getValue().length && label && !icon){
9765 this.el.createChild({
9767 cls : 'text-danger fa fa-lg fa-star',
9768 tooltip : 'This field is required',
9769 style : 'margin-right:5px;'
9773 this.el.addClass(this.invalidClass);
9775 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9777 var feedback = this.el.select('.form-control-feedback', true).first();
9780 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9782 if(this.getValue().length || this.forceFeedback){
9783 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9790 this.fireEvent('invalid', this, msg);
9798 * trigger field - base class for combo..
9803 * @class Roo.bootstrap.TriggerField
9804 * @extends Roo.bootstrap.Input
9805 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9806 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9807 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9808 * for which you can provide a custom implementation. For example:
9810 var trigger = new Roo.bootstrap.TriggerField();
9811 trigger.onTriggerClick = myTriggerFn;
9812 trigger.applyTo('my-field');
9815 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9816 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9817 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9818 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9819 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9822 * Create a new TriggerField.
9823 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9824 * to the base TextField)
9826 Roo.bootstrap.TriggerField = function(config){
9827 this.mimicing = false;
9828 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9831 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9833 * @cfg {String} triggerClass A CSS class to apply to the trigger
9836 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9841 * @cfg {Boolean} removable (true|false) special filter default false
9845 /** @cfg {Boolean} grow @hide */
9846 /** @cfg {Number} growMin @hide */
9847 /** @cfg {Number} growMax @hide */
9853 autoSize: Roo.emptyFn,
9860 actionMode : 'wrap',
9865 getAutoCreate : function(){
9867 var align = this.labelAlign || this.parentLabelAlign();
9872 cls: 'form-group' //input-group
9879 type : this.inputType,
9880 cls : 'form-control',
9881 autocomplete: 'new-password',
9882 placeholder : this.placeholder || ''
9886 input.name = this.name;
9889 input.cls += ' input-' + this.size;
9892 if (this.disabled) {
9893 input.disabled=true;
9896 var inputblock = input;
9898 if(this.hasFeedback && !this.allowBlank){
9902 cls: 'glyphicon form-control-feedback'
9905 if(this.removable && !this.editable && !this.tickable){
9907 cls : 'has-feedback',
9913 cls : 'roo-combo-removable-btn close'
9920 cls : 'has-feedback',
9929 if(this.removable && !this.editable && !this.tickable){
9931 cls : 'roo-removable',
9937 cls : 'roo-combo-removable-btn close'
9944 if (this.before || this.after) {
9947 cls : 'input-group',
9951 inputblock.cn.push({
9953 cls : 'input-group-addon',
9958 inputblock.cn.push(input);
9960 if(this.hasFeedback && !this.allowBlank){
9961 inputblock.cls += ' has-feedback';
9962 inputblock.cn.push(feedback);
9966 inputblock.cn.push({
9968 cls : 'input-group-addon',
9981 cls: 'form-hidden-field'
9995 cls: 'form-hidden-field'
9999 cls: 'roo-select2-choices',
10003 cls: 'roo-select2-search-field',
10016 cls: 'roo-select2-container input-group',
10021 // cls: 'typeahead typeahead-long dropdown-menu',
10022 // style: 'display:none'
10027 if(!this.multiple && this.showToggleBtn){
10033 if (this.caret != false) {
10036 cls: 'fa fa-' + this.caret
10043 cls : 'input-group-addon btn dropdown-toggle',
10048 cls: 'combobox-clear',
10062 combobox.cls += ' roo-select2-container-multi';
10065 if (align ==='left' && this.fieldLabel.length) {
10067 cfg.cls += ' roo-form-group-label-left';
10072 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10073 tooltip : 'This field is required'
10078 cls : 'control-label',
10079 html : this.fieldLabel
10091 var labelCfg = cfg.cn[1];
10092 var contentCfg = cfg.cn[2];
10094 if(this.indicatorpos == 'right'){
10099 cls : 'control-label',
10103 html : this.fieldLabel
10107 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10108 tooltip : 'This field is required'
10121 labelCfg = cfg.cn[0];
10122 contentCfg = cfg.cn[1];
10125 if(this.labelWidth > 12){
10126 labelCfg.style = "width: " + this.labelWidth + 'px';
10129 if(this.labelWidth < 13 && this.labelmd == 0){
10130 this.labelmd = this.labelWidth;
10133 if(this.labellg > 0){
10134 labelCfg.cls += ' col-lg-' + this.labellg;
10135 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10138 if(this.labelmd > 0){
10139 labelCfg.cls += ' col-md-' + this.labelmd;
10140 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10143 if(this.labelsm > 0){
10144 labelCfg.cls += ' col-sm-' + this.labelsm;
10145 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10148 if(this.labelxs > 0){
10149 labelCfg.cls += ' col-xs-' + this.labelxs;
10150 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10153 } else if ( this.fieldLabel.length) {
10154 // Roo.log(" label");
10158 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10159 tooltip : 'This field is required'
10163 //cls : 'input-group-addon',
10164 html : this.fieldLabel
10172 if(this.indicatorpos == 'right'){
10180 html : this.fieldLabel
10184 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10185 tooltip : 'This field is required'
10198 // Roo.log(" no label && no align");
10205 ['xs','sm','md','lg'].map(function(size){
10206 if (settings[size]) {
10207 cfg.cls += ' col-' + size + '-' + settings[size];
10218 onResize : function(w, h){
10219 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10220 // if(typeof w == 'number'){
10221 // var x = w - this.trigger.getWidth();
10222 // this.inputEl().setWidth(this.adjustWidth('input', x));
10223 // this.trigger.setStyle('left', x+'px');
10228 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10231 getResizeEl : function(){
10232 return this.inputEl();
10236 getPositionEl : function(){
10237 return this.inputEl();
10241 alignErrorIcon : function(){
10242 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10246 initEvents : function(){
10250 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10251 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10252 if(!this.multiple && this.showToggleBtn){
10253 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10254 if(this.hideTrigger){
10255 this.trigger.setDisplayed(false);
10257 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10261 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10264 if(this.removable && !this.editable && !this.tickable){
10265 var close = this.closeTriggerEl();
10268 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10269 close.on('click', this.removeBtnClick, this, close);
10273 //this.trigger.addClassOnOver('x-form-trigger-over');
10274 //this.trigger.addClassOnClick('x-form-trigger-click');
10277 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10281 closeTriggerEl : function()
10283 var close = this.el.select('.roo-combo-removable-btn', true).first();
10284 return close ? close : false;
10287 removeBtnClick : function(e, h, el)
10289 e.preventDefault();
10291 if(this.fireEvent("remove", this) !== false){
10293 this.fireEvent("afterremove", this)
10297 createList : function()
10299 this.list = Roo.get(document.body).createChild({
10301 cls: 'typeahead typeahead-long dropdown-menu',
10302 style: 'display:none'
10305 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10310 initTrigger : function(){
10315 onDestroy : function(){
10317 this.trigger.removeAllListeners();
10318 // this.trigger.remove();
10321 // this.wrap.remove();
10323 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10327 onFocus : function(){
10328 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10330 if(!this.mimicing){
10331 this.wrap.addClass('x-trigger-wrap-focus');
10332 this.mimicing = true;
10333 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10334 if(this.monitorTab){
10335 this.el.on("keydown", this.checkTab, this);
10342 checkTab : function(e){
10343 if(e.getKey() == e.TAB){
10344 this.triggerBlur();
10349 onBlur : function(){
10354 mimicBlur : function(e, t){
10356 if(!this.wrap.contains(t) && this.validateBlur()){
10357 this.triggerBlur();
10363 triggerBlur : function(){
10364 this.mimicing = false;
10365 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10366 if(this.monitorTab){
10367 this.el.un("keydown", this.checkTab, this);
10369 //this.wrap.removeClass('x-trigger-wrap-focus');
10370 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10374 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10375 validateBlur : function(e, t){
10380 onDisable : function(){
10381 this.inputEl().dom.disabled = true;
10382 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10384 // this.wrap.addClass('x-item-disabled');
10389 onEnable : function(){
10390 this.inputEl().dom.disabled = false;
10391 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10393 // this.el.removeClass('x-item-disabled');
10398 onShow : function(){
10399 var ae = this.getActionEl();
10402 ae.dom.style.display = '';
10403 ae.dom.style.visibility = 'visible';
10409 onHide : function(){
10410 var ae = this.getActionEl();
10411 ae.dom.style.display = 'none';
10415 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10416 * by an implementing function.
10418 * @param {EventObject} e
10420 onTriggerClick : Roo.emptyFn
10424 * Ext JS Library 1.1.1
10425 * Copyright(c) 2006-2007, Ext JS, LLC.
10427 * Originally Released Under LGPL - original licence link has changed is not relivant.
10430 * <script type="text/javascript">
10435 * @class Roo.data.SortTypes
10437 * Defines the default sorting (casting?) comparison functions used when sorting data.
10439 Roo.data.SortTypes = {
10441 * Default sort that does nothing
10442 * @param {Mixed} s The value being converted
10443 * @return {Mixed} The comparison value
10445 none : function(s){
10450 * The regular expression used to strip tags
10454 stripTagsRE : /<\/?[^>]+>/gi,
10457 * Strips all HTML tags to sort on text only
10458 * @param {Mixed} s The value being converted
10459 * @return {String} The comparison value
10461 asText : function(s){
10462 return String(s).replace(this.stripTagsRE, "");
10466 * Strips all HTML tags to sort on text only - Case insensitive
10467 * @param {Mixed} s The value being converted
10468 * @return {String} The comparison value
10470 asUCText : function(s){
10471 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10475 * Case insensitive string
10476 * @param {Mixed} s The value being converted
10477 * @return {String} The comparison value
10479 asUCString : function(s) {
10480 return String(s).toUpperCase();
10485 * @param {Mixed} s The value being converted
10486 * @return {Number} The comparison value
10488 asDate : function(s) {
10492 if(s instanceof Date){
10493 return s.getTime();
10495 return Date.parse(String(s));
10500 * @param {Mixed} s The value being converted
10501 * @return {Float} The comparison value
10503 asFloat : function(s) {
10504 var val = parseFloat(String(s).replace(/,/g, ""));
10513 * @param {Mixed} s The value being converted
10514 * @return {Number} The comparison value
10516 asInt : function(s) {
10517 var val = parseInt(String(s).replace(/,/g, ""));
10525 * Ext JS Library 1.1.1
10526 * Copyright(c) 2006-2007, Ext JS, LLC.
10528 * Originally Released Under LGPL - original licence link has changed is not relivant.
10531 * <script type="text/javascript">
10535 * @class Roo.data.Record
10536 * Instances of this class encapsulate both record <em>definition</em> information, and record
10537 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10538 * to access Records cached in an {@link Roo.data.Store} object.<br>
10540 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10541 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10544 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10546 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10547 * {@link #create}. The parameters are the same.
10548 * @param {Array} data An associative Array of data values keyed by the field name.
10549 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10550 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10551 * not specified an integer id is generated.
10553 Roo.data.Record = function(data, id){
10554 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10559 * Generate a constructor for a specific record layout.
10560 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10561 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10562 * Each field definition object may contain the following properties: <ul>
10563 * <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,
10564 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10565 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10566 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10567 * is being used, then this is a string containing the javascript expression to reference the data relative to
10568 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10569 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10570 * this may be omitted.</p></li>
10571 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10572 * <ul><li>auto (Default, implies no conversion)</li>
10577 * <li>date</li></ul></p></li>
10578 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10579 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10580 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10581 * by the Reader into an object that will be stored in the Record. It is passed the
10582 * following parameters:<ul>
10583 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10585 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10587 * <br>usage:<br><pre><code>
10588 var TopicRecord = Roo.data.Record.create(
10589 {name: 'title', mapping: 'topic_title'},
10590 {name: 'author', mapping: 'username'},
10591 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10592 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10593 {name: 'lastPoster', mapping: 'user2'},
10594 {name: 'excerpt', mapping: 'post_text'}
10597 var myNewRecord = new TopicRecord({
10598 title: 'Do my job please',
10601 lastPost: new Date(),
10602 lastPoster: 'Animal',
10603 excerpt: 'No way dude!'
10605 myStore.add(myNewRecord);
10610 Roo.data.Record.create = function(o){
10611 var f = function(){
10612 f.superclass.constructor.apply(this, arguments);
10614 Roo.extend(f, Roo.data.Record);
10615 var p = f.prototype;
10616 p.fields = new Roo.util.MixedCollection(false, function(field){
10619 for(var i = 0, len = o.length; i < len; i++){
10620 p.fields.add(new Roo.data.Field(o[i]));
10622 f.getField = function(name){
10623 return p.fields.get(name);
10628 Roo.data.Record.AUTO_ID = 1000;
10629 Roo.data.Record.EDIT = 'edit';
10630 Roo.data.Record.REJECT = 'reject';
10631 Roo.data.Record.COMMIT = 'commit';
10633 Roo.data.Record.prototype = {
10635 * Readonly flag - true if this record has been modified.
10644 join : function(store){
10645 this.store = store;
10649 * Set the named field to the specified value.
10650 * @param {String} name The name of the field to set.
10651 * @param {Object} value The value to set the field to.
10653 set : function(name, value){
10654 if(this.data[name] == value){
10658 if(!this.modified){
10659 this.modified = {};
10661 if(typeof this.modified[name] == 'undefined'){
10662 this.modified[name] = this.data[name];
10664 this.data[name] = value;
10665 if(!this.editing && this.store){
10666 this.store.afterEdit(this);
10671 * Get the value of the named field.
10672 * @param {String} name The name of the field to get the value of.
10673 * @return {Object} The value of the field.
10675 get : function(name){
10676 return this.data[name];
10680 beginEdit : function(){
10681 this.editing = true;
10682 this.modified = {};
10686 cancelEdit : function(){
10687 this.editing = false;
10688 delete this.modified;
10692 endEdit : function(){
10693 this.editing = false;
10694 if(this.dirty && this.store){
10695 this.store.afterEdit(this);
10700 * Usually called by the {@link Roo.data.Store} which owns the Record.
10701 * Rejects all changes made to the Record since either creation, or the last commit operation.
10702 * Modified fields are reverted to their original values.
10704 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10705 * of reject operations.
10707 reject : function(){
10708 var m = this.modified;
10710 if(typeof m[n] != "function"){
10711 this.data[n] = m[n];
10714 this.dirty = false;
10715 delete this.modified;
10716 this.editing = false;
10718 this.store.afterReject(this);
10723 * Usually called by the {@link Roo.data.Store} which owns the Record.
10724 * Commits all changes made to the Record since either creation, or the last commit operation.
10726 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10727 * of commit operations.
10729 commit : function(){
10730 this.dirty = false;
10731 delete this.modified;
10732 this.editing = false;
10734 this.store.afterCommit(this);
10739 hasError : function(){
10740 return this.error != null;
10744 clearError : function(){
10749 * Creates a copy of this record.
10750 * @param {String} id (optional) A new record id if you don't want to use this record's id
10753 copy : function(newId) {
10754 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10758 * Ext JS Library 1.1.1
10759 * Copyright(c) 2006-2007, Ext JS, LLC.
10761 * Originally Released Under LGPL - original licence link has changed is not relivant.
10764 * <script type="text/javascript">
10770 * @class Roo.data.Store
10771 * @extends Roo.util.Observable
10772 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10773 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10775 * 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
10776 * has no knowledge of the format of the data returned by the Proxy.<br>
10778 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10779 * instances from the data object. These records are cached and made available through accessor functions.
10781 * Creates a new Store.
10782 * @param {Object} config A config object containing the objects needed for the Store to access data,
10783 * and read the data into Records.
10785 Roo.data.Store = function(config){
10786 this.data = new Roo.util.MixedCollection(false);
10787 this.data.getKey = function(o){
10790 this.baseParams = {};
10792 this.paramNames = {
10797 "multisort" : "_multisort"
10800 if(config && config.data){
10801 this.inlineData = config.data;
10802 delete config.data;
10805 Roo.apply(this, config);
10807 if(this.reader){ // reader passed
10808 this.reader = Roo.factory(this.reader, Roo.data);
10809 this.reader.xmodule = this.xmodule || false;
10810 if(!this.recordType){
10811 this.recordType = this.reader.recordType;
10813 if(this.reader.onMetaChange){
10814 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10818 if(this.recordType){
10819 this.fields = this.recordType.prototype.fields;
10821 this.modified = [];
10825 * @event datachanged
10826 * Fires when the data cache has changed, and a widget which is using this Store
10827 * as a Record cache should refresh its view.
10828 * @param {Store} this
10830 datachanged : true,
10832 * @event metachange
10833 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10834 * @param {Store} this
10835 * @param {Object} meta The JSON metadata
10840 * Fires when Records have been added to the Store
10841 * @param {Store} this
10842 * @param {Roo.data.Record[]} records The array of Records added
10843 * @param {Number} index The index at which the record(s) were added
10848 * Fires when a Record has been removed from the Store
10849 * @param {Store} this
10850 * @param {Roo.data.Record} record The Record that was removed
10851 * @param {Number} index The index at which the record was removed
10856 * Fires when a Record has been updated
10857 * @param {Store} this
10858 * @param {Roo.data.Record} record The Record that was updated
10859 * @param {String} operation The update operation being performed. Value may be one of:
10861 Roo.data.Record.EDIT
10862 Roo.data.Record.REJECT
10863 Roo.data.Record.COMMIT
10869 * Fires when the data cache has been cleared.
10870 * @param {Store} this
10874 * @event beforeload
10875 * Fires before a request is made for a new data object. If the beforeload handler returns false
10876 * the load action will be canceled.
10877 * @param {Store} this
10878 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10882 * @event beforeloadadd
10883 * Fires after a new set of Records has been loaded.
10884 * @param {Store} this
10885 * @param {Roo.data.Record[]} records The Records that were loaded
10886 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10888 beforeloadadd : true,
10891 * Fires after a new set of Records has been loaded, before they are added to the store.
10892 * @param {Store} this
10893 * @param {Roo.data.Record[]} records The Records that were loaded
10894 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10895 * @params {Object} return from reader
10899 * @event loadexception
10900 * Fires if an exception occurs in the Proxy during loading.
10901 * Called with the signature of the Proxy's "loadexception" event.
10902 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10905 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10906 * @param {Object} load options
10907 * @param {Object} jsonData from your request (normally this contains the Exception)
10909 loadexception : true
10913 this.proxy = Roo.factory(this.proxy, Roo.data);
10914 this.proxy.xmodule = this.xmodule || false;
10915 this.relayEvents(this.proxy, ["loadexception"]);
10917 this.sortToggle = {};
10918 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10920 Roo.data.Store.superclass.constructor.call(this);
10922 if(this.inlineData){
10923 this.loadData(this.inlineData);
10924 delete this.inlineData;
10928 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10930 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10931 * without a remote query - used by combo/forms at present.
10935 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10938 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10941 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10942 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10945 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10946 * on any HTTP request
10949 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10952 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10956 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10957 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10959 remoteSort : false,
10962 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10963 * loaded or when a record is removed. (defaults to false).
10965 pruneModifiedRecords : false,
10968 lastOptions : null,
10971 * Add Records to the Store and fires the add event.
10972 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10974 add : function(records){
10975 records = [].concat(records);
10976 for(var i = 0, len = records.length; i < len; i++){
10977 records[i].join(this);
10979 var index = this.data.length;
10980 this.data.addAll(records);
10981 this.fireEvent("add", this, records, index);
10985 * Remove a Record from the Store and fires the remove event.
10986 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10988 remove : function(record){
10989 var index = this.data.indexOf(record);
10990 this.data.removeAt(index);
10991 if(this.pruneModifiedRecords){
10992 this.modified.remove(record);
10994 this.fireEvent("remove", this, record, index);
10998 * Remove all Records from the Store and fires the clear event.
11000 removeAll : function(){
11002 if(this.pruneModifiedRecords){
11003 this.modified = [];
11005 this.fireEvent("clear", this);
11009 * Inserts Records to the Store at the given index and fires the add event.
11010 * @param {Number} index The start index at which to insert the passed Records.
11011 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11013 insert : function(index, records){
11014 records = [].concat(records);
11015 for(var i = 0, len = records.length; i < len; i++){
11016 this.data.insert(index, records[i]);
11017 records[i].join(this);
11019 this.fireEvent("add", this, records, index);
11023 * Get the index within the cache of the passed Record.
11024 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11025 * @return {Number} The index of the passed Record. Returns -1 if not found.
11027 indexOf : function(record){
11028 return this.data.indexOf(record);
11032 * Get the index within the cache of the Record with the passed id.
11033 * @param {String} id The id of the Record to find.
11034 * @return {Number} The index of the Record. Returns -1 if not found.
11036 indexOfId : function(id){
11037 return this.data.indexOfKey(id);
11041 * Get the Record with the specified id.
11042 * @param {String} id The id of the Record to find.
11043 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11045 getById : function(id){
11046 return this.data.key(id);
11050 * Get the Record at the specified index.
11051 * @param {Number} index The index of the Record to find.
11052 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11054 getAt : function(index){
11055 return this.data.itemAt(index);
11059 * Returns a range of Records between specified indices.
11060 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11061 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11062 * @return {Roo.data.Record[]} An array of Records
11064 getRange : function(start, end){
11065 return this.data.getRange(start, end);
11069 storeOptions : function(o){
11070 o = Roo.apply({}, o);
11073 this.lastOptions = o;
11077 * Loads the Record cache from the configured Proxy using the configured Reader.
11079 * If using remote paging, then the first load call must specify the <em>start</em>
11080 * and <em>limit</em> properties in the options.params property to establish the initial
11081 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11083 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11084 * and this call will return before the new data has been loaded. Perform any post-processing
11085 * in a callback function, or in a "load" event handler.</strong>
11087 * @param {Object} options An object containing properties which control loading options:<ul>
11088 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11089 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11090 * passed the following arguments:<ul>
11091 * <li>r : Roo.data.Record[]</li>
11092 * <li>options: Options object from the load call</li>
11093 * <li>success: Boolean success indicator</li></ul></li>
11094 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11095 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11098 load : function(options){
11099 options = options || {};
11100 if(this.fireEvent("beforeload", this, options) !== false){
11101 this.storeOptions(options);
11102 var p = Roo.apply(options.params || {}, this.baseParams);
11103 // if meta was not loaded from remote source.. try requesting it.
11104 if (!this.reader.metaFromRemote) {
11105 p._requestMeta = 1;
11107 if(this.sortInfo && this.remoteSort){
11108 var pn = this.paramNames;
11109 p[pn["sort"]] = this.sortInfo.field;
11110 p[pn["dir"]] = this.sortInfo.direction;
11112 if (this.multiSort) {
11113 var pn = this.paramNames;
11114 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11117 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11122 * Reloads the Record cache from the configured Proxy using the configured Reader and
11123 * the options from the last load operation performed.
11124 * @param {Object} options (optional) An object containing properties which may override the options
11125 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11126 * the most recently used options are reused).
11128 reload : function(options){
11129 this.load(Roo.applyIf(options||{}, this.lastOptions));
11133 // Called as a callback by the Reader during a load operation.
11134 loadRecords : function(o, options, success){
11135 if(!o || success === false){
11136 if(success !== false){
11137 this.fireEvent("load", this, [], options, o);
11139 if(options.callback){
11140 options.callback.call(options.scope || this, [], options, false);
11144 // if data returned failure - throw an exception.
11145 if (o.success === false) {
11146 // show a message if no listener is registered.
11147 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11148 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11150 // loadmask wil be hooked into this..
11151 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11154 var r = o.records, t = o.totalRecords || r.length;
11156 this.fireEvent("beforeloadadd", this, r, options, o);
11158 if(!options || options.add !== true){
11159 if(this.pruneModifiedRecords){
11160 this.modified = [];
11162 for(var i = 0, len = r.length; i < len; i++){
11166 this.data = this.snapshot;
11167 delete this.snapshot;
11170 this.data.addAll(r);
11171 this.totalLength = t;
11173 this.fireEvent("datachanged", this);
11175 this.totalLength = Math.max(t, this.data.length+r.length);
11179 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11181 var e = new Roo.data.Record({});
11183 e.set(this.parent.displayField, this.parent.emptyTitle);
11184 e.set(this.parent.valueField, '');
11189 this.fireEvent("load", this, r, options, o);
11190 if(options.callback){
11191 options.callback.call(options.scope || this, r, options, true);
11197 * Loads data from a passed data block. A Reader which understands the format of the data
11198 * must have been configured in the constructor.
11199 * @param {Object} data The data block from which to read the Records. The format of the data expected
11200 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11201 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11203 loadData : function(o, append){
11204 var r = this.reader.readRecords(o);
11205 this.loadRecords(r, {add: append}, true);
11209 * Gets the number of cached records.
11211 * <em>If using paging, this may not be the total size of the dataset. If the data object
11212 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11213 * the data set size</em>
11215 getCount : function(){
11216 return this.data.length || 0;
11220 * Gets the total number of records in the dataset as returned by the server.
11222 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11223 * the dataset size</em>
11225 getTotalCount : function(){
11226 return this.totalLength || 0;
11230 * Returns the sort state of the Store as an object with two properties:
11232 field {String} The name of the field by which the Records are sorted
11233 direction {String} The sort order, "ASC" or "DESC"
11236 getSortState : function(){
11237 return this.sortInfo;
11241 applySort : function(){
11242 if(this.sortInfo && !this.remoteSort){
11243 var s = this.sortInfo, f = s.field;
11244 var st = this.fields.get(f).sortType;
11245 var fn = function(r1, r2){
11246 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11247 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11249 this.data.sort(s.direction, fn);
11250 if(this.snapshot && this.snapshot != this.data){
11251 this.snapshot.sort(s.direction, fn);
11257 * Sets the default sort column and order to be used by the next load operation.
11258 * @param {String} fieldName The name of the field to sort by.
11259 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11261 setDefaultSort : function(field, dir){
11262 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11266 * Sort the Records.
11267 * If remote sorting is used, the sort is performed on the server, and the cache is
11268 * reloaded. If local sorting is used, the cache is sorted internally.
11269 * @param {String} fieldName The name of the field to sort by.
11270 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11272 sort : function(fieldName, dir){
11273 var f = this.fields.get(fieldName);
11275 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11277 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11278 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11283 this.sortToggle[f.name] = dir;
11284 this.sortInfo = {field: f.name, direction: dir};
11285 if(!this.remoteSort){
11287 this.fireEvent("datachanged", this);
11289 this.load(this.lastOptions);
11294 * Calls the specified function for each of the Records in the cache.
11295 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11296 * Returning <em>false</em> aborts and exits the iteration.
11297 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11299 each : function(fn, scope){
11300 this.data.each(fn, scope);
11304 * Gets all records modified since the last commit. Modified records are persisted across load operations
11305 * (e.g., during paging).
11306 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11308 getModifiedRecords : function(){
11309 return this.modified;
11313 createFilterFn : function(property, value, anyMatch){
11314 if(!value.exec){ // not a regex
11315 value = String(value);
11316 if(value.length == 0){
11319 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11321 return function(r){
11322 return value.test(r.data[property]);
11327 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11328 * @param {String} property A field on your records
11329 * @param {Number} start The record index to start at (defaults to 0)
11330 * @param {Number} end The last record index to include (defaults to length - 1)
11331 * @return {Number} The sum
11333 sum : function(property, start, end){
11334 var rs = this.data.items, v = 0;
11335 start = start || 0;
11336 end = (end || end === 0) ? end : rs.length-1;
11338 for(var i = start; i <= end; i++){
11339 v += (rs[i].data[property] || 0);
11345 * Filter the records by a specified property.
11346 * @param {String} field A field on your records
11347 * @param {String/RegExp} value Either a string that the field
11348 * should start with or a RegExp to test against the field
11349 * @param {Boolean} anyMatch True to match any part not just the beginning
11351 filter : function(property, value, anyMatch){
11352 var fn = this.createFilterFn(property, value, anyMatch);
11353 return fn ? this.filterBy(fn) : this.clearFilter();
11357 * Filter by a function. The specified function will be called with each
11358 * record in this data source. If the function returns true the record is included,
11359 * otherwise it is filtered.
11360 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11361 * @param {Object} scope (optional) The scope of the function (defaults to this)
11363 filterBy : function(fn, scope){
11364 this.snapshot = this.snapshot || this.data;
11365 this.data = this.queryBy(fn, scope||this);
11366 this.fireEvent("datachanged", this);
11370 * Query the records by a specified property.
11371 * @param {String} field A field on your records
11372 * @param {String/RegExp} value Either a string that the field
11373 * should start with or a RegExp to test against the field
11374 * @param {Boolean} anyMatch True to match any part not just the beginning
11375 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11377 query : function(property, value, anyMatch){
11378 var fn = this.createFilterFn(property, value, anyMatch);
11379 return fn ? this.queryBy(fn) : this.data.clone();
11383 * Query by a function. The specified function will be called with each
11384 * record in this data source. If the function returns true the record is included
11386 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11387 * @param {Object} scope (optional) The scope of the function (defaults to this)
11388 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11390 queryBy : function(fn, scope){
11391 var data = this.snapshot || this.data;
11392 return data.filterBy(fn, scope||this);
11396 * Collects unique values for a particular dataIndex from this store.
11397 * @param {String} dataIndex The property to collect
11398 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11399 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11400 * @return {Array} An array of the unique values
11402 collect : function(dataIndex, allowNull, bypassFilter){
11403 var d = (bypassFilter === true && this.snapshot) ?
11404 this.snapshot.items : this.data.items;
11405 var v, sv, r = [], l = {};
11406 for(var i = 0, len = d.length; i < len; i++){
11407 v = d[i].data[dataIndex];
11409 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11418 * Revert to a view of the Record cache with no filtering applied.
11419 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11421 clearFilter : function(suppressEvent){
11422 if(this.snapshot && this.snapshot != this.data){
11423 this.data = this.snapshot;
11424 delete this.snapshot;
11425 if(suppressEvent !== true){
11426 this.fireEvent("datachanged", this);
11432 afterEdit : function(record){
11433 if(this.modified.indexOf(record) == -1){
11434 this.modified.push(record);
11436 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11440 afterReject : function(record){
11441 this.modified.remove(record);
11442 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11446 afterCommit : function(record){
11447 this.modified.remove(record);
11448 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11452 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11453 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11455 commitChanges : function(){
11456 var m = this.modified.slice(0);
11457 this.modified = [];
11458 for(var i = 0, len = m.length; i < len; i++){
11464 * Cancel outstanding changes on all changed records.
11466 rejectChanges : function(){
11467 var m = this.modified.slice(0);
11468 this.modified = [];
11469 for(var i = 0, len = m.length; i < len; i++){
11474 onMetaChange : function(meta, rtype, o){
11475 this.recordType = rtype;
11476 this.fields = rtype.prototype.fields;
11477 delete this.snapshot;
11478 this.sortInfo = meta.sortInfo || this.sortInfo;
11479 this.modified = [];
11480 this.fireEvent('metachange', this, this.reader.meta);
11483 moveIndex : function(data, type)
11485 var index = this.indexOf(data);
11487 var newIndex = index + type;
11491 this.insert(newIndex, data);
11496 * Ext JS Library 1.1.1
11497 * Copyright(c) 2006-2007, Ext JS, LLC.
11499 * Originally Released Under LGPL - original licence link has changed is not relivant.
11502 * <script type="text/javascript">
11506 * @class Roo.data.SimpleStore
11507 * @extends Roo.data.Store
11508 * Small helper class to make creating Stores from Array data easier.
11509 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11510 * @cfg {Array} fields An array of field definition objects, or field name strings.
11511 * @cfg {Array} data The multi-dimensional array of data
11513 * @param {Object} config
11515 Roo.data.SimpleStore = function(config){
11516 Roo.data.SimpleStore.superclass.constructor.call(this, {
11518 reader: new Roo.data.ArrayReader({
11521 Roo.data.Record.create(config.fields)
11523 proxy : new Roo.data.MemoryProxy(config.data)
11527 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11529 * Ext JS Library 1.1.1
11530 * Copyright(c) 2006-2007, Ext JS, LLC.
11532 * Originally Released Under LGPL - original licence link has changed is not relivant.
11535 * <script type="text/javascript">
11540 * @extends Roo.data.Store
11541 * @class Roo.data.JsonStore
11542 * Small helper class to make creating Stores for JSON data easier. <br/>
11544 var store = new Roo.data.JsonStore({
11545 url: 'get-images.php',
11547 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11550 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11551 * JsonReader and HttpProxy (unless inline data is provided).</b>
11552 * @cfg {Array} fields An array of field definition objects, or field name strings.
11554 * @param {Object} config
11556 Roo.data.JsonStore = function(c){
11557 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11558 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11559 reader: new Roo.data.JsonReader(c, c.fields)
11562 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11564 * Ext JS Library 1.1.1
11565 * Copyright(c) 2006-2007, Ext JS, LLC.
11567 * Originally Released Under LGPL - original licence link has changed is not relivant.
11570 * <script type="text/javascript">
11574 Roo.data.Field = function(config){
11575 if(typeof config == "string"){
11576 config = {name: config};
11578 Roo.apply(this, config);
11581 this.type = "auto";
11584 var st = Roo.data.SortTypes;
11585 // named sortTypes are supported, here we look them up
11586 if(typeof this.sortType == "string"){
11587 this.sortType = st[this.sortType];
11590 // set default sortType for strings and dates
11591 if(!this.sortType){
11594 this.sortType = st.asUCString;
11597 this.sortType = st.asDate;
11600 this.sortType = st.none;
11605 var stripRe = /[\$,%]/g;
11607 // prebuilt conversion function for this field, instead of
11608 // switching every time we're reading a value
11610 var cv, dateFormat = this.dateFormat;
11615 cv = function(v){ return v; };
11618 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11622 return v !== undefined && v !== null && v !== '' ?
11623 parseInt(String(v).replace(stripRe, ""), 10) : '';
11628 return v !== undefined && v !== null && v !== '' ?
11629 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11634 cv = function(v){ return v === true || v === "true" || v == 1; };
11641 if(v instanceof Date){
11645 if(dateFormat == "timestamp"){
11646 return new Date(v*1000);
11648 return Date.parseDate(v, dateFormat);
11650 var parsed = Date.parse(v);
11651 return parsed ? new Date(parsed) : null;
11660 Roo.data.Field.prototype = {
11668 * Ext JS Library 1.1.1
11669 * Copyright(c) 2006-2007, Ext JS, LLC.
11671 * Originally Released Under LGPL - original licence link has changed is not relivant.
11674 * <script type="text/javascript">
11677 // Base class for reading structured data from a data source. This class is intended to be
11678 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11681 * @class Roo.data.DataReader
11682 * Base class for reading structured data from a data source. This class is intended to be
11683 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11686 Roo.data.DataReader = function(meta, recordType){
11690 this.recordType = recordType instanceof Array ?
11691 Roo.data.Record.create(recordType) : recordType;
11694 Roo.data.DataReader.prototype = {
11696 * Create an empty record
11697 * @param {Object} data (optional) - overlay some values
11698 * @return {Roo.data.Record} record created.
11700 newRow : function(d) {
11702 this.recordType.prototype.fields.each(function(c) {
11704 case 'int' : da[c.name] = 0; break;
11705 case 'date' : da[c.name] = new Date(); break;
11706 case 'float' : da[c.name] = 0.0; break;
11707 case 'boolean' : da[c.name] = false; break;
11708 default : da[c.name] = ""; break;
11712 return new this.recordType(Roo.apply(da, d));
11717 * Ext JS Library 1.1.1
11718 * Copyright(c) 2006-2007, Ext JS, LLC.
11720 * Originally Released Under LGPL - original licence link has changed is not relivant.
11723 * <script type="text/javascript">
11727 * @class Roo.data.DataProxy
11728 * @extends Roo.data.Observable
11729 * This class is an abstract base class for implementations which provide retrieval of
11730 * unformatted data objects.<br>
11732 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11733 * (of the appropriate type which knows how to parse the data object) to provide a block of
11734 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11736 * Custom implementations must implement the load method as described in
11737 * {@link Roo.data.HttpProxy#load}.
11739 Roo.data.DataProxy = function(){
11742 * @event beforeload
11743 * Fires before a network request is made to retrieve a data object.
11744 * @param {Object} This DataProxy object.
11745 * @param {Object} params The params parameter to the load function.
11750 * Fires before the load method's callback is called.
11751 * @param {Object} This DataProxy object.
11752 * @param {Object} o The data object.
11753 * @param {Object} arg The callback argument object passed to the load function.
11757 * @event loadexception
11758 * Fires if an Exception occurs during data retrieval.
11759 * @param {Object} This DataProxy object.
11760 * @param {Object} o The data object.
11761 * @param {Object} arg The callback argument object passed to the load function.
11762 * @param {Object} e The Exception.
11764 loadexception : true
11766 Roo.data.DataProxy.superclass.constructor.call(this);
11769 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11772 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11776 * Ext JS Library 1.1.1
11777 * Copyright(c) 2006-2007, Ext JS, LLC.
11779 * Originally Released Under LGPL - original licence link has changed is not relivant.
11782 * <script type="text/javascript">
11785 * @class Roo.data.MemoryProxy
11786 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11787 * to the Reader when its load method is called.
11789 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11791 Roo.data.MemoryProxy = function(data){
11795 Roo.data.MemoryProxy.superclass.constructor.call(this);
11799 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11802 * Load data from the requested source (in this case an in-memory
11803 * data object passed to the constructor), read the data object into
11804 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11805 * process that block using the passed callback.
11806 * @param {Object} params This parameter is not used by the MemoryProxy class.
11807 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11808 * object into a block of Roo.data.Records.
11809 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11810 * The function must be passed <ul>
11811 * <li>The Record block object</li>
11812 * <li>The "arg" argument from the load function</li>
11813 * <li>A boolean success indicator</li>
11815 * @param {Object} scope The scope in which to call the callback
11816 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11818 load : function(params, reader, callback, scope, arg){
11819 params = params || {};
11822 result = reader.readRecords(this.data);
11824 this.fireEvent("loadexception", this, arg, null, e);
11825 callback.call(scope, null, arg, false);
11828 callback.call(scope, result, arg, true);
11832 update : function(params, records){
11837 * Ext JS Library 1.1.1
11838 * Copyright(c) 2006-2007, Ext JS, LLC.
11840 * Originally Released Under LGPL - original licence link has changed is not relivant.
11843 * <script type="text/javascript">
11846 * @class Roo.data.HttpProxy
11847 * @extends Roo.data.DataProxy
11848 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11849 * configured to reference a certain URL.<br><br>
11851 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11852 * from which the running page was served.<br><br>
11854 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11856 * Be aware that to enable the browser to parse an XML document, the server must set
11857 * the Content-Type header in the HTTP response to "text/xml".
11859 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11860 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11861 * will be used to make the request.
11863 Roo.data.HttpProxy = function(conn){
11864 Roo.data.HttpProxy.superclass.constructor.call(this);
11865 // is conn a conn config or a real conn?
11867 this.useAjax = !conn || !conn.events;
11871 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11872 // thse are take from connection...
11875 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11878 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11879 * extra parameters to each request made by this object. (defaults to undefined)
11882 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11883 * to each request made by this object. (defaults to undefined)
11886 * @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)
11889 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11892 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11898 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11902 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11903 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11904 * a finer-grained basis than the DataProxy events.
11906 getConnection : function(){
11907 return this.useAjax ? Roo.Ajax : this.conn;
11911 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11912 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11913 * process that block using the passed callback.
11914 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11915 * for the request to the remote server.
11916 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11917 * object into a block of Roo.data.Records.
11918 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11919 * The function must be passed <ul>
11920 * <li>The Record block object</li>
11921 * <li>The "arg" argument from the load function</li>
11922 * <li>A boolean success indicator</li>
11924 * @param {Object} scope The scope in which to call the callback
11925 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11927 load : function(params, reader, callback, scope, arg){
11928 if(this.fireEvent("beforeload", this, params) !== false){
11930 params : params || {},
11932 callback : callback,
11937 callback : this.loadResponse,
11941 Roo.applyIf(o, this.conn);
11942 if(this.activeRequest){
11943 Roo.Ajax.abort(this.activeRequest);
11945 this.activeRequest = Roo.Ajax.request(o);
11947 this.conn.request(o);
11950 callback.call(scope||this, null, arg, false);
11955 loadResponse : function(o, success, response){
11956 delete this.activeRequest;
11958 this.fireEvent("loadexception", this, o, response);
11959 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11964 result = o.reader.read(response);
11966 this.fireEvent("loadexception", this, o, response, e);
11967 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11971 this.fireEvent("load", this, o, o.request.arg);
11972 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11976 update : function(dataSet){
11981 updateResponse : function(dataSet){
11986 * Ext JS Library 1.1.1
11987 * Copyright(c) 2006-2007, Ext JS, LLC.
11989 * Originally Released Under LGPL - original licence link has changed is not relivant.
11992 * <script type="text/javascript">
11996 * @class Roo.data.ScriptTagProxy
11997 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11998 * other than the originating domain of the running page.<br><br>
12000 * <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
12001 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12003 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12004 * source code that is used as the source inside a <script> tag.<br><br>
12006 * In order for the browser to process the returned data, the server must wrap the data object
12007 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12008 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12009 * depending on whether the callback name was passed:
12012 boolean scriptTag = false;
12013 String cb = request.getParameter("callback");
12016 response.setContentType("text/javascript");
12018 response.setContentType("application/x-json");
12020 Writer out = response.getWriter();
12022 out.write(cb + "(");
12024 out.print(dataBlock.toJsonString());
12031 * @param {Object} config A configuration object.
12033 Roo.data.ScriptTagProxy = function(config){
12034 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12035 Roo.apply(this, config);
12036 this.head = document.getElementsByTagName("head")[0];
12039 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12041 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12043 * @cfg {String} url The URL from which to request the data object.
12046 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12050 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12051 * the server the name of the callback function set up by the load call to process the returned data object.
12052 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12053 * javascript output which calls this named function passing the data object as its only parameter.
12055 callbackParam : "callback",
12057 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12058 * name to the request.
12063 * Load data from the configured URL, read the data object into
12064 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12065 * process that block using the passed callback.
12066 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12067 * for the request to the remote server.
12068 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12069 * object into a block of Roo.data.Records.
12070 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12071 * The function must be passed <ul>
12072 * <li>The Record block object</li>
12073 * <li>The "arg" argument from the load function</li>
12074 * <li>A boolean success indicator</li>
12076 * @param {Object} scope The scope in which to call the callback
12077 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12079 load : function(params, reader, callback, scope, arg){
12080 if(this.fireEvent("beforeload", this, params) !== false){
12082 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12084 var url = this.url;
12085 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12087 url += "&_dc=" + (new Date().getTime());
12089 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12092 cb : "stcCallback"+transId,
12093 scriptId : "stcScript"+transId,
12097 callback : callback,
12103 window[trans.cb] = function(o){
12104 conn.handleResponse(o, trans);
12107 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12109 if(this.autoAbort !== false){
12113 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12115 var script = document.createElement("script");
12116 script.setAttribute("src", url);
12117 script.setAttribute("type", "text/javascript");
12118 script.setAttribute("id", trans.scriptId);
12119 this.head.appendChild(script);
12121 this.trans = trans;
12123 callback.call(scope||this, null, arg, false);
12128 isLoading : function(){
12129 return this.trans ? true : false;
12133 * Abort the current server request.
12135 abort : function(){
12136 if(this.isLoading()){
12137 this.destroyTrans(this.trans);
12142 destroyTrans : function(trans, isLoaded){
12143 this.head.removeChild(document.getElementById(trans.scriptId));
12144 clearTimeout(trans.timeoutId);
12146 window[trans.cb] = undefined;
12148 delete window[trans.cb];
12151 // if hasn't been loaded, wait for load to remove it to prevent script error
12152 window[trans.cb] = function(){
12153 window[trans.cb] = undefined;
12155 delete window[trans.cb];
12162 handleResponse : function(o, trans){
12163 this.trans = false;
12164 this.destroyTrans(trans, true);
12167 result = trans.reader.readRecords(o);
12169 this.fireEvent("loadexception", this, o, trans.arg, e);
12170 trans.callback.call(trans.scope||window, null, trans.arg, false);
12173 this.fireEvent("load", this, o, trans.arg);
12174 trans.callback.call(trans.scope||window, result, trans.arg, true);
12178 handleFailure : function(trans){
12179 this.trans = false;
12180 this.destroyTrans(trans, false);
12181 this.fireEvent("loadexception", this, null, trans.arg);
12182 trans.callback.call(trans.scope||window, null, trans.arg, false);
12186 * Ext JS Library 1.1.1
12187 * Copyright(c) 2006-2007, Ext JS, LLC.
12189 * Originally Released Under LGPL - original licence link has changed is not relivant.
12192 * <script type="text/javascript">
12196 * @class Roo.data.JsonReader
12197 * @extends Roo.data.DataReader
12198 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12199 * based on mappings in a provided Roo.data.Record constructor.
12201 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12202 * in the reply previously.
12207 var RecordDef = Roo.data.Record.create([
12208 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12209 {name: 'occupation'} // This field will use "occupation" as the mapping.
12211 var myReader = new Roo.data.JsonReader({
12212 totalProperty: "results", // The property which contains the total dataset size (optional)
12213 root: "rows", // The property which contains an Array of row objects
12214 id: "id" // The property within each row object that provides an ID for the record (optional)
12218 * This would consume a JSON file like this:
12220 { 'results': 2, 'rows': [
12221 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12222 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12225 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12226 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12227 * paged from the remote server.
12228 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12229 * @cfg {String} root name of the property which contains the Array of row objects.
12230 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12231 * @cfg {Array} fields Array of field definition objects
12233 * Create a new JsonReader
12234 * @param {Object} meta Metadata configuration options
12235 * @param {Object} recordType Either an Array of field definition objects,
12236 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12238 Roo.data.JsonReader = function(meta, recordType){
12241 // set some defaults:
12242 Roo.applyIf(meta, {
12243 totalProperty: 'total',
12244 successProperty : 'success',
12249 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12251 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12254 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12255 * Used by Store query builder to append _requestMeta to params.
12258 metaFromRemote : false,
12260 * This method is only used by a DataProxy which has retrieved data from a remote server.
12261 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12262 * @return {Object} data A data block which is used by an Roo.data.Store object as
12263 * a cache of Roo.data.Records.
12265 read : function(response){
12266 var json = response.responseText;
12268 var o = /* eval:var:o */ eval("("+json+")");
12270 throw {message: "JsonReader.read: Json object not found"};
12276 this.metaFromRemote = true;
12277 this.meta = o.metaData;
12278 this.recordType = Roo.data.Record.create(o.metaData.fields);
12279 this.onMetaChange(this.meta, this.recordType, o);
12281 return this.readRecords(o);
12284 // private function a store will implement
12285 onMetaChange : function(meta, recordType, o){
12292 simpleAccess: function(obj, subsc) {
12299 getJsonAccessor: function(){
12301 return function(expr) {
12303 return(re.test(expr))
12304 ? new Function("obj", "return obj." + expr)
12309 return Roo.emptyFn;
12314 * Create a data block containing Roo.data.Records from an XML document.
12315 * @param {Object} o An object which contains an Array of row objects in the property specified
12316 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12317 * which contains the total size of the dataset.
12318 * @return {Object} data A data block which is used by an Roo.data.Store object as
12319 * a cache of Roo.data.Records.
12321 readRecords : function(o){
12323 * After any data loads, the raw JSON data is available for further custom processing.
12327 var s = this.meta, Record = this.recordType,
12328 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12330 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12332 if(s.totalProperty) {
12333 this.getTotal = this.getJsonAccessor(s.totalProperty);
12335 if(s.successProperty) {
12336 this.getSuccess = this.getJsonAccessor(s.successProperty);
12338 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12340 var g = this.getJsonAccessor(s.id);
12341 this.getId = function(rec) {
12343 return (r === undefined || r === "") ? null : r;
12346 this.getId = function(){return null;};
12349 for(var jj = 0; jj < fl; jj++){
12351 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12352 this.ef[jj] = this.getJsonAccessor(map);
12356 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12357 if(s.totalProperty){
12358 var vt = parseInt(this.getTotal(o), 10);
12363 if(s.successProperty){
12364 var vs = this.getSuccess(o);
12365 if(vs === false || vs === 'false'){
12370 for(var i = 0; i < c; i++){
12373 var id = this.getId(n);
12374 for(var j = 0; j < fl; j++){
12376 var v = this.ef[j](n);
12378 Roo.log('missing convert for ' + f.name);
12382 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12384 var record = new Record(values, id);
12386 records[i] = record;
12392 totalRecords : totalRecords
12397 * Ext JS Library 1.1.1
12398 * Copyright(c) 2006-2007, Ext JS, LLC.
12400 * Originally Released Under LGPL - original licence link has changed is not relivant.
12403 * <script type="text/javascript">
12407 * @class Roo.data.ArrayReader
12408 * @extends Roo.data.DataReader
12409 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12410 * Each element of that Array represents a row of data fields. The
12411 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12412 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12416 var RecordDef = Roo.data.Record.create([
12417 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12418 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12420 var myReader = new Roo.data.ArrayReader({
12421 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12425 * This would consume an Array like this:
12427 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12429 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12431 * Create a new JsonReader
12432 * @param {Object} meta Metadata configuration options.
12433 * @param {Object} recordType Either an Array of field definition objects
12434 * as specified to {@link Roo.data.Record#create},
12435 * or an {@link Roo.data.Record} object
12436 * created using {@link Roo.data.Record#create}.
12438 Roo.data.ArrayReader = function(meta, recordType){
12439 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12442 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12444 * Create a data block containing Roo.data.Records from an XML document.
12445 * @param {Object} o An Array of row objects which represents the dataset.
12446 * @return {Object} data A data block which is used by an Roo.data.Store object as
12447 * a cache of Roo.data.Records.
12449 readRecords : function(o){
12450 var sid = this.meta ? this.meta.id : null;
12451 var recordType = this.recordType, fields = recordType.prototype.fields;
12454 for(var i = 0; i < root.length; i++){
12457 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12458 for(var j = 0, jlen = fields.length; j < jlen; j++){
12459 var f = fields.items[j];
12460 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12461 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12463 values[f.name] = v;
12465 var record = new recordType(values, id);
12467 records[records.length] = record;
12471 totalRecords : records.length
12480 * @class Roo.bootstrap.ComboBox
12481 * @extends Roo.bootstrap.TriggerField
12482 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12483 * @cfg {Boolean} append (true|false) default false
12484 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12485 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12486 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12487 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12488 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12489 * @cfg {Boolean} animate default true
12490 * @cfg {Boolean} emptyResultText only for touch device
12491 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12492 * @cfg {String} emptyTitle default ''
12494 * Create a new ComboBox.
12495 * @param {Object} config Configuration options
12497 Roo.bootstrap.ComboBox = function(config){
12498 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12502 * Fires when the dropdown list is expanded
12503 * @param {Roo.bootstrap.ComboBox} combo This combo box
12508 * Fires when the dropdown list is collapsed
12509 * @param {Roo.bootstrap.ComboBox} combo This combo box
12513 * @event beforeselect
12514 * Fires before a list item is selected. Return false to cancel the selection.
12515 * @param {Roo.bootstrap.ComboBox} combo This combo box
12516 * @param {Roo.data.Record} record The data record returned from the underlying store
12517 * @param {Number} index The index of the selected item in the dropdown list
12519 'beforeselect' : true,
12522 * Fires when a list item is selected
12523 * @param {Roo.bootstrap.ComboBox} combo This combo box
12524 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12525 * @param {Number} index The index of the selected item in the dropdown list
12529 * @event beforequery
12530 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12531 * The event object passed has these properties:
12532 * @param {Roo.bootstrap.ComboBox} combo This combo box
12533 * @param {String} query The query
12534 * @param {Boolean} forceAll true to force "all" query
12535 * @param {Boolean} cancel true to cancel the query
12536 * @param {Object} e The query event object
12538 'beforequery': true,
12541 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12542 * @param {Roo.bootstrap.ComboBox} combo This combo box
12547 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12548 * @param {Roo.bootstrap.ComboBox} combo This combo box
12549 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12554 * Fires when the remove value from the combobox array
12555 * @param {Roo.bootstrap.ComboBox} combo This combo box
12559 * @event afterremove
12560 * Fires when the remove value from the combobox array
12561 * @param {Roo.bootstrap.ComboBox} combo This combo box
12563 'afterremove' : true,
12565 * @event specialfilter
12566 * Fires when specialfilter
12567 * @param {Roo.bootstrap.ComboBox} combo This combo box
12569 'specialfilter' : true,
12572 * Fires when tick the element
12573 * @param {Roo.bootstrap.ComboBox} combo This combo box
12577 * @event touchviewdisplay
12578 * Fires when touch view require special display (default is using displayField)
12579 * @param {Roo.bootstrap.ComboBox} combo This combo box
12580 * @param {Object} cfg set html .
12582 'touchviewdisplay' : true
12587 this.tickItems = [];
12589 this.selectedIndex = -1;
12590 if(this.mode == 'local'){
12591 if(config.queryDelay === undefined){
12592 this.queryDelay = 10;
12594 if(config.minChars === undefined){
12600 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12603 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12604 * rendering into an Roo.Editor, defaults to false)
12607 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12608 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12611 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12614 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12615 * the dropdown list (defaults to undefined, with no header element)
12619 * @cfg {String/Roo.Template} tpl The template to use to render the output
12623 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12625 listWidth: undefined,
12627 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12628 * mode = 'remote' or 'text' if mode = 'local')
12630 displayField: undefined,
12633 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12634 * mode = 'remote' or 'value' if mode = 'local').
12635 * Note: use of a valueField requires the user make a selection
12636 * in order for a value to be mapped.
12638 valueField: undefined,
12640 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12645 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12646 * field's data value (defaults to the underlying DOM element's name)
12648 hiddenName: undefined,
12650 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12654 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12656 selectedClass: 'active',
12659 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12663 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12664 * anchor positions (defaults to 'tl-bl')
12666 listAlign: 'tl-bl?',
12668 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12672 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12673 * query specified by the allQuery config option (defaults to 'query')
12675 triggerAction: 'query',
12677 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12678 * (defaults to 4, does not apply if editable = false)
12682 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12683 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12687 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12688 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12692 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12693 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12697 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12698 * when editable = true (defaults to false)
12700 selectOnFocus:false,
12702 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12704 queryParam: 'query',
12706 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12707 * when mode = 'remote' (defaults to 'Loading...')
12709 loadingText: 'Loading...',
12711 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12715 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12719 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12720 * traditional select (defaults to true)
12724 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12728 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12732 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12733 * listWidth has a higher value)
12737 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12738 * allow the user to set arbitrary text into the field (defaults to false)
12740 forceSelection:false,
12742 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12743 * if typeAhead = true (defaults to 250)
12745 typeAheadDelay : 250,
12747 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12748 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12750 valueNotFoundText : undefined,
12752 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12754 blockFocus : false,
12757 * @cfg {Boolean} disableClear Disable showing of clear button.
12759 disableClear : false,
12761 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12763 alwaysQuery : false,
12766 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12771 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12773 invalidClass : "has-warning",
12776 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12778 validClass : "has-success",
12781 * @cfg {Boolean} specialFilter (true|false) special filter default false
12783 specialFilter : false,
12786 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12788 mobileTouchView : true,
12791 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12793 useNativeIOS : false,
12795 ios_options : false,
12807 btnPosition : 'right',
12808 triggerList : true,
12809 showToggleBtn : true,
12811 emptyResultText: 'Empty',
12812 triggerText : 'Select',
12815 // element that contains real text value.. (when hidden is used..)
12817 getAutoCreate : function()
12822 * Render classic select for iso
12825 if(Roo.isIOS && this.useNativeIOS){
12826 cfg = this.getAutoCreateNativeIOS();
12834 if(Roo.isTouch && this.mobileTouchView){
12835 cfg = this.getAutoCreateTouchView();
12842 if(!this.tickable){
12843 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12848 * ComboBox with tickable selections
12851 var align = this.labelAlign || this.parentLabelAlign();
12854 cls : 'form-group roo-combobox-tickable' //input-group
12857 var btn_text_select = '';
12858 var btn_text_done = '';
12859 var btn_text_cancel = '';
12861 if (this.btn_text_show) {
12862 btn_text_select = 'Select';
12863 btn_text_done = 'Done';
12864 btn_text_cancel = 'Cancel';
12869 cls : 'tickable-buttons',
12874 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12875 //html : this.triggerText
12876 html: btn_text_select
12882 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12884 html: btn_text_done
12890 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12892 html: btn_text_cancel
12898 buttons.cn.unshift({
12900 cls: 'roo-select2-search-field-input'
12906 Roo.each(buttons.cn, function(c){
12908 c.cls += ' btn-' + _this.size;
12911 if (_this.disabled) {
12922 cls: 'form-hidden-field'
12926 cls: 'roo-select2-choices',
12930 cls: 'roo-select2-search-field',
12941 cls: 'roo-select2-container input-group roo-select2-container-multi',
12946 // cls: 'typeahead typeahead-long dropdown-menu',
12947 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12952 if(this.hasFeedback && !this.allowBlank){
12956 cls: 'glyphicon form-control-feedback'
12959 combobox.cn.push(feedback);
12963 if (align ==='left' && this.fieldLabel.length) {
12965 cfg.cls += ' roo-form-group-label-left';
12970 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12971 tooltip : 'This field is required'
12976 cls : 'control-label',
12977 html : this.fieldLabel
12989 var labelCfg = cfg.cn[1];
12990 var contentCfg = cfg.cn[2];
12993 if(this.indicatorpos == 'right'){
12999 cls : 'control-label',
13003 html : this.fieldLabel
13007 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13008 tooltip : 'This field is required'
13023 labelCfg = cfg.cn[0];
13024 contentCfg = cfg.cn[1];
13028 if(this.labelWidth > 12){
13029 labelCfg.style = "width: " + this.labelWidth + 'px';
13032 if(this.labelWidth < 13 && this.labelmd == 0){
13033 this.labelmd = this.labelWidth;
13036 if(this.labellg > 0){
13037 labelCfg.cls += ' col-lg-' + this.labellg;
13038 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13041 if(this.labelmd > 0){
13042 labelCfg.cls += ' col-md-' + this.labelmd;
13043 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13046 if(this.labelsm > 0){
13047 labelCfg.cls += ' col-sm-' + this.labelsm;
13048 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13051 if(this.labelxs > 0){
13052 labelCfg.cls += ' col-xs-' + this.labelxs;
13053 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13057 } else if ( this.fieldLabel.length) {
13058 // Roo.log(" label");
13062 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13063 tooltip : 'This field is required'
13067 //cls : 'input-group-addon',
13068 html : this.fieldLabel
13073 if(this.indicatorpos == 'right'){
13077 //cls : 'input-group-addon',
13078 html : this.fieldLabel
13082 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13083 tooltip : 'This field is required'
13092 // Roo.log(" no label && no align");
13099 ['xs','sm','md','lg'].map(function(size){
13100 if (settings[size]) {
13101 cfg.cls += ' col-' + size + '-' + settings[size];
13109 _initEventsCalled : false,
13112 initEvents: function()
13114 if (this._initEventsCalled) { // as we call render... prevent looping...
13117 this._initEventsCalled = true;
13120 throw "can not find store for combo";
13123 this.indicator = this.indicatorEl();
13125 this.store = Roo.factory(this.store, Roo.data);
13126 this.store.parent = this;
13128 // if we are building from html. then this element is so complex, that we can not really
13129 // use the rendered HTML.
13130 // so we have to trash and replace the previous code.
13131 if (Roo.XComponent.build_from_html) {
13132 // remove this element....
13133 var e = this.el.dom, k=0;
13134 while (e ) { e = e.previousSibling; ++k;}
13139 this.rendered = false;
13141 this.render(this.parent().getChildContainer(true), k);
13144 if(Roo.isIOS && this.useNativeIOS){
13145 this.initIOSView();
13153 if(Roo.isTouch && this.mobileTouchView){
13154 this.initTouchView();
13159 this.initTickableEvents();
13163 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13165 if(this.hiddenName){
13167 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13169 this.hiddenField.dom.value =
13170 this.hiddenValue !== undefined ? this.hiddenValue :
13171 this.value !== undefined ? this.value : '';
13173 // prevent input submission
13174 this.el.dom.removeAttribute('name');
13175 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13180 // this.el.dom.setAttribute('autocomplete', 'off');
13183 var cls = 'x-combo-list';
13185 //this.list = new Roo.Layer({
13186 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13192 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13193 _this.list.setWidth(lw);
13196 this.list.on('mouseover', this.onViewOver, this);
13197 this.list.on('mousemove', this.onViewMove, this);
13198 this.list.on('scroll', this.onViewScroll, this);
13201 this.list.swallowEvent('mousewheel');
13202 this.assetHeight = 0;
13205 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13206 this.assetHeight += this.header.getHeight();
13209 this.innerList = this.list.createChild({cls:cls+'-inner'});
13210 this.innerList.on('mouseover', this.onViewOver, this);
13211 this.innerList.on('mousemove', this.onViewMove, this);
13212 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13214 if(this.allowBlank && !this.pageSize && !this.disableClear){
13215 this.footer = this.list.createChild({cls:cls+'-ft'});
13216 this.pageTb = new Roo.Toolbar(this.footer);
13220 this.footer = this.list.createChild({cls:cls+'-ft'});
13221 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13222 {pageSize: this.pageSize});
13226 if (this.pageTb && this.allowBlank && !this.disableClear) {
13228 this.pageTb.add(new Roo.Toolbar.Fill(), {
13229 cls: 'x-btn-icon x-btn-clear',
13231 handler: function()
13234 _this.clearValue();
13235 _this.onSelect(false, -1);
13240 this.assetHeight += this.footer.getHeight();
13245 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13248 this.view = new Roo.View(this.list, this.tpl, {
13249 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13251 //this.view.wrapEl.setDisplayed(false);
13252 this.view.on('click', this.onViewClick, this);
13255 this.store.on('beforeload', this.onBeforeLoad, this);
13256 this.store.on('load', this.onLoad, this);
13257 this.store.on('loadexception', this.onLoadException, this);
13259 if(this.resizable){
13260 this.resizer = new Roo.Resizable(this.list, {
13261 pinned:true, handles:'se'
13263 this.resizer.on('resize', function(r, w, h){
13264 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13265 this.listWidth = w;
13266 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13267 this.restrictHeight();
13269 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13272 if(!this.editable){
13273 this.editable = true;
13274 this.setEditable(false);
13279 if (typeof(this.events.add.listeners) != 'undefined') {
13281 this.addicon = this.wrap.createChild(
13282 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13284 this.addicon.on('click', function(e) {
13285 this.fireEvent('add', this);
13288 if (typeof(this.events.edit.listeners) != 'undefined') {
13290 this.editicon = this.wrap.createChild(
13291 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13292 if (this.addicon) {
13293 this.editicon.setStyle('margin-left', '40px');
13295 this.editicon.on('click', function(e) {
13297 // we fire even if inothing is selected..
13298 this.fireEvent('edit', this, this.lastData );
13304 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13305 "up" : function(e){
13306 this.inKeyMode = true;
13310 "down" : function(e){
13311 if(!this.isExpanded()){
13312 this.onTriggerClick();
13314 this.inKeyMode = true;
13319 "enter" : function(e){
13320 // this.onViewClick();
13324 if(this.fireEvent("specialkey", this, e)){
13325 this.onViewClick(false);
13331 "esc" : function(e){
13335 "tab" : function(e){
13338 if(this.fireEvent("specialkey", this, e)){
13339 this.onViewClick(false);
13347 doRelay : function(foo, bar, hname){
13348 if(hname == 'down' || this.scope.isExpanded()){
13349 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13358 this.queryDelay = Math.max(this.queryDelay || 10,
13359 this.mode == 'local' ? 10 : 250);
13362 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13364 if(this.typeAhead){
13365 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13367 if(this.editable !== false){
13368 this.inputEl().on("keyup", this.onKeyUp, this);
13370 if(this.forceSelection){
13371 this.inputEl().on('blur', this.doForce, this);
13375 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13376 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13380 initTickableEvents: function()
13384 if(this.hiddenName){
13386 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13388 this.hiddenField.dom.value =
13389 this.hiddenValue !== undefined ? this.hiddenValue :
13390 this.value !== undefined ? this.value : '';
13392 // prevent input submission
13393 this.el.dom.removeAttribute('name');
13394 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13399 // this.list = this.el.select('ul.dropdown-menu',true).first();
13401 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13402 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13403 if(this.triggerList){
13404 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13407 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13408 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13410 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13411 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13413 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13414 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13416 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13417 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13418 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13421 this.cancelBtn.hide();
13426 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13427 _this.list.setWidth(lw);
13430 this.list.on('mouseover', this.onViewOver, this);
13431 this.list.on('mousemove', this.onViewMove, this);
13433 this.list.on('scroll', this.onViewScroll, this);
13436 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>';
13439 this.view = new Roo.View(this.list, this.tpl, {
13440 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13443 //this.view.wrapEl.setDisplayed(false);
13444 this.view.on('click', this.onViewClick, this);
13448 this.store.on('beforeload', this.onBeforeLoad, this);
13449 this.store.on('load', this.onLoad, this);
13450 this.store.on('loadexception', this.onLoadException, this);
13453 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13454 "up" : function(e){
13455 this.inKeyMode = true;
13459 "down" : function(e){
13460 this.inKeyMode = true;
13464 "enter" : function(e){
13465 if(this.fireEvent("specialkey", this, e)){
13466 this.onViewClick(false);
13472 "esc" : function(e){
13473 this.onTickableFooterButtonClick(e, false, false);
13476 "tab" : function(e){
13477 this.fireEvent("specialkey", this, e);
13479 this.onTickableFooterButtonClick(e, false, false);
13486 doRelay : function(e, fn, key){
13487 if(this.scope.isExpanded()){
13488 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13497 this.queryDelay = Math.max(this.queryDelay || 10,
13498 this.mode == 'local' ? 10 : 250);
13501 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13503 if(this.typeAhead){
13504 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13507 if(this.editable !== false){
13508 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13511 this.indicator = this.indicatorEl();
13513 if(this.indicator){
13514 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13515 this.indicator.hide();
13520 onDestroy : function(){
13522 this.view.setStore(null);
13523 this.view.el.removeAllListeners();
13524 this.view.el.remove();
13525 this.view.purgeListeners();
13528 this.list.dom.innerHTML = '';
13532 this.store.un('beforeload', this.onBeforeLoad, this);
13533 this.store.un('load', this.onLoad, this);
13534 this.store.un('loadexception', this.onLoadException, this);
13536 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13540 fireKey : function(e){
13541 if(e.isNavKeyPress() && !this.list.isVisible()){
13542 this.fireEvent("specialkey", this, e);
13547 onResize: function(w, h){
13548 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13550 // if(typeof w != 'number'){
13551 // // we do not handle it!?!?
13554 // var tw = this.trigger.getWidth();
13555 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13556 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13558 // this.inputEl().setWidth( this.adjustWidth('input', x));
13560 // //this.trigger.setStyle('left', x+'px');
13562 // if(this.list && this.listWidth === undefined){
13563 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13564 // this.list.setWidth(lw);
13565 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13573 * Allow or prevent the user from directly editing the field text. If false is passed,
13574 * the user will only be able to select from the items defined in the dropdown list. This method
13575 * is the runtime equivalent of setting the 'editable' config option at config time.
13576 * @param {Boolean} value True to allow the user to directly edit the field text
13578 setEditable : function(value){
13579 if(value == this.editable){
13582 this.editable = value;
13584 this.inputEl().dom.setAttribute('readOnly', true);
13585 this.inputEl().on('mousedown', this.onTriggerClick, this);
13586 this.inputEl().addClass('x-combo-noedit');
13588 this.inputEl().dom.setAttribute('readOnly', false);
13589 this.inputEl().un('mousedown', this.onTriggerClick, this);
13590 this.inputEl().removeClass('x-combo-noedit');
13596 onBeforeLoad : function(combo,opts){
13597 if(!this.hasFocus){
13601 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13603 this.restrictHeight();
13604 this.selectedIndex = -1;
13608 onLoad : function(){
13610 this.hasQuery = false;
13612 if(!this.hasFocus){
13616 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13617 this.loading.hide();
13620 if(this.store.getCount() > 0){
13623 this.restrictHeight();
13624 if(this.lastQuery == this.allQuery){
13625 if(this.editable && !this.tickable){
13626 this.inputEl().dom.select();
13630 !this.selectByValue(this.value, true) &&
13633 !this.store.lastOptions ||
13634 typeof(this.store.lastOptions.add) == 'undefined' ||
13635 this.store.lastOptions.add != true
13638 this.select(0, true);
13641 if(this.autoFocus){
13644 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13645 this.taTask.delay(this.typeAheadDelay);
13649 this.onEmptyResults();
13655 onLoadException : function()
13657 this.hasQuery = false;
13659 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13660 this.loading.hide();
13663 if(this.tickable && this.editable){
13668 // only causes errors at present
13669 //Roo.log(this.store.reader.jsonData);
13670 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13672 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13678 onTypeAhead : function(){
13679 if(this.store.getCount() > 0){
13680 var r = this.store.getAt(0);
13681 var newValue = r.data[this.displayField];
13682 var len = newValue.length;
13683 var selStart = this.getRawValue().length;
13685 if(selStart != len){
13686 this.setRawValue(newValue);
13687 this.selectText(selStart, newValue.length);
13693 onSelect : function(record, index){
13695 if(this.fireEvent('beforeselect', this, record, index) !== false){
13697 this.setFromData(index > -1 ? record.data : false);
13700 this.fireEvent('select', this, record, index);
13705 * Returns the currently selected field value or empty string if no value is set.
13706 * @return {String} value The selected value
13708 getValue : function()
13710 if(Roo.isIOS && this.useNativeIOS){
13711 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13715 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13718 if(this.valueField){
13719 return typeof this.value != 'undefined' ? this.value : '';
13721 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13725 getRawValue : function()
13727 if(Roo.isIOS && this.useNativeIOS){
13728 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13731 var v = this.inputEl().getValue();
13737 * Clears any text/value currently set in the field
13739 clearValue : function(){
13741 if(this.hiddenField){
13742 this.hiddenField.dom.value = '';
13745 this.setRawValue('');
13746 this.lastSelectionText = '';
13747 this.lastData = false;
13749 var close = this.closeTriggerEl();
13760 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13761 * will be displayed in the field. If the value does not match the data value of an existing item,
13762 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13763 * Otherwise the field will be blank (although the value will still be set).
13764 * @param {String} value The value to match
13766 setValue : function(v)
13768 if(Roo.isIOS && this.useNativeIOS){
13769 this.setIOSValue(v);
13779 if(this.valueField){
13780 var r = this.findRecord(this.valueField, v);
13782 text = r.data[this.displayField];
13783 }else if(this.valueNotFoundText !== undefined){
13784 text = this.valueNotFoundText;
13787 this.lastSelectionText = text;
13788 if(this.hiddenField){
13789 this.hiddenField.dom.value = v;
13791 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13794 var close = this.closeTriggerEl();
13797 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13803 * @property {Object} the last set data for the element
13808 * Sets the value of the field based on a object which is related to the record format for the store.
13809 * @param {Object} value the value to set as. or false on reset?
13811 setFromData : function(o){
13818 var dv = ''; // display value
13819 var vv = ''; // value value..
13821 if (this.displayField) {
13822 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13824 // this is an error condition!!!
13825 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13828 if(this.valueField){
13829 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13832 var close = this.closeTriggerEl();
13835 if(dv.length || vv * 1 > 0){
13837 this.blockFocus=true;
13843 if(this.hiddenField){
13844 this.hiddenField.dom.value = vv;
13846 this.lastSelectionText = dv;
13847 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13851 // no hidden field.. - we store the value in 'value', but still display
13852 // display field!!!!
13853 this.lastSelectionText = dv;
13854 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13861 reset : function(){
13862 // overridden so that last data is reset..
13869 this.setValue(this.originalValue);
13870 //this.clearInvalid();
13871 this.lastData = false;
13873 this.view.clearSelections();
13879 findRecord : function(prop, value){
13881 if(this.store.getCount() > 0){
13882 this.store.each(function(r){
13883 if(r.data[prop] == value){
13893 getName: function()
13895 // returns hidden if it's set..
13896 if (!this.rendered) {return ''};
13897 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13901 onViewMove : function(e, t){
13902 this.inKeyMode = false;
13906 onViewOver : function(e, t){
13907 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13910 var item = this.view.findItemFromChild(t);
13913 var index = this.view.indexOf(item);
13914 this.select(index, false);
13919 onViewClick : function(view, doFocus, el, e)
13921 var index = this.view.getSelectedIndexes()[0];
13923 var r = this.store.getAt(index);
13927 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13934 Roo.each(this.tickItems, function(v,k){
13936 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13938 _this.tickItems.splice(k, 1);
13940 if(typeof(e) == 'undefined' && view == false){
13941 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13953 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13954 this.tickItems.push(r.data);
13957 if(typeof(e) == 'undefined' && view == false){
13958 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13965 this.onSelect(r, index);
13967 if(doFocus !== false && !this.blockFocus){
13968 this.inputEl().focus();
13973 restrictHeight : function(){
13974 //this.innerList.dom.style.height = '';
13975 //var inner = this.innerList.dom;
13976 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13977 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13978 //this.list.beginUpdate();
13979 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13980 this.list.alignTo(this.inputEl(), this.listAlign);
13981 this.list.alignTo(this.inputEl(), this.listAlign);
13982 //this.list.endUpdate();
13986 onEmptyResults : function(){
13988 if(this.tickable && this.editable){
13989 this.restrictHeight();
13997 * Returns true if the dropdown list is expanded, else false.
13999 isExpanded : function(){
14000 return this.list.isVisible();
14004 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14005 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14006 * @param {String} value The data value of the item to select
14007 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14008 * selected item if it is not currently in view (defaults to true)
14009 * @return {Boolean} True if the value matched an item in the list, else false
14011 selectByValue : function(v, scrollIntoView){
14012 if(v !== undefined && v !== null){
14013 var r = this.findRecord(this.valueField || this.displayField, v);
14015 this.select(this.store.indexOf(r), scrollIntoView);
14023 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14024 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14025 * @param {Number} index The zero-based index of the list item to select
14026 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14027 * selected item if it is not currently in view (defaults to true)
14029 select : function(index, scrollIntoView){
14030 this.selectedIndex = index;
14031 this.view.select(index);
14032 if(scrollIntoView !== false){
14033 var el = this.view.getNode(index);
14035 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14038 this.list.scrollChildIntoView(el, false);
14044 selectNext : function(){
14045 var ct = this.store.getCount();
14047 if(this.selectedIndex == -1){
14049 }else if(this.selectedIndex < ct-1){
14050 this.select(this.selectedIndex+1);
14056 selectPrev : function(){
14057 var ct = this.store.getCount();
14059 if(this.selectedIndex == -1){
14061 }else if(this.selectedIndex != 0){
14062 this.select(this.selectedIndex-1);
14068 onKeyUp : function(e){
14069 if(this.editable !== false && !e.isSpecialKey()){
14070 this.lastKey = e.getKey();
14071 this.dqTask.delay(this.queryDelay);
14076 validateBlur : function(){
14077 return !this.list || !this.list.isVisible();
14081 initQuery : function(){
14083 var v = this.getRawValue();
14085 if(this.tickable && this.editable){
14086 v = this.tickableInputEl().getValue();
14093 doForce : function(){
14094 if(this.inputEl().dom.value.length > 0){
14095 this.inputEl().dom.value =
14096 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14102 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14103 * query allowing the query action to be canceled if needed.
14104 * @param {String} query The SQL query to execute
14105 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14106 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14107 * saved in the current store (defaults to false)
14109 doQuery : function(q, forceAll){
14111 if(q === undefined || q === null){
14116 forceAll: forceAll,
14120 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14125 forceAll = qe.forceAll;
14126 if(forceAll === true || (q.length >= this.minChars)){
14128 this.hasQuery = true;
14130 if(this.lastQuery != q || this.alwaysQuery){
14131 this.lastQuery = q;
14132 if(this.mode == 'local'){
14133 this.selectedIndex = -1;
14135 this.store.clearFilter();
14138 if(this.specialFilter){
14139 this.fireEvent('specialfilter', this);
14144 this.store.filter(this.displayField, q);
14147 this.store.fireEvent("datachanged", this.store);
14154 this.store.baseParams[this.queryParam] = q;
14156 var options = {params : this.getParams(q)};
14159 options.add = true;
14160 options.params.start = this.page * this.pageSize;
14163 this.store.load(options);
14166 * this code will make the page width larger, at the beginning, the list not align correctly,
14167 * we should expand the list on onLoad
14168 * so command out it
14173 this.selectedIndex = -1;
14178 this.loadNext = false;
14182 getParams : function(q){
14184 //p[this.queryParam] = q;
14188 p.limit = this.pageSize;
14194 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14196 collapse : function(){
14197 if(!this.isExpanded()){
14203 this.hasFocus = false;
14208 this.cancelBtn.hide();
14209 this.trigger.show();
14212 this.tickableInputEl().dom.value = '';
14213 this.tickableInputEl().blur();
14218 Roo.get(document).un('mousedown', this.collapseIf, this);
14219 Roo.get(document).un('mousewheel', this.collapseIf, this);
14220 if (!this.editable) {
14221 Roo.get(document).un('keydown', this.listKeyPress, this);
14223 this.fireEvent('collapse', this);
14229 collapseIf : function(e){
14230 var in_combo = e.within(this.el);
14231 var in_list = e.within(this.list);
14232 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14234 if (in_combo || in_list || is_list) {
14235 //e.stopPropagation();
14240 this.onTickableFooterButtonClick(e, false, false);
14248 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14250 expand : function(){
14252 if(this.isExpanded() || !this.hasFocus){
14256 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14257 this.list.setWidth(lw);
14263 this.restrictHeight();
14267 this.tickItems = Roo.apply([], this.item);
14270 this.cancelBtn.show();
14271 this.trigger.hide();
14274 this.tickableInputEl().focus();
14279 Roo.get(document).on('mousedown', this.collapseIf, this);
14280 Roo.get(document).on('mousewheel', this.collapseIf, this);
14281 if (!this.editable) {
14282 Roo.get(document).on('keydown', this.listKeyPress, this);
14285 this.fireEvent('expand', this);
14289 // Implements the default empty TriggerField.onTriggerClick function
14290 onTriggerClick : function(e)
14292 Roo.log('trigger click');
14294 if(this.disabled || !this.triggerList){
14299 this.loadNext = false;
14301 if(this.isExpanded()){
14303 if (!this.blockFocus) {
14304 this.inputEl().focus();
14308 this.hasFocus = true;
14309 if(this.triggerAction == 'all') {
14310 this.doQuery(this.allQuery, true);
14312 this.doQuery(this.getRawValue());
14314 if (!this.blockFocus) {
14315 this.inputEl().focus();
14320 onTickableTriggerClick : function(e)
14327 this.loadNext = false;
14328 this.hasFocus = true;
14330 if(this.triggerAction == 'all') {
14331 this.doQuery(this.allQuery, true);
14333 this.doQuery(this.getRawValue());
14337 onSearchFieldClick : function(e)
14339 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14340 this.onTickableFooterButtonClick(e, false, false);
14344 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14349 this.loadNext = false;
14350 this.hasFocus = true;
14352 if(this.triggerAction == 'all') {
14353 this.doQuery(this.allQuery, true);
14355 this.doQuery(this.getRawValue());
14359 listKeyPress : function(e)
14361 //Roo.log('listkeypress');
14362 // scroll to first matching element based on key pres..
14363 if (e.isSpecialKey()) {
14366 var k = String.fromCharCode(e.getKey()).toUpperCase();
14369 var csel = this.view.getSelectedNodes();
14370 var cselitem = false;
14372 var ix = this.view.indexOf(csel[0]);
14373 cselitem = this.store.getAt(ix);
14374 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14380 this.store.each(function(v) {
14382 // start at existing selection.
14383 if (cselitem.id == v.id) {
14389 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14390 match = this.store.indexOf(v);
14396 if (match === false) {
14397 return true; // no more action?
14400 this.view.select(match);
14401 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14402 sn.scrollIntoView(sn.dom.parentNode, false);
14405 onViewScroll : function(e, t){
14407 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){
14411 this.hasQuery = true;
14413 this.loading = this.list.select('.loading', true).first();
14415 if(this.loading === null){
14416 this.list.createChild({
14418 cls: 'loading roo-select2-more-results roo-select2-active',
14419 html: 'Loading more results...'
14422 this.loading = this.list.select('.loading', true).first();
14424 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14426 this.loading.hide();
14429 this.loading.show();
14434 this.loadNext = true;
14436 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14441 addItem : function(o)
14443 var dv = ''; // display value
14445 if (this.displayField) {
14446 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14448 // this is an error condition!!!
14449 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14456 var choice = this.choices.createChild({
14458 cls: 'roo-select2-search-choice',
14467 cls: 'roo-select2-search-choice-close fa fa-times',
14472 }, this.searchField);
14474 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14476 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14484 this.inputEl().dom.value = '';
14489 onRemoveItem : function(e, _self, o)
14491 e.preventDefault();
14493 this.lastItem = Roo.apply([], this.item);
14495 var index = this.item.indexOf(o.data) * 1;
14498 Roo.log('not this item?!');
14502 this.item.splice(index, 1);
14507 this.fireEvent('remove', this, e);
14513 syncValue : function()
14515 if(!this.item.length){
14522 Roo.each(this.item, function(i){
14523 if(_this.valueField){
14524 value.push(i[_this.valueField]);
14531 this.value = value.join(',');
14533 if(this.hiddenField){
14534 this.hiddenField.dom.value = this.value;
14537 this.store.fireEvent("datachanged", this.store);
14542 clearItem : function()
14544 if(!this.multiple){
14550 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14558 if(this.tickable && !Roo.isTouch){
14559 this.view.refresh();
14563 inputEl: function ()
14565 if(Roo.isIOS && this.useNativeIOS){
14566 return this.el.select('select.roo-ios-select', true).first();
14569 if(Roo.isTouch && this.mobileTouchView){
14570 return this.el.select('input.form-control',true).first();
14574 return this.searchField;
14577 return this.el.select('input.form-control',true).first();
14580 onTickableFooterButtonClick : function(e, btn, el)
14582 e.preventDefault();
14584 this.lastItem = Roo.apply([], this.item);
14586 if(btn && btn.name == 'cancel'){
14587 this.tickItems = Roo.apply([], this.item);
14596 Roo.each(this.tickItems, function(o){
14604 validate : function()
14606 var v = this.getRawValue();
14609 v = this.getValue();
14612 if(this.disabled || this.allowBlank || v.length){
14617 this.markInvalid();
14621 tickableInputEl : function()
14623 if(!this.tickable || !this.editable){
14624 return this.inputEl();
14627 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14631 getAutoCreateTouchView : function()
14636 cls: 'form-group' //input-group
14642 type : this.inputType,
14643 cls : 'form-control x-combo-noedit',
14644 autocomplete: 'new-password',
14645 placeholder : this.placeholder || '',
14650 input.name = this.name;
14654 input.cls += ' input-' + this.size;
14657 if (this.disabled) {
14658 input.disabled = true;
14669 inputblock.cls += ' input-group';
14671 inputblock.cn.unshift({
14673 cls : 'input-group-addon',
14678 if(this.removable && !this.multiple){
14679 inputblock.cls += ' roo-removable';
14681 inputblock.cn.push({
14684 cls : 'roo-combo-removable-btn close'
14688 if(this.hasFeedback && !this.allowBlank){
14690 inputblock.cls += ' has-feedback';
14692 inputblock.cn.push({
14694 cls: 'glyphicon form-control-feedback'
14701 inputblock.cls += (this.before) ? '' : ' input-group';
14703 inputblock.cn.push({
14705 cls : 'input-group-addon',
14716 cls: 'form-hidden-field'
14730 cls: 'form-hidden-field'
14734 cls: 'roo-select2-choices',
14738 cls: 'roo-select2-search-field',
14751 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14757 if(!this.multiple && this.showToggleBtn){
14764 if (this.caret != false) {
14767 cls: 'fa fa-' + this.caret
14774 cls : 'input-group-addon btn dropdown-toggle',
14779 cls: 'combobox-clear',
14793 combobox.cls += ' roo-select2-container-multi';
14796 var align = this.labelAlign || this.parentLabelAlign();
14798 if (align ==='left' && this.fieldLabel.length) {
14803 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14804 tooltip : 'This field is required'
14808 cls : 'control-label',
14809 html : this.fieldLabel
14820 var labelCfg = cfg.cn[1];
14821 var contentCfg = cfg.cn[2];
14824 if(this.indicatorpos == 'right'){
14829 cls : 'control-label',
14833 html : this.fieldLabel
14837 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14838 tooltip : 'This field is required'
14851 labelCfg = cfg.cn[0];
14852 contentCfg = cfg.cn[1];
14857 if(this.labelWidth > 12){
14858 labelCfg.style = "width: " + this.labelWidth + 'px';
14861 if(this.labelWidth < 13 && this.labelmd == 0){
14862 this.labelmd = this.labelWidth;
14865 if(this.labellg > 0){
14866 labelCfg.cls += ' col-lg-' + this.labellg;
14867 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14870 if(this.labelmd > 0){
14871 labelCfg.cls += ' col-md-' + this.labelmd;
14872 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14875 if(this.labelsm > 0){
14876 labelCfg.cls += ' col-sm-' + this.labelsm;
14877 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14880 if(this.labelxs > 0){
14881 labelCfg.cls += ' col-xs-' + this.labelxs;
14882 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14886 } else if ( this.fieldLabel.length) {
14890 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14891 tooltip : 'This field is required'
14895 cls : 'control-label',
14896 html : this.fieldLabel
14907 if(this.indicatorpos == 'right'){
14911 cls : 'control-label',
14912 html : this.fieldLabel,
14916 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14917 tooltip : 'This field is required'
14934 var settings = this;
14936 ['xs','sm','md','lg'].map(function(size){
14937 if (settings[size]) {
14938 cfg.cls += ' col-' + size + '-' + settings[size];
14945 initTouchView : function()
14947 this.renderTouchView();
14949 this.touchViewEl.on('scroll', function(){
14950 this.el.dom.scrollTop = 0;
14953 this.originalValue = this.getValue();
14955 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14957 this.inputEl().on("click", this.showTouchView, this);
14958 if (this.triggerEl) {
14959 this.triggerEl.on("click", this.showTouchView, this);
14963 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14964 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14966 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14968 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14969 this.store.on('load', this.onTouchViewLoad, this);
14970 this.store.on('loadexception', this.onTouchViewLoadException, this);
14972 if(this.hiddenName){
14974 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14976 this.hiddenField.dom.value =
14977 this.hiddenValue !== undefined ? this.hiddenValue :
14978 this.value !== undefined ? this.value : '';
14980 this.el.dom.removeAttribute('name');
14981 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14985 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14986 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14989 if(this.removable && !this.multiple){
14990 var close = this.closeTriggerEl();
14992 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14993 close.on('click', this.removeBtnClick, this, close);
14997 * fix the bug in Safari iOS8
14999 this.inputEl().on("focus", function(e){
15000 document.activeElement.blur();
15008 renderTouchView : function()
15010 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15011 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15013 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15014 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15016 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15017 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15018 this.touchViewBodyEl.setStyle('overflow', 'auto');
15020 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15021 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15023 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15024 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15028 showTouchView : function()
15034 this.touchViewHeaderEl.hide();
15036 if(this.modalTitle.length){
15037 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15038 this.touchViewHeaderEl.show();
15041 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15042 this.touchViewEl.show();
15044 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15046 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15047 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15049 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15051 if(this.modalTitle.length){
15052 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15055 this.touchViewBodyEl.setHeight(bodyHeight);
15059 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15061 this.touchViewEl.addClass('in');
15064 this.doTouchViewQuery();
15068 hideTouchView : function()
15070 this.touchViewEl.removeClass('in');
15074 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15076 this.touchViewEl.setStyle('display', 'none');
15081 setTouchViewValue : function()
15088 Roo.each(this.tickItems, function(o){
15093 this.hideTouchView();
15096 doTouchViewQuery : function()
15105 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15109 if(!this.alwaysQuery || this.mode == 'local'){
15110 this.onTouchViewLoad();
15117 onTouchViewBeforeLoad : function(combo,opts)
15123 onTouchViewLoad : function()
15125 if(this.store.getCount() < 1){
15126 this.onTouchViewEmptyResults();
15130 this.clearTouchView();
15132 var rawValue = this.getRawValue();
15134 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15136 this.tickItems = [];
15138 this.store.data.each(function(d, rowIndex){
15139 var row = this.touchViewListGroup.createChild(template);
15141 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15142 row.addClass(d.data.cls);
15145 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15148 html : d.data[this.displayField]
15151 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15152 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15155 row.removeClass('selected');
15156 if(!this.multiple && this.valueField &&
15157 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15160 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15161 row.addClass('selected');
15164 if(this.multiple && this.valueField &&
15165 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15169 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15170 this.tickItems.push(d.data);
15173 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15177 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15179 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15181 if(this.modalTitle.length){
15182 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15185 var listHeight = this.touchViewListGroup.getHeight();
15189 if(firstChecked && listHeight > bodyHeight){
15190 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15195 onTouchViewLoadException : function()
15197 this.hideTouchView();
15200 onTouchViewEmptyResults : function()
15202 this.clearTouchView();
15204 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15206 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15210 clearTouchView : function()
15212 this.touchViewListGroup.dom.innerHTML = '';
15215 onTouchViewClick : function(e, el, o)
15217 e.preventDefault();
15220 var rowIndex = o.rowIndex;
15222 var r = this.store.getAt(rowIndex);
15224 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15226 if(!this.multiple){
15227 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15228 c.dom.removeAttribute('checked');
15231 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15233 this.setFromData(r.data);
15235 var close = this.closeTriggerEl();
15241 this.hideTouchView();
15243 this.fireEvent('select', this, r, rowIndex);
15248 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15249 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15250 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15254 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15255 this.addItem(r.data);
15256 this.tickItems.push(r.data);
15260 getAutoCreateNativeIOS : function()
15263 cls: 'form-group' //input-group,
15268 cls : 'roo-ios-select'
15272 combobox.name = this.name;
15275 if (this.disabled) {
15276 combobox.disabled = true;
15279 var settings = this;
15281 ['xs','sm','md','lg'].map(function(size){
15282 if (settings[size]) {
15283 cfg.cls += ' col-' + size + '-' + settings[size];
15293 initIOSView : function()
15295 this.store.on('load', this.onIOSViewLoad, this);
15300 onIOSViewLoad : function()
15302 if(this.store.getCount() < 1){
15306 this.clearIOSView();
15308 if(this.allowBlank) {
15310 var default_text = '-- SELECT --';
15312 if(this.placeholder.length){
15313 default_text = this.placeholder;
15316 if(this.emptyTitle.length){
15317 default_text += ' - ' + this.emptyTitle + ' -';
15320 var opt = this.inputEl().createChild({
15323 html : default_text
15327 o[this.valueField] = 0;
15328 o[this.displayField] = default_text;
15330 this.ios_options.push({
15337 this.store.data.each(function(d, rowIndex){
15341 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15342 html = d.data[this.displayField];
15347 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15348 value = d.data[this.valueField];
15357 if(this.value == d.data[this.valueField]){
15358 option['selected'] = true;
15361 var opt = this.inputEl().createChild(option);
15363 this.ios_options.push({
15370 this.inputEl().on('change', function(){
15371 this.fireEvent('select', this);
15376 clearIOSView: function()
15378 this.inputEl().dom.innerHTML = '';
15380 this.ios_options = [];
15383 setIOSValue: function(v)
15387 if(!this.ios_options){
15391 Roo.each(this.ios_options, function(opts){
15393 opts.el.dom.removeAttribute('selected');
15395 if(opts.data[this.valueField] != v){
15399 opts.el.dom.setAttribute('selected', true);
15405 * @cfg {Boolean} grow
15409 * @cfg {Number} growMin
15413 * @cfg {Number} growMax
15422 Roo.apply(Roo.bootstrap.ComboBox, {
15426 cls: 'modal-header',
15448 cls: 'list-group-item',
15452 cls: 'roo-combobox-list-group-item-value'
15456 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15470 listItemCheckbox : {
15472 cls: 'list-group-item',
15476 cls: 'roo-combobox-list-group-item-value'
15480 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15496 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15501 cls: 'modal-footer',
15509 cls: 'col-xs-6 text-left',
15512 cls: 'btn btn-danger roo-touch-view-cancel',
15518 cls: 'col-xs-6 text-right',
15521 cls: 'btn btn-success roo-touch-view-ok',
15532 Roo.apply(Roo.bootstrap.ComboBox, {
15534 touchViewTemplate : {
15536 cls: 'modal fade roo-combobox-touch-view',
15540 cls: 'modal-dialog',
15541 style : 'position:fixed', // we have to fix position....
15545 cls: 'modal-content',
15547 Roo.bootstrap.ComboBox.header,
15548 Roo.bootstrap.ComboBox.body,
15549 Roo.bootstrap.ComboBox.footer
15558 * Ext JS Library 1.1.1
15559 * Copyright(c) 2006-2007, Ext JS, LLC.
15561 * Originally Released Under LGPL - original licence link has changed is not relivant.
15564 * <script type="text/javascript">
15569 * @extends Roo.util.Observable
15570 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15571 * This class also supports single and multi selection modes. <br>
15572 * Create a data model bound view:
15574 var store = new Roo.data.Store(...);
15576 var view = new Roo.View({
15578 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15580 singleSelect: true,
15581 selectedClass: "ydataview-selected",
15585 // listen for node click?
15586 view.on("click", function(vw, index, node, e){
15587 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15591 dataModel.load("foobar.xml");
15593 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15595 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15596 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15598 * Note: old style constructor is still suported (container, template, config)
15601 * Create a new View
15602 * @param {Object} config The config object
15605 Roo.View = function(config, depreciated_tpl, depreciated_config){
15607 this.parent = false;
15609 if (typeof(depreciated_tpl) == 'undefined') {
15610 // new way.. - universal constructor.
15611 Roo.apply(this, config);
15612 this.el = Roo.get(this.el);
15615 this.el = Roo.get(config);
15616 this.tpl = depreciated_tpl;
15617 Roo.apply(this, depreciated_config);
15619 this.wrapEl = this.el.wrap().wrap();
15620 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15623 if(typeof(this.tpl) == "string"){
15624 this.tpl = new Roo.Template(this.tpl);
15626 // support xtype ctors..
15627 this.tpl = new Roo.factory(this.tpl, Roo);
15631 this.tpl.compile();
15636 * @event beforeclick
15637 * Fires before a click is processed. Returns false to cancel the default action.
15638 * @param {Roo.View} this
15639 * @param {Number} index The index of the target node
15640 * @param {HTMLElement} node The target node
15641 * @param {Roo.EventObject} e The raw event object
15643 "beforeclick" : true,
15646 * Fires when a template node is clicked.
15647 * @param {Roo.View} this
15648 * @param {Number} index The index of the target node
15649 * @param {HTMLElement} node The target node
15650 * @param {Roo.EventObject} e The raw event object
15655 * Fires when a template node is double clicked.
15656 * @param {Roo.View} this
15657 * @param {Number} index The index of the target node
15658 * @param {HTMLElement} node The target node
15659 * @param {Roo.EventObject} e The raw event object
15663 * @event contextmenu
15664 * Fires when a template node is right clicked.
15665 * @param {Roo.View} this
15666 * @param {Number} index The index of the target node
15667 * @param {HTMLElement} node The target node
15668 * @param {Roo.EventObject} e The raw event object
15670 "contextmenu" : true,
15672 * @event selectionchange
15673 * Fires when the selected nodes change.
15674 * @param {Roo.View} this
15675 * @param {Array} selections Array of the selected nodes
15677 "selectionchange" : true,
15680 * @event beforeselect
15681 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15682 * @param {Roo.View} this
15683 * @param {HTMLElement} node The node to be selected
15684 * @param {Array} selections Array of currently selected nodes
15686 "beforeselect" : true,
15688 * @event preparedata
15689 * Fires on every row to render, to allow you to change the data.
15690 * @param {Roo.View} this
15691 * @param {Object} data to be rendered (change this)
15693 "preparedata" : true
15701 "click": this.onClick,
15702 "dblclick": this.onDblClick,
15703 "contextmenu": this.onContextMenu,
15707 this.selections = [];
15709 this.cmp = new Roo.CompositeElementLite([]);
15711 this.store = Roo.factory(this.store, Roo.data);
15712 this.setStore(this.store, true);
15715 if ( this.footer && this.footer.xtype) {
15717 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15719 this.footer.dataSource = this.store;
15720 this.footer.container = fctr;
15721 this.footer = Roo.factory(this.footer, Roo);
15722 fctr.insertFirst(this.el);
15724 // this is a bit insane - as the paging toolbar seems to detach the el..
15725 // dom.parentNode.parentNode.parentNode
15726 // they get detached?
15730 Roo.View.superclass.constructor.call(this);
15735 Roo.extend(Roo.View, Roo.util.Observable, {
15738 * @cfg {Roo.data.Store} store Data store to load data from.
15743 * @cfg {String|Roo.Element} el The container element.
15748 * @cfg {String|Roo.Template} tpl The template used by this View
15752 * @cfg {String} dataName the named area of the template to use as the data area
15753 * Works with domtemplates roo-name="name"
15757 * @cfg {String} selectedClass The css class to add to selected nodes
15759 selectedClass : "x-view-selected",
15761 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15766 * @cfg {String} text to display on mask (default Loading)
15770 * @cfg {Boolean} multiSelect Allow multiple selection
15772 multiSelect : false,
15774 * @cfg {Boolean} singleSelect Allow single selection
15776 singleSelect: false,
15779 * @cfg {Boolean} toggleSelect - selecting
15781 toggleSelect : false,
15784 * @cfg {Boolean} tickable - selecting
15789 * Returns the element this view is bound to.
15790 * @return {Roo.Element}
15792 getEl : function(){
15793 return this.wrapEl;
15799 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15801 refresh : function(){
15802 //Roo.log('refresh');
15805 // if we are using something like 'domtemplate', then
15806 // the what gets used is:
15807 // t.applySubtemplate(NAME, data, wrapping data..)
15808 // the outer template then get' applied with
15809 // the store 'extra data'
15810 // and the body get's added to the
15811 // roo-name="data" node?
15812 // <span class='roo-tpl-{name}'></span> ?????
15816 this.clearSelections();
15817 this.el.update("");
15819 var records = this.store.getRange();
15820 if(records.length < 1) {
15822 // is this valid?? = should it render a template??
15824 this.el.update(this.emptyText);
15828 if (this.dataName) {
15829 this.el.update(t.apply(this.store.meta)); //????
15830 el = this.el.child('.roo-tpl-' + this.dataName);
15833 for(var i = 0, len = records.length; i < len; i++){
15834 var data = this.prepareData(records[i].data, i, records[i]);
15835 this.fireEvent("preparedata", this, data, i, records[i]);
15837 var d = Roo.apply({}, data);
15840 Roo.apply(d, {'roo-id' : Roo.id()});
15844 Roo.each(this.parent.item, function(item){
15845 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15848 Roo.apply(d, {'roo-data-checked' : 'checked'});
15852 html[html.length] = Roo.util.Format.trim(
15854 t.applySubtemplate(this.dataName, d, this.store.meta) :
15861 el.update(html.join(""));
15862 this.nodes = el.dom.childNodes;
15863 this.updateIndexes(0);
15868 * Function to override to reformat the data that is sent to
15869 * the template for each node.
15870 * DEPRICATED - use the preparedata event handler.
15871 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15872 * a JSON object for an UpdateManager bound view).
15874 prepareData : function(data, index, record)
15876 this.fireEvent("preparedata", this, data, index, record);
15880 onUpdate : function(ds, record){
15881 // Roo.log('on update');
15882 this.clearSelections();
15883 var index = this.store.indexOf(record);
15884 var n = this.nodes[index];
15885 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15886 n.parentNode.removeChild(n);
15887 this.updateIndexes(index, index);
15893 onAdd : function(ds, records, index)
15895 //Roo.log(['on Add', ds, records, index] );
15896 this.clearSelections();
15897 if(this.nodes.length == 0){
15901 var n = this.nodes[index];
15902 for(var i = 0, len = records.length; i < len; i++){
15903 var d = this.prepareData(records[i].data, i, records[i]);
15905 this.tpl.insertBefore(n, d);
15908 this.tpl.append(this.el, d);
15911 this.updateIndexes(index);
15914 onRemove : function(ds, record, index){
15915 // Roo.log('onRemove');
15916 this.clearSelections();
15917 var el = this.dataName ?
15918 this.el.child('.roo-tpl-' + this.dataName) :
15921 el.dom.removeChild(this.nodes[index]);
15922 this.updateIndexes(index);
15926 * Refresh an individual node.
15927 * @param {Number} index
15929 refreshNode : function(index){
15930 this.onUpdate(this.store, this.store.getAt(index));
15933 updateIndexes : function(startIndex, endIndex){
15934 var ns = this.nodes;
15935 startIndex = startIndex || 0;
15936 endIndex = endIndex || ns.length - 1;
15937 for(var i = startIndex; i <= endIndex; i++){
15938 ns[i].nodeIndex = i;
15943 * Changes the data store this view uses and refresh the view.
15944 * @param {Store} store
15946 setStore : function(store, initial){
15947 if(!initial && this.store){
15948 this.store.un("datachanged", this.refresh);
15949 this.store.un("add", this.onAdd);
15950 this.store.un("remove", this.onRemove);
15951 this.store.un("update", this.onUpdate);
15952 this.store.un("clear", this.refresh);
15953 this.store.un("beforeload", this.onBeforeLoad);
15954 this.store.un("load", this.onLoad);
15955 this.store.un("loadexception", this.onLoad);
15959 store.on("datachanged", this.refresh, this);
15960 store.on("add", this.onAdd, this);
15961 store.on("remove", this.onRemove, this);
15962 store.on("update", this.onUpdate, this);
15963 store.on("clear", this.refresh, this);
15964 store.on("beforeload", this.onBeforeLoad, this);
15965 store.on("load", this.onLoad, this);
15966 store.on("loadexception", this.onLoad, this);
15974 * onbeforeLoad - masks the loading area.
15977 onBeforeLoad : function(store,opts)
15979 //Roo.log('onBeforeLoad');
15981 this.el.update("");
15983 this.el.mask(this.mask ? this.mask : "Loading" );
15985 onLoad : function ()
15992 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15993 * @param {HTMLElement} node
15994 * @return {HTMLElement} The template node
15996 findItemFromChild : function(node){
15997 var el = this.dataName ?
15998 this.el.child('.roo-tpl-' + this.dataName,true) :
16001 if(!node || node.parentNode == el){
16004 var p = node.parentNode;
16005 while(p && p != el){
16006 if(p.parentNode == el){
16015 onClick : function(e){
16016 var item = this.findItemFromChild(e.getTarget());
16018 var index = this.indexOf(item);
16019 if(this.onItemClick(item, index, e) !== false){
16020 this.fireEvent("click", this, index, item, e);
16023 this.clearSelections();
16028 onContextMenu : function(e){
16029 var item = this.findItemFromChild(e.getTarget());
16031 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16036 onDblClick : function(e){
16037 var item = this.findItemFromChild(e.getTarget());
16039 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16043 onItemClick : function(item, index, e)
16045 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16048 if (this.toggleSelect) {
16049 var m = this.isSelected(item) ? 'unselect' : 'select';
16052 _t[m](item, true, false);
16055 if(this.multiSelect || this.singleSelect){
16056 if(this.multiSelect && e.shiftKey && this.lastSelection){
16057 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16059 this.select(item, this.multiSelect && e.ctrlKey);
16060 this.lastSelection = item;
16063 if(!this.tickable){
16064 e.preventDefault();
16072 * Get the number of selected nodes.
16075 getSelectionCount : function(){
16076 return this.selections.length;
16080 * Get the currently selected nodes.
16081 * @return {Array} An array of HTMLElements
16083 getSelectedNodes : function(){
16084 return this.selections;
16088 * Get the indexes of the selected nodes.
16091 getSelectedIndexes : function(){
16092 var indexes = [], s = this.selections;
16093 for(var i = 0, len = s.length; i < len; i++){
16094 indexes.push(s[i].nodeIndex);
16100 * Clear all selections
16101 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16103 clearSelections : function(suppressEvent){
16104 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16105 this.cmp.elements = this.selections;
16106 this.cmp.removeClass(this.selectedClass);
16107 this.selections = [];
16108 if(!suppressEvent){
16109 this.fireEvent("selectionchange", this, this.selections);
16115 * Returns true if the passed node is selected
16116 * @param {HTMLElement/Number} node The node or node index
16117 * @return {Boolean}
16119 isSelected : function(node){
16120 var s = this.selections;
16124 node = this.getNode(node);
16125 return s.indexOf(node) !== -1;
16130 * @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
16131 * @param {Boolean} keepExisting (optional) true to keep existing selections
16132 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16134 select : function(nodeInfo, keepExisting, suppressEvent){
16135 if(nodeInfo instanceof Array){
16137 this.clearSelections(true);
16139 for(var i = 0, len = nodeInfo.length; i < len; i++){
16140 this.select(nodeInfo[i], true, true);
16144 var node = this.getNode(nodeInfo);
16145 if(!node || this.isSelected(node)){
16146 return; // already selected.
16149 this.clearSelections(true);
16152 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16153 Roo.fly(node).addClass(this.selectedClass);
16154 this.selections.push(node);
16155 if(!suppressEvent){
16156 this.fireEvent("selectionchange", this, this.selections);
16164 * @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
16165 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16166 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16168 unselect : function(nodeInfo, keepExisting, suppressEvent)
16170 if(nodeInfo instanceof Array){
16171 Roo.each(this.selections, function(s) {
16172 this.unselect(s, nodeInfo);
16176 var node = this.getNode(nodeInfo);
16177 if(!node || !this.isSelected(node)){
16178 //Roo.log("not selected");
16179 return; // not selected.
16183 Roo.each(this.selections, function(s) {
16185 Roo.fly(node).removeClass(this.selectedClass);
16192 this.selections= ns;
16193 this.fireEvent("selectionchange", this, this.selections);
16197 * Gets a template node.
16198 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16199 * @return {HTMLElement} The node or null if it wasn't found
16201 getNode : function(nodeInfo){
16202 if(typeof nodeInfo == "string"){
16203 return document.getElementById(nodeInfo);
16204 }else if(typeof nodeInfo == "number"){
16205 return this.nodes[nodeInfo];
16211 * Gets a range template nodes.
16212 * @param {Number} startIndex
16213 * @param {Number} endIndex
16214 * @return {Array} An array of nodes
16216 getNodes : function(start, end){
16217 var ns = this.nodes;
16218 start = start || 0;
16219 end = typeof end == "undefined" ? ns.length - 1 : end;
16222 for(var i = start; i <= end; i++){
16226 for(var i = start; i >= end; i--){
16234 * Finds the index of the passed node
16235 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16236 * @return {Number} The index of the node or -1
16238 indexOf : function(node){
16239 node = this.getNode(node);
16240 if(typeof node.nodeIndex == "number"){
16241 return node.nodeIndex;
16243 var ns = this.nodes;
16244 for(var i = 0, len = ns.length; i < len; i++){
16255 * based on jquery fullcalendar
16259 Roo.bootstrap = Roo.bootstrap || {};
16261 * @class Roo.bootstrap.Calendar
16262 * @extends Roo.bootstrap.Component
16263 * Bootstrap Calendar class
16264 * @cfg {Boolean} loadMask (true|false) default false
16265 * @cfg {Object} header generate the user specific header of the calendar, default false
16268 * Create a new Container
16269 * @param {Object} config The config object
16274 Roo.bootstrap.Calendar = function(config){
16275 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16279 * Fires when a date is selected
16280 * @param {DatePicker} this
16281 * @param {Date} date The selected date
16285 * @event monthchange
16286 * Fires when the displayed month changes
16287 * @param {DatePicker} this
16288 * @param {Date} date The selected month
16290 'monthchange': true,
16292 * @event evententer
16293 * Fires when mouse over an event
16294 * @param {Calendar} this
16295 * @param {event} Event
16297 'evententer': true,
16299 * @event eventleave
16300 * Fires when the mouse leaves an
16301 * @param {Calendar} this
16304 'eventleave': true,
16306 * @event eventclick
16307 * Fires when the mouse click an
16308 * @param {Calendar} this
16317 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16320 * @cfg {Number} startDay
16321 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16329 getAutoCreate : function(){
16332 var fc_button = function(name, corner, style, content ) {
16333 return Roo.apply({},{
16335 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16337 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16340 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16351 style : 'width:100%',
16358 cls : 'fc-header-left',
16360 fc_button('prev', 'left', 'arrow', '‹' ),
16361 fc_button('next', 'right', 'arrow', '›' ),
16362 { tag: 'span', cls: 'fc-header-space' },
16363 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16371 cls : 'fc-header-center',
16375 cls: 'fc-header-title',
16378 html : 'month / year'
16386 cls : 'fc-header-right',
16388 /* fc_button('month', 'left', '', 'month' ),
16389 fc_button('week', '', '', 'week' ),
16390 fc_button('day', 'right', '', 'day' )
16402 header = this.header;
16405 var cal_heads = function() {
16407 // fixme - handle this.
16409 for (var i =0; i < Date.dayNames.length; i++) {
16410 var d = Date.dayNames[i];
16413 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16414 html : d.substring(0,3)
16418 ret[0].cls += ' fc-first';
16419 ret[6].cls += ' fc-last';
16422 var cal_cell = function(n) {
16425 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16430 cls: 'fc-day-number',
16434 cls: 'fc-day-content',
16438 style: 'position: relative;' // height: 17px;
16450 var cal_rows = function() {
16453 for (var r = 0; r < 6; r++) {
16460 for (var i =0; i < Date.dayNames.length; i++) {
16461 var d = Date.dayNames[i];
16462 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16465 row.cn[0].cls+=' fc-first';
16466 row.cn[0].cn[0].style = 'min-height:90px';
16467 row.cn[6].cls+=' fc-last';
16471 ret[0].cls += ' fc-first';
16472 ret[4].cls += ' fc-prev-last';
16473 ret[5].cls += ' fc-last';
16480 cls: 'fc-border-separate',
16481 style : 'width:100%',
16489 cls : 'fc-first fc-last',
16507 cls : 'fc-content',
16508 style : "position: relative;",
16511 cls : 'fc-view fc-view-month fc-grid',
16512 style : 'position: relative',
16513 unselectable : 'on',
16516 cls : 'fc-event-container',
16517 style : 'position:absolute;z-index:8;top:0;left:0;'
16535 initEvents : function()
16538 throw "can not find store for calendar";
16544 style: "text-align:center",
16548 style: "background-color:white;width:50%;margin:250 auto",
16552 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16563 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16565 var size = this.el.select('.fc-content', true).first().getSize();
16566 this.maskEl.setSize(size.width, size.height);
16567 this.maskEl.enableDisplayMode("block");
16568 if(!this.loadMask){
16569 this.maskEl.hide();
16572 this.store = Roo.factory(this.store, Roo.data);
16573 this.store.on('load', this.onLoad, this);
16574 this.store.on('beforeload', this.onBeforeLoad, this);
16578 this.cells = this.el.select('.fc-day',true);
16579 //Roo.log(this.cells);
16580 this.textNodes = this.el.query('.fc-day-number');
16581 this.cells.addClassOnOver('fc-state-hover');
16583 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16584 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16585 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16586 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16588 this.on('monthchange', this.onMonthChange, this);
16590 this.update(new Date().clearTime());
16593 resize : function() {
16594 var sz = this.el.getSize();
16596 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16597 this.el.select('.fc-day-content div',true).setHeight(34);
16602 showPrevMonth : function(e){
16603 this.update(this.activeDate.add("mo", -1));
16605 showToday : function(e){
16606 this.update(new Date().clearTime());
16609 showNextMonth : function(e){
16610 this.update(this.activeDate.add("mo", 1));
16614 showPrevYear : function(){
16615 this.update(this.activeDate.add("y", -1));
16619 showNextYear : function(){
16620 this.update(this.activeDate.add("y", 1));
16625 update : function(date)
16627 var vd = this.activeDate;
16628 this.activeDate = date;
16629 // if(vd && this.el){
16630 // var t = date.getTime();
16631 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16632 // Roo.log('using add remove');
16634 // this.fireEvent('monthchange', this, date);
16636 // this.cells.removeClass("fc-state-highlight");
16637 // this.cells.each(function(c){
16638 // if(c.dateValue == t){
16639 // c.addClass("fc-state-highlight");
16640 // setTimeout(function(){
16641 // try{c.dom.firstChild.focus();}catch(e){}
16651 var days = date.getDaysInMonth();
16653 var firstOfMonth = date.getFirstDateOfMonth();
16654 var startingPos = firstOfMonth.getDay()-this.startDay;
16656 if(startingPos < this.startDay){
16660 var pm = date.add(Date.MONTH, -1);
16661 var prevStart = pm.getDaysInMonth()-startingPos;
16663 this.cells = this.el.select('.fc-day',true);
16664 this.textNodes = this.el.query('.fc-day-number');
16665 this.cells.addClassOnOver('fc-state-hover');
16667 var cells = this.cells.elements;
16668 var textEls = this.textNodes;
16670 Roo.each(cells, function(cell){
16671 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16674 days += startingPos;
16676 // convert everything to numbers so it's fast
16677 var day = 86400000;
16678 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16681 //Roo.log(prevStart);
16683 var today = new Date().clearTime().getTime();
16684 var sel = date.clearTime().getTime();
16685 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16686 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16687 var ddMatch = this.disabledDatesRE;
16688 var ddText = this.disabledDatesText;
16689 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16690 var ddaysText = this.disabledDaysText;
16691 var format = this.format;
16693 var setCellClass = function(cal, cell){
16697 //Roo.log('set Cell Class');
16699 var t = d.getTime();
16703 cell.dateValue = t;
16705 cell.className += " fc-today";
16706 cell.className += " fc-state-highlight";
16707 cell.title = cal.todayText;
16710 // disable highlight in other month..
16711 //cell.className += " fc-state-highlight";
16716 cell.className = " fc-state-disabled";
16717 cell.title = cal.minText;
16721 cell.className = " fc-state-disabled";
16722 cell.title = cal.maxText;
16726 if(ddays.indexOf(d.getDay()) != -1){
16727 cell.title = ddaysText;
16728 cell.className = " fc-state-disabled";
16731 if(ddMatch && format){
16732 var fvalue = d.dateFormat(format);
16733 if(ddMatch.test(fvalue)){
16734 cell.title = ddText.replace("%0", fvalue);
16735 cell.className = " fc-state-disabled";
16739 if (!cell.initialClassName) {
16740 cell.initialClassName = cell.dom.className;
16743 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16748 for(; i < startingPos; i++) {
16749 textEls[i].innerHTML = (++prevStart);
16750 d.setDate(d.getDate()+1);
16752 cells[i].className = "fc-past fc-other-month";
16753 setCellClass(this, cells[i]);
16758 for(; i < days; i++){
16759 intDay = i - startingPos + 1;
16760 textEls[i].innerHTML = (intDay);
16761 d.setDate(d.getDate()+1);
16763 cells[i].className = ''; // "x-date-active";
16764 setCellClass(this, cells[i]);
16768 for(; i < 42; i++) {
16769 textEls[i].innerHTML = (++extraDays);
16770 d.setDate(d.getDate()+1);
16772 cells[i].className = "fc-future fc-other-month";
16773 setCellClass(this, cells[i]);
16776 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16778 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16780 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16781 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16783 if(totalRows != 6){
16784 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16785 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16788 this.fireEvent('monthchange', this, date);
16792 if(!this.internalRender){
16793 var main = this.el.dom.firstChild;
16794 var w = main.offsetWidth;
16795 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16796 Roo.fly(main).setWidth(w);
16797 this.internalRender = true;
16798 // opera does not respect the auto grow header center column
16799 // then, after it gets a width opera refuses to recalculate
16800 // without a second pass
16801 if(Roo.isOpera && !this.secondPass){
16802 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16803 this.secondPass = true;
16804 this.update.defer(10, this, [date]);
16811 findCell : function(dt) {
16812 dt = dt.clearTime().getTime();
16814 this.cells.each(function(c){
16815 //Roo.log("check " +c.dateValue + '?=' + dt);
16816 if(c.dateValue == dt){
16826 findCells : function(ev) {
16827 var s = ev.start.clone().clearTime().getTime();
16829 var e= ev.end.clone().clearTime().getTime();
16832 this.cells.each(function(c){
16833 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16835 if(c.dateValue > e){
16838 if(c.dateValue < s){
16847 // findBestRow: function(cells)
16851 // for (var i =0 ; i < cells.length;i++) {
16852 // ret = Math.max(cells[i].rows || 0,ret);
16859 addItem : function(ev)
16861 // look for vertical location slot in
16862 var cells = this.findCells(ev);
16864 // ev.row = this.findBestRow(cells);
16866 // work out the location.
16870 for(var i =0; i < cells.length; i++) {
16872 cells[i].row = cells[0].row;
16875 cells[i].row = cells[i].row + 1;
16885 if (crow.start.getY() == cells[i].getY()) {
16887 crow.end = cells[i];
16904 cells[0].events.push(ev);
16906 this.calevents.push(ev);
16909 clearEvents: function() {
16911 if(!this.calevents){
16915 Roo.each(this.cells.elements, function(c){
16921 Roo.each(this.calevents, function(e) {
16922 Roo.each(e.els, function(el) {
16923 el.un('mouseenter' ,this.onEventEnter, this);
16924 el.un('mouseleave' ,this.onEventLeave, this);
16929 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16935 renderEvents: function()
16939 this.cells.each(function(c) {
16948 if(c.row != c.events.length){
16949 r = 4 - (4 - (c.row - c.events.length));
16952 c.events = ev.slice(0, r);
16953 c.more = ev.slice(r);
16955 if(c.more.length && c.more.length == 1){
16956 c.events.push(c.more.pop());
16959 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16963 this.cells.each(function(c) {
16965 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16968 for (var e = 0; e < c.events.length; e++){
16969 var ev = c.events[e];
16970 var rows = ev.rows;
16972 for(var i = 0; i < rows.length; i++) {
16974 // how many rows should it span..
16977 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16978 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16980 unselectable : "on",
16983 cls: 'fc-event-inner',
16987 // cls: 'fc-event-time',
16988 // html : cells.length > 1 ? '' : ev.time
16992 cls: 'fc-event-title',
16993 html : String.format('{0}', ev.title)
17000 cls: 'ui-resizable-handle ui-resizable-e',
17001 html : '  '
17008 cfg.cls += ' fc-event-start';
17010 if ((i+1) == rows.length) {
17011 cfg.cls += ' fc-event-end';
17014 var ctr = _this.el.select('.fc-event-container',true).first();
17015 var cg = ctr.createChild(cfg);
17017 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17018 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17020 var r = (c.more.length) ? 1 : 0;
17021 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17022 cg.setWidth(ebox.right - sbox.x -2);
17024 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17025 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17026 cg.on('click', _this.onEventClick, _this, ev);
17037 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17038 style : 'position: absolute',
17039 unselectable : "on",
17042 cls: 'fc-event-inner',
17046 cls: 'fc-event-title',
17054 cls: 'ui-resizable-handle ui-resizable-e',
17055 html : '  '
17061 var ctr = _this.el.select('.fc-event-container',true).first();
17062 var cg = ctr.createChild(cfg);
17064 var sbox = c.select('.fc-day-content',true).first().getBox();
17065 var ebox = c.select('.fc-day-content',true).first().getBox();
17067 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17068 cg.setWidth(ebox.right - sbox.x -2);
17070 cg.on('click', _this.onMoreEventClick, _this, c.more);
17080 onEventEnter: function (e, el,event,d) {
17081 this.fireEvent('evententer', this, el, event);
17084 onEventLeave: function (e, el,event,d) {
17085 this.fireEvent('eventleave', this, el, event);
17088 onEventClick: function (e, el,event,d) {
17089 this.fireEvent('eventclick', this, el, event);
17092 onMonthChange: function () {
17096 onMoreEventClick: function(e, el, more)
17100 this.calpopover.placement = 'right';
17101 this.calpopover.setTitle('More');
17103 this.calpopover.setContent('');
17105 var ctr = this.calpopover.el.select('.popover-content', true).first();
17107 Roo.each(more, function(m){
17109 cls : 'fc-event-hori fc-event-draggable',
17112 var cg = ctr.createChild(cfg);
17114 cg.on('click', _this.onEventClick, _this, m);
17117 this.calpopover.show(el);
17122 onLoad: function ()
17124 this.calevents = [];
17127 if(this.store.getCount() > 0){
17128 this.store.data.each(function(d){
17131 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17132 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17133 time : d.data.start_time,
17134 title : d.data.title,
17135 description : d.data.description,
17136 venue : d.data.venue
17141 this.renderEvents();
17143 if(this.calevents.length && this.loadMask){
17144 this.maskEl.hide();
17148 onBeforeLoad: function()
17150 this.clearEvents();
17152 this.maskEl.show();
17166 * @class Roo.bootstrap.Popover
17167 * @extends Roo.bootstrap.Component
17168 * Bootstrap Popover class
17169 * @cfg {String} html contents of the popover (or false to use children..)
17170 * @cfg {String} title of popover (or false to hide)
17171 * @cfg {String} placement how it is placed
17172 * @cfg {String} trigger click || hover (or false to trigger manually)
17173 * @cfg {String} over what (parent or false to trigger manually.)
17174 * @cfg {Number} delay - delay before showing
17177 * Create a new Popover
17178 * @param {Object} config The config object
17181 Roo.bootstrap.Popover = function(config){
17182 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17188 * After the popover show
17190 * @param {Roo.bootstrap.Popover} this
17195 * After the popover hide
17197 * @param {Roo.bootstrap.Popover} this
17203 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17205 title: 'Fill in a title',
17208 placement : 'right',
17209 trigger : 'hover', // hover
17215 can_build_overlaid : false,
17217 getChildContainer : function()
17219 return this.el.select('.popover-content',true).first();
17222 getAutoCreate : function(){
17225 cls : 'popover roo-dynamic',
17226 style: 'display:block',
17232 cls : 'popover-inner',
17236 cls: 'popover-title',
17240 cls : 'popover-content',
17251 setTitle: function(str)
17254 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17256 setContent: function(str)
17259 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17261 // as it get's added to the bottom of the page.
17262 onRender : function(ct, position)
17264 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17266 var cfg = Roo.apply({}, this.getAutoCreate());
17270 cfg.cls += ' ' + this.cls;
17273 cfg.style = this.style;
17275 //Roo.log("adding to ");
17276 this.el = Roo.get(document.body).createChild(cfg, position);
17277 // Roo.log(this.el);
17282 initEvents : function()
17284 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17285 this.el.enableDisplayMode('block');
17287 if (this.over === false) {
17290 if (this.triggers === false) {
17293 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17294 var triggers = this.trigger ? this.trigger.split(' ') : [];
17295 Roo.each(triggers, function(trigger) {
17297 if (trigger == 'click') {
17298 on_el.on('click', this.toggle, this);
17299 } else if (trigger != 'manual') {
17300 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17301 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17303 on_el.on(eventIn ,this.enter, this);
17304 on_el.on(eventOut, this.leave, this);
17315 toggle : function () {
17316 this.hoverState == 'in' ? this.leave() : this.enter();
17319 enter : function () {
17321 clearTimeout(this.timeout);
17323 this.hoverState = 'in';
17325 if (!this.delay || !this.delay.show) {
17330 this.timeout = setTimeout(function () {
17331 if (_t.hoverState == 'in') {
17334 }, this.delay.show)
17337 leave : function() {
17338 clearTimeout(this.timeout);
17340 this.hoverState = 'out';
17342 if (!this.delay || !this.delay.hide) {
17347 this.timeout = setTimeout(function () {
17348 if (_t.hoverState == 'out') {
17351 }, this.delay.hide)
17354 show : function (on_el)
17357 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17361 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17362 if (this.html !== false) {
17363 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17365 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17366 if (!this.title.length) {
17367 this.el.select('.popover-title',true).hide();
17370 var placement = typeof this.placement == 'function' ?
17371 this.placement.call(this, this.el, on_el) :
17374 var autoToken = /\s?auto?\s?/i;
17375 var autoPlace = autoToken.test(placement);
17377 placement = placement.replace(autoToken, '') || 'top';
17381 //this.el.setXY([0,0]);
17383 this.el.dom.style.display='block';
17384 this.el.addClass(placement);
17386 //this.el.appendTo(on_el);
17388 var p = this.getPosition();
17389 var box = this.el.getBox();
17394 var align = Roo.bootstrap.Popover.alignment[placement];
17397 this.el.alignTo(on_el, align[0],align[1]);
17398 //var arrow = this.el.select('.arrow',true).first();
17399 //arrow.set(align[2],
17401 this.el.addClass('in');
17404 if (this.el.hasClass('fade')) {
17408 this.hoverState = 'in';
17410 this.fireEvent('show', this);
17415 this.el.setXY([0,0]);
17416 this.el.removeClass('in');
17418 this.hoverState = null;
17420 this.fireEvent('hide', this);
17425 Roo.bootstrap.Popover.alignment = {
17426 'left' : ['r-l', [-10,0], 'right'],
17427 'right' : ['l-r', [10,0], 'left'],
17428 'bottom' : ['t-b', [0,10], 'top'],
17429 'top' : [ 'b-t', [0,-10], 'bottom']
17440 * @class Roo.bootstrap.Progress
17441 * @extends Roo.bootstrap.Component
17442 * Bootstrap Progress class
17443 * @cfg {Boolean} striped striped of the progress bar
17444 * @cfg {Boolean} active animated of the progress bar
17448 * Create a new Progress
17449 * @param {Object} config The config object
17452 Roo.bootstrap.Progress = function(config){
17453 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17456 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17461 getAutoCreate : function(){
17469 cfg.cls += ' progress-striped';
17473 cfg.cls += ' active';
17492 * @class Roo.bootstrap.ProgressBar
17493 * @extends Roo.bootstrap.Component
17494 * Bootstrap ProgressBar class
17495 * @cfg {Number} aria_valuenow aria-value now
17496 * @cfg {Number} aria_valuemin aria-value min
17497 * @cfg {Number} aria_valuemax aria-value max
17498 * @cfg {String} label label for the progress bar
17499 * @cfg {String} panel (success | info | warning | danger )
17500 * @cfg {String} role role of the progress bar
17501 * @cfg {String} sr_only text
17505 * Create a new ProgressBar
17506 * @param {Object} config The config object
17509 Roo.bootstrap.ProgressBar = function(config){
17510 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17513 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17517 aria_valuemax : 100,
17523 getAutoCreate : function()
17528 cls: 'progress-bar',
17529 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17541 cfg.role = this.role;
17544 if(this.aria_valuenow){
17545 cfg['aria-valuenow'] = this.aria_valuenow;
17548 if(this.aria_valuemin){
17549 cfg['aria-valuemin'] = this.aria_valuemin;
17552 if(this.aria_valuemax){
17553 cfg['aria-valuemax'] = this.aria_valuemax;
17556 if(this.label && !this.sr_only){
17557 cfg.html = this.label;
17561 cfg.cls += ' progress-bar-' + this.panel;
17567 update : function(aria_valuenow)
17569 this.aria_valuenow = aria_valuenow;
17571 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17586 * @class Roo.bootstrap.TabGroup
17587 * @extends Roo.bootstrap.Column
17588 * Bootstrap Column class
17589 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17590 * @cfg {Boolean} carousel true to make the group behave like a carousel
17591 * @cfg {Boolean} bullets show bullets for the panels
17592 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17593 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17594 * @cfg {Boolean} showarrow (true|false) show arrow default true
17597 * Create a new TabGroup
17598 * @param {Object} config The config object
17601 Roo.bootstrap.TabGroup = function(config){
17602 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17604 this.navId = Roo.id();
17607 Roo.bootstrap.TabGroup.register(this);
17611 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17614 transition : false,
17619 slideOnTouch : false,
17622 getAutoCreate : function()
17624 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17626 cfg.cls += ' tab-content';
17628 if (this.carousel) {
17629 cfg.cls += ' carousel slide';
17632 cls : 'carousel-inner',
17636 if(this.bullets && !Roo.isTouch){
17639 cls : 'carousel-bullets',
17643 if(this.bullets_cls){
17644 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17651 cfg.cn[0].cn.push(bullets);
17654 if(this.showarrow){
17655 cfg.cn[0].cn.push({
17657 class : 'carousel-arrow',
17661 class : 'carousel-prev',
17665 class : 'fa fa-chevron-left'
17671 class : 'carousel-next',
17675 class : 'fa fa-chevron-right'
17688 initEvents: function()
17690 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17691 // this.el.on("touchstart", this.onTouchStart, this);
17694 if(this.autoslide){
17697 this.slideFn = window.setInterval(function() {
17698 _this.showPanelNext();
17702 if(this.showarrow){
17703 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17704 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17710 // onTouchStart : function(e, el, o)
17712 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17716 // this.showPanelNext();
17720 getChildContainer : function()
17722 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17726 * register a Navigation item
17727 * @param {Roo.bootstrap.NavItem} the navitem to add
17729 register : function(item)
17731 this.tabs.push( item);
17732 item.navId = this.navId; // not really needed..
17737 getActivePanel : function()
17740 Roo.each(this.tabs, function(t) {
17750 getPanelByName : function(n)
17753 Roo.each(this.tabs, function(t) {
17754 if (t.tabId == n) {
17762 indexOfPanel : function(p)
17765 Roo.each(this.tabs, function(t,i) {
17766 if (t.tabId == p.tabId) {
17775 * show a specific panel
17776 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17777 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17779 showPanel : function (pan)
17781 if(this.transition || typeof(pan) == 'undefined'){
17782 Roo.log("waiting for the transitionend");
17786 if (typeof(pan) == 'number') {
17787 pan = this.tabs[pan];
17790 if (typeof(pan) == 'string') {
17791 pan = this.getPanelByName(pan);
17794 var cur = this.getActivePanel();
17797 Roo.log('pan or acitve pan is undefined');
17801 if (pan.tabId == this.getActivePanel().tabId) {
17805 if (false === cur.fireEvent('beforedeactivate')) {
17809 if(this.bullets > 0 && !Roo.isTouch){
17810 this.setActiveBullet(this.indexOfPanel(pan));
17813 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17815 this.transition = true;
17816 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17817 var lr = dir == 'next' ? 'left' : 'right';
17818 pan.el.addClass(dir); // or prev
17819 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17820 cur.el.addClass(lr); // or right
17821 pan.el.addClass(lr);
17824 cur.el.on('transitionend', function() {
17825 Roo.log("trans end?");
17827 pan.el.removeClass([lr,dir]);
17828 pan.setActive(true);
17830 cur.el.removeClass([lr]);
17831 cur.setActive(false);
17833 _this.transition = false;
17835 }, this, { single: true } );
17840 cur.setActive(false);
17841 pan.setActive(true);
17846 showPanelNext : function()
17848 var i = this.indexOfPanel(this.getActivePanel());
17850 if (i >= this.tabs.length - 1 && !this.autoslide) {
17854 if (i >= this.tabs.length - 1 && this.autoslide) {
17858 this.showPanel(this.tabs[i+1]);
17861 showPanelPrev : function()
17863 var i = this.indexOfPanel(this.getActivePanel());
17865 if (i < 1 && !this.autoslide) {
17869 if (i < 1 && this.autoslide) {
17870 i = this.tabs.length;
17873 this.showPanel(this.tabs[i-1]);
17877 addBullet: function()
17879 if(!this.bullets || Roo.isTouch){
17882 var ctr = this.el.select('.carousel-bullets',true).first();
17883 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17884 var bullet = ctr.createChild({
17885 cls : 'bullet bullet-' + i
17886 },ctr.dom.lastChild);
17891 bullet.on('click', (function(e, el, o, ii, t){
17893 e.preventDefault();
17895 this.showPanel(ii);
17897 if(this.autoslide && this.slideFn){
17898 clearInterval(this.slideFn);
17899 this.slideFn = window.setInterval(function() {
17900 _this.showPanelNext();
17904 }).createDelegate(this, [i, bullet], true));
17909 setActiveBullet : function(i)
17915 Roo.each(this.el.select('.bullet', true).elements, function(el){
17916 el.removeClass('selected');
17919 var bullet = this.el.select('.bullet-' + i, true).first();
17925 bullet.addClass('selected');
17936 Roo.apply(Roo.bootstrap.TabGroup, {
17940 * register a Navigation Group
17941 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17943 register : function(navgrp)
17945 this.groups[navgrp.navId] = navgrp;
17949 * fetch a Navigation Group based on the navigation ID
17950 * if one does not exist , it will get created.
17951 * @param {string} the navgroup to add
17952 * @returns {Roo.bootstrap.NavGroup} the navgroup
17954 get: function(navId) {
17955 if (typeof(this.groups[navId]) == 'undefined') {
17956 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17958 return this.groups[navId] ;
17973 * @class Roo.bootstrap.TabPanel
17974 * @extends Roo.bootstrap.Component
17975 * Bootstrap TabPanel class
17976 * @cfg {Boolean} active panel active
17977 * @cfg {String} html panel content
17978 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17979 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17980 * @cfg {String} href click to link..
17984 * Create a new TabPanel
17985 * @param {Object} config The config object
17988 Roo.bootstrap.TabPanel = function(config){
17989 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17993 * Fires when the active status changes
17994 * @param {Roo.bootstrap.TabPanel} this
17995 * @param {Boolean} state the new state
18000 * @event beforedeactivate
18001 * Fires before a tab is de-activated - can be used to do validation on a form.
18002 * @param {Roo.bootstrap.TabPanel} this
18003 * @return {Boolean} false if there is an error
18006 'beforedeactivate': true
18009 this.tabId = this.tabId || Roo.id();
18013 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18021 getAutoCreate : function(){
18024 // item is needed for carousel - not sure if it has any effect otherwise
18025 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18026 html: this.html || ''
18030 cfg.cls += ' active';
18034 cfg.tabId = this.tabId;
18041 initEvents: function()
18043 var p = this.parent();
18045 this.navId = this.navId || p.navId;
18047 if (typeof(this.navId) != 'undefined') {
18048 // not really needed.. but just in case.. parent should be a NavGroup.
18049 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18053 var i = tg.tabs.length - 1;
18055 if(this.active && tg.bullets > 0 && i < tg.bullets){
18056 tg.setActiveBullet(i);
18060 this.el.on('click', this.onClick, this);
18063 this.el.on("touchstart", this.onTouchStart, this);
18064 this.el.on("touchmove", this.onTouchMove, this);
18065 this.el.on("touchend", this.onTouchEnd, this);
18070 onRender : function(ct, position)
18072 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18075 setActive : function(state)
18077 Roo.log("panel - set active " + this.tabId + "=" + state);
18079 this.active = state;
18081 this.el.removeClass('active');
18083 } else if (!this.el.hasClass('active')) {
18084 this.el.addClass('active');
18087 this.fireEvent('changed', this, state);
18090 onClick : function(e)
18092 e.preventDefault();
18094 if(!this.href.length){
18098 window.location.href = this.href;
18107 onTouchStart : function(e)
18109 this.swiping = false;
18111 this.startX = e.browserEvent.touches[0].clientX;
18112 this.startY = e.browserEvent.touches[0].clientY;
18115 onTouchMove : function(e)
18117 this.swiping = true;
18119 this.endX = e.browserEvent.touches[0].clientX;
18120 this.endY = e.browserEvent.touches[0].clientY;
18123 onTouchEnd : function(e)
18130 var tabGroup = this.parent();
18132 if(this.endX > this.startX){ // swiping right
18133 tabGroup.showPanelPrev();
18137 if(this.startX > this.endX){ // swiping left
18138 tabGroup.showPanelNext();
18157 * @class Roo.bootstrap.DateField
18158 * @extends Roo.bootstrap.Input
18159 * Bootstrap DateField class
18160 * @cfg {Number} weekStart default 0
18161 * @cfg {String} viewMode default empty, (months|years)
18162 * @cfg {String} minViewMode default empty, (months|years)
18163 * @cfg {Number} startDate default -Infinity
18164 * @cfg {Number} endDate default Infinity
18165 * @cfg {Boolean} todayHighlight default false
18166 * @cfg {Boolean} todayBtn default false
18167 * @cfg {Boolean} calendarWeeks default false
18168 * @cfg {Object} daysOfWeekDisabled default empty
18169 * @cfg {Boolean} singleMode default false (true | false)
18171 * @cfg {Boolean} keyboardNavigation default true
18172 * @cfg {String} language default en
18175 * Create a new DateField
18176 * @param {Object} config The config object
18179 Roo.bootstrap.DateField = function(config){
18180 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18184 * Fires when this field show.
18185 * @param {Roo.bootstrap.DateField} this
18186 * @param {Mixed} date The date value
18191 * Fires when this field hide.
18192 * @param {Roo.bootstrap.DateField} this
18193 * @param {Mixed} date The date value
18198 * Fires when select a date.
18199 * @param {Roo.bootstrap.DateField} this
18200 * @param {Mixed} date The date value
18204 * @event beforeselect
18205 * Fires when before select a date.
18206 * @param {Roo.bootstrap.DateField} this
18207 * @param {Mixed} date The date value
18209 beforeselect : true
18213 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18216 * @cfg {String} format
18217 * The default date format string which can be overriden for localization support. The format must be
18218 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18222 * @cfg {String} altFormats
18223 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18224 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18226 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18234 todayHighlight : false,
18240 keyboardNavigation: true,
18242 calendarWeeks: false,
18244 startDate: -Infinity,
18248 daysOfWeekDisabled: [],
18252 singleMode : false,
18254 UTCDate: function()
18256 return new Date(Date.UTC.apply(Date, arguments));
18259 UTCToday: function()
18261 var today = new Date();
18262 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18265 getDate: function() {
18266 var d = this.getUTCDate();
18267 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18270 getUTCDate: function() {
18274 setDate: function(d) {
18275 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18278 setUTCDate: function(d) {
18280 this.setValue(this.formatDate(this.date));
18283 onRender: function(ct, position)
18286 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18288 this.language = this.language || 'en';
18289 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18290 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18292 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18293 this.format = this.format || 'm/d/y';
18294 this.isInline = false;
18295 this.isInput = true;
18296 this.component = this.el.select('.add-on', true).first() || false;
18297 this.component = (this.component && this.component.length === 0) ? false : this.component;
18298 this.hasInput = this.component && this.inputEl().length;
18300 if (typeof(this.minViewMode === 'string')) {
18301 switch (this.minViewMode) {
18303 this.minViewMode = 1;
18306 this.minViewMode = 2;
18309 this.minViewMode = 0;
18314 if (typeof(this.viewMode === 'string')) {
18315 switch (this.viewMode) {
18328 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18330 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18332 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18334 this.picker().on('mousedown', this.onMousedown, this);
18335 this.picker().on('click', this.onClick, this);
18337 this.picker().addClass('datepicker-dropdown');
18339 this.startViewMode = this.viewMode;
18341 if(this.singleMode){
18342 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18343 v.setVisibilityMode(Roo.Element.DISPLAY);
18347 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18348 v.setStyle('width', '189px');
18352 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18353 if(!this.calendarWeeks){
18358 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18359 v.attr('colspan', function(i, val){
18360 return parseInt(val) + 1;
18365 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18367 this.setStartDate(this.startDate);
18368 this.setEndDate(this.endDate);
18370 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18377 if(this.isInline) {
18382 picker : function()
18384 return this.pickerEl;
18385 // return this.el.select('.datepicker', true).first();
18388 fillDow: function()
18390 var dowCnt = this.weekStart;
18399 if(this.calendarWeeks){
18407 while (dowCnt < this.weekStart + 7) {
18411 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18415 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18418 fillMonths: function()
18421 var months = this.picker().select('>.datepicker-months td', true).first();
18423 months.dom.innerHTML = '';
18429 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18432 months.createChild(month);
18439 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;
18441 if (this.date < this.startDate) {
18442 this.viewDate = new Date(this.startDate);
18443 } else if (this.date > this.endDate) {
18444 this.viewDate = new Date(this.endDate);
18446 this.viewDate = new Date(this.date);
18454 var d = new Date(this.viewDate),
18455 year = d.getUTCFullYear(),
18456 month = d.getUTCMonth(),
18457 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18458 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18459 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18460 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18461 currentDate = this.date && this.date.valueOf(),
18462 today = this.UTCToday();
18464 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18466 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18468 // this.picker.select('>tfoot th.today').
18469 // .text(dates[this.language].today)
18470 // .toggle(this.todayBtn !== false);
18472 this.updateNavArrows();
18475 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18477 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18479 prevMonth.setUTCDate(day);
18481 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18483 var nextMonth = new Date(prevMonth);
18485 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18487 nextMonth = nextMonth.valueOf();
18489 var fillMonths = false;
18491 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18493 while(prevMonth.valueOf() < nextMonth) {
18496 if (prevMonth.getUTCDay() === this.weekStart) {
18498 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18506 if(this.calendarWeeks){
18507 // ISO 8601: First week contains first thursday.
18508 // ISO also states week starts on Monday, but we can be more abstract here.
18510 // Start of current week: based on weekstart/current date
18511 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18512 // Thursday of this week
18513 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18514 // First Thursday of year, year from thursday
18515 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18516 // Calendar week: ms between thursdays, div ms per day, div 7 days
18517 calWeek = (th - yth) / 864e5 / 7 + 1;
18519 fillMonths.cn.push({
18527 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18529 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18532 if (this.todayHighlight &&
18533 prevMonth.getUTCFullYear() == today.getFullYear() &&
18534 prevMonth.getUTCMonth() == today.getMonth() &&
18535 prevMonth.getUTCDate() == today.getDate()) {
18536 clsName += ' today';
18539 if (currentDate && prevMonth.valueOf() === currentDate) {
18540 clsName += ' active';
18543 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18544 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18545 clsName += ' disabled';
18548 fillMonths.cn.push({
18550 cls: 'day ' + clsName,
18551 html: prevMonth.getDate()
18554 prevMonth.setDate(prevMonth.getDate()+1);
18557 var currentYear = this.date && this.date.getUTCFullYear();
18558 var currentMonth = this.date && this.date.getUTCMonth();
18560 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18562 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18563 v.removeClass('active');
18565 if(currentYear === year && k === currentMonth){
18566 v.addClass('active');
18569 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18570 v.addClass('disabled');
18576 year = parseInt(year/10, 10) * 10;
18578 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18580 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18583 for (var i = -1; i < 11; i++) {
18584 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18586 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18594 showMode: function(dir)
18597 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18600 Roo.each(this.picker().select('>div',true).elements, function(v){
18601 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18604 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18609 if(this.isInline) {
18613 this.picker().removeClass(['bottom', 'top']);
18615 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18617 * place to the top of element!
18621 this.picker().addClass('top');
18622 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18627 this.picker().addClass('bottom');
18629 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18632 parseDate : function(value)
18634 if(!value || value instanceof Date){
18637 var v = Date.parseDate(value, this.format);
18638 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18639 v = Date.parseDate(value, 'Y-m-d');
18641 if(!v && this.altFormats){
18642 if(!this.altFormatsArray){
18643 this.altFormatsArray = this.altFormats.split("|");
18645 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18646 v = Date.parseDate(value, this.altFormatsArray[i]);
18652 formatDate : function(date, fmt)
18654 return (!date || !(date instanceof Date)) ?
18655 date : date.dateFormat(fmt || this.format);
18658 onFocus : function()
18660 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18664 onBlur : function()
18666 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18668 var d = this.inputEl().getValue();
18677 this.picker().show();
18681 this.fireEvent('show', this, this.date);
18686 if(this.isInline) {
18689 this.picker().hide();
18690 this.viewMode = this.startViewMode;
18693 this.fireEvent('hide', this, this.date);
18697 onMousedown: function(e)
18699 e.stopPropagation();
18700 e.preventDefault();
18705 Roo.bootstrap.DateField.superclass.keyup.call(this);
18709 setValue: function(v)
18711 if(this.fireEvent('beforeselect', this, v) !== false){
18712 var d = new Date(this.parseDate(v) ).clearTime();
18714 if(isNaN(d.getTime())){
18715 this.date = this.viewDate = '';
18716 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18720 v = this.formatDate(d);
18722 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18724 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18728 this.fireEvent('select', this, this.date);
18732 getValue: function()
18734 return this.formatDate(this.date);
18737 fireKey: function(e)
18739 if (!this.picker().isVisible()){
18740 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18746 var dateChanged = false,
18748 newDate, newViewDate;
18753 e.preventDefault();
18757 if (!this.keyboardNavigation) {
18760 dir = e.keyCode == 37 ? -1 : 1;
18763 newDate = this.moveYear(this.date, dir);
18764 newViewDate = this.moveYear(this.viewDate, dir);
18765 } else if (e.shiftKey){
18766 newDate = this.moveMonth(this.date, dir);
18767 newViewDate = this.moveMonth(this.viewDate, dir);
18769 newDate = new Date(this.date);
18770 newDate.setUTCDate(this.date.getUTCDate() + dir);
18771 newViewDate = new Date(this.viewDate);
18772 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18774 if (this.dateWithinRange(newDate)){
18775 this.date = newDate;
18776 this.viewDate = newViewDate;
18777 this.setValue(this.formatDate(this.date));
18779 e.preventDefault();
18780 dateChanged = true;
18785 if (!this.keyboardNavigation) {
18788 dir = e.keyCode == 38 ? -1 : 1;
18790 newDate = this.moveYear(this.date, dir);
18791 newViewDate = this.moveYear(this.viewDate, dir);
18792 } else if (e.shiftKey){
18793 newDate = this.moveMonth(this.date, dir);
18794 newViewDate = this.moveMonth(this.viewDate, dir);
18796 newDate = new Date(this.date);
18797 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18798 newViewDate = new Date(this.viewDate);
18799 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18801 if (this.dateWithinRange(newDate)){
18802 this.date = newDate;
18803 this.viewDate = newViewDate;
18804 this.setValue(this.formatDate(this.date));
18806 e.preventDefault();
18807 dateChanged = true;
18811 this.setValue(this.formatDate(this.date));
18813 e.preventDefault();
18816 this.setValue(this.formatDate(this.date));
18830 onClick: function(e)
18832 e.stopPropagation();
18833 e.preventDefault();
18835 var target = e.getTarget();
18837 if(target.nodeName.toLowerCase() === 'i'){
18838 target = Roo.get(target).dom.parentNode;
18841 var nodeName = target.nodeName;
18842 var className = target.className;
18843 var html = target.innerHTML;
18844 //Roo.log(nodeName);
18846 switch(nodeName.toLowerCase()) {
18848 switch(className) {
18854 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18855 switch(this.viewMode){
18857 this.viewDate = this.moveMonth(this.viewDate, dir);
18861 this.viewDate = this.moveYear(this.viewDate, dir);
18867 var date = new Date();
18868 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18870 this.setValue(this.formatDate(this.date));
18877 if (className.indexOf('disabled') < 0) {
18878 this.viewDate.setUTCDate(1);
18879 if (className.indexOf('month') > -1) {
18880 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18882 var year = parseInt(html, 10) || 0;
18883 this.viewDate.setUTCFullYear(year);
18887 if(this.singleMode){
18888 this.setValue(this.formatDate(this.viewDate));
18899 //Roo.log(className);
18900 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18901 var day = parseInt(html, 10) || 1;
18902 var year = this.viewDate.getUTCFullYear(),
18903 month = this.viewDate.getUTCMonth();
18905 if (className.indexOf('old') > -1) {
18912 } else if (className.indexOf('new') > -1) {
18920 //Roo.log([year,month,day]);
18921 this.date = this.UTCDate(year, month, day,0,0,0,0);
18922 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18924 //Roo.log(this.formatDate(this.date));
18925 this.setValue(this.formatDate(this.date));
18932 setStartDate: function(startDate)
18934 this.startDate = startDate || -Infinity;
18935 if (this.startDate !== -Infinity) {
18936 this.startDate = this.parseDate(this.startDate);
18939 this.updateNavArrows();
18942 setEndDate: function(endDate)
18944 this.endDate = endDate || Infinity;
18945 if (this.endDate !== Infinity) {
18946 this.endDate = this.parseDate(this.endDate);
18949 this.updateNavArrows();
18952 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18954 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18955 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18956 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18958 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18959 return parseInt(d, 10);
18962 this.updateNavArrows();
18965 updateNavArrows: function()
18967 if(this.singleMode){
18971 var d = new Date(this.viewDate),
18972 year = d.getUTCFullYear(),
18973 month = d.getUTCMonth();
18975 Roo.each(this.picker().select('.prev', true).elements, function(v){
18977 switch (this.viewMode) {
18980 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18986 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18993 Roo.each(this.picker().select('.next', true).elements, function(v){
18995 switch (this.viewMode) {
18998 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19004 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19012 moveMonth: function(date, dir)
19017 var new_date = new Date(date.valueOf()),
19018 day = new_date.getUTCDate(),
19019 month = new_date.getUTCMonth(),
19020 mag = Math.abs(dir),
19022 dir = dir > 0 ? 1 : -1;
19025 // If going back one month, make sure month is not current month
19026 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19028 return new_date.getUTCMonth() == month;
19030 // If going forward one month, make sure month is as expected
19031 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19033 return new_date.getUTCMonth() != new_month;
19035 new_month = month + dir;
19036 new_date.setUTCMonth(new_month);
19037 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19038 if (new_month < 0 || new_month > 11) {
19039 new_month = (new_month + 12) % 12;
19042 // For magnitudes >1, move one month at a time...
19043 for (var i=0; i<mag; i++) {
19044 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19045 new_date = this.moveMonth(new_date, dir);
19047 // ...then reset the day, keeping it in the new month
19048 new_month = new_date.getUTCMonth();
19049 new_date.setUTCDate(day);
19051 return new_month != new_date.getUTCMonth();
19054 // Common date-resetting loop -- if date is beyond end of month, make it
19057 new_date.setUTCDate(--day);
19058 new_date.setUTCMonth(new_month);
19063 moveYear: function(date, dir)
19065 return this.moveMonth(date, dir*12);
19068 dateWithinRange: function(date)
19070 return date >= this.startDate && date <= this.endDate;
19076 this.picker().remove();
19079 validateValue : function(value)
19081 if(value.length < 1) {
19082 if(this.allowBlank){
19088 if(value.length < this.minLength){
19091 if(value.length > this.maxLength){
19095 var vt = Roo.form.VTypes;
19096 if(!vt[this.vtype](value, this)){
19100 if(typeof this.validator == "function"){
19101 var msg = this.validator(value);
19107 if(this.regex && !this.regex.test(value)){
19111 if(typeof(this.parseDate(value)) == 'undefined'){
19115 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19119 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19129 Roo.apply(Roo.bootstrap.DateField, {
19140 html: '<i class="fa fa-arrow-left"/>'
19150 html: '<i class="fa fa-arrow-right"/>'
19192 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19193 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19194 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19195 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19196 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19209 navFnc: 'FullYear',
19214 navFnc: 'FullYear',
19219 Roo.apply(Roo.bootstrap.DateField, {
19223 cls: 'datepicker dropdown-menu roo-dynamic',
19227 cls: 'datepicker-days',
19231 cls: 'table-condensed',
19233 Roo.bootstrap.DateField.head,
19237 Roo.bootstrap.DateField.footer
19244 cls: 'datepicker-months',
19248 cls: 'table-condensed',
19250 Roo.bootstrap.DateField.head,
19251 Roo.bootstrap.DateField.content,
19252 Roo.bootstrap.DateField.footer
19259 cls: 'datepicker-years',
19263 cls: 'table-condensed',
19265 Roo.bootstrap.DateField.head,
19266 Roo.bootstrap.DateField.content,
19267 Roo.bootstrap.DateField.footer
19286 * @class Roo.bootstrap.TimeField
19287 * @extends Roo.bootstrap.Input
19288 * Bootstrap DateField class
19292 * Create a new TimeField
19293 * @param {Object} config The config object
19296 Roo.bootstrap.TimeField = function(config){
19297 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19301 * Fires when this field show.
19302 * @param {Roo.bootstrap.DateField} thisthis
19303 * @param {Mixed} date The date value
19308 * Fires when this field hide.
19309 * @param {Roo.bootstrap.DateField} this
19310 * @param {Mixed} date The date value
19315 * Fires when select a date.
19316 * @param {Roo.bootstrap.DateField} this
19317 * @param {Mixed} date The date value
19323 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19326 * @cfg {String} format
19327 * The default time format string which can be overriden for localization support. The format must be
19328 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19332 onRender: function(ct, position)
19335 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19337 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19339 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19341 this.pop = this.picker().select('>.datepicker-time',true).first();
19342 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19344 this.picker().on('mousedown', this.onMousedown, this);
19345 this.picker().on('click', this.onClick, this);
19347 this.picker().addClass('datepicker-dropdown');
19352 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19353 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19354 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19355 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19356 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19357 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19361 fireKey: function(e){
19362 if (!this.picker().isVisible()){
19363 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19369 e.preventDefault();
19377 this.onTogglePeriod();
19380 this.onIncrementMinutes();
19383 this.onDecrementMinutes();
19392 onClick: function(e) {
19393 e.stopPropagation();
19394 e.preventDefault();
19397 picker : function()
19399 return this.el.select('.datepicker', true).first();
19402 fillTime: function()
19404 var time = this.pop.select('tbody', true).first();
19406 time.dom.innerHTML = '';
19421 cls: 'hours-up glyphicon glyphicon-chevron-up'
19441 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19462 cls: 'timepicker-hour',
19477 cls: 'timepicker-minute',
19492 cls: 'btn btn-primary period',
19514 cls: 'hours-down glyphicon glyphicon-chevron-down'
19534 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19552 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19559 var hours = this.time.getHours();
19560 var minutes = this.time.getMinutes();
19573 hours = hours - 12;
19577 hours = '0' + hours;
19581 minutes = '0' + minutes;
19584 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19585 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19586 this.pop.select('button', true).first().dom.innerHTML = period;
19592 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19594 var cls = ['bottom'];
19596 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19603 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19608 this.picker().addClass(cls.join('-'));
19612 Roo.each(cls, function(c){
19614 _this.picker().setTop(_this.inputEl().getHeight());
19618 _this.picker().setTop(0 - _this.picker().getHeight());
19623 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19627 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19634 onFocus : function()
19636 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19640 onBlur : function()
19642 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19648 this.picker().show();
19653 this.fireEvent('show', this, this.date);
19658 this.picker().hide();
19661 this.fireEvent('hide', this, this.date);
19664 setTime : function()
19667 this.setValue(this.time.format(this.format));
19669 this.fireEvent('select', this, this.date);
19674 onMousedown: function(e){
19675 e.stopPropagation();
19676 e.preventDefault();
19679 onIncrementHours: function()
19681 Roo.log('onIncrementHours');
19682 this.time = this.time.add(Date.HOUR, 1);
19687 onDecrementHours: function()
19689 Roo.log('onDecrementHours');
19690 this.time = this.time.add(Date.HOUR, -1);
19694 onIncrementMinutes: function()
19696 Roo.log('onIncrementMinutes');
19697 this.time = this.time.add(Date.MINUTE, 1);
19701 onDecrementMinutes: function()
19703 Roo.log('onDecrementMinutes');
19704 this.time = this.time.add(Date.MINUTE, -1);
19708 onTogglePeriod: function()
19710 Roo.log('onTogglePeriod');
19711 this.time = this.time.add(Date.HOUR, 12);
19718 Roo.apply(Roo.bootstrap.TimeField, {
19748 cls: 'btn btn-info ok',
19760 Roo.apply(Roo.bootstrap.TimeField, {
19764 cls: 'datepicker dropdown-menu',
19768 cls: 'datepicker-time',
19772 cls: 'table-condensed',
19774 Roo.bootstrap.TimeField.content,
19775 Roo.bootstrap.TimeField.footer
19794 * @class Roo.bootstrap.MonthField
19795 * @extends Roo.bootstrap.Input
19796 * Bootstrap MonthField class
19798 * @cfg {String} language default en
19801 * Create a new MonthField
19802 * @param {Object} config The config object
19805 Roo.bootstrap.MonthField = function(config){
19806 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19811 * Fires when this field show.
19812 * @param {Roo.bootstrap.MonthField} this
19813 * @param {Mixed} date The date value
19818 * Fires when this field hide.
19819 * @param {Roo.bootstrap.MonthField} this
19820 * @param {Mixed} date The date value
19825 * Fires when select a date.
19826 * @param {Roo.bootstrap.MonthField} this
19827 * @param {String} oldvalue The old value
19828 * @param {String} newvalue The new value
19834 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19836 onRender: function(ct, position)
19839 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19841 this.language = this.language || 'en';
19842 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19843 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19845 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19846 this.isInline = false;
19847 this.isInput = true;
19848 this.component = this.el.select('.add-on', true).first() || false;
19849 this.component = (this.component && this.component.length === 0) ? false : this.component;
19850 this.hasInput = this.component && this.inputEL().length;
19852 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19854 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19856 this.picker().on('mousedown', this.onMousedown, this);
19857 this.picker().on('click', this.onClick, this);
19859 this.picker().addClass('datepicker-dropdown');
19861 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19862 v.setStyle('width', '189px');
19869 if(this.isInline) {
19875 setValue: function(v, suppressEvent)
19877 var o = this.getValue();
19879 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19883 if(suppressEvent !== true){
19884 this.fireEvent('select', this, o, v);
19889 getValue: function()
19894 onClick: function(e)
19896 e.stopPropagation();
19897 e.preventDefault();
19899 var target = e.getTarget();
19901 if(target.nodeName.toLowerCase() === 'i'){
19902 target = Roo.get(target).dom.parentNode;
19905 var nodeName = target.nodeName;
19906 var className = target.className;
19907 var html = target.innerHTML;
19909 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19913 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19915 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19921 picker : function()
19923 return this.pickerEl;
19926 fillMonths: function()
19929 var months = this.picker().select('>.datepicker-months td', true).first();
19931 months.dom.innerHTML = '';
19937 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19940 months.createChild(month);
19949 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19950 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19953 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19954 e.removeClass('active');
19956 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19957 e.addClass('active');
19964 if(this.isInline) {
19968 this.picker().removeClass(['bottom', 'top']);
19970 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19972 * place to the top of element!
19976 this.picker().addClass('top');
19977 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19982 this.picker().addClass('bottom');
19984 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19987 onFocus : function()
19989 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19993 onBlur : function()
19995 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19997 var d = this.inputEl().getValue();
20006 this.picker().show();
20007 this.picker().select('>.datepicker-months', true).first().show();
20011 this.fireEvent('show', this, this.date);
20016 if(this.isInline) {
20019 this.picker().hide();
20020 this.fireEvent('hide', this, this.date);
20024 onMousedown: function(e)
20026 e.stopPropagation();
20027 e.preventDefault();
20032 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20036 fireKey: function(e)
20038 if (!this.picker().isVisible()){
20039 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20050 e.preventDefault();
20054 dir = e.keyCode == 37 ? -1 : 1;
20056 this.vIndex = this.vIndex + dir;
20058 if(this.vIndex < 0){
20062 if(this.vIndex > 11){
20066 if(isNaN(this.vIndex)){
20070 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20076 dir = e.keyCode == 38 ? -1 : 1;
20078 this.vIndex = this.vIndex + dir * 4;
20080 if(this.vIndex < 0){
20084 if(this.vIndex > 11){
20088 if(isNaN(this.vIndex)){
20092 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20097 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20098 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20102 e.preventDefault();
20105 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20106 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20122 this.picker().remove();
20127 Roo.apply(Roo.bootstrap.MonthField, {
20146 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20147 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20152 Roo.apply(Roo.bootstrap.MonthField, {
20156 cls: 'datepicker dropdown-menu roo-dynamic',
20160 cls: 'datepicker-months',
20164 cls: 'table-condensed',
20166 Roo.bootstrap.DateField.content
20186 * @class Roo.bootstrap.CheckBox
20187 * @extends Roo.bootstrap.Input
20188 * Bootstrap CheckBox class
20190 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20191 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20192 * @cfg {String} boxLabel The text that appears beside the checkbox
20193 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20194 * @cfg {Boolean} checked initnal the element
20195 * @cfg {Boolean} inline inline the element (default false)
20196 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20197 * @cfg {String} tooltip label tooltip
20200 * Create a new CheckBox
20201 * @param {Object} config The config object
20204 Roo.bootstrap.CheckBox = function(config){
20205 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20210 * Fires when the element is checked or unchecked.
20211 * @param {Roo.bootstrap.CheckBox} this This input
20212 * @param {Boolean} checked The new checked value
20217 * Fires when the element is click.
20218 * @param {Roo.bootstrap.CheckBox} this This input
20225 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20227 inputType: 'checkbox',
20236 getAutoCreate : function()
20238 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20244 cfg.cls = 'form-group ' + this.inputType; //input-group
20247 cfg.cls += ' ' + this.inputType + '-inline';
20253 type : this.inputType,
20254 value : this.inputValue,
20255 cls : 'roo-' + this.inputType, //'form-box',
20256 placeholder : this.placeholder || ''
20260 if(this.inputType != 'radio'){
20264 cls : 'roo-hidden-value',
20265 value : this.checked ? this.inputValue : this.valueOff
20270 if (this.weight) { // Validity check?
20271 cfg.cls += " " + this.inputType + "-" + this.weight;
20274 if (this.disabled) {
20275 input.disabled=true;
20279 input.checked = this.checked;
20284 input.name = this.name;
20286 if(this.inputType != 'radio'){
20287 hidden.name = this.name;
20288 input.name = '_hidden_' + this.name;
20293 input.cls += ' input-' + this.size;
20298 ['xs','sm','md','lg'].map(function(size){
20299 if (settings[size]) {
20300 cfg.cls += ' col-' + size + '-' + settings[size];
20304 var inputblock = input;
20306 if (this.before || this.after) {
20309 cls : 'input-group',
20314 inputblock.cn.push({
20316 cls : 'input-group-addon',
20321 inputblock.cn.push(input);
20323 if(this.inputType != 'radio'){
20324 inputblock.cn.push(hidden);
20328 inputblock.cn.push({
20330 cls : 'input-group-addon',
20337 if (align ==='left' && this.fieldLabel.length) {
20338 // Roo.log("left and has label");
20343 cls : 'control-label',
20344 html : this.fieldLabel
20354 if(this.labelWidth > 12){
20355 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20358 if(this.labelWidth < 13 && this.labelmd == 0){
20359 this.labelmd = this.labelWidth;
20362 if(this.labellg > 0){
20363 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20364 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20367 if(this.labelmd > 0){
20368 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20369 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20372 if(this.labelsm > 0){
20373 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20374 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20377 if(this.labelxs > 0){
20378 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20379 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20382 } else if ( this.fieldLabel.length) {
20383 // Roo.log(" label");
20387 tag: this.boxLabel ? 'span' : 'label',
20389 cls: 'control-label box-input-label',
20390 //cls : 'input-group-addon',
20391 html : this.fieldLabel
20400 // Roo.log(" no label && no align");
20401 cfg.cn = [ inputblock ] ;
20407 var boxLabelCfg = {
20409 //'for': id, // box label is handled by onclick - so no for...
20411 html: this.boxLabel
20415 boxLabelCfg.tooltip = this.tooltip;
20418 cfg.cn.push(boxLabelCfg);
20421 if(this.inputType != 'radio'){
20422 cfg.cn.push(hidden);
20430 * return the real input element.
20432 inputEl: function ()
20434 return this.el.select('input.roo-' + this.inputType,true).first();
20436 hiddenEl: function ()
20438 return this.el.select('input.roo-hidden-value',true).first();
20441 labelEl: function()
20443 return this.el.select('label.control-label',true).first();
20445 /* depricated... */
20449 return this.labelEl();
20452 boxLabelEl: function()
20454 return this.el.select('label.box-label',true).first();
20457 initEvents : function()
20459 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20461 this.inputEl().on('click', this.onClick, this);
20463 if (this.boxLabel) {
20464 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20467 this.startValue = this.getValue();
20470 Roo.bootstrap.CheckBox.register(this);
20474 onClick : function(e)
20476 if(this.fireEvent('click', this, e) !== false){
20477 this.setChecked(!this.checked);
20482 setChecked : function(state,suppressEvent)
20484 this.startValue = this.getValue();
20486 if(this.inputType == 'radio'){
20488 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20489 e.dom.checked = false;
20492 this.inputEl().dom.checked = true;
20494 this.inputEl().dom.value = this.inputValue;
20496 if(suppressEvent !== true){
20497 this.fireEvent('check', this, true);
20505 this.checked = state;
20507 this.inputEl().dom.checked = state;
20510 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20512 if(suppressEvent !== true){
20513 this.fireEvent('check', this, state);
20519 getValue : function()
20521 if(this.inputType == 'radio'){
20522 return this.getGroupValue();
20525 return this.hiddenEl().dom.value;
20529 getGroupValue : function()
20531 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20535 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20538 setValue : function(v,suppressEvent)
20540 if(this.inputType == 'radio'){
20541 this.setGroupValue(v, suppressEvent);
20545 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20550 setGroupValue : function(v, suppressEvent)
20552 this.startValue = this.getValue();
20554 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20555 e.dom.checked = false;
20557 if(e.dom.value == v){
20558 e.dom.checked = true;
20562 if(suppressEvent !== true){
20563 this.fireEvent('check', this, true);
20571 validate : function()
20575 (this.inputType == 'radio' && this.validateRadio()) ||
20576 (this.inputType == 'checkbox' && this.validateCheckbox())
20582 this.markInvalid();
20586 validateRadio : function()
20588 if(this.allowBlank){
20594 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20595 if(!e.dom.checked){
20607 validateCheckbox : function()
20610 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20611 //return (this.getValue() == this.inputValue) ? true : false;
20614 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20622 for(var i in group){
20623 if(group[i].el.isVisible(true)){
20631 for(var i in group){
20636 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20643 * Mark this field as valid
20645 markValid : function()
20649 this.fireEvent('valid', this);
20651 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20654 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20661 if(this.inputType == 'radio'){
20662 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20663 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20664 e.findParent('.form-group', false, true).addClass(_this.validClass);
20671 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20672 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20676 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20682 for(var i in group){
20683 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20684 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20689 * Mark this field as invalid
20690 * @param {String} msg The validation message
20692 markInvalid : function(msg)
20694 if(this.allowBlank){
20700 this.fireEvent('invalid', this, msg);
20702 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20705 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20709 label.markInvalid();
20712 if(this.inputType == 'radio'){
20713 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20714 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20715 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20722 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20723 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20727 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20733 for(var i in group){
20734 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20735 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20740 clearInvalid : function()
20742 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20744 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20746 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20748 if (label && label.iconEl) {
20749 label.iconEl.removeClass(label.validClass);
20750 label.iconEl.removeClass(label.invalidClass);
20754 disable : function()
20756 if(this.inputType != 'radio'){
20757 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20764 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20765 _this.getActionEl().addClass(this.disabledClass);
20766 e.dom.disabled = true;
20770 this.disabled = true;
20771 this.fireEvent("disable", this);
20775 enable : function()
20777 if(this.inputType != 'radio'){
20778 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20785 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20786 _this.getActionEl().removeClass(this.disabledClass);
20787 e.dom.disabled = false;
20791 this.disabled = false;
20792 this.fireEvent("enable", this);
20796 setBoxLabel : function(v)
20801 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20807 Roo.apply(Roo.bootstrap.CheckBox, {
20812 * register a CheckBox Group
20813 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20815 register : function(checkbox)
20817 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20818 this.groups[checkbox.groupId] = {};
20821 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20825 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20829 * fetch a CheckBox Group based on the group ID
20830 * @param {string} the group ID
20831 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20833 get: function(groupId) {
20834 if (typeof(this.groups[groupId]) == 'undefined') {
20838 return this.groups[groupId] ;
20851 * @class Roo.bootstrap.Radio
20852 * @extends Roo.bootstrap.Component
20853 * Bootstrap Radio class
20854 * @cfg {String} boxLabel - the label associated
20855 * @cfg {String} value - the value of radio
20858 * Create a new Radio
20859 * @param {Object} config The config object
20861 Roo.bootstrap.Radio = function(config){
20862 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20866 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20872 getAutoCreate : function()
20876 cls : 'form-group radio',
20881 html : this.boxLabel
20889 initEvents : function()
20891 this.parent().register(this);
20893 this.el.on('click', this.onClick, this);
20897 onClick : function()
20899 this.setChecked(true);
20902 setChecked : function(state, suppressEvent)
20904 this.parent().setValue(this.value, suppressEvent);
20908 setBoxLabel : function(v)
20913 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20928 * @class Roo.bootstrap.SecurePass
20929 * @extends Roo.bootstrap.Input
20930 * Bootstrap SecurePass class
20934 * Create a new SecurePass
20935 * @param {Object} config The config object
20938 Roo.bootstrap.SecurePass = function (config) {
20939 // these go here, so the translation tool can replace them..
20941 PwdEmpty: "Please type a password, and then retype it to confirm.",
20942 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20943 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20944 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20945 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20946 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20947 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20948 TooWeak: "Your password is Too Weak."
20950 this.meterLabel = "Password strength:";
20951 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20952 this.meterClass = [
20953 "roo-password-meter-tooweak",
20954 "roo-password-meter-weak",
20955 "roo-password-meter-medium",
20956 "roo-password-meter-strong",
20957 "roo-password-meter-grey"
20962 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20965 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20967 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20969 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20970 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20971 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20972 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20973 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20974 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20975 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20985 * @cfg {String/Object} Label for the strength meter (defaults to
20986 * 'Password strength:')
20991 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20992 * ['Weak', 'Medium', 'Strong'])
20995 pwdStrengths: false,
21008 initEvents: function ()
21010 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21012 if (this.el.is('input[type=password]') && Roo.isSafari) {
21013 this.el.on('keydown', this.SafariOnKeyDown, this);
21016 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21019 onRender: function (ct, position)
21021 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21022 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21023 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21025 this.trigger.createChild({
21030 cls: 'roo-password-meter-grey col-xs-12',
21033 //width: this.meterWidth + 'px'
21037 cls: 'roo-password-meter-text'
21043 if (this.hideTrigger) {
21044 this.trigger.setDisplayed(false);
21046 this.setSize(this.width || '', this.height || '');
21049 onDestroy: function ()
21051 if (this.trigger) {
21052 this.trigger.removeAllListeners();
21053 this.trigger.remove();
21056 this.wrap.remove();
21058 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21061 checkStrength: function ()
21063 var pwd = this.inputEl().getValue();
21064 if (pwd == this._lastPwd) {
21069 if (this.ClientSideStrongPassword(pwd)) {
21071 } else if (this.ClientSideMediumPassword(pwd)) {
21073 } else if (this.ClientSideWeakPassword(pwd)) {
21079 Roo.log('strength1: ' + strength);
21081 //var pm = this.trigger.child('div/div/div').dom;
21082 var pm = this.trigger.child('div/div');
21083 pm.removeClass(this.meterClass);
21084 pm.addClass(this.meterClass[strength]);
21087 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21089 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21091 this._lastPwd = pwd;
21095 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21097 this._lastPwd = '';
21099 var pm = this.trigger.child('div/div');
21100 pm.removeClass(this.meterClass);
21101 pm.addClass('roo-password-meter-grey');
21104 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21107 this.inputEl().dom.type='password';
21110 validateValue: function (value)
21113 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21116 if (value.length == 0) {
21117 if (this.allowBlank) {
21118 this.clearInvalid();
21122 this.markInvalid(this.errors.PwdEmpty);
21123 this.errorMsg = this.errors.PwdEmpty;
21131 if ('[\x21-\x7e]*'.match(value)) {
21132 this.markInvalid(this.errors.PwdBadChar);
21133 this.errorMsg = this.errors.PwdBadChar;
21136 if (value.length < 6) {
21137 this.markInvalid(this.errors.PwdShort);
21138 this.errorMsg = this.errors.PwdShort;
21141 if (value.length > 16) {
21142 this.markInvalid(this.errors.PwdLong);
21143 this.errorMsg = this.errors.PwdLong;
21147 if (this.ClientSideStrongPassword(value)) {
21149 } else if (this.ClientSideMediumPassword(value)) {
21151 } else if (this.ClientSideWeakPassword(value)) {
21158 if (strength < 2) {
21159 //this.markInvalid(this.errors.TooWeak);
21160 this.errorMsg = this.errors.TooWeak;
21165 console.log('strength2: ' + strength);
21167 //var pm = this.trigger.child('div/div/div').dom;
21169 var pm = this.trigger.child('div/div');
21170 pm.removeClass(this.meterClass);
21171 pm.addClass(this.meterClass[strength]);
21173 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21175 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21177 this.errorMsg = '';
21181 CharacterSetChecks: function (type)
21184 this.fResult = false;
21187 isctype: function (character, type)
21190 case this.kCapitalLetter:
21191 if (character >= 'A' && character <= 'Z') {
21196 case this.kSmallLetter:
21197 if (character >= 'a' && character <= 'z') {
21203 if (character >= '0' && character <= '9') {
21208 case this.kPunctuation:
21209 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21220 IsLongEnough: function (pwd, size)
21222 return !(pwd == null || isNaN(size) || pwd.length < size);
21225 SpansEnoughCharacterSets: function (word, nb)
21227 if (!this.IsLongEnough(word, nb))
21232 var characterSetChecks = new Array(
21233 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21234 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21237 for (var index = 0; index < word.length; ++index) {
21238 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21239 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21240 characterSetChecks[nCharSet].fResult = true;
21247 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21248 if (characterSetChecks[nCharSet].fResult) {
21253 if (nCharSets < nb) {
21259 ClientSideStrongPassword: function (pwd)
21261 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21264 ClientSideMediumPassword: function (pwd)
21266 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21269 ClientSideWeakPassword: function (pwd)
21271 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21274 })//<script type="text/javascript">
21277 * Based Ext JS Library 1.1.1
21278 * Copyright(c) 2006-2007, Ext JS, LLC.
21284 * @class Roo.HtmlEditorCore
21285 * @extends Roo.Component
21286 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21288 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21291 Roo.HtmlEditorCore = function(config){
21294 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21299 * @event initialize
21300 * Fires when the editor is fully initialized (including the iframe)
21301 * @param {Roo.HtmlEditorCore} this
21306 * Fires when the editor is first receives the focus. Any insertion must wait
21307 * until after this event.
21308 * @param {Roo.HtmlEditorCore} this
21312 * @event beforesync
21313 * Fires before the textarea is updated with content from the editor iframe. Return false
21314 * to cancel the sync.
21315 * @param {Roo.HtmlEditorCore} this
21316 * @param {String} html
21320 * @event beforepush
21321 * Fires before the iframe editor is updated with content from the textarea. Return false
21322 * to cancel the push.
21323 * @param {Roo.HtmlEditorCore} this
21324 * @param {String} html
21329 * Fires when the textarea is updated with content from the editor iframe.
21330 * @param {Roo.HtmlEditorCore} this
21331 * @param {String} html
21336 * Fires when the iframe editor is updated with content from the textarea.
21337 * @param {Roo.HtmlEditorCore} this
21338 * @param {String} html
21343 * @event editorevent
21344 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21345 * @param {Roo.HtmlEditorCore} this
21351 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21353 // defaults : white / black...
21354 this.applyBlacklists();
21361 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21365 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21371 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21376 * @cfg {Number} height (in pixels)
21380 * @cfg {Number} width (in pixels)
21385 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21388 stylesheets: false,
21393 // private properties
21394 validationEvent : false,
21396 initialized : false,
21398 sourceEditMode : false,
21399 onFocus : Roo.emptyFn,
21401 hideMode:'offsets',
21405 // blacklist + whitelisted elements..
21412 * Protected method that will not generally be called directly. It
21413 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21414 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21416 getDocMarkup : function(){
21420 // inherit styels from page...??
21421 if (this.stylesheets === false) {
21423 Roo.get(document.head).select('style').each(function(node) {
21424 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21427 Roo.get(document.head).select('link').each(function(node) {
21428 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21431 } else if (!this.stylesheets.length) {
21433 st = '<style type="text/css">' +
21434 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21437 st = '<style type="text/css">' +
21442 st += '<style type="text/css">' +
21443 'IMG { cursor: pointer } ' +
21446 var cls = 'roo-htmleditor-body';
21448 if(this.bodyCls.length){
21449 cls += ' ' + this.bodyCls;
21452 return '<html><head>' + st +
21453 //<style type="text/css">' +
21454 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21456 ' </head><body class="' + cls + '"></body></html>';
21460 onRender : function(ct, position)
21463 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21464 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21467 this.el.dom.style.border = '0 none';
21468 this.el.dom.setAttribute('tabIndex', -1);
21469 this.el.addClass('x-hidden hide');
21473 if(Roo.isIE){ // fix IE 1px bogus margin
21474 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21478 this.frameId = Roo.id();
21482 var iframe = this.owner.wrap.createChild({
21484 cls: 'form-control', // bootstrap..
21486 name: this.frameId,
21487 frameBorder : 'no',
21488 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21493 this.iframe = iframe.dom;
21495 this.assignDocWin();
21497 this.doc.designMode = 'on';
21500 this.doc.write(this.getDocMarkup());
21504 var task = { // must defer to wait for browser to be ready
21506 //console.log("run task?" + this.doc.readyState);
21507 this.assignDocWin();
21508 if(this.doc.body || this.doc.readyState == 'complete'){
21510 this.doc.designMode="on";
21514 Roo.TaskMgr.stop(task);
21515 this.initEditor.defer(10, this);
21522 Roo.TaskMgr.start(task);
21527 onResize : function(w, h)
21529 Roo.log('resize: ' +w + ',' + h );
21530 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21534 if(typeof w == 'number'){
21536 this.iframe.style.width = w + 'px';
21538 if(typeof h == 'number'){
21540 this.iframe.style.height = h + 'px';
21542 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21549 * Toggles the editor between standard and source edit mode.
21550 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21552 toggleSourceEdit : function(sourceEditMode){
21554 this.sourceEditMode = sourceEditMode === true;
21556 if(this.sourceEditMode){
21558 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21561 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21562 //this.iframe.className = '';
21565 //this.setSize(this.owner.wrap.getSize());
21566 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21573 * Protected method that will not generally be called directly. If you need/want
21574 * custom HTML cleanup, this is the method you should override.
21575 * @param {String} html The HTML to be cleaned
21576 * return {String} The cleaned HTML
21578 cleanHtml : function(html){
21579 html = String(html);
21580 if(html.length > 5){
21581 if(Roo.isSafari){ // strip safari nonsense
21582 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21585 if(html == ' '){
21592 * HTML Editor -> Textarea
21593 * Protected method that will not generally be called directly. Syncs the contents
21594 * of the editor iframe with the textarea.
21596 syncValue : function(){
21597 if(this.initialized){
21598 var bd = (this.doc.body || this.doc.documentElement);
21599 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21600 var html = bd.innerHTML;
21602 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21603 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21605 html = '<div style="'+m[0]+'">' + html + '</div>';
21608 html = this.cleanHtml(html);
21609 // fix up the special chars.. normaly like back quotes in word...
21610 // however we do not want to do this with chinese..
21611 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21612 var cc = b.charCodeAt();
21614 (cc >= 0x4E00 && cc < 0xA000 ) ||
21615 (cc >= 0x3400 && cc < 0x4E00 ) ||
21616 (cc >= 0xf900 && cc < 0xfb00 )
21622 if(this.owner.fireEvent('beforesync', this, html) !== false){
21623 this.el.dom.value = html;
21624 this.owner.fireEvent('sync', this, html);
21630 * Protected method that will not generally be called directly. Pushes the value of the textarea
21631 * into the iframe editor.
21633 pushValue : function(){
21634 if(this.initialized){
21635 var v = this.el.dom.value.trim();
21637 // if(v.length < 1){
21641 if(this.owner.fireEvent('beforepush', this, v) !== false){
21642 var d = (this.doc.body || this.doc.documentElement);
21644 this.cleanUpPaste();
21645 this.el.dom.value = d.innerHTML;
21646 this.owner.fireEvent('push', this, v);
21652 deferFocus : function(){
21653 this.focus.defer(10, this);
21657 focus : function(){
21658 if(this.win && !this.sourceEditMode){
21665 assignDocWin: function()
21667 var iframe = this.iframe;
21670 this.doc = iframe.contentWindow.document;
21671 this.win = iframe.contentWindow;
21673 // if (!Roo.get(this.frameId)) {
21676 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21677 // this.win = Roo.get(this.frameId).dom.contentWindow;
21679 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21683 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21684 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21689 initEditor : function(){
21690 //console.log("INIT EDITOR");
21691 this.assignDocWin();
21695 this.doc.designMode="on";
21697 this.doc.write(this.getDocMarkup());
21700 var dbody = (this.doc.body || this.doc.documentElement);
21701 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21702 // this copies styles from the containing element into thsi one..
21703 // not sure why we need all of this..
21704 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21706 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21707 //ss['background-attachment'] = 'fixed'; // w3c
21708 dbody.bgProperties = 'fixed'; // ie
21709 //Roo.DomHelper.applyStyles(dbody, ss);
21710 Roo.EventManager.on(this.doc, {
21711 //'mousedown': this.onEditorEvent,
21712 'mouseup': this.onEditorEvent,
21713 'dblclick': this.onEditorEvent,
21714 'click': this.onEditorEvent,
21715 'keyup': this.onEditorEvent,
21720 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21722 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21723 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21725 this.initialized = true;
21727 this.owner.fireEvent('initialize', this);
21732 onDestroy : function(){
21738 //for (var i =0; i < this.toolbars.length;i++) {
21739 // // fixme - ask toolbars for heights?
21740 // this.toolbars[i].onDestroy();
21743 //this.wrap.dom.innerHTML = '';
21744 //this.wrap.remove();
21749 onFirstFocus : function(){
21751 this.assignDocWin();
21754 this.activated = true;
21757 if(Roo.isGecko){ // prevent silly gecko errors
21759 var s = this.win.getSelection();
21760 if(!s.focusNode || s.focusNode.nodeType != 3){
21761 var r = s.getRangeAt(0);
21762 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21767 this.execCmd('useCSS', true);
21768 this.execCmd('styleWithCSS', false);
21771 this.owner.fireEvent('activate', this);
21775 adjustFont: function(btn){
21776 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21777 //if(Roo.isSafari){ // safari
21780 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21781 if(Roo.isSafari){ // safari
21782 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21783 v = (v < 10) ? 10 : v;
21784 v = (v > 48) ? 48 : v;
21785 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21790 v = Math.max(1, v+adjust);
21792 this.execCmd('FontSize', v );
21795 onEditorEvent : function(e)
21797 this.owner.fireEvent('editorevent', this, e);
21798 // this.updateToolbar();
21799 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21802 insertTag : function(tg)
21804 // could be a bit smarter... -> wrap the current selected tRoo..
21805 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21807 range = this.createRange(this.getSelection());
21808 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21809 wrappingNode.appendChild(range.extractContents());
21810 range.insertNode(wrappingNode);
21817 this.execCmd("formatblock", tg);
21821 insertText : function(txt)
21825 var range = this.createRange();
21826 range.deleteContents();
21827 //alert(Sender.getAttribute('label'));
21829 range.insertNode(this.doc.createTextNode(txt));
21835 * Executes a Midas editor command on the editor document and performs necessary focus and
21836 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21837 * @param {String} cmd The Midas command
21838 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21840 relayCmd : function(cmd, value){
21842 this.execCmd(cmd, value);
21843 this.owner.fireEvent('editorevent', this);
21844 //this.updateToolbar();
21845 this.owner.deferFocus();
21849 * Executes a Midas editor command directly on the editor document.
21850 * For visual commands, you should use {@link #relayCmd} instead.
21851 * <b>This should only be called after the editor is initialized.</b>
21852 * @param {String} cmd The Midas command
21853 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21855 execCmd : function(cmd, value){
21856 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21863 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21865 * @param {String} text | dom node..
21867 insertAtCursor : function(text)
21870 if(!this.activated){
21876 var r = this.doc.selection.createRange();
21887 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21891 // from jquery ui (MIT licenced)
21893 var win = this.win;
21895 if (win.getSelection && win.getSelection().getRangeAt) {
21896 range = win.getSelection().getRangeAt(0);
21897 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21898 range.insertNode(node);
21899 } else if (win.document.selection && win.document.selection.createRange) {
21900 // no firefox support
21901 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21902 win.document.selection.createRange().pasteHTML(txt);
21904 // no firefox support
21905 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21906 this.execCmd('InsertHTML', txt);
21915 mozKeyPress : function(e){
21917 var c = e.getCharCode(), cmd;
21920 c = String.fromCharCode(c).toLowerCase();
21934 this.cleanUpPaste.defer(100, this);
21942 e.preventDefault();
21950 fixKeys : function(){ // load time branching for fastest keydown performance
21952 return function(e){
21953 var k = e.getKey(), r;
21956 r = this.doc.selection.createRange();
21959 r.pasteHTML('    ');
21966 r = this.doc.selection.createRange();
21968 var target = r.parentElement();
21969 if(!target || target.tagName.toLowerCase() != 'li'){
21971 r.pasteHTML('<br />');
21977 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21978 this.cleanUpPaste.defer(100, this);
21984 }else if(Roo.isOpera){
21985 return function(e){
21986 var k = e.getKey();
21990 this.execCmd('InsertHTML','    ');
21993 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21994 this.cleanUpPaste.defer(100, this);
21999 }else if(Roo.isSafari){
22000 return function(e){
22001 var k = e.getKey();
22005 this.execCmd('InsertText','\t');
22009 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22010 this.cleanUpPaste.defer(100, this);
22018 getAllAncestors: function()
22020 var p = this.getSelectedNode();
22023 a.push(p); // push blank onto stack..
22024 p = this.getParentElement();
22028 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22032 a.push(this.doc.body);
22036 lastSelNode : false,
22039 getSelection : function()
22041 this.assignDocWin();
22042 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22045 getSelectedNode: function()
22047 // this may only work on Gecko!!!
22049 // should we cache this!!!!
22054 var range = this.createRange(this.getSelection()).cloneRange();
22057 var parent = range.parentElement();
22059 var testRange = range.duplicate();
22060 testRange.moveToElementText(parent);
22061 if (testRange.inRange(range)) {
22064 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22067 parent = parent.parentElement;
22072 // is ancestor a text element.
22073 var ac = range.commonAncestorContainer;
22074 if (ac.nodeType == 3) {
22075 ac = ac.parentNode;
22078 var ar = ac.childNodes;
22081 var other_nodes = [];
22082 var has_other_nodes = false;
22083 for (var i=0;i<ar.length;i++) {
22084 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22087 // fullly contained node.
22089 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22094 // probably selected..
22095 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22096 other_nodes.push(ar[i]);
22100 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22105 has_other_nodes = true;
22107 if (!nodes.length && other_nodes.length) {
22108 nodes= other_nodes;
22110 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22116 createRange: function(sel)
22118 // this has strange effects when using with
22119 // top toolbar - not sure if it's a great idea.
22120 //this.editor.contentWindow.focus();
22121 if (typeof sel != "undefined") {
22123 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22125 return this.doc.createRange();
22128 return this.doc.createRange();
22131 getParentElement: function()
22134 this.assignDocWin();
22135 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22137 var range = this.createRange(sel);
22140 var p = range.commonAncestorContainer;
22141 while (p.nodeType == 3) { // text node
22152 * Range intersection.. the hard stuff...
22156 * [ -- selected range --- ]
22160 * if end is before start or hits it. fail.
22161 * if start is after end or hits it fail.
22163 * if either hits (but other is outside. - then it's not
22169 // @see http://www.thismuchiknow.co.uk/?p=64.
22170 rangeIntersectsNode : function(range, node)
22172 var nodeRange = node.ownerDocument.createRange();
22174 nodeRange.selectNode(node);
22176 nodeRange.selectNodeContents(node);
22179 var rangeStartRange = range.cloneRange();
22180 rangeStartRange.collapse(true);
22182 var rangeEndRange = range.cloneRange();
22183 rangeEndRange.collapse(false);
22185 var nodeStartRange = nodeRange.cloneRange();
22186 nodeStartRange.collapse(true);
22188 var nodeEndRange = nodeRange.cloneRange();
22189 nodeEndRange.collapse(false);
22191 return rangeStartRange.compareBoundaryPoints(
22192 Range.START_TO_START, nodeEndRange) == -1 &&
22193 rangeEndRange.compareBoundaryPoints(
22194 Range.START_TO_START, nodeStartRange) == 1;
22198 rangeCompareNode : function(range, node)
22200 var nodeRange = node.ownerDocument.createRange();
22202 nodeRange.selectNode(node);
22204 nodeRange.selectNodeContents(node);
22208 range.collapse(true);
22210 nodeRange.collapse(true);
22212 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22213 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22215 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22217 var nodeIsBefore = ss == 1;
22218 var nodeIsAfter = ee == -1;
22220 if (nodeIsBefore && nodeIsAfter) {
22223 if (!nodeIsBefore && nodeIsAfter) {
22224 return 1; //right trailed.
22227 if (nodeIsBefore && !nodeIsAfter) {
22228 return 2; // left trailed.
22234 // private? - in a new class?
22235 cleanUpPaste : function()
22237 // cleans up the whole document..
22238 Roo.log('cleanuppaste');
22240 this.cleanUpChildren(this.doc.body);
22241 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22242 if (clean != this.doc.body.innerHTML) {
22243 this.doc.body.innerHTML = clean;
22248 cleanWordChars : function(input) {// change the chars to hex code
22249 var he = Roo.HtmlEditorCore;
22251 var output = input;
22252 Roo.each(he.swapCodes, function(sw) {
22253 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22255 output = output.replace(swapper, sw[1]);
22262 cleanUpChildren : function (n)
22264 if (!n.childNodes.length) {
22267 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22268 this.cleanUpChild(n.childNodes[i]);
22275 cleanUpChild : function (node)
22278 //console.log(node);
22279 if (node.nodeName == "#text") {
22280 // clean up silly Windows -- stuff?
22283 if (node.nodeName == "#comment") {
22284 node.parentNode.removeChild(node);
22285 // clean up silly Windows -- stuff?
22288 var lcname = node.tagName.toLowerCase();
22289 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22290 // whitelist of tags..
22292 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22294 node.parentNode.removeChild(node);
22299 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22301 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22302 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22304 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22305 // remove_keep_children = true;
22308 if (remove_keep_children) {
22309 this.cleanUpChildren(node);
22310 // inserts everything just before this node...
22311 while (node.childNodes.length) {
22312 var cn = node.childNodes[0];
22313 node.removeChild(cn);
22314 node.parentNode.insertBefore(cn, node);
22316 node.parentNode.removeChild(node);
22320 if (!node.attributes || !node.attributes.length) {
22321 this.cleanUpChildren(node);
22325 function cleanAttr(n,v)
22328 if (v.match(/^\./) || v.match(/^\//)) {
22331 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22334 if (v.match(/^#/)) {
22337 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22338 node.removeAttribute(n);
22342 var cwhite = this.cwhite;
22343 var cblack = this.cblack;
22345 function cleanStyle(n,v)
22347 if (v.match(/expression/)) { //XSS?? should we even bother..
22348 node.removeAttribute(n);
22352 var parts = v.split(/;/);
22355 Roo.each(parts, function(p) {
22356 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22360 var l = p.split(':').shift().replace(/\s+/g,'');
22361 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22363 if ( cwhite.length && cblack.indexOf(l) > -1) {
22364 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22365 //node.removeAttribute(n);
22369 // only allow 'c whitelisted system attributes'
22370 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22371 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22372 //node.removeAttribute(n);
22382 if (clean.length) {
22383 node.setAttribute(n, clean.join(';'));
22385 node.removeAttribute(n);
22391 for (var i = node.attributes.length-1; i > -1 ; i--) {
22392 var a = node.attributes[i];
22395 if (a.name.toLowerCase().substr(0,2)=='on') {
22396 node.removeAttribute(a.name);
22399 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22400 node.removeAttribute(a.name);
22403 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22404 cleanAttr(a.name,a.value); // fixme..
22407 if (a.name == 'style') {
22408 cleanStyle(a.name,a.value);
22411 /// clean up MS crap..
22412 // tecnically this should be a list of valid class'es..
22415 if (a.name == 'class') {
22416 if (a.value.match(/^Mso/)) {
22417 node.className = '';
22420 if (a.value.match(/^body$/)) {
22421 node.className = '';
22432 this.cleanUpChildren(node);
22438 * Clean up MS wordisms...
22440 cleanWord : function(node)
22445 this.cleanWord(this.doc.body);
22448 if (node.nodeName == "#text") {
22449 // clean up silly Windows -- stuff?
22452 if (node.nodeName == "#comment") {
22453 node.parentNode.removeChild(node);
22454 // clean up silly Windows -- stuff?
22458 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22459 node.parentNode.removeChild(node);
22463 // remove - but keep children..
22464 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22465 while (node.childNodes.length) {
22466 var cn = node.childNodes[0];
22467 node.removeChild(cn);
22468 node.parentNode.insertBefore(cn, node);
22470 node.parentNode.removeChild(node);
22471 this.iterateChildren(node, this.cleanWord);
22475 if (node.className.length) {
22477 var cn = node.className.split(/\W+/);
22479 Roo.each(cn, function(cls) {
22480 if (cls.match(/Mso[a-zA-Z]+/)) {
22485 node.className = cna.length ? cna.join(' ') : '';
22487 node.removeAttribute("class");
22491 if (node.hasAttribute("lang")) {
22492 node.removeAttribute("lang");
22495 if (node.hasAttribute("style")) {
22497 var styles = node.getAttribute("style").split(";");
22499 Roo.each(styles, function(s) {
22500 if (!s.match(/:/)) {
22503 var kv = s.split(":");
22504 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22507 // what ever is left... we allow.
22510 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22511 if (!nstyle.length) {
22512 node.removeAttribute('style');
22515 this.iterateChildren(node, this.cleanWord);
22521 * iterateChildren of a Node, calling fn each time, using this as the scole..
22522 * @param {DomNode} node node to iterate children of.
22523 * @param {Function} fn method of this class to call on each item.
22525 iterateChildren : function(node, fn)
22527 if (!node.childNodes.length) {
22530 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22531 fn.call(this, node.childNodes[i])
22537 * cleanTableWidths.
22539 * Quite often pasting from word etc.. results in tables with column and widths.
22540 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22543 cleanTableWidths : function(node)
22548 this.cleanTableWidths(this.doc.body);
22553 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22556 Roo.log(node.tagName);
22557 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22558 this.iterateChildren(node, this.cleanTableWidths);
22561 if (node.hasAttribute('width')) {
22562 node.removeAttribute('width');
22566 if (node.hasAttribute("style")) {
22569 var styles = node.getAttribute("style").split(";");
22571 Roo.each(styles, function(s) {
22572 if (!s.match(/:/)) {
22575 var kv = s.split(":");
22576 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22579 // what ever is left... we allow.
22582 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22583 if (!nstyle.length) {
22584 node.removeAttribute('style');
22588 this.iterateChildren(node, this.cleanTableWidths);
22596 domToHTML : function(currentElement, depth, nopadtext) {
22598 depth = depth || 0;
22599 nopadtext = nopadtext || false;
22601 if (!currentElement) {
22602 return this.domToHTML(this.doc.body);
22605 //Roo.log(currentElement);
22607 var allText = false;
22608 var nodeName = currentElement.nodeName;
22609 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22611 if (nodeName == '#text') {
22613 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22618 if (nodeName != 'BODY') {
22621 // Prints the node tagName, such as <A>, <IMG>, etc
22624 for(i = 0; i < currentElement.attributes.length;i++) {
22626 var aname = currentElement.attributes.item(i).name;
22627 if (!currentElement.attributes.item(i).value.length) {
22630 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22633 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22642 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22645 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22650 // Traverse the tree
22652 var currentElementChild = currentElement.childNodes.item(i);
22653 var allText = true;
22654 var innerHTML = '';
22656 while (currentElementChild) {
22657 // Formatting code (indent the tree so it looks nice on the screen)
22658 var nopad = nopadtext;
22659 if (lastnode == 'SPAN') {
22663 if (currentElementChild.nodeName == '#text') {
22664 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22665 toadd = nopadtext ? toadd : toadd.trim();
22666 if (!nopad && toadd.length > 80) {
22667 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22669 innerHTML += toadd;
22672 currentElementChild = currentElement.childNodes.item(i);
22678 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22680 // Recursively traverse the tree structure of the child node
22681 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22682 lastnode = currentElementChild.nodeName;
22684 currentElementChild=currentElement.childNodes.item(i);
22690 // The remaining code is mostly for formatting the tree
22691 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22696 ret+= "</"+tagName+">";
22702 applyBlacklists : function()
22704 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22705 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22709 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22710 if (b.indexOf(tag) > -1) {
22713 this.white.push(tag);
22717 Roo.each(w, function(tag) {
22718 if (b.indexOf(tag) > -1) {
22721 if (this.white.indexOf(tag) > -1) {
22724 this.white.push(tag);
22729 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22730 if (w.indexOf(tag) > -1) {
22733 this.black.push(tag);
22737 Roo.each(b, function(tag) {
22738 if (w.indexOf(tag) > -1) {
22741 if (this.black.indexOf(tag) > -1) {
22744 this.black.push(tag);
22749 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22750 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22754 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22755 if (b.indexOf(tag) > -1) {
22758 this.cwhite.push(tag);
22762 Roo.each(w, function(tag) {
22763 if (b.indexOf(tag) > -1) {
22766 if (this.cwhite.indexOf(tag) > -1) {
22769 this.cwhite.push(tag);
22774 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22775 if (w.indexOf(tag) > -1) {
22778 this.cblack.push(tag);
22782 Roo.each(b, function(tag) {
22783 if (w.indexOf(tag) > -1) {
22786 if (this.cblack.indexOf(tag) > -1) {
22789 this.cblack.push(tag);
22794 setStylesheets : function(stylesheets)
22796 if(typeof(stylesheets) == 'string'){
22797 Roo.get(this.iframe.contentDocument.head).createChild({
22799 rel : 'stylesheet',
22808 Roo.each(stylesheets, function(s) {
22813 Roo.get(_this.iframe.contentDocument.head).createChild({
22815 rel : 'stylesheet',
22824 removeStylesheets : function()
22828 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22833 setStyle : function(style)
22835 Roo.get(this.iframe.contentDocument.head).createChild({
22844 // hide stuff that is not compatible
22858 * @event specialkey
22862 * @cfg {String} fieldClass @hide
22865 * @cfg {String} focusClass @hide
22868 * @cfg {String} autoCreate @hide
22871 * @cfg {String} inputType @hide
22874 * @cfg {String} invalidClass @hide
22877 * @cfg {String} invalidText @hide
22880 * @cfg {String} msgFx @hide
22883 * @cfg {String} validateOnBlur @hide
22887 Roo.HtmlEditorCore.white = [
22888 'area', 'br', 'img', 'input', 'hr', 'wbr',
22890 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22891 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22892 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22893 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22894 'table', 'ul', 'xmp',
22896 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22899 'dir', 'menu', 'ol', 'ul', 'dl',
22905 Roo.HtmlEditorCore.black = [
22906 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22908 'base', 'basefont', 'bgsound', 'blink', 'body',
22909 'frame', 'frameset', 'head', 'html', 'ilayer',
22910 'iframe', 'layer', 'link', 'meta', 'object',
22911 'script', 'style' ,'title', 'xml' // clean later..
22913 Roo.HtmlEditorCore.clean = [
22914 'script', 'style', 'title', 'xml'
22916 Roo.HtmlEditorCore.remove = [
22921 Roo.HtmlEditorCore.ablack = [
22925 Roo.HtmlEditorCore.aclean = [
22926 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22930 Roo.HtmlEditorCore.pwhite= [
22931 'http', 'https', 'mailto'
22934 // white listed style attributes.
22935 Roo.HtmlEditorCore.cwhite= [
22936 // 'text-align', /// default is to allow most things..
22942 // black listed style attributes.
22943 Roo.HtmlEditorCore.cblack= [
22944 // 'font-size' -- this can be set by the project
22948 Roo.HtmlEditorCore.swapCodes =[
22967 * @class Roo.bootstrap.HtmlEditor
22968 * @extends Roo.bootstrap.TextArea
22969 * Bootstrap HtmlEditor class
22972 * Create a new HtmlEditor
22973 * @param {Object} config The config object
22976 Roo.bootstrap.HtmlEditor = function(config){
22977 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22978 if (!this.toolbars) {
22979 this.toolbars = [];
22982 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22985 * @event initialize
22986 * Fires when the editor is fully initialized (including the iframe)
22987 * @param {HtmlEditor} this
22992 * Fires when the editor is first receives the focus. Any insertion must wait
22993 * until after this event.
22994 * @param {HtmlEditor} this
22998 * @event beforesync
22999 * Fires before the textarea is updated with content from the editor iframe. Return false
23000 * to cancel the sync.
23001 * @param {HtmlEditor} this
23002 * @param {String} html
23006 * @event beforepush
23007 * Fires before the iframe editor is updated with content from the textarea. Return false
23008 * to cancel the push.
23009 * @param {HtmlEditor} this
23010 * @param {String} html
23015 * Fires when the textarea is updated with content from the editor iframe.
23016 * @param {HtmlEditor} this
23017 * @param {String} html
23022 * Fires when the iframe editor is updated with content from the textarea.
23023 * @param {HtmlEditor} this
23024 * @param {String} html
23028 * @event editmodechange
23029 * Fires when the editor switches edit modes
23030 * @param {HtmlEditor} this
23031 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23033 editmodechange: true,
23035 * @event editorevent
23036 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23037 * @param {HtmlEditor} this
23041 * @event firstfocus
23042 * Fires when on first focus - needed by toolbars..
23043 * @param {HtmlEditor} this
23048 * Auto save the htmlEditor value as a file into Events
23049 * @param {HtmlEditor} this
23053 * @event savedpreview
23054 * preview the saved version of htmlEditor
23055 * @param {HtmlEditor} this
23062 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23066 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23071 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23076 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23081 * @cfg {Number} height (in pixels)
23085 * @cfg {Number} width (in pixels)
23090 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23093 stylesheets: false,
23098 // private properties
23099 validationEvent : false,
23101 initialized : false,
23104 onFocus : Roo.emptyFn,
23106 hideMode:'offsets',
23108 tbContainer : false,
23112 toolbarContainer :function() {
23113 return this.wrap.select('.x-html-editor-tb',true).first();
23117 * Protected method that will not generally be called directly. It
23118 * is called when the editor creates its toolbar. Override this method if you need to
23119 * add custom toolbar buttons.
23120 * @param {HtmlEditor} editor
23122 createToolbar : function(){
23123 Roo.log('renewing');
23124 Roo.log("create toolbars");
23126 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23127 this.toolbars[0].render(this.toolbarContainer());
23131 // if (!editor.toolbars || !editor.toolbars.length) {
23132 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23135 // for (var i =0 ; i < editor.toolbars.length;i++) {
23136 // editor.toolbars[i] = Roo.factory(
23137 // typeof(editor.toolbars[i]) == 'string' ?
23138 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23139 // Roo.bootstrap.HtmlEditor);
23140 // editor.toolbars[i].init(editor);
23146 onRender : function(ct, position)
23148 // Roo.log("Call onRender: " + this.xtype);
23150 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23152 this.wrap = this.inputEl().wrap({
23153 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23156 this.editorcore.onRender(ct, position);
23158 if (this.resizable) {
23159 this.resizeEl = new Roo.Resizable(this.wrap, {
23163 minHeight : this.height,
23164 height: this.height,
23165 handles : this.resizable,
23168 resize : function(r, w, h) {
23169 _t.onResize(w,h); // -something
23175 this.createToolbar(this);
23178 if(!this.width && this.resizable){
23179 this.setSize(this.wrap.getSize());
23181 if (this.resizeEl) {
23182 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23183 // should trigger onReize..
23189 onResize : function(w, h)
23191 Roo.log('resize: ' +w + ',' + h );
23192 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23196 if(this.inputEl() ){
23197 if(typeof w == 'number'){
23198 var aw = w - this.wrap.getFrameWidth('lr');
23199 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23202 if(typeof h == 'number'){
23203 var tbh = -11; // fixme it needs to tool bar size!
23204 for (var i =0; i < this.toolbars.length;i++) {
23205 // fixme - ask toolbars for heights?
23206 tbh += this.toolbars[i].el.getHeight();
23207 //if (this.toolbars[i].footer) {
23208 // tbh += this.toolbars[i].footer.el.getHeight();
23216 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23217 ah -= 5; // knock a few pixes off for look..
23218 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23222 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23223 this.editorcore.onResize(ew,eh);
23228 * Toggles the editor between standard and source edit mode.
23229 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23231 toggleSourceEdit : function(sourceEditMode)
23233 this.editorcore.toggleSourceEdit(sourceEditMode);
23235 if(this.editorcore.sourceEditMode){
23236 Roo.log('editor - showing textarea');
23239 // Roo.log(this.syncValue());
23241 this.inputEl().removeClass(['hide', 'x-hidden']);
23242 this.inputEl().dom.removeAttribute('tabIndex');
23243 this.inputEl().focus();
23245 Roo.log('editor - hiding textarea');
23247 // Roo.log(this.pushValue());
23250 this.inputEl().addClass(['hide', 'x-hidden']);
23251 this.inputEl().dom.setAttribute('tabIndex', -1);
23252 //this.deferFocus();
23255 if(this.resizable){
23256 this.setSize(this.wrap.getSize());
23259 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23262 // private (for BoxComponent)
23263 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23265 // private (for BoxComponent)
23266 getResizeEl : function(){
23270 // private (for BoxComponent)
23271 getPositionEl : function(){
23276 initEvents : function(){
23277 this.originalValue = this.getValue();
23281 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23284 // markInvalid : Roo.emptyFn,
23286 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23289 // clearInvalid : Roo.emptyFn,
23291 setValue : function(v){
23292 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23293 this.editorcore.pushValue();
23298 deferFocus : function(){
23299 this.focus.defer(10, this);
23303 focus : function(){
23304 this.editorcore.focus();
23310 onDestroy : function(){
23316 for (var i =0; i < this.toolbars.length;i++) {
23317 // fixme - ask toolbars for heights?
23318 this.toolbars[i].onDestroy();
23321 this.wrap.dom.innerHTML = '';
23322 this.wrap.remove();
23327 onFirstFocus : function(){
23328 //Roo.log("onFirstFocus");
23329 this.editorcore.onFirstFocus();
23330 for (var i =0; i < this.toolbars.length;i++) {
23331 this.toolbars[i].onFirstFocus();
23337 syncValue : function()
23339 this.editorcore.syncValue();
23342 pushValue : function()
23344 this.editorcore.pushValue();
23348 // hide stuff that is not compatible
23362 * @event specialkey
23366 * @cfg {String} fieldClass @hide
23369 * @cfg {String} focusClass @hide
23372 * @cfg {String} autoCreate @hide
23375 * @cfg {String} inputType @hide
23378 * @cfg {String} invalidClass @hide
23381 * @cfg {String} invalidText @hide
23384 * @cfg {String} msgFx @hide
23387 * @cfg {String} validateOnBlur @hide
23396 Roo.namespace('Roo.bootstrap.htmleditor');
23398 * @class Roo.bootstrap.HtmlEditorToolbar1
23403 new Roo.bootstrap.HtmlEditor({
23406 new Roo.bootstrap.HtmlEditorToolbar1({
23407 disable : { fonts: 1 , format: 1, ..., ... , ...],
23413 * @cfg {Object} disable List of elements to disable..
23414 * @cfg {Array} btns List of additional buttons.
23418 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23421 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23424 Roo.apply(this, config);
23426 // default disabled, based on 'good practice'..
23427 this.disable = this.disable || {};
23428 Roo.applyIf(this.disable, {
23431 specialElements : true
23433 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23435 this.editor = config.editor;
23436 this.editorcore = config.editor.editorcore;
23438 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23440 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23441 // dont call parent... till later.
23443 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23448 editorcore : false,
23453 "h1","h2","h3","h4","h5","h6",
23455 "abbr", "acronym", "address", "cite", "samp", "var",
23459 onRender : function(ct, position)
23461 // Roo.log("Call onRender: " + this.xtype);
23463 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23465 this.el.dom.style.marginBottom = '0';
23467 var editorcore = this.editorcore;
23468 var editor= this.editor;
23471 var btn = function(id,cmd , toggle, handler, html){
23473 var event = toggle ? 'toggle' : 'click';
23478 xns: Roo.bootstrap,
23481 enableToggle:toggle !== false,
23483 pressed : toggle ? false : null,
23486 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23487 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23493 // var cb_box = function...
23498 xns: Roo.bootstrap,
23499 glyphicon : 'font',
23503 xns: Roo.bootstrap,
23507 Roo.each(this.formats, function(f) {
23508 style.menu.items.push({
23510 xns: Roo.bootstrap,
23511 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23516 editorcore.insertTag(this.tagname);
23523 children.push(style);
23525 btn('bold',false,true);
23526 btn('italic',false,true);
23527 btn('align-left', 'justifyleft',true);
23528 btn('align-center', 'justifycenter',true);
23529 btn('align-right' , 'justifyright',true);
23530 btn('link', false, false, function(btn) {
23531 //Roo.log("create link?");
23532 var url = prompt(this.createLinkText, this.defaultLinkValue);
23533 if(url && url != 'http:/'+'/'){
23534 this.editorcore.relayCmd('createlink', url);
23537 btn('list','insertunorderedlist',true);
23538 btn('pencil', false,true, function(btn){
23540 this.toggleSourceEdit(btn.pressed);
23543 if (this.editor.btns.length > 0) {
23544 for (var i = 0; i<this.editor.btns.length; i++) {
23545 children.push(this.editor.btns[i]);
23553 xns: Roo.bootstrap,
23558 xns: Roo.bootstrap,
23563 cog.menu.items.push({
23565 xns: Roo.bootstrap,
23566 html : Clean styles,
23571 editorcore.insertTag(this.tagname);
23580 this.xtype = 'NavSimplebar';
23582 for(var i=0;i< children.length;i++) {
23584 this.buttons.add(this.addxtypeChild(children[i]));
23588 editor.on('editorevent', this.updateToolbar, this);
23590 onBtnClick : function(id)
23592 this.editorcore.relayCmd(id);
23593 this.editorcore.focus();
23597 * Protected method that will not generally be called directly. It triggers
23598 * a toolbar update by reading the markup state of the current selection in the editor.
23600 updateToolbar: function(){
23602 if(!this.editorcore.activated){
23603 this.editor.onFirstFocus(); // is this neeed?
23607 var btns = this.buttons;
23608 var doc = this.editorcore.doc;
23609 btns.get('bold').setActive(doc.queryCommandState('bold'));
23610 btns.get('italic').setActive(doc.queryCommandState('italic'));
23611 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23613 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23614 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23615 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23617 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23618 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23621 var ans = this.editorcore.getAllAncestors();
23622 if (this.formatCombo) {
23625 var store = this.formatCombo.store;
23626 this.formatCombo.setValue("");
23627 for (var i =0; i < ans.length;i++) {
23628 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23630 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23638 // hides menus... - so this cant be on a menu...
23639 Roo.bootstrap.MenuMgr.hideAll();
23641 Roo.bootstrap.MenuMgr.hideAll();
23642 //this.editorsyncValue();
23644 onFirstFocus: function() {
23645 this.buttons.each(function(item){
23649 toggleSourceEdit : function(sourceEditMode){
23652 if(sourceEditMode){
23653 Roo.log("disabling buttons");
23654 this.buttons.each( function(item){
23655 if(item.cmd != 'pencil'){
23661 Roo.log("enabling buttons");
23662 if(this.editorcore.initialized){
23663 this.buttons.each( function(item){
23669 Roo.log("calling toggole on editor");
23670 // tell the editor that it's been pressed..
23671 this.editor.toggleSourceEdit(sourceEditMode);
23681 * @class Roo.bootstrap.Table.AbstractSelectionModel
23682 * @extends Roo.util.Observable
23683 * Abstract base class for grid SelectionModels. It provides the interface that should be
23684 * implemented by descendant classes. This class should not be directly instantiated.
23687 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23688 this.locked = false;
23689 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23693 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23694 /** @ignore Called by the grid automatically. Do not call directly. */
23695 init : function(grid){
23701 * Locks the selections.
23704 this.locked = true;
23708 * Unlocks the selections.
23710 unlock : function(){
23711 this.locked = false;
23715 * Returns true if the selections are locked.
23716 * @return {Boolean}
23718 isLocked : function(){
23719 return this.locked;
23723 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23724 * @class Roo.bootstrap.Table.RowSelectionModel
23725 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23726 * It supports multiple selections and keyboard selection/navigation.
23728 * @param {Object} config
23731 Roo.bootstrap.Table.RowSelectionModel = function(config){
23732 Roo.apply(this, config);
23733 this.selections = new Roo.util.MixedCollection(false, function(o){
23738 this.lastActive = false;
23742 * @event selectionchange
23743 * Fires when the selection changes
23744 * @param {SelectionModel} this
23746 "selectionchange" : true,
23748 * @event afterselectionchange
23749 * Fires after the selection changes (eg. by key press or clicking)
23750 * @param {SelectionModel} this
23752 "afterselectionchange" : true,
23754 * @event beforerowselect
23755 * Fires when a row is selected being selected, return false to cancel.
23756 * @param {SelectionModel} this
23757 * @param {Number} rowIndex The selected index
23758 * @param {Boolean} keepExisting False if other selections will be cleared
23760 "beforerowselect" : true,
23763 * Fires when a row is selected.
23764 * @param {SelectionModel} this
23765 * @param {Number} rowIndex The selected index
23766 * @param {Roo.data.Record} r The record
23768 "rowselect" : true,
23770 * @event rowdeselect
23771 * Fires when a row is deselected.
23772 * @param {SelectionModel} this
23773 * @param {Number} rowIndex The selected index
23775 "rowdeselect" : true
23777 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23778 this.locked = false;
23781 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23783 * @cfg {Boolean} singleSelect
23784 * True to allow selection of only one row at a time (defaults to false)
23786 singleSelect : false,
23789 initEvents : function()
23792 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23793 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23794 //}else{ // allow click to work like normal
23795 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23797 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23798 this.grid.on("rowclick", this.handleMouseDown, this);
23800 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23801 "up" : function(e){
23803 this.selectPrevious(e.shiftKey);
23804 }else if(this.last !== false && this.lastActive !== false){
23805 var last = this.last;
23806 this.selectRange(this.last, this.lastActive-1);
23807 this.grid.getView().focusRow(this.lastActive);
23808 if(last !== false){
23812 this.selectFirstRow();
23814 this.fireEvent("afterselectionchange", this);
23816 "down" : function(e){
23818 this.selectNext(e.shiftKey);
23819 }else if(this.last !== false && this.lastActive !== false){
23820 var last = this.last;
23821 this.selectRange(this.last, this.lastActive+1);
23822 this.grid.getView().focusRow(this.lastActive);
23823 if(last !== false){
23827 this.selectFirstRow();
23829 this.fireEvent("afterselectionchange", this);
23833 this.grid.store.on('load', function(){
23834 this.selections.clear();
23837 var view = this.grid.view;
23838 view.on("refresh", this.onRefresh, this);
23839 view.on("rowupdated", this.onRowUpdated, this);
23840 view.on("rowremoved", this.onRemove, this);
23845 onRefresh : function()
23847 var ds = this.grid.store, i, v = this.grid.view;
23848 var s = this.selections;
23849 s.each(function(r){
23850 if((i = ds.indexOfId(r.id)) != -1){
23859 onRemove : function(v, index, r){
23860 this.selections.remove(r);
23864 onRowUpdated : function(v, index, r){
23865 if(this.isSelected(r)){
23866 v.onRowSelect(index);
23872 * @param {Array} records The records to select
23873 * @param {Boolean} keepExisting (optional) True to keep existing selections
23875 selectRecords : function(records, keepExisting)
23878 this.clearSelections();
23880 var ds = this.grid.store;
23881 for(var i = 0, len = records.length; i < len; i++){
23882 this.selectRow(ds.indexOf(records[i]), true);
23887 * Gets the number of selected rows.
23890 getCount : function(){
23891 return this.selections.length;
23895 * Selects the first row in the grid.
23897 selectFirstRow : function(){
23902 * Select the last row.
23903 * @param {Boolean} keepExisting (optional) True to keep existing selections
23905 selectLastRow : function(keepExisting){
23906 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23907 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23911 * Selects the row immediately following the last selected row.
23912 * @param {Boolean} keepExisting (optional) True to keep existing selections
23914 selectNext : function(keepExisting)
23916 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23917 this.selectRow(this.last+1, keepExisting);
23918 this.grid.getView().focusRow(this.last);
23923 * Selects the row that precedes the last selected row.
23924 * @param {Boolean} keepExisting (optional) True to keep existing selections
23926 selectPrevious : function(keepExisting){
23928 this.selectRow(this.last-1, keepExisting);
23929 this.grid.getView().focusRow(this.last);
23934 * Returns the selected records
23935 * @return {Array} Array of selected records
23937 getSelections : function(){
23938 return [].concat(this.selections.items);
23942 * Returns the first selected record.
23945 getSelected : function(){
23946 return this.selections.itemAt(0);
23951 * Clears all selections.
23953 clearSelections : function(fast)
23959 var ds = this.grid.store;
23960 var s = this.selections;
23961 s.each(function(r){
23962 this.deselectRow(ds.indexOfId(r.id));
23966 this.selections.clear();
23973 * Selects all rows.
23975 selectAll : function(){
23979 this.selections.clear();
23980 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23981 this.selectRow(i, true);
23986 * Returns True if there is a selection.
23987 * @return {Boolean}
23989 hasSelection : function(){
23990 return this.selections.length > 0;
23994 * Returns True if the specified row is selected.
23995 * @param {Number/Record} record The record or index of the record to check
23996 * @return {Boolean}
23998 isSelected : function(index){
23999 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24000 return (r && this.selections.key(r.id) ? true : false);
24004 * Returns True if the specified record id is selected.
24005 * @param {String} id The id of record to check
24006 * @return {Boolean}
24008 isIdSelected : function(id){
24009 return (this.selections.key(id) ? true : false);
24014 handleMouseDBClick : function(e, t){
24018 handleMouseDown : function(e, t)
24020 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24021 if(this.isLocked() || rowIndex < 0 ){
24024 if(e.shiftKey && this.last !== false){
24025 var last = this.last;
24026 this.selectRange(last, rowIndex, e.ctrlKey);
24027 this.last = last; // reset the last
24031 var isSelected = this.isSelected(rowIndex);
24032 //Roo.log("select row:" + rowIndex);
24034 this.deselectRow(rowIndex);
24036 this.selectRow(rowIndex, true);
24040 if(e.button !== 0 && isSelected){
24041 alert('rowIndex 2: ' + rowIndex);
24042 view.focusRow(rowIndex);
24043 }else if(e.ctrlKey && isSelected){
24044 this.deselectRow(rowIndex);
24045 }else if(!isSelected){
24046 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24047 view.focusRow(rowIndex);
24051 this.fireEvent("afterselectionchange", this);
24054 handleDragableRowClick : function(grid, rowIndex, e)
24056 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24057 this.selectRow(rowIndex, false);
24058 grid.view.focusRow(rowIndex);
24059 this.fireEvent("afterselectionchange", this);
24064 * Selects multiple rows.
24065 * @param {Array} rows Array of the indexes of the row to select
24066 * @param {Boolean} keepExisting (optional) True to keep existing selections
24068 selectRows : function(rows, keepExisting){
24070 this.clearSelections();
24072 for(var i = 0, len = rows.length; i < len; i++){
24073 this.selectRow(rows[i], true);
24078 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24079 * @param {Number} startRow The index of the first row in the range
24080 * @param {Number} endRow The index of the last row in the range
24081 * @param {Boolean} keepExisting (optional) True to retain existing selections
24083 selectRange : function(startRow, endRow, keepExisting){
24088 this.clearSelections();
24090 if(startRow <= endRow){
24091 for(var i = startRow; i <= endRow; i++){
24092 this.selectRow(i, true);
24095 for(var i = startRow; i >= endRow; i--){
24096 this.selectRow(i, true);
24102 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24103 * @param {Number} startRow The index of the first row in the range
24104 * @param {Number} endRow The index of the last row in the range
24106 deselectRange : function(startRow, endRow, preventViewNotify){
24110 for(var i = startRow; i <= endRow; i++){
24111 this.deselectRow(i, preventViewNotify);
24117 * @param {Number} row The index of the row to select
24118 * @param {Boolean} keepExisting (optional) True to keep existing selections
24120 selectRow : function(index, keepExisting, preventViewNotify)
24122 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24125 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24126 if(!keepExisting || this.singleSelect){
24127 this.clearSelections();
24130 var r = this.grid.store.getAt(index);
24131 //console.log('selectRow - record id :' + r.id);
24133 this.selections.add(r);
24134 this.last = this.lastActive = index;
24135 if(!preventViewNotify){
24136 var proxy = new Roo.Element(
24137 this.grid.getRowDom(index)
24139 proxy.addClass('bg-info info');
24141 this.fireEvent("rowselect", this, index, r);
24142 this.fireEvent("selectionchange", this);
24148 * @param {Number} row The index of the row to deselect
24150 deselectRow : function(index, preventViewNotify)
24155 if(this.last == index){
24158 if(this.lastActive == index){
24159 this.lastActive = false;
24162 var r = this.grid.store.getAt(index);
24167 this.selections.remove(r);
24168 //.console.log('deselectRow - record id :' + r.id);
24169 if(!preventViewNotify){
24171 var proxy = new Roo.Element(
24172 this.grid.getRowDom(index)
24174 proxy.removeClass('bg-info info');
24176 this.fireEvent("rowdeselect", this, index);
24177 this.fireEvent("selectionchange", this);
24181 restoreLast : function(){
24183 this.last = this._last;
24188 acceptsNav : function(row, col, cm){
24189 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24193 onEditorKey : function(field, e){
24194 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24199 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24201 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24203 }else if(k == e.ENTER && !e.ctrlKey){
24207 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24209 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24211 }else if(k == e.ESC){
24215 g.startEditing(newCell[0], newCell[1]);
24221 * Ext JS Library 1.1.1
24222 * Copyright(c) 2006-2007, Ext JS, LLC.
24224 * Originally Released Under LGPL - original licence link has changed is not relivant.
24227 * <script type="text/javascript">
24231 * @class Roo.bootstrap.PagingToolbar
24232 * @extends Roo.bootstrap.NavSimplebar
24233 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24235 * Create a new PagingToolbar
24236 * @param {Object} config The config object
24237 * @param {Roo.data.Store} store
24239 Roo.bootstrap.PagingToolbar = function(config)
24241 // old args format still supported... - xtype is prefered..
24242 // created from xtype...
24244 this.ds = config.dataSource;
24246 if (config.store && !this.ds) {
24247 this.store= Roo.factory(config.store, Roo.data);
24248 this.ds = this.store;
24249 this.ds.xmodule = this.xmodule || false;
24252 this.toolbarItems = [];
24253 if (config.items) {
24254 this.toolbarItems = config.items;
24257 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24262 this.bind(this.ds);
24265 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24269 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24271 * @cfg {Roo.data.Store} dataSource
24272 * The underlying data store providing the paged data
24275 * @cfg {String/HTMLElement/Element} container
24276 * container The id or element that will contain the toolbar
24279 * @cfg {Boolean} displayInfo
24280 * True to display the displayMsg (defaults to false)
24283 * @cfg {Number} pageSize
24284 * The number of records to display per page (defaults to 20)
24288 * @cfg {String} displayMsg
24289 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24291 displayMsg : 'Displaying {0} - {1} of {2}',
24293 * @cfg {String} emptyMsg
24294 * The message to display when no records are found (defaults to "No data to display")
24296 emptyMsg : 'No data to display',
24298 * Customizable piece of the default paging text (defaults to "Page")
24301 beforePageText : "Page",
24303 * Customizable piece of the default paging text (defaults to "of %0")
24306 afterPageText : "of {0}",
24308 * Customizable piece of the default paging text (defaults to "First Page")
24311 firstText : "First Page",
24313 * Customizable piece of the default paging text (defaults to "Previous Page")
24316 prevText : "Previous Page",
24318 * Customizable piece of the default paging text (defaults to "Next Page")
24321 nextText : "Next Page",
24323 * Customizable piece of the default paging text (defaults to "Last Page")
24326 lastText : "Last Page",
24328 * Customizable piece of the default paging text (defaults to "Refresh")
24331 refreshText : "Refresh",
24335 onRender : function(ct, position)
24337 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24338 this.navgroup.parentId = this.id;
24339 this.navgroup.onRender(this.el, null);
24340 // add the buttons to the navgroup
24342 if(this.displayInfo){
24343 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24344 this.displayEl = this.el.select('.x-paging-info', true).first();
24345 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24346 // this.displayEl = navel.el.select('span',true).first();
24352 Roo.each(_this.buttons, function(e){ // this might need to use render????
24353 Roo.factory(e).onRender(_this.el, null);
24357 Roo.each(_this.toolbarItems, function(e) {
24358 _this.navgroup.addItem(e);
24362 this.first = this.navgroup.addItem({
24363 tooltip: this.firstText,
24365 icon : 'fa fa-backward',
24367 preventDefault: true,
24368 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24371 this.prev = this.navgroup.addItem({
24372 tooltip: this.prevText,
24374 icon : 'fa fa-step-backward',
24376 preventDefault: true,
24377 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24379 //this.addSeparator();
24382 var field = this.navgroup.addItem( {
24384 cls : 'x-paging-position',
24386 html : this.beforePageText +
24387 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24388 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24391 this.field = field.el.select('input', true).first();
24392 this.field.on("keydown", this.onPagingKeydown, this);
24393 this.field.on("focus", function(){this.dom.select();});
24396 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24397 //this.field.setHeight(18);
24398 //this.addSeparator();
24399 this.next = this.navgroup.addItem({
24400 tooltip: this.nextText,
24402 html : ' <i class="fa fa-step-forward">',
24404 preventDefault: true,
24405 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24407 this.last = this.navgroup.addItem({
24408 tooltip: this.lastText,
24409 icon : 'fa fa-forward',
24412 preventDefault: true,
24413 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24415 //this.addSeparator();
24416 this.loading = this.navgroup.addItem({
24417 tooltip: this.refreshText,
24418 icon: 'fa fa-refresh',
24419 preventDefault: true,
24420 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24426 updateInfo : function(){
24427 if(this.displayEl){
24428 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24429 var msg = count == 0 ?
24433 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24435 this.displayEl.update(msg);
24440 onLoad : function(ds, r, o)
24442 this.cursor = o.params ? o.params.start : 0;
24443 var d = this.getPageData(),
24448 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24449 this.field.dom.value = ap;
24450 this.first.setDisabled(ap == 1);
24451 this.prev.setDisabled(ap == 1);
24452 this.next.setDisabled(ap == ps);
24453 this.last.setDisabled(ap == ps);
24454 this.loading.enable();
24459 getPageData : function(){
24460 var total = this.ds.getTotalCount();
24463 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24464 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24469 onLoadError : function(){
24470 this.loading.enable();
24474 onPagingKeydown : function(e){
24475 var k = e.getKey();
24476 var d = this.getPageData();
24478 var v = this.field.dom.value, pageNum;
24479 if(!v || isNaN(pageNum = parseInt(v, 10))){
24480 this.field.dom.value = d.activePage;
24483 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24484 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24487 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))
24489 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24490 this.field.dom.value = pageNum;
24491 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24494 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24496 var v = this.field.dom.value, pageNum;
24497 var increment = (e.shiftKey) ? 10 : 1;
24498 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24501 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24502 this.field.dom.value = d.activePage;
24505 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24507 this.field.dom.value = parseInt(v, 10) + increment;
24508 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24509 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24516 beforeLoad : function(){
24518 this.loading.disable();
24523 onClick : function(which){
24532 ds.load({params:{start: 0, limit: this.pageSize}});
24535 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24538 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24541 var total = ds.getTotalCount();
24542 var extra = total % this.pageSize;
24543 var lastStart = extra ? (total - extra) : total-this.pageSize;
24544 ds.load({params:{start: lastStart, limit: this.pageSize}});
24547 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24553 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24554 * @param {Roo.data.Store} store The data store to unbind
24556 unbind : function(ds){
24557 ds.un("beforeload", this.beforeLoad, this);
24558 ds.un("load", this.onLoad, this);
24559 ds.un("loadexception", this.onLoadError, this);
24560 ds.un("remove", this.updateInfo, this);
24561 ds.un("add", this.updateInfo, this);
24562 this.ds = undefined;
24566 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24567 * @param {Roo.data.Store} store The data store to bind
24569 bind : function(ds){
24570 ds.on("beforeload", this.beforeLoad, this);
24571 ds.on("load", this.onLoad, this);
24572 ds.on("loadexception", this.onLoadError, this);
24573 ds.on("remove", this.updateInfo, this);
24574 ds.on("add", this.updateInfo, this);
24585 * @class Roo.bootstrap.MessageBar
24586 * @extends Roo.bootstrap.Component
24587 * Bootstrap MessageBar class
24588 * @cfg {String} html contents of the MessageBar
24589 * @cfg {String} weight (info | success | warning | danger) default info
24590 * @cfg {String} beforeClass insert the bar before the given class
24591 * @cfg {Boolean} closable (true | false) default false
24592 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24595 * Create a new Element
24596 * @param {Object} config The config object
24599 Roo.bootstrap.MessageBar = function(config){
24600 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24603 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24609 beforeClass: 'bootstrap-sticky-wrap',
24611 getAutoCreate : function(){
24615 cls: 'alert alert-dismissable alert-' + this.weight,
24620 html: this.html || ''
24626 cfg.cls += ' alert-messages-fixed';
24640 onRender : function(ct, position)
24642 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24645 var cfg = Roo.apply({}, this.getAutoCreate());
24649 cfg.cls += ' ' + this.cls;
24652 cfg.style = this.style;
24654 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24656 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24659 this.el.select('>button.close').on('click', this.hide, this);
24665 if (!this.rendered) {
24671 this.fireEvent('show', this);
24677 if (!this.rendered) {
24683 this.fireEvent('hide', this);
24686 update : function()
24688 // var e = this.el.dom.firstChild;
24690 // if(this.closable){
24691 // e = e.nextSibling;
24694 // e.data = this.html || '';
24696 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24712 * @class Roo.bootstrap.Graph
24713 * @extends Roo.bootstrap.Component
24714 * Bootstrap Graph class
24718 @cfg {String} graphtype bar | vbar | pie
24719 @cfg {number} g_x coodinator | centre x (pie)
24720 @cfg {number} g_y coodinator | centre y (pie)
24721 @cfg {number} g_r radius (pie)
24722 @cfg {number} g_height height of the chart (respected by all elements in the set)
24723 @cfg {number} g_width width of the chart (respected by all elements in the set)
24724 @cfg {Object} title The title of the chart
24727 -opts (object) options for the chart
24729 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24730 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24732 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.
24733 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24735 o stretch (boolean)
24737 -opts (object) options for the pie
24740 o startAngle (number)
24741 o endAngle (number)
24745 * Create a new Input
24746 * @param {Object} config The config object
24749 Roo.bootstrap.Graph = function(config){
24750 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24756 * The img click event for the img.
24757 * @param {Roo.EventObject} e
24763 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24774 //g_colors: this.colors,
24781 getAutoCreate : function(){
24792 onRender : function(ct,position){
24795 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24797 if (typeof(Raphael) == 'undefined') {
24798 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24802 this.raphael = Raphael(this.el.dom);
24804 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24805 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24806 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24807 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24809 r.text(160, 10, "Single Series Chart").attr(txtattr);
24810 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24811 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24812 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24814 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24815 r.barchart(330, 10, 300, 220, data1);
24816 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24817 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24820 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24821 // r.barchart(30, 30, 560, 250, xdata, {
24822 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24823 // axis : "0 0 1 1",
24824 // axisxlabels : xdata
24825 // //yvalues : cols,
24828 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24830 // this.load(null,xdata,{
24831 // axis : "0 0 1 1",
24832 // axisxlabels : xdata
24837 load : function(graphtype,xdata,opts)
24839 this.raphael.clear();
24841 graphtype = this.graphtype;
24846 var r = this.raphael,
24847 fin = function () {
24848 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24850 fout = function () {
24851 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24853 pfin = function() {
24854 this.sector.stop();
24855 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24858 this.label[0].stop();
24859 this.label[0].attr({ r: 7.5 });
24860 this.label[1].attr({ "font-weight": 800 });
24863 pfout = function() {
24864 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24867 this.label[0].animate({ r: 5 }, 500, "bounce");
24868 this.label[1].attr({ "font-weight": 400 });
24874 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24877 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24880 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24881 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24883 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24890 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24895 setTitle: function(o)
24900 initEvents: function() {
24903 this.el.on('click', this.onClick, this);
24907 onClick : function(e)
24909 Roo.log('img onclick');
24910 this.fireEvent('click', this, e);
24922 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24925 * @class Roo.bootstrap.dash.NumberBox
24926 * @extends Roo.bootstrap.Component
24927 * Bootstrap NumberBox class
24928 * @cfg {String} headline Box headline
24929 * @cfg {String} content Box content
24930 * @cfg {String} icon Box icon
24931 * @cfg {String} footer Footer text
24932 * @cfg {String} fhref Footer href
24935 * Create a new NumberBox
24936 * @param {Object} config The config object
24940 Roo.bootstrap.dash.NumberBox = function(config){
24941 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24945 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24954 getAutoCreate : function(){
24958 cls : 'small-box ',
24966 cls : 'roo-headline',
24967 html : this.headline
24971 cls : 'roo-content',
24972 html : this.content
24986 cls : 'ion ' + this.icon
24995 cls : 'small-box-footer',
24996 href : this.fhref || '#',
25000 cfg.cn.push(footer);
25007 onRender : function(ct,position){
25008 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25015 setHeadline: function (value)
25017 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25020 setFooter: function (value, href)
25022 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25025 this.el.select('a.small-box-footer',true).first().attr('href', href);
25030 setContent: function (value)
25032 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25035 initEvents: function()
25049 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25052 * @class Roo.bootstrap.dash.TabBox
25053 * @extends Roo.bootstrap.Component
25054 * Bootstrap TabBox class
25055 * @cfg {String} title Title of the TabBox
25056 * @cfg {String} icon Icon of the TabBox
25057 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25058 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25061 * Create a new TabBox
25062 * @param {Object} config The config object
25066 Roo.bootstrap.dash.TabBox = function(config){
25067 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25072 * When a pane is added
25073 * @param {Roo.bootstrap.dash.TabPane} pane
25077 * @event activatepane
25078 * When a pane is activated
25079 * @param {Roo.bootstrap.dash.TabPane} pane
25081 "activatepane" : true
25089 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25094 tabScrollable : false,
25096 getChildContainer : function()
25098 return this.el.select('.tab-content', true).first();
25101 getAutoCreate : function(){
25105 cls: 'pull-left header',
25113 cls: 'fa ' + this.icon
25119 cls: 'nav nav-tabs pull-right',
25125 if(this.tabScrollable){
25132 cls: 'nav nav-tabs pull-right',
25143 cls: 'nav-tabs-custom',
25148 cls: 'tab-content no-padding',
25156 initEvents : function()
25158 //Roo.log('add add pane handler');
25159 this.on('addpane', this.onAddPane, this);
25162 * Updates the box title
25163 * @param {String} html to set the title to.
25165 setTitle : function(value)
25167 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25169 onAddPane : function(pane)
25171 this.panes.push(pane);
25172 //Roo.log('addpane');
25174 // tabs are rendere left to right..
25175 if(!this.showtabs){
25179 var ctr = this.el.select('.nav-tabs', true).first();
25182 var existing = ctr.select('.nav-tab',true);
25183 var qty = existing.getCount();;
25186 var tab = ctr.createChild({
25188 cls : 'nav-tab' + (qty ? '' : ' active'),
25196 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25199 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25201 pane.el.addClass('active');
25206 onTabClick : function(ev,un,ob,pane)
25208 //Roo.log('tab - prev default');
25209 ev.preventDefault();
25212 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25213 pane.tab.addClass('active');
25214 //Roo.log(pane.title);
25215 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25216 // technically we should have a deactivate event.. but maybe add later.
25217 // and it should not de-activate the selected tab...
25218 this.fireEvent('activatepane', pane);
25219 pane.el.addClass('active');
25220 pane.fireEvent('activate');
25225 getActivePane : function()
25228 Roo.each(this.panes, function(p) {
25229 if(p.el.hasClass('active')){
25250 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25252 * @class Roo.bootstrap.TabPane
25253 * @extends Roo.bootstrap.Component
25254 * Bootstrap TabPane class
25255 * @cfg {Boolean} active (false | true) Default false
25256 * @cfg {String} title title of panel
25260 * Create a new TabPane
25261 * @param {Object} config The config object
25264 Roo.bootstrap.dash.TabPane = function(config){
25265 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25271 * When a pane is activated
25272 * @param {Roo.bootstrap.dash.TabPane} pane
25279 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25284 // the tabBox that this is attached to.
25287 getAutoCreate : function()
25295 cfg.cls += ' active';
25300 initEvents : function()
25302 //Roo.log('trigger add pane handler');
25303 this.parent().fireEvent('addpane', this)
25307 * Updates the tab title
25308 * @param {String} html to set the title to.
25310 setTitle: function(str)
25316 this.tab.select('a', true).first().dom.innerHTML = str;
25333 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25336 * @class Roo.bootstrap.menu.Menu
25337 * @extends Roo.bootstrap.Component
25338 * Bootstrap Menu class - container for Menu
25339 * @cfg {String} html Text of the menu
25340 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25341 * @cfg {String} icon Font awesome icon
25342 * @cfg {String} pos Menu align to (top | bottom) default bottom
25346 * Create a new Menu
25347 * @param {Object} config The config object
25351 Roo.bootstrap.menu.Menu = function(config){
25352 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25356 * @event beforeshow
25357 * Fires before this menu is displayed
25358 * @param {Roo.bootstrap.menu.Menu} this
25362 * @event beforehide
25363 * Fires before this menu is hidden
25364 * @param {Roo.bootstrap.menu.Menu} this
25369 * Fires after this menu is displayed
25370 * @param {Roo.bootstrap.menu.Menu} this
25375 * Fires after this menu is hidden
25376 * @param {Roo.bootstrap.menu.Menu} this
25381 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25382 * @param {Roo.bootstrap.menu.Menu} this
25383 * @param {Roo.EventObject} e
25390 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25394 weight : 'default',
25399 getChildContainer : function() {
25400 if(this.isSubMenu){
25404 return this.el.select('ul.dropdown-menu', true).first();
25407 getAutoCreate : function()
25412 cls : 'roo-menu-text',
25420 cls : 'fa ' + this.icon
25431 cls : 'dropdown-button btn btn-' + this.weight,
25436 cls : 'dropdown-toggle btn btn-' + this.weight,
25446 cls : 'dropdown-menu'
25452 if(this.pos == 'top'){
25453 cfg.cls += ' dropup';
25456 if(this.isSubMenu){
25459 cls : 'dropdown-menu'
25466 onRender : function(ct, position)
25468 this.isSubMenu = ct.hasClass('dropdown-submenu');
25470 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25473 initEvents : function()
25475 if(this.isSubMenu){
25479 this.hidden = true;
25481 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25482 this.triggerEl.on('click', this.onTriggerPress, this);
25484 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25485 this.buttonEl.on('click', this.onClick, this);
25491 if(this.isSubMenu){
25495 return this.el.select('ul.dropdown-menu', true).first();
25498 onClick : function(e)
25500 this.fireEvent("click", this, e);
25503 onTriggerPress : function(e)
25505 if (this.isVisible()) {
25512 isVisible : function(){
25513 return !this.hidden;
25518 this.fireEvent("beforeshow", this);
25520 this.hidden = false;
25521 this.el.addClass('open');
25523 Roo.get(document).on("mouseup", this.onMouseUp, this);
25525 this.fireEvent("show", this);
25532 this.fireEvent("beforehide", this);
25534 this.hidden = true;
25535 this.el.removeClass('open');
25537 Roo.get(document).un("mouseup", this.onMouseUp);
25539 this.fireEvent("hide", this);
25542 onMouseUp : function()
25556 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25559 * @class Roo.bootstrap.menu.Item
25560 * @extends Roo.bootstrap.Component
25561 * Bootstrap MenuItem class
25562 * @cfg {Boolean} submenu (true | false) default false
25563 * @cfg {String} html text of the item
25564 * @cfg {String} href the link
25565 * @cfg {Boolean} disable (true | false) default false
25566 * @cfg {Boolean} preventDefault (true | false) default true
25567 * @cfg {String} icon Font awesome icon
25568 * @cfg {String} pos Submenu align to (left | right) default right
25572 * Create a new Item
25573 * @param {Object} config The config object
25577 Roo.bootstrap.menu.Item = function(config){
25578 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25582 * Fires when the mouse is hovering over this menu
25583 * @param {Roo.bootstrap.menu.Item} this
25584 * @param {Roo.EventObject} e
25589 * Fires when the mouse exits this menu
25590 * @param {Roo.bootstrap.menu.Item} this
25591 * @param {Roo.EventObject} e
25597 * The raw click event for the entire grid.
25598 * @param {Roo.EventObject} e
25604 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25609 preventDefault: true,
25614 getAutoCreate : function()
25619 cls : 'roo-menu-item-text',
25627 cls : 'fa ' + this.icon
25636 href : this.href || '#',
25643 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25647 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25649 if(this.pos == 'left'){
25650 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25657 initEvents : function()
25659 this.el.on('mouseover', this.onMouseOver, this);
25660 this.el.on('mouseout', this.onMouseOut, this);
25662 this.el.select('a', true).first().on('click', this.onClick, this);
25666 onClick : function(e)
25668 if(this.preventDefault){
25669 e.preventDefault();
25672 this.fireEvent("click", this, e);
25675 onMouseOver : function(e)
25677 if(this.submenu && this.pos == 'left'){
25678 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25681 this.fireEvent("mouseover", this, e);
25684 onMouseOut : function(e)
25686 this.fireEvent("mouseout", this, e);
25698 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25701 * @class Roo.bootstrap.menu.Separator
25702 * @extends Roo.bootstrap.Component
25703 * Bootstrap Separator class
25706 * Create a new Separator
25707 * @param {Object} config The config object
25711 Roo.bootstrap.menu.Separator = function(config){
25712 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25715 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25717 getAutoCreate : function(){
25738 * @class Roo.bootstrap.Tooltip
25739 * Bootstrap Tooltip class
25740 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25741 * to determine which dom element triggers the tooltip.
25743 * It needs to add support for additional attributes like tooltip-position
25746 * Create a new Toolti
25747 * @param {Object} config The config object
25750 Roo.bootstrap.Tooltip = function(config){
25751 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25753 this.alignment = Roo.bootstrap.Tooltip.alignment;
25755 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25756 this.alignment = config.alignment;
25761 Roo.apply(Roo.bootstrap.Tooltip, {
25763 * @function init initialize tooltip monitoring.
25767 currentTip : false,
25768 currentRegion : false,
25774 Roo.get(document).on('mouseover', this.enter ,this);
25775 Roo.get(document).on('mouseout', this.leave, this);
25778 this.currentTip = new Roo.bootstrap.Tooltip();
25781 enter : function(ev)
25783 var dom = ev.getTarget();
25785 //Roo.log(['enter',dom]);
25786 var el = Roo.fly(dom);
25787 if (this.currentEl) {
25789 //Roo.log(this.currentEl);
25790 //Roo.log(this.currentEl.contains(dom));
25791 if (this.currentEl == el) {
25794 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25800 if (this.currentTip.el) {
25801 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25805 if(!el || el.dom == document){
25811 // you can not look for children, as if el is the body.. then everythign is the child..
25812 if (!el.attr('tooltip')) { //
25813 if (!el.select("[tooltip]").elements.length) {
25816 // is the mouse over this child...?
25817 bindEl = el.select("[tooltip]").first();
25818 var xy = ev.getXY();
25819 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25820 //Roo.log("not in region.");
25823 //Roo.log("child element over..");
25826 this.currentEl = bindEl;
25827 this.currentTip.bind(bindEl);
25828 this.currentRegion = Roo.lib.Region.getRegion(dom);
25829 this.currentTip.enter();
25832 leave : function(ev)
25834 var dom = ev.getTarget();
25835 //Roo.log(['leave',dom]);
25836 if (!this.currentEl) {
25841 if (dom != this.currentEl.dom) {
25844 var xy = ev.getXY();
25845 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25848 // only activate leave if mouse cursor is outside... bounding box..
25853 if (this.currentTip) {
25854 this.currentTip.leave();
25856 //Roo.log('clear currentEl');
25857 this.currentEl = false;
25862 'left' : ['r-l', [-2,0], 'right'],
25863 'right' : ['l-r', [2,0], 'left'],
25864 'bottom' : ['t-b', [0,2], 'top'],
25865 'top' : [ 'b-t', [0,-2], 'bottom']
25871 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25876 delay : null, // can be { show : 300 , hide: 500}
25880 hoverState : null, //???
25882 placement : 'bottom',
25886 getAutoCreate : function(){
25893 cls : 'tooltip-arrow'
25896 cls : 'tooltip-inner'
25903 bind : function(el)
25909 enter : function () {
25911 if (this.timeout != null) {
25912 clearTimeout(this.timeout);
25915 this.hoverState = 'in';
25916 //Roo.log("enter - show");
25917 if (!this.delay || !this.delay.show) {
25922 this.timeout = setTimeout(function () {
25923 if (_t.hoverState == 'in') {
25926 }, this.delay.show);
25930 clearTimeout(this.timeout);
25932 this.hoverState = 'out';
25933 if (!this.delay || !this.delay.hide) {
25939 this.timeout = setTimeout(function () {
25940 //Roo.log("leave - timeout");
25942 if (_t.hoverState == 'out') {
25944 Roo.bootstrap.Tooltip.currentEl = false;
25949 show : function (msg)
25952 this.render(document.body);
25955 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25957 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25959 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25961 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25963 var placement = typeof this.placement == 'function' ?
25964 this.placement.call(this, this.el, on_el) :
25967 var autoToken = /\s?auto?\s?/i;
25968 var autoPlace = autoToken.test(placement);
25970 placement = placement.replace(autoToken, '') || 'top';
25974 //this.el.setXY([0,0]);
25976 //this.el.dom.style.display='block';
25978 //this.el.appendTo(on_el);
25980 var p = this.getPosition();
25981 var box = this.el.getBox();
25987 var align = this.alignment[placement];
25989 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25991 if(placement == 'top' || placement == 'bottom'){
25993 placement = 'right';
25996 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25997 placement = 'left';
26000 var scroll = Roo.select('body', true).first().getScroll();
26002 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26008 this.el.alignTo(this.bindEl, align[0],align[1]);
26009 //var arrow = this.el.select('.arrow',true).first();
26010 //arrow.set(align[2],
26012 this.el.addClass(placement);
26014 this.el.addClass('in fade');
26016 this.hoverState = null;
26018 if (this.el.hasClass('fade')) {
26029 //this.el.setXY([0,0]);
26030 this.el.removeClass('in');
26046 * @class Roo.bootstrap.LocationPicker
26047 * @extends Roo.bootstrap.Component
26048 * Bootstrap LocationPicker class
26049 * @cfg {Number} latitude Position when init default 0
26050 * @cfg {Number} longitude Position when init default 0
26051 * @cfg {Number} zoom default 15
26052 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26053 * @cfg {Boolean} mapTypeControl default false
26054 * @cfg {Boolean} disableDoubleClickZoom default false
26055 * @cfg {Boolean} scrollwheel default true
26056 * @cfg {Boolean} streetViewControl default false
26057 * @cfg {Number} radius default 0
26058 * @cfg {String} locationName
26059 * @cfg {Boolean} draggable default true
26060 * @cfg {Boolean} enableAutocomplete default false
26061 * @cfg {Boolean} enableReverseGeocode default true
26062 * @cfg {String} markerTitle
26065 * Create a new LocationPicker
26066 * @param {Object} config The config object
26070 Roo.bootstrap.LocationPicker = function(config){
26072 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26077 * Fires when the picker initialized.
26078 * @param {Roo.bootstrap.LocationPicker} this
26079 * @param {Google Location} location
26083 * @event positionchanged
26084 * Fires when the picker position changed.
26085 * @param {Roo.bootstrap.LocationPicker} this
26086 * @param {Google Location} location
26088 positionchanged : true,
26091 * Fires when the map resize.
26092 * @param {Roo.bootstrap.LocationPicker} this
26097 * Fires when the map show.
26098 * @param {Roo.bootstrap.LocationPicker} this
26103 * Fires when the map hide.
26104 * @param {Roo.bootstrap.LocationPicker} this
26109 * Fires when click the map.
26110 * @param {Roo.bootstrap.LocationPicker} this
26111 * @param {Map event} e
26115 * @event mapRightClick
26116 * Fires when right click the map.
26117 * @param {Roo.bootstrap.LocationPicker} this
26118 * @param {Map event} e
26120 mapRightClick : true,
26122 * @event markerClick
26123 * Fires when click the marker.
26124 * @param {Roo.bootstrap.LocationPicker} this
26125 * @param {Map event} e
26127 markerClick : true,
26129 * @event markerRightClick
26130 * Fires when right click the marker.
26131 * @param {Roo.bootstrap.LocationPicker} this
26132 * @param {Map event} e
26134 markerRightClick : true,
26136 * @event OverlayViewDraw
26137 * Fires when OverlayView Draw
26138 * @param {Roo.bootstrap.LocationPicker} this
26140 OverlayViewDraw : true,
26142 * @event OverlayViewOnAdd
26143 * Fires when OverlayView Draw
26144 * @param {Roo.bootstrap.LocationPicker} this
26146 OverlayViewOnAdd : true,
26148 * @event OverlayViewOnRemove
26149 * Fires when OverlayView Draw
26150 * @param {Roo.bootstrap.LocationPicker} this
26152 OverlayViewOnRemove : true,
26154 * @event OverlayViewShow
26155 * Fires when OverlayView Draw
26156 * @param {Roo.bootstrap.LocationPicker} this
26157 * @param {Pixel} cpx
26159 OverlayViewShow : true,
26161 * @event OverlayViewHide
26162 * Fires when OverlayView Draw
26163 * @param {Roo.bootstrap.LocationPicker} this
26165 OverlayViewHide : true,
26167 * @event loadexception
26168 * Fires when load google lib failed.
26169 * @param {Roo.bootstrap.LocationPicker} this
26171 loadexception : true
26176 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26178 gMapContext: false,
26184 mapTypeControl: false,
26185 disableDoubleClickZoom: false,
26187 streetViewControl: false,
26191 enableAutocomplete: false,
26192 enableReverseGeocode: true,
26195 getAutoCreate: function()
26200 cls: 'roo-location-picker'
26206 initEvents: function(ct, position)
26208 if(!this.el.getWidth() || this.isApplied()){
26212 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26217 initial: function()
26219 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26220 this.fireEvent('loadexception', this);
26224 if(!this.mapTypeId){
26225 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26228 this.gMapContext = this.GMapContext();
26230 this.initOverlayView();
26232 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26236 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26237 _this.setPosition(_this.gMapContext.marker.position);
26240 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26241 _this.fireEvent('mapClick', this, event);
26245 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26246 _this.fireEvent('mapRightClick', this, event);
26250 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26251 _this.fireEvent('markerClick', this, event);
26255 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26256 _this.fireEvent('markerRightClick', this, event);
26260 this.setPosition(this.gMapContext.location);
26262 this.fireEvent('initial', this, this.gMapContext.location);
26265 initOverlayView: function()
26269 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26273 _this.fireEvent('OverlayViewDraw', _this);
26278 _this.fireEvent('OverlayViewOnAdd', _this);
26281 onRemove: function()
26283 _this.fireEvent('OverlayViewOnRemove', _this);
26286 show: function(cpx)
26288 _this.fireEvent('OverlayViewShow', _this, cpx);
26293 _this.fireEvent('OverlayViewHide', _this);
26299 fromLatLngToContainerPixel: function(event)
26301 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26304 isApplied: function()
26306 return this.getGmapContext() == false ? false : true;
26309 getGmapContext: function()
26311 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26314 GMapContext: function()
26316 var position = new google.maps.LatLng(this.latitude, this.longitude);
26318 var _map = new google.maps.Map(this.el.dom, {
26321 mapTypeId: this.mapTypeId,
26322 mapTypeControl: this.mapTypeControl,
26323 disableDoubleClickZoom: this.disableDoubleClickZoom,
26324 scrollwheel: this.scrollwheel,
26325 streetViewControl: this.streetViewControl,
26326 locationName: this.locationName,
26327 draggable: this.draggable,
26328 enableAutocomplete: this.enableAutocomplete,
26329 enableReverseGeocode: this.enableReverseGeocode
26332 var _marker = new google.maps.Marker({
26333 position: position,
26335 title: this.markerTitle,
26336 draggable: this.draggable
26343 location: position,
26344 radius: this.radius,
26345 locationName: this.locationName,
26346 addressComponents: {
26347 formatted_address: null,
26348 addressLine1: null,
26349 addressLine2: null,
26351 streetNumber: null,
26355 stateOrProvince: null
26358 domContainer: this.el.dom,
26359 geodecoder: new google.maps.Geocoder()
26363 drawCircle: function(center, radius, options)
26365 if (this.gMapContext.circle != null) {
26366 this.gMapContext.circle.setMap(null);
26370 options = Roo.apply({}, options, {
26371 strokeColor: "#0000FF",
26372 strokeOpacity: .35,
26374 fillColor: "#0000FF",
26378 options.map = this.gMapContext.map;
26379 options.radius = radius;
26380 options.center = center;
26381 this.gMapContext.circle = new google.maps.Circle(options);
26382 return this.gMapContext.circle;
26388 setPosition: function(location)
26390 this.gMapContext.location = location;
26391 this.gMapContext.marker.setPosition(location);
26392 this.gMapContext.map.panTo(location);
26393 this.drawCircle(location, this.gMapContext.radius, {});
26397 if (this.gMapContext.settings.enableReverseGeocode) {
26398 this.gMapContext.geodecoder.geocode({
26399 latLng: this.gMapContext.location
26400 }, function(results, status) {
26402 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26403 _this.gMapContext.locationName = results[0].formatted_address;
26404 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26406 _this.fireEvent('positionchanged', this, location);
26413 this.fireEvent('positionchanged', this, location);
26418 google.maps.event.trigger(this.gMapContext.map, "resize");
26420 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26422 this.fireEvent('resize', this);
26425 setPositionByLatLng: function(latitude, longitude)
26427 this.setPosition(new google.maps.LatLng(latitude, longitude));
26430 getCurrentPosition: function()
26433 latitude: this.gMapContext.location.lat(),
26434 longitude: this.gMapContext.location.lng()
26438 getAddressName: function()
26440 return this.gMapContext.locationName;
26443 getAddressComponents: function()
26445 return this.gMapContext.addressComponents;
26448 address_component_from_google_geocode: function(address_components)
26452 for (var i = 0; i < address_components.length; i++) {
26453 var component = address_components[i];
26454 if (component.types.indexOf("postal_code") >= 0) {
26455 result.postalCode = component.short_name;
26456 } else if (component.types.indexOf("street_number") >= 0) {
26457 result.streetNumber = component.short_name;
26458 } else if (component.types.indexOf("route") >= 0) {
26459 result.streetName = component.short_name;
26460 } else if (component.types.indexOf("neighborhood") >= 0) {
26461 result.city = component.short_name;
26462 } else if (component.types.indexOf("locality") >= 0) {
26463 result.city = component.short_name;
26464 } else if (component.types.indexOf("sublocality") >= 0) {
26465 result.district = component.short_name;
26466 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26467 result.stateOrProvince = component.short_name;
26468 } else if (component.types.indexOf("country") >= 0) {
26469 result.country = component.short_name;
26473 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26474 result.addressLine2 = "";
26478 setZoomLevel: function(zoom)
26480 this.gMapContext.map.setZoom(zoom);
26493 this.fireEvent('show', this);
26504 this.fireEvent('hide', this);
26509 Roo.apply(Roo.bootstrap.LocationPicker, {
26511 OverlayView : function(map, options)
26513 options = options || {};
26527 * @class Roo.bootstrap.Alert
26528 * @extends Roo.bootstrap.Component
26529 * Bootstrap Alert class
26530 * @cfg {String} title The title of alert
26531 * @cfg {String} html The content of alert
26532 * @cfg {String} weight ( success | info | warning | danger )
26533 * @cfg {String} faicon font-awesomeicon
26536 * Create a new alert
26537 * @param {Object} config The config object
26541 Roo.bootstrap.Alert = function(config){
26542 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26546 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26553 getAutoCreate : function()
26562 cls : 'roo-alert-icon'
26567 cls : 'roo-alert-title',
26572 cls : 'roo-alert-text',
26579 cfg.cn[0].cls += ' fa ' + this.faicon;
26583 cfg.cls += ' alert-' + this.weight;
26589 initEvents: function()
26591 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26594 setTitle : function(str)
26596 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26599 setText : function(str)
26601 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26604 setWeight : function(weight)
26607 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26610 this.weight = weight;
26612 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26615 setIcon : function(icon)
26618 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26621 this.faicon = icon;
26623 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26644 * @class Roo.bootstrap.UploadCropbox
26645 * @extends Roo.bootstrap.Component
26646 * Bootstrap UploadCropbox class
26647 * @cfg {String} emptyText show when image has been loaded
26648 * @cfg {String} rotateNotify show when image too small to rotate
26649 * @cfg {Number} errorTimeout default 3000
26650 * @cfg {Number} minWidth default 300
26651 * @cfg {Number} minHeight default 300
26652 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26653 * @cfg {Boolean} isDocument (true|false) default false
26654 * @cfg {String} url action url
26655 * @cfg {String} paramName default 'imageUpload'
26656 * @cfg {String} method default POST
26657 * @cfg {Boolean} loadMask (true|false) default true
26658 * @cfg {Boolean} loadingText default 'Loading...'
26661 * Create a new UploadCropbox
26662 * @param {Object} config The config object
26665 Roo.bootstrap.UploadCropbox = function(config){
26666 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26670 * @event beforeselectfile
26671 * Fire before select file
26672 * @param {Roo.bootstrap.UploadCropbox} this
26674 "beforeselectfile" : true,
26677 * Fire after initEvent
26678 * @param {Roo.bootstrap.UploadCropbox} this
26683 * Fire after initEvent
26684 * @param {Roo.bootstrap.UploadCropbox} this
26685 * @param {String} data
26690 * Fire when preparing the file data
26691 * @param {Roo.bootstrap.UploadCropbox} this
26692 * @param {Object} file
26697 * Fire when get exception
26698 * @param {Roo.bootstrap.UploadCropbox} this
26699 * @param {XMLHttpRequest} xhr
26701 "exception" : true,
26703 * @event beforeloadcanvas
26704 * Fire before load the canvas
26705 * @param {Roo.bootstrap.UploadCropbox} this
26706 * @param {String} src
26708 "beforeloadcanvas" : true,
26711 * Fire when trash image
26712 * @param {Roo.bootstrap.UploadCropbox} this
26717 * Fire when download the image
26718 * @param {Roo.bootstrap.UploadCropbox} this
26722 * @event footerbuttonclick
26723 * Fire when footerbuttonclick
26724 * @param {Roo.bootstrap.UploadCropbox} this
26725 * @param {String} type
26727 "footerbuttonclick" : true,
26731 * @param {Roo.bootstrap.UploadCropbox} this
26736 * Fire when rotate the image
26737 * @param {Roo.bootstrap.UploadCropbox} this
26738 * @param {String} pos
26743 * Fire when inspect the file
26744 * @param {Roo.bootstrap.UploadCropbox} this
26745 * @param {Object} file
26750 * Fire when xhr upload the file
26751 * @param {Roo.bootstrap.UploadCropbox} this
26752 * @param {Object} data
26757 * Fire when arrange the file data
26758 * @param {Roo.bootstrap.UploadCropbox} this
26759 * @param {Object} formData
26764 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26767 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26769 emptyText : 'Click to upload image',
26770 rotateNotify : 'Image is too small to rotate',
26771 errorTimeout : 3000,
26785 cropType : 'image/jpeg',
26787 canvasLoaded : false,
26788 isDocument : false,
26790 paramName : 'imageUpload',
26792 loadingText : 'Loading...',
26795 getAutoCreate : function()
26799 cls : 'roo-upload-cropbox',
26803 cls : 'roo-upload-cropbox-selector',
26808 cls : 'roo-upload-cropbox-body',
26809 style : 'cursor:pointer',
26813 cls : 'roo-upload-cropbox-preview'
26817 cls : 'roo-upload-cropbox-thumb'
26821 cls : 'roo-upload-cropbox-empty-notify',
26822 html : this.emptyText
26826 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26827 html : this.rotateNotify
26833 cls : 'roo-upload-cropbox-footer',
26836 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26846 onRender : function(ct, position)
26848 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26850 if (this.buttons.length) {
26852 Roo.each(this.buttons, function(bb) {
26854 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26856 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26862 this.maskEl = this.el;
26866 initEvents : function()
26868 this.urlAPI = (window.createObjectURL && window) ||
26869 (window.URL && URL.revokeObjectURL && URL) ||
26870 (window.webkitURL && webkitURL);
26872 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26873 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26875 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26876 this.selectorEl.hide();
26878 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26879 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26881 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26882 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26883 this.thumbEl.hide();
26885 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26886 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26888 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26889 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26890 this.errorEl.hide();
26892 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26893 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26894 this.footerEl.hide();
26896 this.setThumbBoxSize();
26902 this.fireEvent('initial', this);
26909 window.addEventListener("resize", function() { _this.resize(); } );
26911 this.bodyEl.on('click', this.beforeSelectFile, this);
26914 this.bodyEl.on('touchstart', this.onTouchStart, this);
26915 this.bodyEl.on('touchmove', this.onTouchMove, this);
26916 this.bodyEl.on('touchend', this.onTouchEnd, this);
26920 this.bodyEl.on('mousedown', this.onMouseDown, this);
26921 this.bodyEl.on('mousemove', this.onMouseMove, this);
26922 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26923 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26924 Roo.get(document).on('mouseup', this.onMouseUp, this);
26927 this.selectorEl.on('change', this.onFileSelected, this);
26933 this.baseScale = 1;
26935 this.baseRotate = 1;
26936 this.dragable = false;
26937 this.pinching = false;
26940 this.cropData = false;
26941 this.notifyEl.dom.innerHTML = this.emptyText;
26943 this.selectorEl.dom.value = '';
26947 resize : function()
26949 if(this.fireEvent('resize', this) != false){
26950 this.setThumbBoxPosition();
26951 this.setCanvasPosition();
26955 onFooterButtonClick : function(e, el, o, type)
26958 case 'rotate-left' :
26959 this.onRotateLeft(e);
26961 case 'rotate-right' :
26962 this.onRotateRight(e);
26965 this.beforeSelectFile(e);
26980 this.fireEvent('footerbuttonclick', this, type);
26983 beforeSelectFile : function(e)
26985 e.preventDefault();
26987 if(this.fireEvent('beforeselectfile', this) != false){
26988 this.selectorEl.dom.click();
26992 onFileSelected : function(e)
26994 e.preventDefault();
26996 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27000 var file = this.selectorEl.dom.files[0];
27002 if(this.fireEvent('inspect', this, file) != false){
27003 this.prepare(file);
27008 trash : function(e)
27010 this.fireEvent('trash', this);
27013 download : function(e)
27015 this.fireEvent('download', this);
27018 loadCanvas : function(src)
27020 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27024 this.imageEl = document.createElement('img');
27028 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27030 this.imageEl.src = src;
27034 onLoadCanvas : function()
27036 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27037 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27039 this.bodyEl.un('click', this.beforeSelectFile, this);
27041 this.notifyEl.hide();
27042 this.thumbEl.show();
27043 this.footerEl.show();
27045 this.baseRotateLevel();
27047 if(this.isDocument){
27048 this.setThumbBoxSize();
27051 this.setThumbBoxPosition();
27053 this.baseScaleLevel();
27059 this.canvasLoaded = true;
27062 this.maskEl.unmask();
27067 setCanvasPosition : function()
27069 if(!this.canvasEl){
27073 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27074 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27076 this.previewEl.setLeft(pw);
27077 this.previewEl.setTop(ph);
27081 onMouseDown : function(e)
27085 this.dragable = true;
27086 this.pinching = false;
27088 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27089 this.dragable = false;
27093 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27094 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27098 onMouseMove : function(e)
27102 if(!this.canvasLoaded){
27106 if (!this.dragable){
27110 var minX = Math.ceil(this.thumbEl.getLeft(true));
27111 var minY = Math.ceil(this.thumbEl.getTop(true));
27113 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27114 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27116 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27117 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27119 x = x - this.mouseX;
27120 y = y - this.mouseY;
27122 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27123 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27125 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27126 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27128 this.previewEl.setLeft(bgX);
27129 this.previewEl.setTop(bgY);
27131 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27132 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27135 onMouseUp : function(e)
27139 this.dragable = false;
27142 onMouseWheel : function(e)
27146 this.startScale = this.scale;
27148 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27150 if(!this.zoomable()){
27151 this.scale = this.startScale;
27160 zoomable : function()
27162 var minScale = this.thumbEl.getWidth() / this.minWidth;
27164 if(this.minWidth < this.minHeight){
27165 minScale = this.thumbEl.getHeight() / this.minHeight;
27168 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27169 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27173 (this.rotate == 0 || this.rotate == 180) &&
27175 width > this.imageEl.OriginWidth ||
27176 height > this.imageEl.OriginHeight ||
27177 (width < this.minWidth && height < this.minHeight)
27185 (this.rotate == 90 || this.rotate == 270) &&
27187 width > this.imageEl.OriginWidth ||
27188 height > this.imageEl.OriginHeight ||
27189 (width < this.minHeight && height < this.minWidth)
27196 !this.isDocument &&
27197 (this.rotate == 0 || this.rotate == 180) &&
27199 width < this.minWidth ||
27200 width > this.imageEl.OriginWidth ||
27201 height < this.minHeight ||
27202 height > this.imageEl.OriginHeight
27209 !this.isDocument &&
27210 (this.rotate == 90 || this.rotate == 270) &&
27212 width < this.minHeight ||
27213 width > this.imageEl.OriginWidth ||
27214 height < this.minWidth ||
27215 height > this.imageEl.OriginHeight
27225 onRotateLeft : function(e)
27227 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27229 var minScale = this.thumbEl.getWidth() / this.minWidth;
27231 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27232 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27234 this.startScale = this.scale;
27236 while (this.getScaleLevel() < minScale){
27238 this.scale = this.scale + 1;
27240 if(!this.zoomable()){
27245 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27246 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27251 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27258 this.scale = this.startScale;
27260 this.onRotateFail();
27265 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27267 if(this.isDocument){
27268 this.setThumbBoxSize();
27269 this.setThumbBoxPosition();
27270 this.setCanvasPosition();
27275 this.fireEvent('rotate', this, 'left');
27279 onRotateRight : function(e)
27281 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27283 var minScale = this.thumbEl.getWidth() / this.minWidth;
27285 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27286 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27288 this.startScale = this.scale;
27290 while (this.getScaleLevel() < minScale){
27292 this.scale = this.scale + 1;
27294 if(!this.zoomable()){
27299 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27300 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27305 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27312 this.scale = this.startScale;
27314 this.onRotateFail();
27319 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27321 if(this.isDocument){
27322 this.setThumbBoxSize();
27323 this.setThumbBoxPosition();
27324 this.setCanvasPosition();
27329 this.fireEvent('rotate', this, 'right');
27332 onRotateFail : function()
27334 this.errorEl.show(true);
27338 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27343 this.previewEl.dom.innerHTML = '';
27345 var canvasEl = document.createElement("canvas");
27347 var contextEl = canvasEl.getContext("2d");
27349 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27350 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27351 var center = this.imageEl.OriginWidth / 2;
27353 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27354 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27355 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27356 center = this.imageEl.OriginHeight / 2;
27359 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27361 contextEl.translate(center, center);
27362 contextEl.rotate(this.rotate * Math.PI / 180);
27364 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27366 this.canvasEl = document.createElement("canvas");
27368 this.contextEl = this.canvasEl.getContext("2d");
27370 switch (this.rotate) {
27373 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27374 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27376 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27381 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27382 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27384 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27385 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);
27389 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27394 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27395 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27397 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27398 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);
27402 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);
27407 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27408 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27410 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27411 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27415 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);
27422 this.previewEl.appendChild(this.canvasEl);
27424 this.setCanvasPosition();
27429 if(!this.canvasLoaded){
27433 var imageCanvas = document.createElement("canvas");
27435 var imageContext = imageCanvas.getContext("2d");
27437 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27438 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27440 var center = imageCanvas.width / 2;
27442 imageContext.translate(center, center);
27444 imageContext.rotate(this.rotate * Math.PI / 180);
27446 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27448 var canvas = document.createElement("canvas");
27450 var context = canvas.getContext("2d");
27452 canvas.width = this.minWidth;
27453 canvas.height = this.minHeight;
27455 switch (this.rotate) {
27458 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27459 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27461 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27462 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27464 var targetWidth = this.minWidth - 2 * x;
27465 var targetHeight = this.minHeight - 2 * y;
27469 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27470 scale = targetWidth / width;
27473 if(x > 0 && y == 0){
27474 scale = targetHeight / height;
27477 if(x > 0 && y > 0){
27478 scale = targetWidth / width;
27480 if(width < height){
27481 scale = targetHeight / height;
27485 context.scale(scale, scale);
27487 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27488 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27490 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27491 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27493 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27498 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27499 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27501 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27502 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27504 var targetWidth = this.minWidth - 2 * x;
27505 var targetHeight = this.minHeight - 2 * y;
27509 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27510 scale = targetWidth / width;
27513 if(x > 0 && y == 0){
27514 scale = targetHeight / height;
27517 if(x > 0 && y > 0){
27518 scale = targetWidth / width;
27520 if(width < height){
27521 scale = targetHeight / height;
27525 context.scale(scale, scale);
27527 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27528 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27530 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27531 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27533 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27535 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27540 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27541 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27543 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27544 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27546 var targetWidth = this.minWidth - 2 * x;
27547 var targetHeight = this.minHeight - 2 * y;
27551 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27552 scale = targetWidth / width;
27555 if(x > 0 && y == 0){
27556 scale = targetHeight / height;
27559 if(x > 0 && y > 0){
27560 scale = targetWidth / width;
27562 if(width < height){
27563 scale = targetHeight / height;
27567 context.scale(scale, scale);
27569 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27570 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27572 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27573 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27575 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27576 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27578 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27583 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27584 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27586 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27587 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27589 var targetWidth = this.minWidth - 2 * x;
27590 var targetHeight = this.minHeight - 2 * y;
27594 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27595 scale = targetWidth / width;
27598 if(x > 0 && y == 0){
27599 scale = targetHeight / height;
27602 if(x > 0 && y > 0){
27603 scale = targetWidth / width;
27605 if(width < height){
27606 scale = targetHeight / height;
27610 context.scale(scale, scale);
27612 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27613 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27615 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27616 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27618 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27620 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27627 this.cropData = canvas.toDataURL(this.cropType);
27629 if(this.fireEvent('crop', this, this.cropData) !== false){
27630 this.process(this.file, this.cropData);
27637 setThumbBoxSize : function()
27641 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27642 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27643 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27645 this.minWidth = width;
27646 this.minHeight = height;
27648 if(this.rotate == 90 || this.rotate == 270){
27649 this.minWidth = height;
27650 this.minHeight = width;
27655 width = Math.ceil(this.minWidth * height / this.minHeight);
27657 if(this.minWidth > this.minHeight){
27659 height = Math.ceil(this.minHeight * width / this.minWidth);
27662 this.thumbEl.setStyle({
27663 width : width + 'px',
27664 height : height + 'px'
27671 setThumbBoxPosition : function()
27673 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27674 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27676 this.thumbEl.setLeft(x);
27677 this.thumbEl.setTop(y);
27681 baseRotateLevel : function()
27683 this.baseRotate = 1;
27686 typeof(this.exif) != 'undefined' &&
27687 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27688 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27690 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27693 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27697 baseScaleLevel : function()
27701 if(this.isDocument){
27703 if(this.baseRotate == 6 || this.baseRotate == 8){
27705 height = this.thumbEl.getHeight();
27706 this.baseScale = height / this.imageEl.OriginWidth;
27708 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27709 width = this.thumbEl.getWidth();
27710 this.baseScale = width / this.imageEl.OriginHeight;
27716 height = this.thumbEl.getHeight();
27717 this.baseScale = height / this.imageEl.OriginHeight;
27719 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27720 width = this.thumbEl.getWidth();
27721 this.baseScale = width / this.imageEl.OriginWidth;
27727 if(this.baseRotate == 6 || this.baseRotate == 8){
27729 width = this.thumbEl.getHeight();
27730 this.baseScale = width / this.imageEl.OriginHeight;
27732 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27733 height = this.thumbEl.getWidth();
27734 this.baseScale = height / this.imageEl.OriginHeight;
27737 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27738 height = this.thumbEl.getWidth();
27739 this.baseScale = height / this.imageEl.OriginHeight;
27741 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27742 width = this.thumbEl.getHeight();
27743 this.baseScale = width / this.imageEl.OriginWidth;
27750 width = this.thumbEl.getWidth();
27751 this.baseScale = width / this.imageEl.OriginWidth;
27753 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27754 height = this.thumbEl.getHeight();
27755 this.baseScale = height / this.imageEl.OriginHeight;
27758 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27760 height = this.thumbEl.getHeight();
27761 this.baseScale = height / this.imageEl.OriginHeight;
27763 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27764 width = this.thumbEl.getWidth();
27765 this.baseScale = width / this.imageEl.OriginWidth;
27773 getScaleLevel : function()
27775 return this.baseScale * Math.pow(1.1, this.scale);
27778 onTouchStart : function(e)
27780 if(!this.canvasLoaded){
27781 this.beforeSelectFile(e);
27785 var touches = e.browserEvent.touches;
27791 if(touches.length == 1){
27792 this.onMouseDown(e);
27796 if(touches.length != 2){
27802 for(var i = 0, finger; finger = touches[i]; i++){
27803 coords.push(finger.pageX, finger.pageY);
27806 var x = Math.pow(coords[0] - coords[2], 2);
27807 var y = Math.pow(coords[1] - coords[3], 2);
27809 this.startDistance = Math.sqrt(x + y);
27811 this.startScale = this.scale;
27813 this.pinching = true;
27814 this.dragable = false;
27818 onTouchMove : function(e)
27820 if(!this.pinching && !this.dragable){
27824 var touches = e.browserEvent.touches;
27831 this.onMouseMove(e);
27837 for(var i = 0, finger; finger = touches[i]; i++){
27838 coords.push(finger.pageX, finger.pageY);
27841 var x = Math.pow(coords[0] - coords[2], 2);
27842 var y = Math.pow(coords[1] - coords[3], 2);
27844 this.endDistance = Math.sqrt(x + y);
27846 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27848 if(!this.zoomable()){
27849 this.scale = this.startScale;
27857 onTouchEnd : function(e)
27859 this.pinching = false;
27860 this.dragable = false;
27864 process : function(file, crop)
27867 this.maskEl.mask(this.loadingText);
27870 this.xhr = new XMLHttpRequest();
27872 file.xhr = this.xhr;
27874 this.xhr.open(this.method, this.url, true);
27877 "Accept": "application/json",
27878 "Cache-Control": "no-cache",
27879 "X-Requested-With": "XMLHttpRequest"
27882 for (var headerName in headers) {
27883 var headerValue = headers[headerName];
27885 this.xhr.setRequestHeader(headerName, headerValue);
27891 this.xhr.onload = function()
27893 _this.xhrOnLoad(_this.xhr);
27896 this.xhr.onerror = function()
27898 _this.xhrOnError(_this.xhr);
27901 var formData = new FormData();
27903 formData.append('returnHTML', 'NO');
27906 formData.append('crop', crop);
27909 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27910 formData.append(this.paramName, file, file.name);
27913 if(typeof(file.filename) != 'undefined'){
27914 formData.append('filename', file.filename);
27917 if(typeof(file.mimetype) != 'undefined'){
27918 formData.append('mimetype', file.mimetype);
27921 if(this.fireEvent('arrange', this, formData) != false){
27922 this.xhr.send(formData);
27926 xhrOnLoad : function(xhr)
27929 this.maskEl.unmask();
27932 if (xhr.readyState !== 4) {
27933 this.fireEvent('exception', this, xhr);
27937 var response = Roo.decode(xhr.responseText);
27939 if(!response.success){
27940 this.fireEvent('exception', this, xhr);
27944 var response = Roo.decode(xhr.responseText);
27946 this.fireEvent('upload', this, response);
27950 xhrOnError : function()
27953 this.maskEl.unmask();
27956 Roo.log('xhr on error');
27958 var response = Roo.decode(xhr.responseText);
27964 prepare : function(file)
27967 this.maskEl.mask(this.loadingText);
27973 if(typeof(file) === 'string'){
27974 this.loadCanvas(file);
27978 if(!file || !this.urlAPI){
27983 this.cropType = file.type;
27987 if(this.fireEvent('prepare', this, this.file) != false){
27989 var reader = new FileReader();
27991 reader.onload = function (e) {
27992 if (e.target.error) {
27993 Roo.log(e.target.error);
27997 var buffer = e.target.result,
27998 dataView = new DataView(buffer),
28000 maxOffset = dataView.byteLength - 4,
28004 if (dataView.getUint16(0) === 0xffd8) {
28005 while (offset < maxOffset) {
28006 markerBytes = dataView.getUint16(offset);
28008 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28009 markerLength = dataView.getUint16(offset + 2) + 2;
28010 if (offset + markerLength > dataView.byteLength) {
28011 Roo.log('Invalid meta data: Invalid segment size.');
28015 if(markerBytes == 0xffe1){
28016 _this.parseExifData(
28023 offset += markerLength;
28033 var url = _this.urlAPI.createObjectURL(_this.file);
28035 _this.loadCanvas(url);
28040 reader.readAsArrayBuffer(this.file);
28046 parseExifData : function(dataView, offset, length)
28048 var tiffOffset = offset + 10,
28052 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28053 // No Exif data, might be XMP data instead
28057 // Check for the ASCII code for "Exif" (0x45786966):
28058 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28059 // No Exif data, might be XMP data instead
28062 if (tiffOffset + 8 > dataView.byteLength) {
28063 Roo.log('Invalid Exif data: Invalid segment size.');
28066 // Check for the two null bytes:
28067 if (dataView.getUint16(offset + 8) !== 0x0000) {
28068 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28071 // Check the byte alignment:
28072 switch (dataView.getUint16(tiffOffset)) {
28074 littleEndian = true;
28077 littleEndian = false;
28080 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28083 // Check for the TIFF tag marker (0x002A):
28084 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28085 Roo.log('Invalid Exif data: Missing TIFF marker.');
28088 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28089 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28091 this.parseExifTags(
28094 tiffOffset + dirOffset,
28099 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28104 if (dirOffset + 6 > dataView.byteLength) {
28105 Roo.log('Invalid Exif data: Invalid directory offset.');
28108 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28109 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28110 if (dirEndOffset + 4 > dataView.byteLength) {
28111 Roo.log('Invalid Exif data: Invalid directory size.');
28114 for (i = 0; i < tagsNumber; i += 1) {
28118 dirOffset + 2 + 12 * i, // tag offset
28122 // Return the offset to the next directory:
28123 return dataView.getUint32(dirEndOffset, littleEndian);
28126 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28128 var tag = dataView.getUint16(offset, littleEndian);
28130 this.exif[tag] = this.getExifValue(
28134 dataView.getUint16(offset + 2, littleEndian), // tag type
28135 dataView.getUint32(offset + 4, littleEndian), // tag length
28140 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28142 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28151 Roo.log('Invalid Exif data: Invalid tag type.');
28155 tagSize = tagType.size * length;
28156 // Determine if the value is contained in the dataOffset bytes,
28157 // or if the value at the dataOffset is a pointer to the actual data:
28158 dataOffset = tagSize > 4 ?
28159 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28160 if (dataOffset + tagSize > dataView.byteLength) {
28161 Roo.log('Invalid Exif data: Invalid data offset.');
28164 if (length === 1) {
28165 return tagType.getValue(dataView, dataOffset, littleEndian);
28168 for (i = 0; i < length; i += 1) {
28169 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28172 if (tagType.ascii) {
28174 // Concatenate the chars:
28175 for (i = 0; i < values.length; i += 1) {
28177 // Ignore the terminating NULL byte(s):
28178 if (c === '\u0000') {
28190 Roo.apply(Roo.bootstrap.UploadCropbox, {
28192 'Orientation': 0x0112
28196 1: 0, //'top-left',
28198 3: 180, //'bottom-right',
28199 // 4: 'bottom-left',
28201 6: 90, //'right-top',
28202 // 7: 'right-bottom',
28203 8: 270 //'left-bottom'
28207 // byte, 8-bit unsigned int:
28209 getValue: function (dataView, dataOffset) {
28210 return dataView.getUint8(dataOffset);
28214 // ascii, 8-bit byte:
28216 getValue: function (dataView, dataOffset) {
28217 return String.fromCharCode(dataView.getUint8(dataOffset));
28222 // short, 16 bit int:
28224 getValue: function (dataView, dataOffset, littleEndian) {
28225 return dataView.getUint16(dataOffset, littleEndian);
28229 // long, 32 bit int:
28231 getValue: function (dataView, dataOffset, littleEndian) {
28232 return dataView.getUint32(dataOffset, littleEndian);
28236 // rational = two long values, first is numerator, second is denominator:
28238 getValue: function (dataView, dataOffset, littleEndian) {
28239 return dataView.getUint32(dataOffset, littleEndian) /
28240 dataView.getUint32(dataOffset + 4, littleEndian);
28244 // slong, 32 bit signed int:
28246 getValue: function (dataView, dataOffset, littleEndian) {
28247 return dataView.getInt32(dataOffset, littleEndian);
28251 // srational, two slongs, first is numerator, second is denominator:
28253 getValue: function (dataView, dataOffset, littleEndian) {
28254 return dataView.getInt32(dataOffset, littleEndian) /
28255 dataView.getInt32(dataOffset + 4, littleEndian);
28265 cls : 'btn-group roo-upload-cropbox-rotate-left',
28266 action : 'rotate-left',
28270 cls : 'btn btn-default',
28271 html : '<i class="fa fa-undo"></i>'
28277 cls : 'btn-group roo-upload-cropbox-picture',
28278 action : 'picture',
28282 cls : 'btn btn-default',
28283 html : '<i class="fa fa-picture-o"></i>'
28289 cls : 'btn-group roo-upload-cropbox-rotate-right',
28290 action : 'rotate-right',
28294 cls : 'btn btn-default',
28295 html : '<i class="fa fa-repeat"></i>'
28303 cls : 'btn-group roo-upload-cropbox-rotate-left',
28304 action : 'rotate-left',
28308 cls : 'btn btn-default',
28309 html : '<i class="fa fa-undo"></i>'
28315 cls : 'btn-group roo-upload-cropbox-download',
28316 action : 'download',
28320 cls : 'btn btn-default',
28321 html : '<i class="fa fa-download"></i>'
28327 cls : 'btn-group roo-upload-cropbox-crop',
28332 cls : 'btn btn-default',
28333 html : '<i class="fa fa-crop"></i>'
28339 cls : 'btn-group roo-upload-cropbox-trash',
28344 cls : 'btn btn-default',
28345 html : '<i class="fa fa-trash"></i>'
28351 cls : 'btn-group roo-upload-cropbox-rotate-right',
28352 action : 'rotate-right',
28356 cls : 'btn btn-default',
28357 html : '<i class="fa fa-repeat"></i>'
28365 cls : 'btn-group roo-upload-cropbox-rotate-left',
28366 action : 'rotate-left',
28370 cls : 'btn btn-default',
28371 html : '<i class="fa fa-undo"></i>'
28377 cls : 'btn-group roo-upload-cropbox-rotate-right',
28378 action : 'rotate-right',
28382 cls : 'btn btn-default',
28383 html : '<i class="fa fa-repeat"></i>'
28396 * @class Roo.bootstrap.DocumentManager
28397 * @extends Roo.bootstrap.Component
28398 * Bootstrap DocumentManager class
28399 * @cfg {String} paramName default 'imageUpload'
28400 * @cfg {String} toolTipName default 'filename'
28401 * @cfg {String} method default POST
28402 * @cfg {String} url action url
28403 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28404 * @cfg {Boolean} multiple multiple upload default true
28405 * @cfg {Number} thumbSize default 300
28406 * @cfg {String} fieldLabel
28407 * @cfg {Number} labelWidth default 4
28408 * @cfg {String} labelAlign (left|top) default left
28409 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28410 * @cfg {Number} labellg set the width of label (1-12)
28411 * @cfg {Number} labelmd set the width of label (1-12)
28412 * @cfg {Number} labelsm set the width of label (1-12)
28413 * @cfg {Number} labelxs set the width of label (1-12)
28416 * Create a new DocumentManager
28417 * @param {Object} config The config object
28420 Roo.bootstrap.DocumentManager = function(config){
28421 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28424 this.delegates = [];
28429 * Fire when initial the DocumentManager
28430 * @param {Roo.bootstrap.DocumentManager} this
28435 * inspect selected file
28436 * @param {Roo.bootstrap.DocumentManager} this
28437 * @param {File} file
28442 * Fire when xhr load exception
28443 * @param {Roo.bootstrap.DocumentManager} this
28444 * @param {XMLHttpRequest} xhr
28446 "exception" : true,
28448 * @event afterupload
28449 * Fire when xhr load exception
28450 * @param {Roo.bootstrap.DocumentManager} this
28451 * @param {XMLHttpRequest} xhr
28453 "afterupload" : true,
28456 * prepare the form data
28457 * @param {Roo.bootstrap.DocumentManager} this
28458 * @param {Object} formData
28463 * Fire when remove the file
28464 * @param {Roo.bootstrap.DocumentManager} this
28465 * @param {Object} file
28470 * Fire after refresh the file
28471 * @param {Roo.bootstrap.DocumentManager} this
28476 * Fire after click the image
28477 * @param {Roo.bootstrap.DocumentManager} this
28478 * @param {Object} file
28483 * Fire when upload a image and editable set to true
28484 * @param {Roo.bootstrap.DocumentManager} this
28485 * @param {Object} file
28489 * @event beforeselectfile
28490 * Fire before select file
28491 * @param {Roo.bootstrap.DocumentManager} this
28493 "beforeselectfile" : true,
28496 * Fire before process file
28497 * @param {Roo.bootstrap.DocumentManager} this
28498 * @param {Object} file
28502 * @event previewrendered
28503 * Fire when preview rendered
28504 * @param {Roo.bootstrap.DocumentManager} this
28505 * @param {Object} file
28507 "previewrendered" : true
28512 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28521 paramName : 'imageUpload',
28522 toolTipName : 'filename',
28525 labelAlign : 'left',
28535 getAutoCreate : function()
28537 var managerWidget = {
28539 cls : 'roo-document-manager',
28543 cls : 'roo-document-manager-selector',
28548 cls : 'roo-document-manager-uploader',
28552 cls : 'roo-document-manager-upload-btn',
28553 html : '<i class="fa fa-plus"></i>'
28564 cls : 'column col-md-12',
28569 if(this.fieldLabel.length){
28574 cls : 'column col-md-12',
28575 html : this.fieldLabel
28579 cls : 'column col-md-12',
28584 if(this.labelAlign == 'left'){
28589 html : this.fieldLabel
28598 if(this.labelWidth > 12){
28599 content[0].style = "width: " + this.labelWidth + 'px';
28602 if(this.labelWidth < 13 && this.labelmd == 0){
28603 this.labelmd = this.labelWidth;
28606 if(this.labellg > 0){
28607 content[0].cls += ' col-lg-' + this.labellg;
28608 content[1].cls += ' col-lg-' + (12 - this.labellg);
28611 if(this.labelmd > 0){
28612 content[0].cls += ' col-md-' + this.labelmd;
28613 content[1].cls += ' col-md-' + (12 - this.labelmd);
28616 if(this.labelsm > 0){
28617 content[0].cls += ' col-sm-' + this.labelsm;
28618 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28621 if(this.labelxs > 0){
28622 content[0].cls += ' col-xs-' + this.labelxs;
28623 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28631 cls : 'row clearfix',
28639 initEvents : function()
28641 this.managerEl = this.el.select('.roo-document-manager', true).first();
28642 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28644 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28645 this.selectorEl.hide();
28648 this.selectorEl.attr('multiple', 'multiple');
28651 this.selectorEl.on('change', this.onFileSelected, this);
28653 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28654 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28656 this.uploader.on('click', this.onUploaderClick, this);
28658 this.renderProgressDialog();
28662 window.addEventListener("resize", function() { _this.refresh(); } );
28664 this.fireEvent('initial', this);
28667 renderProgressDialog : function()
28671 this.progressDialog = new Roo.bootstrap.Modal({
28672 cls : 'roo-document-manager-progress-dialog',
28673 allow_close : false,
28683 btnclick : function() {
28684 _this.uploadCancel();
28690 this.progressDialog.render(Roo.get(document.body));
28692 this.progress = new Roo.bootstrap.Progress({
28693 cls : 'roo-document-manager-progress',
28698 this.progress.render(this.progressDialog.getChildContainer());
28700 this.progressBar = new Roo.bootstrap.ProgressBar({
28701 cls : 'roo-document-manager-progress-bar',
28704 aria_valuemax : 12,
28708 this.progressBar.render(this.progress.getChildContainer());
28711 onUploaderClick : function(e)
28713 e.preventDefault();
28715 if(this.fireEvent('beforeselectfile', this) != false){
28716 this.selectorEl.dom.click();
28721 onFileSelected : function(e)
28723 e.preventDefault();
28725 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28729 Roo.each(this.selectorEl.dom.files, function(file){
28730 if(this.fireEvent('inspect', this, file) != false){
28731 this.files.push(file);
28741 this.selectorEl.dom.value = '';
28743 if(!this.files || !this.files.length){
28747 if(this.boxes > 0 && this.files.length > this.boxes){
28748 this.files = this.files.slice(0, this.boxes);
28751 this.uploader.show();
28753 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28754 this.uploader.hide();
28763 Roo.each(this.files, function(file){
28765 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28766 var f = this.renderPreview(file);
28771 if(file.type.indexOf('image') != -1){
28772 this.delegates.push(
28774 _this.process(file);
28775 }).createDelegate(this)
28783 _this.process(file);
28784 }).createDelegate(this)
28789 this.files = files;
28791 this.delegates = this.delegates.concat(docs);
28793 if(!this.delegates.length){
28798 this.progressBar.aria_valuemax = this.delegates.length;
28805 arrange : function()
28807 if(!this.delegates.length){
28808 this.progressDialog.hide();
28813 var delegate = this.delegates.shift();
28815 this.progressDialog.show();
28817 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28819 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28824 refresh : function()
28826 this.uploader.show();
28828 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28829 this.uploader.hide();
28832 Roo.isTouch ? this.closable(false) : this.closable(true);
28834 this.fireEvent('refresh', this);
28837 onRemove : function(e, el, o)
28839 e.preventDefault();
28841 this.fireEvent('remove', this, o);
28845 remove : function(o)
28849 Roo.each(this.files, function(file){
28850 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28859 this.files = files;
28866 Roo.each(this.files, function(file){
28871 file.target.remove();
28880 onClick : function(e, el, o)
28882 e.preventDefault();
28884 this.fireEvent('click', this, o);
28888 closable : function(closable)
28890 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28892 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28904 xhrOnLoad : function(xhr)
28906 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28910 if (xhr.readyState !== 4) {
28912 this.fireEvent('exception', this, xhr);
28916 var response = Roo.decode(xhr.responseText);
28918 if(!response.success){
28920 this.fireEvent('exception', this, xhr);
28924 var file = this.renderPreview(response.data);
28926 this.files.push(file);
28930 this.fireEvent('afterupload', this, xhr);
28934 xhrOnError : function(xhr)
28936 Roo.log('xhr on error');
28938 var response = Roo.decode(xhr.responseText);
28945 process : function(file)
28947 if(this.fireEvent('process', this, file) !== false){
28948 if(this.editable && file.type.indexOf('image') != -1){
28949 this.fireEvent('edit', this, file);
28953 this.uploadStart(file, false);
28960 uploadStart : function(file, crop)
28962 this.xhr = new XMLHttpRequest();
28964 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28969 file.xhr = this.xhr;
28971 this.managerEl.createChild({
28973 cls : 'roo-document-manager-loading',
28977 tooltip : file.name,
28978 cls : 'roo-document-manager-thumb',
28979 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28985 this.xhr.open(this.method, this.url, true);
28988 "Accept": "application/json",
28989 "Cache-Control": "no-cache",
28990 "X-Requested-With": "XMLHttpRequest"
28993 for (var headerName in headers) {
28994 var headerValue = headers[headerName];
28996 this.xhr.setRequestHeader(headerName, headerValue);
29002 this.xhr.onload = function()
29004 _this.xhrOnLoad(_this.xhr);
29007 this.xhr.onerror = function()
29009 _this.xhrOnError(_this.xhr);
29012 var formData = new FormData();
29014 formData.append('returnHTML', 'NO');
29017 formData.append('crop', crop);
29020 formData.append(this.paramName, file, file.name);
29027 if(this.fireEvent('prepare', this, formData, options) != false){
29029 if(options.manually){
29033 this.xhr.send(formData);
29037 this.uploadCancel();
29040 uploadCancel : function()
29046 this.delegates = [];
29048 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29055 renderPreview : function(file)
29057 if(typeof(file.target) != 'undefined' && file.target){
29061 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29063 var previewEl = this.managerEl.createChild({
29065 cls : 'roo-document-manager-preview',
29069 tooltip : file[this.toolTipName],
29070 cls : 'roo-document-manager-thumb',
29071 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29076 html : '<i class="fa fa-times-circle"></i>'
29081 var close = previewEl.select('button.close', true).first();
29083 close.on('click', this.onRemove, this, file);
29085 file.target = previewEl;
29087 var image = previewEl.select('img', true).first();
29091 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29093 image.on('click', this.onClick, this, file);
29095 this.fireEvent('previewrendered', this, file);
29101 onPreviewLoad : function(file, image)
29103 if(typeof(file.target) == 'undefined' || !file.target){
29107 var width = image.dom.naturalWidth || image.dom.width;
29108 var height = image.dom.naturalHeight || image.dom.height;
29110 if(width > height){
29111 file.target.addClass('wide');
29115 file.target.addClass('tall');
29120 uploadFromSource : function(file, crop)
29122 this.xhr = new XMLHttpRequest();
29124 this.managerEl.createChild({
29126 cls : 'roo-document-manager-loading',
29130 tooltip : file.name,
29131 cls : 'roo-document-manager-thumb',
29132 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29138 this.xhr.open(this.method, this.url, true);
29141 "Accept": "application/json",
29142 "Cache-Control": "no-cache",
29143 "X-Requested-With": "XMLHttpRequest"
29146 for (var headerName in headers) {
29147 var headerValue = headers[headerName];
29149 this.xhr.setRequestHeader(headerName, headerValue);
29155 this.xhr.onload = function()
29157 _this.xhrOnLoad(_this.xhr);
29160 this.xhr.onerror = function()
29162 _this.xhrOnError(_this.xhr);
29165 var formData = new FormData();
29167 formData.append('returnHTML', 'NO');
29169 formData.append('crop', crop);
29171 if(typeof(file.filename) != 'undefined'){
29172 formData.append('filename', file.filename);
29175 if(typeof(file.mimetype) != 'undefined'){
29176 formData.append('mimetype', file.mimetype);
29181 if(this.fireEvent('prepare', this, formData) != false){
29182 this.xhr.send(formData);
29192 * @class Roo.bootstrap.DocumentViewer
29193 * @extends Roo.bootstrap.Component
29194 * Bootstrap DocumentViewer class
29195 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29196 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29199 * Create a new DocumentViewer
29200 * @param {Object} config The config object
29203 Roo.bootstrap.DocumentViewer = function(config){
29204 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29209 * Fire after initEvent
29210 * @param {Roo.bootstrap.DocumentViewer} this
29216 * @param {Roo.bootstrap.DocumentViewer} this
29221 * Fire after download button
29222 * @param {Roo.bootstrap.DocumentViewer} this
29227 * Fire after trash button
29228 * @param {Roo.bootstrap.DocumentViewer} this
29235 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29237 showDownload : true,
29241 getAutoCreate : function()
29245 cls : 'roo-document-viewer',
29249 cls : 'roo-document-viewer-body',
29253 cls : 'roo-document-viewer-thumb',
29257 cls : 'roo-document-viewer-image'
29265 cls : 'roo-document-viewer-footer',
29268 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29272 cls : 'btn-group roo-document-viewer-download',
29276 cls : 'btn btn-default',
29277 html : '<i class="fa fa-download"></i>'
29283 cls : 'btn-group roo-document-viewer-trash',
29287 cls : 'btn btn-default',
29288 html : '<i class="fa fa-trash"></i>'
29301 initEvents : function()
29303 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29304 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29306 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29307 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29309 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29310 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29312 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29313 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29315 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29316 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29318 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29319 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29321 this.bodyEl.on('click', this.onClick, this);
29322 this.downloadBtn.on('click', this.onDownload, this);
29323 this.trashBtn.on('click', this.onTrash, this);
29325 this.downloadBtn.hide();
29326 this.trashBtn.hide();
29328 if(this.showDownload){
29329 this.downloadBtn.show();
29332 if(this.showTrash){
29333 this.trashBtn.show();
29336 if(!this.showDownload && !this.showTrash) {
29337 this.footerEl.hide();
29342 initial : function()
29344 this.fireEvent('initial', this);
29348 onClick : function(e)
29350 e.preventDefault();
29352 this.fireEvent('click', this);
29355 onDownload : function(e)
29357 e.preventDefault();
29359 this.fireEvent('download', this);
29362 onTrash : function(e)
29364 e.preventDefault();
29366 this.fireEvent('trash', this);
29378 * @class Roo.bootstrap.NavProgressBar
29379 * @extends Roo.bootstrap.Component
29380 * Bootstrap NavProgressBar class
29383 * Create a new nav progress bar
29384 * @param {Object} config The config object
29387 Roo.bootstrap.NavProgressBar = function(config){
29388 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29390 this.bullets = this.bullets || [];
29392 // Roo.bootstrap.NavProgressBar.register(this);
29396 * Fires when the active item changes
29397 * @param {Roo.bootstrap.NavProgressBar} this
29398 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29399 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29406 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29411 getAutoCreate : function()
29413 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29417 cls : 'roo-navigation-bar-group',
29421 cls : 'roo-navigation-top-bar'
29425 cls : 'roo-navigation-bullets-bar',
29429 cls : 'roo-navigation-bar'
29436 cls : 'roo-navigation-bottom-bar'
29446 initEvents: function()
29451 onRender : function(ct, position)
29453 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29455 if(this.bullets.length){
29456 Roo.each(this.bullets, function(b){
29465 addItem : function(cfg)
29467 var item = new Roo.bootstrap.NavProgressItem(cfg);
29469 item.parentId = this.id;
29470 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29473 var top = new Roo.bootstrap.Element({
29475 cls : 'roo-navigation-bar-text'
29478 var bottom = new Roo.bootstrap.Element({
29480 cls : 'roo-navigation-bar-text'
29483 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29484 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29486 var topText = new Roo.bootstrap.Element({
29488 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29491 var bottomText = new Roo.bootstrap.Element({
29493 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29496 topText.onRender(top.el, null);
29497 bottomText.onRender(bottom.el, null);
29500 item.bottomEl = bottom;
29503 this.barItems.push(item);
29508 getActive : function()
29510 var active = false;
29512 Roo.each(this.barItems, function(v){
29514 if (!v.isActive()) {
29526 setActiveItem : function(item)
29530 Roo.each(this.barItems, function(v){
29531 if (v.rid == item.rid) {
29535 if (v.isActive()) {
29536 v.setActive(false);
29541 item.setActive(true);
29543 this.fireEvent('changed', this, item, prev);
29546 getBarItem: function(rid)
29550 Roo.each(this.barItems, function(e) {
29551 if (e.rid != rid) {
29562 indexOfItem : function(item)
29566 Roo.each(this.barItems, function(v, i){
29568 if (v.rid != item.rid) {
29579 setActiveNext : function()
29581 var i = this.indexOfItem(this.getActive());
29583 if (i > this.barItems.length) {
29587 this.setActiveItem(this.barItems[i+1]);
29590 setActivePrev : function()
29592 var i = this.indexOfItem(this.getActive());
29598 this.setActiveItem(this.barItems[i-1]);
29601 format : function()
29603 if(!this.barItems.length){
29607 var width = 100 / this.barItems.length;
29609 Roo.each(this.barItems, function(i){
29610 i.el.setStyle('width', width + '%');
29611 i.topEl.el.setStyle('width', width + '%');
29612 i.bottomEl.el.setStyle('width', width + '%');
29621 * Nav Progress Item
29626 * @class Roo.bootstrap.NavProgressItem
29627 * @extends Roo.bootstrap.Component
29628 * Bootstrap NavProgressItem class
29629 * @cfg {String} rid the reference id
29630 * @cfg {Boolean} active (true|false) Is item active default false
29631 * @cfg {Boolean} disabled (true|false) Is item active default false
29632 * @cfg {String} html
29633 * @cfg {String} position (top|bottom) text position default bottom
29634 * @cfg {String} icon show icon instead of number
29637 * Create a new NavProgressItem
29638 * @param {Object} config The config object
29640 Roo.bootstrap.NavProgressItem = function(config){
29641 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29646 * The raw click event for the entire grid.
29647 * @param {Roo.bootstrap.NavProgressItem} this
29648 * @param {Roo.EventObject} e
29655 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29661 position : 'bottom',
29664 getAutoCreate : function()
29666 var iconCls = 'roo-navigation-bar-item-icon';
29668 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29672 cls: 'roo-navigation-bar-item',
29682 cfg.cls += ' active';
29685 cfg.cls += ' disabled';
29691 disable : function()
29693 this.setDisabled(true);
29696 enable : function()
29698 this.setDisabled(false);
29701 initEvents: function()
29703 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29705 this.iconEl.on('click', this.onClick, this);
29708 onClick : function(e)
29710 e.preventDefault();
29716 if(this.fireEvent('click', this, e) === false){
29720 this.parent().setActiveItem(this);
29723 isActive: function ()
29725 return this.active;
29728 setActive : function(state)
29730 if(this.active == state){
29734 this.active = state;
29737 this.el.addClass('active');
29741 this.el.removeClass('active');
29746 setDisabled : function(state)
29748 if(this.disabled == state){
29752 this.disabled = state;
29755 this.el.addClass('disabled');
29759 this.el.removeClass('disabled');
29762 tooltipEl : function()
29764 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29777 * @class Roo.bootstrap.FieldLabel
29778 * @extends Roo.bootstrap.Component
29779 * Bootstrap FieldLabel class
29780 * @cfg {String} html contents of the element
29781 * @cfg {String} tag tag of the element default label
29782 * @cfg {String} cls class of the element
29783 * @cfg {String} target label target
29784 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29785 * @cfg {String} invalidClass default "text-warning"
29786 * @cfg {String} validClass default "text-success"
29787 * @cfg {String} iconTooltip default "This field is required"
29788 * @cfg {String} indicatorpos (left|right) default left
29791 * Create a new FieldLabel
29792 * @param {Object} config The config object
29795 Roo.bootstrap.FieldLabel = function(config){
29796 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29801 * Fires after the field has been marked as invalid.
29802 * @param {Roo.form.FieldLabel} this
29803 * @param {String} msg The validation message
29808 * Fires after the field has been validated with no errors.
29809 * @param {Roo.form.FieldLabel} this
29815 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29822 invalidClass : 'has-warning',
29823 validClass : 'has-success',
29824 iconTooltip : 'This field is required',
29825 indicatorpos : 'left',
29827 getAutoCreate : function(){
29831 cls : 'roo-bootstrap-field-label ' + this.cls,
29836 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29837 tooltip : this.iconTooltip
29846 if(this.indicatorpos == 'right'){
29849 cls : 'roo-bootstrap-field-label ' + this.cls,
29858 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29859 tooltip : this.iconTooltip
29868 initEvents: function()
29870 Roo.bootstrap.Element.superclass.initEvents.call(this);
29872 this.indicator = this.indicatorEl();
29874 if(this.indicator){
29875 this.indicator.removeClass('visible');
29876 this.indicator.addClass('invisible');
29879 Roo.bootstrap.FieldLabel.register(this);
29882 indicatorEl : function()
29884 var indicator = this.el.select('i.roo-required-indicator',true).first();
29895 * Mark this field as valid
29897 markValid : function()
29899 if(this.indicator){
29900 this.indicator.removeClass('visible');
29901 this.indicator.addClass('invisible');
29904 this.el.removeClass(this.invalidClass);
29906 this.el.addClass(this.validClass);
29908 this.fireEvent('valid', this);
29912 * Mark this field as invalid
29913 * @param {String} msg The validation message
29915 markInvalid : function(msg)
29917 if(this.indicator){
29918 this.indicator.removeClass('invisible');
29919 this.indicator.addClass('visible');
29922 this.el.removeClass(this.validClass);
29924 this.el.addClass(this.invalidClass);
29926 this.fireEvent('invalid', this, msg);
29932 Roo.apply(Roo.bootstrap.FieldLabel, {
29937 * register a FieldLabel Group
29938 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29940 register : function(label)
29942 if(this.groups.hasOwnProperty(label.target)){
29946 this.groups[label.target] = label;
29950 * fetch a FieldLabel Group based on the target
29951 * @param {string} target
29952 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29954 get: function(target) {
29955 if (typeof(this.groups[target]) == 'undefined') {
29959 return this.groups[target] ;
29968 * page DateSplitField.
29974 * @class Roo.bootstrap.DateSplitField
29975 * @extends Roo.bootstrap.Component
29976 * Bootstrap DateSplitField class
29977 * @cfg {string} fieldLabel - the label associated
29978 * @cfg {Number} labelWidth set the width of label (0-12)
29979 * @cfg {String} labelAlign (top|left)
29980 * @cfg {Boolean} dayAllowBlank (true|false) default false
29981 * @cfg {Boolean} monthAllowBlank (true|false) default false
29982 * @cfg {Boolean} yearAllowBlank (true|false) default false
29983 * @cfg {string} dayPlaceholder
29984 * @cfg {string} monthPlaceholder
29985 * @cfg {string} yearPlaceholder
29986 * @cfg {string} dayFormat default 'd'
29987 * @cfg {string} monthFormat default 'm'
29988 * @cfg {string} yearFormat default 'Y'
29989 * @cfg {Number} labellg set the width of label (1-12)
29990 * @cfg {Number} labelmd set the width of label (1-12)
29991 * @cfg {Number} labelsm set the width of label (1-12)
29992 * @cfg {Number} labelxs set the width of label (1-12)
29996 * Create a new DateSplitField
29997 * @param {Object} config The config object
30000 Roo.bootstrap.DateSplitField = function(config){
30001 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30007 * getting the data of years
30008 * @param {Roo.bootstrap.DateSplitField} this
30009 * @param {Object} years
30014 * getting the data of days
30015 * @param {Roo.bootstrap.DateSplitField} this
30016 * @param {Object} days
30021 * Fires after the field has been marked as invalid.
30022 * @param {Roo.form.Field} this
30023 * @param {String} msg The validation message
30028 * Fires after the field has been validated with no errors.
30029 * @param {Roo.form.Field} this
30035 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30038 labelAlign : 'top',
30040 dayAllowBlank : false,
30041 monthAllowBlank : false,
30042 yearAllowBlank : false,
30043 dayPlaceholder : '',
30044 monthPlaceholder : '',
30045 yearPlaceholder : '',
30049 isFormField : true,
30055 getAutoCreate : function()
30059 cls : 'row roo-date-split-field-group',
30064 cls : 'form-hidden-field roo-date-split-field-group-value',
30070 var labelCls = 'col-md-12';
30071 var contentCls = 'col-md-4';
30073 if(this.fieldLabel){
30077 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30081 html : this.fieldLabel
30086 if(this.labelAlign == 'left'){
30088 if(this.labelWidth > 12){
30089 label.style = "width: " + this.labelWidth + 'px';
30092 if(this.labelWidth < 13 && this.labelmd == 0){
30093 this.labelmd = this.labelWidth;
30096 if(this.labellg > 0){
30097 labelCls = ' col-lg-' + this.labellg;
30098 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30101 if(this.labelmd > 0){
30102 labelCls = ' col-md-' + this.labelmd;
30103 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30106 if(this.labelsm > 0){
30107 labelCls = ' col-sm-' + this.labelsm;
30108 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30111 if(this.labelxs > 0){
30112 labelCls = ' col-xs-' + this.labelxs;
30113 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30117 label.cls += ' ' + labelCls;
30119 cfg.cn.push(label);
30122 Roo.each(['day', 'month', 'year'], function(t){
30125 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30132 inputEl: function ()
30134 return this.el.select('.roo-date-split-field-group-value', true).first();
30137 onRender : function(ct, position)
30141 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30143 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30145 this.dayField = new Roo.bootstrap.ComboBox({
30146 allowBlank : this.dayAllowBlank,
30147 alwaysQuery : true,
30148 displayField : 'value',
30151 forceSelection : true,
30153 placeholder : this.dayPlaceholder,
30154 selectOnFocus : true,
30155 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30156 triggerAction : 'all',
30158 valueField : 'value',
30159 store : new Roo.data.SimpleStore({
30160 data : (function() {
30162 _this.fireEvent('days', _this, days);
30165 fields : [ 'value' ]
30168 select : function (_self, record, index)
30170 _this.setValue(_this.getValue());
30175 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30177 this.monthField = new Roo.bootstrap.MonthField({
30178 after : '<i class=\"fa fa-calendar\"></i>',
30179 allowBlank : this.monthAllowBlank,
30180 placeholder : this.monthPlaceholder,
30183 render : function (_self)
30185 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30186 e.preventDefault();
30190 select : function (_self, oldvalue, newvalue)
30192 _this.setValue(_this.getValue());
30197 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30199 this.yearField = new Roo.bootstrap.ComboBox({
30200 allowBlank : this.yearAllowBlank,
30201 alwaysQuery : true,
30202 displayField : 'value',
30205 forceSelection : true,
30207 placeholder : this.yearPlaceholder,
30208 selectOnFocus : true,
30209 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30210 triggerAction : 'all',
30212 valueField : 'value',
30213 store : new Roo.data.SimpleStore({
30214 data : (function() {
30216 _this.fireEvent('years', _this, years);
30219 fields : [ 'value' ]
30222 select : function (_self, record, index)
30224 _this.setValue(_this.getValue());
30229 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30232 setValue : function(v, format)
30234 this.inputEl.dom.value = v;
30236 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30238 var d = Date.parseDate(v, f);
30245 this.setDay(d.format(this.dayFormat));
30246 this.setMonth(d.format(this.monthFormat));
30247 this.setYear(d.format(this.yearFormat));
30254 setDay : function(v)
30256 this.dayField.setValue(v);
30257 this.inputEl.dom.value = this.getValue();
30262 setMonth : function(v)
30264 this.monthField.setValue(v, true);
30265 this.inputEl.dom.value = this.getValue();
30270 setYear : function(v)
30272 this.yearField.setValue(v);
30273 this.inputEl.dom.value = this.getValue();
30278 getDay : function()
30280 return this.dayField.getValue();
30283 getMonth : function()
30285 return this.monthField.getValue();
30288 getYear : function()
30290 return this.yearField.getValue();
30293 getValue : function()
30295 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30297 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30307 this.inputEl.dom.value = '';
30312 validate : function()
30314 var d = this.dayField.validate();
30315 var m = this.monthField.validate();
30316 var y = this.yearField.validate();
30321 (!this.dayAllowBlank && !d) ||
30322 (!this.monthAllowBlank && !m) ||
30323 (!this.yearAllowBlank && !y)
30328 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30337 this.markInvalid();
30342 markValid : function()
30345 var label = this.el.select('label', true).first();
30346 var icon = this.el.select('i.fa-star', true).first();
30352 this.fireEvent('valid', this);
30356 * Mark this field as invalid
30357 * @param {String} msg The validation message
30359 markInvalid : function(msg)
30362 var label = this.el.select('label', true).first();
30363 var icon = this.el.select('i.fa-star', true).first();
30365 if(label && !icon){
30366 this.el.select('.roo-date-split-field-label', true).createChild({
30368 cls : 'text-danger fa fa-lg fa-star',
30369 tooltip : 'This field is required',
30370 style : 'margin-right:5px;'
30374 this.fireEvent('invalid', this, msg);
30377 clearInvalid : function()
30379 var label = this.el.select('label', true).first();
30380 var icon = this.el.select('i.fa-star', true).first();
30386 this.fireEvent('valid', this);
30389 getName: function()
30399 * http://masonry.desandro.com
30401 * The idea is to render all the bricks based on vertical width...
30403 * The original code extends 'outlayer' - we might need to use that....
30409 * @class Roo.bootstrap.LayoutMasonry
30410 * @extends Roo.bootstrap.Component
30411 * Bootstrap Layout Masonry class
30414 * Create a new Element
30415 * @param {Object} config The config object
30418 Roo.bootstrap.LayoutMasonry = function(config){
30420 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30424 Roo.bootstrap.LayoutMasonry.register(this);
30430 * Fire after layout the items
30431 * @param {Roo.bootstrap.LayoutMasonry} this
30432 * @param {Roo.EventObject} e
30439 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30442 * @cfg {Boolean} isLayoutInstant = no animation?
30444 isLayoutInstant : false, // needed?
30447 * @cfg {Number} boxWidth width of the columns
30452 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30457 * @cfg {Number} padWidth padding below box..
30462 * @cfg {Number} gutter gutter width..
30467 * @cfg {Number} maxCols maximum number of columns
30473 * @cfg {Boolean} isAutoInitial defalut true
30475 isAutoInitial : true,
30480 * @cfg {Boolean} isHorizontal defalut false
30482 isHorizontal : false,
30484 currentSize : null,
30490 bricks: null, //CompositeElement
30494 _isLayoutInited : false,
30496 // isAlternative : false, // only use for vertical layout...
30499 * @cfg {Number} alternativePadWidth padding below box..
30501 alternativePadWidth : 50,
30503 selectedBrick : [],
30505 getAutoCreate : function(){
30507 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30511 cls: 'blog-masonary-wrapper ' + this.cls,
30513 cls : 'mas-boxes masonary'
30520 getChildContainer: function( )
30522 if (this.boxesEl) {
30523 return this.boxesEl;
30526 this.boxesEl = this.el.select('.mas-boxes').first();
30528 return this.boxesEl;
30532 initEvents : function()
30536 if(this.isAutoInitial){
30537 Roo.log('hook children rendered');
30538 this.on('childrenrendered', function() {
30539 Roo.log('children rendered');
30545 initial : function()
30547 this.selectedBrick = [];
30549 this.currentSize = this.el.getBox(true);
30551 Roo.EventManager.onWindowResize(this.resize, this);
30553 if(!this.isAutoInitial){
30561 //this.layout.defer(500,this);
30565 resize : function()
30567 var cs = this.el.getBox(true);
30570 this.currentSize.width == cs.width &&
30571 this.currentSize.x == cs.x &&
30572 this.currentSize.height == cs.height &&
30573 this.currentSize.y == cs.y
30575 Roo.log("no change in with or X or Y");
30579 this.currentSize = cs;
30585 layout : function()
30587 this._resetLayout();
30589 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30591 this.layoutItems( isInstant );
30593 this._isLayoutInited = true;
30595 this.fireEvent('layout', this);
30599 _resetLayout : function()
30601 if(this.isHorizontal){
30602 this.horizontalMeasureColumns();
30606 this.verticalMeasureColumns();
30610 verticalMeasureColumns : function()
30612 this.getContainerWidth();
30614 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30615 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30619 var boxWidth = this.boxWidth + this.padWidth;
30621 if(this.containerWidth < this.boxWidth){
30622 boxWidth = this.containerWidth
30625 var containerWidth = this.containerWidth;
30627 var cols = Math.floor(containerWidth / boxWidth);
30629 this.cols = Math.max( cols, 1 );
30631 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30633 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30635 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30637 this.colWidth = boxWidth + avail - this.padWidth;
30639 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30640 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30643 horizontalMeasureColumns : function()
30645 this.getContainerWidth();
30647 var boxWidth = this.boxWidth;
30649 if(this.containerWidth < boxWidth){
30650 boxWidth = this.containerWidth;
30653 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30655 this.el.setHeight(boxWidth);
30659 getContainerWidth : function()
30661 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30664 layoutItems : function( isInstant )
30666 Roo.log(this.bricks);
30668 var items = Roo.apply([], this.bricks);
30670 if(this.isHorizontal){
30671 this._horizontalLayoutItems( items , isInstant );
30675 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30676 // this._verticalAlternativeLayoutItems( items , isInstant );
30680 this._verticalLayoutItems( items , isInstant );
30684 _verticalLayoutItems : function ( items , isInstant)
30686 if ( !items || !items.length ) {
30691 ['xs', 'xs', 'xs', 'tall'],
30692 ['xs', 'xs', 'tall'],
30693 ['xs', 'xs', 'sm'],
30694 ['xs', 'xs', 'xs'],
30700 ['sm', 'xs', 'xs'],
30704 ['tall', 'xs', 'xs', 'xs'],
30705 ['tall', 'xs', 'xs'],
30717 Roo.each(items, function(item, k){
30719 switch (item.size) {
30720 // these layouts take up a full box,
30731 boxes.push([item]);
30754 var filterPattern = function(box, length)
30762 var pattern = box.slice(0, length);
30766 Roo.each(pattern, function(i){
30767 format.push(i.size);
30770 Roo.each(standard, function(s){
30772 if(String(s) != String(format)){
30781 if(!match && length == 1){
30786 filterPattern(box, length - 1);
30790 queue.push(pattern);
30792 box = box.slice(length, box.length);
30794 filterPattern(box, 4);
30800 Roo.each(boxes, function(box, k){
30806 if(box.length == 1){
30811 filterPattern(box, 4);
30815 this._processVerticalLayoutQueue( queue, isInstant );
30819 // _verticalAlternativeLayoutItems : function( items , isInstant )
30821 // if ( !items || !items.length ) {
30825 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30829 _horizontalLayoutItems : function ( items , isInstant)
30831 if ( !items || !items.length || items.length < 3) {
30837 var eItems = items.slice(0, 3);
30839 items = items.slice(3, items.length);
30842 ['xs', 'xs', 'xs', 'wide'],
30843 ['xs', 'xs', 'wide'],
30844 ['xs', 'xs', 'sm'],
30845 ['xs', 'xs', 'xs'],
30851 ['sm', 'xs', 'xs'],
30855 ['wide', 'xs', 'xs', 'xs'],
30856 ['wide', 'xs', 'xs'],
30869 Roo.each(items, function(item, k){
30871 switch (item.size) {
30882 boxes.push([item]);
30906 var filterPattern = function(box, length)
30914 var pattern = box.slice(0, length);
30918 Roo.each(pattern, function(i){
30919 format.push(i.size);
30922 Roo.each(standard, function(s){
30924 if(String(s) != String(format)){
30933 if(!match && length == 1){
30938 filterPattern(box, length - 1);
30942 queue.push(pattern);
30944 box = box.slice(length, box.length);
30946 filterPattern(box, 4);
30952 Roo.each(boxes, function(box, k){
30958 if(box.length == 1){
30963 filterPattern(box, 4);
30970 var pos = this.el.getBox(true);
30974 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30976 var hit_end = false;
30978 Roo.each(queue, function(box){
30982 Roo.each(box, function(b){
30984 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30994 Roo.each(box, function(b){
30996 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30999 mx = Math.max(mx, b.x);
31003 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31007 Roo.each(box, function(b){
31009 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31023 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31026 /** Sets position of item in DOM
31027 * @param {Element} item
31028 * @param {Number} x - horizontal position
31029 * @param {Number} y - vertical position
31030 * @param {Boolean} isInstant - disables transitions
31032 _processVerticalLayoutQueue : function( queue, isInstant )
31034 var pos = this.el.getBox(true);
31039 for (var i = 0; i < this.cols; i++){
31043 Roo.each(queue, function(box, k){
31045 var col = k % this.cols;
31047 Roo.each(box, function(b,kk){
31049 b.el.position('absolute');
31051 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31052 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31054 if(b.size == 'md-left' || b.size == 'md-right'){
31055 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31056 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31059 b.el.setWidth(width);
31060 b.el.setHeight(height);
31062 b.el.select('iframe',true).setSize(width,height);
31066 for (var i = 0; i < this.cols; i++){
31068 if(maxY[i] < maxY[col]){
31073 col = Math.min(col, i);
31077 x = pos.x + col * (this.colWidth + this.padWidth);
31081 var positions = [];
31083 switch (box.length){
31085 positions = this.getVerticalOneBoxColPositions(x, y, box);
31088 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31091 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31094 positions = this.getVerticalFourBoxColPositions(x, y, box);
31100 Roo.each(box, function(b,kk){
31102 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31104 var sz = b.el.getSize();
31106 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31114 for (var i = 0; i < this.cols; i++){
31115 mY = Math.max(mY, maxY[i]);
31118 this.el.setHeight(mY - pos.y);
31122 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31124 // var pos = this.el.getBox(true);
31127 // var maxX = pos.right;
31129 // var maxHeight = 0;
31131 // Roo.each(items, function(item, k){
31135 // item.el.position('absolute');
31137 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31139 // item.el.setWidth(width);
31141 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31143 // item.el.setHeight(height);
31146 // item.el.setXY([x, y], isInstant ? false : true);
31148 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31151 // y = y + height + this.alternativePadWidth;
31153 // maxHeight = maxHeight + height + this.alternativePadWidth;
31157 // this.el.setHeight(maxHeight);
31161 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31163 var pos = this.el.getBox(true);
31168 var maxX = pos.right;
31170 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31172 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31174 Roo.each(queue, function(box, k){
31176 Roo.each(box, function(b, kk){
31178 b.el.position('absolute');
31180 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31181 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31183 if(b.size == 'md-left' || b.size == 'md-right'){
31184 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31185 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31188 b.el.setWidth(width);
31189 b.el.setHeight(height);
31197 var positions = [];
31199 switch (box.length){
31201 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31204 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31207 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31210 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31216 Roo.each(box, function(b,kk){
31218 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31220 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31228 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31230 Roo.each(eItems, function(b,k){
31232 b.size = (k == 0) ? 'sm' : 'xs';
31233 b.x = (k == 0) ? 2 : 1;
31234 b.y = (k == 0) ? 2 : 1;
31236 b.el.position('absolute');
31238 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31240 b.el.setWidth(width);
31242 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31244 b.el.setHeight(height);
31248 var positions = [];
31251 x : maxX - this.unitWidth * 2 - this.gutter,
31256 x : maxX - this.unitWidth,
31257 y : minY + (this.unitWidth + this.gutter) * 2
31261 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31265 Roo.each(eItems, function(b,k){
31267 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31273 getVerticalOneBoxColPositions : function(x, y, box)
31277 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31279 if(box[0].size == 'md-left'){
31283 if(box[0].size == 'md-right'){
31288 x : x + (this.unitWidth + this.gutter) * rand,
31295 getVerticalTwoBoxColPositions : function(x, y, box)
31299 if(box[0].size == 'xs'){
31303 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31307 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31321 x : x + (this.unitWidth + this.gutter) * 2,
31322 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31329 getVerticalThreeBoxColPositions : function(x, y, box)
31333 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31341 x : x + (this.unitWidth + this.gutter) * 1,
31346 x : x + (this.unitWidth + this.gutter) * 2,
31354 if(box[0].size == 'xs' && box[1].size == 'xs'){
31363 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31367 x : x + (this.unitWidth + this.gutter) * 1,
31381 x : x + (this.unitWidth + this.gutter) * 2,
31386 x : x + (this.unitWidth + this.gutter) * 2,
31387 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31394 getVerticalFourBoxColPositions : function(x, y, box)
31398 if(box[0].size == 'xs'){
31407 y : y + (this.unitHeight + this.gutter) * 1
31412 y : y + (this.unitHeight + this.gutter) * 2
31416 x : x + (this.unitWidth + this.gutter) * 1,
31430 x : x + (this.unitWidth + this.gutter) * 2,
31435 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31436 y : y + (this.unitHeight + this.gutter) * 1
31440 x : x + (this.unitWidth + this.gutter) * 2,
31441 y : y + (this.unitWidth + this.gutter) * 2
31448 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31452 if(box[0].size == 'md-left'){
31454 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31461 if(box[0].size == 'md-right'){
31463 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31464 y : minY + (this.unitWidth + this.gutter) * 1
31470 var rand = Math.floor(Math.random() * (4 - box[0].y));
31473 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31474 y : minY + (this.unitWidth + this.gutter) * rand
31481 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31485 if(box[0].size == 'xs'){
31488 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31493 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31494 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31502 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31507 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31508 y : minY + (this.unitWidth + this.gutter) * 2
31515 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31519 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31522 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31527 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31528 y : minY + (this.unitWidth + this.gutter) * 1
31532 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31533 y : minY + (this.unitWidth + this.gutter) * 2
31540 if(box[0].size == 'xs' && box[1].size == 'xs'){
31543 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31548 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31553 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31554 y : minY + (this.unitWidth + this.gutter) * 1
31562 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31567 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31568 y : minY + (this.unitWidth + this.gutter) * 2
31572 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31573 y : minY + (this.unitWidth + this.gutter) * 2
31580 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31584 if(box[0].size == 'xs'){
31587 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31592 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31597 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),
31602 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31603 y : minY + (this.unitWidth + this.gutter) * 1
31611 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31616 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31617 y : minY + (this.unitWidth + this.gutter) * 2
31621 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31622 y : minY + (this.unitWidth + this.gutter) * 2
31626 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),
31627 y : minY + (this.unitWidth + this.gutter) * 2
31635 * remove a Masonry Brick
31636 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31638 removeBrick : function(brick_id)
31644 for (var i = 0; i<this.bricks.length; i++) {
31645 if (this.bricks[i].id == brick_id) {
31646 this.bricks.splice(i,1);
31647 this.el.dom.removeChild(Roo.get(brick_id).dom);
31654 * adds a Masonry Brick
31655 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31657 addBrick : function(cfg)
31659 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31660 //this.register(cn);
31661 cn.parentId = this.id;
31662 cn.onRender(this.el, null);
31667 * register a Masonry Brick
31668 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31671 register : function(brick)
31673 this.bricks.push(brick);
31674 brick.masonryId = this.id;
31678 * clear all the Masonry Brick
31680 clearAll : function()
31683 //this.getChildContainer().dom.innerHTML = "";
31684 this.el.dom.innerHTML = '';
31687 getSelected : function()
31689 if (!this.selectedBrick) {
31693 return this.selectedBrick;
31697 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31701 * register a Masonry Layout
31702 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31705 register : function(layout)
31707 this.groups[layout.id] = layout;
31710 * fetch a Masonry Layout based on the masonry layout ID
31711 * @param {string} the masonry layout to add
31712 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31715 get: function(layout_id) {
31716 if (typeof(this.groups[layout_id]) == 'undefined') {
31719 return this.groups[layout_id] ;
31731 * http://masonry.desandro.com
31733 * The idea is to render all the bricks based on vertical width...
31735 * The original code extends 'outlayer' - we might need to use that....
31741 * @class Roo.bootstrap.LayoutMasonryAuto
31742 * @extends Roo.bootstrap.Component
31743 * Bootstrap Layout Masonry class
31746 * Create a new Element
31747 * @param {Object} config The config object
31750 Roo.bootstrap.LayoutMasonryAuto = function(config){
31751 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31754 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31757 * @cfg {Boolean} isFitWidth - resize the width..
31759 isFitWidth : false, // options..
31761 * @cfg {Boolean} isOriginLeft = left align?
31763 isOriginLeft : true,
31765 * @cfg {Boolean} isOriginTop = top align?
31767 isOriginTop : false,
31769 * @cfg {Boolean} isLayoutInstant = no animation?
31771 isLayoutInstant : false, // needed?
31773 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31775 isResizingContainer : true,
31777 * @cfg {Number} columnWidth width of the columns
31783 * @cfg {Number} maxCols maximum number of columns
31788 * @cfg {Number} padHeight padding below box..
31794 * @cfg {Boolean} isAutoInitial defalut true
31797 isAutoInitial : true,
31803 initialColumnWidth : 0,
31804 currentSize : null,
31806 colYs : null, // array.
31813 bricks: null, //CompositeElement
31814 cols : 0, // array?
31815 // element : null, // wrapped now this.el
31816 _isLayoutInited : null,
31819 getAutoCreate : function(){
31823 cls: 'blog-masonary-wrapper ' + this.cls,
31825 cls : 'mas-boxes masonary'
31832 getChildContainer: function( )
31834 if (this.boxesEl) {
31835 return this.boxesEl;
31838 this.boxesEl = this.el.select('.mas-boxes').first();
31840 return this.boxesEl;
31844 initEvents : function()
31848 if(this.isAutoInitial){
31849 Roo.log('hook children rendered');
31850 this.on('childrenrendered', function() {
31851 Roo.log('children rendered');
31858 initial : function()
31860 this.reloadItems();
31862 this.currentSize = this.el.getBox(true);
31864 /// was window resize... - let's see if this works..
31865 Roo.EventManager.onWindowResize(this.resize, this);
31867 if(!this.isAutoInitial){
31872 this.layout.defer(500,this);
31875 reloadItems: function()
31877 this.bricks = this.el.select('.masonry-brick', true);
31879 this.bricks.each(function(b) {
31880 //Roo.log(b.getSize());
31881 if (!b.attr('originalwidth')) {
31882 b.attr('originalwidth', b.getSize().width);
31887 Roo.log(this.bricks.elements.length);
31890 resize : function()
31893 var cs = this.el.getBox(true);
31895 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31896 Roo.log("no change in with or X");
31899 this.currentSize = cs;
31903 layout : function()
31906 this._resetLayout();
31907 //this._manageStamps();
31909 // don't animate first layout
31910 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31911 this.layoutItems( isInstant );
31913 // flag for initalized
31914 this._isLayoutInited = true;
31917 layoutItems : function( isInstant )
31919 //var items = this._getItemsForLayout( this.items );
31920 // original code supports filtering layout items.. we just ignore it..
31922 this._layoutItems( this.bricks , isInstant );
31924 this._postLayout();
31926 _layoutItems : function ( items , isInstant)
31928 //this.fireEvent( 'layout', this, items );
31931 if ( !items || !items.elements.length ) {
31932 // no items, emit event with empty array
31937 items.each(function(item) {
31938 Roo.log("layout item");
31940 // get x/y object from method
31941 var position = this._getItemLayoutPosition( item );
31943 position.item = item;
31944 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31945 queue.push( position );
31948 this._processLayoutQueue( queue );
31950 /** Sets position of item in DOM
31951 * @param {Element} item
31952 * @param {Number} x - horizontal position
31953 * @param {Number} y - vertical position
31954 * @param {Boolean} isInstant - disables transitions
31956 _processLayoutQueue : function( queue )
31958 for ( var i=0, len = queue.length; i < len; i++ ) {
31959 var obj = queue[i];
31960 obj.item.position('absolute');
31961 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31967 * Any logic you want to do after each layout,
31968 * i.e. size the container
31970 _postLayout : function()
31972 this.resizeContainer();
31975 resizeContainer : function()
31977 if ( !this.isResizingContainer ) {
31980 var size = this._getContainerSize();
31982 this.el.setSize(size.width,size.height);
31983 this.boxesEl.setSize(size.width,size.height);
31989 _resetLayout : function()
31991 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31992 this.colWidth = this.el.getWidth();
31993 //this.gutter = this.el.getWidth();
31995 this.measureColumns();
32001 this.colYs.push( 0 );
32007 measureColumns : function()
32009 this.getContainerWidth();
32010 // if columnWidth is 0, default to outerWidth of first item
32011 if ( !this.columnWidth ) {
32012 var firstItem = this.bricks.first();
32013 Roo.log(firstItem);
32014 this.columnWidth = this.containerWidth;
32015 if (firstItem && firstItem.attr('originalwidth') ) {
32016 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32018 // columnWidth fall back to item of first element
32019 Roo.log("set column width?");
32020 this.initialColumnWidth = this.columnWidth ;
32022 // if first elem has no width, default to size of container
32027 if (this.initialColumnWidth) {
32028 this.columnWidth = this.initialColumnWidth;
32033 // column width is fixed at the top - however if container width get's smaller we should
32036 // this bit calcs how man columns..
32038 var columnWidth = this.columnWidth += this.gutter;
32040 // calculate columns
32041 var containerWidth = this.containerWidth + this.gutter;
32043 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32044 // fix rounding errors, typically with gutters
32045 var excess = columnWidth - containerWidth % columnWidth;
32048 // if overshoot is less than a pixel, round up, otherwise floor it
32049 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32050 cols = Math[ mathMethod ]( cols );
32051 this.cols = Math.max( cols, 1 );
32052 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32054 // padding positioning..
32055 var totalColWidth = this.cols * this.columnWidth;
32056 var padavail = this.containerWidth - totalColWidth;
32057 // so for 2 columns - we need 3 'pads'
32059 var padNeeded = (1+this.cols) * this.padWidth;
32061 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32063 this.columnWidth += padExtra
32064 //this.padWidth = Math.floor(padavail / ( this.cols));
32066 // adjust colum width so that padding is fixed??
32068 // we have 3 columns ... total = width * 3
32069 // we have X left over... that should be used by
32071 //if (this.expandC) {
32079 getContainerWidth : function()
32081 /* // container is parent if fit width
32082 var container = this.isFitWidth ? this.element.parentNode : this.element;
32083 // check that this.size and size are there
32084 // IE8 triggers resize on body size change, so they might not be
32086 var size = getSize( container ); //FIXME
32087 this.containerWidth = size && size.innerWidth; //FIXME
32090 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32094 _getItemLayoutPosition : function( item ) // what is item?
32096 // we resize the item to our columnWidth..
32098 item.setWidth(this.columnWidth);
32099 item.autoBoxAdjust = false;
32101 var sz = item.getSize();
32103 // how many columns does this brick span
32104 var remainder = this.containerWidth % this.columnWidth;
32106 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32107 // round if off by 1 pixel, otherwise use ceil
32108 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32109 colSpan = Math.min( colSpan, this.cols );
32111 // normally this should be '1' as we dont' currently allow multi width columns..
32113 var colGroup = this._getColGroup( colSpan );
32114 // get the minimum Y value from the columns
32115 var minimumY = Math.min.apply( Math, colGroup );
32116 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32118 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32120 // position the brick
32122 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32123 y: this.currentSize.y + minimumY + this.padHeight
32127 // apply setHeight to necessary columns
32128 var setHeight = minimumY + sz.height + this.padHeight;
32129 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32131 var setSpan = this.cols + 1 - colGroup.length;
32132 for ( var i = 0; i < setSpan; i++ ) {
32133 this.colYs[ shortColIndex + i ] = setHeight ;
32140 * @param {Number} colSpan - number of columns the element spans
32141 * @returns {Array} colGroup
32143 _getColGroup : function( colSpan )
32145 if ( colSpan < 2 ) {
32146 // if brick spans only one column, use all the column Ys
32151 // how many different places could this brick fit horizontally
32152 var groupCount = this.cols + 1 - colSpan;
32153 // for each group potential horizontal position
32154 for ( var i = 0; i < groupCount; i++ ) {
32155 // make an array of colY values for that one group
32156 var groupColYs = this.colYs.slice( i, i + colSpan );
32157 // and get the max value of the array
32158 colGroup[i] = Math.max.apply( Math, groupColYs );
32163 _manageStamp : function( stamp )
32165 var stampSize = stamp.getSize();
32166 var offset = stamp.getBox();
32167 // get the columns that this stamp affects
32168 var firstX = this.isOriginLeft ? offset.x : offset.right;
32169 var lastX = firstX + stampSize.width;
32170 var firstCol = Math.floor( firstX / this.columnWidth );
32171 firstCol = Math.max( 0, firstCol );
32173 var lastCol = Math.floor( lastX / this.columnWidth );
32174 // lastCol should not go over if multiple of columnWidth #425
32175 lastCol -= lastX % this.columnWidth ? 0 : 1;
32176 lastCol = Math.min( this.cols - 1, lastCol );
32178 // set colYs to bottom of the stamp
32179 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32182 for ( var i = firstCol; i <= lastCol; i++ ) {
32183 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32188 _getContainerSize : function()
32190 this.maxY = Math.max.apply( Math, this.colYs );
32195 if ( this.isFitWidth ) {
32196 size.width = this._getContainerFitWidth();
32202 _getContainerFitWidth : function()
32204 var unusedCols = 0;
32205 // count unused columns
32208 if ( this.colYs[i] !== 0 ) {
32213 // fit container to columns that have been used
32214 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32217 needsResizeLayout : function()
32219 var previousWidth = this.containerWidth;
32220 this.getContainerWidth();
32221 return previousWidth !== this.containerWidth;
32236 * @class Roo.bootstrap.MasonryBrick
32237 * @extends Roo.bootstrap.Component
32238 * Bootstrap MasonryBrick class
32241 * Create a new MasonryBrick
32242 * @param {Object} config The config object
32245 Roo.bootstrap.MasonryBrick = function(config){
32247 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32249 Roo.bootstrap.MasonryBrick.register(this);
32255 * When a MasonryBrick is clcik
32256 * @param {Roo.bootstrap.MasonryBrick} this
32257 * @param {Roo.EventObject} e
32263 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32266 * @cfg {String} title
32270 * @cfg {String} html
32274 * @cfg {String} bgimage
32278 * @cfg {String} videourl
32282 * @cfg {String} cls
32286 * @cfg {String} href
32290 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32295 * @cfg {String} placetitle (center|bottom)
32300 * @cfg {Boolean} isFitContainer defalut true
32302 isFitContainer : true,
32305 * @cfg {Boolean} preventDefault defalut false
32307 preventDefault : false,
32310 * @cfg {Boolean} inverse defalut false
32312 maskInverse : false,
32314 getAutoCreate : function()
32316 if(!this.isFitContainer){
32317 return this.getSplitAutoCreate();
32320 var cls = 'masonry-brick masonry-brick-full';
32322 if(this.href.length){
32323 cls += ' masonry-brick-link';
32326 if(this.bgimage.length){
32327 cls += ' masonry-brick-image';
32330 if(this.maskInverse){
32331 cls += ' mask-inverse';
32334 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32335 cls += ' enable-mask';
32339 cls += ' masonry-' + this.size + '-brick';
32342 if(this.placetitle.length){
32344 switch (this.placetitle) {
32346 cls += ' masonry-center-title';
32349 cls += ' masonry-bottom-title';
32356 if(!this.html.length && !this.bgimage.length){
32357 cls += ' masonry-center-title';
32360 if(!this.html.length && this.bgimage.length){
32361 cls += ' masonry-bottom-title';
32366 cls += ' ' + this.cls;
32370 tag: (this.href.length) ? 'a' : 'div',
32375 cls: 'masonry-brick-mask'
32379 cls: 'masonry-brick-paragraph',
32385 if(this.href.length){
32386 cfg.href = this.href;
32389 var cn = cfg.cn[1].cn;
32391 if(this.title.length){
32394 cls: 'masonry-brick-title',
32399 if(this.html.length){
32402 cls: 'masonry-brick-text',
32407 if (!this.title.length && !this.html.length) {
32408 cfg.cn[1].cls += ' hide';
32411 if(this.bgimage.length){
32414 cls: 'masonry-brick-image-view',
32419 if(this.videourl.length){
32420 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32421 // youtube support only?
32424 cls: 'masonry-brick-image-view',
32427 allowfullscreen : true
32435 getSplitAutoCreate : function()
32437 var cls = 'masonry-brick masonry-brick-split';
32439 if(this.href.length){
32440 cls += ' masonry-brick-link';
32443 if(this.bgimage.length){
32444 cls += ' masonry-brick-image';
32448 cls += ' masonry-' + this.size + '-brick';
32451 switch (this.placetitle) {
32453 cls += ' masonry-center-title';
32456 cls += ' masonry-bottom-title';
32459 if(!this.bgimage.length){
32460 cls += ' masonry-center-title';
32463 if(this.bgimage.length){
32464 cls += ' masonry-bottom-title';
32470 cls += ' ' + this.cls;
32474 tag: (this.href.length) ? 'a' : 'div',
32479 cls: 'masonry-brick-split-head',
32483 cls: 'masonry-brick-paragraph',
32490 cls: 'masonry-brick-split-body',
32496 if(this.href.length){
32497 cfg.href = this.href;
32500 if(this.title.length){
32501 cfg.cn[0].cn[0].cn.push({
32503 cls: 'masonry-brick-title',
32508 if(this.html.length){
32509 cfg.cn[1].cn.push({
32511 cls: 'masonry-brick-text',
32516 if(this.bgimage.length){
32517 cfg.cn[0].cn.push({
32519 cls: 'masonry-brick-image-view',
32524 if(this.videourl.length){
32525 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32526 // youtube support only?
32527 cfg.cn[0].cn.cn.push({
32529 cls: 'masonry-brick-image-view',
32532 allowfullscreen : true
32539 initEvents: function()
32541 switch (this.size) {
32574 this.el.on('touchstart', this.onTouchStart, this);
32575 this.el.on('touchmove', this.onTouchMove, this);
32576 this.el.on('touchend', this.onTouchEnd, this);
32577 this.el.on('contextmenu', this.onContextMenu, this);
32579 this.el.on('mouseenter' ,this.enter, this);
32580 this.el.on('mouseleave', this.leave, this);
32581 this.el.on('click', this.onClick, this);
32584 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32585 this.parent().bricks.push(this);
32590 onClick: function(e, el)
32592 var time = this.endTimer - this.startTimer;
32593 // Roo.log(e.preventDefault());
32596 e.preventDefault();
32601 if(!this.preventDefault){
32605 e.preventDefault();
32607 if (this.activcClass != '') {
32608 this.selectBrick();
32611 this.fireEvent('click', this);
32614 enter: function(e, el)
32616 e.preventDefault();
32618 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32622 if(this.bgimage.length && this.html.length){
32623 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32627 leave: function(e, el)
32629 e.preventDefault();
32631 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32635 if(this.bgimage.length && this.html.length){
32636 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32640 onTouchStart: function(e, el)
32642 // e.preventDefault();
32644 this.touchmoved = false;
32646 if(!this.isFitContainer){
32650 if(!this.bgimage.length || !this.html.length){
32654 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32656 this.timer = new Date().getTime();
32660 onTouchMove: function(e, el)
32662 this.touchmoved = true;
32665 onContextMenu : function(e,el)
32667 e.preventDefault();
32668 e.stopPropagation();
32672 onTouchEnd: function(e, el)
32674 // e.preventDefault();
32676 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32683 if(!this.bgimage.length || !this.html.length){
32685 if(this.href.length){
32686 window.location.href = this.href;
32692 if(!this.isFitContainer){
32696 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32698 window.location.href = this.href;
32701 //selection on single brick only
32702 selectBrick : function() {
32704 if (!this.parentId) {
32708 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32709 var index = m.selectedBrick.indexOf(this.id);
32712 m.selectedBrick.splice(index,1);
32713 this.el.removeClass(this.activeClass);
32717 for(var i = 0; i < m.selectedBrick.length; i++) {
32718 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32719 b.el.removeClass(b.activeClass);
32722 m.selectedBrick = [];
32724 m.selectedBrick.push(this.id);
32725 this.el.addClass(this.activeClass);
32731 Roo.apply(Roo.bootstrap.MasonryBrick, {
32734 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32736 * register a Masonry Brick
32737 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32740 register : function(brick)
32742 //this.groups[brick.id] = brick;
32743 this.groups.add(brick.id, brick);
32746 * fetch a masonry brick based on the masonry brick ID
32747 * @param {string} the masonry brick to add
32748 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32751 get: function(brick_id)
32753 // if (typeof(this.groups[brick_id]) == 'undefined') {
32756 // return this.groups[brick_id] ;
32758 if(this.groups.key(brick_id)) {
32759 return this.groups.key(brick_id);
32777 * @class Roo.bootstrap.Brick
32778 * @extends Roo.bootstrap.Component
32779 * Bootstrap Brick class
32782 * Create a new Brick
32783 * @param {Object} config The config object
32786 Roo.bootstrap.Brick = function(config){
32787 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32793 * When a Brick is click
32794 * @param {Roo.bootstrap.Brick} this
32795 * @param {Roo.EventObject} e
32801 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32804 * @cfg {String} title
32808 * @cfg {String} html
32812 * @cfg {String} bgimage
32816 * @cfg {String} cls
32820 * @cfg {String} href
32824 * @cfg {String} video
32828 * @cfg {Boolean} square
32832 getAutoCreate : function()
32834 var cls = 'roo-brick';
32836 if(this.href.length){
32837 cls += ' roo-brick-link';
32840 if(this.bgimage.length){
32841 cls += ' roo-brick-image';
32844 if(!this.html.length && !this.bgimage.length){
32845 cls += ' roo-brick-center-title';
32848 if(!this.html.length && this.bgimage.length){
32849 cls += ' roo-brick-bottom-title';
32853 cls += ' ' + this.cls;
32857 tag: (this.href.length) ? 'a' : 'div',
32862 cls: 'roo-brick-paragraph',
32868 if(this.href.length){
32869 cfg.href = this.href;
32872 var cn = cfg.cn[0].cn;
32874 if(this.title.length){
32877 cls: 'roo-brick-title',
32882 if(this.html.length){
32885 cls: 'roo-brick-text',
32892 if(this.bgimage.length){
32895 cls: 'roo-brick-image-view',
32903 initEvents: function()
32905 if(this.title.length || this.html.length){
32906 this.el.on('mouseenter' ,this.enter, this);
32907 this.el.on('mouseleave', this.leave, this);
32910 Roo.EventManager.onWindowResize(this.resize, this);
32912 if(this.bgimage.length){
32913 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32914 this.imageEl.on('load', this.onImageLoad, this);
32921 onImageLoad : function()
32926 resize : function()
32928 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32930 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32932 if(this.bgimage.length){
32933 var image = this.el.select('.roo-brick-image-view', true).first();
32935 image.setWidth(paragraph.getWidth());
32938 image.setHeight(paragraph.getWidth());
32941 this.el.setHeight(image.getHeight());
32942 paragraph.setHeight(image.getHeight());
32948 enter: function(e, el)
32950 e.preventDefault();
32952 if(this.bgimage.length){
32953 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32954 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32958 leave: function(e, el)
32960 e.preventDefault();
32962 if(this.bgimage.length){
32963 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32964 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32980 * @class Roo.bootstrap.NumberField
32981 * @extends Roo.bootstrap.Input
32982 * Bootstrap NumberField class
32988 * Create a new NumberField
32989 * @param {Object} config The config object
32992 Roo.bootstrap.NumberField = function(config){
32993 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32996 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32999 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33001 allowDecimals : true,
33003 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33005 decimalSeparator : ".",
33007 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33009 decimalPrecision : 2,
33011 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33013 allowNegative : true,
33015 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33017 minValue : Number.NEGATIVE_INFINITY,
33019 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33021 maxValue : Number.MAX_VALUE,
33023 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33025 minText : "The minimum value for this field is {0}",
33027 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33029 maxText : "The maximum value for this field is {0}",
33031 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33032 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33034 nanText : "{0} is not a valid number",
33036 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
33041 initEvents : function()
33043 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33045 var allowed = "0123456789";
33047 if(this.allowDecimals){
33048 allowed += this.decimalSeparator;
33051 if(this.allowNegative){
33055 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33057 var keyPress = function(e){
33059 var k = e.getKey();
33061 var c = e.getCharCode();
33064 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33065 allowed.indexOf(String.fromCharCode(c)) === -1
33071 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33075 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33080 this.el.on("keypress", keyPress, this);
33083 validateValue : function(value)
33086 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33090 var num = this.parseValue(value);
33093 this.markInvalid(String.format(this.nanText, value));
33097 if(num < this.minValue){
33098 this.markInvalid(String.format(this.minText, this.minValue));
33102 if(num > this.maxValue){
33103 this.markInvalid(String.format(this.maxText, this.maxValue));
33110 getValue : function()
33112 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
33115 parseValue : function(value)
33117 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33118 return isNaN(value) ? '' : value;
33121 fixPrecision : function(value)
33123 var nan = isNaN(value);
33125 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33126 return nan ? '' : value;
33128 return parseFloat(value).toFixed(this.decimalPrecision);
33131 setValue : function(v)
33133 v = this.fixPrecision(v);
33134 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
33137 decimalPrecisionFcn : function(v)
33139 return Math.floor(v);
33142 beforeBlur : function()
33148 var v = this.parseValue(this.getRawValue());
33163 * @class Roo.bootstrap.DocumentSlider
33164 * @extends Roo.bootstrap.Component
33165 * Bootstrap DocumentSlider class
33168 * Create a new DocumentViewer
33169 * @param {Object} config The config object
33172 Roo.bootstrap.DocumentSlider = function(config){
33173 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33180 * Fire after initEvent
33181 * @param {Roo.bootstrap.DocumentSlider} this
33186 * Fire after update
33187 * @param {Roo.bootstrap.DocumentSlider} this
33193 * @param {Roo.bootstrap.DocumentSlider} this
33199 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33205 getAutoCreate : function()
33209 cls : 'roo-document-slider',
33213 cls : 'roo-document-slider-header',
33217 cls : 'roo-document-slider-header-title'
33223 cls : 'roo-document-slider-body',
33227 cls : 'roo-document-slider-prev',
33231 cls : 'fa fa-chevron-left'
33237 cls : 'roo-document-slider-thumb',
33241 cls : 'roo-document-slider-image'
33247 cls : 'roo-document-slider-next',
33251 cls : 'fa fa-chevron-right'
33263 initEvents : function()
33265 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33266 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33268 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33269 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33271 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33272 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33274 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33275 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33277 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33278 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33280 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33281 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33283 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33284 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33286 this.thumbEl.on('click', this.onClick, this);
33288 this.prevIndicator.on('click', this.prev, this);
33290 this.nextIndicator.on('click', this.next, this);
33294 initial : function()
33296 if(this.files.length){
33297 this.indicator = 1;
33301 this.fireEvent('initial', this);
33304 update : function()
33306 this.imageEl.attr('src', this.files[this.indicator - 1]);
33308 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33310 this.prevIndicator.show();
33312 if(this.indicator == 1){
33313 this.prevIndicator.hide();
33316 this.nextIndicator.show();
33318 if(this.indicator == this.files.length){
33319 this.nextIndicator.hide();
33322 this.thumbEl.scrollTo('top');
33324 this.fireEvent('update', this);
33327 onClick : function(e)
33329 e.preventDefault();
33331 this.fireEvent('click', this);
33336 e.preventDefault();
33338 this.indicator = Math.max(1, this.indicator - 1);
33345 e.preventDefault();
33347 this.indicator = Math.min(this.files.length, this.indicator + 1);
33361 * @class Roo.bootstrap.RadioSet
33362 * @extends Roo.bootstrap.Input
33363 * Bootstrap RadioSet class
33364 * @cfg {String} indicatorpos (left|right) default left
33365 * @cfg {Boolean} inline (true|false) inline the element (default true)
33366 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33368 * Create a new RadioSet
33369 * @param {Object} config The config object
33372 Roo.bootstrap.RadioSet = function(config){
33374 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33378 Roo.bootstrap.RadioSet.register(this);
33383 * Fires when the element is checked or unchecked.
33384 * @param {Roo.bootstrap.RadioSet} this This radio
33385 * @param {Roo.bootstrap.Radio} item The checked item
33392 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33400 indicatorpos : 'left',
33402 getAutoCreate : function()
33406 cls : 'roo-radio-set-label',
33410 html : this.fieldLabel
33415 if(this.indicatorpos == 'left'){
33418 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33419 tooltip : 'This field is required'
33424 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33425 tooltip : 'This field is required'
33431 cls : 'roo-radio-set-items'
33434 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33436 if (align === 'left' && this.fieldLabel.length) {
33439 cls : "roo-radio-set-right",
33445 if(this.labelWidth > 12){
33446 label.style = "width: " + this.labelWidth + 'px';
33449 if(this.labelWidth < 13 && this.labelmd == 0){
33450 this.labelmd = this.labelWidth;
33453 if(this.labellg > 0){
33454 label.cls += ' col-lg-' + this.labellg;
33455 items.cls += ' col-lg-' + (12 - this.labellg);
33458 if(this.labelmd > 0){
33459 label.cls += ' col-md-' + this.labelmd;
33460 items.cls += ' col-md-' + (12 - this.labelmd);
33463 if(this.labelsm > 0){
33464 label.cls += ' col-sm-' + this.labelsm;
33465 items.cls += ' col-sm-' + (12 - this.labelsm);
33468 if(this.labelxs > 0){
33469 label.cls += ' col-xs-' + this.labelxs;
33470 items.cls += ' col-xs-' + (12 - this.labelxs);
33476 cls : 'roo-radio-set',
33480 cls : 'roo-radio-set-input',
33483 value : this.value ? this.value : ''
33490 if(this.weight.length){
33491 cfg.cls += ' roo-radio-' + this.weight;
33495 cfg.cls += ' roo-radio-set-inline';
33499 ['xs','sm','md','lg'].map(function(size){
33500 if (settings[size]) {
33501 cfg.cls += ' col-' + size + '-' + settings[size];
33509 initEvents : function()
33511 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33512 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33514 if(!this.fieldLabel.length){
33515 this.labelEl.hide();
33518 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33519 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33521 this.indicatorEl().addClass('invisible');
33523 this.originalValue = this.getValue();
33527 inputEl: function ()
33529 return this.el.select('.roo-radio-set-input', true).first();
33532 getChildContainer : function()
33534 return this.itemsEl;
33537 register : function(item)
33539 this.radioes.push(item);
33543 validate : function()
33547 Roo.each(this.radioes, function(i){
33556 if(this.allowBlank) {
33560 if(this.disabled || valid){
33565 this.markInvalid();
33570 markValid : function()
33572 if(this.labelEl.isVisible(true)){
33573 this.indicatorEl().removeClass('visible');
33574 this.indicatorEl().addClass('invisible');
33577 this.el.removeClass([this.invalidClass, this.validClass]);
33578 this.el.addClass(this.validClass);
33580 this.fireEvent('valid', this);
33583 markInvalid : function(msg)
33585 if(this.allowBlank || this.disabled){
33589 if(this.labelEl.isVisible(true)){
33590 this.indicatorEl().removeClass('invisible');
33591 this.indicatorEl().addClass('visible');
33594 this.el.removeClass([this.invalidClass, this.validClass]);
33595 this.el.addClass(this.invalidClass);
33597 this.fireEvent('invalid', this, msg);
33601 setValue : function(v, suppressEvent)
33603 if(this.value === v){
33610 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33613 Roo.each(this.radioes, function(i){
33616 i.el.removeClass('checked');
33618 if(i.value === v || i.value.toString() === v.toString()){
33620 i.el.addClass('checked');
33622 if(suppressEvent !== true){
33623 this.fireEvent('check', this, i);
33632 clearInvalid : function(){
33634 if(!this.el || this.preventMark){
33638 this.el.removeClass([this.invalidClass]);
33640 this.fireEvent('valid', this);
33645 Roo.apply(Roo.bootstrap.RadioSet, {
33649 register : function(set)
33651 this.groups[set.name] = set;
33654 get: function(name)
33656 if (typeof(this.groups[name]) == 'undefined') {
33660 return this.groups[name] ;
33666 * Ext JS Library 1.1.1
33667 * Copyright(c) 2006-2007, Ext JS, LLC.
33669 * Originally Released Under LGPL - original licence link has changed is not relivant.
33672 * <script type="text/javascript">
33677 * @class Roo.bootstrap.SplitBar
33678 * @extends Roo.util.Observable
33679 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33683 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33684 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33685 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33686 split.minSize = 100;
33687 split.maxSize = 600;
33688 split.animate = true;
33689 split.on('moved', splitterMoved);
33692 * Create a new SplitBar
33693 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33694 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33695 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33696 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33697 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33698 position of the SplitBar).
33700 Roo.bootstrap.SplitBar = function(cfg){
33705 // dragElement : elm
33706 // resizingElement: el,
33708 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33709 // placement : Roo.bootstrap.SplitBar.LEFT ,
33710 // existingProxy ???
33713 this.el = Roo.get(cfg.dragElement, true);
33714 this.el.dom.unselectable = "on";
33716 this.resizingEl = Roo.get(cfg.resizingElement, true);
33720 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33721 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33724 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33727 * The minimum size of the resizing element. (Defaults to 0)
33733 * The maximum size of the resizing element. (Defaults to 2000)
33736 this.maxSize = 2000;
33739 * Whether to animate the transition to the new size
33742 this.animate = false;
33745 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33748 this.useShim = false;
33753 if(!cfg.existingProxy){
33755 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33757 this.proxy = Roo.get(cfg.existingProxy).dom;
33760 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33763 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33766 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33769 this.dragSpecs = {};
33772 * @private The adapter to use to positon and resize elements
33774 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33775 this.adapter.init(this);
33777 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33779 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33780 this.el.addClass("roo-splitbar-h");
33783 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33784 this.el.addClass("roo-splitbar-v");
33790 * Fires when the splitter is moved (alias for {@link #event-moved})
33791 * @param {Roo.bootstrap.SplitBar} this
33792 * @param {Number} newSize the new width or height
33797 * Fires when the splitter is moved
33798 * @param {Roo.bootstrap.SplitBar} this
33799 * @param {Number} newSize the new width or height
33803 * @event beforeresize
33804 * Fires before the splitter is dragged
33805 * @param {Roo.bootstrap.SplitBar} this
33807 "beforeresize" : true,
33809 "beforeapply" : true
33812 Roo.util.Observable.call(this);
33815 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33816 onStartProxyDrag : function(x, y){
33817 this.fireEvent("beforeresize", this);
33819 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33821 o.enableDisplayMode("block");
33822 // all splitbars share the same overlay
33823 Roo.bootstrap.SplitBar.prototype.overlay = o;
33825 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33826 this.overlay.show();
33827 Roo.get(this.proxy).setDisplayed("block");
33828 var size = this.adapter.getElementSize(this);
33829 this.activeMinSize = this.getMinimumSize();;
33830 this.activeMaxSize = this.getMaximumSize();;
33831 var c1 = size - this.activeMinSize;
33832 var c2 = Math.max(this.activeMaxSize - size, 0);
33833 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33834 this.dd.resetConstraints();
33835 this.dd.setXConstraint(
33836 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33837 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33839 this.dd.setYConstraint(0, 0);
33841 this.dd.resetConstraints();
33842 this.dd.setXConstraint(0, 0);
33843 this.dd.setYConstraint(
33844 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33845 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33848 this.dragSpecs.startSize = size;
33849 this.dragSpecs.startPoint = [x, y];
33850 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33854 * @private Called after the drag operation by the DDProxy
33856 onEndProxyDrag : function(e){
33857 Roo.get(this.proxy).setDisplayed(false);
33858 var endPoint = Roo.lib.Event.getXY(e);
33860 this.overlay.hide();
33863 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33864 newSize = this.dragSpecs.startSize +
33865 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33866 endPoint[0] - this.dragSpecs.startPoint[0] :
33867 this.dragSpecs.startPoint[0] - endPoint[0]
33870 newSize = this.dragSpecs.startSize +
33871 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33872 endPoint[1] - this.dragSpecs.startPoint[1] :
33873 this.dragSpecs.startPoint[1] - endPoint[1]
33876 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33877 if(newSize != this.dragSpecs.startSize){
33878 if(this.fireEvent('beforeapply', this, newSize) !== false){
33879 this.adapter.setElementSize(this, newSize);
33880 this.fireEvent("moved", this, newSize);
33881 this.fireEvent("resize", this, newSize);
33887 * Get the adapter this SplitBar uses
33888 * @return The adapter object
33890 getAdapter : function(){
33891 return this.adapter;
33895 * Set the adapter this SplitBar uses
33896 * @param {Object} adapter A SplitBar adapter object
33898 setAdapter : function(adapter){
33899 this.adapter = adapter;
33900 this.adapter.init(this);
33904 * Gets the minimum size for the resizing element
33905 * @return {Number} The minimum size
33907 getMinimumSize : function(){
33908 return this.minSize;
33912 * Sets the minimum size for the resizing element
33913 * @param {Number} minSize The minimum size
33915 setMinimumSize : function(minSize){
33916 this.minSize = minSize;
33920 * Gets the maximum size for the resizing element
33921 * @return {Number} The maximum size
33923 getMaximumSize : function(){
33924 return this.maxSize;
33928 * Sets the maximum size for the resizing element
33929 * @param {Number} maxSize The maximum size
33931 setMaximumSize : function(maxSize){
33932 this.maxSize = maxSize;
33936 * Sets the initialize size for the resizing element
33937 * @param {Number} size The initial size
33939 setCurrentSize : function(size){
33940 var oldAnimate = this.animate;
33941 this.animate = false;
33942 this.adapter.setElementSize(this, size);
33943 this.animate = oldAnimate;
33947 * Destroy this splitbar.
33948 * @param {Boolean} removeEl True to remove the element
33950 destroy : function(removeEl){
33952 this.shim.remove();
33955 this.proxy.parentNode.removeChild(this.proxy);
33963 * @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.
33965 Roo.bootstrap.SplitBar.createProxy = function(dir){
33966 var proxy = new Roo.Element(document.createElement("div"));
33967 proxy.unselectable();
33968 var cls = 'roo-splitbar-proxy';
33969 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
33970 document.body.appendChild(proxy.dom);
33975 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
33976 * Default Adapter. It assumes the splitter and resizing element are not positioned
33977 * elements and only gets/sets the width of the element. Generally used for table based layouts.
33979 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
33982 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
33983 // do nothing for now
33984 init : function(s){
33988 * Called before drag operations to get the current size of the resizing element.
33989 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33991 getElementSize : function(s){
33992 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33993 return s.resizingEl.getWidth();
33995 return s.resizingEl.getHeight();
34000 * Called after drag operations to set the size of the resizing element.
34001 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34002 * @param {Number} newSize The new size to set
34003 * @param {Function} onComplete A function to be invoked when resizing is complete
34005 setElementSize : function(s, newSize, onComplete){
34006 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34008 s.resizingEl.setWidth(newSize);
34010 onComplete(s, newSize);
34013 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34018 s.resizingEl.setHeight(newSize);
34020 onComplete(s, newSize);
34023 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34030 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34031 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34032 * Adapter that moves the splitter element to align with the resized sizing element.
34033 * Used with an absolute positioned SplitBar.
34034 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34035 * document.body, make sure you assign an id to the body element.
34037 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34038 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34039 this.container = Roo.get(container);
34042 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34043 init : function(s){
34044 this.basic.init(s);
34047 getElementSize : function(s){
34048 return this.basic.getElementSize(s);
34051 setElementSize : function(s, newSize, onComplete){
34052 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34055 moveSplitter : function(s){
34056 var yes = Roo.bootstrap.SplitBar;
34057 switch(s.placement){
34059 s.el.setX(s.resizingEl.getRight());
34062 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34065 s.el.setY(s.resizingEl.getBottom());
34068 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34075 * Orientation constant - Create a vertical SplitBar
34079 Roo.bootstrap.SplitBar.VERTICAL = 1;
34082 * Orientation constant - Create a horizontal SplitBar
34086 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34089 * Placement constant - The resizing element is to the left of the splitter element
34093 Roo.bootstrap.SplitBar.LEFT = 1;
34096 * Placement constant - The resizing element is to the right of the splitter element
34100 Roo.bootstrap.SplitBar.RIGHT = 2;
34103 * Placement constant - The resizing element is positioned above the splitter element
34107 Roo.bootstrap.SplitBar.TOP = 3;
34110 * Placement constant - The resizing element is positioned under splitter element
34114 Roo.bootstrap.SplitBar.BOTTOM = 4;
34115 Roo.namespace("Roo.bootstrap.layout");/*
34117 * Ext JS Library 1.1.1
34118 * Copyright(c) 2006-2007, Ext JS, LLC.
34120 * Originally Released Under LGPL - original licence link has changed is not relivant.
34123 * <script type="text/javascript">
34127 * @class Roo.bootstrap.layout.Manager
34128 * @extends Roo.bootstrap.Component
34129 * Base class for layout managers.
34131 Roo.bootstrap.layout.Manager = function(config)
34133 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34139 /** false to disable window resize monitoring @type Boolean */
34140 this.monitorWindowResize = true;
34145 * Fires when a layout is performed.
34146 * @param {Roo.LayoutManager} this
34150 * @event regionresized
34151 * Fires when the user resizes a region.
34152 * @param {Roo.LayoutRegion} region The resized region
34153 * @param {Number} newSize The new size (width for east/west, height for north/south)
34155 "regionresized" : true,
34157 * @event regioncollapsed
34158 * Fires when a region is collapsed.
34159 * @param {Roo.LayoutRegion} region The collapsed region
34161 "regioncollapsed" : true,
34163 * @event regionexpanded
34164 * Fires when a region is expanded.
34165 * @param {Roo.LayoutRegion} region The expanded region
34167 "regionexpanded" : true
34169 this.updating = false;
34172 this.el = Roo.get(config.el);
34178 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34183 monitorWindowResize : true,
34189 onRender : function(ct, position)
34192 this.el = Roo.get(ct);
34195 //this.fireEvent('render',this);
34199 initEvents: function()
34203 // ie scrollbar fix
34204 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34205 document.body.scroll = "no";
34206 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34207 this.el.position('relative');
34209 this.id = this.el.id;
34210 this.el.addClass("roo-layout-container");
34211 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34212 if(this.el.dom != document.body ) {
34213 this.el.on('resize', this.layout,this);
34214 this.el.on('show', this.layout,this);
34220 * Returns true if this layout is currently being updated
34221 * @return {Boolean}
34223 isUpdating : function(){
34224 return this.updating;
34228 * Suspend the LayoutManager from doing auto-layouts while
34229 * making multiple add or remove calls
34231 beginUpdate : function(){
34232 this.updating = true;
34236 * Restore auto-layouts and optionally disable the manager from performing a layout
34237 * @param {Boolean} noLayout true to disable a layout update
34239 endUpdate : function(noLayout){
34240 this.updating = false;
34246 layout: function(){
34250 onRegionResized : function(region, newSize){
34251 this.fireEvent("regionresized", region, newSize);
34255 onRegionCollapsed : function(region){
34256 this.fireEvent("regioncollapsed", region);
34259 onRegionExpanded : function(region){
34260 this.fireEvent("regionexpanded", region);
34264 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34265 * performs box-model adjustments.
34266 * @return {Object} The size as an object {width: (the width), height: (the height)}
34268 getViewSize : function()
34271 if(this.el.dom != document.body){
34272 size = this.el.getSize();
34274 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34276 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34277 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34282 * Returns the Element this layout is bound to.
34283 * @return {Roo.Element}
34285 getEl : function(){
34290 * Returns the specified region.
34291 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34292 * @return {Roo.LayoutRegion}
34294 getRegion : function(target){
34295 return this.regions[target.toLowerCase()];
34298 onWindowResize : function(){
34299 if(this.monitorWindowResize){
34306 * Ext JS Library 1.1.1
34307 * Copyright(c) 2006-2007, Ext JS, LLC.
34309 * Originally Released Under LGPL - original licence link has changed is not relivant.
34312 * <script type="text/javascript">
34315 * @class Roo.bootstrap.layout.Border
34316 * @extends Roo.bootstrap.layout.Manager
34317 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34318 * please see: examples/bootstrap/nested.html<br><br>
34320 <b>The container the layout is rendered into can be either the body element or any other element.
34321 If it is not the body element, the container needs to either be an absolute positioned element,
34322 or you will need to add "position:relative" to the css of the container. You will also need to specify
34323 the container size if it is not the body element.</b>
34326 * Create a new Border
34327 * @param {Object} config Configuration options
34329 Roo.bootstrap.layout.Border = function(config){
34330 config = config || {};
34331 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34335 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34336 if(config[region]){
34337 config[region].region = region;
34338 this.addRegion(config[region]);
34344 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34346 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34348 * Creates and adds a new region if it doesn't already exist.
34349 * @param {String} target The target region key (north, south, east, west or center).
34350 * @param {Object} config The regions config object
34351 * @return {BorderLayoutRegion} The new region
34353 addRegion : function(config)
34355 if(!this.regions[config.region]){
34356 var r = this.factory(config);
34357 this.bindRegion(r);
34359 return this.regions[config.region];
34363 bindRegion : function(r){
34364 this.regions[r.config.region] = r;
34366 r.on("visibilitychange", this.layout, this);
34367 r.on("paneladded", this.layout, this);
34368 r.on("panelremoved", this.layout, this);
34369 r.on("invalidated", this.layout, this);
34370 r.on("resized", this.onRegionResized, this);
34371 r.on("collapsed", this.onRegionCollapsed, this);
34372 r.on("expanded", this.onRegionExpanded, this);
34376 * Performs a layout update.
34378 layout : function()
34380 if(this.updating) {
34384 // render all the rebions if they have not been done alreayd?
34385 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34386 if(this.regions[region] && !this.regions[region].bodyEl){
34387 this.regions[region].onRender(this.el)
34391 var size = this.getViewSize();
34392 var w = size.width;
34393 var h = size.height;
34398 //var x = 0, y = 0;
34400 var rs = this.regions;
34401 var north = rs["north"];
34402 var south = rs["south"];
34403 var west = rs["west"];
34404 var east = rs["east"];
34405 var center = rs["center"];
34406 //if(this.hideOnLayout){ // not supported anymore
34407 //c.el.setStyle("display", "none");
34409 if(north && north.isVisible()){
34410 var b = north.getBox();
34411 var m = north.getMargins();
34412 b.width = w - (m.left+m.right);
34415 centerY = b.height + b.y + m.bottom;
34416 centerH -= centerY;
34417 north.updateBox(this.safeBox(b));
34419 if(south && south.isVisible()){
34420 var b = south.getBox();
34421 var m = south.getMargins();
34422 b.width = w - (m.left+m.right);
34424 var totalHeight = (b.height + m.top + m.bottom);
34425 b.y = h - totalHeight + m.top;
34426 centerH -= totalHeight;
34427 south.updateBox(this.safeBox(b));
34429 if(west && west.isVisible()){
34430 var b = west.getBox();
34431 var m = west.getMargins();
34432 b.height = centerH - (m.top+m.bottom);
34434 b.y = centerY + m.top;
34435 var totalWidth = (b.width + m.left + m.right);
34436 centerX += totalWidth;
34437 centerW -= totalWidth;
34438 west.updateBox(this.safeBox(b));
34440 if(east && east.isVisible()){
34441 var b = east.getBox();
34442 var m = east.getMargins();
34443 b.height = centerH - (m.top+m.bottom);
34444 var totalWidth = (b.width + m.left + m.right);
34445 b.x = w - totalWidth + m.left;
34446 b.y = centerY + m.top;
34447 centerW -= totalWidth;
34448 east.updateBox(this.safeBox(b));
34451 var m = center.getMargins();
34453 x: centerX + m.left,
34454 y: centerY + m.top,
34455 width: centerW - (m.left+m.right),
34456 height: centerH - (m.top+m.bottom)
34458 //if(this.hideOnLayout){
34459 //center.el.setStyle("display", "block");
34461 center.updateBox(this.safeBox(centerBox));
34464 this.fireEvent("layout", this);
34468 safeBox : function(box){
34469 box.width = Math.max(0, box.width);
34470 box.height = Math.max(0, box.height);
34475 * Adds a ContentPanel (or subclass) to this layout.
34476 * @param {String} target The target region key (north, south, east, west or center).
34477 * @param {Roo.ContentPanel} panel The panel to add
34478 * @return {Roo.ContentPanel} The added panel
34480 add : function(target, panel){
34482 target = target.toLowerCase();
34483 return this.regions[target].add(panel);
34487 * Remove a ContentPanel (or subclass) to this layout.
34488 * @param {String} target The target region key (north, south, east, west or center).
34489 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34490 * @return {Roo.ContentPanel} The removed panel
34492 remove : function(target, panel){
34493 target = target.toLowerCase();
34494 return this.regions[target].remove(panel);
34498 * Searches all regions for a panel with the specified id
34499 * @param {String} panelId
34500 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34502 findPanel : function(panelId){
34503 var rs = this.regions;
34504 for(var target in rs){
34505 if(typeof rs[target] != "function"){
34506 var p = rs[target].getPanel(panelId);
34516 * Searches all regions for a panel with the specified id and activates (shows) it.
34517 * @param {String/ContentPanel} panelId The panels id or the panel itself
34518 * @return {Roo.ContentPanel} The shown panel or null
34520 showPanel : function(panelId) {
34521 var rs = this.regions;
34522 for(var target in rs){
34523 var r = rs[target];
34524 if(typeof r != "function"){
34525 if(r.hasPanel(panelId)){
34526 return r.showPanel(panelId);
34534 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34535 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34538 restoreState : function(provider){
34540 provider = Roo.state.Manager;
34542 var sm = new Roo.LayoutStateManager();
34543 sm.init(this, provider);
34549 * Adds a xtype elements to the layout.
34553 xtype : 'ContentPanel',
34560 xtype : 'NestedLayoutPanel',
34566 items : [ ... list of content panels or nested layout panels.. ]
34570 * @param {Object} cfg Xtype definition of item to add.
34572 addxtype : function(cfg)
34574 // basically accepts a pannel...
34575 // can accept a layout region..!?!?
34576 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34579 // theory? children can only be panels??
34581 //if (!cfg.xtype.match(/Panel$/)) {
34586 if (typeof(cfg.region) == 'undefined') {
34587 Roo.log("Failed to add Panel, region was not set");
34591 var region = cfg.region;
34597 xitems = cfg.items;
34604 case 'Content': // ContentPanel (el, cfg)
34605 case 'Scroll': // ContentPanel (el, cfg)
34607 cfg.autoCreate = true;
34608 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34610 // var el = this.el.createChild();
34611 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34614 this.add(region, ret);
34618 case 'TreePanel': // our new panel!
34619 cfg.el = this.el.createChild();
34620 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34621 this.add(region, ret);
34626 // create a new Layout (which is a Border Layout...
34628 var clayout = cfg.layout;
34629 clayout.el = this.el.createChild();
34630 clayout.items = clayout.items || [];
34634 // replace this exitems with the clayout ones..
34635 xitems = clayout.items;
34637 // force background off if it's in center...
34638 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34639 cfg.background = false;
34641 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34644 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34645 //console.log('adding nested layout panel ' + cfg.toSource());
34646 this.add(region, ret);
34647 nb = {}; /// find first...
34652 // needs grid and region
34654 //var el = this.getRegion(region).el.createChild();
34656 *var el = this.el.createChild();
34657 // create the grid first...
34658 cfg.grid.container = el;
34659 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34662 if (region == 'center' && this.active ) {
34663 cfg.background = false;
34666 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34668 this.add(region, ret);
34670 if (cfg.background) {
34671 // render grid on panel activation (if panel background)
34672 ret.on('activate', function(gp) {
34673 if (!gp.grid.rendered) {
34674 // gp.grid.render(el);
34678 // cfg.grid.render(el);
34684 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34685 // it was the old xcomponent building that caused this before.
34686 // espeically if border is the top element in the tree.
34696 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34698 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34699 this.add(region, ret);
34703 throw "Can not add '" + cfg.xtype + "' to Border";
34709 this.beginUpdate();
34713 Roo.each(xitems, function(i) {
34714 region = nb && i.region ? i.region : false;
34716 var add = ret.addxtype(i);
34719 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34720 if (!i.background) {
34721 abn[region] = nb[region] ;
34728 // make the last non-background panel active..
34729 //if (nb) { Roo.log(abn); }
34732 for(var r in abn) {
34733 region = this.getRegion(r);
34735 // tried using nb[r], but it does not work..
34737 region.showPanel(abn[r]);
34748 factory : function(cfg)
34751 var validRegions = Roo.bootstrap.layout.Border.regions;
34753 var target = cfg.region;
34756 var r = Roo.bootstrap.layout;
34760 return new r.North(cfg);
34762 return new r.South(cfg);
34764 return new r.East(cfg);
34766 return new r.West(cfg);
34768 return new r.Center(cfg);
34770 throw 'Layout region "'+target+'" not supported.';
34777 * Ext JS Library 1.1.1
34778 * Copyright(c) 2006-2007, Ext JS, LLC.
34780 * Originally Released Under LGPL - original licence link has changed is not relivant.
34783 * <script type="text/javascript">
34787 * @class Roo.bootstrap.layout.Basic
34788 * @extends Roo.util.Observable
34789 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34790 * and does not have a titlebar, tabs or any other features. All it does is size and position
34791 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34792 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34793 * @cfg {string} region the region that it inhabits..
34794 * @cfg {bool} skipConfig skip config?
34798 Roo.bootstrap.layout.Basic = function(config){
34800 this.mgr = config.mgr;
34802 this.position = config.region;
34804 var skipConfig = config.skipConfig;
34808 * @scope Roo.BasicLayoutRegion
34812 * @event beforeremove
34813 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34814 * @param {Roo.LayoutRegion} this
34815 * @param {Roo.ContentPanel} panel The panel
34816 * @param {Object} e The cancel event object
34818 "beforeremove" : true,
34820 * @event invalidated
34821 * Fires when the layout for this region is changed.
34822 * @param {Roo.LayoutRegion} this
34824 "invalidated" : true,
34826 * @event visibilitychange
34827 * Fires when this region is shown or hidden
34828 * @param {Roo.LayoutRegion} this
34829 * @param {Boolean} visibility true or false
34831 "visibilitychange" : true,
34833 * @event paneladded
34834 * Fires when a panel is added.
34835 * @param {Roo.LayoutRegion} this
34836 * @param {Roo.ContentPanel} panel The panel
34838 "paneladded" : true,
34840 * @event panelremoved
34841 * Fires when a panel is removed.
34842 * @param {Roo.LayoutRegion} this
34843 * @param {Roo.ContentPanel} panel The panel
34845 "panelremoved" : true,
34847 * @event beforecollapse
34848 * Fires when this region before collapse.
34849 * @param {Roo.LayoutRegion} this
34851 "beforecollapse" : true,
34854 * Fires when this region is collapsed.
34855 * @param {Roo.LayoutRegion} this
34857 "collapsed" : true,
34860 * Fires when this region is expanded.
34861 * @param {Roo.LayoutRegion} this
34866 * Fires when this region is slid into view.
34867 * @param {Roo.LayoutRegion} this
34869 "slideshow" : true,
34872 * Fires when this region slides out of view.
34873 * @param {Roo.LayoutRegion} this
34875 "slidehide" : true,
34877 * @event panelactivated
34878 * Fires when a panel is activated.
34879 * @param {Roo.LayoutRegion} this
34880 * @param {Roo.ContentPanel} panel The activated panel
34882 "panelactivated" : true,
34885 * Fires when the user resizes this region.
34886 * @param {Roo.LayoutRegion} this
34887 * @param {Number} newSize The new size (width for east/west, height for north/south)
34891 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34892 this.panels = new Roo.util.MixedCollection();
34893 this.panels.getKey = this.getPanelId.createDelegate(this);
34895 this.activePanel = null;
34896 // ensure listeners are added...
34898 if (config.listeners || config.events) {
34899 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34900 listeners : config.listeners || {},
34901 events : config.events || {}
34905 if(skipConfig !== true){
34906 this.applyConfig(config);
34910 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34912 getPanelId : function(p){
34916 applyConfig : function(config){
34917 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34918 this.config = config;
34923 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34924 * the width, for horizontal (north, south) the height.
34925 * @param {Number} newSize The new width or height
34927 resizeTo : function(newSize){
34928 var el = this.el ? this.el :
34929 (this.activePanel ? this.activePanel.getEl() : null);
34931 switch(this.position){
34934 el.setWidth(newSize);
34935 this.fireEvent("resized", this, newSize);
34939 el.setHeight(newSize);
34940 this.fireEvent("resized", this, newSize);
34946 getBox : function(){
34947 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34950 getMargins : function(){
34951 return this.margins;
34954 updateBox : function(box){
34956 var el = this.activePanel.getEl();
34957 el.dom.style.left = box.x + "px";
34958 el.dom.style.top = box.y + "px";
34959 this.activePanel.setSize(box.width, box.height);
34963 * Returns the container element for this region.
34964 * @return {Roo.Element}
34966 getEl : function(){
34967 return this.activePanel;
34971 * Returns true if this region is currently visible.
34972 * @return {Boolean}
34974 isVisible : function(){
34975 return this.activePanel ? true : false;
34978 setActivePanel : function(panel){
34979 panel = this.getPanel(panel);
34980 if(this.activePanel && this.activePanel != panel){
34981 this.activePanel.setActiveState(false);
34982 this.activePanel.getEl().setLeftTop(-10000,-10000);
34984 this.activePanel = panel;
34985 panel.setActiveState(true);
34987 panel.setSize(this.box.width, this.box.height);
34989 this.fireEvent("panelactivated", this, panel);
34990 this.fireEvent("invalidated");
34994 * Show the specified panel.
34995 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
34996 * @return {Roo.ContentPanel} The shown panel or null
34998 showPanel : function(panel){
34999 panel = this.getPanel(panel);
35001 this.setActivePanel(panel);
35007 * Get the active panel for this region.
35008 * @return {Roo.ContentPanel} The active panel or null
35010 getActivePanel : function(){
35011 return this.activePanel;
35015 * Add the passed ContentPanel(s)
35016 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35017 * @return {Roo.ContentPanel} The panel added (if only one was added)
35019 add : function(panel){
35020 if(arguments.length > 1){
35021 for(var i = 0, len = arguments.length; i < len; i++) {
35022 this.add(arguments[i]);
35026 if(this.hasPanel(panel)){
35027 this.showPanel(panel);
35030 var el = panel.getEl();
35031 if(el.dom.parentNode != this.mgr.el.dom){
35032 this.mgr.el.dom.appendChild(el.dom);
35034 if(panel.setRegion){
35035 panel.setRegion(this);
35037 this.panels.add(panel);
35038 el.setStyle("position", "absolute");
35039 if(!panel.background){
35040 this.setActivePanel(panel);
35041 if(this.config.initialSize && this.panels.getCount()==1){
35042 this.resizeTo(this.config.initialSize);
35045 this.fireEvent("paneladded", this, panel);
35050 * Returns true if the panel is in this region.
35051 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35052 * @return {Boolean}
35054 hasPanel : function(panel){
35055 if(typeof panel == "object"){ // must be panel obj
35056 panel = panel.getId();
35058 return this.getPanel(panel) ? true : false;
35062 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35063 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35064 * @param {Boolean} preservePanel Overrides the config preservePanel option
35065 * @return {Roo.ContentPanel} The panel that was removed
35067 remove : function(panel, preservePanel){
35068 panel = this.getPanel(panel);
35073 this.fireEvent("beforeremove", this, panel, e);
35074 if(e.cancel === true){
35077 var panelId = panel.getId();
35078 this.panels.removeKey(panelId);
35083 * Returns the panel specified or null if it's not in this region.
35084 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35085 * @return {Roo.ContentPanel}
35087 getPanel : function(id){
35088 if(typeof id == "object"){ // must be panel obj
35091 return this.panels.get(id);
35095 * Returns this regions position (north/south/east/west/center).
35098 getPosition: function(){
35099 return this.position;
35103 * Ext JS Library 1.1.1
35104 * Copyright(c) 2006-2007, Ext JS, LLC.
35106 * Originally Released Under LGPL - original licence link has changed is not relivant.
35109 * <script type="text/javascript">
35113 * @class Roo.bootstrap.layout.Region
35114 * @extends Roo.bootstrap.layout.Basic
35115 * This class represents a region in a layout manager.
35117 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35118 * @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})
35119 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35120 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35121 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35122 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35123 * @cfg {String} title The title for the region (overrides panel titles)
35124 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35125 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35126 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35127 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35128 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35129 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35130 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35131 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35132 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35133 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35135 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35136 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35137 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35138 * @cfg {Number} width For East/West panels
35139 * @cfg {Number} height For North/South panels
35140 * @cfg {Boolean} split To show the splitter
35141 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35143 * @cfg {string} cls Extra CSS classes to add to region
35145 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35146 * @cfg {string} region the region that it inhabits..
35149 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35150 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35152 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35153 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35154 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35156 Roo.bootstrap.layout.Region = function(config)
35158 this.applyConfig(config);
35160 var mgr = config.mgr;
35161 var pos = config.region;
35162 config.skipConfig = true;
35163 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35166 this.onRender(mgr.el);
35169 this.visible = true;
35170 this.collapsed = false;
35171 this.unrendered_panels = [];
35174 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35176 position: '', // set by wrapper (eg. north/south etc..)
35177 unrendered_panels : null, // unrendered panels.
35178 createBody : function(){
35179 /** This region's body element
35180 * @type Roo.Element */
35181 this.bodyEl = this.el.createChild({
35183 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35187 onRender: function(ctr, pos)
35189 var dh = Roo.DomHelper;
35190 /** This region's container element
35191 * @type Roo.Element */
35192 this.el = dh.append(ctr.dom, {
35194 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35196 /** This region's title element
35197 * @type Roo.Element */
35199 this.titleEl = dh.append(this.el.dom,
35202 unselectable: "on",
35203 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35205 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35206 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35209 this.titleEl.enableDisplayMode();
35210 /** This region's title text element
35211 * @type HTMLElement */
35212 this.titleTextEl = this.titleEl.dom.firstChild;
35213 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35215 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35216 this.closeBtn.enableDisplayMode();
35217 this.closeBtn.on("click", this.closeClicked, this);
35218 this.closeBtn.hide();
35220 this.createBody(this.config);
35221 if(this.config.hideWhenEmpty){
35223 this.on("paneladded", this.validateVisibility, this);
35224 this.on("panelremoved", this.validateVisibility, this);
35226 if(this.autoScroll){
35227 this.bodyEl.setStyle("overflow", "auto");
35229 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35231 //if(c.titlebar !== false){
35232 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35233 this.titleEl.hide();
35235 this.titleEl.show();
35236 if(this.config.title){
35237 this.titleTextEl.innerHTML = this.config.title;
35241 if(this.config.collapsed){
35242 this.collapse(true);
35244 if(this.config.hidden){
35248 if (this.unrendered_panels && this.unrendered_panels.length) {
35249 for (var i =0;i< this.unrendered_panels.length; i++) {
35250 this.add(this.unrendered_panels[i]);
35252 this.unrendered_panels = null;
35258 applyConfig : function(c)
35261 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35262 var dh = Roo.DomHelper;
35263 if(c.titlebar !== false){
35264 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35265 this.collapseBtn.on("click", this.collapse, this);
35266 this.collapseBtn.enableDisplayMode();
35268 if(c.showPin === true || this.showPin){
35269 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35270 this.stickBtn.enableDisplayMode();
35271 this.stickBtn.on("click", this.expand, this);
35272 this.stickBtn.hide();
35277 /** This region's collapsed element
35278 * @type Roo.Element */
35281 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35282 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35285 if(c.floatable !== false){
35286 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35287 this.collapsedEl.on("click", this.collapseClick, this);
35290 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35291 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35292 id: "message", unselectable: "on", style:{"float":"left"}});
35293 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35295 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35296 this.expandBtn.on("click", this.expand, this);
35300 if(this.collapseBtn){
35301 this.collapseBtn.setVisible(c.collapsible == true);
35304 this.cmargins = c.cmargins || this.cmargins ||
35305 (this.position == "west" || this.position == "east" ?
35306 {top: 0, left: 2, right:2, bottom: 0} :
35307 {top: 2, left: 0, right:0, bottom: 2});
35309 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35312 this.bottomTabs = c.tabPosition != "top";
35314 this.autoScroll = c.autoScroll || false;
35319 this.duration = c.duration || .30;
35320 this.slideDuration = c.slideDuration || .45;
35325 * Returns true if this region is currently visible.
35326 * @return {Boolean}
35328 isVisible : function(){
35329 return this.visible;
35333 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35334 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35336 //setCollapsedTitle : function(title){
35337 // title = title || " ";
35338 // if(this.collapsedTitleTextEl){
35339 // this.collapsedTitleTextEl.innerHTML = title;
35343 getBox : function(){
35345 // if(!this.collapsed){
35346 b = this.el.getBox(false, true);
35348 // b = this.collapsedEl.getBox(false, true);
35353 getMargins : function(){
35354 return this.margins;
35355 //return this.collapsed ? this.cmargins : this.margins;
35358 highlight : function(){
35359 this.el.addClass("x-layout-panel-dragover");
35362 unhighlight : function(){
35363 this.el.removeClass("x-layout-panel-dragover");
35366 updateBox : function(box)
35368 if (!this.bodyEl) {
35369 return; // not rendered yet..
35373 if(!this.collapsed){
35374 this.el.dom.style.left = box.x + "px";
35375 this.el.dom.style.top = box.y + "px";
35376 this.updateBody(box.width, box.height);
35378 this.collapsedEl.dom.style.left = box.x + "px";
35379 this.collapsedEl.dom.style.top = box.y + "px";
35380 this.collapsedEl.setSize(box.width, box.height);
35383 this.tabs.autoSizeTabs();
35387 updateBody : function(w, h)
35390 this.el.setWidth(w);
35391 w -= this.el.getBorderWidth("rl");
35392 if(this.config.adjustments){
35393 w += this.config.adjustments[0];
35396 if(h !== null && h > 0){
35397 this.el.setHeight(h);
35398 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35399 h -= this.el.getBorderWidth("tb");
35400 if(this.config.adjustments){
35401 h += this.config.adjustments[1];
35403 this.bodyEl.setHeight(h);
35405 h = this.tabs.syncHeight(h);
35408 if(this.panelSize){
35409 w = w !== null ? w : this.panelSize.width;
35410 h = h !== null ? h : this.panelSize.height;
35412 if(this.activePanel){
35413 var el = this.activePanel.getEl();
35414 w = w !== null ? w : el.getWidth();
35415 h = h !== null ? h : el.getHeight();
35416 this.panelSize = {width: w, height: h};
35417 this.activePanel.setSize(w, h);
35419 if(Roo.isIE && this.tabs){
35420 this.tabs.el.repaint();
35425 * Returns the container element for this region.
35426 * @return {Roo.Element}
35428 getEl : function(){
35433 * Hides this region.
35436 //if(!this.collapsed){
35437 this.el.dom.style.left = "-2000px";
35440 // this.collapsedEl.dom.style.left = "-2000px";
35441 // this.collapsedEl.hide();
35443 this.visible = false;
35444 this.fireEvent("visibilitychange", this, false);
35448 * Shows this region if it was previously hidden.
35451 //if(!this.collapsed){
35454 // this.collapsedEl.show();
35456 this.visible = true;
35457 this.fireEvent("visibilitychange", this, true);
35460 closeClicked : function(){
35461 if(this.activePanel){
35462 this.remove(this.activePanel);
35466 collapseClick : function(e){
35468 e.stopPropagation();
35471 e.stopPropagation();
35477 * Collapses this region.
35478 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35481 collapse : function(skipAnim, skipCheck = false){
35482 if(this.collapsed) {
35486 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35488 this.collapsed = true;
35490 this.split.el.hide();
35492 if(this.config.animate && skipAnim !== true){
35493 this.fireEvent("invalidated", this);
35494 this.animateCollapse();
35496 this.el.setLocation(-20000,-20000);
35498 this.collapsedEl.show();
35499 this.fireEvent("collapsed", this);
35500 this.fireEvent("invalidated", this);
35506 animateCollapse : function(){
35511 * Expands this region if it was previously collapsed.
35512 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35513 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35516 expand : function(e, skipAnim){
35518 e.stopPropagation();
35520 if(!this.collapsed || this.el.hasActiveFx()) {
35524 this.afterSlideIn();
35527 this.collapsed = false;
35528 if(this.config.animate && skipAnim !== true){
35529 this.animateExpand();
35533 this.split.el.show();
35535 this.collapsedEl.setLocation(-2000,-2000);
35536 this.collapsedEl.hide();
35537 this.fireEvent("invalidated", this);
35538 this.fireEvent("expanded", this);
35542 animateExpand : function(){
35546 initTabs : function()
35548 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35550 var ts = new Roo.bootstrap.panel.Tabs({
35551 el: this.bodyEl.dom,
35552 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35553 disableTooltips: this.config.disableTabTips,
35554 toolbar : this.config.toolbar
35557 if(this.config.hideTabs){
35558 ts.stripWrap.setDisplayed(false);
35561 ts.resizeTabs = this.config.resizeTabs === true;
35562 ts.minTabWidth = this.config.minTabWidth || 40;
35563 ts.maxTabWidth = this.config.maxTabWidth || 250;
35564 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35565 ts.monitorResize = false;
35566 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35567 ts.bodyEl.addClass('roo-layout-tabs-body');
35568 this.panels.each(this.initPanelAsTab, this);
35571 initPanelAsTab : function(panel){
35572 var ti = this.tabs.addTab(
35576 this.config.closeOnTab && panel.isClosable(),
35579 if(panel.tabTip !== undefined){
35580 ti.setTooltip(panel.tabTip);
35582 ti.on("activate", function(){
35583 this.setActivePanel(panel);
35586 if(this.config.closeOnTab){
35587 ti.on("beforeclose", function(t, e){
35589 this.remove(panel);
35593 panel.tabItem = ti;
35598 updatePanelTitle : function(panel, title)
35600 if(this.activePanel == panel){
35601 this.updateTitle(title);
35604 var ti = this.tabs.getTab(panel.getEl().id);
35606 if(panel.tabTip !== undefined){
35607 ti.setTooltip(panel.tabTip);
35612 updateTitle : function(title){
35613 if(this.titleTextEl && !this.config.title){
35614 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35618 setActivePanel : function(panel)
35620 panel = this.getPanel(panel);
35621 if(this.activePanel && this.activePanel != panel){
35622 if(this.activePanel.setActiveState(false) === false){
35626 this.activePanel = panel;
35627 panel.setActiveState(true);
35628 if(this.panelSize){
35629 panel.setSize(this.panelSize.width, this.panelSize.height);
35632 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35634 this.updateTitle(panel.getTitle());
35636 this.fireEvent("invalidated", this);
35638 this.fireEvent("panelactivated", this, panel);
35642 * Shows the specified panel.
35643 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35644 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35646 showPanel : function(panel)
35648 panel = this.getPanel(panel);
35651 var tab = this.tabs.getTab(panel.getEl().id);
35652 if(tab.isHidden()){
35653 this.tabs.unhideTab(tab.id);
35657 this.setActivePanel(panel);
35664 * Get the active panel for this region.
35665 * @return {Roo.ContentPanel} The active panel or null
35667 getActivePanel : function(){
35668 return this.activePanel;
35671 validateVisibility : function(){
35672 if(this.panels.getCount() < 1){
35673 this.updateTitle(" ");
35674 this.closeBtn.hide();
35677 if(!this.isVisible()){
35684 * Adds the passed ContentPanel(s) to this region.
35685 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35686 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35688 add : function(panel)
35690 if(arguments.length > 1){
35691 for(var i = 0, len = arguments.length; i < len; i++) {
35692 this.add(arguments[i]);
35697 // if we have not been rendered yet, then we can not really do much of this..
35698 if (!this.bodyEl) {
35699 this.unrendered_panels.push(panel);
35706 if(this.hasPanel(panel)){
35707 this.showPanel(panel);
35710 panel.setRegion(this);
35711 this.panels.add(panel);
35712 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35713 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35714 // and hide them... ???
35715 this.bodyEl.dom.appendChild(panel.getEl().dom);
35716 if(panel.background !== true){
35717 this.setActivePanel(panel);
35719 this.fireEvent("paneladded", this, panel);
35726 this.initPanelAsTab(panel);
35730 if(panel.background !== true){
35731 this.tabs.activate(panel.getEl().id);
35733 this.fireEvent("paneladded", this, panel);
35738 * Hides the tab for the specified panel.
35739 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35741 hidePanel : function(panel){
35742 if(this.tabs && (panel = this.getPanel(panel))){
35743 this.tabs.hideTab(panel.getEl().id);
35748 * Unhides the tab for a previously hidden panel.
35749 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35751 unhidePanel : function(panel){
35752 if(this.tabs && (panel = this.getPanel(panel))){
35753 this.tabs.unhideTab(panel.getEl().id);
35757 clearPanels : function(){
35758 while(this.panels.getCount() > 0){
35759 this.remove(this.panels.first());
35764 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35765 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35766 * @param {Boolean} preservePanel Overrides the config preservePanel option
35767 * @return {Roo.ContentPanel} The panel that was removed
35769 remove : function(panel, preservePanel)
35771 panel = this.getPanel(panel);
35776 this.fireEvent("beforeremove", this, panel, e);
35777 if(e.cancel === true){
35780 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35781 var panelId = panel.getId();
35782 this.panels.removeKey(panelId);
35784 document.body.appendChild(panel.getEl().dom);
35787 this.tabs.removeTab(panel.getEl().id);
35788 }else if (!preservePanel){
35789 this.bodyEl.dom.removeChild(panel.getEl().dom);
35791 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35792 var p = this.panels.first();
35793 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35794 tempEl.appendChild(p.getEl().dom);
35795 this.bodyEl.update("");
35796 this.bodyEl.dom.appendChild(p.getEl().dom);
35798 this.updateTitle(p.getTitle());
35800 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35801 this.setActivePanel(p);
35803 panel.setRegion(null);
35804 if(this.activePanel == panel){
35805 this.activePanel = null;
35807 if(this.config.autoDestroy !== false && preservePanel !== true){
35808 try{panel.destroy();}catch(e){}
35810 this.fireEvent("panelremoved", this, panel);
35815 * Returns the TabPanel component used by this region
35816 * @return {Roo.TabPanel}
35818 getTabs : function(){
35822 createTool : function(parentEl, className){
35823 var btn = Roo.DomHelper.append(parentEl, {
35825 cls: "x-layout-tools-button",
35828 cls: "roo-layout-tools-button-inner " + className,
35832 btn.addClassOnOver("roo-layout-tools-button-over");
35837 * Ext JS Library 1.1.1
35838 * Copyright(c) 2006-2007, Ext JS, LLC.
35840 * Originally Released Under LGPL - original licence link has changed is not relivant.
35843 * <script type="text/javascript">
35849 * @class Roo.SplitLayoutRegion
35850 * @extends Roo.LayoutRegion
35851 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35853 Roo.bootstrap.layout.Split = function(config){
35854 this.cursor = config.cursor;
35855 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35858 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35860 splitTip : "Drag to resize.",
35861 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35862 useSplitTips : false,
35864 applyConfig : function(config){
35865 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35868 onRender : function(ctr,pos) {
35870 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35871 if(!this.config.split){
35876 var splitEl = Roo.DomHelper.append(ctr.dom, {
35878 id: this.el.id + "-split",
35879 cls: "roo-layout-split roo-layout-split-"+this.position,
35882 /** The SplitBar for this region
35883 * @type Roo.SplitBar */
35884 // does not exist yet...
35885 Roo.log([this.position, this.orientation]);
35887 this.split = new Roo.bootstrap.SplitBar({
35888 dragElement : splitEl,
35889 resizingElement: this.el,
35890 orientation : this.orientation
35893 this.split.on("moved", this.onSplitMove, this);
35894 this.split.useShim = this.config.useShim === true;
35895 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35896 if(this.useSplitTips){
35897 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35899 //if(config.collapsible){
35900 // this.split.el.on("dblclick", this.collapse, this);
35903 if(typeof this.config.minSize != "undefined"){
35904 this.split.minSize = this.config.minSize;
35906 if(typeof this.config.maxSize != "undefined"){
35907 this.split.maxSize = this.config.maxSize;
35909 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35910 this.hideSplitter();
35915 getHMaxSize : function(){
35916 var cmax = this.config.maxSize || 10000;
35917 var center = this.mgr.getRegion("center");
35918 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35921 getVMaxSize : function(){
35922 var cmax = this.config.maxSize || 10000;
35923 var center = this.mgr.getRegion("center");
35924 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35927 onSplitMove : function(split, newSize){
35928 this.fireEvent("resized", this, newSize);
35932 * Returns the {@link Roo.SplitBar} for this region.
35933 * @return {Roo.SplitBar}
35935 getSplitBar : function(){
35940 this.hideSplitter();
35941 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35944 hideSplitter : function(){
35946 this.split.el.setLocation(-2000,-2000);
35947 this.split.el.hide();
35953 this.split.el.show();
35955 Roo.bootstrap.layout.Split.superclass.show.call(this);
35958 beforeSlide: function(){
35959 if(Roo.isGecko){// firefox overflow auto bug workaround
35960 this.bodyEl.clip();
35962 this.tabs.bodyEl.clip();
35964 if(this.activePanel){
35965 this.activePanel.getEl().clip();
35967 if(this.activePanel.beforeSlide){
35968 this.activePanel.beforeSlide();
35974 afterSlide : function(){
35975 if(Roo.isGecko){// firefox overflow auto bug workaround
35976 this.bodyEl.unclip();
35978 this.tabs.bodyEl.unclip();
35980 if(this.activePanel){
35981 this.activePanel.getEl().unclip();
35982 if(this.activePanel.afterSlide){
35983 this.activePanel.afterSlide();
35989 initAutoHide : function(){
35990 if(this.autoHide !== false){
35991 if(!this.autoHideHd){
35992 var st = new Roo.util.DelayedTask(this.slideIn, this);
35993 this.autoHideHd = {
35994 "mouseout": function(e){
35995 if(!e.within(this.el, true)){
35999 "mouseover" : function(e){
36005 this.el.on(this.autoHideHd);
36009 clearAutoHide : function(){
36010 if(this.autoHide !== false){
36011 this.el.un("mouseout", this.autoHideHd.mouseout);
36012 this.el.un("mouseover", this.autoHideHd.mouseover);
36016 clearMonitor : function(){
36017 Roo.get(document).un("click", this.slideInIf, this);
36020 // these names are backwards but not changed for compat
36021 slideOut : function(){
36022 if(this.isSlid || this.el.hasActiveFx()){
36025 this.isSlid = true;
36026 if(this.collapseBtn){
36027 this.collapseBtn.hide();
36029 this.closeBtnState = this.closeBtn.getStyle('display');
36030 this.closeBtn.hide();
36032 this.stickBtn.show();
36035 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36036 this.beforeSlide();
36037 this.el.setStyle("z-index", 10001);
36038 this.el.slideIn(this.getSlideAnchor(), {
36039 callback: function(){
36041 this.initAutoHide();
36042 Roo.get(document).on("click", this.slideInIf, this);
36043 this.fireEvent("slideshow", this);
36050 afterSlideIn : function(){
36051 this.clearAutoHide();
36052 this.isSlid = false;
36053 this.clearMonitor();
36054 this.el.setStyle("z-index", "");
36055 if(this.collapseBtn){
36056 this.collapseBtn.show();
36058 this.closeBtn.setStyle('display', this.closeBtnState);
36060 this.stickBtn.hide();
36062 this.fireEvent("slidehide", this);
36065 slideIn : function(cb){
36066 if(!this.isSlid || this.el.hasActiveFx()){
36070 this.isSlid = false;
36071 this.beforeSlide();
36072 this.el.slideOut(this.getSlideAnchor(), {
36073 callback: function(){
36074 this.el.setLeftTop(-10000, -10000);
36076 this.afterSlideIn();
36084 slideInIf : function(e){
36085 if(!e.within(this.el)){
36090 animateCollapse : function(){
36091 this.beforeSlide();
36092 this.el.setStyle("z-index", 20000);
36093 var anchor = this.getSlideAnchor();
36094 this.el.slideOut(anchor, {
36095 callback : function(){
36096 this.el.setStyle("z-index", "");
36097 this.collapsedEl.slideIn(anchor, {duration:.3});
36099 this.el.setLocation(-10000,-10000);
36101 this.fireEvent("collapsed", this);
36108 animateExpand : function(){
36109 this.beforeSlide();
36110 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36111 this.el.setStyle("z-index", 20000);
36112 this.collapsedEl.hide({
36115 this.el.slideIn(this.getSlideAnchor(), {
36116 callback : function(){
36117 this.el.setStyle("z-index", "");
36120 this.split.el.show();
36122 this.fireEvent("invalidated", this);
36123 this.fireEvent("expanded", this);
36151 getAnchor : function(){
36152 return this.anchors[this.position];
36155 getCollapseAnchor : function(){
36156 return this.canchors[this.position];
36159 getSlideAnchor : function(){
36160 return this.sanchors[this.position];
36163 getAlignAdj : function(){
36164 var cm = this.cmargins;
36165 switch(this.position){
36181 getExpandAdj : function(){
36182 var c = this.collapsedEl, cm = this.cmargins;
36183 switch(this.position){
36185 return [-(cm.right+c.getWidth()+cm.left), 0];
36188 return [cm.right+c.getWidth()+cm.left, 0];
36191 return [0, -(cm.top+cm.bottom+c.getHeight())];
36194 return [0, cm.top+cm.bottom+c.getHeight()];
36200 * Ext JS Library 1.1.1
36201 * Copyright(c) 2006-2007, Ext JS, LLC.
36203 * Originally Released Under LGPL - original licence link has changed is not relivant.
36206 * <script type="text/javascript">
36209 * These classes are private internal classes
36211 Roo.bootstrap.layout.Center = function(config){
36212 config.region = "center";
36213 Roo.bootstrap.layout.Region.call(this, config);
36214 this.visible = true;
36215 this.minWidth = config.minWidth || 20;
36216 this.minHeight = config.minHeight || 20;
36219 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36221 // center panel can't be hidden
36225 // center panel can't be hidden
36228 getMinWidth: function(){
36229 return this.minWidth;
36232 getMinHeight: function(){
36233 return this.minHeight;
36246 Roo.bootstrap.layout.North = function(config)
36248 config.region = 'north';
36249 config.cursor = 'n-resize';
36251 Roo.bootstrap.layout.Split.call(this, config);
36255 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36256 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36257 this.split.el.addClass("roo-layout-split-v");
36259 var size = config.initialSize || config.height;
36260 if(typeof size != "undefined"){
36261 this.el.setHeight(size);
36264 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36266 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36270 getBox : function(){
36271 if(this.collapsed){
36272 return this.collapsedEl.getBox();
36274 var box = this.el.getBox();
36276 box.height += this.split.el.getHeight();
36281 updateBox : function(box){
36282 if(this.split && !this.collapsed){
36283 box.height -= this.split.el.getHeight();
36284 this.split.el.setLeft(box.x);
36285 this.split.el.setTop(box.y+box.height);
36286 this.split.el.setWidth(box.width);
36288 if(this.collapsed){
36289 this.updateBody(box.width, null);
36291 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36299 Roo.bootstrap.layout.South = function(config){
36300 config.region = 'south';
36301 config.cursor = 's-resize';
36302 Roo.bootstrap.layout.Split.call(this, config);
36304 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36305 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36306 this.split.el.addClass("roo-layout-split-v");
36308 var size = config.initialSize || config.height;
36309 if(typeof size != "undefined"){
36310 this.el.setHeight(size);
36314 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36315 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36316 getBox : function(){
36317 if(this.collapsed){
36318 return this.collapsedEl.getBox();
36320 var box = this.el.getBox();
36322 var sh = this.split.el.getHeight();
36329 updateBox : function(box){
36330 if(this.split && !this.collapsed){
36331 var sh = this.split.el.getHeight();
36334 this.split.el.setLeft(box.x);
36335 this.split.el.setTop(box.y-sh);
36336 this.split.el.setWidth(box.width);
36338 if(this.collapsed){
36339 this.updateBody(box.width, null);
36341 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36345 Roo.bootstrap.layout.East = function(config){
36346 config.region = "east";
36347 config.cursor = "e-resize";
36348 Roo.bootstrap.layout.Split.call(this, config);
36350 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36351 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36352 this.split.el.addClass("roo-layout-split-h");
36354 var size = config.initialSize || config.width;
36355 if(typeof size != "undefined"){
36356 this.el.setWidth(size);
36359 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36360 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36361 getBox : function(){
36362 if(this.collapsed){
36363 return this.collapsedEl.getBox();
36365 var box = this.el.getBox();
36367 var sw = this.split.el.getWidth();
36374 updateBox : function(box){
36375 if(this.split && !this.collapsed){
36376 var sw = this.split.el.getWidth();
36378 this.split.el.setLeft(box.x);
36379 this.split.el.setTop(box.y);
36380 this.split.el.setHeight(box.height);
36383 if(this.collapsed){
36384 this.updateBody(null, box.height);
36386 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36390 Roo.bootstrap.layout.West = function(config){
36391 config.region = "west";
36392 config.cursor = "w-resize";
36394 Roo.bootstrap.layout.Split.call(this, config);
36396 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36397 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36398 this.split.el.addClass("roo-layout-split-h");
36402 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36403 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36405 onRender: function(ctr, pos)
36407 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36408 var size = this.config.initialSize || this.config.width;
36409 if(typeof size != "undefined"){
36410 this.el.setWidth(size);
36414 getBox : function(){
36415 if(this.collapsed){
36416 return this.collapsedEl.getBox();
36418 var box = this.el.getBox();
36420 box.width += this.split.el.getWidth();
36425 updateBox : function(box){
36426 if(this.split && !this.collapsed){
36427 var sw = this.split.el.getWidth();
36429 this.split.el.setLeft(box.x+box.width);
36430 this.split.el.setTop(box.y);
36431 this.split.el.setHeight(box.height);
36433 if(this.collapsed){
36434 this.updateBody(null, box.height);
36436 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36439 Roo.namespace("Roo.bootstrap.panel");/*
36441 * Ext JS Library 1.1.1
36442 * Copyright(c) 2006-2007, Ext JS, LLC.
36444 * Originally Released Under LGPL - original licence link has changed is not relivant.
36447 * <script type="text/javascript">
36450 * @class Roo.ContentPanel
36451 * @extends Roo.util.Observable
36452 * A basic ContentPanel element.
36453 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36454 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36455 * @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
36456 * @cfg {Boolean} closable True if the panel can be closed/removed
36457 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36458 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36459 * @cfg {Toolbar} toolbar A toolbar for this panel
36460 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36461 * @cfg {String} title The title for this panel
36462 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36463 * @cfg {String} url Calls {@link #setUrl} with this value
36464 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36465 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36466 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36467 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36468 * @cfg {Boolean} badges render the badges
36471 * Create a new ContentPanel.
36472 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36473 * @param {String/Object} config A string to set only the title or a config object
36474 * @param {String} content (optional) Set the HTML content for this panel
36475 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36477 Roo.bootstrap.panel.Content = function( config){
36479 this.tpl = config.tpl || false;
36481 var el = config.el;
36482 var content = config.content;
36484 if(config.autoCreate){ // xtype is available if this is called from factory
36487 this.el = Roo.get(el);
36488 if(!this.el && config && config.autoCreate){
36489 if(typeof config.autoCreate == "object"){
36490 if(!config.autoCreate.id){
36491 config.autoCreate.id = config.id||el;
36493 this.el = Roo.DomHelper.append(document.body,
36494 config.autoCreate, true);
36496 var elcfg = { tag: "div",
36497 cls: "roo-layout-inactive-content",
36501 elcfg.html = config.html;
36505 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36508 this.closable = false;
36509 this.loaded = false;
36510 this.active = false;
36513 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36515 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36517 this.wrapEl = this.el; //this.el.wrap();
36519 if (config.toolbar.items) {
36520 ti = config.toolbar.items ;
36521 delete config.toolbar.items ;
36525 this.toolbar.render(this.wrapEl, 'before');
36526 for(var i =0;i < ti.length;i++) {
36527 // Roo.log(['add child', items[i]]);
36528 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36530 this.toolbar.items = nitems;
36531 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36532 delete config.toolbar;
36536 // xtype created footer. - not sure if will work as we normally have to render first..
36537 if (this.footer && !this.footer.el && this.footer.xtype) {
36538 if (!this.wrapEl) {
36539 this.wrapEl = this.el.wrap();
36542 this.footer.container = this.wrapEl.createChild();
36544 this.footer = Roo.factory(this.footer, Roo);
36549 if(typeof config == "string"){
36550 this.title = config;
36552 Roo.apply(this, config);
36556 this.resizeEl = Roo.get(this.resizeEl, true);
36558 this.resizeEl = this.el;
36560 // handle view.xtype
36568 * Fires when this panel is activated.
36569 * @param {Roo.ContentPanel} this
36573 * @event deactivate
36574 * Fires when this panel is activated.
36575 * @param {Roo.ContentPanel} this
36577 "deactivate" : true,
36581 * Fires when this panel is resized if fitToFrame is true.
36582 * @param {Roo.ContentPanel} this
36583 * @param {Number} width The width after any component adjustments
36584 * @param {Number} height The height after any component adjustments
36590 * Fires when this tab is created
36591 * @param {Roo.ContentPanel} this
36602 if(this.autoScroll){
36603 this.resizeEl.setStyle("overflow", "auto");
36605 // fix randome scrolling
36606 //this.el.on('scroll', function() {
36607 // Roo.log('fix random scolling');
36608 // this.scrollTo('top',0);
36611 content = content || this.content;
36613 this.setContent(content);
36615 if(config && config.url){
36616 this.setUrl(this.url, this.params, this.loadOnce);
36621 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36623 if (this.view && typeof(this.view.xtype) != 'undefined') {
36624 this.view.el = this.el.appendChild(document.createElement("div"));
36625 this.view = Roo.factory(this.view);
36626 this.view.render && this.view.render(false, '');
36630 this.fireEvent('render', this);
36633 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36637 setRegion : function(region){
36638 this.region = region;
36639 this.setActiveClass(region && !this.background);
36643 setActiveClass: function(state)
36646 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36647 this.el.setStyle('position','relative');
36649 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36650 this.el.setStyle('position', 'absolute');
36655 * Returns the toolbar for this Panel if one was configured.
36656 * @return {Roo.Toolbar}
36658 getToolbar : function(){
36659 return this.toolbar;
36662 setActiveState : function(active)
36664 this.active = active;
36665 this.setActiveClass(active);
36667 if(this.fireEvent("deactivate", this) === false){
36672 this.fireEvent("activate", this);
36676 * Updates this panel's element
36677 * @param {String} content The new content
36678 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36680 setContent : function(content, loadScripts){
36681 this.el.update(content, loadScripts);
36684 ignoreResize : function(w, h){
36685 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36688 this.lastSize = {width: w, height: h};
36693 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36694 * @return {Roo.UpdateManager} The UpdateManager
36696 getUpdateManager : function(){
36697 return this.el.getUpdateManager();
36700 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36701 * @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:
36704 url: "your-url.php",
36705 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36706 callback: yourFunction,
36707 scope: yourObject, //(optional scope)
36710 text: "Loading...",
36715 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36716 * 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.
36717 * @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}
36718 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36719 * @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.
36720 * @return {Roo.ContentPanel} this
36723 var um = this.el.getUpdateManager();
36724 um.update.apply(um, arguments);
36730 * 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.
36731 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36732 * @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)
36733 * @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)
36734 * @return {Roo.UpdateManager} The UpdateManager
36736 setUrl : function(url, params, loadOnce){
36737 if(this.refreshDelegate){
36738 this.removeListener("activate", this.refreshDelegate);
36740 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36741 this.on("activate", this.refreshDelegate);
36742 return this.el.getUpdateManager();
36745 _handleRefresh : function(url, params, loadOnce){
36746 if(!loadOnce || !this.loaded){
36747 var updater = this.el.getUpdateManager();
36748 updater.update(url, params, this._setLoaded.createDelegate(this));
36752 _setLoaded : function(){
36753 this.loaded = true;
36757 * Returns this panel's id
36760 getId : function(){
36765 * Returns this panel's element - used by regiosn to add.
36766 * @return {Roo.Element}
36768 getEl : function(){
36769 return this.wrapEl || this.el;
36774 adjustForComponents : function(width, height)
36776 //Roo.log('adjustForComponents ');
36777 if(this.resizeEl != this.el){
36778 width -= this.el.getFrameWidth('lr');
36779 height -= this.el.getFrameWidth('tb');
36782 var te = this.toolbar.getEl();
36783 te.setWidth(width);
36784 height -= te.getHeight();
36787 var te = this.footer.getEl();
36788 te.setWidth(width);
36789 height -= te.getHeight();
36793 if(this.adjustments){
36794 width += this.adjustments[0];
36795 height += this.adjustments[1];
36797 return {"width": width, "height": height};
36800 setSize : function(width, height){
36801 if(this.fitToFrame && !this.ignoreResize(width, height)){
36802 if(this.fitContainer && this.resizeEl != this.el){
36803 this.el.setSize(width, height);
36805 var size = this.adjustForComponents(width, height);
36806 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36807 this.fireEvent('resize', this, size.width, size.height);
36812 * Returns this panel's title
36815 getTitle : function(){
36817 if (typeof(this.title) != 'object') {
36822 for (var k in this.title) {
36823 if (!this.title.hasOwnProperty(k)) {
36827 if (k.indexOf('-') >= 0) {
36828 var s = k.split('-');
36829 for (var i = 0; i<s.length; i++) {
36830 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36833 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36840 * Set this panel's title
36841 * @param {String} title
36843 setTitle : function(title){
36844 this.title = title;
36846 this.region.updatePanelTitle(this, title);
36851 * Returns true is this panel was configured to be closable
36852 * @return {Boolean}
36854 isClosable : function(){
36855 return this.closable;
36858 beforeSlide : function(){
36860 this.resizeEl.clip();
36863 afterSlide : function(){
36865 this.resizeEl.unclip();
36869 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36870 * Will fail silently if the {@link #setUrl} method has not been called.
36871 * This does not activate the panel, just updates its content.
36873 refresh : function(){
36874 if(this.refreshDelegate){
36875 this.loaded = false;
36876 this.refreshDelegate();
36881 * Destroys this panel
36883 destroy : function(){
36884 this.el.removeAllListeners();
36885 var tempEl = document.createElement("span");
36886 tempEl.appendChild(this.el.dom);
36887 tempEl.innerHTML = "";
36893 * form - if the content panel contains a form - this is a reference to it.
36894 * @type {Roo.form.Form}
36898 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36899 * This contains a reference to it.
36905 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36915 * @param {Object} cfg Xtype definition of item to add.
36919 getChildContainer: function () {
36920 return this.getEl();
36925 var ret = new Roo.factory(cfg);
36930 if (cfg.xtype.match(/^Form$/)) {
36933 //if (this.footer) {
36934 // el = this.footer.container.insertSibling(false, 'before');
36936 el = this.el.createChild();
36939 this.form = new Roo.form.Form(cfg);
36942 if ( this.form.allItems.length) {
36943 this.form.render(el.dom);
36947 // should only have one of theses..
36948 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36949 // views.. should not be just added - used named prop 'view''
36951 cfg.el = this.el.appendChild(document.createElement("div"));
36954 var ret = new Roo.factory(cfg);
36956 ret.render && ret.render(false, ''); // render blank..
36966 * @class Roo.bootstrap.panel.Grid
36967 * @extends Roo.bootstrap.panel.Content
36969 * Create a new GridPanel.
36970 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
36971 * @param {Object} config A the config object
36977 Roo.bootstrap.panel.Grid = function(config)
36981 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
36982 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
36984 config.el = this.wrapper;
36985 //this.el = this.wrapper;
36987 if (config.container) {
36988 // ctor'ed from a Border/panel.grid
36991 this.wrapper.setStyle("overflow", "hidden");
36992 this.wrapper.addClass('roo-grid-container');
36997 if(config.toolbar){
36998 var tool_el = this.wrapper.createChild();
36999 this.toolbar = Roo.factory(config.toolbar);
37001 if (config.toolbar.items) {
37002 ti = config.toolbar.items ;
37003 delete config.toolbar.items ;
37007 this.toolbar.render(tool_el);
37008 for(var i =0;i < ti.length;i++) {
37009 // Roo.log(['add child', items[i]]);
37010 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37012 this.toolbar.items = nitems;
37014 delete config.toolbar;
37017 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37018 config.grid.scrollBody = true;;
37019 config.grid.monitorWindowResize = false; // turn off autosizing
37020 config.grid.autoHeight = false;
37021 config.grid.autoWidth = false;
37023 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37025 if (config.background) {
37026 // render grid on panel activation (if panel background)
37027 this.on('activate', function(gp) {
37028 if (!gp.grid.rendered) {
37029 gp.grid.render(this.wrapper);
37030 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37035 this.grid.render(this.wrapper);
37036 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37039 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37040 // ??? needed ??? config.el = this.wrapper;
37045 // xtype created footer. - not sure if will work as we normally have to render first..
37046 if (this.footer && !this.footer.el && this.footer.xtype) {
37048 var ctr = this.grid.getView().getFooterPanel(true);
37049 this.footer.dataSource = this.grid.dataSource;
37050 this.footer = Roo.factory(this.footer, Roo);
37051 this.footer.render(ctr);
37061 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37062 getId : function(){
37063 return this.grid.id;
37067 * Returns the grid for this panel
37068 * @return {Roo.bootstrap.Table}
37070 getGrid : function(){
37074 setSize : function(width, height){
37075 if(!this.ignoreResize(width, height)){
37076 var grid = this.grid;
37077 var size = this.adjustForComponents(width, height);
37078 var gridel = grid.getGridEl();
37079 gridel.setSize(size.width, size.height);
37081 var thd = grid.getGridEl().select('thead',true).first();
37082 var tbd = grid.getGridEl().select('tbody', true).first();
37084 tbd.setSize(width, height - thd.getHeight());
37093 beforeSlide : function(){
37094 this.grid.getView().scroller.clip();
37097 afterSlide : function(){
37098 this.grid.getView().scroller.unclip();
37101 destroy : function(){
37102 this.grid.destroy();
37104 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37109 * @class Roo.bootstrap.panel.Nest
37110 * @extends Roo.bootstrap.panel.Content
37112 * Create a new Panel, that can contain a layout.Border.
37115 * @param {Roo.BorderLayout} layout The layout for this panel
37116 * @param {String/Object} config A string to set only the title or a config object
37118 Roo.bootstrap.panel.Nest = function(config)
37120 // construct with only one argument..
37121 /* FIXME - implement nicer consturctors
37122 if (layout.layout) {
37124 layout = config.layout;
37125 delete config.layout;
37127 if (layout.xtype && !layout.getEl) {
37128 // then layout needs constructing..
37129 layout = Roo.factory(layout, Roo);
37133 config.el = config.layout.getEl();
37135 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37137 config.layout.monitorWindowResize = false; // turn off autosizing
37138 this.layout = config.layout;
37139 this.layout.getEl().addClass("roo-layout-nested-layout");
37146 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37148 setSize : function(width, height){
37149 if(!this.ignoreResize(width, height)){
37150 var size = this.adjustForComponents(width, height);
37151 var el = this.layout.getEl();
37152 if (size.height < 1) {
37153 el.setWidth(size.width);
37155 el.setSize(size.width, size.height);
37157 var touch = el.dom.offsetWidth;
37158 this.layout.layout();
37159 // ie requires a double layout on the first pass
37160 if(Roo.isIE && !this.initialized){
37161 this.initialized = true;
37162 this.layout.layout();
37167 // activate all subpanels if not currently active..
37169 setActiveState : function(active){
37170 this.active = active;
37171 this.setActiveClass(active);
37174 this.fireEvent("deactivate", this);
37178 this.fireEvent("activate", this);
37179 // not sure if this should happen before or after..
37180 if (!this.layout) {
37181 return; // should not happen..
37184 for (var r in this.layout.regions) {
37185 reg = this.layout.getRegion(r);
37186 if (reg.getActivePanel()) {
37187 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37188 reg.setActivePanel(reg.getActivePanel());
37191 if (!reg.panels.length) {
37194 reg.showPanel(reg.getPanel(0));
37203 * Returns the nested BorderLayout for this panel
37204 * @return {Roo.BorderLayout}
37206 getLayout : function(){
37207 return this.layout;
37211 * Adds a xtype elements to the layout of the nested panel
37215 xtype : 'ContentPanel',
37222 xtype : 'NestedLayoutPanel',
37228 items : [ ... list of content panels or nested layout panels.. ]
37232 * @param {Object} cfg Xtype definition of item to add.
37234 addxtype : function(cfg) {
37235 return this.layout.addxtype(cfg);
37240 * Ext JS Library 1.1.1
37241 * Copyright(c) 2006-2007, Ext JS, LLC.
37243 * Originally Released Under LGPL - original licence link has changed is not relivant.
37246 * <script type="text/javascript">
37249 * @class Roo.TabPanel
37250 * @extends Roo.util.Observable
37251 * A lightweight tab container.
37255 // basic tabs 1, built from existing content
37256 var tabs = new Roo.TabPanel("tabs1");
37257 tabs.addTab("script", "View Script");
37258 tabs.addTab("markup", "View Markup");
37259 tabs.activate("script");
37261 // more advanced tabs, built from javascript
37262 var jtabs = new Roo.TabPanel("jtabs");
37263 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37265 // set up the UpdateManager
37266 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37267 var updater = tab2.getUpdateManager();
37268 updater.setDefaultUrl("ajax1.htm");
37269 tab2.on('activate', updater.refresh, updater, true);
37271 // Use setUrl for Ajax loading
37272 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37273 tab3.setUrl("ajax2.htm", null, true);
37276 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37279 jtabs.activate("jtabs-1");
37282 * Create a new TabPanel.
37283 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37284 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37286 Roo.bootstrap.panel.Tabs = function(config){
37288 * The container element for this TabPanel.
37289 * @type Roo.Element
37291 this.el = Roo.get(config.el);
37294 if(typeof config == "boolean"){
37295 this.tabPosition = config ? "bottom" : "top";
37297 Roo.apply(this, config);
37301 if(this.tabPosition == "bottom"){
37302 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37303 this.el.addClass("roo-tabs-bottom");
37305 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37306 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37307 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37309 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37311 if(this.tabPosition != "bottom"){
37312 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37313 * @type Roo.Element
37315 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37316 this.el.addClass("roo-tabs-top");
37320 this.bodyEl.setStyle("position", "relative");
37322 this.active = null;
37323 this.activateDelegate = this.activate.createDelegate(this);
37328 * Fires when the active tab changes
37329 * @param {Roo.TabPanel} this
37330 * @param {Roo.TabPanelItem} activePanel The new active tab
37334 * @event beforetabchange
37335 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37336 * @param {Roo.TabPanel} this
37337 * @param {Object} e Set cancel to true on this object to cancel the tab change
37338 * @param {Roo.TabPanelItem} tab The tab being changed to
37340 "beforetabchange" : true
37343 Roo.EventManager.onWindowResize(this.onResize, this);
37344 this.cpad = this.el.getPadding("lr");
37345 this.hiddenCount = 0;
37348 // toolbar on the tabbar support...
37349 if (this.toolbar) {
37350 alert("no toolbar support yet");
37351 this.toolbar = false;
37353 var tcfg = this.toolbar;
37354 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37355 this.toolbar = new Roo.Toolbar(tcfg);
37356 if (Roo.isSafari) {
37357 var tbl = tcfg.container.child('table', true);
37358 tbl.setAttribute('width', '100%');
37366 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37369 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37371 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37373 tabPosition : "top",
37375 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37377 currentTabWidth : 0,
37379 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37383 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37387 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37389 preferredTabWidth : 175,
37391 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37393 resizeTabs : false,
37395 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37397 monitorResize : true,
37399 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37404 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37405 * @param {String} id The id of the div to use <b>or create</b>
37406 * @param {String} text The text for the tab
37407 * @param {String} content (optional) Content to put in the TabPanelItem body
37408 * @param {Boolean} closable (optional) True to create a close icon on the tab
37409 * @return {Roo.TabPanelItem} The created TabPanelItem
37411 addTab : function(id, text, content, closable, tpl)
37413 var item = new Roo.bootstrap.panel.TabItem({
37417 closable : closable,
37420 this.addTabItem(item);
37422 item.setContent(content);
37428 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37429 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37430 * @return {Roo.TabPanelItem}
37432 getTab : function(id){
37433 return this.items[id];
37437 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37438 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37440 hideTab : function(id){
37441 var t = this.items[id];
37444 this.hiddenCount++;
37445 this.autoSizeTabs();
37450 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37451 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37453 unhideTab : function(id){
37454 var t = this.items[id];
37456 t.setHidden(false);
37457 this.hiddenCount--;
37458 this.autoSizeTabs();
37463 * Adds an existing {@link Roo.TabPanelItem}.
37464 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37466 addTabItem : function(item){
37467 this.items[item.id] = item;
37468 this.items.push(item);
37469 // if(this.resizeTabs){
37470 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37471 // this.autoSizeTabs();
37473 // item.autoSize();
37478 * Removes a {@link Roo.TabPanelItem}.
37479 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37481 removeTab : function(id){
37482 var items = this.items;
37483 var tab = items[id];
37484 if(!tab) { return; }
37485 var index = items.indexOf(tab);
37486 if(this.active == tab && items.length > 1){
37487 var newTab = this.getNextAvailable(index);
37492 this.stripEl.dom.removeChild(tab.pnode.dom);
37493 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37494 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37496 items.splice(index, 1);
37497 delete this.items[tab.id];
37498 tab.fireEvent("close", tab);
37499 tab.purgeListeners();
37500 this.autoSizeTabs();
37503 getNextAvailable : function(start){
37504 var items = this.items;
37506 // look for a next tab that will slide over to
37507 // replace the one being removed
37508 while(index < items.length){
37509 var item = items[++index];
37510 if(item && !item.isHidden()){
37514 // if one isn't found select the previous tab (on the left)
37517 var item = items[--index];
37518 if(item && !item.isHidden()){
37526 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37527 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37529 disableTab : function(id){
37530 var tab = this.items[id];
37531 if(tab && this.active != tab){
37537 * Enables a {@link Roo.TabPanelItem} that is disabled.
37538 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37540 enableTab : function(id){
37541 var tab = this.items[id];
37546 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37547 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37548 * @return {Roo.TabPanelItem} The TabPanelItem.
37550 activate : function(id){
37551 var tab = this.items[id];
37555 if(tab == this.active || tab.disabled){
37559 this.fireEvent("beforetabchange", this, e, tab);
37560 if(e.cancel !== true && !tab.disabled){
37562 this.active.hide();
37564 this.active = this.items[id];
37565 this.active.show();
37566 this.fireEvent("tabchange", this, this.active);
37572 * Gets the active {@link Roo.TabPanelItem}.
37573 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37575 getActiveTab : function(){
37576 return this.active;
37580 * Updates the tab body element to fit the height of the container element
37581 * for overflow scrolling
37582 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37584 syncHeight : function(targetHeight){
37585 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37586 var bm = this.bodyEl.getMargins();
37587 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37588 this.bodyEl.setHeight(newHeight);
37592 onResize : function(){
37593 if(this.monitorResize){
37594 this.autoSizeTabs();
37599 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37601 beginUpdate : function(){
37602 this.updating = true;
37606 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37608 endUpdate : function(){
37609 this.updating = false;
37610 this.autoSizeTabs();
37614 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37616 autoSizeTabs : function(){
37617 var count = this.items.length;
37618 var vcount = count - this.hiddenCount;
37619 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37622 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37623 var availWidth = Math.floor(w / vcount);
37624 var b = this.stripBody;
37625 if(b.getWidth() > w){
37626 var tabs = this.items;
37627 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37628 if(availWidth < this.minTabWidth){
37629 /*if(!this.sleft){ // incomplete scrolling code
37630 this.createScrollButtons();
37633 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37636 if(this.currentTabWidth < this.preferredTabWidth){
37637 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37643 * Returns the number of tabs in this TabPanel.
37646 getCount : function(){
37647 return this.items.length;
37651 * Resizes all the tabs to the passed width
37652 * @param {Number} The new width
37654 setTabWidth : function(width){
37655 this.currentTabWidth = width;
37656 for(var i = 0, len = this.items.length; i < len; i++) {
37657 if(!this.items[i].isHidden()) {
37658 this.items[i].setWidth(width);
37664 * Destroys this TabPanel
37665 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37667 destroy : function(removeEl){
37668 Roo.EventManager.removeResizeListener(this.onResize, this);
37669 for(var i = 0, len = this.items.length; i < len; i++){
37670 this.items[i].purgeListeners();
37672 if(removeEl === true){
37673 this.el.update("");
37678 createStrip : function(container)
37680 var strip = document.createElement("nav");
37681 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37682 container.appendChild(strip);
37686 createStripList : function(strip)
37688 // div wrapper for retard IE
37689 // returns the "tr" element.
37690 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37691 //'<div class="x-tabs-strip-wrap">'+
37692 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37693 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37694 return strip.firstChild; //.firstChild.firstChild.firstChild;
37696 createBody : function(container)
37698 var body = document.createElement("div");
37699 Roo.id(body, "tab-body");
37700 //Roo.fly(body).addClass("x-tabs-body");
37701 Roo.fly(body).addClass("tab-content");
37702 container.appendChild(body);
37705 createItemBody :function(bodyEl, id){
37706 var body = Roo.getDom(id);
37708 body = document.createElement("div");
37711 //Roo.fly(body).addClass("x-tabs-item-body");
37712 Roo.fly(body).addClass("tab-pane");
37713 bodyEl.insertBefore(body, bodyEl.firstChild);
37717 createStripElements : function(stripEl, text, closable, tpl)
37719 var td = document.createElement("li"); // was td..
37722 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37725 stripEl.appendChild(td);
37727 td.className = "x-tabs-closable";
37728 if(!this.closeTpl){
37729 this.closeTpl = new Roo.Template(
37730 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37731 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37732 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37735 var el = this.closeTpl.overwrite(td, {"text": text});
37736 var close = el.getElementsByTagName("div")[0];
37737 var inner = el.getElementsByTagName("em")[0];
37738 return {"el": el, "close": close, "inner": inner};
37741 // not sure what this is..
37742 // if(!this.tabTpl){
37743 //this.tabTpl = new Roo.Template(
37744 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37745 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37747 // this.tabTpl = new Roo.Template(
37748 // '<a href="#">' +
37749 // '<span unselectable="on"' +
37750 // (this.disableTooltips ? '' : ' title="{text}"') +
37751 // ' >{text}</span></a>'
37757 var template = tpl || this.tabTpl || false;
37761 template = new Roo.Template(
37763 '<span unselectable="on"' +
37764 (this.disableTooltips ? '' : ' title="{text}"') +
37765 ' >{text}</span></a>'
37769 switch (typeof(template)) {
37773 template = new Roo.Template(template);
37779 var el = template.overwrite(td, {"text": text});
37781 var inner = el.getElementsByTagName("span")[0];
37783 return {"el": el, "inner": inner};
37791 * @class Roo.TabPanelItem
37792 * @extends Roo.util.Observable
37793 * Represents an individual item (tab plus body) in a TabPanel.
37794 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37795 * @param {String} id The id of this TabPanelItem
37796 * @param {String} text The text for the tab of this TabPanelItem
37797 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37799 Roo.bootstrap.panel.TabItem = function(config){
37801 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37802 * @type Roo.TabPanel
37804 this.tabPanel = config.panel;
37806 * The id for this TabPanelItem
37809 this.id = config.id;
37811 this.disabled = false;
37813 this.text = config.text;
37815 this.loaded = false;
37816 this.closable = config.closable;
37819 * The body element for this TabPanelItem.
37820 * @type Roo.Element
37822 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37823 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37824 this.bodyEl.setStyle("display", "block");
37825 this.bodyEl.setStyle("zoom", "1");
37826 //this.hideAction();
37828 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37830 this.el = Roo.get(els.el);
37831 this.inner = Roo.get(els.inner, true);
37832 this.textEl = Roo.get(this.el.dom.firstChild, true);
37833 this.pnode = Roo.get(els.el.parentNode, true);
37834 // this.el.on("mousedown", this.onTabMouseDown, this);
37835 this.el.on("click", this.onTabClick, this);
37837 if(config.closable){
37838 var c = Roo.get(els.close, true);
37839 c.dom.title = this.closeText;
37840 c.addClassOnOver("close-over");
37841 c.on("click", this.closeClick, this);
37847 * Fires when this tab becomes the active tab.
37848 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37849 * @param {Roo.TabPanelItem} this
37853 * @event beforeclose
37854 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37855 * @param {Roo.TabPanelItem} this
37856 * @param {Object} e Set cancel to true on this object to cancel the close.
37858 "beforeclose": true,
37861 * Fires when this tab is closed.
37862 * @param {Roo.TabPanelItem} this
37866 * @event deactivate
37867 * Fires when this tab is no longer the active tab.
37868 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37869 * @param {Roo.TabPanelItem} this
37871 "deactivate" : true
37873 this.hidden = false;
37875 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37878 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37880 purgeListeners : function(){
37881 Roo.util.Observable.prototype.purgeListeners.call(this);
37882 this.el.removeAllListeners();
37885 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37888 this.pnode.addClass("active");
37891 this.tabPanel.stripWrap.repaint();
37893 this.fireEvent("activate", this.tabPanel, this);
37897 * Returns true if this tab is the active tab.
37898 * @return {Boolean}
37900 isActive : function(){
37901 return this.tabPanel.getActiveTab() == this;
37905 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37908 this.pnode.removeClass("active");
37910 this.fireEvent("deactivate", this.tabPanel, this);
37913 hideAction : function(){
37914 this.bodyEl.hide();
37915 this.bodyEl.setStyle("position", "absolute");
37916 this.bodyEl.setLeft("-20000px");
37917 this.bodyEl.setTop("-20000px");
37920 showAction : function(){
37921 this.bodyEl.setStyle("position", "relative");
37922 this.bodyEl.setTop("");
37923 this.bodyEl.setLeft("");
37924 this.bodyEl.show();
37928 * Set the tooltip for the tab.
37929 * @param {String} tooltip The tab's tooltip
37931 setTooltip : function(text){
37932 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37933 this.textEl.dom.qtip = text;
37934 this.textEl.dom.removeAttribute('title');
37936 this.textEl.dom.title = text;
37940 onTabClick : function(e){
37941 e.preventDefault();
37942 this.tabPanel.activate(this.id);
37945 onTabMouseDown : function(e){
37946 e.preventDefault();
37947 this.tabPanel.activate(this.id);
37950 getWidth : function(){
37951 return this.inner.getWidth();
37954 setWidth : function(width){
37955 var iwidth = width - this.pnode.getPadding("lr");
37956 this.inner.setWidth(iwidth);
37957 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
37958 this.pnode.setWidth(width);
37962 * Show or hide the tab
37963 * @param {Boolean} hidden True to hide or false to show.
37965 setHidden : function(hidden){
37966 this.hidden = hidden;
37967 this.pnode.setStyle("display", hidden ? "none" : "");
37971 * Returns true if this tab is "hidden"
37972 * @return {Boolean}
37974 isHidden : function(){
37975 return this.hidden;
37979 * Returns the text for this tab
37982 getText : function(){
37986 autoSize : function(){
37987 //this.el.beginMeasure();
37988 this.textEl.setWidth(1);
37990 * #2804 [new] Tabs in Roojs
37991 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
37993 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
37994 //this.el.endMeasure();
37998 * Sets the text for the tab (Note: this also sets the tooltip text)
37999 * @param {String} text The tab's text and tooltip
38001 setText : function(text){
38003 this.textEl.update(text);
38004 this.setTooltip(text);
38005 //if(!this.tabPanel.resizeTabs){
38006 // this.autoSize();
38010 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38012 activate : function(){
38013 this.tabPanel.activate(this.id);
38017 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38019 disable : function(){
38020 if(this.tabPanel.active != this){
38021 this.disabled = true;
38022 this.pnode.addClass("disabled");
38027 * Enables this TabPanelItem if it was previously disabled.
38029 enable : function(){
38030 this.disabled = false;
38031 this.pnode.removeClass("disabled");
38035 * Sets the content for this TabPanelItem.
38036 * @param {String} content The content
38037 * @param {Boolean} loadScripts true to look for and load scripts
38039 setContent : function(content, loadScripts){
38040 this.bodyEl.update(content, loadScripts);
38044 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38045 * @return {Roo.UpdateManager} The UpdateManager
38047 getUpdateManager : function(){
38048 return this.bodyEl.getUpdateManager();
38052 * Set a URL to be used to load the content for this TabPanelItem.
38053 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38054 * @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)
38055 * @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)
38056 * @return {Roo.UpdateManager} The UpdateManager
38058 setUrl : function(url, params, loadOnce){
38059 if(this.refreshDelegate){
38060 this.un('activate', this.refreshDelegate);
38062 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38063 this.on("activate", this.refreshDelegate);
38064 return this.bodyEl.getUpdateManager();
38068 _handleRefresh : function(url, params, loadOnce){
38069 if(!loadOnce || !this.loaded){
38070 var updater = this.bodyEl.getUpdateManager();
38071 updater.update(url, params, this._setLoaded.createDelegate(this));
38076 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38077 * Will fail silently if the setUrl method has not been called.
38078 * This does not activate the panel, just updates its content.
38080 refresh : function(){
38081 if(this.refreshDelegate){
38082 this.loaded = false;
38083 this.refreshDelegate();
38088 _setLoaded : function(){
38089 this.loaded = true;
38093 closeClick : function(e){
38096 this.fireEvent("beforeclose", this, o);
38097 if(o.cancel !== true){
38098 this.tabPanel.removeTab(this.id);
38102 * The text displayed in the tooltip for the close icon.
38105 closeText : "Close this tab"
38108 * This script refer to:
38109 * Title: International Telephone Input
38110 * Author: Jack O'Connor
38111 * Code version: v12.1.12
38112 * Availability: https://github.com/jackocnr/intl-tel-input.git
38115 Roo.bootstrap.PhoneInputData = function() {
38118 "Afghanistan (افغانستان)",
38123 "Albania (Shqipëri)",
38128 "Algeria (الجزائر)",
38153 "Antigua and Barbuda",
38163 "Armenia (Հայաստան)",
38179 "Austria (Österreich)",
38184 "Azerbaijan (Azərbaycan)",
38194 "Bahrain (البحرين)",
38199 "Bangladesh (বাংলাদেশ)",
38209 "Belarus (Беларусь)",
38214 "Belgium (België)",
38244 "Bosnia and Herzegovina (Босна и Херцеговина)",
38259 "British Indian Ocean Territory",
38264 "British Virgin Islands",
38274 "Bulgaria (България)",
38284 "Burundi (Uburundi)",
38289 "Cambodia (កម្ពុជា)",
38294 "Cameroon (Cameroun)",
38303 ["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"]
38306 "Cape Verde (Kabu Verdi)",
38311 "Caribbean Netherlands",
38322 "Central African Republic (République centrafricaine)",
38342 "Christmas Island",
38348 "Cocos (Keeling) Islands",
38359 "Comoros (جزر القمر)",
38364 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38369 "Congo (Republic) (Congo-Brazzaville)",
38389 "Croatia (Hrvatska)",
38410 "Czech Republic (Česká republika)",
38415 "Denmark (Danmark)",
38430 "Dominican Republic (República Dominicana)",
38434 ["809", "829", "849"]
38452 "Equatorial Guinea (Guinea Ecuatorial)",
38472 "Falkland Islands (Islas Malvinas)",
38477 "Faroe Islands (Føroyar)",
38498 "French Guiana (Guyane française)",
38503 "French Polynesia (Polynésie française)",
38518 "Georgia (საქართველო)",
38523 "Germany (Deutschland)",
38543 "Greenland (Kalaallit Nunaat)",
38580 "Guinea-Bissau (Guiné Bissau)",
38605 "Hungary (Magyarország)",
38610 "Iceland (Ísland)",
38630 "Iraq (العراق)",
38646 "Israel (ישראל)",
38673 "Jordan (الأردن)",
38678 "Kazakhstan (Казахстан)",
38699 "Kuwait (الكويت)",
38704 "Kyrgyzstan (Кыргызстан)",
38714 "Latvia (Latvija)",
38719 "Lebanon (لبنان)",
38734 "Libya (ليبيا)",
38744 "Lithuania (Lietuva)",
38759 "Macedonia (FYROM) (Македонија)",
38764 "Madagascar (Madagasikara)",
38794 "Marshall Islands",
38804 "Mauritania (موريتانيا)",
38809 "Mauritius (Moris)",
38830 "Moldova (Republica Moldova)",
38840 "Mongolia (Монгол)",
38845 "Montenegro (Crna Gora)",
38855 "Morocco (المغرب)",
38861 "Mozambique (Moçambique)",
38866 "Myanmar (Burma) (မြန်မာ)",
38871 "Namibia (Namibië)",
38886 "Netherlands (Nederland)",
38891 "New Caledonia (Nouvelle-Calédonie)",
38926 "North Korea (조선 민주주의 인민 공화국)",
38931 "Northern Mariana Islands",
38947 "Pakistan (پاکستان)",
38957 "Palestine (فلسطين)",
38967 "Papua New Guinea",
39009 "Réunion (La Réunion)",
39015 "Romania (România)",
39031 "Saint Barthélemy",
39042 "Saint Kitts and Nevis",
39052 "Saint Martin (Saint-Martin (partie française))",
39058 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39063 "Saint Vincent and the Grenadines",
39078 "São Tomé and Príncipe (São Tomé e Príncipe)",
39083 "Saudi Arabia (المملكة العربية السعودية)",
39088 "Senegal (Sénégal)",
39118 "Slovakia (Slovensko)",
39123 "Slovenia (Slovenija)",
39133 "Somalia (Soomaaliya)",
39143 "South Korea (대한민국)",
39148 "South Sudan (جنوب السودان)",
39158 "Sri Lanka (ශ්රී ලංකාව)",
39163 "Sudan (السودان)",
39173 "Svalbard and Jan Mayen",
39184 "Sweden (Sverige)",
39189 "Switzerland (Schweiz)",
39194 "Syria (سوريا)",
39239 "Trinidad and Tobago",
39244 "Tunisia (تونس)",
39249 "Turkey (Türkiye)",
39259 "Turks and Caicos Islands",
39269 "U.S. Virgin Islands",
39279 "Ukraine (Україна)",
39284 "United Arab Emirates (الإمارات العربية المتحدة)",
39306 "Uzbekistan (Oʻzbekiston)",
39316 "Vatican City (Città del Vaticano)",
39327 "Vietnam (Việt Nam)",
39332 "Wallis and Futuna (Wallis-et-Futuna)",
39337 "Western Sahara (الصحراء الغربية)",
39343 "Yemen (اليمن)",
39367 * This script refer to:
39368 * Title: International Telephone Input
39369 * Author: Jack O'Connor
39370 * Code version: v12.1.12
39371 * Availability: https://github.com/jackocnr/intl-tel-input.git
39375 * @class Roo.bootstrap.PhoneInput
39376 * @extends Roo.bootstrap.TriggerField
39377 * An input with International dial-code selection
39379 * @cfg {String} defaultDialCode default '+852'
39380 * @cfg {Array} preferedCountries default []
39383 * Create a new PhoneInput.
39384 * @param {Object} config Configuration options
39387 Roo.bootstrap.PhoneInput = function(config) {
39388 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39391 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39393 listWidth: undefined,
39395 selectedClass: 'active',
39397 invalidClass : "has-warning",
39399 validClass: 'has-success',
39401 allowed: '0123456789',
39404 * @cfg {String} defaultDialCode The default dial code when initializing the input
39406 defaultDialCode: '+852',
39409 * @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
39411 preferedCountries: false,
39413 getAutoCreate : function()
39415 var data = Roo.bootstrap.PhoneInputData();
39416 var align = this.labelAlign || this.parentLabelAlign();
39419 this.allCountries = [];
39420 this.dialCodeMapping = [];
39422 for (var i = 0; i < data.length; i++) {
39424 this.allCountries[i] = {
39428 priority: c[3] || 0,
39429 areaCodes: c[4] || null
39431 this.dialCodeMapping[c[2]] = {
39434 priority: c[3] || 0,
39435 areaCodes: c[4] || null
39447 cls : 'form-control tel-input',
39448 autocomplete: 'new-password'
39451 var hiddenInput = {
39454 cls: 'hidden-tel-input'
39458 hiddenInput.name = this.name;
39461 if (this.disabled) {
39462 input.disabled = true;
39465 var flag_container = {
39482 cls: this.hasFeedback ? 'has-feedback' : '',
39488 cls: 'dial-code-holder',
39495 cls: 'roo-select2-container input-group',
39502 if (this.fieldLabel.length) {
39505 tooltip: 'This field is required'
39511 cls: 'control-label',
39517 html: this.fieldLabel
39520 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39526 if(this.indicatorpos == 'right') {
39527 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39534 if(align == 'left') {
39542 if(this.labelWidth > 12){
39543 label.style = "width: " + this.labelWidth + 'px';
39545 if(this.labelWidth < 13 && this.labelmd == 0){
39546 this.labelmd = this.labelWidth;
39548 if(this.labellg > 0){
39549 label.cls += ' col-lg-' + this.labellg;
39550 input.cls += ' col-lg-' + (12 - this.labellg);
39552 if(this.labelmd > 0){
39553 label.cls += ' col-md-' + this.labelmd;
39554 container.cls += ' col-md-' + (12 - this.labelmd);
39556 if(this.labelsm > 0){
39557 label.cls += ' col-sm-' + this.labelsm;
39558 container.cls += ' col-sm-' + (12 - this.labelsm);
39560 if(this.labelxs > 0){
39561 label.cls += ' col-xs-' + this.labelxs;
39562 container.cls += ' col-xs-' + (12 - this.labelxs);
39572 var settings = this;
39574 ['xs','sm','md','lg'].map(function(size){
39575 if (settings[size]) {
39576 cfg.cls += ' col-' + size + '-' + settings[size];
39580 this.store = new Roo.data.Store({
39581 proxy : new Roo.data.MemoryProxy({}),
39582 reader : new Roo.data.JsonReader({
39593 'name' : 'dialCode',
39597 'name' : 'priority',
39601 'name' : 'areaCodes',
39608 if(!this.preferedCountries) {
39609 this.preferedCountries = [
39616 var p = this.preferedCountries.reverse();
39619 for (var i = 0; i < p.length; i++) {
39620 for (var j = 0; j < this.allCountries.length; j++) {
39621 if(this.allCountries[j].iso2 == p[i]) {
39622 var t = this.allCountries[j];
39623 this.allCountries.splice(j,1);
39624 this.allCountries.unshift(t);
39630 this.store.proxy.data = {
39632 data: this.allCountries
39638 initEvents : function()
39641 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39643 this.indicator = this.indicatorEl();
39644 this.flag = this.flagEl();
39645 this.dialCodeHolder = this.dialCodeHolderEl();
39647 this.trigger = this.el.select('div.flag-box',true).first();
39648 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39653 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39654 _this.list.setWidth(lw);
39657 this.list.on('mouseover', this.onViewOver, this);
39658 this.list.on('mousemove', this.onViewMove, this);
39659 this.inputEl().on("keyup", this.onKeyUp, this);
39661 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39663 this.view = new Roo.View(this.list, this.tpl, {
39664 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39667 this.view.on('click', this.onViewClick, this);
39668 this.setValue(this.defaultDialCode);
39671 onTriggerClick : function(e)
39673 Roo.log('trigger click');
39678 if(this.isExpanded()){
39680 this.hasFocus = false;
39682 this.store.load({});
39683 this.hasFocus = true;
39688 isExpanded : function()
39690 return this.list.isVisible();
39693 collapse : function()
39695 if(!this.isExpanded()){
39699 Roo.get(document).un('mousedown', this.collapseIf, this);
39700 Roo.get(document).un('mousewheel', this.collapseIf, this);
39701 this.fireEvent('collapse', this);
39705 expand : function()
39709 if(this.isExpanded() || !this.hasFocus){
39713 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39714 this.list.setWidth(lw);
39717 this.restrictHeight();
39719 Roo.get(document).on('mousedown', this.collapseIf, this);
39720 Roo.get(document).on('mousewheel', this.collapseIf, this);
39722 this.fireEvent('expand', this);
39725 restrictHeight : function()
39727 this.list.alignTo(this.inputEl(), this.listAlign);
39728 this.list.alignTo(this.inputEl(), this.listAlign);
39731 onViewOver : function(e, t)
39733 if(this.inKeyMode){
39736 var item = this.view.findItemFromChild(t);
39739 var index = this.view.indexOf(item);
39740 this.select(index, false);
39745 onViewClick : function(view, doFocus, el, e)
39747 var index = this.view.getSelectedIndexes()[0];
39749 var r = this.store.getAt(index);
39752 this.onSelect(r, index);
39754 if(doFocus !== false && !this.blockFocus){
39755 this.inputEl().focus();
39759 onViewMove : function(e, t)
39761 this.inKeyMode = false;
39764 select : function(index, scrollIntoView)
39766 this.selectedIndex = index;
39767 this.view.select(index);
39768 if(scrollIntoView !== false){
39769 var el = this.view.getNode(index);
39771 this.list.scrollChildIntoView(el, false);
39776 createList : function()
39778 this.list = Roo.get(document.body).createChild({
39780 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39781 style: 'display:none'
39783 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39786 collapseIf : function(e)
39788 var in_combo = e.within(this.el);
39789 var in_list = e.within(this.list);
39790 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39792 if (in_combo || in_list || is_list) {
39798 onSelect : function(record, index)
39800 if(this.fireEvent('beforeselect', this, record, index) !== false){
39802 this.setFlagClass(record.data.iso2);
39803 this.setDialCode(record.data.dialCode);
39804 this.hasFocus = false;
39806 this.fireEvent('select', this, record, index);
39810 flagEl : function()
39812 var flag = this.el.select('div.flag',true).first();
39819 dialCodeHolderEl : function()
39821 var d = this.el.select('input.dial-code-holder',true).first();
39828 setDialCode : function(v)
39830 this.dialCodeHolder.dom.value = '+'+v;
39833 setFlagClass : function(n)
39835 this.flag.dom.className = 'flag '+n;
39838 getValue : function()
39840 var v = this.inputEl().getValue();
39841 if(this.dialCodeHolder) {
39842 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
39847 setValue : function(v)
39849 var d = this.getDialCode(v);
39851 //invalid dial code
39852 if(v.length == 0 || !d || d.length == 0) {
39854 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
39855 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39861 this.setFlagClass(this.dialCodeMapping[d].iso2);
39862 this.setDialCode(d);
39863 this.inputEl().dom.value = v.replace('+'+d,'');
39864 this.hiddenEl().dom.value = this.getValue();
39869 getDialCode : function(v = '')
39871 if (v.length == 0) {
39872 return this.dialCodeHolder.dom.value;
39876 if (v.charAt(0) != "+") {
39879 var numericChars = "";
39880 for (var i = 1; i < v.length; i++) {
39881 var c = v.charAt(i);
39884 if (this.dialCodeMapping[numericChars]) {
39885 dialCode = v.substr(1, i);
39887 if (numericChars.length == 4) {
39897 this.setValue(this.defaultDialCode);
39901 hiddenEl : function()
39903 return this.el.select('input.hidden-tel-input',true).first();
39906 onKeyUp : function(e){
39908 var k = e.getKey();
39909 var c = e.getCharCode();
39912 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39913 this.allowed.indexOf(String.fromCharCode(c)) === -1
39918 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39921 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
39925 this.setValue(this.getValue());
39930 * @class Roo.bootstrap.MoneyField
39931 * @extends Roo.bootstrap.ComboBox
39932 * Bootstrap MoneyField class
39935 * Create a new MoneyField.
39936 * @param {Object} config Configuration options
39939 Roo.bootstrap.MoneyField = function(config) {
39941 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
39945 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
39948 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
39950 allowDecimals : true,
39952 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
39954 decimalSeparator : ".",
39956 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
39958 decimalPrecision : 2,
39960 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
39962 allowNegative : true,
39964 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
39966 minValue : Number.NEGATIVE_INFINITY,
39968 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
39970 maxValue : Number.MAX_VALUE,
39972 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
39974 minText : "The minimum value for this field is {0}",
39976 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
39978 maxText : "The maximum value for this field is {0}",
39980 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
39981 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
39983 nanText : "{0} is not a valid number",
39985 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
39989 * @cfg {String} defaults currency of the MoneyField
39990 * value should be in lkey
39992 defaultCurrency : false,
40002 getAutoCreate : function()
40004 var align = this.labelAlign || this.parentLabelAlign();
40016 cls : 'form-control roo-money-amount-input',
40017 autocomplete: 'new-password'
40021 input.name = this.name;
40024 if (this.disabled) {
40025 input.disabled = true;
40028 var clg = 12 - this.inputlg;
40029 var cmd = 12 - this.inputmd;
40030 var csm = 12 - this.inputsm;
40031 var cxs = 12 - this.inputxs;
40035 cls : 'row roo-money-field',
40039 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40043 cls: 'roo-select2-container input-group',
40047 cls : 'form-control roo-money-currency-input',
40048 autocomplete: 'new-password',
40050 name : this.currencyName
40054 cls : 'input-group-addon',
40068 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40072 cls: this.hasFeedback ? 'has-feedback' : '',
40083 if (this.fieldLabel.length) {
40086 tooltip: 'This field is required'
40092 cls: 'control-label',
40098 html: this.fieldLabel
40101 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40107 if(this.indicatorpos == 'right') {
40108 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40115 if(align == 'left') {
40123 if(this.labelWidth > 12){
40124 label.style = "width: " + this.labelWidth + 'px';
40126 if(this.labelWidth < 13 && this.labelmd == 0){
40127 this.labelmd = this.labelWidth;
40129 if(this.labellg > 0){
40130 label.cls += ' col-lg-' + this.labellg;
40131 input.cls += ' col-lg-' + (12 - this.labellg);
40133 if(this.labelmd > 0){
40134 label.cls += ' col-md-' + this.labelmd;
40135 container.cls += ' col-md-' + (12 - this.labelmd);
40137 if(this.labelsm > 0){
40138 label.cls += ' col-sm-' + this.labelsm;
40139 container.cls += ' col-sm-' + (12 - this.labelsm);
40141 if(this.labelxs > 0){
40142 label.cls += ' col-xs-' + this.labelxs;
40143 container.cls += ' col-xs-' + (12 - this.labelxs);
40153 var settings = this;
40155 ['xs','sm','md','lg'].map(function(size){
40156 if (settings[size]) {
40157 cfg.cls += ' col-' + size + '-' + settings[size];
40165 initEvents : function()
40167 this.indicator = this.indicatorEl();
40169 this.initCurrencyEvent();
40171 this.initNumberEvent();
40175 initCurrencyEvent : function()
40178 throw "can not find store for combo";
40181 this.store = Roo.factory(this.store, Roo.data);
40182 this.store.parent = this;
40186 this.triggerEl = this.el.select('.input-group-addon', true).first();
40188 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40193 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40194 _this.list.setWidth(lw);
40197 this.list.on('mouseover', this.onViewOver, this);
40198 this.list.on('mousemove', this.onViewMove, this);
40199 this.list.on('scroll', this.onViewScroll, this);
40202 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40205 this.view = new Roo.View(this.list, this.tpl, {
40206 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40209 this.view.on('click', this.onViewClick, this);
40211 this.store.on('beforeload', this.onBeforeLoad, this);
40212 this.store.on('load', this.onLoad, this);
40213 this.store.on('loadexception', this.onLoadException, this);
40215 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40216 "up" : function(e){
40217 this.inKeyMode = true;
40221 "down" : function(e){
40222 if(!this.isExpanded()){
40223 this.onTriggerClick();
40225 this.inKeyMode = true;
40230 "enter" : function(e){
40233 if(this.fireEvent("specialkey", this, e)){
40234 this.onViewClick(false);
40240 "esc" : function(e){
40244 "tab" : function(e){
40247 if(this.fireEvent("specialkey", this, e)){
40248 this.onViewClick(false);
40256 doRelay : function(foo, bar, hname){
40257 if(hname == 'down' || this.scope.isExpanded()){
40258 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40266 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40270 initNumberEvent : function(e)
40272 this.inputEl().on("keydown" , this.fireKey, this);
40273 this.inputEl().on("focus", this.onFocus, this);
40274 this.inputEl().on("blur", this.onBlur, this);
40276 this.inputEl().relayEvent('keyup', this);
40278 if(this.indicator){
40279 this.indicator.addClass('invisible');
40282 this.originalValue = this.getValue();
40284 if(this.validationEvent == 'keyup'){
40285 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40286 this.inputEl().on('keyup', this.filterValidation, this);
40288 else if(this.validationEvent !== false){
40289 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40292 if(this.selectOnFocus){
40293 this.on("focus", this.preFocus, this);
40296 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40297 this.inputEl().on("keypress", this.filterKeys, this);
40299 this.inputEl().relayEvent('keypress', this);
40302 var allowed = "0123456789";
40304 if(this.allowDecimals){
40305 allowed += this.decimalSeparator;
40308 if(this.allowNegative){
40312 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40314 var keyPress = function(e){
40316 var k = e.getKey();
40318 var c = e.getCharCode();
40321 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40322 allowed.indexOf(String.fromCharCode(c)) === -1
40328 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40332 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40337 this.inputEl().on("keypress", keyPress, this);
40341 onTriggerClick : function(e)
40348 this.loadNext = false;
40350 if(this.isExpanded()){
40355 this.hasFocus = true;
40357 if(this.triggerAction == 'all') {
40358 this.doQuery(this.allQuery, true);
40362 this.doQuery(this.getRawValue());
40365 getCurrency : function()
40367 var v = this.currencyEl().getValue();
40372 restrictHeight : function()
40374 this.list.alignTo(this.currencyEl(), this.listAlign);
40375 this.list.alignTo(this.currencyEl(), this.listAlign);
40378 onViewClick : function(view, doFocus, el, e)
40380 var index = this.view.getSelectedIndexes()[0];
40382 var r = this.store.getAt(index);
40385 this.onSelect(r, index);
40389 onSelect : function(record, index){
40391 if(this.fireEvent('beforeselect', this, record, index) !== false){
40393 this.setFromCurrencyData(index > -1 ? record.data : false);
40397 this.fireEvent('select', this, record, index);
40401 setFromCurrencyData : function(o)
40405 this.lastCurrency = o;
40407 if (this.currencyField) {
40408 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40410 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40413 this.lastSelectionText = currency;
40415 //setting default currency
40416 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40417 this.setCurrency(this.defaultCurrency);
40421 this.setCurrency(currency);
40424 setFromData : function(o)
40428 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40430 this.setFromCurrencyData(c);
40435 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40437 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40440 this.setValue(value);
40444 setCurrency : function(v)
40446 this.currencyValue = v;
40449 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40454 setValue : function(v)
40456 v = this.fixPrecision(v);
40458 v = String(v).replace(".", this.decimalSeparator);
40463 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40468 getRawValue : function()
40470 var v = this.inputEl().getValue();
40475 getValue : function()
40477 return this.fixPrecision(this.parseValue(this.getRawValue()));
40480 parseValue : function(value)
40482 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40483 return isNaN(value) ? '' : value;
40486 fixPrecision : function(value)
40488 var nan = isNaN(value);
40490 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40491 return nan ? '' : value;
40494 return parseFloat(value).toFixed(this.decimalPrecision);
40497 decimalPrecisionFcn : function(v)
40499 return Math.floor(v);
40502 validateValue : function(value)
40504 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40508 var num = this.parseValue(value);
40511 this.markInvalid(String.format(this.nanText, value));
40515 if(num < this.minValue){
40516 this.markInvalid(String.format(this.minText, this.minValue));
40520 if(num > this.maxValue){
40521 this.markInvalid(String.format(this.maxText, this.maxValue));
40528 validate : function()
40530 if(this.disabled || this.allowBlank){
40535 var currency = this.getCurrency();
40537 if(this.validateValue(this.getRawValue()) && currency.length){
40542 this.markInvalid();
40546 getName: function()
40551 beforeBlur : function()
40557 var v = this.parseValue(this.getRawValue());
40564 onBlur : function()
40568 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40569 //this.el.removeClass(this.focusClass);
40572 this.hasFocus = false;
40574 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40578 var v = this.getValue();
40580 if(String(v) !== String(this.startValue)){
40581 this.fireEvent('change', this, v, this.startValue);
40584 this.fireEvent("blur", this);
40587 inputEl : function()
40589 return this.el.select('.roo-money-amount-input', true).first();
40592 currencyEl : function()
40594 return this.el.select('.roo-money-currency-input', true).first();