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
376 this.getEl().removeClass('hidden');
380 * Hide a component - adds 'hidden' class
384 if(!this.getEl() || this.getEl().hasClass('hidden')){
388 this.getEl().addClass('hidden');
401 * @class Roo.bootstrap.Body
402 * @extends Roo.bootstrap.Component
403 * Bootstrap Body class
407 * @param {Object} config The config object
410 Roo.bootstrap.Body = function(config){
412 config = config || {};
414 Roo.bootstrap.Body.superclass.constructor.call(this, config);
415 this.el = Roo.get(config.el ? config.el : document.body );
416 if (this.cls && this.cls.length) {
417 Roo.get(document.body).addClass(this.cls);
421 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
423 is_body : true,// just to make sure it's constructed?
428 onRender : function(ct, position)
430 /* Roo.log("Roo.bootstrap.Body - onRender");
431 if (this.cls && this.cls.length) {
432 Roo.get(document.body).addClass(this.cls);
451 * @class Roo.bootstrap.ButtonGroup
452 * @extends Roo.bootstrap.Component
453 * Bootstrap ButtonGroup class
454 * @cfg {String} size lg | sm | xs (default empty normal)
455 * @cfg {String} align vertical | justified (default none)
456 * @cfg {String} direction up | down (default down)
457 * @cfg {Boolean} toolbar false | true
458 * @cfg {Boolean} btn true | false
463 * @param {Object} config The config object
466 Roo.bootstrap.ButtonGroup = function(config){
467 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
470 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
478 getAutoCreate : function(){
484 cfg.html = this.html || cfg.html;
495 if (['vertical','justified'].indexOf(this.align)!==-1) {
496 cfg.cls = 'btn-group-' + this.align;
498 if (this.align == 'justified') {
499 console.log(this.items);
503 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
504 cfg.cls += ' btn-group-' + this.size;
507 if (this.direction == 'up') {
508 cfg.cls += ' dropup' ;
524 * @class Roo.bootstrap.Button
525 * @extends Roo.bootstrap.Component
526 * Bootstrap Button class
527 * @cfg {String} html The button content
528 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
529 * @cfg {String} size ( lg | sm | xs)
530 * @cfg {String} tag ( a | input | submit)
531 * @cfg {String} href empty or href
532 * @cfg {Boolean} disabled default false;
533 * @cfg {Boolean} isClose default false;
534 * @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)
535 * @cfg {String} badge text for badge
536 * @cfg {String} theme default
537 * @cfg {Boolean} inverse
538 * @cfg {Boolean} toggle
539 * @cfg {String} ontext text for on toggle state
540 * @cfg {String} offtext text for off toggle state
541 * @cfg {Boolean} defaulton
542 * @cfg {Boolean} preventDefault default true
543 * @cfg {Boolean} removeClass remove the standard class..
544 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
547 * Create a new button
548 * @param {Object} config The config object
552 Roo.bootstrap.Button = function(config){
553 Roo.bootstrap.Button.superclass.constructor.call(this, config);
554 this.weightClass = ["btn-default",
566 * When a butotn is pressed
567 * @param {Roo.bootstrap.Button} this
568 * @param {Roo.EventObject} e
573 * After the button has been toggles
574 * @param {Roo.EventObject} e
575 * @param {boolean} pressed (also available as button.pressed)
581 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
599 preventDefault: true,
608 getAutoCreate : function(){
616 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
617 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
622 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
624 if (this.toggle == true) {
627 cls: 'slider-frame roo-button',
632 'data-off-text':'OFF',
633 cls: 'slider-button',
639 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
640 cfg.cls += ' '+this.weight;
649 cfg["aria-hidden"] = true;
651 cfg.html = "×";
657 if (this.theme==='default') {
658 cfg.cls = 'btn roo-button';
660 //if (this.parentType != 'Navbar') {
661 this.weight = this.weight.length ? this.weight : 'default';
663 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
665 cfg.cls += ' btn-' + this.weight;
667 } else if (this.theme==='glow') {
670 cfg.cls = 'btn-glow roo-button';
672 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
674 cfg.cls += ' ' + this.weight;
680 this.cls += ' inverse';
685 cfg.cls += ' active';
689 cfg.disabled = 'disabled';
693 Roo.log('changing to ul' );
695 this.glyphicon = 'caret';
698 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
700 //gsRoo.log(this.parentType);
701 if (this.parentType === 'Navbar' && !this.parent().bar) {
702 Roo.log('changing to li?');
711 href : this.href || '#'
714 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
715 cfg.cls += ' dropdown';
722 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
724 if (this.glyphicon) {
725 cfg.html = ' ' + cfg.html;
730 cls: 'glyphicon glyphicon-' + this.glyphicon
740 // cfg.cls='btn roo-button';
744 var value = cfg.html;
749 cls: 'glyphicon glyphicon-' + this.glyphicon,
768 cfg.cls += ' dropdown';
769 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
772 if (cfg.tag !== 'a' && this.href !== '') {
773 throw "Tag must be a to set href.";
774 } else if (this.href.length > 0) {
775 cfg.href = this.href;
778 if(this.removeClass){
783 cfg.target = this.target;
788 initEvents: function() {
789 // Roo.log('init events?');
790 // Roo.log(this.el.dom);
793 if (typeof (this.menu) != 'undefined') {
794 this.menu.parentType = this.xtype;
795 this.menu.triggerEl = this.el;
796 this.addxtype(Roo.apply({}, this.menu));
800 if (this.el.hasClass('roo-button')) {
801 this.el.on('click', this.onClick, this);
803 this.el.select('.roo-button').on('click', this.onClick, this);
806 if(this.removeClass){
807 this.el.on('click', this.onClick, this);
810 this.el.enableDisplayMode();
813 onClick : function(e)
820 Roo.log('button on click ');
821 if(this.preventDefault){
824 if (this.pressed === true || this.pressed === false) {
825 this.pressed = !this.pressed;
826 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
827 this.fireEvent('toggle', this, e, this.pressed);
831 this.fireEvent('click', this, e);
835 * Enables this button
839 this.disabled = false;
840 this.el.removeClass('disabled');
844 * Disable this button
848 this.disabled = true;
849 this.el.addClass('disabled');
852 * sets the active state on/off,
853 * @param {Boolean} state (optional) Force a particular state
855 setActive : function(v) {
857 this.el[v ? 'addClass' : 'removeClass']('active');
860 * toggles the current active state
862 toggleActive : function()
864 var active = this.el.hasClass('active');
865 this.setActive(!active);
869 setText : function(str)
871 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
875 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
886 setWeight : function(str)
888 this.el.removeClass(this.weightClass);
889 this.el.addClass('btn-' + str);
903 * @class Roo.bootstrap.Column
904 * @extends Roo.bootstrap.Component
905 * Bootstrap Column class
906 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
907 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
908 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
909 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
910 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
911 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
912 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
913 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
916 * @cfg {Boolean} hidden (true|false) hide the element
917 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
918 * @cfg {String} fa (ban|check|...) font awesome icon
919 * @cfg {Number} fasize (1|2|....) font awsome size
921 * @cfg {String} icon (info-sign|check|...) glyphicon name
923 * @cfg {String} html content of column.
926 * Create a new Column
927 * @param {Object} config The config object
930 Roo.bootstrap.Column = function(config){
931 Roo.bootstrap.Column.superclass.constructor.call(this, config);
934 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
952 getAutoCreate : function(){
953 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
961 ['xs','sm','md','lg'].map(function(size){
962 //Roo.log( size + ':' + settings[size]);
964 if (settings[size+'off'] !== false) {
965 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
968 if (settings[size] === false) {
972 if (!settings[size]) { // 0 = hidden
973 cfg.cls += ' hidden-' + size;
976 cfg.cls += ' col-' + size + '-' + settings[size];
981 cfg.cls += ' hidden';
984 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
985 cfg.cls +=' alert alert-' + this.alert;
989 if (this.html.length) {
990 cfg.html = this.html;
994 if (this.fasize > 1) {
995 fasize = ' fa-' + this.fasize + 'x';
997 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1002 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1021 * @class Roo.bootstrap.Container
1022 * @extends Roo.bootstrap.Component
1023 * Bootstrap Container class
1024 * @cfg {Boolean} jumbotron is it a jumbotron element
1025 * @cfg {String} html content of element
1026 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1027 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1028 * @cfg {String} header content of header (for panel)
1029 * @cfg {String} footer content of footer (for panel)
1030 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1031 * @cfg {String} tag (header|aside|section) type of HTML tag.
1032 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1033 * @cfg {String} fa font awesome icon
1034 * @cfg {String} icon (info-sign|check|...) glyphicon name
1035 * @cfg {Boolean} hidden (true|false) hide the element
1036 * @cfg {Boolean} expandable (true|false) default false
1037 * @cfg {Boolean} expanded (true|false) default true
1038 * @cfg {String} rheader contet on the right of header
1039 * @cfg {Boolean} clickable (true|false) default false
1043 * Create a new Container
1044 * @param {Object} config The config object
1047 Roo.bootstrap.Container = function(config){
1048 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1054 * After the panel has been expand
1056 * @param {Roo.bootstrap.Container} this
1061 * After the panel has been collapsed
1063 * @param {Roo.bootstrap.Container} this
1068 * When a element is chick
1069 * @param {Roo.bootstrap.Container} this
1070 * @param {Roo.EventObject} e
1076 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1094 getChildContainer : function() {
1100 if (this.panel.length) {
1101 return this.el.select('.panel-body',true).first();
1108 getAutoCreate : function(){
1111 tag : this.tag || 'div',
1115 if (this.jumbotron) {
1116 cfg.cls = 'jumbotron';
1121 // - this is applied by the parent..
1123 // cfg.cls = this.cls + '';
1126 if (this.sticky.length) {
1128 var bd = Roo.get(document.body);
1129 if (!bd.hasClass('bootstrap-sticky')) {
1130 bd.addClass('bootstrap-sticky');
1131 Roo.select('html',true).setStyle('height', '100%');
1134 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1138 if (this.well.length) {
1139 switch (this.well) {
1142 cfg.cls +=' well well-' +this.well;
1151 cfg.cls += ' hidden';
1155 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1156 cfg.cls +=' alert alert-' + this.alert;
1161 if (this.panel.length) {
1162 cfg.cls += ' panel panel-' + this.panel;
1164 if (this.header.length) {
1168 if(this.expandable){
1170 cfg.cls = cfg.cls + ' expandable';
1174 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1182 cls : 'panel-title',
1183 html : (this.expandable ? ' ' : '') + this.header
1187 cls: 'panel-header-right',
1193 cls : 'panel-heading',
1194 style : this.expandable ? 'cursor: pointer' : '',
1202 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1207 if (this.footer.length) {
1209 cls : 'panel-footer',
1218 body.html = this.html || cfg.html;
1219 // prefix with the icons..
1221 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1224 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1229 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1230 cfg.cls = 'container';
1236 initEvents: function()
1238 if(this.expandable){
1239 var headerEl = this.headerEl();
1242 headerEl.on('click', this.onToggleClick, this);
1247 this.el.on('click', this.onClick, this);
1252 onToggleClick : function()
1254 var headerEl = this.headerEl();
1270 if(this.fireEvent('expand', this)) {
1272 this.expanded = true;
1274 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1276 this.el.select('.panel-body',true).first().removeClass('hide');
1278 var toggleEl = this.toggleEl();
1284 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1289 collapse : function()
1291 if(this.fireEvent('collapse', this)) {
1293 this.expanded = false;
1295 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1296 this.el.select('.panel-body',true).first().addClass('hide');
1298 var toggleEl = this.toggleEl();
1304 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1308 toggleEl : function()
1310 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1314 return this.el.select('.panel-heading .fa',true).first();
1317 headerEl : function()
1319 if(!this.el || !this.panel.length || !this.header.length){
1323 return this.el.select('.panel-heading',true).first()
1328 if(!this.el || !this.panel.length){
1332 return this.el.select('.panel-body',true).first()
1335 titleEl : function()
1337 if(!this.el || !this.panel.length || !this.header.length){
1341 return this.el.select('.panel-title',true).first();
1344 setTitle : function(v)
1346 var titleEl = this.titleEl();
1352 titleEl.dom.innerHTML = v;
1355 getTitle : function()
1358 var titleEl = this.titleEl();
1364 return titleEl.dom.innerHTML;
1367 setRightTitle : function(v)
1369 var t = this.el.select('.panel-header-right',true).first();
1375 t.dom.innerHTML = v;
1378 onClick : function(e)
1382 this.fireEvent('click', this, e);
1385 allChildren : function()
1387 var r=new Roo.util.MixedCollection(false, function(o){
1388 return o.id || (o.id = Roo.id());
1390 var iter = function(el) {
1397 Roo.each(el.items,function(e) {
1406 checkEmpty : function()
1408 var items = this.allChildren();
1411 items.each(function(f){
1412 if(f.el.isVisible()) {
1431 * @class Roo.bootstrap.Img
1432 * @extends Roo.bootstrap.Component
1433 * Bootstrap Img class
1434 * @cfg {Boolean} imgResponsive false | true
1435 * @cfg {String} border rounded | circle | thumbnail
1436 * @cfg {String} src image source
1437 * @cfg {String} alt image alternative text
1438 * @cfg {String} href a tag href
1439 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1440 * @cfg {String} xsUrl xs image source
1441 * @cfg {String} smUrl sm image source
1442 * @cfg {String} mdUrl md image source
1443 * @cfg {String} lgUrl lg image source
1446 * Create a new Input
1447 * @param {Object} config The config object
1450 Roo.bootstrap.Img = function(config){
1451 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1457 * The img click event for the img.
1458 * @param {Roo.EventObject} e
1464 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1466 imgResponsive: true,
1476 getAutoCreate : function()
1478 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1479 return this.createSingleImg();
1484 cls: 'roo-image-responsive-group',
1489 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1491 if(!_this[size + 'Url']){
1497 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1498 html: _this.html || cfg.html,
1499 src: _this[size + 'Url']
1502 img.cls += ' roo-image-responsive-' + size;
1504 var s = ['xs', 'sm', 'md', 'lg'];
1506 s.splice(s.indexOf(size), 1);
1508 Roo.each(s, function(ss){
1509 img.cls += ' hidden-' + ss;
1512 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1513 cfg.cls += ' img-' + _this.border;
1517 cfg.alt = _this.alt;
1530 a.target = _this.target;
1534 cfg.cn.push((_this.href) ? a : img);
1541 createSingleImg : function()
1545 cls: (this.imgResponsive) ? 'img-responsive' : '',
1547 src : 'about:blank' // just incase src get's set to undefined?!?
1550 cfg.html = this.html || cfg.html;
1552 cfg.src = this.src || cfg.src;
1554 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1555 cfg.cls += ' img-' + this.border;
1572 a.target = this.target;
1577 return (this.href) ? a : cfg;
1580 initEvents: function()
1583 this.el.on('click', this.onClick, this);
1588 onClick : function(e)
1590 Roo.log('img onclick');
1591 this.fireEvent('click', this, e);
1594 * Sets the url of the image - used to update it
1595 * @param {String} url the url of the image
1598 setSrc : function(url)
1602 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1603 this.el.dom.src = url;
1607 this.el.select('img', true).first().dom.src = url;
1623 * @class Roo.bootstrap.Link
1624 * @extends Roo.bootstrap.Component
1625 * Bootstrap Link Class
1626 * @cfg {String} alt image alternative text
1627 * @cfg {String} href a tag href
1628 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1629 * @cfg {String} html the content of the link.
1630 * @cfg {String} anchor name for the anchor link
1631 * @cfg {String} fa - favicon
1633 * @cfg {Boolean} preventDefault (true | false) default false
1637 * Create a new Input
1638 * @param {Object} config The config object
1641 Roo.bootstrap.Link = function(config){
1642 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1648 * The img click event for the img.
1649 * @param {Roo.EventObject} e
1655 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1659 preventDefault: false,
1665 getAutoCreate : function()
1667 var html = this.html || '';
1669 if (this.fa !== false) {
1670 html = '<i class="fa fa-' + this.fa + '"></i>';
1675 // anchor's do not require html/href...
1676 if (this.anchor === false) {
1678 cfg.href = this.href || '#';
1680 cfg.name = this.anchor;
1681 if (this.html !== false || this.fa !== false) {
1684 if (this.href !== false) {
1685 cfg.href = this.href;
1689 if(this.alt !== false){
1694 if(this.target !== false) {
1695 cfg.target = this.target;
1701 initEvents: function() {
1703 if(!this.href || this.preventDefault){
1704 this.el.on('click', this.onClick, this);
1708 onClick : function(e)
1710 if(this.preventDefault){
1713 //Roo.log('img onclick');
1714 this.fireEvent('click', this, e);
1727 * @class Roo.bootstrap.Header
1728 * @extends Roo.bootstrap.Component
1729 * Bootstrap Header class
1730 * @cfg {String} html content of header
1731 * @cfg {Number} level (1|2|3|4|5|6) default 1
1734 * Create a new Header
1735 * @param {Object} config The config object
1739 Roo.bootstrap.Header = function(config){
1740 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1743 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1751 getAutoCreate : function(){
1756 tag: 'h' + (1 *this.level),
1757 html: this.html || ''
1769 * Ext JS Library 1.1.1
1770 * Copyright(c) 2006-2007, Ext JS, LLC.
1772 * Originally Released Under LGPL - original licence link has changed is not relivant.
1775 * <script type="text/javascript">
1779 * @class Roo.bootstrap.MenuMgr
1780 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1783 Roo.bootstrap.MenuMgr = function(){
1784 var menus, active, groups = {}, attached = false, lastShow = new Date();
1786 // private - called when first menu is created
1789 active = new Roo.util.MixedCollection();
1790 Roo.get(document).addKeyListener(27, function(){
1791 if(active.length > 0){
1799 if(active && active.length > 0){
1800 var c = active.clone();
1810 if(active.length < 1){
1811 Roo.get(document).un("mouseup", onMouseDown);
1819 var last = active.last();
1820 lastShow = new Date();
1823 Roo.get(document).on("mouseup", onMouseDown);
1828 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1829 m.parentMenu.activeChild = m;
1830 }else if(last && last.isVisible()){
1831 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1836 function onBeforeHide(m){
1838 m.activeChild.hide();
1840 if(m.autoHideTimer){
1841 clearTimeout(m.autoHideTimer);
1842 delete m.autoHideTimer;
1847 function onBeforeShow(m){
1848 var pm = m.parentMenu;
1849 if(!pm && !m.allowOtherMenus){
1851 }else if(pm && pm.activeChild && active != m){
1852 pm.activeChild.hide();
1856 // private this should really trigger on mouseup..
1857 function onMouseDown(e){
1858 Roo.log("on Mouse Up");
1860 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1861 Roo.log("MenuManager hideAll");
1870 function onBeforeCheck(mi, state){
1872 var g = groups[mi.group];
1873 for(var i = 0, l = g.length; i < l; i++){
1875 g[i].setChecked(false);
1884 * Hides all menus that are currently visible
1886 hideAll : function(){
1891 register : function(menu){
1895 menus[menu.id] = menu;
1896 menu.on("beforehide", onBeforeHide);
1897 menu.on("hide", onHide);
1898 menu.on("beforeshow", onBeforeShow);
1899 menu.on("show", onShow);
1901 if(g && menu.events["checkchange"]){
1905 groups[g].push(menu);
1906 menu.on("checkchange", onCheck);
1911 * Returns a {@link Roo.menu.Menu} object
1912 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1913 * be used to generate and return a new Menu instance.
1915 get : function(menu){
1916 if(typeof menu == "string"){ // menu id
1918 }else if(menu.events){ // menu instance
1921 /*else if(typeof menu.length == 'number'){ // array of menu items?
1922 return new Roo.bootstrap.Menu({items:menu});
1923 }else{ // otherwise, must be a config
1924 return new Roo.bootstrap.Menu(menu);
1931 unregister : function(menu){
1932 delete menus[menu.id];
1933 menu.un("beforehide", onBeforeHide);
1934 menu.un("hide", onHide);
1935 menu.un("beforeshow", onBeforeShow);
1936 menu.un("show", onShow);
1938 if(g && menu.events["checkchange"]){
1939 groups[g].remove(menu);
1940 menu.un("checkchange", onCheck);
1945 registerCheckable : function(menuItem){
1946 var g = menuItem.group;
1951 groups[g].push(menuItem);
1952 menuItem.on("beforecheckchange", onBeforeCheck);
1957 unregisterCheckable : function(menuItem){
1958 var g = menuItem.group;
1960 groups[g].remove(menuItem);
1961 menuItem.un("beforecheckchange", onBeforeCheck);
1973 * @class Roo.bootstrap.Menu
1974 * @extends Roo.bootstrap.Component
1975 * Bootstrap Menu class - container for MenuItems
1976 * @cfg {String} type (dropdown|treeview|submenu) type of menu
1977 * @cfg {bool} hidden if the menu should be hidden when rendered.
1978 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
1979 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
1983 * @param {Object} config The config object
1987 Roo.bootstrap.Menu = function(config){
1988 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
1989 if (this.registerMenu && this.type != 'treeview') {
1990 Roo.bootstrap.MenuMgr.register(this);
1995 * Fires before this menu is displayed
1996 * @param {Roo.menu.Menu} this
2001 * Fires before this menu is hidden
2002 * @param {Roo.menu.Menu} this
2007 * Fires after this menu is displayed
2008 * @param {Roo.menu.Menu} this
2013 * Fires after this menu is hidden
2014 * @param {Roo.menu.Menu} this
2019 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2020 * @param {Roo.menu.Menu} this
2021 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2022 * @param {Roo.EventObject} e
2027 * Fires when the mouse is hovering over this menu
2028 * @param {Roo.menu.Menu} this
2029 * @param {Roo.EventObject} e
2030 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2035 * Fires when the mouse exits this menu
2036 * @param {Roo.menu.Menu} this
2037 * @param {Roo.EventObject} e
2038 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2043 * Fires when a menu item contained in this menu is clicked
2044 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2045 * @param {Roo.EventObject} e
2049 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2052 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2056 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2059 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2061 registerMenu : true,
2063 menuItems :false, // stores the menu items..
2073 getChildContainer : function() {
2077 getAutoCreate : function(){
2079 //if (['right'].indexOf(this.align)!==-1) {
2080 // cfg.cn[1].cls += ' pull-right'
2086 cls : 'dropdown-menu' ,
2087 style : 'z-index:1000'
2091 if (this.type === 'submenu') {
2092 cfg.cls = 'submenu active';
2094 if (this.type === 'treeview') {
2095 cfg.cls = 'treeview-menu';
2100 initEvents : function() {
2102 // Roo.log("ADD event");
2103 // Roo.log(this.triggerEl.dom);
2105 this.triggerEl.on('click', this.onTriggerClick, this);
2107 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2109 this.triggerEl.addClass('dropdown-toggle');
2112 this.el.on('touchstart' , this.onTouch, this);
2114 this.el.on('click' , this.onClick, this);
2116 this.el.on("mouseover", this.onMouseOver, this);
2117 this.el.on("mouseout", this.onMouseOut, this);
2121 findTargetItem : function(e)
2123 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2127 //Roo.log(t); Roo.log(t.id);
2129 //Roo.log(this.menuitems);
2130 return this.menuitems.get(t.id);
2132 //return this.items.get(t.menuItemId);
2138 onTouch : function(e)
2140 Roo.log("menu.onTouch");
2141 //e.stopEvent(); this make the user popdown broken
2145 onClick : function(e)
2147 Roo.log("menu.onClick");
2149 var t = this.findTargetItem(e);
2150 if(!t || t.isContainer){
2155 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2156 if(t == this.activeItem && t.shouldDeactivate(e)){
2157 this.activeItem.deactivate();
2158 delete this.activeItem;
2162 this.setActiveItem(t, true);
2170 Roo.log('pass click event');
2174 this.fireEvent("click", this, t, e);
2178 if(!t.href.length || t.href == '#'){
2179 (function() { _this.hide(); }).defer(100);
2184 onMouseOver : function(e){
2185 var t = this.findTargetItem(e);
2188 // if(t.canActivate && !t.disabled){
2189 // this.setActiveItem(t, true);
2193 this.fireEvent("mouseover", this, e, t);
2195 isVisible : function(){
2196 return !this.hidden;
2198 onMouseOut : function(e){
2199 var t = this.findTargetItem(e);
2202 // if(t == this.activeItem && t.shouldDeactivate(e)){
2203 // this.activeItem.deactivate();
2204 // delete this.activeItem;
2207 this.fireEvent("mouseout", this, e, t);
2212 * Displays this menu relative to another element
2213 * @param {String/HTMLElement/Roo.Element} element The element to align to
2214 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2215 * the element (defaults to this.defaultAlign)
2216 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2218 show : function(el, pos, parentMenu){
2219 this.parentMenu = parentMenu;
2223 this.fireEvent("beforeshow", this);
2224 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2227 * Displays this menu at a specific xy position
2228 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2229 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2231 showAt : function(xy, parentMenu, /* private: */_e){
2232 this.parentMenu = parentMenu;
2237 this.fireEvent("beforeshow", this);
2238 //xy = this.el.adjustForConstraints(xy);
2242 this.hideMenuItems();
2243 this.hidden = false;
2244 this.triggerEl.addClass('open');
2246 if(this.el.getWidth() + xy[0] > Roo.lib.Dom.getViewWidth()){
2247 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2250 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2255 this.fireEvent("show", this);
2261 this.doFocus.defer(50, this);
2265 doFocus : function(){
2267 this.focusEl.focus();
2272 * Hides this menu and optionally all parent menus
2273 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2275 hide : function(deep)
2278 this.hideMenuItems();
2279 if(this.el && this.isVisible()){
2280 this.fireEvent("beforehide", this);
2281 if(this.activeItem){
2282 this.activeItem.deactivate();
2283 this.activeItem = null;
2285 this.triggerEl.removeClass('open');;
2287 this.fireEvent("hide", this);
2289 if(deep === true && this.parentMenu){
2290 this.parentMenu.hide(true);
2294 onTriggerClick : function(e)
2296 Roo.log('trigger click');
2298 var target = e.getTarget();
2300 Roo.log(target.nodeName.toLowerCase());
2302 if(target.nodeName.toLowerCase() === 'i'){
2308 onTriggerPress : function(e)
2310 Roo.log('trigger press');
2311 //Roo.log(e.getTarget());
2312 // Roo.log(this.triggerEl.dom);
2314 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2315 var pel = Roo.get(e.getTarget());
2316 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2317 Roo.log('is treeview or dropdown?');
2321 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2325 if (this.isVisible()) {
2330 this.show(this.triggerEl, false, false);
2333 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2340 hideMenuItems : function()
2342 Roo.log("hide Menu Items");
2346 //$(backdrop).remove()
2347 this.el.select('.open',true).each(function(aa) {
2349 aa.removeClass('open');
2350 //var parent = getParent($(this))
2351 //var relatedTarget = { relatedTarget: this }
2353 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2354 //if (e.isDefaultPrevented()) return
2355 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2358 addxtypeChild : function (tree, cntr) {
2359 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2361 this.menuitems.add(comp);
2373 this.getEl().dom.innerHTML = '';
2374 this.menuitems.clear();
2388 * @class Roo.bootstrap.MenuItem
2389 * @extends Roo.bootstrap.Component
2390 * Bootstrap MenuItem class
2391 * @cfg {String} html the menu label
2392 * @cfg {String} href the link
2393 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2394 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2395 * @cfg {Boolean} active used on sidebars to highlight active itesm
2396 * @cfg {String} fa favicon to show on left of menu item.
2397 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2401 * Create a new MenuItem
2402 * @param {Object} config The config object
2406 Roo.bootstrap.MenuItem = function(config){
2407 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2412 * The raw click event for the entire grid.
2413 * @param {Roo.bootstrap.MenuItem} this
2414 * @param {Roo.EventObject} e
2420 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2424 preventDefault: false,
2425 isContainer : false,
2429 getAutoCreate : function(){
2431 if(this.isContainer){
2434 cls: 'dropdown-menu-item'
2448 if (this.fa !== false) {
2451 cls : 'fa fa-' + this.fa
2460 cls: 'dropdown-menu-item',
2463 if (this.parent().type == 'treeview') {
2464 cfg.cls = 'treeview-menu';
2467 cfg.cls += ' active';
2472 anc.href = this.href || cfg.cn[0].href ;
2473 ctag.html = this.html || cfg.cn[0].html ;
2477 initEvents: function()
2479 if (this.parent().type == 'treeview') {
2480 this.el.select('a').on('click', this.onClick, this);
2484 this.menu.parentType = this.xtype;
2485 this.menu.triggerEl = this.el;
2486 this.menu = this.addxtype(Roo.apply({}, this.menu));
2490 onClick : function(e)
2492 Roo.log('item on click ');
2494 if(this.preventDefault){
2497 //this.parent().hideMenuItems();
2499 this.fireEvent('click', this, e);
2518 * @class Roo.bootstrap.MenuSeparator
2519 * @extends Roo.bootstrap.Component
2520 * Bootstrap MenuSeparator class
2523 * Create a new MenuItem
2524 * @param {Object} config The config object
2528 Roo.bootstrap.MenuSeparator = function(config){
2529 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2532 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2534 getAutoCreate : function(){
2553 * @class Roo.bootstrap.Modal
2554 * @extends Roo.bootstrap.Component
2555 * Bootstrap Modal class
2556 * @cfg {String} title Title of dialog
2557 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2558 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2559 * @cfg {Boolean} specificTitle default false
2560 * @cfg {Array} buttons Array of buttons or standard button set..
2561 * @cfg {String} buttonPosition (left|right|center) default right
2562 * @cfg {Boolean} animate default true
2563 * @cfg {Boolean} allow_close default true
2564 * @cfg {Boolean} fitwindow default false
2565 * @cfg {String} size (sm|lg) default empty
2569 * Create a new Modal Dialog
2570 * @param {Object} config The config object
2573 Roo.bootstrap.Modal = function(config){
2574 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2579 * The raw btnclick event for the button
2580 * @param {Roo.EventObject} e
2585 * Fire when dialog resize
2586 * @param {Roo.bootstrap.Modal} this
2587 * @param {Roo.EventObject} e
2591 this.buttons = this.buttons || [];
2594 this.tmpl = Roo.factory(this.tmpl);
2599 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2601 title : 'test dialog',
2611 specificTitle: false,
2613 buttonPosition: 'right',
2632 onRender : function(ct, position)
2634 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2637 var cfg = Roo.apply({}, this.getAutoCreate());
2640 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2642 //if (!cfg.name.length) {
2646 cfg.cls += ' ' + this.cls;
2649 cfg.style = this.style;
2651 this.el = Roo.get(document.body).createChild(cfg, position);
2653 //var type = this.el.dom.type;
2656 if(this.tabIndex !== undefined){
2657 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2660 this.dialogEl = this.el.select('.modal-dialog',true).first();
2661 this.bodyEl = this.el.select('.modal-body',true).first();
2662 this.closeEl = this.el.select('.modal-header .close', true).first();
2663 this.headerEl = this.el.select('.modal-header',true).first();
2664 this.titleEl = this.el.select('.modal-title',true).first();
2665 this.footerEl = this.el.select('.modal-footer',true).first();
2667 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2668 this.maskEl.enableDisplayMode("block");
2670 //this.el.addClass("x-dlg-modal");
2672 if (this.buttons.length) {
2673 Roo.each(this.buttons, function(bb) {
2674 var b = Roo.apply({}, bb);
2675 b.xns = b.xns || Roo.bootstrap;
2676 b.xtype = b.xtype || 'Button';
2677 if (typeof(b.listeners) == 'undefined') {
2678 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2681 var btn = Roo.factory(b);
2683 btn.render(this.el.select('.modal-footer div').first());
2687 // render the children.
2690 if(typeof(this.items) != 'undefined'){
2691 var items = this.items;
2694 for(var i =0;i < items.length;i++) {
2695 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2699 this.items = nitems;
2701 // where are these used - they used to be body/close/footer
2705 //this.el.addClass([this.fieldClass, this.cls]);
2709 getAutoCreate : function(){
2714 html : this.html || ''
2719 cls : 'modal-title',
2723 if(this.specificTitle){
2729 if (this.allow_close) {
2741 if(this.size.length){
2742 size = 'modal-' + this.size;
2747 style : 'display: none',
2750 cls: "modal-dialog " + size,
2753 cls : "modal-content",
2756 cls : 'modal-header',
2761 cls : 'modal-footer',
2765 cls: 'btn-' + this.buttonPosition
2782 modal.cls += ' fade';
2788 getChildContainer : function() {
2793 getButtonContainer : function() {
2794 return this.el.select('.modal-footer div',true).first();
2797 initEvents : function()
2799 if (this.allow_close) {
2800 this.closeEl.on('click', this.hide, this);
2802 Roo.EventManager.onWindowResize(this.resize, this, true);
2809 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2810 if (this.fitwindow) {
2811 var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
2812 var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
2817 setSize : function(w,h)
2827 if (!this.rendered) {
2831 this.el.setStyle('display', 'block');
2833 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2836 this.el.addClass('in');
2839 this.el.addClass('in');
2843 // not sure how we can show data in here..
2845 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2848 Roo.get(document.body).addClass("x-body-masked");
2850 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2851 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2856 this.fireEvent('show', this);
2858 // set zindex here - otherwise it appears to be ignored...
2859 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2862 this.items.forEach( function(e) {
2863 e.layout ? e.layout() : false;
2871 if(this.fireEvent("beforehide", this) !== false){
2873 Roo.get(document.body).removeClass("x-body-masked");
2874 this.el.removeClass('in');
2875 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2877 if(this.animate){ // why
2879 (function(){ _this.el.setStyle('display', 'none'); }).defer(150);
2881 this.el.setStyle('display', 'none');
2883 this.fireEvent('hide', this);
2887 addButton : function(str, cb)
2891 var b = Roo.apply({}, { html : str } );
2892 b.xns = b.xns || Roo.bootstrap;
2893 b.xtype = b.xtype || 'Button';
2894 if (typeof(b.listeners) == 'undefined') {
2895 b.listeners = { click : cb.createDelegate(this) };
2898 var btn = Roo.factory(b);
2900 btn.render(this.el.select('.modal-footer div').first());
2906 setDefaultButton : function(btn)
2908 //this.el.select('.modal-footer').()
2912 resizeTo: function(w,h)
2916 this.dialogEl.setWidth(w);
2917 if (this.diff === false) {
2918 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
2921 this.bodyEl.setHeight(h-this.diff);
2923 this.fireEvent('resize', this);
2926 setContentSize : function(w, h)
2930 onButtonClick: function(btn,e)
2933 this.fireEvent('btnclick', btn.name, e);
2936 * Set the title of the Dialog
2937 * @param {String} str new Title
2939 setTitle: function(str) {
2940 this.titleEl.dom.innerHTML = str;
2943 * Set the body of the Dialog
2944 * @param {String} str new Title
2946 setBody: function(str) {
2947 this.bodyEl.dom.innerHTML = str;
2950 * Set the body of the Dialog using the template
2951 * @param {Obj} data - apply this data to the template and replace the body contents.
2953 applyBody: function(obj)
2956 Roo.log("Error - using apply Body without a template");
2959 this.tmpl.overwrite(this.bodyEl, obj);
2965 Roo.apply(Roo.bootstrap.Modal, {
2967 * Button config that displays a single OK button
2976 * Button config that displays Yes and No buttons
2992 * Button config that displays OK and Cancel buttons
3007 * Button config that displays Yes, No and Cancel buttons
3031 * messagebox - can be used as a replace
3035 * @class Roo.MessageBox
3036 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3040 Roo.Msg.alert('Status', 'Changes saved successfully.');
3042 // Prompt for user data:
3043 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3045 // process text value...
3049 // Show a dialog using config options:
3051 title:'Save Changes?',
3052 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3053 buttons: Roo.Msg.YESNOCANCEL,
3060 Roo.bootstrap.MessageBox = function(){
3061 var dlg, opt, mask, waitTimer;
3062 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3063 var buttons, activeTextEl, bwidth;
3067 var handleButton = function(button){
3069 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3073 var handleHide = function(){
3075 dlg.el.removeClass(opt.cls);
3078 // Roo.TaskMgr.stop(waitTimer);
3079 // waitTimer = null;
3084 var updateButtons = function(b){
3087 buttons["ok"].hide();
3088 buttons["cancel"].hide();
3089 buttons["yes"].hide();
3090 buttons["no"].hide();
3091 //dlg.footer.dom.style.display = 'none';
3094 dlg.footerEl.dom.style.display = '';
3095 for(var k in buttons){
3096 if(typeof buttons[k] != "function"){
3099 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3100 width += buttons[k].el.getWidth()+15;
3110 var handleEsc = function(d, k, e){
3111 if(opt && opt.closable !== false){
3121 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3122 * @return {Roo.BasicDialog} The BasicDialog element
3124 getDialog : function(){
3126 dlg = new Roo.bootstrap.Modal( {
3129 //constraintoviewport:false,
3131 //collapsible : false,
3136 //buttonAlign:"center",
3137 closeClick : function(){
3138 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3141 handleButton("cancel");
3146 dlg.on("hide", handleHide);
3148 //dlg.addKeyListener(27, handleEsc);
3150 this.buttons = buttons;
3151 var bt = this.buttonText;
3152 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3153 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3154 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3155 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3157 bodyEl = dlg.bodyEl.createChild({
3159 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3160 '<textarea class="roo-mb-textarea"></textarea>' +
3161 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3163 msgEl = bodyEl.dom.firstChild;
3164 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3165 textboxEl.enableDisplayMode();
3166 textboxEl.addKeyListener([10,13], function(){
3167 if(dlg.isVisible() && opt && opt.buttons){
3170 }else if(opt.buttons.yes){
3171 handleButton("yes");
3175 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3176 textareaEl.enableDisplayMode();
3177 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3178 progressEl.enableDisplayMode();
3180 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3181 var pf = progressEl.dom.firstChild;
3183 pp = Roo.get(pf.firstChild);
3184 pp.setHeight(pf.offsetHeight);
3192 * Updates the message box body text
3193 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3194 * the XHTML-compliant non-breaking space character '&#160;')
3195 * @return {Roo.MessageBox} This message box
3197 updateText : function(text)
3199 if(!dlg.isVisible() && !opt.width){
3200 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3201 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3203 msgEl.innerHTML = text || ' ';
3205 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3206 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3208 Math.min(opt.width || cw , this.maxWidth),
3209 Math.max(opt.minWidth || this.minWidth, bwidth)
3212 activeTextEl.setWidth(w);
3214 if(dlg.isVisible()){
3215 dlg.fixedcenter = false;
3217 // to big, make it scroll. = But as usual stupid IE does not support
3220 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3221 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3222 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3224 bodyEl.dom.style.height = '';
3225 bodyEl.dom.style.overflowY = '';
3228 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3230 bodyEl.dom.style.overflowX = '';
3233 dlg.setContentSize(w, bodyEl.getHeight());
3234 if(dlg.isVisible()){
3235 dlg.fixedcenter = true;
3241 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3242 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3243 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3244 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3245 * @return {Roo.MessageBox} This message box
3247 updateProgress : function(value, text){
3249 this.updateText(text);
3252 if (pp) { // weird bug on my firefox - for some reason this is not defined
3253 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3254 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3260 * Returns true if the message box is currently displayed
3261 * @return {Boolean} True if the message box is visible, else false
3263 isVisible : function(){
3264 return dlg && dlg.isVisible();
3268 * Hides the message box if it is displayed
3271 if(this.isVisible()){
3277 * Displays a new message box, or reinitializes an existing message box, based on the config options
3278 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3279 * The following config object properties are supported:
3281 Property Type Description
3282 ---------- --------------- ------------------------------------------------------------------------------------
3283 animEl String/Element An id or Element from which the message box should animate as it opens and
3284 closes (defaults to undefined)
3285 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3286 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3287 closable Boolean False to hide the top-right close button (defaults to true). Note that
3288 progress and wait dialogs will ignore this property and always hide the
3289 close button as they can only be closed programmatically.
3290 cls String A custom CSS class to apply to the message box element
3291 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3292 displayed (defaults to 75)
3293 fn Function A callback function to execute after closing the dialog. The arguments to the
3294 function will be btn (the name of the button that was clicked, if applicable,
3295 e.g. "ok"), and text (the value of the active text field, if applicable).
3296 Progress and wait dialogs will ignore this option since they do not respond to
3297 user actions and can only be closed programmatically, so any required function
3298 should be called by the same code after it closes the dialog.
3299 icon String A CSS class that provides a background image to be used as an icon for
3300 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3301 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3302 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3303 modal Boolean False to allow user interaction with the page while the message box is
3304 displayed (defaults to true)
3305 msg String A string that will replace the existing message box body text (defaults
3306 to the XHTML-compliant non-breaking space character ' ')
3307 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3308 progress Boolean True to display a progress bar (defaults to false)
3309 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3310 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3311 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3312 title String The title text
3313 value String The string value to set into the active textbox element if displayed
3314 wait Boolean True to display a progress bar (defaults to false)
3315 width Number The width of the dialog in pixels
3322 msg: 'Please enter your address:',
3324 buttons: Roo.MessageBox.OKCANCEL,
3327 animEl: 'addAddressBtn'
3330 * @param {Object} config Configuration options
3331 * @return {Roo.MessageBox} This message box
3333 show : function(options)
3336 // this causes nightmares if you show one dialog after another
3337 // especially on callbacks..
3339 if(this.isVisible()){
3342 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3343 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3344 Roo.log("New Dialog Message:" + options.msg )
3345 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3346 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3349 var d = this.getDialog();
3351 d.setTitle(opt.title || " ");
3352 d.closeEl.setDisplayed(opt.closable !== false);
3353 activeTextEl = textboxEl;
3354 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3359 textareaEl.setHeight(typeof opt.multiline == "number" ?
3360 opt.multiline : this.defaultTextHeight);
3361 activeTextEl = textareaEl;
3370 progressEl.setDisplayed(opt.progress === true);
3371 this.updateProgress(0);
3372 activeTextEl.dom.value = opt.value || "";
3374 dlg.setDefaultButton(activeTextEl);
3376 var bs = opt.buttons;
3380 }else if(bs && bs.yes){
3381 db = buttons["yes"];
3383 dlg.setDefaultButton(db);
3385 bwidth = updateButtons(opt.buttons);
3386 this.updateText(opt.msg);
3388 d.el.addClass(opt.cls);
3390 d.proxyDrag = opt.proxyDrag === true;
3391 d.modal = opt.modal !== false;
3392 d.mask = opt.modal !== false ? mask : false;
3394 // force it to the end of the z-index stack so it gets a cursor in FF
3395 document.body.appendChild(dlg.el.dom);
3396 d.animateTarget = null;
3397 d.show(options.animEl);
3403 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3404 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3405 * and closing the message box when the process is complete.
3406 * @param {String} title The title bar text
3407 * @param {String} msg The message box body text
3408 * @return {Roo.MessageBox} This message box
3410 progress : function(title, msg){
3417 minWidth: this.minProgressWidth,
3424 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3425 * If a callback function is passed it will be called after the user clicks the button, and the
3426 * id of the button that was clicked will be passed as the only parameter to the callback
3427 * (could also be the top-right close button).
3428 * @param {String} title The title bar text
3429 * @param {String} msg The message box body text
3430 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3431 * @param {Object} scope (optional) The scope of the callback function
3432 * @return {Roo.MessageBox} This message box
3434 alert : function(title, msg, fn, scope)
3449 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3450 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3451 * You are responsible for closing the message box when the process is complete.
3452 * @param {String} msg The message box body text
3453 * @param {String} title (optional) The title bar text
3454 * @return {Roo.MessageBox} This message box
3456 wait : function(msg, title){
3467 waitTimer = Roo.TaskMgr.start({
3469 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3477 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3478 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3479 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3480 * @param {String} title The title bar text
3481 * @param {String} msg The message box body text
3482 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3483 * @param {Object} scope (optional) The scope of the callback function
3484 * @return {Roo.MessageBox} This message box
3486 confirm : function(title, msg, fn, scope){
3490 buttons: this.YESNO,
3499 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3500 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3501 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3502 * (could also be the top-right close button) and the text that was entered will be passed as the two
3503 * parameters to the callback.
3504 * @param {String} title The title bar text
3505 * @param {String} msg The message box body text
3506 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3507 * @param {Object} scope (optional) The scope of the callback function
3508 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3509 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3510 * @return {Roo.MessageBox} This message box
3512 prompt : function(title, msg, fn, scope, multiline){
3516 buttons: this.OKCANCEL,
3521 multiline: multiline,
3528 * Button config that displays a single OK button
3533 * Button config that displays Yes and No buttons
3536 YESNO : {yes:true, no:true},
3538 * Button config that displays OK and Cancel buttons
3541 OKCANCEL : {ok:true, cancel:true},
3543 * Button config that displays Yes, No and Cancel buttons
3546 YESNOCANCEL : {yes:true, no:true, cancel:true},
3549 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3552 defaultTextHeight : 75,
3554 * The maximum width in pixels of the message box (defaults to 600)
3559 * The minimum width in pixels of the message box (defaults to 100)
3564 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3565 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3568 minProgressWidth : 250,
3570 * An object containing the default button text strings that can be overriden for localized language support.
3571 * Supported properties are: ok, cancel, yes and no.
3572 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3585 * Shorthand for {@link Roo.MessageBox}
3587 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3588 Roo.Msg = Roo.Msg || Roo.MessageBox;
3597 * @class Roo.bootstrap.Navbar
3598 * @extends Roo.bootstrap.Component
3599 * Bootstrap Navbar class
3602 * Create a new Navbar
3603 * @param {Object} config The config object
3607 Roo.bootstrap.Navbar = function(config){
3608 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3612 * @event beforetoggle
3613 * Fire before toggle the menu
3614 * @param {Roo.EventObject} e
3616 "beforetoggle" : true
3620 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3629 getAutoCreate : function(){
3632 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3636 initEvents :function ()
3638 //Roo.log(this.el.select('.navbar-toggle',true));
3639 this.el.select('.navbar-toggle',true).on('click', function() {
3640 if(this.fireEvent('beforetoggle', this) !== false){
3641 this.el.select('.navbar-collapse',true).toggleClass('in');
3651 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3653 var size = this.el.getSize();
3654 this.maskEl.setSize(size.width, size.height);
3655 this.maskEl.enableDisplayMode("block");
3664 getChildContainer : function()
3666 if (this.el.select('.collapse').getCount()) {
3667 return this.el.select('.collapse',true).first();
3700 * @class Roo.bootstrap.NavSimplebar
3701 * @extends Roo.bootstrap.Navbar
3702 * Bootstrap Sidebar class
3704 * @cfg {Boolean} inverse is inverted color
3706 * @cfg {String} type (nav | pills | tabs)
3707 * @cfg {Boolean} arrangement stacked | justified
3708 * @cfg {String} align (left | right) alignment
3710 * @cfg {Boolean} main (true|false) main nav bar? default false
3711 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3713 * @cfg {String} tag (header|footer|nav|div) default is nav
3719 * Create a new Sidebar
3720 * @param {Object} config The config object
3724 Roo.bootstrap.NavSimplebar = function(config){
3725 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3728 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3744 getAutoCreate : function(){
3748 tag : this.tag || 'div',
3761 this.type = this.type || 'nav';
3762 if (['tabs','pills'].indexOf(this.type)!==-1) {
3763 cfg.cn[0].cls += ' nav-' + this.type
3767 if (this.type!=='nav') {
3768 Roo.log('nav type must be nav/tabs/pills')
3770 cfg.cn[0].cls += ' navbar-nav'
3776 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3777 cfg.cn[0].cls += ' nav-' + this.arrangement;
3781 if (this.align === 'right') {
3782 cfg.cn[0].cls += ' navbar-right';
3786 cfg.cls += ' navbar-inverse';
3813 * @class Roo.bootstrap.NavHeaderbar
3814 * @extends Roo.bootstrap.NavSimplebar
3815 * Bootstrap Sidebar class
3817 * @cfg {String} brand what is brand
3818 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
3819 * @cfg {String} brand_href href of the brand
3820 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
3821 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
3822 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
3823 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
3826 * Create a new Sidebar
3827 * @param {Object} config The config object
3831 Roo.bootstrap.NavHeaderbar = function(config){
3832 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
3836 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
3843 desktopCenter : false,
3846 getAutoCreate : function(){
3849 tag: this.nav || 'nav',
3856 if (this.desktopCenter) {
3857 cn.push({cls : 'container', cn : []});
3864 cls: 'navbar-header',
3869 cls: 'navbar-toggle',
3870 'data-toggle': 'collapse',
3875 html: 'Toggle navigation'
3897 cls: 'collapse navbar-collapse',
3901 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
3903 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
3904 cfg.cls += ' navbar-' + this.position;
3906 // tag can override this..
3908 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
3911 if (this.brand !== '') {
3914 href: this.brand_href ? this.brand_href : '#',
3915 cls: 'navbar-brand',
3923 cfg.cls += ' main-nav';
3931 getHeaderChildContainer : function()
3933 if (this.srButton && this.el.select('.navbar-header').getCount()) {
3934 return this.el.select('.navbar-header',true).first();
3937 return this.getChildContainer();
3941 initEvents : function()
3943 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
3945 if (this.autohide) {
3950 Roo.get(document).on('scroll',function(e) {
3951 var ns = Roo.get(document).getScroll().top;
3952 var os = prevScroll;
3956 ft.removeClass('slideDown');
3957 ft.addClass('slideUp');
3960 ft.removeClass('slideUp');
3961 ft.addClass('slideDown');
3982 * @class Roo.bootstrap.NavSidebar
3983 * @extends Roo.bootstrap.Navbar
3984 * Bootstrap Sidebar class
3987 * Create a new Sidebar
3988 * @param {Object} config The config object
3992 Roo.bootstrap.NavSidebar = function(config){
3993 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
3996 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
3998 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4000 getAutoCreate : function(){
4005 cls: 'sidebar sidebar-nav'
4027 * @class Roo.bootstrap.NavGroup
4028 * @extends Roo.bootstrap.Component
4029 * Bootstrap NavGroup class
4030 * @cfg {String} align (left|right)
4031 * @cfg {Boolean} inverse
4032 * @cfg {String} type (nav|pills|tab) default nav
4033 * @cfg {String} navId - reference Id for navbar.
4037 * Create a new nav group
4038 * @param {Object} config The config object
4041 Roo.bootstrap.NavGroup = function(config){
4042 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4045 Roo.bootstrap.NavGroup.register(this);
4049 * Fires when the active item changes
4050 * @param {Roo.bootstrap.NavGroup} this
4051 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4052 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4059 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4070 getAutoCreate : function()
4072 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4079 if (['tabs','pills'].indexOf(this.type)!==-1) {
4080 cfg.cls += ' nav-' + this.type
4082 if (this.type!=='nav') {
4083 Roo.log('nav type must be nav/tabs/pills')
4085 cfg.cls += ' navbar-nav'
4088 if (this.parent() && this.parent().sidebar) {
4091 cls: 'dashboard-menu sidebar-menu'
4097 if (this.form === true) {
4103 if (this.align === 'right') {
4104 cfg.cls += ' navbar-right';
4106 cfg.cls += ' navbar-left';
4110 if (this.align === 'right') {
4111 cfg.cls += ' navbar-right';
4115 cfg.cls += ' navbar-inverse';
4123 * sets the active Navigation item
4124 * @param {Roo.bootstrap.NavItem} the new current navitem
4126 setActiveItem : function(item)
4129 Roo.each(this.navItems, function(v){
4134 v.setActive(false, true);
4141 item.setActive(true, true);
4142 this.fireEvent('changed', this, item, prev);
4147 * gets the active Navigation item
4148 * @return {Roo.bootstrap.NavItem} the current navitem
4150 getActive : function()
4154 Roo.each(this.navItems, function(v){
4165 indexOfNav : function()
4169 Roo.each(this.navItems, function(v,i){
4180 * adds a Navigation item
4181 * @param {Roo.bootstrap.NavItem} the navitem to add
4183 addItem : function(cfg)
4185 var cn = new Roo.bootstrap.NavItem(cfg);
4187 cn.parentId = this.id;
4188 cn.onRender(this.el, null);
4192 * register a Navigation item
4193 * @param {Roo.bootstrap.NavItem} the navitem to add
4195 register : function(item)
4197 this.navItems.push( item);
4198 item.navId = this.navId;
4203 * clear all the Navigation item
4206 clearAll : function()
4209 this.el.dom.innerHTML = '';
4212 getNavItem: function(tabId)
4215 Roo.each(this.navItems, function(e) {
4216 if (e.tabId == tabId) {
4226 setActiveNext : function()
4228 var i = this.indexOfNav(this.getActive());
4229 if (i > this.navItems.length) {
4232 this.setActiveItem(this.navItems[i+1]);
4234 setActivePrev : function()
4236 var i = this.indexOfNav(this.getActive());
4240 this.setActiveItem(this.navItems[i-1]);
4242 clearWasActive : function(except) {
4243 Roo.each(this.navItems, function(e) {
4244 if (e.tabId != except.tabId && e.was_active) {
4245 e.was_active = false;
4252 getWasActive : function ()
4255 Roo.each(this.navItems, function(e) {
4270 Roo.apply(Roo.bootstrap.NavGroup, {
4274 * register a Navigation Group
4275 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4277 register : function(navgrp)
4279 this.groups[navgrp.navId] = navgrp;
4283 * fetch a Navigation Group based on the navigation ID
4284 * @param {string} the navgroup to add
4285 * @returns {Roo.bootstrap.NavGroup} the navgroup
4287 get: function(navId) {
4288 if (typeof(this.groups[navId]) == 'undefined') {
4290 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4292 return this.groups[navId] ;
4307 * @class Roo.bootstrap.NavItem
4308 * @extends Roo.bootstrap.Component
4309 * Bootstrap Navbar.NavItem class
4310 * @cfg {String} href link to
4311 * @cfg {String} html content of button
4312 * @cfg {String} badge text inside badge
4313 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4314 * @cfg {String} glyphicon name of glyphicon
4315 * @cfg {String} icon name of font awesome icon
4316 * @cfg {Boolean} active Is item active
4317 * @cfg {Boolean} disabled Is item disabled
4319 * @cfg {Boolean} preventDefault (true | false) default false
4320 * @cfg {String} tabId the tab that this item activates.
4321 * @cfg {String} tagtype (a|span) render as a href or span?
4322 * @cfg {Boolean} animateRef (true|false) link to element default false
4325 * Create a new Navbar Item
4326 * @param {Object} config The config object
4328 Roo.bootstrap.NavItem = function(config){
4329 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4334 * The raw click event for the entire grid.
4335 * @param {Roo.EventObject} e
4340 * Fires when the active item active state changes
4341 * @param {Roo.bootstrap.NavItem} this
4342 * @param {boolean} state the new state
4348 * Fires when scroll to element
4349 * @param {Roo.bootstrap.NavItem} this
4350 * @param {Object} options
4351 * @param {Roo.EventObject} e
4359 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4367 preventDefault : false,
4374 getAutoCreate : function(){
4383 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4385 if (this.disabled) {
4386 cfg.cls += ' disabled';
4389 if (this.href || this.html || this.glyphicon || this.icon) {
4393 href : this.href || "#",
4394 html: this.html || ''
4399 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4402 if(this.glyphicon) {
4403 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4408 cfg.cn[0].html += " <span class='caret'></span>";
4412 if (this.badge !== '') {
4414 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
4422 initEvents: function()
4424 if (typeof (this.menu) != 'undefined') {
4425 this.menu.parentType = this.xtype;
4426 this.menu.triggerEl = this.el;
4427 this.menu = this.addxtype(Roo.apply({}, this.menu));
4430 this.el.select('a',true).on('click', this.onClick, this);
4432 if(this.tagtype == 'span'){
4433 this.el.select('span',true).on('click', this.onClick, this);
4436 // at this point parent should be available..
4437 this.parent().register(this);
4440 onClick : function(e)
4442 if (e.getTarget('.dropdown-menu-item')) {
4443 // did you click on a menu itemm.... - then don't trigger onclick..
4448 this.preventDefault ||
4451 Roo.log("NavItem - prevent Default?");
4455 if (this.disabled) {
4459 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4460 if (tg && tg.transition) {
4461 Roo.log("waiting for the transitionend");
4467 //Roo.log("fire event clicked");
4468 if(this.fireEvent('click', this, e) === false){
4472 if(this.tagtype == 'span'){
4476 //Roo.log(this.href);
4477 var ael = this.el.select('a',true).first();
4480 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4481 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4482 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4483 return; // ignore... - it's a 'hash' to another page.
4485 Roo.log("NavItem - prevent Default?");
4487 this.scrollToElement(e);
4491 var p = this.parent();
4493 if (['tabs','pills'].indexOf(p.type)!==-1) {
4494 if (typeof(p.setActiveItem) !== 'undefined') {
4495 p.setActiveItem(this);
4499 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4500 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4501 // remove the collapsed menu expand...
4502 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4506 isActive: function () {
4509 setActive : function(state, fire, is_was_active)
4511 if (this.active && !state && this.navId) {
4512 this.was_active = true;
4513 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4515 nv.clearWasActive(this);
4519 this.active = state;
4522 this.el.removeClass('active');
4523 } else if (!this.el.hasClass('active')) {
4524 this.el.addClass('active');
4527 this.fireEvent('changed', this, state);
4530 // show a panel if it's registered and related..
4532 if (!this.navId || !this.tabId || !state || is_was_active) {
4536 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4540 var pan = tg.getPanelByName(this.tabId);
4544 // if we can not flip to new panel - go back to old nav highlight..
4545 if (false == tg.showPanel(pan)) {
4546 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4548 var onav = nv.getWasActive();
4550 onav.setActive(true, false, true);
4559 // this should not be here...
4560 setDisabled : function(state)
4562 this.disabled = state;
4564 this.el.removeClass('disabled');
4565 } else if (!this.el.hasClass('disabled')) {
4566 this.el.addClass('disabled');
4572 * Fetch the element to display the tooltip on.
4573 * @return {Roo.Element} defaults to this.el
4575 tooltipEl : function()
4577 return this.el.select('' + this.tagtype + '', true).first();
4580 scrollToElement : function(e)
4582 var c = document.body;
4585 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4587 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4588 c = document.documentElement;
4591 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4597 var o = target.calcOffsetsTo(c);
4604 this.fireEvent('scrollto', this, options, e);
4606 Roo.get(c).scrollTo('top', options.value, true);
4619 * <span> icon </span>
4620 * <span> text </span>
4621 * <span>badge </span>
4625 * @class Roo.bootstrap.NavSidebarItem
4626 * @extends Roo.bootstrap.NavItem
4627 * Bootstrap Navbar.NavSidebarItem class
4628 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4629 * {Boolean} open is the menu open
4630 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4631 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4632 * {String} buttonSize (sm|md|lg)the extra classes for the button
4633 * {Boolean} showArrow show arrow next to the text (default true)
4635 * Create a new Navbar Button
4636 * @param {Object} config The config object
4638 Roo.bootstrap.NavSidebarItem = function(config){
4639 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4644 * The raw click event for the entire grid.
4645 * @param {Roo.EventObject} e
4650 * Fires when the active item active state changes
4651 * @param {Roo.bootstrap.NavSidebarItem} this
4652 * @param {boolean} state the new state
4660 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4662 badgeWeight : 'default',
4668 buttonWeight : 'default',
4674 getAutoCreate : function(){
4679 href : this.href || '#',
4685 if(this.buttonView){
4688 href : this.href || '#',
4689 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4702 cfg.cls += ' active';
4705 if (this.disabled) {
4706 cfg.cls += ' disabled';
4709 cfg.cls += ' open x-open';
4712 if (this.glyphicon || this.icon) {
4713 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4714 a.cn.push({ tag : 'i', cls : c }) ;
4717 if(!this.buttonView){
4720 html : this.html || ''
4727 if (this.badge !== '') {
4728 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4734 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4737 a.cls += ' dropdown-toggle treeview' ;
4743 initEvents : function()
4745 if (typeof (this.menu) != 'undefined') {
4746 this.menu.parentType = this.xtype;
4747 this.menu.triggerEl = this.el;
4748 this.menu = this.addxtype(Roo.apply({}, this.menu));
4751 this.el.on('click', this.onClick, this);
4753 if(this.badge !== ''){
4754 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4759 onClick : function(e)
4766 if(this.preventDefault){
4770 this.fireEvent('click', this);
4773 disable : function()
4775 this.setDisabled(true);
4780 this.setDisabled(false);
4783 setDisabled : function(state)
4785 if(this.disabled == state){
4789 this.disabled = state;
4792 this.el.addClass('disabled');
4796 this.el.removeClass('disabled');
4801 setActive : function(state)
4803 if(this.active == state){
4807 this.active = state;
4810 this.el.addClass('active');
4814 this.el.removeClass('active');
4819 isActive: function ()
4824 setBadge : function(str)
4830 this.badgeEl.dom.innerHTML = str;
4847 * @class Roo.bootstrap.Row
4848 * @extends Roo.bootstrap.Component
4849 * Bootstrap Row class (contains columns...)
4853 * @param {Object} config The config object
4856 Roo.bootstrap.Row = function(config){
4857 Roo.bootstrap.Row.superclass.constructor.call(this, config);
4860 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
4862 getAutoCreate : function(){
4881 * @class Roo.bootstrap.Element
4882 * @extends Roo.bootstrap.Component
4883 * Bootstrap Element class
4884 * @cfg {String} html contents of the element
4885 * @cfg {String} tag tag of the element
4886 * @cfg {String} cls class of the element
4887 * @cfg {Boolean} preventDefault (true|false) default false
4888 * @cfg {Boolean} clickable (true|false) default false
4891 * Create a new Element
4892 * @param {Object} config The config object
4895 Roo.bootstrap.Element = function(config){
4896 Roo.bootstrap.Element.superclass.constructor.call(this, config);
4902 * When a element is chick
4903 * @param {Roo.bootstrap.Element} this
4904 * @param {Roo.EventObject} e
4910 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
4915 preventDefault: false,
4918 getAutoCreate : function(){
4929 initEvents: function()
4931 Roo.bootstrap.Element.superclass.initEvents.call(this);
4934 this.el.on('click', this.onClick, this);
4939 onClick : function(e)
4941 if(this.preventDefault){
4945 this.fireEvent('click', this, e);
4948 getValue : function()
4950 return this.el.dom.innerHTML;
4953 setValue : function(value)
4955 this.el.dom.innerHTML = value;
4970 * @class Roo.bootstrap.Pagination
4971 * @extends Roo.bootstrap.Component
4972 * Bootstrap Pagination class
4973 * @cfg {String} size xs | sm | md | lg
4974 * @cfg {Boolean} inverse false | true
4977 * Create a new Pagination
4978 * @param {Object} config The config object
4981 Roo.bootstrap.Pagination = function(config){
4982 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
4985 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
4991 getAutoCreate : function(){
4997 cfg.cls += ' inverse';
5003 cfg.cls += " " + this.cls;
5021 * @class Roo.bootstrap.PaginationItem
5022 * @extends Roo.bootstrap.Component
5023 * Bootstrap PaginationItem class
5024 * @cfg {String} html text
5025 * @cfg {String} href the link
5026 * @cfg {Boolean} preventDefault (true | false) default true
5027 * @cfg {Boolean} active (true | false) default false
5028 * @cfg {Boolean} disabled default false
5032 * Create a new PaginationItem
5033 * @param {Object} config The config object
5037 Roo.bootstrap.PaginationItem = function(config){
5038 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5043 * The raw click event for the entire grid.
5044 * @param {Roo.EventObject} e
5050 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5054 preventDefault: true,
5059 getAutoCreate : function(){
5065 href : this.href ? this.href : '#',
5066 html : this.html ? this.html : ''
5076 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5080 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5086 initEvents: function() {
5088 this.el.on('click', this.onClick, this);
5091 onClick : function(e)
5093 Roo.log('PaginationItem on click ');
5094 if(this.preventDefault){
5102 this.fireEvent('click', this, e);
5118 * @class Roo.bootstrap.Slider
5119 * @extends Roo.bootstrap.Component
5120 * Bootstrap Slider class
5123 * Create a new Slider
5124 * @param {Object} config The config object
5127 Roo.bootstrap.Slider = function(config){
5128 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5131 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5133 getAutoCreate : function(){
5137 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5141 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5153 * Ext JS Library 1.1.1
5154 * Copyright(c) 2006-2007, Ext JS, LLC.
5156 * Originally Released Under LGPL - original licence link has changed is not relivant.
5159 * <script type="text/javascript">
5164 * @class Roo.grid.ColumnModel
5165 * @extends Roo.util.Observable
5166 * This is the default implementation of a ColumnModel used by the Grid. It defines
5167 * the columns in the grid.
5170 var colModel = new Roo.grid.ColumnModel([
5171 {header: "Ticker", width: 60, sortable: true, locked: true},
5172 {header: "Company Name", width: 150, sortable: true},
5173 {header: "Market Cap.", width: 100, sortable: true},
5174 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5175 {header: "Employees", width: 100, sortable: true, resizable: false}
5180 * The config options listed for this class are options which may appear in each
5181 * individual column definition.
5182 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5184 * @param {Object} config An Array of column config objects. See this class's
5185 * config objects for details.
5187 Roo.grid.ColumnModel = function(config){
5189 * The config passed into the constructor
5191 this.config = config;
5194 // if no id, create one
5195 // if the column does not have a dataIndex mapping,
5196 // map it to the order it is in the config
5197 for(var i = 0, len = config.length; i < len; i++){
5199 if(typeof c.dataIndex == "undefined"){
5202 if(typeof c.renderer == "string"){
5203 c.renderer = Roo.util.Format[c.renderer];
5205 if(typeof c.id == "undefined"){
5208 if(c.editor && c.editor.xtype){
5209 c.editor = Roo.factory(c.editor, Roo.grid);
5211 if(c.editor && c.editor.isFormField){
5212 c.editor = new Roo.grid.GridEditor(c.editor);
5214 this.lookup[c.id] = c;
5218 * The width of columns which have no width specified (defaults to 100)
5221 this.defaultWidth = 100;
5224 * Default sortable of columns which have no sortable specified (defaults to false)
5227 this.defaultSortable = false;
5231 * @event widthchange
5232 * Fires when the width of a column changes.
5233 * @param {ColumnModel} this
5234 * @param {Number} columnIndex The column index
5235 * @param {Number} newWidth The new width
5237 "widthchange": true,
5239 * @event headerchange
5240 * Fires when the text of a header changes.
5241 * @param {ColumnModel} this
5242 * @param {Number} columnIndex The column index
5243 * @param {Number} newText The new header text
5245 "headerchange": true,
5247 * @event hiddenchange
5248 * Fires when a column is hidden or "unhidden".
5249 * @param {ColumnModel} this
5250 * @param {Number} columnIndex The column index
5251 * @param {Boolean} hidden true if hidden, false otherwise
5253 "hiddenchange": true,
5255 * @event columnmoved
5256 * Fires when a column is moved.
5257 * @param {ColumnModel} this
5258 * @param {Number} oldIndex
5259 * @param {Number} newIndex
5261 "columnmoved" : true,
5263 * @event columlockchange
5264 * Fires when a column's locked state is changed
5265 * @param {ColumnModel} this
5266 * @param {Number} colIndex
5267 * @param {Boolean} locked true if locked
5269 "columnlockchange" : true
5271 Roo.grid.ColumnModel.superclass.constructor.call(this);
5273 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5275 * @cfg {String} header The header text to display in the Grid view.
5278 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5279 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5280 * specified, the column's index is used as an index into the Record's data Array.
5283 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5284 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5287 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5288 * Defaults to the value of the {@link #defaultSortable} property.
5289 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5292 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5295 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5298 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5301 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5304 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5305 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5306 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5307 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5310 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5313 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5316 * @cfg {String} cursor (Optional)
5319 * @cfg {String} tooltip (Optional)
5322 * @cfg {Number} xs (Optional)
5325 * @cfg {Number} sm (Optional)
5328 * @cfg {Number} md (Optional)
5331 * @cfg {Number} lg (Optional)
5334 * Returns the id of the column at the specified index.
5335 * @param {Number} index The column index
5336 * @return {String} the id
5338 getColumnId : function(index){
5339 return this.config[index].id;
5343 * Returns the column for a specified id.
5344 * @param {String} id The column id
5345 * @return {Object} the column
5347 getColumnById : function(id){
5348 return this.lookup[id];
5353 * Returns the column for a specified dataIndex.
5354 * @param {String} dataIndex The column dataIndex
5355 * @return {Object|Boolean} the column or false if not found
5357 getColumnByDataIndex: function(dataIndex){
5358 var index = this.findColumnIndex(dataIndex);
5359 return index > -1 ? this.config[index] : false;
5363 * Returns the index for a specified column id.
5364 * @param {String} id The column id
5365 * @return {Number} the index, or -1 if not found
5367 getIndexById : function(id){
5368 for(var i = 0, len = this.config.length; i < len; i++){
5369 if(this.config[i].id == id){
5377 * Returns the index for a specified column dataIndex.
5378 * @param {String} dataIndex The column dataIndex
5379 * @return {Number} the index, or -1 if not found
5382 findColumnIndex : function(dataIndex){
5383 for(var i = 0, len = this.config.length; i < len; i++){
5384 if(this.config[i].dataIndex == dataIndex){
5392 moveColumn : function(oldIndex, newIndex){
5393 var c = this.config[oldIndex];
5394 this.config.splice(oldIndex, 1);
5395 this.config.splice(newIndex, 0, c);
5396 this.dataMap = null;
5397 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5400 isLocked : function(colIndex){
5401 return this.config[colIndex].locked === true;
5404 setLocked : function(colIndex, value, suppressEvent){
5405 if(this.isLocked(colIndex) == value){
5408 this.config[colIndex].locked = value;
5410 this.fireEvent("columnlockchange", this, colIndex, value);
5414 getTotalLockedWidth : function(){
5416 for(var i = 0; i < this.config.length; i++){
5417 if(this.isLocked(i) && !this.isHidden(i)){
5418 this.totalWidth += this.getColumnWidth(i);
5424 getLockedCount : function(){
5425 for(var i = 0, len = this.config.length; i < len; i++){
5426 if(!this.isLocked(i)){
5431 return this.config.length;
5435 * Returns the number of columns.
5438 getColumnCount : function(visibleOnly){
5439 if(visibleOnly === true){
5441 for(var i = 0, len = this.config.length; i < len; i++){
5442 if(!this.isHidden(i)){
5448 return this.config.length;
5452 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5453 * @param {Function} fn
5454 * @param {Object} scope (optional)
5455 * @return {Array} result
5457 getColumnsBy : function(fn, scope){
5459 for(var i = 0, len = this.config.length; i < len; i++){
5460 var c = this.config[i];
5461 if(fn.call(scope||this, c, i) === true){
5469 * Returns true if the specified column is sortable.
5470 * @param {Number} col The column index
5473 isSortable : function(col){
5474 if(typeof this.config[col].sortable == "undefined"){
5475 return this.defaultSortable;
5477 return this.config[col].sortable;
5481 * Returns the rendering (formatting) function defined for the column.
5482 * @param {Number} col The column index.
5483 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5485 getRenderer : function(col){
5486 if(!this.config[col].renderer){
5487 return Roo.grid.ColumnModel.defaultRenderer;
5489 return this.config[col].renderer;
5493 * Sets the rendering (formatting) function for a column.
5494 * @param {Number} col The column index
5495 * @param {Function} fn The function to use to process the cell's raw data
5496 * to return HTML markup for the grid view. The render function is called with
5497 * the following parameters:<ul>
5498 * <li>Data value.</li>
5499 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5500 * <li>css A CSS style string to apply to the table cell.</li>
5501 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5502 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5503 * <li>Row index</li>
5504 * <li>Column index</li>
5505 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5507 setRenderer : function(col, fn){
5508 this.config[col].renderer = fn;
5512 * Returns the width for the specified column.
5513 * @param {Number} col The column index
5516 getColumnWidth : function(col){
5517 return this.config[col].width * 1 || this.defaultWidth;
5521 * Sets the width for a column.
5522 * @param {Number} col The column index
5523 * @param {Number} width The new width
5525 setColumnWidth : function(col, width, suppressEvent){
5526 this.config[col].width = width;
5527 this.totalWidth = null;
5529 this.fireEvent("widthchange", this, col, width);
5534 * Returns the total width of all columns.
5535 * @param {Boolean} includeHidden True to include hidden column widths
5538 getTotalWidth : function(includeHidden){
5539 if(!this.totalWidth){
5540 this.totalWidth = 0;
5541 for(var i = 0, len = this.config.length; i < len; i++){
5542 if(includeHidden || !this.isHidden(i)){
5543 this.totalWidth += this.getColumnWidth(i);
5547 return this.totalWidth;
5551 * Returns the header for the specified column.
5552 * @param {Number} col The column index
5555 getColumnHeader : function(col){
5556 return this.config[col].header;
5560 * Sets the header for a column.
5561 * @param {Number} col The column index
5562 * @param {String} header The new header
5564 setColumnHeader : function(col, header){
5565 this.config[col].header = header;
5566 this.fireEvent("headerchange", this, col, header);
5570 * Returns the tooltip for the specified column.
5571 * @param {Number} col The column index
5574 getColumnTooltip : function(col){
5575 return this.config[col].tooltip;
5578 * Sets the tooltip for a column.
5579 * @param {Number} col The column index
5580 * @param {String} tooltip The new tooltip
5582 setColumnTooltip : function(col, tooltip){
5583 this.config[col].tooltip = tooltip;
5587 * Returns the dataIndex for the specified column.
5588 * @param {Number} col The column index
5591 getDataIndex : function(col){
5592 return this.config[col].dataIndex;
5596 * Sets the dataIndex for a column.
5597 * @param {Number} col The column index
5598 * @param {Number} dataIndex The new dataIndex
5600 setDataIndex : function(col, dataIndex){
5601 this.config[col].dataIndex = dataIndex;
5607 * Returns true if the cell is editable.
5608 * @param {Number} colIndex The column index
5609 * @param {Number} rowIndex The row index - this is nto actually used..?
5612 isCellEditable : function(colIndex, rowIndex){
5613 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5617 * Returns the editor defined for the cell/column.
5618 * return false or null to disable editing.
5619 * @param {Number} colIndex The column index
5620 * @param {Number} rowIndex The row index
5623 getCellEditor : function(colIndex, rowIndex){
5624 return this.config[colIndex].editor;
5628 * Sets if a column is editable.
5629 * @param {Number} col The column index
5630 * @param {Boolean} editable True if the column is editable
5632 setEditable : function(col, editable){
5633 this.config[col].editable = editable;
5638 * Returns true if the column is hidden.
5639 * @param {Number} colIndex The column index
5642 isHidden : function(colIndex){
5643 return this.config[colIndex].hidden;
5648 * Returns true if the column width cannot be changed
5650 isFixed : function(colIndex){
5651 return this.config[colIndex].fixed;
5655 * Returns true if the column can be resized
5658 isResizable : function(colIndex){
5659 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5662 * Sets if a column is hidden.
5663 * @param {Number} colIndex The column index
5664 * @param {Boolean} hidden True if the column is hidden
5666 setHidden : function(colIndex, hidden){
5667 this.config[colIndex].hidden = hidden;
5668 this.totalWidth = null;
5669 this.fireEvent("hiddenchange", this, colIndex, hidden);
5673 * Sets the editor for a column.
5674 * @param {Number} col The column index
5675 * @param {Object} editor The editor object
5677 setEditor : function(col, editor){
5678 this.config[col].editor = editor;
5682 Roo.grid.ColumnModel.defaultRenderer = function(value)
5684 if(typeof value == "object") {
5687 if(typeof value == "string" && value.length < 1){
5691 return String.format("{0}", value);
5694 // Alias for backwards compatibility
5695 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5698 * Ext JS Library 1.1.1
5699 * Copyright(c) 2006-2007, Ext JS, LLC.
5701 * Originally Released Under LGPL - original licence link has changed is not relivant.
5704 * <script type="text/javascript">
5708 * @class Roo.LoadMask
5709 * A simple utility class for generically masking elements while loading data. If the element being masked has
5710 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5711 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5712 * element's UpdateManager load indicator and will be destroyed after the initial load.
5714 * Create a new LoadMask
5715 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5716 * @param {Object} config The config object
5718 Roo.LoadMask = function(el, config){
5719 this.el = Roo.get(el);
5720 Roo.apply(this, config);
5722 this.store.on('beforeload', this.onBeforeLoad, this);
5723 this.store.on('load', this.onLoad, this);
5724 this.store.on('loadexception', this.onLoadException, this);
5725 this.removeMask = false;
5727 var um = this.el.getUpdateManager();
5728 um.showLoadIndicator = false; // disable the default indicator
5729 um.on('beforeupdate', this.onBeforeLoad, this);
5730 um.on('update', this.onLoad, this);
5731 um.on('failure', this.onLoad, this);
5732 this.removeMask = true;
5736 Roo.LoadMask.prototype = {
5738 * @cfg {Boolean} removeMask
5739 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5740 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5744 * The text to display in a centered loading message box (defaults to 'Loading...')
5748 * @cfg {String} msgCls
5749 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5751 msgCls : 'x-mask-loading',
5754 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5760 * Disables the mask to prevent it from being displayed
5762 disable : function(){
5763 this.disabled = true;
5767 * Enables the mask so that it can be displayed
5769 enable : function(){
5770 this.disabled = false;
5773 onLoadException : function()
5777 if (typeof(arguments[3]) != 'undefined') {
5778 Roo.MessageBox.alert("Error loading",arguments[3]);
5782 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5783 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5790 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5795 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5799 onBeforeLoad : function(){
5801 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5806 destroy : function(){
5808 this.store.un('beforeload', this.onBeforeLoad, this);
5809 this.store.un('load', this.onLoad, this);
5810 this.store.un('loadexception', this.onLoadException, this);
5812 var um = this.el.getUpdateManager();
5813 um.un('beforeupdate', this.onBeforeLoad, this);
5814 um.un('update', this.onLoad, this);
5815 um.un('failure', this.onLoad, this);
5826 * @class Roo.bootstrap.Table
5827 * @extends Roo.bootstrap.Component
5828 * Bootstrap Table class
5829 * @cfg {String} cls table class
5830 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
5831 * @cfg {String} bgcolor Specifies the background color for a table
5832 * @cfg {Number} border Specifies whether the table cells should have borders or not
5833 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
5834 * @cfg {Number} cellspacing Specifies the space between cells
5835 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
5836 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
5837 * @cfg {String} sortable Specifies that the table should be sortable
5838 * @cfg {String} summary Specifies a summary of the content of a table
5839 * @cfg {Number} width Specifies the width of a table
5840 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
5842 * @cfg {boolean} striped Should the rows be alternative striped
5843 * @cfg {boolean} bordered Add borders to the table
5844 * @cfg {boolean} hover Add hover highlighting
5845 * @cfg {boolean} condensed Format condensed
5846 * @cfg {boolean} responsive Format condensed
5847 * @cfg {Boolean} loadMask (true|false) default false
5848 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
5849 * @cfg {Boolean} headerShow (true|false) generate thead, default true
5850 * @cfg {Boolean} rowSelection (true|false) default false
5851 * @cfg {Boolean} cellSelection (true|false) default false
5852 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
5853 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
5854 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
5858 * Create a new Table
5859 * @param {Object} config The config object
5862 Roo.bootstrap.Table = function(config){
5863 Roo.bootstrap.Table.superclass.constructor.call(this, config);
5868 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
5869 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
5870 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
5871 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
5873 this.sm = this.sm || {xtype: 'RowSelectionModel'};
5875 this.sm.grid = this;
5876 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
5877 this.sm = this.selModel;
5878 this.sm.xmodule = this.xmodule || false;
5881 if (this.cm && typeof(this.cm.config) == 'undefined') {
5882 this.colModel = new Roo.grid.ColumnModel(this.cm);
5883 this.cm = this.colModel;
5884 this.cm.xmodule = this.xmodule || false;
5887 this.store= Roo.factory(this.store, Roo.data);
5888 this.ds = this.store;
5889 this.ds.xmodule = this.xmodule || false;
5892 if (this.footer && this.store) {
5893 this.footer.dataSource = this.ds;
5894 this.footer = Roo.factory(this.footer);
5901 * Fires when a cell is clicked
5902 * @param {Roo.bootstrap.Table} this
5903 * @param {Roo.Element} el
5904 * @param {Number} rowIndex
5905 * @param {Number} columnIndex
5906 * @param {Roo.EventObject} e
5910 * @event celldblclick
5911 * Fires when a cell is double clicked
5912 * @param {Roo.bootstrap.Table} this
5913 * @param {Roo.Element} el
5914 * @param {Number} rowIndex
5915 * @param {Number} columnIndex
5916 * @param {Roo.EventObject} e
5918 "celldblclick" : true,
5921 * Fires when a row is clicked
5922 * @param {Roo.bootstrap.Table} this
5923 * @param {Roo.Element} el
5924 * @param {Number} rowIndex
5925 * @param {Roo.EventObject} e
5929 * @event rowdblclick
5930 * Fires when a row is double clicked
5931 * @param {Roo.bootstrap.Table} this
5932 * @param {Roo.Element} el
5933 * @param {Number} rowIndex
5934 * @param {Roo.EventObject} e
5936 "rowdblclick" : true,
5939 * Fires when a mouseover occur
5940 * @param {Roo.bootstrap.Table} this
5941 * @param {Roo.Element} el
5942 * @param {Number} rowIndex
5943 * @param {Number} columnIndex
5944 * @param {Roo.EventObject} e
5949 * Fires when a mouseout occur
5950 * @param {Roo.bootstrap.Table} this
5951 * @param {Roo.Element} el
5952 * @param {Number} rowIndex
5953 * @param {Number} columnIndex
5954 * @param {Roo.EventObject} e
5959 * Fires when a row is rendered, so you can change add a style to it.
5960 * @param {Roo.bootstrap.Table} this
5961 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
5965 * @event rowsrendered
5966 * Fires when all the rows have been rendered
5967 * @param {Roo.bootstrap.Table} this
5969 'rowsrendered' : true,
5971 * @event contextmenu
5972 * The raw contextmenu event for the entire grid.
5973 * @param {Roo.EventObject} e
5975 "contextmenu" : true,
5977 * @event rowcontextmenu
5978 * Fires when a row is right clicked
5979 * @param {Roo.bootstrap.Table} this
5980 * @param {Number} rowIndex
5981 * @param {Roo.EventObject} e
5983 "rowcontextmenu" : true,
5985 * @event cellcontextmenu
5986 * Fires when a cell is right clicked
5987 * @param {Roo.bootstrap.Table} this
5988 * @param {Number} rowIndex
5989 * @param {Number} cellIndex
5990 * @param {Roo.EventObject} e
5992 "cellcontextmenu" : true,
5994 * @event headercontextmenu
5995 * Fires when a header is right clicked
5996 * @param {Roo.bootstrap.Table} this
5997 * @param {Number} columnIndex
5998 * @param {Roo.EventObject} e
6000 "headercontextmenu" : true
6004 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6030 rowSelection : false,
6031 cellSelection : false,
6034 // Roo.Element - the tbody
6036 // Roo.Element - thead element
6039 container: false, // used by gridpanel...
6043 getAutoCreate : function()
6045 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6052 if (this.scrollBody) {
6053 cfg.cls += ' table-body-fixed';
6056 cfg.cls += ' table-striped';
6060 cfg.cls += ' table-hover';
6062 if (this.bordered) {
6063 cfg.cls += ' table-bordered';
6065 if (this.condensed) {
6066 cfg.cls += ' table-condensed';
6068 if (this.responsive) {
6069 cfg.cls += ' table-responsive';
6073 cfg.cls+= ' ' +this.cls;
6076 // this lot should be simplifed...
6079 cfg.align=this.align;
6082 cfg.bgcolor=this.bgcolor;
6085 cfg.border=this.border;
6087 if (this.cellpadding) {
6088 cfg.cellpadding=this.cellpadding;
6090 if (this.cellspacing) {
6091 cfg.cellspacing=this.cellspacing;
6094 cfg.frame=this.frame;
6097 cfg.rules=this.rules;
6099 if (this.sortable) {
6100 cfg.sortable=this.sortable;
6103 cfg.summary=this.summary;
6106 cfg.width=this.width;
6109 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6112 if(this.store || this.cm){
6113 if(this.headerShow){
6114 cfg.cn.push(this.renderHeader());
6117 cfg.cn.push(this.renderBody());
6119 if(this.footerShow){
6120 cfg.cn.push(this.renderFooter());
6122 // where does this come from?
6123 //cfg.cls+= ' TableGrid';
6126 return { cn : [ cfg ] };
6129 initEvents : function()
6131 if(!this.store || !this.cm){
6134 if (this.selModel) {
6135 this.selModel.initEvents();
6139 //Roo.log('initEvents with ds!!!!');
6141 this.mainBody = this.el.select('tbody', true).first();
6142 this.mainHead = this.el.select('thead', true).first();
6149 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6150 e.on('click', _this.sort, _this);
6153 this.mainBody.on("click", this.onClick, this);
6154 this.mainBody.on("dblclick", this.onDblClick, this);
6156 // why is this done????? = it breaks dialogs??
6157 //this.parent().el.setStyle('position', 'relative');
6161 this.footer.parentId = this.id;
6162 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6165 this.el.select('tfoot tr td').first().addClass('hide');
6169 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6171 this.store.on('load', this.onLoad, this);
6172 this.store.on('beforeload', this.onBeforeLoad, this);
6173 this.store.on('update', this.onUpdate, this);
6174 this.store.on('add', this.onAdd, this);
6175 this.store.on("clear", this.clear, this);
6177 this.el.on("contextmenu", this.onContextMenu, this);
6179 this.mainBody.on('scroll', this.onBodyScroll, this);
6181 this.cm.on("headerchange", this.onHeaderChange, this);
6185 onContextMenu : function(e, t)
6187 this.processEvent("contextmenu", e);
6190 processEvent : function(name, e)
6192 if (name != 'touchstart' ) {
6193 this.fireEvent(name, e);
6196 var t = e.getTarget();
6198 var cell = Roo.get(t);
6204 if(cell.findParent('tfoot', false, true)){
6208 if(cell.findParent('thead', false, true)){
6210 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6211 cell = Roo.get(t).findParent('th', false, true);
6213 Roo.log("failed to find th in thead?");
6214 Roo.log(e.getTarget());
6219 var cellIndex = cell.dom.cellIndex;
6221 var ename = name == 'touchstart' ? 'click' : name;
6222 this.fireEvent("header" + ename, this, cellIndex, e);
6227 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6228 cell = Roo.get(t).findParent('td', false, true);
6230 Roo.log("failed to find th in tbody?");
6231 Roo.log(e.getTarget());
6236 var row = cell.findParent('tr', false, true);
6237 var cellIndex = cell.dom.cellIndex;
6238 var rowIndex = row.dom.rowIndex - 1;
6242 this.fireEvent("row" + name, this, rowIndex, e);
6246 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6252 onMouseover : function(e, el)
6254 var cell = Roo.get(el);
6260 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6261 cell = cell.findParent('td', false, true);
6264 var row = cell.findParent('tr', false, true);
6265 var cellIndex = cell.dom.cellIndex;
6266 var rowIndex = row.dom.rowIndex - 1; // start from 0
6268 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6272 onMouseout : function(e, el)
6274 var cell = Roo.get(el);
6280 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6281 cell = cell.findParent('td', false, true);
6284 var row = cell.findParent('tr', false, true);
6285 var cellIndex = cell.dom.cellIndex;
6286 var rowIndex = row.dom.rowIndex - 1; // start from 0
6288 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6292 onClick : function(e, el)
6294 var cell = Roo.get(el);
6296 if(!cell || (!this.cellSelection && !this.rowSelection)){
6300 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6301 cell = cell.findParent('td', false, true);
6304 if(!cell || typeof(cell) == 'undefined'){
6308 var row = cell.findParent('tr', false, true);
6310 if(!row || typeof(row) == 'undefined'){
6314 var cellIndex = cell.dom.cellIndex;
6315 var rowIndex = this.getRowIndex(row);
6317 // why??? - should these not be based on SelectionModel?
6318 if(this.cellSelection){
6319 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6322 if(this.rowSelection){
6323 this.fireEvent('rowclick', this, row, rowIndex, e);
6329 onDblClick : function(e,el)
6331 var cell = Roo.get(el);
6333 if(!cell || (!this.cellSelection && !this.rowSelection)){
6337 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6338 cell = cell.findParent('td', false, true);
6341 if(!cell || typeof(cell) == 'undefined'){
6345 var row = cell.findParent('tr', false, true);
6347 if(!row || typeof(row) == 'undefined'){
6351 var cellIndex = cell.dom.cellIndex;
6352 var rowIndex = this.getRowIndex(row);
6354 if(this.cellSelection){
6355 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6358 if(this.rowSelection){
6359 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6363 sort : function(e,el)
6365 var col = Roo.get(el);
6367 if(!col.hasClass('sortable')){
6371 var sort = col.attr('sort');
6374 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6378 this.store.sortInfo = {field : sort, direction : dir};
6381 Roo.log("calling footer first");
6382 this.footer.onClick('first');
6385 this.store.load({ params : { start : 0 } });
6389 renderHeader : function()
6397 this.totalWidth = 0;
6399 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6401 var config = cm.config[i];
6406 html: cm.getColumnHeader(i)
6411 if(typeof(config.sortable) != 'undefined' && config.sortable){
6413 c.html = '<i class="glyphicon"></i>' + c.html;
6416 if(typeof(config.lgHeader) != 'undefined'){
6417 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6420 if(typeof(config.mdHeader) != 'undefined'){
6421 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6424 if(typeof(config.smHeader) != 'undefined'){
6425 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6428 if(typeof(config.xsHeader) != 'undefined'){
6429 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6436 if(typeof(config.tooltip) != 'undefined'){
6437 c.tooltip = config.tooltip;
6440 if(typeof(config.colspan) != 'undefined'){
6441 c.colspan = config.colspan;
6444 if(typeof(config.hidden) != 'undefined' && config.hidden){
6445 c.style += ' display:none;';
6448 if(typeof(config.dataIndex) != 'undefined'){
6449 c.sort = config.dataIndex;
6454 if(typeof(config.align) != 'undefined' && config.align.length){
6455 c.style += ' text-align:' + config.align + ';';
6458 if(typeof(config.width) != 'undefined'){
6459 c.style += ' width:' + config.width + 'px;';
6460 this.totalWidth += config.width;
6462 this.totalWidth += 100; // assume minimum of 100 per column?
6465 if(typeof(config.cls) != 'undefined'){
6466 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6469 ['xs','sm','md','lg'].map(function(size){
6471 if(typeof(config[size]) == 'undefined'){
6475 if (!config[size]) { // 0 = hidden
6476 c.cls += ' hidden-' + size;
6480 c.cls += ' col-' + size + '-' + config[size];
6490 renderBody : function()
6500 colspan : this.cm.getColumnCount()
6510 renderFooter : function()
6520 colspan : this.cm.getColumnCount()
6534 // Roo.log('ds onload');
6539 var ds = this.store;
6541 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6542 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6543 if (_this.store.sortInfo) {
6545 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6546 e.select('i', true).addClass(['glyphicon-arrow-up']);
6549 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6550 e.select('i', true).addClass(['glyphicon-arrow-down']);
6555 var tbody = this.mainBody;
6557 if(ds.getCount() > 0){
6558 ds.data.each(function(d,rowIndex){
6559 var row = this.renderRow(cm, ds, rowIndex);
6561 tbody.createChild(row);
6565 if(row.cellObjects.length){
6566 Roo.each(row.cellObjects, function(r){
6567 _this.renderCellObject(r);
6574 Roo.each(this.el.select('tbody td', true).elements, function(e){
6575 e.on('mouseover', _this.onMouseover, _this);
6578 Roo.each(this.el.select('tbody td', true).elements, function(e){
6579 e.on('mouseout', _this.onMouseout, _this);
6581 this.fireEvent('rowsrendered', this);
6582 //if(this.loadMask){
6583 // this.maskEl.hide();
6590 onUpdate : function(ds,record)
6592 this.refreshRow(record);
6596 onRemove : function(ds, record, index, isUpdate){
6597 if(isUpdate !== true){
6598 this.fireEvent("beforerowremoved", this, index, record);
6600 var bt = this.mainBody.dom;
6602 var rows = this.el.select('tbody > tr', true).elements;
6604 if(typeof(rows[index]) != 'undefined'){
6605 bt.removeChild(rows[index].dom);
6608 // if(bt.rows[index]){
6609 // bt.removeChild(bt.rows[index]);
6612 if(isUpdate !== true){
6613 //this.stripeRows(index);
6614 //this.syncRowHeights(index, index);
6616 this.fireEvent("rowremoved", this, index, record);
6620 onAdd : function(ds, records, rowIndex)
6622 //Roo.log('on Add called');
6623 // - note this does not handle multiple adding very well..
6624 var bt = this.mainBody.dom;
6625 for (var i =0 ; i < records.length;i++) {
6626 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6627 //Roo.log(records[i]);
6628 //Roo.log(this.store.getAt(rowIndex+i));
6629 this.insertRow(this.store, rowIndex + i, false);
6636 refreshRow : function(record){
6637 var ds = this.store, index;
6638 if(typeof record == 'number'){
6640 record = ds.getAt(index);
6642 index = ds.indexOf(record);
6644 this.insertRow(ds, index, true);
6646 this.onRemove(ds, record, index+1, true);
6648 //this.syncRowHeights(index, index);
6650 this.fireEvent("rowupdated", this, index, record);
6653 insertRow : function(dm, rowIndex, isUpdate){
6656 this.fireEvent("beforerowsinserted", this, rowIndex);
6658 //var s = this.getScrollState();
6659 var row = this.renderRow(this.cm, this.store, rowIndex);
6660 // insert before rowIndex..
6661 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6665 if(row.cellObjects.length){
6666 Roo.each(row.cellObjects, function(r){
6667 _this.renderCellObject(r);
6672 this.fireEvent("rowsinserted", this, rowIndex);
6673 //this.syncRowHeights(firstRow, lastRow);
6674 //this.stripeRows(firstRow);
6681 getRowDom : function(rowIndex)
6683 var rows = this.el.select('tbody > tr', true).elements;
6685 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6688 // returns the object tree for a tr..
6691 renderRow : function(cm, ds, rowIndex)
6694 var d = ds.getAt(rowIndex);
6701 var cellObjects = [];
6703 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6704 var config = cm.config[i];
6706 var renderer = cm.getRenderer(i);
6710 if(typeof(renderer) !== 'undefined'){
6711 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6713 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6714 // and are rendered into the cells after the row is rendered - using the id for the element.
6716 if(typeof(value) === 'object'){
6726 rowIndex : rowIndex,
6731 this.fireEvent('rowclass', this, rowcfg);
6735 cls : rowcfg.rowClass,
6737 html: (typeof(value) === 'object') ? '' : value
6744 if(typeof(config.colspan) != 'undefined'){
6745 td.colspan = config.colspan;
6748 if(typeof(config.hidden) != 'undefined' && config.hidden){
6749 td.style += ' display:none;';
6752 if(typeof(config.align) != 'undefined' && config.align.length){
6753 td.style += ' text-align:' + config.align + ';';
6756 if(typeof(config.width) != 'undefined'){
6757 td.style += ' width:' + config.width + 'px;';
6760 if(typeof(config.cursor) != 'undefined'){
6761 td.style += ' cursor:' + config.cursor + ';';
6764 if(typeof(config.cls) != 'undefined'){
6765 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6768 ['xs','sm','md','lg'].map(function(size){
6770 if(typeof(config[size]) == 'undefined'){
6774 if (!config[size]) { // 0 = hidden
6775 td.cls += ' hidden-' + size;
6779 td.cls += ' col-' + size + '-' + config[size];
6787 row.cellObjects = cellObjects;
6795 onBeforeLoad : function()
6797 //Roo.log('ds onBeforeLoad');
6801 //if(this.loadMask){
6802 // this.maskEl.show();
6810 this.el.select('tbody', true).first().dom.innerHTML = '';
6813 * Show or hide a row.
6814 * @param {Number} rowIndex to show or hide
6815 * @param {Boolean} state hide
6817 setRowVisibility : function(rowIndex, state)
6819 var bt = this.mainBody.dom;
6821 var rows = this.el.select('tbody > tr', true).elements;
6823 if(typeof(rows[rowIndex]) == 'undefined'){
6826 rows[rowIndex].dom.style.display = state ? '' : 'none';
6830 getSelectionModel : function(){
6832 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
6834 return this.selModel;
6837 * Render the Roo.bootstrap object from renderder
6839 renderCellObject : function(r)
6843 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
6845 var t = r.cfg.render(r.container);
6848 Roo.each(r.cfg.cn, function(c){
6850 container: t.getChildContainer(),
6853 _this.renderCellObject(child);
6858 getRowIndex : function(row)
6862 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
6873 * Returns the grid's underlying element = used by panel.Grid
6874 * @return {Element} The element
6876 getGridEl : function(){
6880 * Forces a resize - used by panel.Grid
6881 * @return {Element} The element
6883 autoSize : function()
6885 //var ctr = Roo.get(this.container.dom.parentElement);
6886 var ctr = Roo.get(this.el.dom);
6888 var thd = this.getGridEl().select('thead',true).first();
6889 var tbd = this.getGridEl().select('tbody', true).first();
6890 var tfd = this.getGridEl().select('tfoot', true).first();
6892 var cw = ctr.getWidth();
6896 tbd.setSize(ctr.getWidth(),
6897 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
6899 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
6902 cw = Math.max(cw, this.totalWidth);
6903 this.getGridEl().select('tr',true).setWidth(cw);
6904 // resize 'expandable coloumn?
6906 return; // we doe not have a view in this design..
6909 onBodyScroll: function()
6911 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
6913 this.mainHead.setStyle({
6914 'position' : 'relative',
6915 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6921 var scrollHeight = this.mainBody.dom.scrollHeight;
6923 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
6925 var height = this.mainBody.getHeight();
6927 if(scrollHeight - height == scrollTop) {
6929 var total = this.ds.getTotalCount();
6931 if(this.footer.cursor + this.footer.pageSize < total){
6933 this.footer.ds.load({
6935 start : this.footer.cursor + this.footer.pageSize,
6936 limit : this.footer.pageSize
6946 onHeaderChange : function()
6949 var header = this.renderHeader();
6950 var table = this.el.select('table', true).first();
6952 this.mainHead.remove();
6953 this.mainHead = table.createChild(header, this.mainBody, false);
6968 * @class Roo.bootstrap.TableCell
6969 * @extends Roo.bootstrap.Component
6970 * Bootstrap TableCell class
6971 * @cfg {String} html cell contain text
6972 * @cfg {String} cls cell class
6973 * @cfg {String} tag cell tag (td|th) default td
6974 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6975 * @cfg {String} align Aligns the content in a cell
6976 * @cfg {String} axis Categorizes cells
6977 * @cfg {String} bgcolor Specifies the background color of a cell
6978 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6979 * @cfg {Number} colspan Specifies the number of columns a cell should span
6980 * @cfg {String} headers Specifies one or more header cells a cell is related to
6981 * @cfg {Number} height Sets the height of a cell
6982 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
6983 * @cfg {Number} rowspan Sets the number of rows a cell should span
6984 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
6985 * @cfg {String} valign Vertical aligns the content in a cell
6986 * @cfg {Number} width Specifies the width of a cell
6989 * Create a new TableCell
6990 * @param {Object} config The config object
6993 Roo.bootstrap.TableCell = function(config){
6994 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
6997 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7017 getAutoCreate : function(){
7018 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7038 cfg.align=this.align
7044 cfg.bgcolor=this.bgcolor
7047 cfg.charoff=this.charoff
7050 cfg.colspan=this.colspan
7053 cfg.headers=this.headers
7056 cfg.height=this.height
7059 cfg.nowrap=this.nowrap
7062 cfg.rowspan=this.rowspan
7065 cfg.scope=this.scope
7068 cfg.valign=this.valign
7071 cfg.width=this.width
7090 * @class Roo.bootstrap.TableRow
7091 * @extends Roo.bootstrap.Component
7092 * Bootstrap TableRow class
7093 * @cfg {String} cls row class
7094 * @cfg {String} align Aligns the content in a table row
7095 * @cfg {String} bgcolor Specifies a background color for a table row
7096 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7097 * @cfg {String} valign Vertical aligns the content in a table row
7100 * Create a new TableRow
7101 * @param {Object} config The config object
7104 Roo.bootstrap.TableRow = function(config){
7105 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7108 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7116 getAutoCreate : function(){
7117 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7127 cfg.align = this.align;
7130 cfg.bgcolor = this.bgcolor;
7133 cfg.charoff = this.charoff;
7136 cfg.valign = this.valign;
7154 * @class Roo.bootstrap.TableBody
7155 * @extends Roo.bootstrap.Component
7156 * Bootstrap TableBody class
7157 * @cfg {String} cls element class
7158 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7159 * @cfg {String} align Aligns the content inside the element
7160 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7161 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7164 * Create a new TableBody
7165 * @param {Object} config The config object
7168 Roo.bootstrap.TableBody = function(config){
7169 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7172 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7180 getAutoCreate : function(){
7181 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7195 cfg.align = this.align;
7198 cfg.charoff = this.charoff;
7201 cfg.valign = this.valign;
7208 // initEvents : function()
7215 // this.store = Roo.factory(this.store, Roo.data);
7216 // this.store.on('load', this.onLoad, this);
7218 // this.store.load();
7222 // onLoad: function ()
7224 // this.fireEvent('load', this);
7234 * Ext JS Library 1.1.1
7235 * Copyright(c) 2006-2007, Ext JS, LLC.
7237 * Originally Released Under LGPL - original licence link has changed is not relivant.
7240 * <script type="text/javascript">
7243 // as we use this in bootstrap.
7244 Roo.namespace('Roo.form');
7246 * @class Roo.form.Action
7247 * Internal Class used to handle form actions
7249 * @param {Roo.form.BasicForm} el The form element or its id
7250 * @param {Object} config Configuration options
7255 // define the action interface
7256 Roo.form.Action = function(form, options){
7258 this.options = options || {};
7261 * Client Validation Failed
7264 Roo.form.Action.CLIENT_INVALID = 'client';
7266 * Server Validation Failed
7269 Roo.form.Action.SERVER_INVALID = 'server';
7271 * Connect to Server Failed
7274 Roo.form.Action.CONNECT_FAILURE = 'connect';
7276 * Reading Data from Server Failed
7279 Roo.form.Action.LOAD_FAILURE = 'load';
7281 Roo.form.Action.prototype = {
7283 failureType : undefined,
7284 response : undefined,
7288 run : function(options){
7293 success : function(response){
7298 handleResponse : function(response){
7302 // default connection failure
7303 failure : function(response){
7305 this.response = response;
7306 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7307 this.form.afterAction(this, false);
7310 processResponse : function(response){
7311 this.response = response;
7312 if(!response.responseText){
7315 this.result = this.handleResponse(response);
7319 // utility functions used internally
7320 getUrl : function(appendParams){
7321 var url = this.options.url || this.form.url || this.form.el.dom.action;
7323 var p = this.getParams();
7325 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7331 getMethod : function(){
7332 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7335 getParams : function(){
7336 var bp = this.form.baseParams;
7337 var p = this.options.params;
7339 if(typeof p == "object"){
7340 p = Roo.urlEncode(Roo.applyIf(p, bp));
7341 }else if(typeof p == 'string' && bp){
7342 p += '&' + Roo.urlEncode(bp);
7345 p = Roo.urlEncode(bp);
7350 createCallback : function(){
7352 success: this.success,
7353 failure: this.failure,
7355 timeout: (this.form.timeout*1000),
7356 upload: this.form.fileUpload ? this.success : undefined
7361 Roo.form.Action.Submit = function(form, options){
7362 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7365 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7368 haveProgress : false,
7369 uploadComplete : false,
7371 // uploadProgress indicator.
7372 uploadProgress : function()
7374 if (!this.form.progressUrl) {
7378 if (!this.haveProgress) {
7379 Roo.MessageBox.progress("Uploading", "Uploading");
7381 if (this.uploadComplete) {
7382 Roo.MessageBox.hide();
7386 this.haveProgress = true;
7388 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7390 var c = new Roo.data.Connection();
7392 url : this.form.progressUrl,
7397 success : function(req){
7398 //console.log(data);
7402 rdata = Roo.decode(req.responseText)
7404 Roo.log("Invalid data from server..");
7408 if (!rdata || !rdata.success) {
7410 Roo.MessageBox.alert(Roo.encode(rdata));
7413 var data = rdata.data;
7415 if (this.uploadComplete) {
7416 Roo.MessageBox.hide();
7421 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7422 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7425 this.uploadProgress.defer(2000,this);
7428 failure: function(data) {
7429 Roo.log('progress url failed ');
7440 // run get Values on the form, so it syncs any secondary forms.
7441 this.form.getValues();
7443 var o = this.options;
7444 var method = this.getMethod();
7445 var isPost = method == 'POST';
7446 if(o.clientValidation === false || this.form.isValid()){
7448 if (this.form.progressUrl) {
7449 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7450 (new Date() * 1) + '' + Math.random());
7455 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7456 form:this.form.el.dom,
7457 url:this.getUrl(!isPost),
7459 params:isPost ? this.getParams() : null,
7460 isUpload: this.form.fileUpload
7463 this.uploadProgress();
7465 }else if (o.clientValidation !== false){ // client validation failed
7466 this.failureType = Roo.form.Action.CLIENT_INVALID;
7467 this.form.afterAction(this, false);
7471 success : function(response)
7473 this.uploadComplete= true;
7474 if (this.haveProgress) {
7475 Roo.MessageBox.hide();
7479 var result = this.processResponse(response);
7480 if(result === true || result.success){
7481 this.form.afterAction(this, true);
7485 this.form.markInvalid(result.errors);
7486 this.failureType = Roo.form.Action.SERVER_INVALID;
7488 this.form.afterAction(this, false);
7490 failure : function(response)
7492 this.uploadComplete= true;
7493 if (this.haveProgress) {
7494 Roo.MessageBox.hide();
7497 this.response = response;
7498 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7499 this.form.afterAction(this, false);
7502 handleResponse : function(response){
7503 if(this.form.errorReader){
7504 var rs = this.form.errorReader.read(response);
7507 for(var i = 0, len = rs.records.length; i < len; i++) {
7508 var r = rs.records[i];
7512 if(errors.length < 1){
7516 success : rs.success,
7522 ret = Roo.decode(response.responseText);
7526 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7536 Roo.form.Action.Load = function(form, options){
7537 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7538 this.reader = this.form.reader;
7541 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7546 Roo.Ajax.request(Roo.apply(
7547 this.createCallback(), {
7548 method:this.getMethod(),
7549 url:this.getUrl(false),
7550 params:this.getParams()
7554 success : function(response){
7556 var result = this.processResponse(response);
7557 if(result === true || !result.success || !result.data){
7558 this.failureType = Roo.form.Action.LOAD_FAILURE;
7559 this.form.afterAction(this, false);
7562 this.form.clearInvalid();
7563 this.form.setValues(result.data);
7564 this.form.afterAction(this, true);
7567 handleResponse : function(response){
7568 if(this.form.reader){
7569 var rs = this.form.reader.read(response);
7570 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7572 success : rs.success,
7576 return Roo.decode(response.responseText);
7580 Roo.form.Action.ACTION_TYPES = {
7581 'load' : Roo.form.Action.Load,
7582 'submit' : Roo.form.Action.Submit
7591 * @class Roo.bootstrap.Form
7592 * @extends Roo.bootstrap.Component
7593 * Bootstrap Form class
7594 * @cfg {String} method GET | POST (default POST)
7595 * @cfg {String} labelAlign top | left (default top)
7596 * @cfg {String} align left | right - for navbars
7597 * @cfg {Boolean} loadMask load mask when submit (default true)
7602 * @param {Object} config The config object
7606 Roo.bootstrap.Form = function(config){
7608 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7610 Roo.bootstrap.Form.popover.apply();
7614 * @event clientvalidation
7615 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7616 * @param {Form} this
7617 * @param {Boolean} valid true if the form has passed client-side validation
7619 clientvalidation: true,
7621 * @event beforeaction
7622 * Fires before any action is performed. Return false to cancel the action.
7623 * @param {Form} this
7624 * @param {Action} action The action to be performed
7628 * @event actionfailed
7629 * Fires when an action fails.
7630 * @param {Form} this
7631 * @param {Action} action The action that failed
7633 actionfailed : true,
7635 * @event actioncomplete
7636 * Fires when an action is completed.
7637 * @param {Form} this
7638 * @param {Action} action The action that completed
7640 actioncomplete : true
7644 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7647 * @cfg {String} method
7648 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7653 * The URL to use for form actions if one isn't supplied in the action options.
7656 * @cfg {Boolean} fileUpload
7657 * Set to true if this form is a file upload.
7661 * @cfg {Object} baseParams
7662 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7666 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7670 * @cfg {Sting} align (left|right) for navbar forms
7675 activeAction : null,
7678 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7679 * element by passing it or its id or mask the form itself by passing in true.
7682 waitMsgTarget : false,
7687 * @cfg {Boolean} errorMask (true|false) default false
7692 * @cfg {Number} maskOffset Default 100
7697 * @cfg {Boolean} maskBody
7701 getAutoCreate : function(){
7705 method : this.method || 'POST',
7706 id : this.id || Roo.id(),
7709 if (this.parent().xtype.match(/^Nav/)) {
7710 cfg.cls = 'navbar-form navbar-' + this.align;
7714 if (this.labelAlign == 'left' ) {
7715 cfg.cls += ' form-horizontal';
7721 initEvents : function()
7723 this.el.on('submit', this.onSubmit, this);
7724 // this was added as random key presses on the form where triggering form submit.
7725 this.el.on('keypress', function(e) {
7726 if (e.getCharCode() != 13) {
7729 // we might need to allow it for textareas.. and some other items.
7730 // check e.getTarget().
7732 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7736 Roo.log("keypress blocked");
7744 onSubmit : function(e){
7749 * Returns true if client-side validation on the form is successful.
7752 isValid : function(){
7753 var items = this.getItems();
7757 items.each(function(f){
7763 if(!target && f.el.isVisible(true)){
7769 if(this.errorMask && !valid){
7770 Roo.bootstrap.Form.popover.mask(this, target);
7777 * Returns true if any fields in this form have changed since their original load.
7780 isDirty : function(){
7782 var items = this.getItems();
7783 items.each(function(f){
7793 * Performs a predefined action (submit or load) or custom actions you define on this form.
7794 * @param {String} actionName The name of the action type
7795 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7796 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7797 * accept other config options):
7799 Property Type Description
7800 ---------------- --------------- ----------------------------------------------------------------------------------
7801 url String The url for the action (defaults to the form's url)
7802 method String The form method to use (defaults to the form's method, or POST if not defined)
7803 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7804 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7805 validate the form on the client (defaults to false)
7807 * @return {BasicForm} this
7809 doAction : function(action, options){
7810 if(typeof action == 'string'){
7811 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7813 if(this.fireEvent('beforeaction', this, action) !== false){
7814 this.beforeAction(action);
7815 action.run.defer(100, action);
7821 beforeAction : function(action){
7822 var o = action.options;
7827 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
7829 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7832 // not really supported yet.. ??
7834 //if(this.waitMsgTarget === true){
7835 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7836 //}else if(this.waitMsgTarget){
7837 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7838 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7840 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7846 afterAction : function(action, success){
7847 this.activeAction = null;
7848 var o = action.options;
7853 Roo.get(document.body).unmask();
7859 //if(this.waitMsgTarget === true){
7860 // this.el.unmask();
7861 //}else if(this.waitMsgTarget){
7862 // this.waitMsgTarget.unmask();
7864 // Roo.MessageBox.updateProgress(1);
7865 // Roo.MessageBox.hide();
7872 Roo.callback(o.success, o.scope, [this, action]);
7873 this.fireEvent('actioncomplete', this, action);
7877 // failure condition..
7878 // we have a scenario where updates need confirming.
7879 // eg. if a locking scenario exists..
7880 // we look for { errors : { needs_confirm : true }} in the response.
7882 (typeof(action.result) != 'undefined') &&
7883 (typeof(action.result.errors) != 'undefined') &&
7884 (typeof(action.result.errors.needs_confirm) != 'undefined')
7887 Roo.log("not supported yet");
7890 Roo.MessageBox.confirm(
7891 "Change requires confirmation",
7892 action.result.errorMsg,
7897 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7907 Roo.callback(o.failure, o.scope, [this, action]);
7908 // show an error message if no failed handler is set..
7909 if (!this.hasListener('actionfailed')) {
7910 Roo.log("need to add dialog support");
7912 Roo.MessageBox.alert("Error",
7913 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7914 action.result.errorMsg :
7915 "Saving Failed, please check your entries or try again"
7920 this.fireEvent('actionfailed', this, action);
7925 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7926 * @param {String} id The value to search for
7929 findField : function(id){
7930 var items = this.getItems();
7931 var field = items.get(id);
7933 items.each(function(f){
7934 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7941 return field || null;
7944 * Mark fields in this form invalid in bulk.
7945 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7946 * @return {BasicForm} this
7948 markInvalid : function(errors){
7949 if(errors instanceof Array){
7950 for(var i = 0, len = errors.length; i < len; i++){
7951 var fieldError = errors[i];
7952 var f = this.findField(fieldError.id);
7954 f.markInvalid(fieldError.msg);
7960 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7961 field.markInvalid(errors[id]);
7965 //Roo.each(this.childForms || [], function (f) {
7966 // f.markInvalid(errors);
7973 * Set values for fields in this form in bulk.
7974 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7975 * @return {BasicForm} this
7977 setValues : function(values){
7978 if(values instanceof Array){ // array of objects
7979 for(var i = 0, len = values.length; i < len; i++){
7981 var f = this.findField(v.id);
7983 f.setValue(v.value);
7984 if(this.trackResetOnLoad){
7985 f.originalValue = f.getValue();
7989 }else{ // object hash
7992 if(typeof values[id] != 'function' && (field = this.findField(id))){
7994 if (field.setFromData &&
7996 field.displayField &&
7997 // combos' with local stores can
7998 // be queried via setValue()
7999 // to set their value..
8000 (field.store && !field.store.isLocal)
8004 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8005 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8006 field.setFromData(sd);
8008 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8010 field.setFromData(values);
8013 field.setValue(values[id]);
8017 if(this.trackResetOnLoad){
8018 field.originalValue = field.getValue();
8024 //Roo.each(this.childForms || [], function (f) {
8025 // f.setValues(values);
8032 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8033 * they are returned as an array.
8034 * @param {Boolean} asString
8037 getValues : function(asString){
8038 //if (this.childForms) {
8039 // copy values from the child forms
8040 // Roo.each(this.childForms, function (f) {
8041 // this.setValues(f.getValues());
8047 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8048 if(asString === true){
8051 return Roo.urlDecode(fs);
8055 * Returns the fields in this form as an object with key/value pairs.
8056 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8059 getFieldValues : function(with_hidden)
8061 var items = this.getItems();
8063 items.each(function(f){
8069 var v = f.getValue();
8071 if (f.inputType =='radio') {
8072 if (typeof(ret[f.getName()]) == 'undefined') {
8073 ret[f.getName()] = ''; // empty..
8076 if (!f.el.dom.checked) {
8084 if(f.xtype == 'MoneyField'){
8085 ret[f.currencyName] = f.getCurrency();
8088 // not sure if this supported any more..
8089 if ((typeof(v) == 'object') && f.getRawValue) {
8090 v = f.getRawValue() ; // dates..
8092 // combo boxes where name != hiddenName...
8093 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8094 ret[f.name] = f.getRawValue();
8096 ret[f.getName()] = v;
8103 * Clears all invalid messages in this form.
8104 * @return {BasicForm} this
8106 clearInvalid : function(){
8107 var items = this.getItems();
8109 items.each(function(f){
8118 * @return {BasicForm} this
8121 var items = this.getItems();
8122 items.each(function(f){
8126 Roo.each(this.childForms || [], function (f) {
8134 getItems : function()
8136 var r=new Roo.util.MixedCollection(false, function(o){
8137 return o.id || (o.id = Roo.id());
8139 var iter = function(el) {
8146 Roo.each(el.items,function(e) {
8155 hideFields : function(items)
8157 Roo.each(items, function(i){
8159 var f = this.findField(i);
8165 if(f.xtype == 'DateField'){
8166 f.setVisible(false);
8175 showFields : function(items)
8177 Roo.each(items, function(i){
8179 var f = this.findField(i);
8185 if(f.xtype == 'DateField'){
8197 Roo.apply(Roo.bootstrap.Form, {
8224 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8225 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8226 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8227 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8230 this.maskEl.top.enableDisplayMode("block");
8231 this.maskEl.left.enableDisplayMode("block");
8232 this.maskEl.bottom.enableDisplayMode("block");
8233 this.maskEl.right.enableDisplayMode("block");
8235 this.toolTip = new Roo.bootstrap.Tooltip({
8236 cls : 'roo-form-error-popover',
8238 'left' : ['r-l', [-2,0], 'right'],
8239 'right' : ['l-r', [2,0], 'left'],
8240 'bottom' : ['tl-bl', [0,2], 'top'],
8241 'top' : [ 'bl-tl', [0,-2], 'bottom']
8245 this.toolTip.render(Roo.get(document.body));
8247 this.toolTip.el.enableDisplayMode("block");
8249 Roo.get(document.body).on('click', function(){
8253 Roo.get(document.body).on('touchstart', function(){
8257 this.isApplied = true
8260 mask : function(form, target)
8264 this.target = target;
8266 if(!this.form.errorMask || !target.el){
8270 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8272 Roo.log(scrollable);
8274 var ot = this.target.el.calcOffsetsTo(scrollable);
8276 var scrollTo = ot[1] - this.form.maskOffset;
8278 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8280 scrollable.scrollTo('top', scrollTo);
8282 var box = this.target.el.getBox();
8284 var zIndex = Roo.bootstrap.Modal.zIndex++;
8287 this.maskEl.top.setStyle('position', 'absolute');
8288 this.maskEl.top.setStyle('z-index', zIndex);
8289 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8290 this.maskEl.top.setLeft(0);
8291 this.maskEl.top.setTop(0);
8292 this.maskEl.top.show();
8294 this.maskEl.left.setStyle('position', 'absolute');
8295 this.maskEl.left.setStyle('z-index', zIndex);
8296 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8297 this.maskEl.left.setLeft(0);
8298 this.maskEl.left.setTop(box.y - this.padding);
8299 this.maskEl.left.show();
8301 this.maskEl.bottom.setStyle('position', 'absolute');
8302 this.maskEl.bottom.setStyle('z-index', zIndex);
8303 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8304 this.maskEl.bottom.setLeft(0);
8305 this.maskEl.bottom.setTop(box.bottom + this.padding);
8306 this.maskEl.bottom.show();
8308 this.maskEl.right.setStyle('position', 'absolute');
8309 this.maskEl.right.setStyle('z-index', zIndex);
8310 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8311 this.maskEl.right.setLeft(box.right + this.padding);
8312 this.maskEl.right.setTop(box.y - this.padding);
8313 this.maskEl.right.show();
8315 this.toolTip.bindEl = this.target.el;
8317 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8319 var tip = this.target.blankText;
8321 if(this.target.getValue() !== '' ) {
8323 if (this.target.invalidText.length) {
8324 tip = this.target.invalidText;
8325 } else if (this.target.regexText.length){
8326 tip = this.target.regexText;
8330 this.toolTip.show(tip);
8332 this.intervalID = window.setInterval(function() {
8333 Roo.bootstrap.Form.popover.unmask();
8336 window.onwheel = function(){ return false;};
8338 (function(){ this.isMasked = true; }).defer(500, this);
8344 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8348 this.maskEl.top.setStyle('position', 'absolute');
8349 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8350 this.maskEl.top.hide();
8352 this.maskEl.left.setStyle('position', 'absolute');
8353 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8354 this.maskEl.left.hide();
8356 this.maskEl.bottom.setStyle('position', 'absolute');
8357 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8358 this.maskEl.bottom.hide();
8360 this.maskEl.right.setStyle('position', 'absolute');
8361 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8362 this.maskEl.right.hide();
8364 this.toolTip.hide();
8366 this.toolTip.el.hide();
8368 window.onwheel = function(){ return true;};
8370 if(this.intervalID){
8371 window.clearInterval(this.intervalID);
8372 this.intervalID = false;
8375 this.isMasked = false;
8385 * Ext JS Library 1.1.1
8386 * Copyright(c) 2006-2007, Ext JS, LLC.
8388 * Originally Released Under LGPL - original licence link has changed is not relivant.
8391 * <script type="text/javascript">
8394 * @class Roo.form.VTypes
8395 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8398 Roo.form.VTypes = function(){
8399 // closure these in so they are only created once.
8400 var alpha = /^[a-zA-Z_]+$/;
8401 var alphanum = /^[a-zA-Z0-9_]+$/;
8402 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8403 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8405 // All these messages and functions are configurable
8408 * The function used to validate email addresses
8409 * @param {String} value The email address
8411 'email' : function(v){
8412 return email.test(v);
8415 * The error text to display when the email validation function returns false
8418 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8420 * The keystroke filter mask to be applied on email input
8423 'emailMask' : /[a-z0-9_\.\-@]/i,
8426 * The function used to validate URLs
8427 * @param {String} value The URL
8429 'url' : function(v){
8433 * The error text to display when the url validation function returns false
8436 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8439 * The function used to validate alpha values
8440 * @param {String} value The value
8442 'alpha' : function(v){
8443 return alpha.test(v);
8446 * The error text to display when the alpha validation function returns false
8449 'alphaText' : 'This field should only contain letters and _',
8451 * The keystroke filter mask to be applied on alpha input
8454 'alphaMask' : /[a-z_]/i,
8457 * The function used to validate alphanumeric values
8458 * @param {String} value The value
8460 'alphanum' : function(v){
8461 return alphanum.test(v);
8464 * The error text to display when the alphanumeric validation function returns false
8467 'alphanumText' : 'This field should only contain letters, numbers and _',
8469 * The keystroke filter mask to be applied on alphanumeric input
8472 'alphanumMask' : /[a-z0-9_]/i
8482 * @class Roo.bootstrap.Input
8483 * @extends Roo.bootstrap.Component
8484 * Bootstrap Input class
8485 * @cfg {Boolean} disabled is it disabled
8486 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8487 * @cfg {String} name name of the input
8488 * @cfg {string} fieldLabel - the label associated
8489 * @cfg {string} placeholder - placeholder to put in text.
8490 * @cfg {string} before - input group add on before
8491 * @cfg {string} after - input group add on after
8492 * @cfg {string} size - (lg|sm) or leave empty..
8493 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8494 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8495 * @cfg {Number} md colspan out of 12 for computer-sized screens
8496 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8497 * @cfg {string} value default value of the input
8498 * @cfg {Number} labelWidth set the width of label
8499 * @cfg {Number} labellg set the width of label (1-12)
8500 * @cfg {Number} labelmd set the width of label (1-12)
8501 * @cfg {Number} labelsm set the width of label (1-12)
8502 * @cfg {Number} labelxs set the width of label (1-12)
8503 * @cfg {String} labelAlign (top|left)
8504 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8505 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8506 * @cfg {String} indicatorpos (left|right) default left
8508 * @cfg {String} align (left|center|right) Default left
8509 * @cfg {Boolean} forceFeedback (true|false) Default false
8515 * Create a new Input
8516 * @param {Object} config The config object
8519 Roo.bootstrap.Input = function(config){
8521 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8526 * Fires when this field receives input focus.
8527 * @param {Roo.form.Field} this
8532 * Fires when this field loses input focus.
8533 * @param {Roo.form.Field} this
8538 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8539 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8540 * @param {Roo.form.Field} this
8541 * @param {Roo.EventObject} e The event object
8546 * Fires just before the field blurs if the field value has changed.
8547 * @param {Roo.form.Field} this
8548 * @param {Mixed} newValue The new value
8549 * @param {Mixed} oldValue The original value
8554 * Fires after the field has been marked as invalid.
8555 * @param {Roo.form.Field} this
8556 * @param {String} msg The validation message
8561 * Fires after the field has been validated with no errors.
8562 * @param {Roo.form.Field} this
8567 * Fires after the key up
8568 * @param {Roo.form.Field} this
8569 * @param {Roo.EventObject} e The event Object
8575 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8577 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8578 automatic validation (defaults to "keyup").
8580 validationEvent : "keyup",
8582 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8584 validateOnBlur : true,
8586 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8588 validationDelay : 250,
8590 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8592 focusClass : "x-form-focus", // not needed???
8596 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8598 invalidClass : "has-warning",
8601 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8603 validClass : "has-success",
8606 * @cfg {Boolean} hasFeedback (true|false) default true
8611 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8613 invalidFeedbackClass : "glyphicon-warning-sign",
8616 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8618 validFeedbackClass : "glyphicon-ok",
8621 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8623 selectOnFocus : false,
8626 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8630 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8635 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8637 disableKeyFilter : false,
8640 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8644 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8648 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8650 blankText : "Please complete this mandatory field",
8653 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8657 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8659 maxLength : Number.MAX_VALUE,
8661 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8663 minLengthText : "The minimum length for this field is {0}",
8665 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8667 maxLengthText : "The maximum length for this field is {0}",
8671 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8672 * If available, this function will be called only after the basic validators all return true, and will be passed the
8673 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8677 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8678 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8679 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8683 * @cfg {String} regexText -- Depricated - use Invalid Text
8688 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8694 autocomplete: false,
8713 formatedValue : false,
8714 forceFeedback : false,
8716 indicatorpos : 'left',
8723 parentLabelAlign : function()
8726 while (parent.parent()) {
8727 parent = parent.parent();
8728 if (typeof(parent.labelAlign) !='undefined') {
8729 return parent.labelAlign;
8736 getAutoCreate : function()
8738 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8744 if(this.inputType != 'hidden'){
8745 cfg.cls = 'form-group' //input-group
8751 type : this.inputType,
8753 cls : 'form-control',
8754 placeholder : this.placeholder || '',
8755 autocomplete : this.autocomplete || 'new-password'
8759 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8762 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8763 input.maxLength = this.maxLength;
8766 if (this.disabled) {
8767 input.disabled=true;
8770 if (this.readOnly) {
8771 input.readonly=true;
8775 input.name = this.name;
8779 input.cls += ' input-' + this.size;
8783 ['xs','sm','md','lg'].map(function(size){
8784 if (settings[size]) {
8785 cfg.cls += ' col-' + size + '-' + settings[size];
8789 var inputblock = input;
8793 cls: 'glyphicon form-control-feedback'
8796 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8799 cls : 'has-feedback',
8807 if (this.before || this.after) {
8810 cls : 'input-group',
8814 if (this.before && typeof(this.before) == 'string') {
8816 inputblock.cn.push({
8818 cls : 'roo-input-before input-group-addon',
8822 if (this.before && typeof(this.before) == 'object') {
8823 this.before = Roo.factory(this.before);
8825 inputblock.cn.push({
8827 cls : 'roo-input-before input-group-' +
8828 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8832 inputblock.cn.push(input);
8834 if (this.after && typeof(this.after) == 'string') {
8835 inputblock.cn.push({
8837 cls : 'roo-input-after input-group-addon',
8841 if (this.after && typeof(this.after) == 'object') {
8842 this.after = Roo.factory(this.after);
8844 inputblock.cn.push({
8846 cls : 'roo-input-after input-group-' +
8847 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8851 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8852 inputblock.cls += ' has-feedback';
8853 inputblock.cn.push(feedback);
8857 if (align ==='left' && this.fieldLabel.length) {
8859 cfg.cls += ' roo-form-group-label-left';
8864 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8865 tooltip : 'This field is required'
8870 cls : 'control-label',
8871 html : this.fieldLabel
8882 var labelCfg = cfg.cn[1];
8883 var contentCfg = cfg.cn[2];
8885 if(this.indicatorpos == 'right'){
8890 cls : 'control-label',
8894 html : this.fieldLabel
8898 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8899 tooltip : 'This field is required'
8912 labelCfg = cfg.cn[0];
8913 contentCfg = cfg.cn[1];
8917 if(this.labelWidth > 12){
8918 labelCfg.style = "width: " + this.labelWidth + 'px';
8921 if(this.labelWidth < 13 && this.labelmd == 0){
8922 this.labelmd = this.labelWidth;
8925 if(this.labellg > 0){
8926 labelCfg.cls += ' col-lg-' + this.labellg;
8927 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8930 if(this.labelmd > 0){
8931 labelCfg.cls += ' col-md-' + this.labelmd;
8932 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8935 if(this.labelsm > 0){
8936 labelCfg.cls += ' col-sm-' + this.labelsm;
8937 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8940 if(this.labelxs > 0){
8941 labelCfg.cls += ' col-xs-' + this.labelxs;
8942 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8946 } else if ( this.fieldLabel.length) {
8951 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8952 tooltip : 'This field is required'
8956 //cls : 'input-group-addon',
8957 html : this.fieldLabel
8965 if(this.indicatorpos == 'right'){
8970 //cls : 'input-group-addon',
8971 html : this.fieldLabel
8976 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8977 tooltip : 'This field is required'
8997 if (this.parentType === 'Navbar' && this.parent().bar) {
8998 cfg.cls += ' navbar-form';
9001 if (this.parentType === 'NavGroup') {
9002 cfg.cls += ' navbar-form';
9010 * return the real input element.
9012 inputEl: function ()
9014 return this.el.select('input.form-control',true).first();
9017 tooltipEl : function()
9019 return this.inputEl();
9022 indicatorEl : function()
9024 var indicator = this.el.select('i.roo-required-indicator',true).first();
9034 setDisabled : function(v)
9036 var i = this.inputEl().dom;
9038 i.removeAttribute('disabled');
9042 i.setAttribute('disabled','true');
9044 initEvents : function()
9047 this.inputEl().on("keydown" , this.fireKey, this);
9048 this.inputEl().on("focus", this.onFocus, this);
9049 this.inputEl().on("blur", this.onBlur, this);
9051 this.inputEl().relayEvent('keyup', this);
9053 this.indicator = this.indicatorEl();
9056 this.indicator.addClass('invisible');
9060 // reference to original value for reset
9061 this.originalValue = this.getValue();
9062 //Roo.form.TextField.superclass.initEvents.call(this);
9063 if(this.validationEvent == 'keyup'){
9064 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9065 this.inputEl().on('keyup', this.filterValidation, this);
9067 else if(this.validationEvent !== false){
9068 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9071 if(this.selectOnFocus){
9072 this.on("focus", this.preFocus, this);
9075 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9076 this.inputEl().on("keypress", this.filterKeys, this);
9078 this.inputEl().relayEvent('keypress', this);
9081 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9082 this.el.on("click", this.autoSize, this);
9085 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9086 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9089 if (typeof(this.before) == 'object') {
9090 this.before.render(this.el.select('.roo-input-before',true).first());
9092 if (typeof(this.after) == 'object') {
9093 this.after.render(this.el.select('.roo-input-after',true).first());
9098 filterValidation : function(e){
9099 if(!e.isNavKeyPress()){
9100 this.validationTask.delay(this.validationDelay);
9104 * Validates the field value
9105 * @return {Boolean} True if the value is valid, else false
9107 validate : function(){
9108 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9109 if(this.disabled || this.validateValue(this.getRawValue())){
9120 * Validates a value according to the field's validation rules and marks the field as invalid
9121 * if the validation fails
9122 * @param {Mixed} value The value to validate
9123 * @return {Boolean} True if the value is valid, else false
9125 validateValue : function(value)
9127 if(this.getEl().hasClass('hidden')){
9131 if(value.length < 1) { // if it's blank
9132 if(this.allowBlank){
9138 if(value.length < this.minLength){
9141 if(value.length > this.maxLength){
9145 var vt = Roo.form.VTypes;
9146 if(!vt[this.vtype](value, this)){
9150 if(typeof this.validator == "function"){
9151 var msg = this.validator(value);
9155 if (typeof(msg) == 'string') {
9156 this.invalidText = msg;
9160 if(this.regex && !this.regex.test(value)){
9168 fireKey : function(e){
9169 //Roo.log('field ' + e.getKey());
9170 if(e.isNavKeyPress()){
9171 this.fireEvent("specialkey", this, e);
9174 focus : function (selectText){
9176 this.inputEl().focus();
9177 if(selectText === true){
9178 this.inputEl().dom.select();
9184 onFocus : function(){
9185 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9186 // this.el.addClass(this.focusClass);
9189 this.hasFocus = true;
9190 this.startValue = this.getValue();
9191 this.fireEvent("focus", this);
9195 beforeBlur : Roo.emptyFn,
9199 onBlur : function(){
9201 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9202 //this.el.removeClass(this.focusClass);
9204 this.hasFocus = false;
9205 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9208 var v = this.getValue();
9209 if(String(v) !== String(this.startValue)){
9210 this.fireEvent('change', this, v, this.startValue);
9212 this.fireEvent("blur", this);
9216 * Resets the current field value to the originally loaded value and clears any validation messages
9219 this.setValue(this.originalValue);
9223 * Returns the name of the field
9224 * @return {Mixed} name The name field
9226 getName: function(){
9230 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9231 * @return {Mixed} value The field value
9233 getValue : function(){
9235 var v = this.inputEl().getValue();
9240 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9241 * @return {Mixed} value The field value
9243 getRawValue : function(){
9244 var v = this.inputEl().getValue();
9250 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9251 * @param {Mixed} value The value to set
9253 setRawValue : function(v){
9254 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9257 selectText : function(start, end){
9258 var v = this.getRawValue();
9260 start = start === undefined ? 0 : start;
9261 end = end === undefined ? v.length : end;
9262 var d = this.inputEl().dom;
9263 if(d.setSelectionRange){
9264 d.setSelectionRange(start, end);
9265 }else if(d.createTextRange){
9266 var range = d.createTextRange();
9267 range.moveStart("character", start);
9268 range.moveEnd("character", v.length-end);
9275 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9276 * @param {Mixed} value The value to set
9278 setValue : function(v){
9281 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9287 processValue : function(value){
9288 if(this.stripCharsRe){
9289 var newValue = value.replace(this.stripCharsRe, '');
9290 if(newValue !== value){
9291 this.setRawValue(newValue);
9298 preFocus : function(){
9300 if(this.selectOnFocus){
9301 this.inputEl().dom.select();
9304 filterKeys : function(e){
9306 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9309 var c = e.getCharCode(), cc = String.fromCharCode(c);
9310 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9313 if(!this.maskRe.test(cc)){
9318 * Clear any invalid styles/messages for this field
9320 clearInvalid : function(){
9322 if(!this.el || this.preventMark){ // not rendered
9327 this.el.removeClass(this.invalidClass);
9329 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9331 var feedback = this.el.select('.form-control-feedback', true).first();
9334 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9339 this.fireEvent('valid', this);
9343 * Mark this field as valid
9345 markValid : function()
9347 if(!this.el || this.preventMark){ // not rendered...
9351 this.el.removeClass([this.invalidClass, this.validClass]);
9353 var feedback = this.el.select('.form-control-feedback', true).first();
9356 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9360 this.indicator.removeClass('visible');
9361 this.indicator.addClass('invisible');
9368 if(this.allowBlank && !this.getRawValue().length){
9372 this.el.addClass(this.validClass);
9374 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9376 var feedback = this.el.select('.form-control-feedback', true).first();
9379 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9380 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9385 this.fireEvent('valid', this);
9389 * Mark this field as invalid
9390 * @param {String} msg The validation message
9392 markInvalid : function(msg)
9394 if(!this.el || this.preventMark){ // not rendered
9398 this.el.removeClass([this.invalidClass, this.validClass]);
9400 var feedback = this.el.select('.form-control-feedback', true).first();
9403 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9410 if(this.allowBlank && !this.getRawValue().length){
9415 this.indicator.removeClass('invisible');
9416 this.indicator.addClass('visible');
9419 this.el.addClass(this.invalidClass);
9421 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9423 var feedback = this.el.select('.form-control-feedback', true).first();
9426 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9428 if(this.getValue().length || this.forceFeedback){
9429 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9436 this.fireEvent('invalid', this, msg);
9439 SafariOnKeyDown : function(event)
9441 // this is a workaround for a password hang bug on chrome/ webkit.
9442 if (this.inputEl().dom.type != 'password') {
9446 var isSelectAll = false;
9448 if(this.inputEl().dom.selectionEnd > 0){
9449 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9451 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9452 event.preventDefault();
9457 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9459 event.preventDefault();
9460 // this is very hacky as keydown always get's upper case.
9462 var cc = String.fromCharCode(event.getCharCode());
9463 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9467 adjustWidth : function(tag, w){
9468 tag = tag.toLowerCase();
9469 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9470 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9474 if(tag == 'textarea'){
9477 }else if(Roo.isOpera){
9481 if(tag == 'textarea'){
9489 setFieldLabel : function(v)
9496 var ar = this.el.select('label > span',true);
9498 if (ar.elements.length) {
9499 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9500 this.fieldLabel = v;
9504 var br = this.el.select('label',true);
9506 if(br.elements.length) {
9507 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9508 this.fieldLabel = v;
9512 Roo.log('Cannot Found any of label > span || label in input');
9516 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9517 this.fieldLabel = v;
9532 * @class Roo.bootstrap.TextArea
9533 * @extends Roo.bootstrap.Input
9534 * Bootstrap TextArea class
9535 * @cfg {Number} cols Specifies the visible width of a text area
9536 * @cfg {Number} rows Specifies the visible number of lines in a text area
9537 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9538 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9539 * @cfg {string} html text
9542 * Create a new TextArea
9543 * @param {Object} config The config object
9546 Roo.bootstrap.TextArea = function(config){
9547 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9551 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9561 getAutoCreate : function(){
9563 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9569 if(this.inputType != 'hidden'){
9570 cfg.cls = 'form-group' //input-group
9578 value : this.value || '',
9579 html: this.html || '',
9580 cls : 'form-control',
9581 placeholder : this.placeholder || ''
9585 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9586 input.maxLength = this.maxLength;
9590 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9594 input.cols = this.cols;
9597 if (this.readOnly) {
9598 input.readonly = true;
9602 input.name = this.name;
9606 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9610 ['xs','sm','md','lg'].map(function(size){
9611 if (settings[size]) {
9612 cfg.cls += ' col-' + size + '-' + settings[size];
9616 var inputblock = input;
9618 if(this.hasFeedback && !this.allowBlank){
9622 cls: 'glyphicon form-control-feedback'
9626 cls : 'has-feedback',
9635 if (this.before || this.after) {
9638 cls : 'input-group',
9642 inputblock.cn.push({
9644 cls : 'input-group-addon',
9649 inputblock.cn.push(input);
9651 if(this.hasFeedback && !this.allowBlank){
9652 inputblock.cls += ' has-feedback';
9653 inputblock.cn.push(feedback);
9657 inputblock.cn.push({
9659 cls : 'input-group-addon',
9666 if (align ==='left' && this.fieldLabel.length) {
9671 cls : 'control-label',
9672 html : this.fieldLabel
9683 if(this.labelWidth > 12){
9684 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9687 if(this.labelWidth < 13 && this.labelmd == 0){
9688 this.labelmd = this.labelWidth;
9691 if(this.labellg > 0){
9692 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9693 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9696 if(this.labelmd > 0){
9697 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9698 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9701 if(this.labelsm > 0){
9702 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9703 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9706 if(this.labelxs > 0){
9707 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9708 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9711 } else if ( this.fieldLabel.length) {
9716 //cls : 'input-group-addon',
9717 html : this.fieldLabel
9735 if (this.disabled) {
9736 input.disabled=true;
9743 * return the real textarea element.
9745 inputEl: function ()
9747 return this.el.select('textarea.form-control',true).first();
9751 * Clear any invalid styles/messages for this field
9753 clearInvalid : function()
9756 if(!this.el || this.preventMark){ // not rendered
9760 var label = this.el.select('label', true).first();
9761 var icon = this.el.select('i.fa-star', true).first();
9767 this.el.removeClass(this.invalidClass);
9769 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9771 var feedback = this.el.select('.form-control-feedback', true).first();
9774 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9779 this.fireEvent('valid', this);
9783 * Mark this field as valid
9785 markValid : function()
9787 if(!this.el || this.preventMark){ // not rendered
9791 this.el.removeClass([this.invalidClass, this.validClass]);
9793 var feedback = this.el.select('.form-control-feedback', true).first();
9796 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9799 if(this.disabled || this.allowBlank){
9803 var label = this.el.select('label', true).first();
9804 var icon = this.el.select('i.fa-star', true).first();
9810 this.el.addClass(this.validClass);
9812 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9814 var feedback = this.el.select('.form-control-feedback', true).first();
9817 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9818 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9823 this.fireEvent('valid', this);
9827 * Mark this field as invalid
9828 * @param {String} msg The validation message
9830 markInvalid : function(msg)
9832 if(!this.el || this.preventMark){ // not rendered
9836 this.el.removeClass([this.invalidClass, this.validClass]);
9838 var feedback = this.el.select('.form-control-feedback', true).first();
9841 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9844 if(this.disabled || this.allowBlank){
9848 var label = this.el.select('label', true).first();
9849 var icon = this.el.select('i.fa-star', true).first();
9851 if(!this.getValue().length && label && !icon){
9852 this.el.createChild({
9854 cls : 'text-danger fa fa-lg fa-star',
9855 tooltip : 'This field is required',
9856 style : 'margin-right:5px;'
9860 this.el.addClass(this.invalidClass);
9862 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9864 var feedback = this.el.select('.form-control-feedback', true).first();
9867 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9869 if(this.getValue().length || this.forceFeedback){
9870 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9877 this.fireEvent('invalid', this, msg);
9885 * trigger field - base class for combo..
9890 * @class Roo.bootstrap.TriggerField
9891 * @extends Roo.bootstrap.Input
9892 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9893 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9894 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9895 * for which you can provide a custom implementation. For example:
9897 var trigger = new Roo.bootstrap.TriggerField();
9898 trigger.onTriggerClick = myTriggerFn;
9899 trigger.applyTo('my-field');
9902 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9903 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9904 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9905 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9906 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9909 * Create a new TriggerField.
9910 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9911 * to the base TextField)
9913 Roo.bootstrap.TriggerField = function(config){
9914 this.mimicing = false;
9915 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9918 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9920 * @cfg {String} triggerClass A CSS class to apply to the trigger
9923 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9928 * @cfg {Boolean} removable (true|false) special filter default false
9932 /** @cfg {Boolean} grow @hide */
9933 /** @cfg {Number} growMin @hide */
9934 /** @cfg {Number} growMax @hide */
9940 autoSize: Roo.emptyFn,
9947 actionMode : 'wrap',
9952 getAutoCreate : function(){
9954 var align = this.labelAlign || this.parentLabelAlign();
9959 cls: 'form-group' //input-group
9966 type : this.inputType,
9967 cls : 'form-control',
9968 autocomplete: 'new-password',
9969 placeholder : this.placeholder || ''
9973 input.name = this.name;
9976 input.cls += ' input-' + this.size;
9979 if (this.disabled) {
9980 input.disabled=true;
9983 var inputblock = input;
9985 if(this.hasFeedback && !this.allowBlank){
9989 cls: 'glyphicon form-control-feedback'
9992 if(this.removable && !this.editable && !this.tickable){
9994 cls : 'has-feedback',
10000 cls : 'roo-combo-removable-btn close'
10007 cls : 'has-feedback',
10016 if(this.removable && !this.editable && !this.tickable){
10018 cls : 'roo-removable',
10024 cls : 'roo-combo-removable-btn close'
10031 if (this.before || this.after) {
10034 cls : 'input-group',
10038 inputblock.cn.push({
10040 cls : 'input-group-addon',
10045 inputblock.cn.push(input);
10047 if(this.hasFeedback && !this.allowBlank){
10048 inputblock.cls += ' has-feedback';
10049 inputblock.cn.push(feedback);
10053 inputblock.cn.push({
10055 cls : 'input-group-addon',
10068 cls: 'form-hidden-field'
10082 cls: 'form-hidden-field'
10086 cls: 'roo-select2-choices',
10090 cls: 'roo-select2-search-field',
10103 cls: 'roo-select2-container input-group',
10108 // cls: 'typeahead typeahead-long dropdown-menu',
10109 // style: 'display:none'
10114 if(!this.multiple && this.showToggleBtn){
10120 if (this.caret != false) {
10123 cls: 'fa fa-' + this.caret
10130 cls : 'input-group-addon btn dropdown-toggle',
10135 cls: 'combobox-clear',
10149 combobox.cls += ' roo-select2-container-multi';
10152 if (align ==='left' && this.fieldLabel.length) {
10154 cfg.cls += ' roo-form-group-label-left';
10159 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10160 tooltip : 'This field is required'
10165 cls : 'control-label',
10166 html : this.fieldLabel
10178 var labelCfg = cfg.cn[1];
10179 var contentCfg = cfg.cn[2];
10181 if(this.indicatorpos == 'right'){
10186 cls : 'control-label',
10190 html : this.fieldLabel
10194 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10195 tooltip : 'This field is required'
10208 labelCfg = cfg.cn[0];
10209 contentCfg = cfg.cn[1];
10212 if(this.labelWidth > 12){
10213 labelCfg.style = "width: " + this.labelWidth + 'px';
10216 if(this.labelWidth < 13 && this.labelmd == 0){
10217 this.labelmd = this.labelWidth;
10220 if(this.labellg > 0){
10221 labelCfg.cls += ' col-lg-' + this.labellg;
10222 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10225 if(this.labelmd > 0){
10226 labelCfg.cls += ' col-md-' + this.labelmd;
10227 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10230 if(this.labelsm > 0){
10231 labelCfg.cls += ' col-sm-' + this.labelsm;
10232 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10235 if(this.labelxs > 0){
10236 labelCfg.cls += ' col-xs-' + this.labelxs;
10237 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10240 } else if ( this.fieldLabel.length) {
10241 // Roo.log(" label");
10245 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10246 tooltip : 'This field is required'
10250 //cls : 'input-group-addon',
10251 html : this.fieldLabel
10259 if(this.indicatorpos == 'right'){
10267 html : this.fieldLabel
10271 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10272 tooltip : 'This field is required'
10285 // Roo.log(" no label && no align");
10292 ['xs','sm','md','lg'].map(function(size){
10293 if (settings[size]) {
10294 cfg.cls += ' col-' + size + '-' + settings[size];
10305 onResize : function(w, h){
10306 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10307 // if(typeof w == 'number'){
10308 // var x = w - this.trigger.getWidth();
10309 // this.inputEl().setWidth(this.adjustWidth('input', x));
10310 // this.trigger.setStyle('left', x+'px');
10315 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10318 getResizeEl : function(){
10319 return this.inputEl();
10323 getPositionEl : function(){
10324 return this.inputEl();
10328 alignErrorIcon : function(){
10329 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10333 initEvents : function(){
10337 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10338 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10339 if(!this.multiple && this.showToggleBtn){
10340 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10341 if(this.hideTrigger){
10342 this.trigger.setDisplayed(false);
10344 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10348 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10351 if(this.removable && !this.editable && !this.tickable){
10352 var close = this.closeTriggerEl();
10355 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10356 close.on('click', this.removeBtnClick, this, close);
10360 //this.trigger.addClassOnOver('x-form-trigger-over');
10361 //this.trigger.addClassOnClick('x-form-trigger-click');
10364 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10368 closeTriggerEl : function()
10370 var close = this.el.select('.roo-combo-removable-btn', true).first();
10371 return close ? close : false;
10374 removeBtnClick : function(e, h, el)
10376 e.preventDefault();
10378 if(this.fireEvent("remove", this) !== false){
10380 this.fireEvent("afterremove", this)
10384 createList : function()
10386 this.list = Roo.get(document.body).createChild({
10388 cls: 'typeahead typeahead-long dropdown-menu',
10389 style: 'display:none'
10392 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10397 initTrigger : function(){
10402 onDestroy : function(){
10404 this.trigger.removeAllListeners();
10405 // this.trigger.remove();
10408 // this.wrap.remove();
10410 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10414 onFocus : function(){
10415 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10417 if(!this.mimicing){
10418 this.wrap.addClass('x-trigger-wrap-focus');
10419 this.mimicing = true;
10420 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10421 if(this.monitorTab){
10422 this.el.on("keydown", this.checkTab, this);
10429 checkTab : function(e){
10430 if(e.getKey() == e.TAB){
10431 this.triggerBlur();
10436 onBlur : function(){
10441 mimicBlur : function(e, t){
10443 if(!this.wrap.contains(t) && this.validateBlur()){
10444 this.triggerBlur();
10450 triggerBlur : function(){
10451 this.mimicing = false;
10452 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10453 if(this.monitorTab){
10454 this.el.un("keydown", this.checkTab, this);
10456 //this.wrap.removeClass('x-trigger-wrap-focus');
10457 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10461 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10462 validateBlur : function(e, t){
10467 onDisable : function(){
10468 this.inputEl().dom.disabled = true;
10469 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10471 // this.wrap.addClass('x-item-disabled');
10476 onEnable : function(){
10477 this.inputEl().dom.disabled = false;
10478 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10480 // this.el.removeClass('x-item-disabled');
10485 onShow : function(){
10486 var ae = this.getActionEl();
10489 ae.dom.style.display = '';
10490 ae.dom.style.visibility = 'visible';
10496 onHide : function(){
10497 var ae = this.getActionEl();
10498 ae.dom.style.display = 'none';
10502 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10503 * by an implementing function.
10505 * @param {EventObject} e
10507 onTriggerClick : Roo.emptyFn
10511 * Ext JS Library 1.1.1
10512 * Copyright(c) 2006-2007, Ext JS, LLC.
10514 * Originally Released Under LGPL - original licence link has changed is not relivant.
10517 * <script type="text/javascript">
10522 * @class Roo.data.SortTypes
10524 * Defines the default sorting (casting?) comparison functions used when sorting data.
10526 Roo.data.SortTypes = {
10528 * Default sort that does nothing
10529 * @param {Mixed} s The value being converted
10530 * @return {Mixed} The comparison value
10532 none : function(s){
10537 * The regular expression used to strip tags
10541 stripTagsRE : /<\/?[^>]+>/gi,
10544 * Strips all HTML tags to sort on text only
10545 * @param {Mixed} s The value being converted
10546 * @return {String} The comparison value
10548 asText : function(s){
10549 return String(s).replace(this.stripTagsRE, "");
10553 * Strips all HTML tags to sort on text only - Case insensitive
10554 * @param {Mixed} s The value being converted
10555 * @return {String} The comparison value
10557 asUCText : function(s){
10558 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10562 * Case insensitive string
10563 * @param {Mixed} s The value being converted
10564 * @return {String} The comparison value
10566 asUCString : function(s) {
10567 return String(s).toUpperCase();
10572 * @param {Mixed} s The value being converted
10573 * @return {Number} The comparison value
10575 asDate : function(s) {
10579 if(s instanceof Date){
10580 return s.getTime();
10582 return Date.parse(String(s));
10587 * @param {Mixed} s The value being converted
10588 * @return {Float} The comparison value
10590 asFloat : function(s) {
10591 var val = parseFloat(String(s).replace(/,/g, ""));
10600 * @param {Mixed} s The value being converted
10601 * @return {Number} The comparison value
10603 asInt : function(s) {
10604 var val = parseInt(String(s).replace(/,/g, ""));
10612 * Ext JS Library 1.1.1
10613 * Copyright(c) 2006-2007, Ext JS, LLC.
10615 * Originally Released Under LGPL - original licence link has changed is not relivant.
10618 * <script type="text/javascript">
10622 * @class Roo.data.Record
10623 * Instances of this class encapsulate both record <em>definition</em> information, and record
10624 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10625 * to access Records cached in an {@link Roo.data.Store} object.<br>
10627 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10628 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10631 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10633 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10634 * {@link #create}. The parameters are the same.
10635 * @param {Array} data An associative Array of data values keyed by the field name.
10636 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10637 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10638 * not specified an integer id is generated.
10640 Roo.data.Record = function(data, id){
10641 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10646 * Generate a constructor for a specific record layout.
10647 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10648 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10649 * Each field definition object may contain the following properties: <ul>
10650 * <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,
10651 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10652 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10653 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10654 * is being used, then this is a string containing the javascript expression to reference the data relative to
10655 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10656 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10657 * this may be omitted.</p></li>
10658 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10659 * <ul><li>auto (Default, implies no conversion)</li>
10664 * <li>date</li></ul></p></li>
10665 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10666 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10667 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10668 * by the Reader into an object that will be stored in the Record. It is passed the
10669 * following parameters:<ul>
10670 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10672 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10674 * <br>usage:<br><pre><code>
10675 var TopicRecord = Roo.data.Record.create(
10676 {name: 'title', mapping: 'topic_title'},
10677 {name: 'author', mapping: 'username'},
10678 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10679 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10680 {name: 'lastPoster', mapping: 'user2'},
10681 {name: 'excerpt', mapping: 'post_text'}
10684 var myNewRecord = new TopicRecord({
10685 title: 'Do my job please',
10688 lastPost: new Date(),
10689 lastPoster: 'Animal',
10690 excerpt: 'No way dude!'
10692 myStore.add(myNewRecord);
10697 Roo.data.Record.create = function(o){
10698 var f = function(){
10699 f.superclass.constructor.apply(this, arguments);
10701 Roo.extend(f, Roo.data.Record);
10702 var p = f.prototype;
10703 p.fields = new Roo.util.MixedCollection(false, function(field){
10706 for(var i = 0, len = o.length; i < len; i++){
10707 p.fields.add(new Roo.data.Field(o[i]));
10709 f.getField = function(name){
10710 return p.fields.get(name);
10715 Roo.data.Record.AUTO_ID = 1000;
10716 Roo.data.Record.EDIT = 'edit';
10717 Roo.data.Record.REJECT = 'reject';
10718 Roo.data.Record.COMMIT = 'commit';
10720 Roo.data.Record.prototype = {
10722 * Readonly flag - true if this record has been modified.
10731 join : function(store){
10732 this.store = store;
10736 * Set the named field to the specified value.
10737 * @param {String} name The name of the field to set.
10738 * @param {Object} value The value to set the field to.
10740 set : function(name, value){
10741 if(this.data[name] == value){
10745 if(!this.modified){
10746 this.modified = {};
10748 if(typeof this.modified[name] == 'undefined'){
10749 this.modified[name] = this.data[name];
10751 this.data[name] = value;
10752 if(!this.editing && this.store){
10753 this.store.afterEdit(this);
10758 * Get the value of the named field.
10759 * @param {String} name The name of the field to get the value of.
10760 * @return {Object} The value of the field.
10762 get : function(name){
10763 return this.data[name];
10767 beginEdit : function(){
10768 this.editing = true;
10769 this.modified = {};
10773 cancelEdit : function(){
10774 this.editing = false;
10775 delete this.modified;
10779 endEdit : function(){
10780 this.editing = false;
10781 if(this.dirty && this.store){
10782 this.store.afterEdit(this);
10787 * Usually called by the {@link Roo.data.Store} which owns the Record.
10788 * Rejects all changes made to the Record since either creation, or the last commit operation.
10789 * Modified fields are reverted to their original values.
10791 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10792 * of reject operations.
10794 reject : function(){
10795 var m = this.modified;
10797 if(typeof m[n] != "function"){
10798 this.data[n] = m[n];
10801 this.dirty = false;
10802 delete this.modified;
10803 this.editing = false;
10805 this.store.afterReject(this);
10810 * Usually called by the {@link Roo.data.Store} which owns the Record.
10811 * Commits all changes made to the Record since either creation, or the last commit operation.
10813 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10814 * of commit operations.
10816 commit : function(){
10817 this.dirty = false;
10818 delete this.modified;
10819 this.editing = false;
10821 this.store.afterCommit(this);
10826 hasError : function(){
10827 return this.error != null;
10831 clearError : function(){
10836 * Creates a copy of this record.
10837 * @param {String} id (optional) A new record id if you don't want to use this record's id
10840 copy : function(newId) {
10841 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10845 * Ext JS Library 1.1.1
10846 * Copyright(c) 2006-2007, Ext JS, LLC.
10848 * Originally Released Under LGPL - original licence link has changed is not relivant.
10851 * <script type="text/javascript">
10857 * @class Roo.data.Store
10858 * @extends Roo.util.Observable
10859 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10860 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10862 * 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
10863 * has no knowledge of the format of the data returned by the Proxy.<br>
10865 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10866 * instances from the data object. These records are cached and made available through accessor functions.
10868 * Creates a new Store.
10869 * @param {Object} config A config object containing the objects needed for the Store to access data,
10870 * and read the data into Records.
10872 Roo.data.Store = function(config){
10873 this.data = new Roo.util.MixedCollection(false);
10874 this.data.getKey = function(o){
10877 this.baseParams = {};
10879 this.paramNames = {
10884 "multisort" : "_multisort"
10887 if(config && config.data){
10888 this.inlineData = config.data;
10889 delete config.data;
10892 Roo.apply(this, config);
10894 if(this.reader){ // reader passed
10895 this.reader = Roo.factory(this.reader, Roo.data);
10896 this.reader.xmodule = this.xmodule || false;
10897 if(!this.recordType){
10898 this.recordType = this.reader.recordType;
10900 if(this.reader.onMetaChange){
10901 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10905 if(this.recordType){
10906 this.fields = this.recordType.prototype.fields;
10908 this.modified = [];
10912 * @event datachanged
10913 * Fires when the data cache has changed, and a widget which is using this Store
10914 * as a Record cache should refresh its view.
10915 * @param {Store} this
10917 datachanged : true,
10919 * @event metachange
10920 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10921 * @param {Store} this
10922 * @param {Object} meta The JSON metadata
10927 * Fires when Records have been added to the Store
10928 * @param {Store} this
10929 * @param {Roo.data.Record[]} records The array of Records added
10930 * @param {Number} index The index at which the record(s) were added
10935 * Fires when a Record has been removed from the Store
10936 * @param {Store} this
10937 * @param {Roo.data.Record} record The Record that was removed
10938 * @param {Number} index The index at which the record was removed
10943 * Fires when a Record has been updated
10944 * @param {Store} this
10945 * @param {Roo.data.Record} record The Record that was updated
10946 * @param {String} operation The update operation being performed. Value may be one of:
10948 Roo.data.Record.EDIT
10949 Roo.data.Record.REJECT
10950 Roo.data.Record.COMMIT
10956 * Fires when the data cache has been cleared.
10957 * @param {Store} this
10961 * @event beforeload
10962 * Fires before a request is made for a new data object. If the beforeload handler returns false
10963 * the load action will be canceled.
10964 * @param {Store} this
10965 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10969 * @event beforeloadadd
10970 * Fires after a new set of Records has been loaded.
10971 * @param {Store} this
10972 * @param {Roo.data.Record[]} records The Records that were loaded
10973 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10975 beforeloadadd : true,
10978 * Fires after a new set of Records has been loaded, before they are added to the store.
10979 * @param {Store} this
10980 * @param {Roo.data.Record[]} records The Records that were loaded
10981 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10982 * @params {Object} return from reader
10986 * @event loadexception
10987 * Fires if an exception occurs in the Proxy during loading.
10988 * Called with the signature of the Proxy's "loadexception" event.
10989 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10992 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10993 * @param {Object} load options
10994 * @param {Object} jsonData from your request (normally this contains the Exception)
10996 loadexception : true
11000 this.proxy = Roo.factory(this.proxy, Roo.data);
11001 this.proxy.xmodule = this.xmodule || false;
11002 this.relayEvents(this.proxy, ["loadexception"]);
11004 this.sortToggle = {};
11005 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11007 Roo.data.Store.superclass.constructor.call(this);
11009 if(this.inlineData){
11010 this.loadData(this.inlineData);
11011 delete this.inlineData;
11015 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11017 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11018 * without a remote query - used by combo/forms at present.
11022 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11025 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11028 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11029 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11032 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11033 * on any HTTP request
11036 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11039 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11043 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11044 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11046 remoteSort : false,
11049 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11050 * loaded or when a record is removed. (defaults to false).
11052 pruneModifiedRecords : false,
11055 lastOptions : null,
11058 * Add Records to the Store and fires the add event.
11059 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11061 add : function(records){
11062 records = [].concat(records);
11063 for(var i = 0, len = records.length; i < len; i++){
11064 records[i].join(this);
11066 var index = this.data.length;
11067 this.data.addAll(records);
11068 this.fireEvent("add", this, records, index);
11072 * Remove a Record from the Store and fires the remove event.
11073 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11075 remove : function(record){
11076 var index = this.data.indexOf(record);
11077 this.data.removeAt(index);
11078 if(this.pruneModifiedRecords){
11079 this.modified.remove(record);
11081 this.fireEvent("remove", this, record, index);
11085 * Remove all Records from the Store and fires the clear event.
11087 removeAll : function(){
11089 if(this.pruneModifiedRecords){
11090 this.modified = [];
11092 this.fireEvent("clear", this);
11096 * Inserts Records to the Store at the given index and fires the add event.
11097 * @param {Number} index The start index at which to insert the passed Records.
11098 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11100 insert : function(index, records){
11101 records = [].concat(records);
11102 for(var i = 0, len = records.length; i < len; i++){
11103 this.data.insert(index, records[i]);
11104 records[i].join(this);
11106 this.fireEvent("add", this, records, index);
11110 * Get the index within the cache of the passed Record.
11111 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11112 * @return {Number} The index of the passed Record. Returns -1 if not found.
11114 indexOf : function(record){
11115 return this.data.indexOf(record);
11119 * Get the index within the cache of the Record with the passed id.
11120 * @param {String} id The id of the Record to find.
11121 * @return {Number} The index of the Record. Returns -1 if not found.
11123 indexOfId : function(id){
11124 return this.data.indexOfKey(id);
11128 * Get the Record with the specified id.
11129 * @param {String} id The id of the Record to find.
11130 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11132 getById : function(id){
11133 return this.data.key(id);
11137 * Get the Record at the specified index.
11138 * @param {Number} index The index of the Record to find.
11139 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11141 getAt : function(index){
11142 return this.data.itemAt(index);
11146 * Returns a range of Records between specified indices.
11147 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11148 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11149 * @return {Roo.data.Record[]} An array of Records
11151 getRange : function(start, end){
11152 return this.data.getRange(start, end);
11156 storeOptions : function(o){
11157 o = Roo.apply({}, o);
11160 this.lastOptions = o;
11164 * Loads the Record cache from the configured Proxy using the configured Reader.
11166 * If using remote paging, then the first load call must specify the <em>start</em>
11167 * and <em>limit</em> properties in the options.params property to establish the initial
11168 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11170 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11171 * and this call will return before the new data has been loaded. Perform any post-processing
11172 * in a callback function, or in a "load" event handler.</strong>
11174 * @param {Object} options An object containing properties which control loading options:<ul>
11175 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11176 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11177 * passed the following arguments:<ul>
11178 * <li>r : Roo.data.Record[]</li>
11179 * <li>options: Options object from the load call</li>
11180 * <li>success: Boolean success indicator</li></ul></li>
11181 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11182 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11185 load : function(options){
11186 options = options || {};
11187 if(this.fireEvent("beforeload", this, options) !== false){
11188 this.storeOptions(options);
11189 var p = Roo.apply(options.params || {}, this.baseParams);
11190 // if meta was not loaded from remote source.. try requesting it.
11191 if (!this.reader.metaFromRemote) {
11192 p._requestMeta = 1;
11194 if(this.sortInfo && this.remoteSort){
11195 var pn = this.paramNames;
11196 p[pn["sort"]] = this.sortInfo.field;
11197 p[pn["dir"]] = this.sortInfo.direction;
11199 if (this.multiSort) {
11200 var pn = this.paramNames;
11201 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11204 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11209 * Reloads the Record cache from the configured Proxy using the configured Reader and
11210 * the options from the last load operation performed.
11211 * @param {Object} options (optional) An object containing properties which may override the options
11212 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11213 * the most recently used options are reused).
11215 reload : function(options){
11216 this.load(Roo.applyIf(options||{}, this.lastOptions));
11220 // Called as a callback by the Reader during a load operation.
11221 loadRecords : function(o, options, success){
11222 if(!o || success === false){
11223 if(success !== false){
11224 this.fireEvent("load", this, [], options, o);
11226 if(options.callback){
11227 options.callback.call(options.scope || this, [], options, false);
11231 // if data returned failure - throw an exception.
11232 if (o.success === false) {
11233 // show a message if no listener is registered.
11234 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11235 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11237 // loadmask wil be hooked into this..
11238 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11241 var r = o.records, t = o.totalRecords || r.length;
11243 this.fireEvent("beforeloadadd", this, r, options, o);
11245 if(!options || options.add !== true){
11246 if(this.pruneModifiedRecords){
11247 this.modified = [];
11249 for(var i = 0, len = r.length; i < len; i++){
11253 this.data = this.snapshot;
11254 delete this.snapshot;
11257 this.data.addAll(r);
11258 this.totalLength = t;
11260 this.fireEvent("datachanged", this);
11262 this.totalLength = Math.max(t, this.data.length+r.length);
11266 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11268 var e = new Roo.data.Record({});
11270 e.set(this.parent.displayField, this.parent.emptyTitle);
11271 e.set(this.parent.valueField, '');
11276 this.fireEvent("load", this, r, options, o);
11277 if(options.callback){
11278 options.callback.call(options.scope || this, r, options, true);
11284 * Loads data from a passed data block. A Reader which understands the format of the data
11285 * must have been configured in the constructor.
11286 * @param {Object} data The data block from which to read the Records. The format of the data expected
11287 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11288 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11290 loadData : function(o, append){
11291 var r = this.reader.readRecords(o);
11292 this.loadRecords(r, {add: append}, true);
11296 * Gets the number of cached records.
11298 * <em>If using paging, this may not be the total size of the dataset. If the data object
11299 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11300 * the data set size</em>
11302 getCount : function(){
11303 return this.data.length || 0;
11307 * Gets the total number of records in the dataset as returned by the server.
11309 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11310 * the dataset size</em>
11312 getTotalCount : function(){
11313 return this.totalLength || 0;
11317 * Returns the sort state of the Store as an object with two properties:
11319 field {String} The name of the field by which the Records are sorted
11320 direction {String} The sort order, "ASC" or "DESC"
11323 getSortState : function(){
11324 return this.sortInfo;
11328 applySort : function(){
11329 if(this.sortInfo && !this.remoteSort){
11330 var s = this.sortInfo, f = s.field;
11331 var st = this.fields.get(f).sortType;
11332 var fn = function(r1, r2){
11333 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11334 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11336 this.data.sort(s.direction, fn);
11337 if(this.snapshot && this.snapshot != this.data){
11338 this.snapshot.sort(s.direction, fn);
11344 * Sets the default sort column and order to be used by the next load operation.
11345 * @param {String} fieldName The name of the field to sort by.
11346 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11348 setDefaultSort : function(field, dir){
11349 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11353 * Sort the Records.
11354 * If remote sorting is used, the sort is performed on the server, and the cache is
11355 * reloaded. If local sorting is used, the cache is sorted internally.
11356 * @param {String} fieldName The name of the field to sort by.
11357 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11359 sort : function(fieldName, dir){
11360 var f = this.fields.get(fieldName);
11362 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11364 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11365 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11370 this.sortToggle[f.name] = dir;
11371 this.sortInfo = {field: f.name, direction: dir};
11372 if(!this.remoteSort){
11374 this.fireEvent("datachanged", this);
11376 this.load(this.lastOptions);
11381 * Calls the specified function for each of the Records in the cache.
11382 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11383 * Returning <em>false</em> aborts and exits the iteration.
11384 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11386 each : function(fn, scope){
11387 this.data.each(fn, scope);
11391 * Gets all records modified since the last commit. Modified records are persisted across load operations
11392 * (e.g., during paging).
11393 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11395 getModifiedRecords : function(){
11396 return this.modified;
11400 createFilterFn : function(property, value, anyMatch){
11401 if(!value.exec){ // not a regex
11402 value = String(value);
11403 if(value.length == 0){
11406 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11408 return function(r){
11409 return value.test(r.data[property]);
11414 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11415 * @param {String} property A field on your records
11416 * @param {Number} start The record index to start at (defaults to 0)
11417 * @param {Number} end The last record index to include (defaults to length - 1)
11418 * @return {Number} The sum
11420 sum : function(property, start, end){
11421 var rs = this.data.items, v = 0;
11422 start = start || 0;
11423 end = (end || end === 0) ? end : rs.length-1;
11425 for(var i = start; i <= end; i++){
11426 v += (rs[i].data[property] || 0);
11432 * Filter the records by a specified property.
11433 * @param {String} field A field on your records
11434 * @param {String/RegExp} value Either a string that the field
11435 * should start with or a RegExp to test against the field
11436 * @param {Boolean} anyMatch True to match any part not just the beginning
11438 filter : function(property, value, anyMatch){
11439 var fn = this.createFilterFn(property, value, anyMatch);
11440 return fn ? this.filterBy(fn) : this.clearFilter();
11444 * Filter by a function. The specified function will be called with each
11445 * record in this data source. If the function returns true the record is included,
11446 * otherwise it is filtered.
11447 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11448 * @param {Object} scope (optional) The scope of the function (defaults to this)
11450 filterBy : function(fn, scope){
11451 this.snapshot = this.snapshot || this.data;
11452 this.data = this.queryBy(fn, scope||this);
11453 this.fireEvent("datachanged", this);
11457 * Query the records by a specified property.
11458 * @param {String} field A field on your records
11459 * @param {String/RegExp} value Either a string that the field
11460 * should start with or a RegExp to test against the field
11461 * @param {Boolean} anyMatch True to match any part not just the beginning
11462 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11464 query : function(property, value, anyMatch){
11465 var fn = this.createFilterFn(property, value, anyMatch);
11466 return fn ? this.queryBy(fn) : this.data.clone();
11470 * Query by a function. The specified function will be called with each
11471 * record in this data source. If the function returns true the record is included
11473 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11474 * @param {Object} scope (optional) The scope of the function (defaults to this)
11475 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11477 queryBy : function(fn, scope){
11478 var data = this.snapshot || this.data;
11479 return data.filterBy(fn, scope||this);
11483 * Collects unique values for a particular dataIndex from this store.
11484 * @param {String} dataIndex The property to collect
11485 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11486 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11487 * @return {Array} An array of the unique values
11489 collect : function(dataIndex, allowNull, bypassFilter){
11490 var d = (bypassFilter === true && this.snapshot) ?
11491 this.snapshot.items : this.data.items;
11492 var v, sv, r = [], l = {};
11493 for(var i = 0, len = d.length; i < len; i++){
11494 v = d[i].data[dataIndex];
11496 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11505 * Revert to a view of the Record cache with no filtering applied.
11506 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11508 clearFilter : function(suppressEvent){
11509 if(this.snapshot && this.snapshot != this.data){
11510 this.data = this.snapshot;
11511 delete this.snapshot;
11512 if(suppressEvent !== true){
11513 this.fireEvent("datachanged", this);
11519 afterEdit : function(record){
11520 if(this.modified.indexOf(record) == -1){
11521 this.modified.push(record);
11523 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11527 afterReject : function(record){
11528 this.modified.remove(record);
11529 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11533 afterCommit : function(record){
11534 this.modified.remove(record);
11535 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11539 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11540 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11542 commitChanges : function(){
11543 var m = this.modified.slice(0);
11544 this.modified = [];
11545 for(var i = 0, len = m.length; i < len; i++){
11551 * Cancel outstanding changes on all changed records.
11553 rejectChanges : function(){
11554 var m = this.modified.slice(0);
11555 this.modified = [];
11556 for(var i = 0, len = m.length; i < len; i++){
11561 onMetaChange : function(meta, rtype, o){
11562 this.recordType = rtype;
11563 this.fields = rtype.prototype.fields;
11564 delete this.snapshot;
11565 this.sortInfo = meta.sortInfo || this.sortInfo;
11566 this.modified = [];
11567 this.fireEvent('metachange', this, this.reader.meta);
11570 moveIndex : function(data, type)
11572 var index = this.indexOf(data);
11574 var newIndex = index + type;
11578 this.insert(newIndex, data);
11583 * Ext JS Library 1.1.1
11584 * Copyright(c) 2006-2007, Ext JS, LLC.
11586 * Originally Released Under LGPL - original licence link has changed is not relivant.
11589 * <script type="text/javascript">
11593 * @class Roo.data.SimpleStore
11594 * @extends Roo.data.Store
11595 * Small helper class to make creating Stores from Array data easier.
11596 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11597 * @cfg {Array} fields An array of field definition objects, or field name strings.
11598 * @cfg {Array} data The multi-dimensional array of data
11600 * @param {Object} config
11602 Roo.data.SimpleStore = function(config){
11603 Roo.data.SimpleStore.superclass.constructor.call(this, {
11605 reader: new Roo.data.ArrayReader({
11608 Roo.data.Record.create(config.fields)
11610 proxy : new Roo.data.MemoryProxy(config.data)
11614 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11616 * Ext JS Library 1.1.1
11617 * Copyright(c) 2006-2007, Ext JS, LLC.
11619 * Originally Released Under LGPL - original licence link has changed is not relivant.
11622 * <script type="text/javascript">
11627 * @extends Roo.data.Store
11628 * @class Roo.data.JsonStore
11629 * Small helper class to make creating Stores for JSON data easier. <br/>
11631 var store = new Roo.data.JsonStore({
11632 url: 'get-images.php',
11634 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11637 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11638 * JsonReader and HttpProxy (unless inline data is provided).</b>
11639 * @cfg {Array} fields An array of field definition objects, or field name strings.
11641 * @param {Object} config
11643 Roo.data.JsonStore = function(c){
11644 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11645 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11646 reader: new Roo.data.JsonReader(c, c.fields)
11649 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11651 * Ext JS Library 1.1.1
11652 * Copyright(c) 2006-2007, Ext JS, LLC.
11654 * Originally Released Under LGPL - original licence link has changed is not relivant.
11657 * <script type="text/javascript">
11661 Roo.data.Field = function(config){
11662 if(typeof config == "string"){
11663 config = {name: config};
11665 Roo.apply(this, config);
11668 this.type = "auto";
11671 var st = Roo.data.SortTypes;
11672 // named sortTypes are supported, here we look them up
11673 if(typeof this.sortType == "string"){
11674 this.sortType = st[this.sortType];
11677 // set default sortType for strings and dates
11678 if(!this.sortType){
11681 this.sortType = st.asUCString;
11684 this.sortType = st.asDate;
11687 this.sortType = st.none;
11692 var stripRe = /[\$,%]/g;
11694 // prebuilt conversion function for this field, instead of
11695 // switching every time we're reading a value
11697 var cv, dateFormat = this.dateFormat;
11702 cv = function(v){ return v; };
11705 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11709 return v !== undefined && v !== null && v !== '' ?
11710 parseInt(String(v).replace(stripRe, ""), 10) : '';
11715 return v !== undefined && v !== null && v !== '' ?
11716 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11721 cv = function(v){ return v === true || v === "true" || v == 1; };
11728 if(v instanceof Date){
11732 if(dateFormat == "timestamp"){
11733 return new Date(v*1000);
11735 return Date.parseDate(v, dateFormat);
11737 var parsed = Date.parse(v);
11738 return parsed ? new Date(parsed) : null;
11747 Roo.data.Field.prototype = {
11755 * Ext JS Library 1.1.1
11756 * Copyright(c) 2006-2007, Ext JS, LLC.
11758 * Originally Released Under LGPL - original licence link has changed is not relivant.
11761 * <script type="text/javascript">
11764 // Base class for reading structured data from a data source. This class is intended to be
11765 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11768 * @class Roo.data.DataReader
11769 * Base class for reading structured data from a data source. This class is intended to be
11770 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11773 Roo.data.DataReader = function(meta, recordType){
11777 this.recordType = recordType instanceof Array ?
11778 Roo.data.Record.create(recordType) : recordType;
11781 Roo.data.DataReader.prototype = {
11783 * Create an empty record
11784 * @param {Object} data (optional) - overlay some values
11785 * @return {Roo.data.Record} record created.
11787 newRow : function(d) {
11789 this.recordType.prototype.fields.each(function(c) {
11791 case 'int' : da[c.name] = 0; break;
11792 case 'date' : da[c.name] = new Date(); break;
11793 case 'float' : da[c.name] = 0.0; break;
11794 case 'boolean' : da[c.name] = false; break;
11795 default : da[c.name] = ""; break;
11799 return new this.recordType(Roo.apply(da, d));
11804 * Ext JS Library 1.1.1
11805 * Copyright(c) 2006-2007, Ext JS, LLC.
11807 * Originally Released Under LGPL - original licence link has changed is not relivant.
11810 * <script type="text/javascript">
11814 * @class Roo.data.DataProxy
11815 * @extends Roo.data.Observable
11816 * This class is an abstract base class for implementations which provide retrieval of
11817 * unformatted data objects.<br>
11819 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11820 * (of the appropriate type which knows how to parse the data object) to provide a block of
11821 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11823 * Custom implementations must implement the load method as described in
11824 * {@link Roo.data.HttpProxy#load}.
11826 Roo.data.DataProxy = function(){
11829 * @event beforeload
11830 * Fires before a network request is made to retrieve a data object.
11831 * @param {Object} This DataProxy object.
11832 * @param {Object} params The params parameter to the load function.
11837 * Fires before the load method's callback is called.
11838 * @param {Object} This DataProxy object.
11839 * @param {Object} o The data object.
11840 * @param {Object} arg The callback argument object passed to the load function.
11844 * @event loadexception
11845 * Fires if an Exception occurs during data retrieval.
11846 * @param {Object} This DataProxy object.
11847 * @param {Object} o The data object.
11848 * @param {Object} arg The callback argument object passed to the load function.
11849 * @param {Object} e The Exception.
11851 loadexception : true
11853 Roo.data.DataProxy.superclass.constructor.call(this);
11856 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11859 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11863 * Ext JS Library 1.1.1
11864 * Copyright(c) 2006-2007, Ext JS, LLC.
11866 * Originally Released Under LGPL - original licence link has changed is not relivant.
11869 * <script type="text/javascript">
11872 * @class Roo.data.MemoryProxy
11873 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11874 * to the Reader when its load method is called.
11876 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11878 Roo.data.MemoryProxy = function(data){
11882 Roo.data.MemoryProxy.superclass.constructor.call(this);
11886 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11889 * Load data from the requested source (in this case an in-memory
11890 * data object passed to the constructor), read the data object into
11891 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11892 * process that block using the passed callback.
11893 * @param {Object} params This parameter is not used by the MemoryProxy class.
11894 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11895 * object into a block of Roo.data.Records.
11896 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11897 * The function must be passed <ul>
11898 * <li>The Record block object</li>
11899 * <li>The "arg" argument from the load function</li>
11900 * <li>A boolean success indicator</li>
11902 * @param {Object} scope The scope in which to call the callback
11903 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11905 load : function(params, reader, callback, scope, arg){
11906 params = params || {};
11909 result = reader.readRecords(this.data);
11911 this.fireEvent("loadexception", this, arg, null, e);
11912 callback.call(scope, null, arg, false);
11915 callback.call(scope, result, arg, true);
11919 update : function(params, records){
11924 * Ext JS Library 1.1.1
11925 * Copyright(c) 2006-2007, Ext JS, LLC.
11927 * Originally Released Under LGPL - original licence link has changed is not relivant.
11930 * <script type="text/javascript">
11933 * @class Roo.data.HttpProxy
11934 * @extends Roo.data.DataProxy
11935 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11936 * configured to reference a certain URL.<br><br>
11938 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11939 * from which the running page was served.<br><br>
11941 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11943 * Be aware that to enable the browser to parse an XML document, the server must set
11944 * the Content-Type header in the HTTP response to "text/xml".
11946 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11947 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11948 * will be used to make the request.
11950 Roo.data.HttpProxy = function(conn){
11951 Roo.data.HttpProxy.superclass.constructor.call(this);
11952 // is conn a conn config or a real conn?
11954 this.useAjax = !conn || !conn.events;
11958 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11959 // thse are take from connection...
11962 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11965 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11966 * extra parameters to each request made by this object. (defaults to undefined)
11969 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11970 * to each request made by this object. (defaults to undefined)
11973 * @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)
11976 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11979 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11985 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11989 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11990 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11991 * a finer-grained basis than the DataProxy events.
11993 getConnection : function(){
11994 return this.useAjax ? Roo.Ajax : this.conn;
11998 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11999 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12000 * process that block using the passed callback.
12001 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12002 * for the request to the remote server.
12003 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12004 * object into a block of Roo.data.Records.
12005 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12006 * The function must be passed <ul>
12007 * <li>The Record block object</li>
12008 * <li>The "arg" argument from the load function</li>
12009 * <li>A boolean success indicator</li>
12011 * @param {Object} scope The scope in which to call the callback
12012 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12014 load : function(params, reader, callback, scope, arg){
12015 if(this.fireEvent("beforeload", this, params) !== false){
12017 params : params || {},
12019 callback : callback,
12024 callback : this.loadResponse,
12028 Roo.applyIf(o, this.conn);
12029 if(this.activeRequest){
12030 Roo.Ajax.abort(this.activeRequest);
12032 this.activeRequest = Roo.Ajax.request(o);
12034 this.conn.request(o);
12037 callback.call(scope||this, null, arg, false);
12042 loadResponse : function(o, success, response){
12043 delete this.activeRequest;
12045 this.fireEvent("loadexception", this, o, response);
12046 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12051 result = o.reader.read(response);
12053 this.fireEvent("loadexception", this, o, response, e);
12054 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12058 this.fireEvent("load", this, o, o.request.arg);
12059 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12063 update : function(dataSet){
12068 updateResponse : function(dataSet){
12073 * Ext JS Library 1.1.1
12074 * Copyright(c) 2006-2007, Ext JS, LLC.
12076 * Originally Released Under LGPL - original licence link has changed is not relivant.
12079 * <script type="text/javascript">
12083 * @class Roo.data.ScriptTagProxy
12084 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12085 * other than the originating domain of the running page.<br><br>
12087 * <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
12088 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12090 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12091 * source code that is used as the source inside a <script> tag.<br><br>
12093 * In order for the browser to process the returned data, the server must wrap the data object
12094 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12095 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12096 * depending on whether the callback name was passed:
12099 boolean scriptTag = false;
12100 String cb = request.getParameter("callback");
12103 response.setContentType("text/javascript");
12105 response.setContentType("application/x-json");
12107 Writer out = response.getWriter();
12109 out.write(cb + "(");
12111 out.print(dataBlock.toJsonString());
12118 * @param {Object} config A configuration object.
12120 Roo.data.ScriptTagProxy = function(config){
12121 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12122 Roo.apply(this, config);
12123 this.head = document.getElementsByTagName("head")[0];
12126 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12128 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12130 * @cfg {String} url The URL from which to request the data object.
12133 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12137 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12138 * the server the name of the callback function set up by the load call to process the returned data object.
12139 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12140 * javascript output which calls this named function passing the data object as its only parameter.
12142 callbackParam : "callback",
12144 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12145 * name to the request.
12150 * Load data from the configured URL, read the data object into
12151 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12152 * process that block using the passed callback.
12153 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12154 * for the request to the remote server.
12155 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12156 * object into a block of Roo.data.Records.
12157 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12158 * The function must be passed <ul>
12159 * <li>The Record block object</li>
12160 * <li>The "arg" argument from the load function</li>
12161 * <li>A boolean success indicator</li>
12163 * @param {Object} scope The scope in which to call the callback
12164 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12166 load : function(params, reader, callback, scope, arg){
12167 if(this.fireEvent("beforeload", this, params) !== false){
12169 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12171 var url = this.url;
12172 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12174 url += "&_dc=" + (new Date().getTime());
12176 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12179 cb : "stcCallback"+transId,
12180 scriptId : "stcScript"+transId,
12184 callback : callback,
12190 window[trans.cb] = function(o){
12191 conn.handleResponse(o, trans);
12194 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12196 if(this.autoAbort !== false){
12200 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12202 var script = document.createElement("script");
12203 script.setAttribute("src", url);
12204 script.setAttribute("type", "text/javascript");
12205 script.setAttribute("id", trans.scriptId);
12206 this.head.appendChild(script);
12208 this.trans = trans;
12210 callback.call(scope||this, null, arg, false);
12215 isLoading : function(){
12216 return this.trans ? true : false;
12220 * Abort the current server request.
12222 abort : function(){
12223 if(this.isLoading()){
12224 this.destroyTrans(this.trans);
12229 destroyTrans : function(trans, isLoaded){
12230 this.head.removeChild(document.getElementById(trans.scriptId));
12231 clearTimeout(trans.timeoutId);
12233 window[trans.cb] = undefined;
12235 delete window[trans.cb];
12238 // if hasn't been loaded, wait for load to remove it to prevent script error
12239 window[trans.cb] = function(){
12240 window[trans.cb] = undefined;
12242 delete window[trans.cb];
12249 handleResponse : function(o, trans){
12250 this.trans = false;
12251 this.destroyTrans(trans, true);
12254 result = trans.reader.readRecords(o);
12256 this.fireEvent("loadexception", this, o, trans.arg, e);
12257 trans.callback.call(trans.scope||window, null, trans.arg, false);
12260 this.fireEvent("load", this, o, trans.arg);
12261 trans.callback.call(trans.scope||window, result, trans.arg, true);
12265 handleFailure : function(trans){
12266 this.trans = false;
12267 this.destroyTrans(trans, false);
12268 this.fireEvent("loadexception", this, null, trans.arg);
12269 trans.callback.call(trans.scope||window, null, trans.arg, false);
12273 * Ext JS Library 1.1.1
12274 * Copyright(c) 2006-2007, Ext JS, LLC.
12276 * Originally Released Under LGPL - original licence link has changed is not relivant.
12279 * <script type="text/javascript">
12283 * @class Roo.data.JsonReader
12284 * @extends Roo.data.DataReader
12285 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12286 * based on mappings in a provided Roo.data.Record constructor.
12288 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12289 * in the reply previously.
12294 var RecordDef = Roo.data.Record.create([
12295 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12296 {name: 'occupation'} // This field will use "occupation" as the mapping.
12298 var myReader = new Roo.data.JsonReader({
12299 totalProperty: "results", // The property which contains the total dataset size (optional)
12300 root: "rows", // The property which contains an Array of row objects
12301 id: "id" // The property within each row object that provides an ID for the record (optional)
12305 * This would consume a JSON file like this:
12307 { 'results': 2, 'rows': [
12308 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12309 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12312 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12313 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12314 * paged from the remote server.
12315 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12316 * @cfg {String} root name of the property which contains the Array of row objects.
12317 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12318 * @cfg {Array} fields Array of field definition objects
12320 * Create a new JsonReader
12321 * @param {Object} meta Metadata configuration options
12322 * @param {Object} recordType Either an Array of field definition objects,
12323 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12325 Roo.data.JsonReader = function(meta, recordType){
12328 // set some defaults:
12329 Roo.applyIf(meta, {
12330 totalProperty: 'total',
12331 successProperty : 'success',
12336 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12338 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12341 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12342 * Used by Store query builder to append _requestMeta to params.
12345 metaFromRemote : false,
12347 * This method is only used by a DataProxy which has retrieved data from a remote server.
12348 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12349 * @return {Object} data A data block which is used by an Roo.data.Store object as
12350 * a cache of Roo.data.Records.
12352 read : function(response){
12353 var json = response.responseText;
12355 var o = /* eval:var:o */ eval("("+json+")");
12357 throw {message: "JsonReader.read: Json object not found"};
12363 this.metaFromRemote = true;
12364 this.meta = o.metaData;
12365 this.recordType = Roo.data.Record.create(o.metaData.fields);
12366 this.onMetaChange(this.meta, this.recordType, o);
12368 return this.readRecords(o);
12371 // private function a store will implement
12372 onMetaChange : function(meta, recordType, o){
12379 simpleAccess: function(obj, subsc) {
12386 getJsonAccessor: function(){
12388 return function(expr) {
12390 return(re.test(expr))
12391 ? new Function("obj", "return obj." + expr)
12396 return Roo.emptyFn;
12401 * Create a data block containing Roo.data.Records from an XML document.
12402 * @param {Object} o An object which contains an Array of row objects in the property specified
12403 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12404 * which contains the total size of the dataset.
12405 * @return {Object} data A data block which is used by an Roo.data.Store object as
12406 * a cache of Roo.data.Records.
12408 readRecords : function(o){
12410 * After any data loads, the raw JSON data is available for further custom processing.
12414 var s = this.meta, Record = this.recordType,
12415 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12417 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12419 if(s.totalProperty) {
12420 this.getTotal = this.getJsonAccessor(s.totalProperty);
12422 if(s.successProperty) {
12423 this.getSuccess = this.getJsonAccessor(s.successProperty);
12425 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12427 var g = this.getJsonAccessor(s.id);
12428 this.getId = function(rec) {
12430 return (r === undefined || r === "") ? null : r;
12433 this.getId = function(){return null;};
12436 for(var jj = 0; jj < fl; jj++){
12438 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12439 this.ef[jj] = this.getJsonAccessor(map);
12443 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12444 if(s.totalProperty){
12445 var vt = parseInt(this.getTotal(o), 10);
12450 if(s.successProperty){
12451 var vs = this.getSuccess(o);
12452 if(vs === false || vs === 'false'){
12457 for(var i = 0; i < c; i++){
12460 var id = this.getId(n);
12461 for(var j = 0; j < fl; j++){
12463 var v = this.ef[j](n);
12465 Roo.log('missing convert for ' + f.name);
12469 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12471 var record = new Record(values, id);
12473 records[i] = record;
12479 totalRecords : totalRecords
12484 * Ext JS Library 1.1.1
12485 * Copyright(c) 2006-2007, Ext JS, LLC.
12487 * Originally Released Under LGPL - original licence link has changed is not relivant.
12490 * <script type="text/javascript">
12494 * @class Roo.data.ArrayReader
12495 * @extends Roo.data.DataReader
12496 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12497 * Each element of that Array represents a row of data fields. The
12498 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12499 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12503 var RecordDef = Roo.data.Record.create([
12504 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12505 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12507 var myReader = new Roo.data.ArrayReader({
12508 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12512 * This would consume an Array like this:
12514 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12516 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12518 * Create a new JsonReader
12519 * @param {Object} meta Metadata configuration options.
12520 * @param {Object} recordType Either an Array of field definition objects
12521 * as specified to {@link Roo.data.Record#create},
12522 * or an {@link Roo.data.Record} object
12523 * created using {@link Roo.data.Record#create}.
12525 Roo.data.ArrayReader = function(meta, recordType){
12526 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12529 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12531 * Create a data block containing Roo.data.Records from an XML document.
12532 * @param {Object} o An Array of row objects which represents the dataset.
12533 * @return {Object} data A data block which is used by an Roo.data.Store object as
12534 * a cache of Roo.data.Records.
12536 readRecords : function(o){
12537 var sid = this.meta ? this.meta.id : null;
12538 var recordType = this.recordType, fields = recordType.prototype.fields;
12541 for(var i = 0; i < root.length; i++){
12544 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12545 for(var j = 0, jlen = fields.length; j < jlen; j++){
12546 var f = fields.items[j];
12547 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12548 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12550 values[f.name] = v;
12552 var record = new recordType(values, id);
12554 records[records.length] = record;
12558 totalRecords : records.length
12567 * @class Roo.bootstrap.ComboBox
12568 * @extends Roo.bootstrap.TriggerField
12569 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12570 * @cfg {Boolean} append (true|false) default false
12571 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12572 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12573 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12574 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12575 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12576 * @cfg {Boolean} animate default true
12577 * @cfg {Boolean} emptyResultText only for touch device
12578 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12579 * @cfg {String} emptyTitle default ''
12581 * Create a new ComboBox.
12582 * @param {Object} config Configuration options
12584 Roo.bootstrap.ComboBox = function(config){
12585 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12589 * Fires when the dropdown list is expanded
12590 * @param {Roo.bootstrap.ComboBox} combo This combo box
12595 * Fires when the dropdown list is collapsed
12596 * @param {Roo.bootstrap.ComboBox} combo This combo box
12600 * @event beforeselect
12601 * Fires before a list item is selected. Return false to cancel the selection.
12602 * @param {Roo.bootstrap.ComboBox} combo This combo box
12603 * @param {Roo.data.Record} record The data record returned from the underlying store
12604 * @param {Number} index The index of the selected item in the dropdown list
12606 'beforeselect' : true,
12609 * Fires when a list item is selected
12610 * @param {Roo.bootstrap.ComboBox} combo This combo box
12611 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12612 * @param {Number} index The index of the selected item in the dropdown list
12616 * @event beforequery
12617 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12618 * The event object passed has these properties:
12619 * @param {Roo.bootstrap.ComboBox} combo This combo box
12620 * @param {String} query The query
12621 * @param {Boolean} forceAll true to force "all" query
12622 * @param {Boolean} cancel true to cancel the query
12623 * @param {Object} e The query event object
12625 'beforequery': true,
12628 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12629 * @param {Roo.bootstrap.ComboBox} combo This combo box
12634 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12635 * @param {Roo.bootstrap.ComboBox} combo This combo box
12636 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12641 * Fires when the remove value from the combobox array
12642 * @param {Roo.bootstrap.ComboBox} combo This combo box
12646 * @event afterremove
12647 * Fires when the remove value from the combobox array
12648 * @param {Roo.bootstrap.ComboBox} combo This combo box
12650 'afterremove' : true,
12652 * @event specialfilter
12653 * Fires when specialfilter
12654 * @param {Roo.bootstrap.ComboBox} combo This combo box
12656 'specialfilter' : true,
12659 * Fires when tick the element
12660 * @param {Roo.bootstrap.ComboBox} combo This combo box
12664 * @event touchviewdisplay
12665 * Fires when touch view require special display (default is using displayField)
12666 * @param {Roo.bootstrap.ComboBox} combo This combo box
12667 * @param {Object} cfg set html .
12669 'touchviewdisplay' : true
12674 this.tickItems = [];
12676 this.selectedIndex = -1;
12677 if(this.mode == 'local'){
12678 if(config.queryDelay === undefined){
12679 this.queryDelay = 10;
12681 if(config.minChars === undefined){
12687 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12690 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12691 * rendering into an Roo.Editor, defaults to false)
12694 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12695 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12698 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12701 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12702 * the dropdown list (defaults to undefined, with no header element)
12706 * @cfg {String/Roo.Template} tpl The template to use to render the output
12710 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12712 listWidth: undefined,
12714 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12715 * mode = 'remote' or 'text' if mode = 'local')
12717 displayField: undefined,
12720 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12721 * mode = 'remote' or 'value' if mode = 'local').
12722 * Note: use of a valueField requires the user make a selection
12723 * in order for a value to be mapped.
12725 valueField: undefined,
12727 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12732 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12733 * field's data value (defaults to the underlying DOM element's name)
12735 hiddenName: undefined,
12737 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12741 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12743 selectedClass: 'active',
12746 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12750 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12751 * anchor positions (defaults to 'tl-bl')
12753 listAlign: 'tl-bl?',
12755 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12759 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12760 * query specified by the allQuery config option (defaults to 'query')
12762 triggerAction: 'query',
12764 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12765 * (defaults to 4, does not apply if editable = false)
12769 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12770 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12774 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12775 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12779 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12780 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12784 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12785 * when editable = true (defaults to false)
12787 selectOnFocus:false,
12789 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12791 queryParam: 'query',
12793 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12794 * when mode = 'remote' (defaults to 'Loading...')
12796 loadingText: 'Loading...',
12798 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12802 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12806 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12807 * traditional select (defaults to true)
12811 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12815 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12819 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12820 * listWidth has a higher value)
12824 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12825 * allow the user to set arbitrary text into the field (defaults to false)
12827 forceSelection:false,
12829 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12830 * if typeAhead = true (defaults to 250)
12832 typeAheadDelay : 250,
12834 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12835 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12837 valueNotFoundText : undefined,
12839 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12841 blockFocus : false,
12844 * @cfg {Boolean} disableClear Disable showing of clear button.
12846 disableClear : false,
12848 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12850 alwaysQuery : false,
12853 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12858 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12860 invalidClass : "has-warning",
12863 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12865 validClass : "has-success",
12868 * @cfg {Boolean} specialFilter (true|false) special filter default false
12870 specialFilter : false,
12873 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12875 mobileTouchView : true,
12878 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12880 useNativeIOS : false,
12882 ios_options : false,
12894 btnPosition : 'right',
12895 triggerList : true,
12896 showToggleBtn : true,
12898 emptyResultText: 'Empty',
12899 triggerText : 'Select',
12902 // element that contains real text value.. (when hidden is used..)
12904 getAutoCreate : function()
12909 * Render classic select for iso
12912 if(Roo.isIOS && this.useNativeIOS){
12913 cfg = this.getAutoCreateNativeIOS();
12921 if(Roo.isTouch && this.mobileTouchView){
12922 cfg = this.getAutoCreateTouchView();
12929 if(!this.tickable){
12930 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12935 * ComboBox with tickable selections
12938 var align = this.labelAlign || this.parentLabelAlign();
12941 cls : 'form-group roo-combobox-tickable' //input-group
12944 var btn_text_select = '';
12945 var btn_text_done = '';
12946 var btn_text_cancel = '';
12948 if (this.btn_text_show) {
12949 btn_text_select = 'Select';
12950 btn_text_done = 'Done';
12951 btn_text_cancel = 'Cancel';
12956 cls : 'tickable-buttons',
12961 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12962 //html : this.triggerText
12963 html: btn_text_select
12969 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12971 html: btn_text_done
12977 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12979 html: btn_text_cancel
12985 buttons.cn.unshift({
12987 cls: 'roo-select2-search-field-input'
12993 Roo.each(buttons.cn, function(c){
12995 c.cls += ' btn-' + _this.size;
12998 if (_this.disabled) {
13009 cls: 'form-hidden-field'
13013 cls: 'roo-select2-choices',
13017 cls: 'roo-select2-search-field',
13028 cls: 'roo-select2-container input-group roo-select2-container-multi',
13033 // cls: 'typeahead typeahead-long dropdown-menu',
13034 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13039 if(this.hasFeedback && !this.allowBlank){
13043 cls: 'glyphicon form-control-feedback'
13046 combobox.cn.push(feedback);
13050 if (align ==='left' && this.fieldLabel.length) {
13052 cfg.cls += ' roo-form-group-label-left';
13057 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13058 tooltip : 'This field is required'
13063 cls : 'control-label',
13064 html : this.fieldLabel
13076 var labelCfg = cfg.cn[1];
13077 var contentCfg = cfg.cn[2];
13080 if(this.indicatorpos == 'right'){
13086 cls : 'control-label',
13090 html : this.fieldLabel
13094 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13095 tooltip : 'This field is required'
13110 labelCfg = cfg.cn[0];
13111 contentCfg = cfg.cn[1];
13115 if(this.labelWidth > 12){
13116 labelCfg.style = "width: " + this.labelWidth + 'px';
13119 if(this.labelWidth < 13 && this.labelmd == 0){
13120 this.labelmd = this.labelWidth;
13123 if(this.labellg > 0){
13124 labelCfg.cls += ' col-lg-' + this.labellg;
13125 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13128 if(this.labelmd > 0){
13129 labelCfg.cls += ' col-md-' + this.labelmd;
13130 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13133 if(this.labelsm > 0){
13134 labelCfg.cls += ' col-sm-' + this.labelsm;
13135 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13138 if(this.labelxs > 0){
13139 labelCfg.cls += ' col-xs-' + this.labelxs;
13140 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13144 } else if ( this.fieldLabel.length) {
13145 // Roo.log(" label");
13149 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13150 tooltip : 'This field is required'
13154 //cls : 'input-group-addon',
13155 html : this.fieldLabel
13160 if(this.indicatorpos == 'right'){
13164 //cls : 'input-group-addon',
13165 html : this.fieldLabel
13169 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13170 tooltip : 'This field is required'
13179 // Roo.log(" no label && no align");
13186 ['xs','sm','md','lg'].map(function(size){
13187 if (settings[size]) {
13188 cfg.cls += ' col-' + size + '-' + settings[size];
13196 _initEventsCalled : false,
13199 initEvents: function()
13201 if (this._initEventsCalled) { // as we call render... prevent looping...
13204 this._initEventsCalled = true;
13207 throw "can not find store for combo";
13210 this.indicator = this.indicatorEl();
13212 this.store = Roo.factory(this.store, Roo.data);
13213 this.store.parent = this;
13215 // if we are building from html. then this element is so complex, that we can not really
13216 // use the rendered HTML.
13217 // so we have to trash and replace the previous code.
13218 if (Roo.XComponent.build_from_html) {
13219 // remove this element....
13220 var e = this.el.dom, k=0;
13221 while (e ) { e = e.previousSibling; ++k;}
13226 this.rendered = false;
13228 this.render(this.parent().getChildContainer(true), k);
13231 if(Roo.isIOS && this.useNativeIOS){
13232 this.initIOSView();
13240 if(Roo.isTouch && this.mobileTouchView){
13241 this.initTouchView();
13246 this.initTickableEvents();
13250 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13252 if(this.hiddenName){
13254 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13256 this.hiddenField.dom.value =
13257 this.hiddenValue !== undefined ? this.hiddenValue :
13258 this.value !== undefined ? this.value : '';
13260 // prevent input submission
13261 this.el.dom.removeAttribute('name');
13262 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13267 // this.el.dom.setAttribute('autocomplete', 'off');
13270 var cls = 'x-combo-list';
13272 //this.list = new Roo.Layer({
13273 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13279 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13280 _this.list.setWidth(lw);
13283 this.list.on('mouseover', this.onViewOver, this);
13284 this.list.on('mousemove', this.onViewMove, this);
13285 this.list.on('scroll', this.onViewScroll, this);
13288 this.list.swallowEvent('mousewheel');
13289 this.assetHeight = 0;
13292 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13293 this.assetHeight += this.header.getHeight();
13296 this.innerList = this.list.createChild({cls:cls+'-inner'});
13297 this.innerList.on('mouseover', this.onViewOver, this);
13298 this.innerList.on('mousemove', this.onViewMove, this);
13299 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13301 if(this.allowBlank && !this.pageSize && !this.disableClear){
13302 this.footer = this.list.createChild({cls:cls+'-ft'});
13303 this.pageTb = new Roo.Toolbar(this.footer);
13307 this.footer = this.list.createChild({cls:cls+'-ft'});
13308 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13309 {pageSize: this.pageSize});
13313 if (this.pageTb && this.allowBlank && !this.disableClear) {
13315 this.pageTb.add(new Roo.Toolbar.Fill(), {
13316 cls: 'x-btn-icon x-btn-clear',
13318 handler: function()
13321 _this.clearValue();
13322 _this.onSelect(false, -1);
13327 this.assetHeight += this.footer.getHeight();
13332 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13335 this.view = new Roo.View(this.list, this.tpl, {
13336 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13338 //this.view.wrapEl.setDisplayed(false);
13339 this.view.on('click', this.onViewClick, this);
13342 this.store.on('beforeload', this.onBeforeLoad, this);
13343 this.store.on('load', this.onLoad, this);
13344 this.store.on('loadexception', this.onLoadException, this);
13346 if(this.resizable){
13347 this.resizer = new Roo.Resizable(this.list, {
13348 pinned:true, handles:'se'
13350 this.resizer.on('resize', function(r, w, h){
13351 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13352 this.listWidth = w;
13353 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13354 this.restrictHeight();
13356 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13359 if(!this.editable){
13360 this.editable = true;
13361 this.setEditable(false);
13366 if (typeof(this.events.add.listeners) != 'undefined') {
13368 this.addicon = this.wrap.createChild(
13369 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13371 this.addicon.on('click', function(e) {
13372 this.fireEvent('add', this);
13375 if (typeof(this.events.edit.listeners) != 'undefined') {
13377 this.editicon = this.wrap.createChild(
13378 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13379 if (this.addicon) {
13380 this.editicon.setStyle('margin-left', '40px');
13382 this.editicon.on('click', function(e) {
13384 // we fire even if inothing is selected..
13385 this.fireEvent('edit', this, this.lastData );
13391 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13392 "up" : function(e){
13393 this.inKeyMode = true;
13397 "down" : function(e){
13398 if(!this.isExpanded()){
13399 this.onTriggerClick();
13401 this.inKeyMode = true;
13406 "enter" : function(e){
13407 // this.onViewClick();
13411 if(this.fireEvent("specialkey", this, e)){
13412 this.onViewClick(false);
13418 "esc" : function(e){
13422 "tab" : function(e){
13425 if(this.fireEvent("specialkey", this, e)){
13426 this.onViewClick(false);
13434 doRelay : function(foo, bar, hname){
13435 if(hname == 'down' || this.scope.isExpanded()){
13436 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13445 this.queryDelay = Math.max(this.queryDelay || 10,
13446 this.mode == 'local' ? 10 : 250);
13449 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13451 if(this.typeAhead){
13452 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13454 if(this.editable !== false){
13455 this.inputEl().on("keyup", this.onKeyUp, this);
13457 if(this.forceSelection){
13458 this.inputEl().on('blur', this.doForce, this);
13462 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13463 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13467 initTickableEvents: function()
13471 if(this.hiddenName){
13473 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13475 this.hiddenField.dom.value =
13476 this.hiddenValue !== undefined ? this.hiddenValue :
13477 this.value !== undefined ? this.value : '';
13479 // prevent input submission
13480 this.el.dom.removeAttribute('name');
13481 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13486 // this.list = this.el.select('ul.dropdown-menu',true).first();
13488 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13489 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13490 if(this.triggerList){
13491 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13494 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13495 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13497 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13498 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13500 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13501 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13503 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13504 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13505 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13508 this.cancelBtn.hide();
13513 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13514 _this.list.setWidth(lw);
13517 this.list.on('mouseover', this.onViewOver, this);
13518 this.list.on('mousemove', this.onViewMove, this);
13520 this.list.on('scroll', this.onViewScroll, this);
13523 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>';
13526 this.view = new Roo.View(this.list, this.tpl, {
13527 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13530 //this.view.wrapEl.setDisplayed(false);
13531 this.view.on('click', this.onViewClick, this);
13535 this.store.on('beforeload', this.onBeforeLoad, this);
13536 this.store.on('load', this.onLoad, this);
13537 this.store.on('loadexception', this.onLoadException, this);
13540 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13541 "up" : function(e){
13542 this.inKeyMode = true;
13546 "down" : function(e){
13547 this.inKeyMode = true;
13551 "enter" : function(e){
13552 if(this.fireEvent("specialkey", this, e)){
13553 this.onViewClick(false);
13559 "esc" : function(e){
13560 this.onTickableFooterButtonClick(e, false, false);
13563 "tab" : function(e){
13564 this.fireEvent("specialkey", this, e);
13566 this.onTickableFooterButtonClick(e, false, false);
13573 doRelay : function(e, fn, key){
13574 if(this.scope.isExpanded()){
13575 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13584 this.queryDelay = Math.max(this.queryDelay || 10,
13585 this.mode == 'local' ? 10 : 250);
13588 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13590 if(this.typeAhead){
13591 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13594 if(this.editable !== false){
13595 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13598 this.indicator = this.indicatorEl();
13600 if(this.indicator){
13601 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13602 this.indicator.hide();
13607 onDestroy : function(){
13609 this.view.setStore(null);
13610 this.view.el.removeAllListeners();
13611 this.view.el.remove();
13612 this.view.purgeListeners();
13615 this.list.dom.innerHTML = '';
13619 this.store.un('beforeload', this.onBeforeLoad, this);
13620 this.store.un('load', this.onLoad, this);
13621 this.store.un('loadexception', this.onLoadException, this);
13623 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13627 fireKey : function(e){
13628 if(e.isNavKeyPress() && !this.list.isVisible()){
13629 this.fireEvent("specialkey", this, e);
13634 onResize: function(w, h){
13635 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13637 // if(typeof w != 'number'){
13638 // // we do not handle it!?!?
13641 // var tw = this.trigger.getWidth();
13642 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13643 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13645 // this.inputEl().setWidth( this.adjustWidth('input', x));
13647 // //this.trigger.setStyle('left', x+'px');
13649 // if(this.list && this.listWidth === undefined){
13650 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13651 // this.list.setWidth(lw);
13652 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13660 * Allow or prevent the user from directly editing the field text. If false is passed,
13661 * the user will only be able to select from the items defined in the dropdown list. This method
13662 * is the runtime equivalent of setting the 'editable' config option at config time.
13663 * @param {Boolean} value True to allow the user to directly edit the field text
13665 setEditable : function(value){
13666 if(value == this.editable){
13669 this.editable = value;
13671 this.inputEl().dom.setAttribute('readOnly', true);
13672 this.inputEl().on('mousedown', this.onTriggerClick, this);
13673 this.inputEl().addClass('x-combo-noedit');
13675 this.inputEl().dom.setAttribute('readOnly', false);
13676 this.inputEl().un('mousedown', this.onTriggerClick, this);
13677 this.inputEl().removeClass('x-combo-noedit');
13683 onBeforeLoad : function(combo,opts){
13684 if(!this.hasFocus){
13688 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13690 this.restrictHeight();
13691 this.selectedIndex = -1;
13695 onLoad : function(){
13697 this.hasQuery = false;
13699 if(!this.hasFocus){
13703 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13704 this.loading.hide();
13707 if(this.store.getCount() > 0){
13710 this.restrictHeight();
13711 if(this.lastQuery == this.allQuery){
13712 if(this.editable && !this.tickable){
13713 this.inputEl().dom.select();
13717 !this.selectByValue(this.value, true) &&
13720 !this.store.lastOptions ||
13721 typeof(this.store.lastOptions.add) == 'undefined' ||
13722 this.store.lastOptions.add != true
13725 this.select(0, true);
13728 if(this.autoFocus){
13731 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13732 this.taTask.delay(this.typeAheadDelay);
13736 this.onEmptyResults();
13742 onLoadException : function()
13744 this.hasQuery = false;
13746 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13747 this.loading.hide();
13750 if(this.tickable && this.editable){
13755 // only causes errors at present
13756 //Roo.log(this.store.reader.jsonData);
13757 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13759 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13765 onTypeAhead : function(){
13766 if(this.store.getCount() > 0){
13767 var r = this.store.getAt(0);
13768 var newValue = r.data[this.displayField];
13769 var len = newValue.length;
13770 var selStart = this.getRawValue().length;
13772 if(selStart != len){
13773 this.setRawValue(newValue);
13774 this.selectText(selStart, newValue.length);
13780 onSelect : function(record, index){
13782 if(this.fireEvent('beforeselect', this, record, index) !== false){
13784 this.setFromData(index > -1 ? record.data : false);
13787 this.fireEvent('select', this, record, index);
13792 * Returns the currently selected field value or empty string if no value is set.
13793 * @return {String} value The selected value
13795 getValue : function()
13797 if(Roo.isIOS && this.useNativeIOS){
13798 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13802 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13805 if(this.valueField){
13806 return typeof this.value != 'undefined' ? this.value : '';
13808 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13812 getRawValue : function()
13814 if(Roo.isIOS && this.useNativeIOS){
13815 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13818 var v = this.inputEl().getValue();
13824 * Clears any text/value currently set in the field
13826 clearValue : function(){
13828 if(this.hiddenField){
13829 this.hiddenField.dom.value = '';
13832 this.setRawValue('');
13833 this.lastSelectionText = '';
13834 this.lastData = false;
13836 var close = this.closeTriggerEl();
13847 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13848 * will be displayed in the field. If the value does not match the data value of an existing item,
13849 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13850 * Otherwise the field will be blank (although the value will still be set).
13851 * @param {String} value The value to match
13853 setValue : function(v)
13855 if(Roo.isIOS && this.useNativeIOS){
13856 this.setIOSValue(v);
13866 if(this.valueField){
13867 var r = this.findRecord(this.valueField, v);
13869 text = r.data[this.displayField];
13870 }else if(this.valueNotFoundText !== undefined){
13871 text = this.valueNotFoundText;
13874 this.lastSelectionText = text;
13875 if(this.hiddenField){
13876 this.hiddenField.dom.value = v;
13878 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13881 var close = this.closeTriggerEl();
13884 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13890 * @property {Object} the last set data for the element
13895 * Sets the value of the field based on a object which is related to the record format for the store.
13896 * @param {Object} value the value to set as. or false on reset?
13898 setFromData : function(o){
13905 var dv = ''; // display value
13906 var vv = ''; // value value..
13908 if (this.displayField) {
13909 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13911 // this is an error condition!!!
13912 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13915 if(this.valueField){
13916 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13919 var close = this.closeTriggerEl();
13922 if(dv.length || vv * 1 > 0){
13924 this.blockFocus=true;
13930 if(this.hiddenField){
13931 this.hiddenField.dom.value = vv;
13933 this.lastSelectionText = dv;
13934 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13938 // no hidden field.. - we store the value in 'value', but still display
13939 // display field!!!!
13940 this.lastSelectionText = dv;
13941 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13948 reset : function(){
13949 // overridden so that last data is reset..
13956 this.setValue(this.originalValue);
13957 //this.clearInvalid();
13958 this.lastData = false;
13960 this.view.clearSelections();
13966 findRecord : function(prop, value){
13968 if(this.store.getCount() > 0){
13969 this.store.each(function(r){
13970 if(r.data[prop] == value){
13980 getName: function()
13982 // returns hidden if it's set..
13983 if (!this.rendered) {return ''};
13984 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13988 onViewMove : function(e, t){
13989 this.inKeyMode = false;
13993 onViewOver : function(e, t){
13994 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13997 var item = this.view.findItemFromChild(t);
14000 var index = this.view.indexOf(item);
14001 this.select(index, false);
14006 onViewClick : function(view, doFocus, el, e)
14008 var index = this.view.getSelectedIndexes()[0];
14010 var r = this.store.getAt(index);
14014 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14021 Roo.each(this.tickItems, function(v,k){
14023 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14025 _this.tickItems.splice(k, 1);
14027 if(typeof(e) == 'undefined' && view == false){
14028 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14040 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14041 this.tickItems.push(r.data);
14044 if(typeof(e) == 'undefined' && view == false){
14045 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14052 this.onSelect(r, index);
14054 if(doFocus !== false && !this.blockFocus){
14055 this.inputEl().focus();
14060 restrictHeight : function(){
14061 //this.innerList.dom.style.height = '';
14062 //var inner = this.innerList.dom;
14063 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14064 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14065 //this.list.beginUpdate();
14066 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14067 this.list.alignTo(this.inputEl(), this.listAlign);
14068 this.list.alignTo(this.inputEl(), this.listAlign);
14069 //this.list.endUpdate();
14073 onEmptyResults : function(){
14075 if(this.tickable && this.editable){
14076 this.hasFocus = false;
14077 this.restrictHeight();
14085 * Returns true if the dropdown list is expanded, else false.
14087 isExpanded : function(){
14088 return this.list.isVisible();
14092 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14093 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14094 * @param {String} value The data value of the item to select
14095 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14096 * selected item if it is not currently in view (defaults to true)
14097 * @return {Boolean} True if the value matched an item in the list, else false
14099 selectByValue : function(v, scrollIntoView){
14100 if(v !== undefined && v !== null){
14101 var r = this.findRecord(this.valueField || this.displayField, v);
14103 this.select(this.store.indexOf(r), scrollIntoView);
14111 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14112 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14113 * @param {Number} index The zero-based index of the list item to select
14114 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14115 * selected item if it is not currently in view (defaults to true)
14117 select : function(index, scrollIntoView){
14118 this.selectedIndex = index;
14119 this.view.select(index);
14120 if(scrollIntoView !== false){
14121 var el = this.view.getNode(index);
14123 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14126 this.list.scrollChildIntoView(el, false);
14132 selectNext : function(){
14133 var ct = this.store.getCount();
14135 if(this.selectedIndex == -1){
14137 }else if(this.selectedIndex < ct-1){
14138 this.select(this.selectedIndex+1);
14144 selectPrev : function(){
14145 var ct = this.store.getCount();
14147 if(this.selectedIndex == -1){
14149 }else if(this.selectedIndex != 0){
14150 this.select(this.selectedIndex-1);
14156 onKeyUp : function(e){
14157 if(this.editable !== false && !e.isSpecialKey()){
14158 this.lastKey = e.getKey();
14159 this.dqTask.delay(this.queryDelay);
14164 validateBlur : function(){
14165 return !this.list || !this.list.isVisible();
14169 initQuery : function(){
14171 var v = this.getRawValue();
14173 if(this.tickable && this.editable){
14174 v = this.tickableInputEl().getValue();
14181 doForce : function(){
14182 if(this.inputEl().dom.value.length > 0){
14183 this.inputEl().dom.value =
14184 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14190 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14191 * query allowing the query action to be canceled if needed.
14192 * @param {String} query The SQL query to execute
14193 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14194 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14195 * saved in the current store (defaults to false)
14197 doQuery : function(q, forceAll){
14199 if(q === undefined || q === null){
14204 forceAll: forceAll,
14208 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14213 forceAll = qe.forceAll;
14214 if(forceAll === true || (q.length >= this.minChars)){
14216 this.hasQuery = true;
14218 if(this.lastQuery != q || this.alwaysQuery){
14219 this.lastQuery = q;
14220 if(this.mode == 'local'){
14221 this.selectedIndex = -1;
14223 this.store.clearFilter();
14226 if(this.specialFilter){
14227 this.fireEvent('specialfilter', this);
14232 this.store.filter(this.displayField, q);
14235 this.store.fireEvent("datachanged", this.store);
14242 this.store.baseParams[this.queryParam] = q;
14244 var options = {params : this.getParams(q)};
14247 options.add = true;
14248 options.params.start = this.page * this.pageSize;
14251 this.store.load(options);
14254 * this code will make the page width larger, at the beginning, the list not align correctly,
14255 * we should expand the list on onLoad
14256 * so command out it
14261 this.selectedIndex = -1;
14266 this.loadNext = false;
14270 getParams : function(q){
14272 //p[this.queryParam] = q;
14276 p.limit = this.pageSize;
14282 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14284 collapse : function(){
14285 if(!this.isExpanded()){
14291 this.hasFocus = false;
14295 this.cancelBtn.hide();
14296 this.trigger.show();
14299 this.tickableInputEl().dom.value = '';
14300 this.tickableInputEl().blur();
14305 Roo.get(document).un('mousedown', this.collapseIf, this);
14306 Roo.get(document).un('mousewheel', this.collapseIf, this);
14307 if (!this.editable) {
14308 Roo.get(document).un('keydown', this.listKeyPress, this);
14310 this.fireEvent('collapse', this);
14316 collapseIf : function(e){
14317 var in_combo = e.within(this.el);
14318 var in_list = e.within(this.list);
14319 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14321 if (in_combo || in_list || is_list) {
14322 //e.stopPropagation();
14327 this.onTickableFooterButtonClick(e, false, false);
14335 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14337 expand : function(){
14339 if(this.isExpanded() || !this.hasFocus){
14343 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14344 this.list.setWidth(lw);
14350 this.restrictHeight();
14354 this.tickItems = Roo.apply([], this.item);
14357 this.cancelBtn.show();
14358 this.trigger.hide();
14361 this.tickableInputEl().focus();
14366 Roo.get(document).on('mousedown', this.collapseIf, this);
14367 Roo.get(document).on('mousewheel', this.collapseIf, this);
14368 if (!this.editable) {
14369 Roo.get(document).on('keydown', this.listKeyPress, this);
14372 this.fireEvent('expand', this);
14376 // Implements the default empty TriggerField.onTriggerClick function
14377 onTriggerClick : function(e)
14379 Roo.log('trigger click');
14381 if(this.disabled || !this.triggerList){
14386 this.loadNext = false;
14388 if(this.isExpanded()){
14390 if (!this.blockFocus) {
14391 this.inputEl().focus();
14395 this.hasFocus = true;
14396 if(this.triggerAction == 'all') {
14397 this.doQuery(this.allQuery, true);
14399 this.doQuery(this.getRawValue());
14401 if (!this.blockFocus) {
14402 this.inputEl().focus();
14407 onTickableTriggerClick : function(e)
14414 this.loadNext = false;
14415 this.hasFocus = true;
14417 if(this.triggerAction == 'all') {
14418 this.doQuery(this.allQuery, true);
14420 this.doQuery(this.getRawValue());
14424 onSearchFieldClick : function(e)
14426 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14427 this.onTickableFooterButtonClick(e, false, false);
14431 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14436 this.loadNext = false;
14437 this.hasFocus = true;
14439 if(this.triggerAction == 'all') {
14440 this.doQuery(this.allQuery, true);
14442 this.doQuery(this.getRawValue());
14446 listKeyPress : function(e)
14448 //Roo.log('listkeypress');
14449 // scroll to first matching element based on key pres..
14450 if (e.isSpecialKey()) {
14453 var k = String.fromCharCode(e.getKey()).toUpperCase();
14456 var csel = this.view.getSelectedNodes();
14457 var cselitem = false;
14459 var ix = this.view.indexOf(csel[0]);
14460 cselitem = this.store.getAt(ix);
14461 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14467 this.store.each(function(v) {
14469 // start at existing selection.
14470 if (cselitem.id == v.id) {
14476 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14477 match = this.store.indexOf(v);
14483 if (match === false) {
14484 return true; // no more action?
14487 this.view.select(match);
14488 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14489 sn.scrollIntoView(sn.dom.parentNode, false);
14492 onViewScroll : function(e, t){
14494 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){
14498 this.hasQuery = true;
14500 this.loading = this.list.select('.loading', true).first();
14502 if(this.loading === null){
14503 this.list.createChild({
14505 cls: 'loading roo-select2-more-results roo-select2-active',
14506 html: 'Loading more results...'
14509 this.loading = this.list.select('.loading', true).first();
14511 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14513 this.loading.hide();
14516 this.loading.show();
14521 this.loadNext = true;
14523 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14528 addItem : function(o)
14530 var dv = ''; // display value
14532 if (this.displayField) {
14533 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14535 // this is an error condition!!!
14536 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14543 var choice = this.choices.createChild({
14545 cls: 'roo-select2-search-choice',
14554 cls: 'roo-select2-search-choice-close fa fa-times',
14559 }, this.searchField);
14561 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14563 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14571 this.inputEl().dom.value = '';
14576 onRemoveItem : function(e, _self, o)
14578 e.preventDefault();
14580 this.lastItem = Roo.apply([], this.item);
14582 var index = this.item.indexOf(o.data) * 1;
14585 Roo.log('not this item?!');
14589 this.item.splice(index, 1);
14594 this.fireEvent('remove', this, e);
14600 syncValue : function()
14602 if(!this.item.length){
14609 Roo.each(this.item, function(i){
14610 if(_this.valueField){
14611 value.push(i[_this.valueField]);
14618 this.value = value.join(',');
14620 if(this.hiddenField){
14621 this.hiddenField.dom.value = this.value;
14624 this.store.fireEvent("datachanged", this.store);
14629 clearItem : function()
14631 if(!this.multiple){
14637 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14645 if(this.tickable && !Roo.isTouch){
14646 this.view.refresh();
14650 inputEl: function ()
14652 if(Roo.isIOS && this.useNativeIOS){
14653 return this.el.select('select.roo-ios-select', true).first();
14656 if(Roo.isTouch && this.mobileTouchView){
14657 return this.el.select('input.form-control',true).first();
14661 return this.searchField;
14664 return this.el.select('input.form-control',true).first();
14667 onTickableFooterButtonClick : function(e, btn, el)
14669 e.preventDefault();
14671 this.lastItem = Roo.apply([], this.item);
14673 if(btn && btn.name == 'cancel'){
14674 this.tickItems = Roo.apply([], this.item);
14683 Roo.each(this.tickItems, function(o){
14691 validate : function()
14693 var v = this.getRawValue();
14696 v = this.getValue();
14699 if(this.disabled || this.allowBlank || v.length){
14704 this.markInvalid();
14708 tickableInputEl : function()
14710 if(!this.tickable || !this.editable){
14711 return this.inputEl();
14714 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14718 getAutoCreateTouchView : function()
14723 cls: 'form-group' //input-group
14729 type : this.inputType,
14730 cls : 'form-control x-combo-noedit',
14731 autocomplete: 'new-password',
14732 placeholder : this.placeholder || '',
14737 input.name = this.name;
14741 input.cls += ' input-' + this.size;
14744 if (this.disabled) {
14745 input.disabled = true;
14756 inputblock.cls += ' input-group';
14758 inputblock.cn.unshift({
14760 cls : 'input-group-addon',
14765 if(this.removable && !this.multiple){
14766 inputblock.cls += ' roo-removable';
14768 inputblock.cn.push({
14771 cls : 'roo-combo-removable-btn close'
14775 if(this.hasFeedback && !this.allowBlank){
14777 inputblock.cls += ' has-feedback';
14779 inputblock.cn.push({
14781 cls: 'glyphicon form-control-feedback'
14788 inputblock.cls += (this.before) ? '' : ' input-group';
14790 inputblock.cn.push({
14792 cls : 'input-group-addon',
14803 cls: 'form-hidden-field'
14817 cls: 'form-hidden-field'
14821 cls: 'roo-select2-choices',
14825 cls: 'roo-select2-search-field',
14838 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14844 if(!this.multiple && this.showToggleBtn){
14851 if (this.caret != false) {
14854 cls: 'fa fa-' + this.caret
14861 cls : 'input-group-addon btn dropdown-toggle',
14866 cls: 'combobox-clear',
14880 combobox.cls += ' roo-select2-container-multi';
14883 var align = this.labelAlign || this.parentLabelAlign();
14885 if (align ==='left' && 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 var labelCfg = cfg.cn[1];
14908 var contentCfg = cfg.cn[2];
14911 if(this.indicatorpos == 'right'){
14916 cls : 'control-label',
14920 html : this.fieldLabel
14924 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14925 tooltip : 'This field is required'
14938 labelCfg = cfg.cn[0];
14939 contentCfg = cfg.cn[1];
14944 if(this.labelWidth > 12){
14945 labelCfg.style = "width: " + this.labelWidth + 'px';
14948 if(this.labelWidth < 13 && this.labelmd == 0){
14949 this.labelmd = this.labelWidth;
14952 if(this.labellg > 0){
14953 labelCfg.cls += ' col-lg-' + this.labellg;
14954 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14957 if(this.labelmd > 0){
14958 labelCfg.cls += ' col-md-' + this.labelmd;
14959 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14962 if(this.labelsm > 0){
14963 labelCfg.cls += ' col-sm-' + this.labelsm;
14964 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14967 if(this.labelxs > 0){
14968 labelCfg.cls += ' col-xs-' + this.labelxs;
14969 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14973 } else if ( this.fieldLabel.length) {
14977 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14978 tooltip : 'This field is required'
14982 cls : 'control-label',
14983 html : this.fieldLabel
14994 if(this.indicatorpos == 'right'){
14998 cls : 'control-label',
14999 html : this.fieldLabel,
15003 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15004 tooltip : 'This field is required'
15021 var settings = this;
15023 ['xs','sm','md','lg'].map(function(size){
15024 if (settings[size]) {
15025 cfg.cls += ' col-' + size + '-' + settings[size];
15032 initTouchView : function()
15034 this.renderTouchView();
15036 this.touchViewEl.on('scroll', function(){
15037 this.el.dom.scrollTop = 0;
15040 this.originalValue = this.getValue();
15042 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15044 this.inputEl().on("click", this.showTouchView, this);
15045 if (this.triggerEl) {
15046 this.triggerEl.on("click", this.showTouchView, this);
15050 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15051 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15053 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15055 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15056 this.store.on('load', this.onTouchViewLoad, this);
15057 this.store.on('loadexception', this.onTouchViewLoadException, this);
15059 if(this.hiddenName){
15061 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15063 this.hiddenField.dom.value =
15064 this.hiddenValue !== undefined ? this.hiddenValue :
15065 this.value !== undefined ? this.value : '';
15067 this.el.dom.removeAttribute('name');
15068 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15072 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15073 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15076 if(this.removable && !this.multiple){
15077 var close = this.closeTriggerEl();
15079 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15080 close.on('click', this.removeBtnClick, this, close);
15084 * fix the bug in Safari iOS8
15086 this.inputEl().on("focus", function(e){
15087 document.activeElement.blur();
15095 renderTouchView : function()
15097 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15098 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15100 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15101 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15103 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15104 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15105 this.touchViewBodyEl.setStyle('overflow', 'auto');
15107 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15108 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15110 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15111 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15115 showTouchView : function()
15121 this.touchViewHeaderEl.hide();
15123 if(this.modalTitle.length){
15124 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15125 this.touchViewHeaderEl.show();
15128 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15129 this.touchViewEl.show();
15131 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15133 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15134 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15136 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15138 if(this.modalTitle.length){
15139 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15142 this.touchViewBodyEl.setHeight(bodyHeight);
15146 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15148 this.touchViewEl.addClass('in');
15151 this.doTouchViewQuery();
15155 hideTouchView : function()
15157 this.touchViewEl.removeClass('in');
15161 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15163 this.touchViewEl.setStyle('display', 'none');
15168 setTouchViewValue : function()
15175 Roo.each(this.tickItems, function(o){
15180 this.hideTouchView();
15183 doTouchViewQuery : function()
15192 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15196 if(!this.alwaysQuery || this.mode == 'local'){
15197 this.onTouchViewLoad();
15204 onTouchViewBeforeLoad : function(combo,opts)
15210 onTouchViewLoad : function()
15212 if(this.store.getCount() < 1){
15213 this.onTouchViewEmptyResults();
15217 this.clearTouchView();
15219 var rawValue = this.getRawValue();
15221 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15223 this.tickItems = [];
15225 this.store.data.each(function(d, rowIndex){
15226 var row = this.touchViewListGroup.createChild(template);
15228 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15229 row.addClass(d.data.cls);
15232 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15235 html : d.data[this.displayField]
15238 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15239 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15242 row.removeClass('selected');
15243 if(!this.multiple && this.valueField &&
15244 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15247 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15248 row.addClass('selected');
15251 if(this.multiple && this.valueField &&
15252 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15256 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15257 this.tickItems.push(d.data);
15260 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15264 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15266 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15268 if(this.modalTitle.length){
15269 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15272 var listHeight = this.touchViewListGroup.getHeight();
15276 if(firstChecked && listHeight > bodyHeight){
15277 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15282 onTouchViewLoadException : function()
15284 this.hideTouchView();
15287 onTouchViewEmptyResults : function()
15289 this.clearTouchView();
15291 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15293 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15297 clearTouchView : function()
15299 this.touchViewListGroup.dom.innerHTML = '';
15302 onTouchViewClick : function(e, el, o)
15304 e.preventDefault();
15307 var rowIndex = o.rowIndex;
15309 var r = this.store.getAt(rowIndex);
15311 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15313 if(!this.multiple){
15314 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15315 c.dom.removeAttribute('checked');
15318 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15320 this.setFromData(r.data);
15322 var close = this.closeTriggerEl();
15328 this.hideTouchView();
15330 this.fireEvent('select', this, r, rowIndex);
15335 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15336 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15337 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15341 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15342 this.addItem(r.data);
15343 this.tickItems.push(r.data);
15347 getAutoCreateNativeIOS : function()
15350 cls: 'form-group' //input-group,
15355 cls : 'roo-ios-select'
15359 combobox.name = this.name;
15362 if (this.disabled) {
15363 combobox.disabled = true;
15366 var settings = this;
15368 ['xs','sm','md','lg'].map(function(size){
15369 if (settings[size]) {
15370 cfg.cls += ' col-' + size + '-' + settings[size];
15380 initIOSView : function()
15382 this.store.on('load', this.onIOSViewLoad, this);
15387 onIOSViewLoad : function()
15389 if(this.store.getCount() < 1){
15393 this.clearIOSView();
15395 if(this.allowBlank) {
15397 var default_text = '-- SELECT --';
15399 if(this.placeholder.length){
15400 default_text = this.placeholder;
15403 if(this.emptyTitle.length){
15404 default_text += ' - ' + this.emptyTitle + ' -';
15407 var opt = this.inputEl().createChild({
15410 html : default_text
15414 o[this.valueField] = 0;
15415 o[this.displayField] = default_text;
15417 this.ios_options.push({
15424 this.store.data.each(function(d, rowIndex){
15428 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15429 html = d.data[this.displayField];
15434 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15435 value = d.data[this.valueField];
15444 if(this.value == d.data[this.valueField]){
15445 option['selected'] = true;
15448 var opt = this.inputEl().createChild(option);
15450 this.ios_options.push({
15457 this.inputEl().on('change', function(){
15458 this.fireEvent('select', this);
15463 clearIOSView: function()
15465 this.inputEl().dom.innerHTML = '';
15467 this.ios_options = [];
15470 setIOSValue: function(v)
15474 if(!this.ios_options){
15478 Roo.each(this.ios_options, function(opts){
15480 opts.el.dom.removeAttribute('selected');
15482 if(opts.data[this.valueField] != v){
15486 opts.el.dom.setAttribute('selected', true);
15492 * @cfg {Boolean} grow
15496 * @cfg {Number} growMin
15500 * @cfg {Number} growMax
15509 Roo.apply(Roo.bootstrap.ComboBox, {
15513 cls: 'modal-header',
15535 cls: 'list-group-item',
15539 cls: 'roo-combobox-list-group-item-value'
15543 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15557 listItemCheckbox : {
15559 cls: 'list-group-item',
15563 cls: 'roo-combobox-list-group-item-value'
15567 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15583 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15588 cls: 'modal-footer',
15596 cls: 'col-xs-6 text-left',
15599 cls: 'btn btn-danger roo-touch-view-cancel',
15605 cls: 'col-xs-6 text-right',
15608 cls: 'btn btn-success roo-touch-view-ok',
15619 Roo.apply(Roo.bootstrap.ComboBox, {
15621 touchViewTemplate : {
15623 cls: 'modal fade roo-combobox-touch-view',
15627 cls: 'modal-dialog',
15628 style : 'position:fixed', // we have to fix position....
15632 cls: 'modal-content',
15634 Roo.bootstrap.ComboBox.header,
15635 Roo.bootstrap.ComboBox.body,
15636 Roo.bootstrap.ComboBox.footer
15645 * Ext JS Library 1.1.1
15646 * Copyright(c) 2006-2007, Ext JS, LLC.
15648 * Originally Released Under LGPL - original licence link has changed is not relivant.
15651 * <script type="text/javascript">
15656 * @extends Roo.util.Observable
15657 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15658 * This class also supports single and multi selection modes. <br>
15659 * Create a data model bound view:
15661 var store = new Roo.data.Store(...);
15663 var view = new Roo.View({
15665 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15667 singleSelect: true,
15668 selectedClass: "ydataview-selected",
15672 // listen for node click?
15673 view.on("click", function(vw, index, node, e){
15674 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15678 dataModel.load("foobar.xml");
15680 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15682 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15683 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15685 * Note: old style constructor is still suported (container, template, config)
15688 * Create a new View
15689 * @param {Object} config The config object
15692 Roo.View = function(config, depreciated_tpl, depreciated_config){
15694 this.parent = false;
15696 if (typeof(depreciated_tpl) == 'undefined') {
15697 // new way.. - universal constructor.
15698 Roo.apply(this, config);
15699 this.el = Roo.get(this.el);
15702 this.el = Roo.get(config);
15703 this.tpl = depreciated_tpl;
15704 Roo.apply(this, depreciated_config);
15706 this.wrapEl = this.el.wrap().wrap();
15707 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15710 if(typeof(this.tpl) == "string"){
15711 this.tpl = new Roo.Template(this.tpl);
15713 // support xtype ctors..
15714 this.tpl = new Roo.factory(this.tpl, Roo);
15718 this.tpl.compile();
15723 * @event beforeclick
15724 * Fires before a click is processed. Returns false to cancel the default action.
15725 * @param {Roo.View} this
15726 * @param {Number} index The index of the target node
15727 * @param {HTMLElement} node The target node
15728 * @param {Roo.EventObject} e The raw event object
15730 "beforeclick" : true,
15733 * Fires when a template node is clicked.
15734 * @param {Roo.View} this
15735 * @param {Number} index The index of the target node
15736 * @param {HTMLElement} node The target node
15737 * @param {Roo.EventObject} e The raw event object
15742 * Fires when a template node is double clicked.
15743 * @param {Roo.View} this
15744 * @param {Number} index The index of the target node
15745 * @param {HTMLElement} node The target node
15746 * @param {Roo.EventObject} e The raw event object
15750 * @event contextmenu
15751 * Fires when a template node is right clicked.
15752 * @param {Roo.View} this
15753 * @param {Number} index The index of the target node
15754 * @param {HTMLElement} node The target node
15755 * @param {Roo.EventObject} e The raw event object
15757 "contextmenu" : true,
15759 * @event selectionchange
15760 * Fires when the selected nodes change.
15761 * @param {Roo.View} this
15762 * @param {Array} selections Array of the selected nodes
15764 "selectionchange" : true,
15767 * @event beforeselect
15768 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15769 * @param {Roo.View} this
15770 * @param {HTMLElement} node The node to be selected
15771 * @param {Array} selections Array of currently selected nodes
15773 "beforeselect" : true,
15775 * @event preparedata
15776 * Fires on every row to render, to allow you to change the data.
15777 * @param {Roo.View} this
15778 * @param {Object} data to be rendered (change this)
15780 "preparedata" : true
15788 "click": this.onClick,
15789 "dblclick": this.onDblClick,
15790 "contextmenu": this.onContextMenu,
15794 this.selections = [];
15796 this.cmp = new Roo.CompositeElementLite([]);
15798 this.store = Roo.factory(this.store, Roo.data);
15799 this.setStore(this.store, true);
15802 if ( this.footer && this.footer.xtype) {
15804 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15806 this.footer.dataSource = this.store;
15807 this.footer.container = fctr;
15808 this.footer = Roo.factory(this.footer, Roo);
15809 fctr.insertFirst(this.el);
15811 // this is a bit insane - as the paging toolbar seems to detach the el..
15812 // dom.parentNode.parentNode.parentNode
15813 // they get detached?
15817 Roo.View.superclass.constructor.call(this);
15822 Roo.extend(Roo.View, Roo.util.Observable, {
15825 * @cfg {Roo.data.Store} store Data store to load data from.
15830 * @cfg {String|Roo.Element} el The container element.
15835 * @cfg {String|Roo.Template} tpl The template used by this View
15839 * @cfg {String} dataName the named area of the template to use as the data area
15840 * Works with domtemplates roo-name="name"
15844 * @cfg {String} selectedClass The css class to add to selected nodes
15846 selectedClass : "x-view-selected",
15848 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15853 * @cfg {String} text to display on mask (default Loading)
15857 * @cfg {Boolean} multiSelect Allow multiple selection
15859 multiSelect : false,
15861 * @cfg {Boolean} singleSelect Allow single selection
15863 singleSelect: false,
15866 * @cfg {Boolean} toggleSelect - selecting
15868 toggleSelect : false,
15871 * @cfg {Boolean} tickable - selecting
15876 * Returns the element this view is bound to.
15877 * @return {Roo.Element}
15879 getEl : function(){
15880 return this.wrapEl;
15886 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15888 refresh : function(){
15889 //Roo.log('refresh');
15892 // if we are using something like 'domtemplate', then
15893 // the what gets used is:
15894 // t.applySubtemplate(NAME, data, wrapping data..)
15895 // the outer template then get' applied with
15896 // the store 'extra data'
15897 // and the body get's added to the
15898 // roo-name="data" node?
15899 // <span class='roo-tpl-{name}'></span> ?????
15903 this.clearSelections();
15904 this.el.update("");
15906 var records = this.store.getRange();
15907 if(records.length < 1) {
15909 // is this valid?? = should it render a template??
15911 this.el.update(this.emptyText);
15915 if (this.dataName) {
15916 this.el.update(t.apply(this.store.meta)); //????
15917 el = this.el.child('.roo-tpl-' + this.dataName);
15920 for(var i = 0, len = records.length; i < len; i++){
15921 var data = this.prepareData(records[i].data, i, records[i]);
15922 this.fireEvent("preparedata", this, data, i, records[i]);
15924 var d = Roo.apply({}, data);
15927 Roo.apply(d, {'roo-id' : Roo.id()});
15931 Roo.each(this.parent.item, function(item){
15932 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15935 Roo.apply(d, {'roo-data-checked' : 'checked'});
15939 html[html.length] = Roo.util.Format.trim(
15941 t.applySubtemplate(this.dataName, d, this.store.meta) :
15948 el.update(html.join(""));
15949 this.nodes = el.dom.childNodes;
15950 this.updateIndexes(0);
15955 * Function to override to reformat the data that is sent to
15956 * the template for each node.
15957 * DEPRICATED - use the preparedata event handler.
15958 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15959 * a JSON object for an UpdateManager bound view).
15961 prepareData : function(data, index, record)
15963 this.fireEvent("preparedata", this, data, index, record);
15967 onUpdate : function(ds, record){
15968 // Roo.log('on update');
15969 this.clearSelections();
15970 var index = this.store.indexOf(record);
15971 var n = this.nodes[index];
15972 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15973 n.parentNode.removeChild(n);
15974 this.updateIndexes(index, index);
15980 onAdd : function(ds, records, index)
15982 //Roo.log(['on Add', ds, records, index] );
15983 this.clearSelections();
15984 if(this.nodes.length == 0){
15988 var n = this.nodes[index];
15989 for(var i = 0, len = records.length; i < len; i++){
15990 var d = this.prepareData(records[i].data, i, records[i]);
15992 this.tpl.insertBefore(n, d);
15995 this.tpl.append(this.el, d);
15998 this.updateIndexes(index);
16001 onRemove : function(ds, record, index){
16002 // Roo.log('onRemove');
16003 this.clearSelections();
16004 var el = this.dataName ?
16005 this.el.child('.roo-tpl-' + this.dataName) :
16008 el.dom.removeChild(this.nodes[index]);
16009 this.updateIndexes(index);
16013 * Refresh an individual node.
16014 * @param {Number} index
16016 refreshNode : function(index){
16017 this.onUpdate(this.store, this.store.getAt(index));
16020 updateIndexes : function(startIndex, endIndex){
16021 var ns = this.nodes;
16022 startIndex = startIndex || 0;
16023 endIndex = endIndex || ns.length - 1;
16024 for(var i = startIndex; i <= endIndex; i++){
16025 ns[i].nodeIndex = i;
16030 * Changes the data store this view uses and refresh the view.
16031 * @param {Store} store
16033 setStore : function(store, initial){
16034 if(!initial && this.store){
16035 this.store.un("datachanged", this.refresh);
16036 this.store.un("add", this.onAdd);
16037 this.store.un("remove", this.onRemove);
16038 this.store.un("update", this.onUpdate);
16039 this.store.un("clear", this.refresh);
16040 this.store.un("beforeload", this.onBeforeLoad);
16041 this.store.un("load", this.onLoad);
16042 this.store.un("loadexception", this.onLoad);
16046 store.on("datachanged", this.refresh, this);
16047 store.on("add", this.onAdd, this);
16048 store.on("remove", this.onRemove, this);
16049 store.on("update", this.onUpdate, this);
16050 store.on("clear", this.refresh, this);
16051 store.on("beforeload", this.onBeforeLoad, this);
16052 store.on("load", this.onLoad, this);
16053 store.on("loadexception", this.onLoad, this);
16061 * onbeforeLoad - masks the loading area.
16064 onBeforeLoad : function(store,opts)
16066 //Roo.log('onBeforeLoad');
16068 this.el.update("");
16070 this.el.mask(this.mask ? this.mask : "Loading" );
16072 onLoad : function ()
16079 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16080 * @param {HTMLElement} node
16081 * @return {HTMLElement} The template node
16083 findItemFromChild : function(node){
16084 var el = this.dataName ?
16085 this.el.child('.roo-tpl-' + this.dataName,true) :
16088 if(!node || node.parentNode == el){
16091 var p = node.parentNode;
16092 while(p && p != el){
16093 if(p.parentNode == el){
16102 onClick : function(e){
16103 var item = this.findItemFromChild(e.getTarget());
16105 var index = this.indexOf(item);
16106 if(this.onItemClick(item, index, e) !== false){
16107 this.fireEvent("click", this, index, item, e);
16110 this.clearSelections();
16115 onContextMenu : function(e){
16116 var item = this.findItemFromChild(e.getTarget());
16118 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16123 onDblClick : function(e){
16124 var item = this.findItemFromChild(e.getTarget());
16126 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16130 onItemClick : function(item, index, e)
16132 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16135 if (this.toggleSelect) {
16136 var m = this.isSelected(item) ? 'unselect' : 'select';
16139 _t[m](item, true, false);
16142 if(this.multiSelect || this.singleSelect){
16143 if(this.multiSelect && e.shiftKey && this.lastSelection){
16144 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16146 this.select(item, this.multiSelect && e.ctrlKey);
16147 this.lastSelection = item;
16150 if(!this.tickable){
16151 e.preventDefault();
16159 * Get the number of selected nodes.
16162 getSelectionCount : function(){
16163 return this.selections.length;
16167 * Get the currently selected nodes.
16168 * @return {Array} An array of HTMLElements
16170 getSelectedNodes : function(){
16171 return this.selections;
16175 * Get the indexes of the selected nodes.
16178 getSelectedIndexes : function(){
16179 var indexes = [], s = this.selections;
16180 for(var i = 0, len = s.length; i < len; i++){
16181 indexes.push(s[i].nodeIndex);
16187 * Clear all selections
16188 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16190 clearSelections : function(suppressEvent){
16191 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16192 this.cmp.elements = this.selections;
16193 this.cmp.removeClass(this.selectedClass);
16194 this.selections = [];
16195 if(!suppressEvent){
16196 this.fireEvent("selectionchange", this, this.selections);
16202 * Returns true if the passed node is selected
16203 * @param {HTMLElement/Number} node The node or node index
16204 * @return {Boolean}
16206 isSelected : function(node){
16207 var s = this.selections;
16211 node = this.getNode(node);
16212 return s.indexOf(node) !== -1;
16217 * @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
16218 * @param {Boolean} keepExisting (optional) true to keep existing selections
16219 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16221 select : function(nodeInfo, keepExisting, suppressEvent){
16222 if(nodeInfo instanceof Array){
16224 this.clearSelections(true);
16226 for(var i = 0, len = nodeInfo.length; i < len; i++){
16227 this.select(nodeInfo[i], true, true);
16231 var node = this.getNode(nodeInfo);
16232 if(!node || this.isSelected(node)){
16233 return; // already selected.
16236 this.clearSelections(true);
16239 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16240 Roo.fly(node).addClass(this.selectedClass);
16241 this.selections.push(node);
16242 if(!suppressEvent){
16243 this.fireEvent("selectionchange", this, this.selections);
16251 * @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
16252 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16253 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16255 unselect : function(nodeInfo, keepExisting, suppressEvent)
16257 if(nodeInfo instanceof Array){
16258 Roo.each(this.selections, function(s) {
16259 this.unselect(s, nodeInfo);
16263 var node = this.getNode(nodeInfo);
16264 if(!node || !this.isSelected(node)){
16265 //Roo.log("not selected");
16266 return; // not selected.
16270 Roo.each(this.selections, function(s) {
16272 Roo.fly(node).removeClass(this.selectedClass);
16279 this.selections= ns;
16280 this.fireEvent("selectionchange", this, this.selections);
16284 * Gets a template node.
16285 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16286 * @return {HTMLElement} The node or null if it wasn't found
16288 getNode : function(nodeInfo){
16289 if(typeof nodeInfo == "string"){
16290 return document.getElementById(nodeInfo);
16291 }else if(typeof nodeInfo == "number"){
16292 return this.nodes[nodeInfo];
16298 * Gets a range template nodes.
16299 * @param {Number} startIndex
16300 * @param {Number} endIndex
16301 * @return {Array} An array of nodes
16303 getNodes : function(start, end){
16304 var ns = this.nodes;
16305 start = start || 0;
16306 end = typeof end == "undefined" ? ns.length - 1 : end;
16309 for(var i = start; i <= end; i++){
16313 for(var i = start; i >= end; i--){
16321 * Finds the index of the passed node
16322 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16323 * @return {Number} The index of the node or -1
16325 indexOf : function(node){
16326 node = this.getNode(node);
16327 if(typeof node.nodeIndex == "number"){
16328 return node.nodeIndex;
16330 var ns = this.nodes;
16331 for(var i = 0, len = ns.length; i < len; i++){
16342 * based on jquery fullcalendar
16346 Roo.bootstrap = Roo.bootstrap || {};
16348 * @class Roo.bootstrap.Calendar
16349 * @extends Roo.bootstrap.Component
16350 * Bootstrap Calendar class
16351 * @cfg {Boolean} loadMask (true|false) default false
16352 * @cfg {Object} header generate the user specific header of the calendar, default false
16355 * Create a new Container
16356 * @param {Object} config The config object
16361 Roo.bootstrap.Calendar = function(config){
16362 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16366 * Fires when a date is selected
16367 * @param {DatePicker} this
16368 * @param {Date} date The selected date
16372 * @event monthchange
16373 * Fires when the displayed month changes
16374 * @param {DatePicker} this
16375 * @param {Date} date The selected month
16377 'monthchange': true,
16379 * @event evententer
16380 * Fires when mouse over an event
16381 * @param {Calendar} this
16382 * @param {event} Event
16384 'evententer': true,
16386 * @event eventleave
16387 * Fires when the mouse leaves an
16388 * @param {Calendar} this
16391 'eventleave': true,
16393 * @event eventclick
16394 * Fires when the mouse click an
16395 * @param {Calendar} this
16404 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16407 * @cfg {Number} startDay
16408 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16416 getAutoCreate : function(){
16419 var fc_button = function(name, corner, style, content ) {
16420 return Roo.apply({},{
16422 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16424 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16427 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16438 style : 'width:100%',
16445 cls : 'fc-header-left',
16447 fc_button('prev', 'left', 'arrow', '‹' ),
16448 fc_button('next', 'right', 'arrow', '›' ),
16449 { tag: 'span', cls: 'fc-header-space' },
16450 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16458 cls : 'fc-header-center',
16462 cls: 'fc-header-title',
16465 html : 'month / year'
16473 cls : 'fc-header-right',
16475 /* fc_button('month', 'left', '', 'month' ),
16476 fc_button('week', '', '', 'week' ),
16477 fc_button('day', 'right', '', 'day' )
16489 header = this.header;
16492 var cal_heads = function() {
16494 // fixme - handle this.
16496 for (var i =0; i < Date.dayNames.length; i++) {
16497 var d = Date.dayNames[i];
16500 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16501 html : d.substring(0,3)
16505 ret[0].cls += ' fc-first';
16506 ret[6].cls += ' fc-last';
16509 var cal_cell = function(n) {
16512 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16517 cls: 'fc-day-number',
16521 cls: 'fc-day-content',
16525 style: 'position: relative;' // height: 17px;
16537 var cal_rows = function() {
16540 for (var r = 0; r < 6; r++) {
16547 for (var i =0; i < Date.dayNames.length; i++) {
16548 var d = Date.dayNames[i];
16549 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16552 row.cn[0].cls+=' fc-first';
16553 row.cn[0].cn[0].style = 'min-height:90px';
16554 row.cn[6].cls+=' fc-last';
16558 ret[0].cls += ' fc-first';
16559 ret[4].cls += ' fc-prev-last';
16560 ret[5].cls += ' fc-last';
16567 cls: 'fc-border-separate',
16568 style : 'width:100%',
16576 cls : 'fc-first fc-last',
16594 cls : 'fc-content',
16595 style : "position: relative;",
16598 cls : 'fc-view fc-view-month fc-grid',
16599 style : 'position: relative',
16600 unselectable : 'on',
16603 cls : 'fc-event-container',
16604 style : 'position:absolute;z-index:8;top:0;left:0;'
16622 initEvents : function()
16625 throw "can not find store for calendar";
16631 style: "text-align:center",
16635 style: "background-color:white;width:50%;margin:250 auto",
16639 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16650 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16652 var size = this.el.select('.fc-content', true).first().getSize();
16653 this.maskEl.setSize(size.width, size.height);
16654 this.maskEl.enableDisplayMode("block");
16655 if(!this.loadMask){
16656 this.maskEl.hide();
16659 this.store = Roo.factory(this.store, Roo.data);
16660 this.store.on('load', this.onLoad, this);
16661 this.store.on('beforeload', this.onBeforeLoad, this);
16665 this.cells = this.el.select('.fc-day',true);
16666 //Roo.log(this.cells);
16667 this.textNodes = this.el.query('.fc-day-number');
16668 this.cells.addClassOnOver('fc-state-hover');
16670 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16671 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16672 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16673 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16675 this.on('monthchange', this.onMonthChange, this);
16677 this.update(new Date().clearTime());
16680 resize : function() {
16681 var sz = this.el.getSize();
16683 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16684 this.el.select('.fc-day-content div',true).setHeight(34);
16689 showPrevMonth : function(e){
16690 this.update(this.activeDate.add("mo", -1));
16692 showToday : function(e){
16693 this.update(new Date().clearTime());
16696 showNextMonth : function(e){
16697 this.update(this.activeDate.add("mo", 1));
16701 showPrevYear : function(){
16702 this.update(this.activeDate.add("y", -1));
16706 showNextYear : function(){
16707 this.update(this.activeDate.add("y", 1));
16712 update : function(date)
16714 var vd = this.activeDate;
16715 this.activeDate = date;
16716 // if(vd && this.el){
16717 // var t = date.getTime();
16718 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16719 // Roo.log('using add remove');
16721 // this.fireEvent('monthchange', this, date);
16723 // this.cells.removeClass("fc-state-highlight");
16724 // this.cells.each(function(c){
16725 // if(c.dateValue == t){
16726 // c.addClass("fc-state-highlight");
16727 // setTimeout(function(){
16728 // try{c.dom.firstChild.focus();}catch(e){}
16738 var days = date.getDaysInMonth();
16740 var firstOfMonth = date.getFirstDateOfMonth();
16741 var startingPos = firstOfMonth.getDay()-this.startDay;
16743 if(startingPos < this.startDay){
16747 var pm = date.add(Date.MONTH, -1);
16748 var prevStart = pm.getDaysInMonth()-startingPos;
16750 this.cells = this.el.select('.fc-day',true);
16751 this.textNodes = this.el.query('.fc-day-number');
16752 this.cells.addClassOnOver('fc-state-hover');
16754 var cells = this.cells.elements;
16755 var textEls = this.textNodes;
16757 Roo.each(cells, function(cell){
16758 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16761 days += startingPos;
16763 // convert everything to numbers so it's fast
16764 var day = 86400000;
16765 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16768 //Roo.log(prevStart);
16770 var today = new Date().clearTime().getTime();
16771 var sel = date.clearTime().getTime();
16772 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16773 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16774 var ddMatch = this.disabledDatesRE;
16775 var ddText = this.disabledDatesText;
16776 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16777 var ddaysText = this.disabledDaysText;
16778 var format = this.format;
16780 var setCellClass = function(cal, cell){
16784 //Roo.log('set Cell Class');
16786 var t = d.getTime();
16790 cell.dateValue = t;
16792 cell.className += " fc-today";
16793 cell.className += " fc-state-highlight";
16794 cell.title = cal.todayText;
16797 // disable highlight in other month..
16798 //cell.className += " fc-state-highlight";
16803 cell.className = " fc-state-disabled";
16804 cell.title = cal.minText;
16808 cell.className = " fc-state-disabled";
16809 cell.title = cal.maxText;
16813 if(ddays.indexOf(d.getDay()) != -1){
16814 cell.title = ddaysText;
16815 cell.className = " fc-state-disabled";
16818 if(ddMatch && format){
16819 var fvalue = d.dateFormat(format);
16820 if(ddMatch.test(fvalue)){
16821 cell.title = ddText.replace("%0", fvalue);
16822 cell.className = " fc-state-disabled";
16826 if (!cell.initialClassName) {
16827 cell.initialClassName = cell.dom.className;
16830 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16835 for(; i < startingPos; i++) {
16836 textEls[i].innerHTML = (++prevStart);
16837 d.setDate(d.getDate()+1);
16839 cells[i].className = "fc-past fc-other-month";
16840 setCellClass(this, cells[i]);
16845 for(; i < days; i++){
16846 intDay = i - startingPos + 1;
16847 textEls[i].innerHTML = (intDay);
16848 d.setDate(d.getDate()+1);
16850 cells[i].className = ''; // "x-date-active";
16851 setCellClass(this, cells[i]);
16855 for(; i < 42; i++) {
16856 textEls[i].innerHTML = (++extraDays);
16857 d.setDate(d.getDate()+1);
16859 cells[i].className = "fc-future fc-other-month";
16860 setCellClass(this, cells[i]);
16863 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16865 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16867 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16868 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16870 if(totalRows != 6){
16871 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16872 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16875 this.fireEvent('monthchange', this, date);
16879 if(!this.internalRender){
16880 var main = this.el.dom.firstChild;
16881 var w = main.offsetWidth;
16882 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16883 Roo.fly(main).setWidth(w);
16884 this.internalRender = true;
16885 // opera does not respect the auto grow header center column
16886 // then, after it gets a width opera refuses to recalculate
16887 // without a second pass
16888 if(Roo.isOpera && !this.secondPass){
16889 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16890 this.secondPass = true;
16891 this.update.defer(10, this, [date]);
16898 findCell : function(dt) {
16899 dt = dt.clearTime().getTime();
16901 this.cells.each(function(c){
16902 //Roo.log("check " +c.dateValue + '?=' + dt);
16903 if(c.dateValue == dt){
16913 findCells : function(ev) {
16914 var s = ev.start.clone().clearTime().getTime();
16916 var e= ev.end.clone().clearTime().getTime();
16919 this.cells.each(function(c){
16920 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16922 if(c.dateValue > e){
16925 if(c.dateValue < s){
16934 // findBestRow: function(cells)
16938 // for (var i =0 ; i < cells.length;i++) {
16939 // ret = Math.max(cells[i].rows || 0,ret);
16946 addItem : function(ev)
16948 // look for vertical location slot in
16949 var cells = this.findCells(ev);
16951 // ev.row = this.findBestRow(cells);
16953 // work out the location.
16957 for(var i =0; i < cells.length; i++) {
16959 cells[i].row = cells[0].row;
16962 cells[i].row = cells[i].row + 1;
16972 if (crow.start.getY() == cells[i].getY()) {
16974 crow.end = cells[i];
16991 cells[0].events.push(ev);
16993 this.calevents.push(ev);
16996 clearEvents: function() {
16998 if(!this.calevents){
17002 Roo.each(this.cells.elements, function(c){
17008 Roo.each(this.calevents, function(e) {
17009 Roo.each(e.els, function(el) {
17010 el.un('mouseenter' ,this.onEventEnter, this);
17011 el.un('mouseleave' ,this.onEventLeave, this);
17016 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17022 renderEvents: function()
17026 this.cells.each(function(c) {
17035 if(c.row != c.events.length){
17036 r = 4 - (4 - (c.row - c.events.length));
17039 c.events = ev.slice(0, r);
17040 c.more = ev.slice(r);
17042 if(c.more.length && c.more.length == 1){
17043 c.events.push(c.more.pop());
17046 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17050 this.cells.each(function(c) {
17052 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17055 for (var e = 0; e < c.events.length; e++){
17056 var ev = c.events[e];
17057 var rows = ev.rows;
17059 for(var i = 0; i < rows.length; i++) {
17061 // how many rows should it span..
17064 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17065 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17067 unselectable : "on",
17070 cls: 'fc-event-inner',
17074 // cls: 'fc-event-time',
17075 // html : cells.length > 1 ? '' : ev.time
17079 cls: 'fc-event-title',
17080 html : String.format('{0}', ev.title)
17087 cls: 'ui-resizable-handle ui-resizable-e',
17088 html : '  '
17095 cfg.cls += ' fc-event-start';
17097 if ((i+1) == rows.length) {
17098 cfg.cls += ' fc-event-end';
17101 var ctr = _this.el.select('.fc-event-container',true).first();
17102 var cg = ctr.createChild(cfg);
17104 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17105 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17107 var r = (c.more.length) ? 1 : 0;
17108 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17109 cg.setWidth(ebox.right - sbox.x -2);
17111 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17112 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17113 cg.on('click', _this.onEventClick, _this, ev);
17124 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17125 style : 'position: absolute',
17126 unselectable : "on",
17129 cls: 'fc-event-inner',
17133 cls: 'fc-event-title',
17141 cls: 'ui-resizable-handle ui-resizable-e',
17142 html : '  '
17148 var ctr = _this.el.select('.fc-event-container',true).first();
17149 var cg = ctr.createChild(cfg);
17151 var sbox = c.select('.fc-day-content',true).first().getBox();
17152 var ebox = c.select('.fc-day-content',true).first().getBox();
17154 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17155 cg.setWidth(ebox.right - sbox.x -2);
17157 cg.on('click', _this.onMoreEventClick, _this, c.more);
17167 onEventEnter: function (e, el,event,d) {
17168 this.fireEvent('evententer', this, el, event);
17171 onEventLeave: function (e, el,event,d) {
17172 this.fireEvent('eventleave', this, el, event);
17175 onEventClick: function (e, el,event,d) {
17176 this.fireEvent('eventclick', this, el, event);
17179 onMonthChange: function () {
17183 onMoreEventClick: function(e, el, more)
17187 this.calpopover.placement = 'right';
17188 this.calpopover.setTitle('More');
17190 this.calpopover.setContent('');
17192 var ctr = this.calpopover.el.select('.popover-content', true).first();
17194 Roo.each(more, function(m){
17196 cls : 'fc-event-hori fc-event-draggable',
17199 var cg = ctr.createChild(cfg);
17201 cg.on('click', _this.onEventClick, _this, m);
17204 this.calpopover.show(el);
17209 onLoad: function ()
17211 this.calevents = [];
17214 if(this.store.getCount() > 0){
17215 this.store.data.each(function(d){
17218 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17219 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17220 time : d.data.start_time,
17221 title : d.data.title,
17222 description : d.data.description,
17223 venue : d.data.venue
17228 this.renderEvents();
17230 if(this.calevents.length && this.loadMask){
17231 this.maskEl.hide();
17235 onBeforeLoad: function()
17237 this.clearEvents();
17239 this.maskEl.show();
17253 * @class Roo.bootstrap.Popover
17254 * @extends Roo.bootstrap.Component
17255 * Bootstrap Popover class
17256 * @cfg {String} html contents of the popover (or false to use children..)
17257 * @cfg {String} title of popover (or false to hide)
17258 * @cfg {String} placement how it is placed
17259 * @cfg {String} trigger click || hover (or false to trigger manually)
17260 * @cfg {String} over what (parent or false to trigger manually.)
17261 * @cfg {Number} delay - delay before showing
17264 * Create a new Popover
17265 * @param {Object} config The config object
17268 Roo.bootstrap.Popover = function(config){
17269 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17275 * After the popover show
17277 * @param {Roo.bootstrap.Popover} this
17282 * After the popover hide
17284 * @param {Roo.bootstrap.Popover} this
17290 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17292 title: 'Fill in a title',
17295 placement : 'right',
17296 trigger : 'hover', // hover
17302 can_build_overlaid : false,
17304 getChildContainer : function()
17306 return this.el.select('.popover-content',true).first();
17309 getAutoCreate : function(){
17312 cls : 'popover roo-dynamic',
17313 style: 'display:block',
17319 cls : 'popover-inner',
17323 cls: 'popover-title',
17327 cls : 'popover-content',
17338 setTitle: function(str)
17341 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17343 setContent: function(str)
17346 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17348 // as it get's added to the bottom of the page.
17349 onRender : function(ct, position)
17351 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17353 var cfg = Roo.apply({}, this.getAutoCreate());
17357 cfg.cls += ' ' + this.cls;
17360 cfg.style = this.style;
17362 //Roo.log("adding to ");
17363 this.el = Roo.get(document.body).createChild(cfg, position);
17364 // Roo.log(this.el);
17369 initEvents : function()
17371 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17372 this.el.enableDisplayMode('block');
17374 if (this.over === false) {
17377 if (this.triggers === false) {
17380 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17381 var triggers = this.trigger ? this.trigger.split(' ') : [];
17382 Roo.each(triggers, function(trigger) {
17384 if (trigger == 'click') {
17385 on_el.on('click', this.toggle, this);
17386 } else if (trigger != 'manual') {
17387 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17388 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17390 on_el.on(eventIn ,this.enter, this);
17391 on_el.on(eventOut, this.leave, this);
17402 toggle : function () {
17403 this.hoverState == 'in' ? this.leave() : this.enter();
17406 enter : function () {
17408 clearTimeout(this.timeout);
17410 this.hoverState = 'in';
17412 if (!this.delay || !this.delay.show) {
17417 this.timeout = setTimeout(function () {
17418 if (_t.hoverState == 'in') {
17421 }, this.delay.show)
17424 leave : function() {
17425 clearTimeout(this.timeout);
17427 this.hoverState = 'out';
17429 if (!this.delay || !this.delay.hide) {
17434 this.timeout = setTimeout(function () {
17435 if (_t.hoverState == 'out') {
17438 }, this.delay.hide)
17441 show : function (on_el)
17444 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17448 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17449 if (this.html !== false) {
17450 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17452 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17453 if (!this.title.length) {
17454 this.el.select('.popover-title',true).hide();
17457 var placement = typeof this.placement == 'function' ?
17458 this.placement.call(this, this.el, on_el) :
17461 var autoToken = /\s?auto?\s?/i;
17462 var autoPlace = autoToken.test(placement);
17464 placement = placement.replace(autoToken, '') || 'top';
17468 //this.el.setXY([0,0]);
17470 this.el.dom.style.display='block';
17471 this.el.addClass(placement);
17473 //this.el.appendTo(on_el);
17475 var p = this.getPosition();
17476 var box = this.el.getBox();
17481 var align = Roo.bootstrap.Popover.alignment[placement];
17484 this.el.alignTo(on_el, align[0],align[1]);
17485 //var arrow = this.el.select('.arrow',true).first();
17486 //arrow.set(align[2],
17488 this.el.addClass('in');
17491 if (this.el.hasClass('fade')) {
17495 this.hoverState = 'in';
17497 this.fireEvent('show', this);
17502 this.el.setXY([0,0]);
17503 this.el.removeClass('in');
17505 this.hoverState = null;
17507 this.fireEvent('hide', this);
17512 Roo.bootstrap.Popover.alignment = {
17513 'left' : ['r-l', [-10,0], 'right'],
17514 'right' : ['l-r', [10,0], 'left'],
17515 'bottom' : ['t-b', [0,10], 'top'],
17516 'top' : [ 'b-t', [0,-10], 'bottom']
17527 * @class Roo.bootstrap.Progress
17528 * @extends Roo.bootstrap.Component
17529 * Bootstrap Progress class
17530 * @cfg {Boolean} striped striped of the progress bar
17531 * @cfg {Boolean} active animated of the progress bar
17535 * Create a new Progress
17536 * @param {Object} config The config object
17539 Roo.bootstrap.Progress = function(config){
17540 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17543 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17548 getAutoCreate : function(){
17556 cfg.cls += ' progress-striped';
17560 cfg.cls += ' active';
17579 * @class Roo.bootstrap.ProgressBar
17580 * @extends Roo.bootstrap.Component
17581 * Bootstrap ProgressBar class
17582 * @cfg {Number} aria_valuenow aria-value now
17583 * @cfg {Number} aria_valuemin aria-value min
17584 * @cfg {Number} aria_valuemax aria-value max
17585 * @cfg {String} label label for the progress bar
17586 * @cfg {String} panel (success | info | warning | danger )
17587 * @cfg {String} role role of the progress bar
17588 * @cfg {String} sr_only text
17592 * Create a new ProgressBar
17593 * @param {Object} config The config object
17596 Roo.bootstrap.ProgressBar = function(config){
17597 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17600 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17604 aria_valuemax : 100,
17610 getAutoCreate : function()
17615 cls: 'progress-bar',
17616 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17628 cfg.role = this.role;
17631 if(this.aria_valuenow){
17632 cfg['aria-valuenow'] = this.aria_valuenow;
17635 if(this.aria_valuemin){
17636 cfg['aria-valuemin'] = this.aria_valuemin;
17639 if(this.aria_valuemax){
17640 cfg['aria-valuemax'] = this.aria_valuemax;
17643 if(this.label && !this.sr_only){
17644 cfg.html = this.label;
17648 cfg.cls += ' progress-bar-' + this.panel;
17654 update : function(aria_valuenow)
17656 this.aria_valuenow = aria_valuenow;
17658 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17673 * @class Roo.bootstrap.TabGroup
17674 * @extends Roo.bootstrap.Column
17675 * Bootstrap Column class
17676 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17677 * @cfg {Boolean} carousel true to make the group behave like a carousel
17678 * @cfg {Boolean} bullets show bullets for the panels
17679 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17680 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17681 * @cfg {Boolean} showarrow (true|false) show arrow default true
17684 * Create a new TabGroup
17685 * @param {Object} config The config object
17688 Roo.bootstrap.TabGroup = function(config){
17689 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17691 this.navId = Roo.id();
17694 Roo.bootstrap.TabGroup.register(this);
17698 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17701 transition : false,
17706 slideOnTouch : false,
17709 getAutoCreate : function()
17711 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17713 cfg.cls += ' tab-content';
17715 if (this.carousel) {
17716 cfg.cls += ' carousel slide';
17719 cls : 'carousel-inner',
17723 if(this.bullets && !Roo.isTouch){
17726 cls : 'carousel-bullets',
17730 if(this.bullets_cls){
17731 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17738 cfg.cn[0].cn.push(bullets);
17741 if(this.showarrow){
17742 cfg.cn[0].cn.push({
17744 class : 'carousel-arrow',
17748 class : 'carousel-prev',
17752 class : 'fa fa-chevron-left'
17758 class : 'carousel-next',
17762 class : 'fa fa-chevron-right'
17775 initEvents: function()
17777 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17778 // this.el.on("touchstart", this.onTouchStart, this);
17781 if(this.autoslide){
17784 this.slideFn = window.setInterval(function() {
17785 _this.showPanelNext();
17789 if(this.showarrow){
17790 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17791 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17797 // onTouchStart : function(e, el, o)
17799 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17803 // this.showPanelNext();
17807 getChildContainer : function()
17809 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17813 * register a Navigation item
17814 * @param {Roo.bootstrap.NavItem} the navitem to add
17816 register : function(item)
17818 this.tabs.push( item);
17819 item.navId = this.navId; // not really needed..
17824 getActivePanel : function()
17827 Roo.each(this.tabs, function(t) {
17837 getPanelByName : function(n)
17840 Roo.each(this.tabs, function(t) {
17841 if (t.tabId == n) {
17849 indexOfPanel : function(p)
17852 Roo.each(this.tabs, function(t,i) {
17853 if (t.tabId == p.tabId) {
17862 * show a specific panel
17863 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17864 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17866 showPanel : function (pan)
17868 if(this.transition || typeof(pan) == 'undefined'){
17869 Roo.log("waiting for the transitionend");
17873 if (typeof(pan) == 'number') {
17874 pan = this.tabs[pan];
17877 if (typeof(pan) == 'string') {
17878 pan = this.getPanelByName(pan);
17881 var cur = this.getActivePanel();
17884 Roo.log('pan or acitve pan is undefined');
17888 if (pan.tabId == this.getActivePanel().tabId) {
17892 if (false === cur.fireEvent('beforedeactivate')) {
17896 if(this.bullets > 0 && !Roo.isTouch){
17897 this.setActiveBullet(this.indexOfPanel(pan));
17900 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17902 this.transition = true;
17903 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17904 var lr = dir == 'next' ? 'left' : 'right';
17905 pan.el.addClass(dir); // or prev
17906 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17907 cur.el.addClass(lr); // or right
17908 pan.el.addClass(lr);
17911 cur.el.on('transitionend', function() {
17912 Roo.log("trans end?");
17914 pan.el.removeClass([lr,dir]);
17915 pan.setActive(true);
17917 cur.el.removeClass([lr]);
17918 cur.setActive(false);
17920 _this.transition = false;
17922 }, this, { single: true } );
17927 cur.setActive(false);
17928 pan.setActive(true);
17933 showPanelNext : function()
17935 var i = this.indexOfPanel(this.getActivePanel());
17937 if (i >= this.tabs.length - 1 && !this.autoslide) {
17941 if (i >= this.tabs.length - 1 && this.autoslide) {
17945 this.showPanel(this.tabs[i+1]);
17948 showPanelPrev : function()
17950 var i = this.indexOfPanel(this.getActivePanel());
17952 if (i < 1 && !this.autoslide) {
17956 if (i < 1 && this.autoslide) {
17957 i = this.tabs.length;
17960 this.showPanel(this.tabs[i-1]);
17964 addBullet: function()
17966 if(!this.bullets || Roo.isTouch){
17969 var ctr = this.el.select('.carousel-bullets',true).first();
17970 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17971 var bullet = ctr.createChild({
17972 cls : 'bullet bullet-' + i
17973 },ctr.dom.lastChild);
17978 bullet.on('click', (function(e, el, o, ii, t){
17980 e.preventDefault();
17982 this.showPanel(ii);
17984 if(this.autoslide && this.slideFn){
17985 clearInterval(this.slideFn);
17986 this.slideFn = window.setInterval(function() {
17987 _this.showPanelNext();
17991 }).createDelegate(this, [i, bullet], true));
17996 setActiveBullet : function(i)
18002 Roo.each(this.el.select('.bullet', true).elements, function(el){
18003 el.removeClass('selected');
18006 var bullet = this.el.select('.bullet-' + i, true).first();
18012 bullet.addClass('selected');
18023 Roo.apply(Roo.bootstrap.TabGroup, {
18027 * register a Navigation Group
18028 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18030 register : function(navgrp)
18032 this.groups[navgrp.navId] = navgrp;
18036 * fetch a Navigation Group based on the navigation ID
18037 * if one does not exist , it will get created.
18038 * @param {string} the navgroup to add
18039 * @returns {Roo.bootstrap.NavGroup} the navgroup
18041 get: function(navId) {
18042 if (typeof(this.groups[navId]) == 'undefined') {
18043 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18045 return this.groups[navId] ;
18060 * @class Roo.bootstrap.TabPanel
18061 * @extends Roo.bootstrap.Component
18062 * Bootstrap TabPanel class
18063 * @cfg {Boolean} active panel active
18064 * @cfg {String} html panel content
18065 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18066 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18067 * @cfg {String} href click to link..
18071 * Create a new TabPanel
18072 * @param {Object} config The config object
18075 Roo.bootstrap.TabPanel = function(config){
18076 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18080 * Fires when the active status changes
18081 * @param {Roo.bootstrap.TabPanel} this
18082 * @param {Boolean} state the new state
18087 * @event beforedeactivate
18088 * Fires before a tab is de-activated - can be used to do validation on a form.
18089 * @param {Roo.bootstrap.TabPanel} this
18090 * @return {Boolean} false if there is an error
18093 'beforedeactivate': true
18096 this.tabId = this.tabId || Roo.id();
18100 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18108 getAutoCreate : function(){
18111 // item is needed for carousel - not sure if it has any effect otherwise
18112 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18113 html: this.html || ''
18117 cfg.cls += ' active';
18121 cfg.tabId = this.tabId;
18128 initEvents: function()
18130 var p = this.parent();
18132 this.navId = this.navId || p.navId;
18134 if (typeof(this.navId) != 'undefined') {
18135 // not really needed.. but just in case.. parent should be a NavGroup.
18136 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18140 var i = tg.tabs.length - 1;
18142 if(this.active && tg.bullets > 0 && i < tg.bullets){
18143 tg.setActiveBullet(i);
18147 this.el.on('click', this.onClick, this);
18150 this.el.on("touchstart", this.onTouchStart, this);
18151 this.el.on("touchmove", this.onTouchMove, this);
18152 this.el.on("touchend", this.onTouchEnd, this);
18157 onRender : function(ct, position)
18159 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18162 setActive : function(state)
18164 Roo.log("panel - set active " + this.tabId + "=" + state);
18166 this.active = state;
18168 this.el.removeClass('active');
18170 } else if (!this.el.hasClass('active')) {
18171 this.el.addClass('active');
18174 this.fireEvent('changed', this, state);
18177 onClick : function(e)
18179 e.preventDefault();
18181 if(!this.href.length){
18185 window.location.href = this.href;
18194 onTouchStart : function(e)
18196 this.swiping = false;
18198 this.startX = e.browserEvent.touches[0].clientX;
18199 this.startY = e.browserEvent.touches[0].clientY;
18202 onTouchMove : function(e)
18204 this.swiping = true;
18206 this.endX = e.browserEvent.touches[0].clientX;
18207 this.endY = e.browserEvent.touches[0].clientY;
18210 onTouchEnd : function(e)
18217 var tabGroup = this.parent();
18219 if(this.endX > this.startX){ // swiping right
18220 tabGroup.showPanelPrev();
18224 if(this.startX > this.endX){ // swiping left
18225 tabGroup.showPanelNext();
18244 * @class Roo.bootstrap.DateField
18245 * @extends Roo.bootstrap.Input
18246 * Bootstrap DateField class
18247 * @cfg {Number} weekStart default 0
18248 * @cfg {String} viewMode default empty, (months|years)
18249 * @cfg {String} minViewMode default empty, (months|years)
18250 * @cfg {Number} startDate default -Infinity
18251 * @cfg {Number} endDate default Infinity
18252 * @cfg {Boolean} todayHighlight default false
18253 * @cfg {Boolean} todayBtn default false
18254 * @cfg {Boolean} calendarWeeks default false
18255 * @cfg {Object} daysOfWeekDisabled default empty
18256 * @cfg {Boolean} singleMode default false (true | false)
18258 * @cfg {Boolean} keyboardNavigation default true
18259 * @cfg {String} language default en
18262 * Create a new DateField
18263 * @param {Object} config The config object
18266 Roo.bootstrap.DateField = function(config){
18267 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18271 * Fires when this field show.
18272 * @param {Roo.bootstrap.DateField} this
18273 * @param {Mixed} date The date value
18278 * Fires when this field hide.
18279 * @param {Roo.bootstrap.DateField} this
18280 * @param {Mixed} date The date value
18285 * Fires when select a date.
18286 * @param {Roo.bootstrap.DateField} this
18287 * @param {Mixed} date The date value
18291 * @event beforeselect
18292 * Fires when before select a date.
18293 * @param {Roo.bootstrap.DateField} this
18294 * @param {Mixed} date The date value
18296 beforeselect : true
18300 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18303 * @cfg {String} format
18304 * The default date format string which can be overriden for localization support. The format must be
18305 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18309 * @cfg {String} altFormats
18310 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18311 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18313 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18321 todayHighlight : false,
18327 keyboardNavigation: true,
18329 calendarWeeks: false,
18331 startDate: -Infinity,
18335 daysOfWeekDisabled: [],
18339 singleMode : false,
18341 UTCDate: function()
18343 return new Date(Date.UTC.apply(Date, arguments));
18346 UTCToday: function()
18348 var today = new Date();
18349 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18352 getDate: function() {
18353 var d = this.getUTCDate();
18354 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18357 getUTCDate: function() {
18361 setDate: function(d) {
18362 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18365 setUTCDate: function(d) {
18367 this.setValue(this.formatDate(this.date));
18370 onRender: function(ct, position)
18373 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18375 this.language = this.language || 'en';
18376 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18377 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18379 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18380 this.format = this.format || 'm/d/y';
18381 this.isInline = false;
18382 this.isInput = true;
18383 this.component = this.el.select('.add-on', true).first() || false;
18384 this.component = (this.component && this.component.length === 0) ? false : this.component;
18385 this.hasInput = this.component && this.inputEl().length;
18387 if (typeof(this.minViewMode === 'string')) {
18388 switch (this.minViewMode) {
18390 this.minViewMode = 1;
18393 this.minViewMode = 2;
18396 this.minViewMode = 0;
18401 if (typeof(this.viewMode === 'string')) {
18402 switch (this.viewMode) {
18415 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18417 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18419 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18421 this.picker().on('mousedown', this.onMousedown, this);
18422 this.picker().on('click', this.onClick, this);
18424 this.picker().addClass('datepicker-dropdown');
18426 this.startViewMode = this.viewMode;
18428 if(this.singleMode){
18429 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18430 v.setVisibilityMode(Roo.Element.DISPLAY);
18434 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18435 v.setStyle('width', '189px');
18439 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18440 if(!this.calendarWeeks){
18445 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18446 v.attr('colspan', function(i, val){
18447 return parseInt(val) + 1;
18452 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18454 this.setStartDate(this.startDate);
18455 this.setEndDate(this.endDate);
18457 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18464 if(this.isInline) {
18469 picker : function()
18471 return this.pickerEl;
18472 // return this.el.select('.datepicker', true).first();
18475 fillDow: function()
18477 var dowCnt = this.weekStart;
18486 if(this.calendarWeeks){
18494 while (dowCnt < this.weekStart + 7) {
18498 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18502 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18505 fillMonths: function()
18508 var months = this.picker().select('>.datepicker-months td', true).first();
18510 months.dom.innerHTML = '';
18516 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18519 months.createChild(month);
18526 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;
18528 if (this.date < this.startDate) {
18529 this.viewDate = new Date(this.startDate);
18530 } else if (this.date > this.endDate) {
18531 this.viewDate = new Date(this.endDate);
18533 this.viewDate = new Date(this.date);
18541 var d = new Date(this.viewDate),
18542 year = d.getUTCFullYear(),
18543 month = d.getUTCMonth(),
18544 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18545 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18546 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18547 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18548 currentDate = this.date && this.date.valueOf(),
18549 today = this.UTCToday();
18551 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18553 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18555 // this.picker.select('>tfoot th.today').
18556 // .text(dates[this.language].today)
18557 // .toggle(this.todayBtn !== false);
18559 this.updateNavArrows();
18562 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18564 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18566 prevMonth.setUTCDate(day);
18568 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18570 var nextMonth = new Date(prevMonth);
18572 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18574 nextMonth = nextMonth.valueOf();
18576 var fillMonths = false;
18578 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18580 while(prevMonth.valueOf() < nextMonth) {
18583 if (prevMonth.getUTCDay() === this.weekStart) {
18585 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18593 if(this.calendarWeeks){
18594 // ISO 8601: First week contains first thursday.
18595 // ISO also states week starts on Monday, but we can be more abstract here.
18597 // Start of current week: based on weekstart/current date
18598 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18599 // Thursday of this week
18600 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18601 // First Thursday of year, year from thursday
18602 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18603 // Calendar week: ms between thursdays, div ms per day, div 7 days
18604 calWeek = (th - yth) / 864e5 / 7 + 1;
18606 fillMonths.cn.push({
18614 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18616 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18619 if (this.todayHighlight &&
18620 prevMonth.getUTCFullYear() == today.getFullYear() &&
18621 prevMonth.getUTCMonth() == today.getMonth() &&
18622 prevMonth.getUTCDate() == today.getDate()) {
18623 clsName += ' today';
18626 if (currentDate && prevMonth.valueOf() === currentDate) {
18627 clsName += ' active';
18630 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18631 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18632 clsName += ' disabled';
18635 fillMonths.cn.push({
18637 cls: 'day ' + clsName,
18638 html: prevMonth.getDate()
18641 prevMonth.setDate(prevMonth.getDate()+1);
18644 var currentYear = this.date && this.date.getUTCFullYear();
18645 var currentMonth = this.date && this.date.getUTCMonth();
18647 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18649 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18650 v.removeClass('active');
18652 if(currentYear === year && k === currentMonth){
18653 v.addClass('active');
18656 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18657 v.addClass('disabled');
18663 year = parseInt(year/10, 10) * 10;
18665 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18667 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18670 for (var i = -1; i < 11; i++) {
18671 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18673 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18681 showMode: function(dir)
18684 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18687 Roo.each(this.picker().select('>div',true).elements, function(v){
18688 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18691 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18696 if(this.isInline) {
18700 this.picker().removeClass(['bottom', 'top']);
18702 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18704 * place to the top of element!
18708 this.picker().addClass('top');
18709 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18714 this.picker().addClass('bottom');
18716 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18719 parseDate : function(value)
18721 if(!value || value instanceof Date){
18724 var v = Date.parseDate(value, this.format);
18725 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18726 v = Date.parseDate(value, 'Y-m-d');
18728 if(!v && this.altFormats){
18729 if(!this.altFormatsArray){
18730 this.altFormatsArray = this.altFormats.split("|");
18732 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18733 v = Date.parseDate(value, this.altFormatsArray[i]);
18739 formatDate : function(date, fmt)
18741 return (!date || !(date instanceof Date)) ?
18742 date : date.dateFormat(fmt || this.format);
18745 onFocus : function()
18747 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18751 onBlur : function()
18753 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18755 var d = this.inputEl().getValue();
18764 this.picker().show();
18768 this.fireEvent('show', this, this.date);
18773 if(this.isInline) {
18776 this.picker().hide();
18777 this.viewMode = this.startViewMode;
18780 this.fireEvent('hide', this, this.date);
18784 onMousedown: function(e)
18786 e.stopPropagation();
18787 e.preventDefault();
18792 Roo.bootstrap.DateField.superclass.keyup.call(this);
18796 setValue: function(v)
18798 if(this.fireEvent('beforeselect', this, v) !== false){
18799 var d = new Date(this.parseDate(v) ).clearTime();
18801 if(isNaN(d.getTime())){
18802 this.date = this.viewDate = '';
18803 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18807 v = this.formatDate(d);
18809 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18811 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18815 this.fireEvent('select', this, this.date);
18819 getValue: function()
18821 return this.formatDate(this.date);
18824 fireKey: function(e)
18826 if (!this.picker().isVisible()){
18827 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18833 var dateChanged = false,
18835 newDate, newViewDate;
18840 e.preventDefault();
18844 if (!this.keyboardNavigation) {
18847 dir = e.keyCode == 37 ? -1 : 1;
18850 newDate = this.moveYear(this.date, dir);
18851 newViewDate = this.moveYear(this.viewDate, dir);
18852 } else if (e.shiftKey){
18853 newDate = this.moveMonth(this.date, dir);
18854 newViewDate = this.moveMonth(this.viewDate, dir);
18856 newDate = new Date(this.date);
18857 newDate.setUTCDate(this.date.getUTCDate() + dir);
18858 newViewDate = new Date(this.viewDate);
18859 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18861 if (this.dateWithinRange(newDate)){
18862 this.date = newDate;
18863 this.viewDate = newViewDate;
18864 this.setValue(this.formatDate(this.date));
18866 e.preventDefault();
18867 dateChanged = true;
18872 if (!this.keyboardNavigation) {
18875 dir = e.keyCode == 38 ? -1 : 1;
18877 newDate = this.moveYear(this.date, dir);
18878 newViewDate = this.moveYear(this.viewDate, dir);
18879 } else if (e.shiftKey){
18880 newDate = this.moveMonth(this.date, dir);
18881 newViewDate = this.moveMonth(this.viewDate, dir);
18883 newDate = new Date(this.date);
18884 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18885 newViewDate = new Date(this.viewDate);
18886 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18888 if (this.dateWithinRange(newDate)){
18889 this.date = newDate;
18890 this.viewDate = newViewDate;
18891 this.setValue(this.formatDate(this.date));
18893 e.preventDefault();
18894 dateChanged = true;
18898 this.setValue(this.formatDate(this.date));
18900 e.preventDefault();
18903 this.setValue(this.formatDate(this.date));
18917 onClick: function(e)
18919 e.stopPropagation();
18920 e.preventDefault();
18922 var target = e.getTarget();
18924 if(target.nodeName.toLowerCase() === 'i'){
18925 target = Roo.get(target).dom.parentNode;
18928 var nodeName = target.nodeName;
18929 var className = target.className;
18930 var html = target.innerHTML;
18931 //Roo.log(nodeName);
18933 switch(nodeName.toLowerCase()) {
18935 switch(className) {
18941 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18942 switch(this.viewMode){
18944 this.viewDate = this.moveMonth(this.viewDate, dir);
18948 this.viewDate = this.moveYear(this.viewDate, dir);
18954 var date = new Date();
18955 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18957 this.setValue(this.formatDate(this.date));
18964 if (className.indexOf('disabled') < 0) {
18965 this.viewDate.setUTCDate(1);
18966 if (className.indexOf('month') > -1) {
18967 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18969 var year = parseInt(html, 10) || 0;
18970 this.viewDate.setUTCFullYear(year);
18974 if(this.singleMode){
18975 this.setValue(this.formatDate(this.viewDate));
18986 //Roo.log(className);
18987 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18988 var day = parseInt(html, 10) || 1;
18989 var year = this.viewDate.getUTCFullYear(),
18990 month = this.viewDate.getUTCMonth();
18992 if (className.indexOf('old') > -1) {
18999 } else if (className.indexOf('new') > -1) {
19007 //Roo.log([year,month,day]);
19008 this.date = this.UTCDate(year, month, day,0,0,0,0);
19009 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19011 //Roo.log(this.formatDate(this.date));
19012 this.setValue(this.formatDate(this.date));
19019 setStartDate: function(startDate)
19021 this.startDate = startDate || -Infinity;
19022 if (this.startDate !== -Infinity) {
19023 this.startDate = this.parseDate(this.startDate);
19026 this.updateNavArrows();
19029 setEndDate: function(endDate)
19031 this.endDate = endDate || Infinity;
19032 if (this.endDate !== Infinity) {
19033 this.endDate = this.parseDate(this.endDate);
19036 this.updateNavArrows();
19039 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19041 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19042 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19043 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19045 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19046 return parseInt(d, 10);
19049 this.updateNavArrows();
19052 updateNavArrows: function()
19054 if(this.singleMode){
19058 var d = new Date(this.viewDate),
19059 year = d.getUTCFullYear(),
19060 month = d.getUTCMonth();
19062 Roo.each(this.picker().select('.prev', true).elements, function(v){
19064 switch (this.viewMode) {
19067 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19073 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19080 Roo.each(this.picker().select('.next', true).elements, function(v){
19082 switch (this.viewMode) {
19085 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19091 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19099 moveMonth: function(date, dir)
19104 var new_date = new Date(date.valueOf()),
19105 day = new_date.getUTCDate(),
19106 month = new_date.getUTCMonth(),
19107 mag = Math.abs(dir),
19109 dir = dir > 0 ? 1 : -1;
19112 // If going back one month, make sure month is not current month
19113 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19115 return new_date.getUTCMonth() == month;
19117 // If going forward one month, make sure month is as expected
19118 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19120 return new_date.getUTCMonth() != new_month;
19122 new_month = month + dir;
19123 new_date.setUTCMonth(new_month);
19124 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19125 if (new_month < 0 || new_month > 11) {
19126 new_month = (new_month + 12) % 12;
19129 // For magnitudes >1, move one month at a time...
19130 for (var i=0; i<mag; i++) {
19131 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19132 new_date = this.moveMonth(new_date, dir);
19134 // ...then reset the day, keeping it in the new month
19135 new_month = new_date.getUTCMonth();
19136 new_date.setUTCDate(day);
19138 return new_month != new_date.getUTCMonth();
19141 // Common date-resetting loop -- if date is beyond end of month, make it
19144 new_date.setUTCDate(--day);
19145 new_date.setUTCMonth(new_month);
19150 moveYear: function(date, dir)
19152 return this.moveMonth(date, dir*12);
19155 dateWithinRange: function(date)
19157 return date >= this.startDate && date <= this.endDate;
19163 this.picker().remove();
19166 validateValue : function(value)
19168 if(value.length < 1) {
19169 if(this.allowBlank){
19175 if(value.length < this.minLength){
19178 if(value.length > this.maxLength){
19182 var vt = Roo.form.VTypes;
19183 if(!vt[this.vtype](value, this)){
19187 if(typeof this.validator == "function"){
19188 var msg = this.validator(value);
19194 if(this.regex && !this.regex.test(value)){
19198 if(typeof(this.parseDate(value)) == 'undefined'){
19202 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19206 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19214 setVisible : function(visible)
19220 this.getEl().removeClass('hidden');
19226 this.getEl().addClass('hidden');
19231 Roo.apply(Roo.bootstrap.DateField, {
19242 html: '<i class="fa fa-arrow-left"/>'
19252 html: '<i class="fa fa-arrow-right"/>'
19294 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19295 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19296 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19297 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19298 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19311 navFnc: 'FullYear',
19316 navFnc: 'FullYear',
19321 Roo.apply(Roo.bootstrap.DateField, {
19325 cls: 'datepicker dropdown-menu roo-dynamic',
19329 cls: 'datepicker-days',
19333 cls: 'table-condensed',
19335 Roo.bootstrap.DateField.head,
19339 Roo.bootstrap.DateField.footer
19346 cls: 'datepicker-months',
19350 cls: 'table-condensed',
19352 Roo.bootstrap.DateField.head,
19353 Roo.bootstrap.DateField.content,
19354 Roo.bootstrap.DateField.footer
19361 cls: 'datepicker-years',
19365 cls: 'table-condensed',
19367 Roo.bootstrap.DateField.head,
19368 Roo.bootstrap.DateField.content,
19369 Roo.bootstrap.DateField.footer
19388 * @class Roo.bootstrap.TimeField
19389 * @extends Roo.bootstrap.Input
19390 * Bootstrap DateField class
19394 * Create a new TimeField
19395 * @param {Object} config The config object
19398 Roo.bootstrap.TimeField = function(config){
19399 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19403 * Fires when this field show.
19404 * @param {Roo.bootstrap.DateField} thisthis
19405 * @param {Mixed} date The date value
19410 * Fires when this field hide.
19411 * @param {Roo.bootstrap.DateField} this
19412 * @param {Mixed} date The date value
19417 * Fires when select a date.
19418 * @param {Roo.bootstrap.DateField} this
19419 * @param {Mixed} date The date value
19425 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19428 * @cfg {String} format
19429 * The default time format string which can be overriden for localization support. The format must be
19430 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19434 onRender: function(ct, position)
19437 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19439 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19441 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19443 this.pop = this.picker().select('>.datepicker-time',true).first();
19444 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19446 this.picker().on('mousedown', this.onMousedown, this);
19447 this.picker().on('click', this.onClick, this);
19449 this.picker().addClass('datepicker-dropdown');
19454 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19455 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19456 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19457 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19458 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19459 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19463 fireKey: function(e){
19464 if (!this.picker().isVisible()){
19465 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19471 e.preventDefault();
19479 this.onTogglePeriod();
19482 this.onIncrementMinutes();
19485 this.onDecrementMinutes();
19494 onClick: function(e) {
19495 e.stopPropagation();
19496 e.preventDefault();
19499 picker : function()
19501 return this.el.select('.datepicker', true).first();
19504 fillTime: function()
19506 var time = this.pop.select('tbody', true).first();
19508 time.dom.innerHTML = '';
19523 cls: 'hours-up glyphicon glyphicon-chevron-up'
19543 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19564 cls: 'timepicker-hour',
19579 cls: 'timepicker-minute',
19594 cls: 'btn btn-primary period',
19616 cls: 'hours-down glyphicon glyphicon-chevron-down'
19636 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19654 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19661 var hours = this.time.getHours();
19662 var minutes = this.time.getMinutes();
19675 hours = hours - 12;
19679 hours = '0' + hours;
19683 minutes = '0' + minutes;
19686 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19687 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19688 this.pop.select('button', true).first().dom.innerHTML = period;
19694 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19696 var cls = ['bottom'];
19698 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19705 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19710 this.picker().addClass(cls.join('-'));
19714 Roo.each(cls, function(c){
19716 _this.picker().setTop(_this.inputEl().getHeight());
19720 _this.picker().setTop(0 - _this.picker().getHeight());
19725 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19729 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19736 onFocus : function()
19738 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19742 onBlur : function()
19744 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19750 this.picker().show();
19755 this.fireEvent('show', this, this.date);
19760 this.picker().hide();
19763 this.fireEvent('hide', this, this.date);
19766 setTime : function()
19769 this.setValue(this.time.format(this.format));
19771 this.fireEvent('select', this, this.date);
19776 onMousedown: function(e){
19777 e.stopPropagation();
19778 e.preventDefault();
19781 onIncrementHours: function()
19783 Roo.log('onIncrementHours');
19784 this.time = this.time.add(Date.HOUR, 1);
19789 onDecrementHours: function()
19791 Roo.log('onDecrementHours');
19792 this.time = this.time.add(Date.HOUR, -1);
19796 onIncrementMinutes: function()
19798 Roo.log('onIncrementMinutes');
19799 this.time = this.time.add(Date.MINUTE, 1);
19803 onDecrementMinutes: function()
19805 Roo.log('onDecrementMinutes');
19806 this.time = this.time.add(Date.MINUTE, -1);
19810 onTogglePeriod: function()
19812 Roo.log('onTogglePeriod');
19813 this.time = this.time.add(Date.HOUR, 12);
19820 Roo.apply(Roo.bootstrap.TimeField, {
19850 cls: 'btn btn-info ok',
19862 Roo.apply(Roo.bootstrap.TimeField, {
19866 cls: 'datepicker dropdown-menu',
19870 cls: 'datepicker-time',
19874 cls: 'table-condensed',
19876 Roo.bootstrap.TimeField.content,
19877 Roo.bootstrap.TimeField.footer
19896 * @class Roo.bootstrap.MonthField
19897 * @extends Roo.bootstrap.Input
19898 * Bootstrap MonthField class
19900 * @cfg {String} language default en
19903 * Create a new MonthField
19904 * @param {Object} config The config object
19907 Roo.bootstrap.MonthField = function(config){
19908 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19913 * Fires when this field show.
19914 * @param {Roo.bootstrap.MonthField} this
19915 * @param {Mixed} date The date value
19920 * Fires when this field hide.
19921 * @param {Roo.bootstrap.MonthField} this
19922 * @param {Mixed} date The date value
19927 * Fires when select a date.
19928 * @param {Roo.bootstrap.MonthField} this
19929 * @param {String} oldvalue The old value
19930 * @param {String} newvalue The new value
19936 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19938 onRender: function(ct, position)
19941 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19943 this.language = this.language || 'en';
19944 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19945 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19947 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19948 this.isInline = false;
19949 this.isInput = true;
19950 this.component = this.el.select('.add-on', true).first() || false;
19951 this.component = (this.component && this.component.length === 0) ? false : this.component;
19952 this.hasInput = this.component && this.inputEL().length;
19954 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19956 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19958 this.picker().on('mousedown', this.onMousedown, this);
19959 this.picker().on('click', this.onClick, this);
19961 this.picker().addClass('datepicker-dropdown');
19963 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19964 v.setStyle('width', '189px');
19971 if(this.isInline) {
19977 setValue: function(v, suppressEvent)
19979 var o = this.getValue();
19981 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19985 if(suppressEvent !== true){
19986 this.fireEvent('select', this, o, v);
19991 getValue: function()
19996 onClick: function(e)
19998 e.stopPropagation();
19999 e.preventDefault();
20001 var target = e.getTarget();
20003 if(target.nodeName.toLowerCase() === 'i'){
20004 target = Roo.get(target).dom.parentNode;
20007 var nodeName = target.nodeName;
20008 var className = target.className;
20009 var html = target.innerHTML;
20011 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20015 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20017 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20023 picker : function()
20025 return this.pickerEl;
20028 fillMonths: function()
20031 var months = this.picker().select('>.datepicker-months td', true).first();
20033 months.dom.innerHTML = '';
20039 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20042 months.createChild(month);
20051 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20052 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20055 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20056 e.removeClass('active');
20058 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20059 e.addClass('active');
20066 if(this.isInline) {
20070 this.picker().removeClass(['bottom', 'top']);
20072 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20074 * place to the top of element!
20078 this.picker().addClass('top');
20079 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20084 this.picker().addClass('bottom');
20086 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20089 onFocus : function()
20091 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20095 onBlur : function()
20097 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20099 var d = this.inputEl().getValue();
20108 this.picker().show();
20109 this.picker().select('>.datepicker-months', true).first().show();
20113 this.fireEvent('show', this, this.date);
20118 if(this.isInline) {
20121 this.picker().hide();
20122 this.fireEvent('hide', this, this.date);
20126 onMousedown: function(e)
20128 e.stopPropagation();
20129 e.preventDefault();
20134 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20138 fireKey: function(e)
20140 if (!this.picker().isVisible()){
20141 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20152 e.preventDefault();
20156 dir = e.keyCode == 37 ? -1 : 1;
20158 this.vIndex = this.vIndex + dir;
20160 if(this.vIndex < 0){
20164 if(this.vIndex > 11){
20168 if(isNaN(this.vIndex)){
20172 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20178 dir = e.keyCode == 38 ? -1 : 1;
20180 this.vIndex = this.vIndex + dir * 4;
20182 if(this.vIndex < 0){
20186 if(this.vIndex > 11){
20190 if(isNaN(this.vIndex)){
20194 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20199 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20200 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20204 e.preventDefault();
20207 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20208 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20224 this.picker().remove();
20229 Roo.apply(Roo.bootstrap.MonthField, {
20248 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20249 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20254 Roo.apply(Roo.bootstrap.MonthField, {
20258 cls: 'datepicker dropdown-menu roo-dynamic',
20262 cls: 'datepicker-months',
20266 cls: 'table-condensed',
20268 Roo.bootstrap.DateField.content
20288 * @class Roo.bootstrap.CheckBox
20289 * @extends Roo.bootstrap.Input
20290 * Bootstrap CheckBox class
20292 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20293 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20294 * @cfg {String} boxLabel The text that appears beside the checkbox
20295 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20296 * @cfg {Boolean} checked initnal the element
20297 * @cfg {Boolean} inline inline the element (default false)
20298 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20299 * @cfg {String} tooltip label tooltip
20302 * Create a new CheckBox
20303 * @param {Object} config The config object
20306 Roo.bootstrap.CheckBox = function(config){
20307 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20312 * Fires when the element is checked or unchecked.
20313 * @param {Roo.bootstrap.CheckBox} this This input
20314 * @param {Boolean} checked The new checked value
20319 * Fires when the element is click.
20320 * @param {Roo.bootstrap.CheckBox} this This input
20327 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20329 inputType: 'checkbox',
20338 getAutoCreate : function()
20340 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20346 cfg.cls = 'form-group ' + this.inputType; //input-group
20349 cfg.cls += ' ' + this.inputType + '-inline';
20355 type : this.inputType,
20356 value : this.inputValue,
20357 cls : 'roo-' + this.inputType, //'form-box',
20358 placeholder : this.placeholder || ''
20362 if(this.inputType != 'radio'){
20366 cls : 'roo-hidden-value',
20367 value : this.checked ? this.inputValue : this.valueOff
20372 if (this.weight) { // Validity check?
20373 cfg.cls += " " + this.inputType + "-" + this.weight;
20376 if (this.disabled) {
20377 input.disabled=true;
20381 input.checked = this.checked;
20386 input.name = this.name;
20388 if(this.inputType != 'radio'){
20389 hidden.name = this.name;
20390 input.name = '_hidden_' + this.name;
20395 input.cls += ' input-' + this.size;
20400 ['xs','sm','md','lg'].map(function(size){
20401 if (settings[size]) {
20402 cfg.cls += ' col-' + size + '-' + settings[size];
20406 var inputblock = input;
20408 if (this.before || this.after) {
20411 cls : 'input-group',
20416 inputblock.cn.push({
20418 cls : 'input-group-addon',
20423 inputblock.cn.push(input);
20425 if(this.inputType != 'radio'){
20426 inputblock.cn.push(hidden);
20430 inputblock.cn.push({
20432 cls : 'input-group-addon',
20439 if (align ==='left' && this.fieldLabel.length) {
20440 // Roo.log("left and has label");
20445 cls : 'control-label',
20446 html : this.fieldLabel
20456 if(this.labelWidth > 12){
20457 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20460 if(this.labelWidth < 13 && this.labelmd == 0){
20461 this.labelmd = this.labelWidth;
20464 if(this.labellg > 0){
20465 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20466 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20469 if(this.labelmd > 0){
20470 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20471 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20474 if(this.labelsm > 0){
20475 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20476 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20479 if(this.labelxs > 0){
20480 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20481 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20484 } else if ( this.fieldLabel.length) {
20485 // Roo.log(" label");
20489 tag: this.boxLabel ? 'span' : 'label',
20491 cls: 'control-label box-input-label',
20492 //cls : 'input-group-addon',
20493 html : this.fieldLabel
20502 // Roo.log(" no label && no align");
20503 cfg.cn = [ inputblock ] ;
20509 var boxLabelCfg = {
20511 //'for': id, // box label is handled by onclick - so no for...
20513 html: this.boxLabel
20517 boxLabelCfg.tooltip = this.tooltip;
20520 cfg.cn.push(boxLabelCfg);
20523 if(this.inputType != 'radio'){
20524 cfg.cn.push(hidden);
20532 * return the real input element.
20534 inputEl: function ()
20536 return this.el.select('input.roo-' + this.inputType,true).first();
20538 hiddenEl: function ()
20540 return this.el.select('input.roo-hidden-value',true).first();
20543 labelEl: function()
20545 return this.el.select('label.control-label',true).first();
20547 /* depricated... */
20551 return this.labelEl();
20554 boxLabelEl: function()
20556 return this.el.select('label.box-label',true).first();
20559 initEvents : function()
20561 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20563 this.inputEl().on('click', this.onClick, this);
20565 if (this.boxLabel) {
20566 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20569 this.startValue = this.getValue();
20572 Roo.bootstrap.CheckBox.register(this);
20576 onClick : function(e)
20578 if(this.fireEvent('click', this, e) !== false){
20579 this.setChecked(!this.checked);
20584 setChecked : function(state,suppressEvent)
20586 this.startValue = this.getValue();
20588 if(this.inputType == 'radio'){
20590 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20591 e.dom.checked = false;
20594 this.inputEl().dom.checked = true;
20596 this.inputEl().dom.value = this.inputValue;
20598 if(suppressEvent !== true){
20599 this.fireEvent('check', this, true);
20607 this.checked = state;
20609 this.inputEl().dom.checked = state;
20612 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20614 if(suppressEvent !== true){
20615 this.fireEvent('check', this, state);
20621 getValue : function()
20623 if(this.inputType == 'radio'){
20624 return this.getGroupValue();
20627 return this.hiddenEl().dom.value;
20631 getGroupValue : function()
20633 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20637 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20640 setValue : function(v,suppressEvent)
20642 if(this.inputType == 'radio'){
20643 this.setGroupValue(v, suppressEvent);
20647 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20652 setGroupValue : function(v, suppressEvent)
20654 this.startValue = this.getValue();
20656 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20657 e.dom.checked = false;
20659 if(e.dom.value == v){
20660 e.dom.checked = true;
20664 if(suppressEvent !== true){
20665 this.fireEvent('check', this, true);
20673 validate : function()
20677 (this.inputType == 'radio' && this.validateRadio()) ||
20678 (this.inputType == 'checkbox' && this.validateCheckbox())
20684 this.markInvalid();
20688 validateRadio : function()
20690 if(this.allowBlank){
20696 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20697 if(!e.dom.checked){
20709 validateCheckbox : function()
20712 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20713 //return (this.getValue() == this.inputValue) ? true : false;
20716 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20724 for(var i in group){
20725 if(group[i].el.isVisible(true)){
20733 for(var i in group){
20738 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20745 * Mark this field as valid
20747 markValid : function()
20751 this.fireEvent('valid', this);
20753 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20756 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20763 if(this.inputType == 'radio'){
20764 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20765 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20766 e.findParent('.form-group', false, true).addClass(_this.validClass);
20773 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20774 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20778 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20784 for(var i in group){
20785 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20786 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20791 * Mark this field as invalid
20792 * @param {String} msg The validation message
20794 markInvalid : function(msg)
20796 if(this.allowBlank){
20802 this.fireEvent('invalid', this, msg);
20804 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20807 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20811 label.markInvalid();
20814 if(this.inputType == 'radio'){
20815 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20816 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20817 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20824 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20825 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20829 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20835 for(var i in group){
20836 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20837 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20842 clearInvalid : function()
20844 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20846 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20848 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20850 if (label && label.iconEl) {
20851 label.iconEl.removeClass(label.validClass);
20852 label.iconEl.removeClass(label.invalidClass);
20856 disable : function()
20858 if(this.inputType != 'radio'){
20859 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20866 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20867 _this.getActionEl().addClass(this.disabledClass);
20868 e.dom.disabled = true;
20872 this.disabled = true;
20873 this.fireEvent("disable", this);
20877 enable : function()
20879 if(this.inputType != 'radio'){
20880 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20887 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20888 _this.getActionEl().removeClass(this.disabledClass);
20889 e.dom.disabled = false;
20893 this.disabled = false;
20894 this.fireEvent("enable", this);
20898 setBoxLabel : function(v)
20903 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20909 Roo.apply(Roo.bootstrap.CheckBox, {
20914 * register a CheckBox Group
20915 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20917 register : function(checkbox)
20919 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20920 this.groups[checkbox.groupId] = {};
20923 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20927 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20931 * fetch a CheckBox Group based on the group ID
20932 * @param {string} the group ID
20933 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20935 get: function(groupId) {
20936 if (typeof(this.groups[groupId]) == 'undefined') {
20940 return this.groups[groupId] ;
20953 * @class Roo.bootstrap.Radio
20954 * @extends Roo.bootstrap.Component
20955 * Bootstrap Radio class
20956 * @cfg {String} boxLabel - the label associated
20957 * @cfg {String} value - the value of radio
20960 * Create a new Radio
20961 * @param {Object} config The config object
20963 Roo.bootstrap.Radio = function(config){
20964 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20968 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20974 getAutoCreate : function()
20978 cls : 'form-group radio',
20983 html : this.boxLabel
20991 initEvents : function()
20993 this.parent().register(this);
20995 this.el.on('click', this.onClick, this);
20999 onClick : function(e)
21001 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21002 this.setChecked(true);
21006 setChecked : function(state, suppressEvent)
21008 this.parent().setValue(this.value, suppressEvent);
21012 setBoxLabel : function(v)
21017 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21032 * @class Roo.bootstrap.SecurePass
21033 * @extends Roo.bootstrap.Input
21034 * Bootstrap SecurePass class
21038 * Create a new SecurePass
21039 * @param {Object} config The config object
21042 Roo.bootstrap.SecurePass = function (config) {
21043 // these go here, so the translation tool can replace them..
21045 PwdEmpty: "Please type a password, and then retype it to confirm.",
21046 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21047 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21048 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21049 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21050 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21051 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21052 TooWeak: "Your password is Too Weak."
21054 this.meterLabel = "Password strength:";
21055 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21056 this.meterClass = [
21057 "roo-password-meter-tooweak",
21058 "roo-password-meter-weak",
21059 "roo-password-meter-medium",
21060 "roo-password-meter-strong",
21061 "roo-password-meter-grey"
21066 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21069 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21071 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21073 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21074 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21075 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21076 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21077 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21078 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21079 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21089 * @cfg {String/Object} Label for the strength meter (defaults to
21090 * 'Password strength:')
21095 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21096 * ['Weak', 'Medium', 'Strong'])
21099 pwdStrengths: false,
21112 initEvents: function ()
21114 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21116 if (this.el.is('input[type=password]') && Roo.isSafari) {
21117 this.el.on('keydown', this.SafariOnKeyDown, this);
21120 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21123 onRender: function (ct, position)
21125 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21126 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21127 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21129 this.trigger.createChild({
21134 cls: 'roo-password-meter-grey col-xs-12',
21137 //width: this.meterWidth + 'px'
21141 cls: 'roo-password-meter-text'
21147 if (this.hideTrigger) {
21148 this.trigger.setDisplayed(false);
21150 this.setSize(this.width || '', this.height || '');
21153 onDestroy: function ()
21155 if (this.trigger) {
21156 this.trigger.removeAllListeners();
21157 this.trigger.remove();
21160 this.wrap.remove();
21162 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21165 checkStrength: function ()
21167 var pwd = this.inputEl().getValue();
21168 if (pwd == this._lastPwd) {
21173 if (this.ClientSideStrongPassword(pwd)) {
21175 } else if (this.ClientSideMediumPassword(pwd)) {
21177 } else if (this.ClientSideWeakPassword(pwd)) {
21183 Roo.log('strength1: ' + strength);
21185 //var pm = this.trigger.child('div/div/div').dom;
21186 var pm = this.trigger.child('div/div');
21187 pm.removeClass(this.meterClass);
21188 pm.addClass(this.meterClass[strength]);
21191 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21193 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21195 this._lastPwd = pwd;
21199 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21201 this._lastPwd = '';
21203 var pm = this.trigger.child('div/div');
21204 pm.removeClass(this.meterClass);
21205 pm.addClass('roo-password-meter-grey');
21208 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21211 this.inputEl().dom.type='password';
21214 validateValue: function (value)
21217 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21220 if (value.length == 0) {
21221 if (this.allowBlank) {
21222 this.clearInvalid();
21226 this.markInvalid(this.errors.PwdEmpty);
21227 this.errorMsg = this.errors.PwdEmpty;
21235 if ('[\x21-\x7e]*'.match(value)) {
21236 this.markInvalid(this.errors.PwdBadChar);
21237 this.errorMsg = this.errors.PwdBadChar;
21240 if (value.length < 6) {
21241 this.markInvalid(this.errors.PwdShort);
21242 this.errorMsg = this.errors.PwdShort;
21245 if (value.length > 16) {
21246 this.markInvalid(this.errors.PwdLong);
21247 this.errorMsg = this.errors.PwdLong;
21251 if (this.ClientSideStrongPassword(value)) {
21253 } else if (this.ClientSideMediumPassword(value)) {
21255 } else if (this.ClientSideWeakPassword(value)) {
21262 if (strength < 2) {
21263 //this.markInvalid(this.errors.TooWeak);
21264 this.errorMsg = this.errors.TooWeak;
21269 console.log('strength2: ' + strength);
21271 //var pm = this.trigger.child('div/div/div').dom;
21273 var pm = this.trigger.child('div/div');
21274 pm.removeClass(this.meterClass);
21275 pm.addClass(this.meterClass[strength]);
21277 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21279 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21281 this.errorMsg = '';
21285 CharacterSetChecks: function (type)
21288 this.fResult = false;
21291 isctype: function (character, type)
21294 case this.kCapitalLetter:
21295 if (character >= 'A' && character <= 'Z') {
21300 case this.kSmallLetter:
21301 if (character >= 'a' && character <= 'z') {
21307 if (character >= '0' && character <= '9') {
21312 case this.kPunctuation:
21313 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21324 IsLongEnough: function (pwd, size)
21326 return !(pwd == null || isNaN(size) || pwd.length < size);
21329 SpansEnoughCharacterSets: function (word, nb)
21331 if (!this.IsLongEnough(word, nb))
21336 var characterSetChecks = new Array(
21337 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21338 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21341 for (var index = 0; index < word.length; ++index) {
21342 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21343 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21344 characterSetChecks[nCharSet].fResult = true;
21351 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21352 if (characterSetChecks[nCharSet].fResult) {
21357 if (nCharSets < nb) {
21363 ClientSideStrongPassword: function (pwd)
21365 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21368 ClientSideMediumPassword: function (pwd)
21370 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21373 ClientSideWeakPassword: function (pwd)
21375 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21378 })//<script type="text/javascript">
21381 * Based Ext JS Library 1.1.1
21382 * Copyright(c) 2006-2007, Ext JS, LLC.
21388 * @class Roo.HtmlEditorCore
21389 * @extends Roo.Component
21390 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21392 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21395 Roo.HtmlEditorCore = function(config){
21398 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21403 * @event initialize
21404 * Fires when the editor is fully initialized (including the iframe)
21405 * @param {Roo.HtmlEditorCore} this
21410 * Fires when the editor is first receives the focus. Any insertion must wait
21411 * until after this event.
21412 * @param {Roo.HtmlEditorCore} this
21416 * @event beforesync
21417 * Fires before the textarea is updated with content from the editor iframe. Return false
21418 * to cancel the sync.
21419 * @param {Roo.HtmlEditorCore} this
21420 * @param {String} html
21424 * @event beforepush
21425 * Fires before the iframe editor is updated with content from the textarea. Return false
21426 * to cancel the push.
21427 * @param {Roo.HtmlEditorCore} this
21428 * @param {String} html
21433 * Fires when the textarea is updated with content from the editor iframe.
21434 * @param {Roo.HtmlEditorCore} this
21435 * @param {String} html
21440 * Fires when the iframe editor is updated with content from the textarea.
21441 * @param {Roo.HtmlEditorCore} this
21442 * @param {String} html
21447 * @event editorevent
21448 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21449 * @param {Roo.HtmlEditorCore} this
21455 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21457 // defaults : white / black...
21458 this.applyBlacklists();
21465 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21469 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21475 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21480 * @cfg {Number} height (in pixels)
21484 * @cfg {Number} width (in pixels)
21489 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21492 stylesheets: false,
21497 // private properties
21498 validationEvent : false,
21500 initialized : false,
21502 sourceEditMode : false,
21503 onFocus : Roo.emptyFn,
21505 hideMode:'offsets',
21509 // blacklist + whitelisted elements..
21516 * Protected method that will not generally be called directly. It
21517 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21518 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21520 getDocMarkup : function(){
21524 // inherit styels from page...??
21525 if (this.stylesheets === false) {
21527 Roo.get(document.head).select('style').each(function(node) {
21528 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21531 Roo.get(document.head).select('link').each(function(node) {
21532 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21535 } else if (!this.stylesheets.length) {
21537 st = '<style type="text/css">' +
21538 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21541 st = '<style type="text/css">' +
21546 st += '<style type="text/css">' +
21547 'IMG { cursor: pointer } ' +
21550 var cls = 'roo-htmleditor-body';
21552 if(this.bodyCls.length){
21553 cls += ' ' + this.bodyCls;
21556 return '<html><head>' + st +
21557 //<style type="text/css">' +
21558 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21560 ' </head><body class="' + cls + '"></body></html>';
21564 onRender : function(ct, position)
21567 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21568 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21571 this.el.dom.style.border = '0 none';
21572 this.el.dom.setAttribute('tabIndex', -1);
21573 this.el.addClass('x-hidden hide');
21577 if(Roo.isIE){ // fix IE 1px bogus margin
21578 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21582 this.frameId = Roo.id();
21586 var iframe = this.owner.wrap.createChild({
21588 cls: 'form-control', // bootstrap..
21590 name: this.frameId,
21591 frameBorder : 'no',
21592 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21597 this.iframe = iframe.dom;
21599 this.assignDocWin();
21601 this.doc.designMode = 'on';
21604 this.doc.write(this.getDocMarkup());
21608 var task = { // must defer to wait for browser to be ready
21610 //console.log("run task?" + this.doc.readyState);
21611 this.assignDocWin();
21612 if(this.doc.body || this.doc.readyState == 'complete'){
21614 this.doc.designMode="on";
21618 Roo.TaskMgr.stop(task);
21619 this.initEditor.defer(10, this);
21626 Roo.TaskMgr.start(task);
21631 onResize : function(w, h)
21633 Roo.log('resize: ' +w + ',' + h );
21634 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21638 if(typeof w == 'number'){
21640 this.iframe.style.width = w + 'px';
21642 if(typeof h == 'number'){
21644 this.iframe.style.height = h + 'px';
21646 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21653 * Toggles the editor between standard and source edit mode.
21654 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21656 toggleSourceEdit : function(sourceEditMode){
21658 this.sourceEditMode = sourceEditMode === true;
21660 if(this.sourceEditMode){
21662 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21665 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21666 //this.iframe.className = '';
21669 //this.setSize(this.owner.wrap.getSize());
21670 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21677 * Protected method that will not generally be called directly. If you need/want
21678 * custom HTML cleanup, this is the method you should override.
21679 * @param {String} html The HTML to be cleaned
21680 * return {String} The cleaned HTML
21682 cleanHtml : function(html){
21683 html = String(html);
21684 if(html.length > 5){
21685 if(Roo.isSafari){ // strip safari nonsense
21686 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21689 if(html == ' '){
21696 * HTML Editor -> Textarea
21697 * Protected method that will not generally be called directly. Syncs the contents
21698 * of the editor iframe with the textarea.
21700 syncValue : function(){
21701 if(this.initialized){
21702 var bd = (this.doc.body || this.doc.documentElement);
21703 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21704 var html = bd.innerHTML;
21706 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21707 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21709 html = '<div style="'+m[0]+'">' + html + '</div>';
21712 html = this.cleanHtml(html);
21713 // fix up the special chars.. normaly like back quotes in word...
21714 // however we do not want to do this with chinese..
21715 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21716 var cc = b.charCodeAt();
21718 (cc >= 0x4E00 && cc < 0xA000 ) ||
21719 (cc >= 0x3400 && cc < 0x4E00 ) ||
21720 (cc >= 0xf900 && cc < 0xfb00 )
21726 if(this.owner.fireEvent('beforesync', this, html) !== false){
21727 this.el.dom.value = html;
21728 this.owner.fireEvent('sync', this, html);
21734 * Protected method that will not generally be called directly. Pushes the value of the textarea
21735 * into the iframe editor.
21737 pushValue : function(){
21738 if(this.initialized){
21739 var v = this.el.dom.value.trim();
21741 // if(v.length < 1){
21745 if(this.owner.fireEvent('beforepush', this, v) !== false){
21746 var d = (this.doc.body || this.doc.documentElement);
21748 this.cleanUpPaste();
21749 this.el.dom.value = d.innerHTML;
21750 this.owner.fireEvent('push', this, v);
21756 deferFocus : function(){
21757 this.focus.defer(10, this);
21761 focus : function(){
21762 if(this.win && !this.sourceEditMode){
21769 assignDocWin: function()
21771 var iframe = this.iframe;
21774 this.doc = iframe.contentWindow.document;
21775 this.win = iframe.contentWindow;
21777 // if (!Roo.get(this.frameId)) {
21780 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21781 // this.win = Roo.get(this.frameId).dom.contentWindow;
21783 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21787 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21788 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21793 initEditor : function(){
21794 //console.log("INIT EDITOR");
21795 this.assignDocWin();
21799 this.doc.designMode="on";
21801 this.doc.write(this.getDocMarkup());
21804 var dbody = (this.doc.body || this.doc.documentElement);
21805 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21806 // this copies styles from the containing element into thsi one..
21807 // not sure why we need all of this..
21808 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21810 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21811 //ss['background-attachment'] = 'fixed'; // w3c
21812 dbody.bgProperties = 'fixed'; // ie
21813 //Roo.DomHelper.applyStyles(dbody, ss);
21814 Roo.EventManager.on(this.doc, {
21815 //'mousedown': this.onEditorEvent,
21816 'mouseup': this.onEditorEvent,
21817 'dblclick': this.onEditorEvent,
21818 'click': this.onEditorEvent,
21819 'keyup': this.onEditorEvent,
21824 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21826 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21827 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21829 this.initialized = true;
21831 this.owner.fireEvent('initialize', this);
21836 onDestroy : function(){
21842 //for (var i =0; i < this.toolbars.length;i++) {
21843 // // fixme - ask toolbars for heights?
21844 // this.toolbars[i].onDestroy();
21847 //this.wrap.dom.innerHTML = '';
21848 //this.wrap.remove();
21853 onFirstFocus : function(){
21855 this.assignDocWin();
21858 this.activated = true;
21861 if(Roo.isGecko){ // prevent silly gecko errors
21863 var s = this.win.getSelection();
21864 if(!s.focusNode || s.focusNode.nodeType != 3){
21865 var r = s.getRangeAt(0);
21866 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21871 this.execCmd('useCSS', true);
21872 this.execCmd('styleWithCSS', false);
21875 this.owner.fireEvent('activate', this);
21879 adjustFont: function(btn){
21880 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21881 //if(Roo.isSafari){ // safari
21884 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21885 if(Roo.isSafari){ // safari
21886 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21887 v = (v < 10) ? 10 : v;
21888 v = (v > 48) ? 48 : v;
21889 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21894 v = Math.max(1, v+adjust);
21896 this.execCmd('FontSize', v );
21899 onEditorEvent : function(e)
21901 this.owner.fireEvent('editorevent', this, e);
21902 // this.updateToolbar();
21903 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21906 insertTag : function(tg)
21908 // could be a bit smarter... -> wrap the current selected tRoo..
21909 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21911 range = this.createRange(this.getSelection());
21912 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21913 wrappingNode.appendChild(range.extractContents());
21914 range.insertNode(wrappingNode);
21921 this.execCmd("formatblock", tg);
21925 insertText : function(txt)
21929 var range = this.createRange();
21930 range.deleteContents();
21931 //alert(Sender.getAttribute('label'));
21933 range.insertNode(this.doc.createTextNode(txt));
21939 * Executes a Midas editor command on the editor document and performs necessary focus and
21940 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21941 * @param {String} cmd The Midas command
21942 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21944 relayCmd : function(cmd, value){
21946 this.execCmd(cmd, value);
21947 this.owner.fireEvent('editorevent', this);
21948 //this.updateToolbar();
21949 this.owner.deferFocus();
21953 * Executes a Midas editor command directly on the editor document.
21954 * For visual commands, you should use {@link #relayCmd} instead.
21955 * <b>This should only be called after the editor is initialized.</b>
21956 * @param {String} cmd The Midas command
21957 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21959 execCmd : function(cmd, value){
21960 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21967 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21969 * @param {String} text | dom node..
21971 insertAtCursor : function(text)
21974 if(!this.activated){
21980 var r = this.doc.selection.createRange();
21991 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21995 // from jquery ui (MIT licenced)
21997 var win = this.win;
21999 if (win.getSelection && win.getSelection().getRangeAt) {
22000 range = win.getSelection().getRangeAt(0);
22001 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22002 range.insertNode(node);
22003 } else if (win.document.selection && win.document.selection.createRange) {
22004 // no firefox support
22005 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22006 win.document.selection.createRange().pasteHTML(txt);
22008 // no firefox support
22009 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22010 this.execCmd('InsertHTML', txt);
22019 mozKeyPress : function(e){
22021 var c = e.getCharCode(), cmd;
22024 c = String.fromCharCode(c).toLowerCase();
22038 this.cleanUpPaste.defer(100, this);
22046 e.preventDefault();
22054 fixKeys : function(){ // load time branching for fastest keydown performance
22056 return function(e){
22057 var k = e.getKey(), r;
22060 r = this.doc.selection.createRange();
22063 r.pasteHTML('    ');
22070 r = this.doc.selection.createRange();
22072 var target = r.parentElement();
22073 if(!target || target.tagName.toLowerCase() != 'li'){
22075 r.pasteHTML('<br />');
22081 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22082 this.cleanUpPaste.defer(100, this);
22088 }else if(Roo.isOpera){
22089 return function(e){
22090 var k = e.getKey();
22094 this.execCmd('InsertHTML','    ');
22097 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22098 this.cleanUpPaste.defer(100, this);
22103 }else if(Roo.isSafari){
22104 return function(e){
22105 var k = e.getKey();
22109 this.execCmd('InsertText','\t');
22113 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22114 this.cleanUpPaste.defer(100, this);
22122 getAllAncestors: function()
22124 var p = this.getSelectedNode();
22127 a.push(p); // push blank onto stack..
22128 p = this.getParentElement();
22132 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22136 a.push(this.doc.body);
22140 lastSelNode : false,
22143 getSelection : function()
22145 this.assignDocWin();
22146 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22149 getSelectedNode: function()
22151 // this may only work on Gecko!!!
22153 // should we cache this!!!!
22158 var range = this.createRange(this.getSelection()).cloneRange();
22161 var parent = range.parentElement();
22163 var testRange = range.duplicate();
22164 testRange.moveToElementText(parent);
22165 if (testRange.inRange(range)) {
22168 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22171 parent = parent.parentElement;
22176 // is ancestor a text element.
22177 var ac = range.commonAncestorContainer;
22178 if (ac.nodeType == 3) {
22179 ac = ac.parentNode;
22182 var ar = ac.childNodes;
22185 var other_nodes = [];
22186 var has_other_nodes = false;
22187 for (var i=0;i<ar.length;i++) {
22188 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22191 // fullly contained node.
22193 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22198 // probably selected..
22199 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22200 other_nodes.push(ar[i]);
22204 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22209 has_other_nodes = true;
22211 if (!nodes.length && other_nodes.length) {
22212 nodes= other_nodes;
22214 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22220 createRange: function(sel)
22222 // this has strange effects when using with
22223 // top toolbar - not sure if it's a great idea.
22224 //this.editor.contentWindow.focus();
22225 if (typeof sel != "undefined") {
22227 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22229 return this.doc.createRange();
22232 return this.doc.createRange();
22235 getParentElement: function()
22238 this.assignDocWin();
22239 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22241 var range = this.createRange(sel);
22244 var p = range.commonAncestorContainer;
22245 while (p.nodeType == 3) { // text node
22256 * Range intersection.. the hard stuff...
22260 * [ -- selected range --- ]
22264 * if end is before start or hits it. fail.
22265 * if start is after end or hits it fail.
22267 * if either hits (but other is outside. - then it's not
22273 // @see http://www.thismuchiknow.co.uk/?p=64.
22274 rangeIntersectsNode : function(range, node)
22276 var nodeRange = node.ownerDocument.createRange();
22278 nodeRange.selectNode(node);
22280 nodeRange.selectNodeContents(node);
22283 var rangeStartRange = range.cloneRange();
22284 rangeStartRange.collapse(true);
22286 var rangeEndRange = range.cloneRange();
22287 rangeEndRange.collapse(false);
22289 var nodeStartRange = nodeRange.cloneRange();
22290 nodeStartRange.collapse(true);
22292 var nodeEndRange = nodeRange.cloneRange();
22293 nodeEndRange.collapse(false);
22295 return rangeStartRange.compareBoundaryPoints(
22296 Range.START_TO_START, nodeEndRange) == -1 &&
22297 rangeEndRange.compareBoundaryPoints(
22298 Range.START_TO_START, nodeStartRange) == 1;
22302 rangeCompareNode : function(range, node)
22304 var nodeRange = node.ownerDocument.createRange();
22306 nodeRange.selectNode(node);
22308 nodeRange.selectNodeContents(node);
22312 range.collapse(true);
22314 nodeRange.collapse(true);
22316 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22317 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22319 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22321 var nodeIsBefore = ss == 1;
22322 var nodeIsAfter = ee == -1;
22324 if (nodeIsBefore && nodeIsAfter) {
22327 if (!nodeIsBefore && nodeIsAfter) {
22328 return 1; //right trailed.
22331 if (nodeIsBefore && !nodeIsAfter) {
22332 return 2; // left trailed.
22338 // private? - in a new class?
22339 cleanUpPaste : function()
22341 // cleans up the whole document..
22342 Roo.log('cleanuppaste');
22344 this.cleanUpChildren(this.doc.body);
22345 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22346 if (clean != this.doc.body.innerHTML) {
22347 this.doc.body.innerHTML = clean;
22352 cleanWordChars : function(input) {// change the chars to hex code
22353 var he = Roo.HtmlEditorCore;
22355 var output = input;
22356 Roo.each(he.swapCodes, function(sw) {
22357 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22359 output = output.replace(swapper, sw[1]);
22366 cleanUpChildren : function (n)
22368 if (!n.childNodes.length) {
22371 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22372 this.cleanUpChild(n.childNodes[i]);
22379 cleanUpChild : function (node)
22382 //console.log(node);
22383 if (node.nodeName == "#text") {
22384 // clean up silly Windows -- stuff?
22387 if (node.nodeName == "#comment") {
22388 node.parentNode.removeChild(node);
22389 // clean up silly Windows -- stuff?
22392 var lcname = node.tagName.toLowerCase();
22393 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22394 // whitelist of tags..
22396 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22398 node.parentNode.removeChild(node);
22403 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22405 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22406 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22408 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22409 // remove_keep_children = true;
22412 if (remove_keep_children) {
22413 this.cleanUpChildren(node);
22414 // inserts everything just before this node...
22415 while (node.childNodes.length) {
22416 var cn = node.childNodes[0];
22417 node.removeChild(cn);
22418 node.parentNode.insertBefore(cn, node);
22420 node.parentNode.removeChild(node);
22424 if (!node.attributes || !node.attributes.length) {
22425 this.cleanUpChildren(node);
22429 function cleanAttr(n,v)
22432 if (v.match(/^\./) || v.match(/^\//)) {
22435 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22438 if (v.match(/^#/)) {
22441 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22442 node.removeAttribute(n);
22446 var cwhite = this.cwhite;
22447 var cblack = this.cblack;
22449 function cleanStyle(n,v)
22451 if (v.match(/expression/)) { //XSS?? should we even bother..
22452 node.removeAttribute(n);
22456 var parts = v.split(/;/);
22459 Roo.each(parts, function(p) {
22460 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22464 var l = p.split(':').shift().replace(/\s+/g,'');
22465 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22467 if ( cwhite.length && cblack.indexOf(l) > -1) {
22468 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22469 //node.removeAttribute(n);
22473 // only allow 'c whitelisted system attributes'
22474 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22475 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22476 //node.removeAttribute(n);
22486 if (clean.length) {
22487 node.setAttribute(n, clean.join(';'));
22489 node.removeAttribute(n);
22495 for (var i = node.attributes.length-1; i > -1 ; i--) {
22496 var a = node.attributes[i];
22499 if (a.name.toLowerCase().substr(0,2)=='on') {
22500 node.removeAttribute(a.name);
22503 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22504 node.removeAttribute(a.name);
22507 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22508 cleanAttr(a.name,a.value); // fixme..
22511 if (a.name == 'style') {
22512 cleanStyle(a.name,a.value);
22515 /// clean up MS crap..
22516 // tecnically this should be a list of valid class'es..
22519 if (a.name == 'class') {
22520 if (a.value.match(/^Mso/)) {
22521 node.className = '';
22524 if (a.value.match(/^body$/)) {
22525 node.className = '';
22536 this.cleanUpChildren(node);
22542 * Clean up MS wordisms...
22544 cleanWord : function(node)
22549 this.cleanWord(this.doc.body);
22552 if (node.nodeName == "#text") {
22553 // clean up silly Windows -- stuff?
22556 if (node.nodeName == "#comment") {
22557 node.parentNode.removeChild(node);
22558 // clean up silly Windows -- stuff?
22562 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22563 node.parentNode.removeChild(node);
22567 // remove - but keep children..
22568 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22569 while (node.childNodes.length) {
22570 var cn = node.childNodes[0];
22571 node.removeChild(cn);
22572 node.parentNode.insertBefore(cn, node);
22574 node.parentNode.removeChild(node);
22575 this.iterateChildren(node, this.cleanWord);
22579 if (node.className.length) {
22581 var cn = node.className.split(/\W+/);
22583 Roo.each(cn, function(cls) {
22584 if (cls.match(/Mso[a-zA-Z]+/)) {
22589 node.className = cna.length ? cna.join(' ') : '';
22591 node.removeAttribute("class");
22595 if (node.hasAttribute("lang")) {
22596 node.removeAttribute("lang");
22599 if (node.hasAttribute("style")) {
22601 var styles = node.getAttribute("style").split(";");
22603 Roo.each(styles, function(s) {
22604 if (!s.match(/:/)) {
22607 var kv = s.split(":");
22608 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22611 // what ever is left... we allow.
22614 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22615 if (!nstyle.length) {
22616 node.removeAttribute('style');
22619 this.iterateChildren(node, this.cleanWord);
22625 * iterateChildren of a Node, calling fn each time, using this as the scole..
22626 * @param {DomNode} node node to iterate children of.
22627 * @param {Function} fn method of this class to call on each item.
22629 iterateChildren : function(node, fn)
22631 if (!node.childNodes.length) {
22634 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22635 fn.call(this, node.childNodes[i])
22641 * cleanTableWidths.
22643 * Quite often pasting from word etc.. results in tables with column and widths.
22644 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22647 cleanTableWidths : function(node)
22652 this.cleanTableWidths(this.doc.body);
22657 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22660 Roo.log(node.tagName);
22661 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22662 this.iterateChildren(node, this.cleanTableWidths);
22665 if (node.hasAttribute('width')) {
22666 node.removeAttribute('width');
22670 if (node.hasAttribute("style")) {
22673 var styles = node.getAttribute("style").split(";");
22675 Roo.each(styles, function(s) {
22676 if (!s.match(/:/)) {
22679 var kv = s.split(":");
22680 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22683 // what ever is left... we allow.
22686 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22687 if (!nstyle.length) {
22688 node.removeAttribute('style');
22692 this.iterateChildren(node, this.cleanTableWidths);
22700 domToHTML : function(currentElement, depth, nopadtext) {
22702 depth = depth || 0;
22703 nopadtext = nopadtext || false;
22705 if (!currentElement) {
22706 return this.domToHTML(this.doc.body);
22709 //Roo.log(currentElement);
22711 var allText = false;
22712 var nodeName = currentElement.nodeName;
22713 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22715 if (nodeName == '#text') {
22717 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22722 if (nodeName != 'BODY') {
22725 // Prints the node tagName, such as <A>, <IMG>, etc
22728 for(i = 0; i < currentElement.attributes.length;i++) {
22730 var aname = currentElement.attributes.item(i).name;
22731 if (!currentElement.attributes.item(i).value.length) {
22734 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22737 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22746 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22749 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22754 // Traverse the tree
22756 var currentElementChild = currentElement.childNodes.item(i);
22757 var allText = true;
22758 var innerHTML = '';
22760 while (currentElementChild) {
22761 // Formatting code (indent the tree so it looks nice on the screen)
22762 var nopad = nopadtext;
22763 if (lastnode == 'SPAN') {
22767 if (currentElementChild.nodeName == '#text') {
22768 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22769 toadd = nopadtext ? toadd : toadd.trim();
22770 if (!nopad && toadd.length > 80) {
22771 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22773 innerHTML += toadd;
22776 currentElementChild = currentElement.childNodes.item(i);
22782 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22784 // Recursively traverse the tree structure of the child node
22785 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22786 lastnode = currentElementChild.nodeName;
22788 currentElementChild=currentElement.childNodes.item(i);
22794 // The remaining code is mostly for formatting the tree
22795 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22800 ret+= "</"+tagName+">";
22806 applyBlacklists : function()
22808 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22809 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22813 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22814 if (b.indexOf(tag) > -1) {
22817 this.white.push(tag);
22821 Roo.each(w, function(tag) {
22822 if (b.indexOf(tag) > -1) {
22825 if (this.white.indexOf(tag) > -1) {
22828 this.white.push(tag);
22833 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22834 if (w.indexOf(tag) > -1) {
22837 this.black.push(tag);
22841 Roo.each(b, function(tag) {
22842 if (w.indexOf(tag) > -1) {
22845 if (this.black.indexOf(tag) > -1) {
22848 this.black.push(tag);
22853 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22854 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22858 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22859 if (b.indexOf(tag) > -1) {
22862 this.cwhite.push(tag);
22866 Roo.each(w, function(tag) {
22867 if (b.indexOf(tag) > -1) {
22870 if (this.cwhite.indexOf(tag) > -1) {
22873 this.cwhite.push(tag);
22878 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22879 if (w.indexOf(tag) > -1) {
22882 this.cblack.push(tag);
22886 Roo.each(b, function(tag) {
22887 if (w.indexOf(tag) > -1) {
22890 if (this.cblack.indexOf(tag) > -1) {
22893 this.cblack.push(tag);
22898 setStylesheets : function(stylesheets)
22900 if(typeof(stylesheets) == 'string'){
22901 Roo.get(this.iframe.contentDocument.head).createChild({
22903 rel : 'stylesheet',
22912 Roo.each(stylesheets, function(s) {
22917 Roo.get(_this.iframe.contentDocument.head).createChild({
22919 rel : 'stylesheet',
22928 removeStylesheets : function()
22932 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22937 setStyle : function(style)
22939 Roo.get(this.iframe.contentDocument.head).createChild({
22948 // hide stuff that is not compatible
22962 * @event specialkey
22966 * @cfg {String} fieldClass @hide
22969 * @cfg {String} focusClass @hide
22972 * @cfg {String} autoCreate @hide
22975 * @cfg {String} inputType @hide
22978 * @cfg {String} invalidClass @hide
22981 * @cfg {String} invalidText @hide
22984 * @cfg {String} msgFx @hide
22987 * @cfg {String} validateOnBlur @hide
22991 Roo.HtmlEditorCore.white = [
22992 'area', 'br', 'img', 'input', 'hr', 'wbr',
22994 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22995 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22996 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22997 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22998 'table', 'ul', 'xmp',
23000 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23003 'dir', 'menu', 'ol', 'ul', 'dl',
23009 Roo.HtmlEditorCore.black = [
23010 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23012 'base', 'basefont', 'bgsound', 'blink', 'body',
23013 'frame', 'frameset', 'head', 'html', 'ilayer',
23014 'iframe', 'layer', 'link', 'meta', 'object',
23015 'script', 'style' ,'title', 'xml' // clean later..
23017 Roo.HtmlEditorCore.clean = [
23018 'script', 'style', 'title', 'xml'
23020 Roo.HtmlEditorCore.remove = [
23025 Roo.HtmlEditorCore.ablack = [
23029 Roo.HtmlEditorCore.aclean = [
23030 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23034 Roo.HtmlEditorCore.pwhite= [
23035 'http', 'https', 'mailto'
23038 // white listed style attributes.
23039 Roo.HtmlEditorCore.cwhite= [
23040 // 'text-align', /// default is to allow most things..
23046 // black listed style attributes.
23047 Roo.HtmlEditorCore.cblack= [
23048 // 'font-size' -- this can be set by the project
23052 Roo.HtmlEditorCore.swapCodes =[
23071 * @class Roo.bootstrap.HtmlEditor
23072 * @extends Roo.bootstrap.TextArea
23073 * Bootstrap HtmlEditor class
23076 * Create a new HtmlEditor
23077 * @param {Object} config The config object
23080 Roo.bootstrap.HtmlEditor = function(config){
23081 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23082 if (!this.toolbars) {
23083 this.toolbars = [];
23086 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23089 * @event initialize
23090 * Fires when the editor is fully initialized (including the iframe)
23091 * @param {HtmlEditor} this
23096 * Fires when the editor is first receives the focus. Any insertion must wait
23097 * until after this event.
23098 * @param {HtmlEditor} this
23102 * @event beforesync
23103 * Fires before the textarea is updated with content from the editor iframe. Return false
23104 * to cancel the sync.
23105 * @param {HtmlEditor} this
23106 * @param {String} html
23110 * @event beforepush
23111 * Fires before the iframe editor is updated with content from the textarea. Return false
23112 * to cancel the push.
23113 * @param {HtmlEditor} this
23114 * @param {String} html
23119 * Fires when the textarea is updated with content from the editor iframe.
23120 * @param {HtmlEditor} this
23121 * @param {String} html
23126 * Fires when the iframe editor is updated with content from the textarea.
23127 * @param {HtmlEditor} this
23128 * @param {String} html
23132 * @event editmodechange
23133 * Fires when the editor switches edit modes
23134 * @param {HtmlEditor} this
23135 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23137 editmodechange: true,
23139 * @event editorevent
23140 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23141 * @param {HtmlEditor} this
23145 * @event firstfocus
23146 * Fires when on first focus - needed by toolbars..
23147 * @param {HtmlEditor} this
23152 * Auto save the htmlEditor value as a file into Events
23153 * @param {HtmlEditor} this
23157 * @event savedpreview
23158 * preview the saved version of htmlEditor
23159 * @param {HtmlEditor} this
23166 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23170 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23175 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23180 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23185 * @cfg {Number} height (in pixels)
23189 * @cfg {Number} width (in pixels)
23194 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23197 stylesheets: false,
23202 // private properties
23203 validationEvent : false,
23205 initialized : false,
23208 onFocus : Roo.emptyFn,
23210 hideMode:'offsets',
23212 tbContainer : false,
23216 toolbarContainer :function() {
23217 return this.wrap.select('.x-html-editor-tb',true).first();
23221 * Protected method that will not generally be called directly. It
23222 * is called when the editor creates its toolbar. Override this method if you need to
23223 * add custom toolbar buttons.
23224 * @param {HtmlEditor} editor
23226 createToolbar : function(){
23227 Roo.log('renewing');
23228 Roo.log("create toolbars");
23230 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23231 this.toolbars[0].render(this.toolbarContainer());
23235 // if (!editor.toolbars || !editor.toolbars.length) {
23236 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23239 // for (var i =0 ; i < editor.toolbars.length;i++) {
23240 // editor.toolbars[i] = Roo.factory(
23241 // typeof(editor.toolbars[i]) == 'string' ?
23242 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23243 // Roo.bootstrap.HtmlEditor);
23244 // editor.toolbars[i].init(editor);
23250 onRender : function(ct, position)
23252 // Roo.log("Call onRender: " + this.xtype);
23254 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23256 this.wrap = this.inputEl().wrap({
23257 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23260 this.editorcore.onRender(ct, position);
23262 if (this.resizable) {
23263 this.resizeEl = new Roo.Resizable(this.wrap, {
23267 minHeight : this.height,
23268 height: this.height,
23269 handles : this.resizable,
23272 resize : function(r, w, h) {
23273 _t.onResize(w,h); // -something
23279 this.createToolbar(this);
23282 if(!this.width && this.resizable){
23283 this.setSize(this.wrap.getSize());
23285 if (this.resizeEl) {
23286 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23287 // should trigger onReize..
23293 onResize : function(w, h)
23295 Roo.log('resize: ' +w + ',' + h );
23296 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23300 if(this.inputEl() ){
23301 if(typeof w == 'number'){
23302 var aw = w - this.wrap.getFrameWidth('lr');
23303 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23306 if(typeof h == 'number'){
23307 var tbh = -11; // fixme it needs to tool bar size!
23308 for (var i =0; i < this.toolbars.length;i++) {
23309 // fixme - ask toolbars for heights?
23310 tbh += this.toolbars[i].el.getHeight();
23311 //if (this.toolbars[i].footer) {
23312 // tbh += this.toolbars[i].footer.el.getHeight();
23320 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23321 ah -= 5; // knock a few pixes off for look..
23322 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23326 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23327 this.editorcore.onResize(ew,eh);
23332 * Toggles the editor between standard and source edit mode.
23333 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23335 toggleSourceEdit : function(sourceEditMode)
23337 this.editorcore.toggleSourceEdit(sourceEditMode);
23339 if(this.editorcore.sourceEditMode){
23340 Roo.log('editor - showing textarea');
23343 // Roo.log(this.syncValue());
23345 this.inputEl().removeClass(['hide', 'x-hidden']);
23346 this.inputEl().dom.removeAttribute('tabIndex');
23347 this.inputEl().focus();
23349 Roo.log('editor - hiding textarea');
23351 // Roo.log(this.pushValue());
23354 this.inputEl().addClass(['hide', 'x-hidden']);
23355 this.inputEl().dom.setAttribute('tabIndex', -1);
23356 //this.deferFocus();
23359 if(this.resizable){
23360 this.setSize(this.wrap.getSize());
23363 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23366 // private (for BoxComponent)
23367 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23369 // private (for BoxComponent)
23370 getResizeEl : function(){
23374 // private (for BoxComponent)
23375 getPositionEl : function(){
23380 initEvents : function(){
23381 this.originalValue = this.getValue();
23385 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23388 // markInvalid : Roo.emptyFn,
23390 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23393 // clearInvalid : Roo.emptyFn,
23395 setValue : function(v){
23396 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23397 this.editorcore.pushValue();
23402 deferFocus : function(){
23403 this.focus.defer(10, this);
23407 focus : function(){
23408 this.editorcore.focus();
23414 onDestroy : function(){
23420 for (var i =0; i < this.toolbars.length;i++) {
23421 // fixme - ask toolbars for heights?
23422 this.toolbars[i].onDestroy();
23425 this.wrap.dom.innerHTML = '';
23426 this.wrap.remove();
23431 onFirstFocus : function(){
23432 //Roo.log("onFirstFocus");
23433 this.editorcore.onFirstFocus();
23434 for (var i =0; i < this.toolbars.length;i++) {
23435 this.toolbars[i].onFirstFocus();
23441 syncValue : function()
23443 this.editorcore.syncValue();
23446 pushValue : function()
23448 this.editorcore.pushValue();
23452 // hide stuff that is not compatible
23466 * @event specialkey
23470 * @cfg {String} fieldClass @hide
23473 * @cfg {String} focusClass @hide
23476 * @cfg {String} autoCreate @hide
23479 * @cfg {String} inputType @hide
23482 * @cfg {String} invalidClass @hide
23485 * @cfg {String} invalidText @hide
23488 * @cfg {String} msgFx @hide
23491 * @cfg {String} validateOnBlur @hide
23500 Roo.namespace('Roo.bootstrap.htmleditor');
23502 * @class Roo.bootstrap.HtmlEditorToolbar1
23507 new Roo.bootstrap.HtmlEditor({
23510 new Roo.bootstrap.HtmlEditorToolbar1({
23511 disable : { fonts: 1 , format: 1, ..., ... , ...],
23517 * @cfg {Object} disable List of elements to disable..
23518 * @cfg {Array} btns List of additional buttons.
23522 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23525 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23528 Roo.apply(this, config);
23530 // default disabled, based on 'good practice'..
23531 this.disable = this.disable || {};
23532 Roo.applyIf(this.disable, {
23535 specialElements : true
23537 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23539 this.editor = config.editor;
23540 this.editorcore = config.editor.editorcore;
23542 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23544 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23545 // dont call parent... till later.
23547 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23552 editorcore : false,
23557 "h1","h2","h3","h4","h5","h6",
23559 "abbr", "acronym", "address", "cite", "samp", "var",
23563 onRender : function(ct, position)
23565 // Roo.log("Call onRender: " + this.xtype);
23567 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23569 this.el.dom.style.marginBottom = '0';
23571 var editorcore = this.editorcore;
23572 var editor= this.editor;
23575 var btn = function(id,cmd , toggle, handler, html){
23577 var event = toggle ? 'toggle' : 'click';
23582 xns: Roo.bootstrap,
23585 enableToggle:toggle !== false,
23587 pressed : toggle ? false : null,
23590 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23591 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23597 // var cb_box = function...
23602 xns: Roo.bootstrap,
23603 glyphicon : 'font',
23607 xns: Roo.bootstrap,
23611 Roo.each(this.formats, function(f) {
23612 style.menu.items.push({
23614 xns: Roo.bootstrap,
23615 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23620 editorcore.insertTag(this.tagname);
23627 children.push(style);
23629 btn('bold',false,true);
23630 btn('italic',false,true);
23631 btn('align-left', 'justifyleft',true);
23632 btn('align-center', 'justifycenter',true);
23633 btn('align-right' , 'justifyright',true);
23634 btn('link', false, false, function(btn) {
23635 //Roo.log("create link?");
23636 var url = prompt(this.createLinkText, this.defaultLinkValue);
23637 if(url && url != 'http:/'+'/'){
23638 this.editorcore.relayCmd('createlink', url);
23641 btn('list','insertunorderedlist',true);
23642 btn('pencil', false,true, function(btn){
23644 this.toggleSourceEdit(btn.pressed);
23647 if (this.editor.btns.length > 0) {
23648 for (var i = 0; i<this.editor.btns.length; i++) {
23649 children.push(this.editor.btns[i]);
23657 xns: Roo.bootstrap,
23662 xns: Roo.bootstrap,
23667 cog.menu.items.push({
23669 xns: Roo.bootstrap,
23670 html : Clean styles,
23675 editorcore.insertTag(this.tagname);
23684 this.xtype = 'NavSimplebar';
23686 for(var i=0;i< children.length;i++) {
23688 this.buttons.add(this.addxtypeChild(children[i]));
23692 editor.on('editorevent', this.updateToolbar, this);
23694 onBtnClick : function(id)
23696 this.editorcore.relayCmd(id);
23697 this.editorcore.focus();
23701 * Protected method that will not generally be called directly. It triggers
23702 * a toolbar update by reading the markup state of the current selection in the editor.
23704 updateToolbar: function(){
23706 if(!this.editorcore.activated){
23707 this.editor.onFirstFocus(); // is this neeed?
23711 var btns = this.buttons;
23712 var doc = this.editorcore.doc;
23713 btns.get('bold').setActive(doc.queryCommandState('bold'));
23714 btns.get('italic').setActive(doc.queryCommandState('italic'));
23715 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23717 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23718 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23719 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23721 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23722 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23725 var ans = this.editorcore.getAllAncestors();
23726 if (this.formatCombo) {
23729 var store = this.formatCombo.store;
23730 this.formatCombo.setValue("");
23731 for (var i =0; i < ans.length;i++) {
23732 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23734 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23742 // hides menus... - so this cant be on a menu...
23743 Roo.bootstrap.MenuMgr.hideAll();
23745 Roo.bootstrap.MenuMgr.hideAll();
23746 //this.editorsyncValue();
23748 onFirstFocus: function() {
23749 this.buttons.each(function(item){
23753 toggleSourceEdit : function(sourceEditMode){
23756 if(sourceEditMode){
23757 Roo.log("disabling buttons");
23758 this.buttons.each( function(item){
23759 if(item.cmd != 'pencil'){
23765 Roo.log("enabling buttons");
23766 if(this.editorcore.initialized){
23767 this.buttons.each( function(item){
23773 Roo.log("calling toggole on editor");
23774 // tell the editor that it's been pressed..
23775 this.editor.toggleSourceEdit(sourceEditMode);
23785 * @class Roo.bootstrap.Table.AbstractSelectionModel
23786 * @extends Roo.util.Observable
23787 * Abstract base class for grid SelectionModels. It provides the interface that should be
23788 * implemented by descendant classes. This class should not be directly instantiated.
23791 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23792 this.locked = false;
23793 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23797 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23798 /** @ignore Called by the grid automatically. Do not call directly. */
23799 init : function(grid){
23805 * Locks the selections.
23808 this.locked = true;
23812 * Unlocks the selections.
23814 unlock : function(){
23815 this.locked = false;
23819 * Returns true if the selections are locked.
23820 * @return {Boolean}
23822 isLocked : function(){
23823 return this.locked;
23827 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23828 * @class Roo.bootstrap.Table.RowSelectionModel
23829 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23830 * It supports multiple selections and keyboard selection/navigation.
23832 * @param {Object} config
23835 Roo.bootstrap.Table.RowSelectionModel = function(config){
23836 Roo.apply(this, config);
23837 this.selections = new Roo.util.MixedCollection(false, function(o){
23842 this.lastActive = false;
23846 * @event selectionchange
23847 * Fires when the selection changes
23848 * @param {SelectionModel} this
23850 "selectionchange" : true,
23852 * @event afterselectionchange
23853 * Fires after the selection changes (eg. by key press or clicking)
23854 * @param {SelectionModel} this
23856 "afterselectionchange" : true,
23858 * @event beforerowselect
23859 * Fires when a row is selected being selected, return false to cancel.
23860 * @param {SelectionModel} this
23861 * @param {Number} rowIndex The selected index
23862 * @param {Boolean} keepExisting False if other selections will be cleared
23864 "beforerowselect" : true,
23867 * Fires when a row is selected.
23868 * @param {SelectionModel} this
23869 * @param {Number} rowIndex The selected index
23870 * @param {Roo.data.Record} r The record
23872 "rowselect" : true,
23874 * @event rowdeselect
23875 * Fires when a row is deselected.
23876 * @param {SelectionModel} this
23877 * @param {Number} rowIndex The selected index
23879 "rowdeselect" : true
23881 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23882 this.locked = false;
23885 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23887 * @cfg {Boolean} singleSelect
23888 * True to allow selection of only one row at a time (defaults to false)
23890 singleSelect : false,
23893 initEvents : function()
23896 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23897 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23898 //}else{ // allow click to work like normal
23899 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23901 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23902 this.grid.on("rowclick", this.handleMouseDown, this);
23904 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23905 "up" : function(e){
23907 this.selectPrevious(e.shiftKey);
23908 }else if(this.last !== false && this.lastActive !== false){
23909 var last = this.last;
23910 this.selectRange(this.last, this.lastActive-1);
23911 this.grid.getView().focusRow(this.lastActive);
23912 if(last !== false){
23916 this.selectFirstRow();
23918 this.fireEvent("afterselectionchange", this);
23920 "down" : function(e){
23922 this.selectNext(e.shiftKey);
23923 }else if(this.last !== false && this.lastActive !== false){
23924 var last = this.last;
23925 this.selectRange(this.last, this.lastActive+1);
23926 this.grid.getView().focusRow(this.lastActive);
23927 if(last !== false){
23931 this.selectFirstRow();
23933 this.fireEvent("afterselectionchange", this);
23937 this.grid.store.on('load', function(){
23938 this.selections.clear();
23941 var view = this.grid.view;
23942 view.on("refresh", this.onRefresh, this);
23943 view.on("rowupdated", this.onRowUpdated, this);
23944 view.on("rowremoved", this.onRemove, this);
23949 onRefresh : function()
23951 var ds = this.grid.store, i, v = this.grid.view;
23952 var s = this.selections;
23953 s.each(function(r){
23954 if((i = ds.indexOfId(r.id)) != -1){
23963 onRemove : function(v, index, r){
23964 this.selections.remove(r);
23968 onRowUpdated : function(v, index, r){
23969 if(this.isSelected(r)){
23970 v.onRowSelect(index);
23976 * @param {Array} records The records to select
23977 * @param {Boolean} keepExisting (optional) True to keep existing selections
23979 selectRecords : function(records, keepExisting)
23982 this.clearSelections();
23984 var ds = this.grid.store;
23985 for(var i = 0, len = records.length; i < len; i++){
23986 this.selectRow(ds.indexOf(records[i]), true);
23991 * Gets the number of selected rows.
23994 getCount : function(){
23995 return this.selections.length;
23999 * Selects the first row in the grid.
24001 selectFirstRow : function(){
24006 * Select the last row.
24007 * @param {Boolean} keepExisting (optional) True to keep existing selections
24009 selectLastRow : function(keepExisting){
24010 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24011 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24015 * Selects the row immediately following the last selected row.
24016 * @param {Boolean} keepExisting (optional) True to keep existing selections
24018 selectNext : function(keepExisting)
24020 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24021 this.selectRow(this.last+1, keepExisting);
24022 this.grid.getView().focusRow(this.last);
24027 * Selects the row that precedes the last selected row.
24028 * @param {Boolean} keepExisting (optional) True to keep existing selections
24030 selectPrevious : function(keepExisting){
24032 this.selectRow(this.last-1, keepExisting);
24033 this.grid.getView().focusRow(this.last);
24038 * Returns the selected records
24039 * @return {Array} Array of selected records
24041 getSelections : function(){
24042 return [].concat(this.selections.items);
24046 * Returns the first selected record.
24049 getSelected : function(){
24050 return this.selections.itemAt(0);
24055 * Clears all selections.
24057 clearSelections : function(fast)
24063 var ds = this.grid.store;
24064 var s = this.selections;
24065 s.each(function(r){
24066 this.deselectRow(ds.indexOfId(r.id));
24070 this.selections.clear();
24077 * Selects all rows.
24079 selectAll : function(){
24083 this.selections.clear();
24084 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24085 this.selectRow(i, true);
24090 * Returns True if there is a selection.
24091 * @return {Boolean}
24093 hasSelection : function(){
24094 return this.selections.length > 0;
24098 * Returns True if the specified row is selected.
24099 * @param {Number/Record} record The record or index of the record to check
24100 * @return {Boolean}
24102 isSelected : function(index){
24103 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24104 return (r && this.selections.key(r.id) ? true : false);
24108 * Returns True if the specified record id is selected.
24109 * @param {String} id The id of record to check
24110 * @return {Boolean}
24112 isIdSelected : function(id){
24113 return (this.selections.key(id) ? true : false);
24118 handleMouseDBClick : function(e, t){
24122 handleMouseDown : function(e, t)
24124 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24125 if(this.isLocked() || rowIndex < 0 ){
24128 if(e.shiftKey && this.last !== false){
24129 var last = this.last;
24130 this.selectRange(last, rowIndex, e.ctrlKey);
24131 this.last = last; // reset the last
24135 var isSelected = this.isSelected(rowIndex);
24136 //Roo.log("select row:" + rowIndex);
24138 this.deselectRow(rowIndex);
24140 this.selectRow(rowIndex, true);
24144 if(e.button !== 0 && isSelected){
24145 alert('rowIndex 2: ' + rowIndex);
24146 view.focusRow(rowIndex);
24147 }else if(e.ctrlKey && isSelected){
24148 this.deselectRow(rowIndex);
24149 }else if(!isSelected){
24150 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24151 view.focusRow(rowIndex);
24155 this.fireEvent("afterselectionchange", this);
24158 handleDragableRowClick : function(grid, rowIndex, e)
24160 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24161 this.selectRow(rowIndex, false);
24162 grid.view.focusRow(rowIndex);
24163 this.fireEvent("afterselectionchange", this);
24168 * Selects multiple rows.
24169 * @param {Array} rows Array of the indexes of the row to select
24170 * @param {Boolean} keepExisting (optional) True to keep existing selections
24172 selectRows : function(rows, keepExisting){
24174 this.clearSelections();
24176 for(var i = 0, len = rows.length; i < len; i++){
24177 this.selectRow(rows[i], true);
24182 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24183 * @param {Number} startRow The index of the first row in the range
24184 * @param {Number} endRow The index of the last row in the range
24185 * @param {Boolean} keepExisting (optional) True to retain existing selections
24187 selectRange : function(startRow, endRow, keepExisting){
24192 this.clearSelections();
24194 if(startRow <= endRow){
24195 for(var i = startRow; i <= endRow; i++){
24196 this.selectRow(i, true);
24199 for(var i = startRow; i >= endRow; i--){
24200 this.selectRow(i, true);
24206 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24207 * @param {Number} startRow The index of the first row in the range
24208 * @param {Number} endRow The index of the last row in the range
24210 deselectRange : function(startRow, endRow, preventViewNotify){
24214 for(var i = startRow; i <= endRow; i++){
24215 this.deselectRow(i, preventViewNotify);
24221 * @param {Number} row The index of the row to select
24222 * @param {Boolean} keepExisting (optional) True to keep existing selections
24224 selectRow : function(index, keepExisting, preventViewNotify)
24226 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24229 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24230 if(!keepExisting || this.singleSelect){
24231 this.clearSelections();
24234 var r = this.grid.store.getAt(index);
24235 //console.log('selectRow - record id :' + r.id);
24237 this.selections.add(r);
24238 this.last = this.lastActive = index;
24239 if(!preventViewNotify){
24240 var proxy = new Roo.Element(
24241 this.grid.getRowDom(index)
24243 proxy.addClass('bg-info info');
24245 this.fireEvent("rowselect", this, index, r);
24246 this.fireEvent("selectionchange", this);
24252 * @param {Number} row The index of the row to deselect
24254 deselectRow : function(index, preventViewNotify)
24259 if(this.last == index){
24262 if(this.lastActive == index){
24263 this.lastActive = false;
24266 var r = this.grid.store.getAt(index);
24271 this.selections.remove(r);
24272 //.console.log('deselectRow - record id :' + r.id);
24273 if(!preventViewNotify){
24275 var proxy = new Roo.Element(
24276 this.grid.getRowDom(index)
24278 proxy.removeClass('bg-info info');
24280 this.fireEvent("rowdeselect", this, index);
24281 this.fireEvent("selectionchange", this);
24285 restoreLast : function(){
24287 this.last = this._last;
24292 acceptsNav : function(row, col, cm){
24293 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24297 onEditorKey : function(field, e){
24298 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24303 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24305 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24307 }else if(k == e.ENTER && !e.ctrlKey){
24311 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24313 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24315 }else if(k == e.ESC){
24319 g.startEditing(newCell[0], newCell[1]);
24325 * Ext JS Library 1.1.1
24326 * Copyright(c) 2006-2007, Ext JS, LLC.
24328 * Originally Released Under LGPL - original licence link has changed is not relivant.
24331 * <script type="text/javascript">
24335 * @class Roo.bootstrap.PagingToolbar
24336 * @extends Roo.bootstrap.NavSimplebar
24337 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24339 * Create a new PagingToolbar
24340 * @param {Object} config The config object
24341 * @param {Roo.data.Store} store
24343 Roo.bootstrap.PagingToolbar = function(config)
24345 // old args format still supported... - xtype is prefered..
24346 // created from xtype...
24348 this.ds = config.dataSource;
24350 if (config.store && !this.ds) {
24351 this.store= Roo.factory(config.store, Roo.data);
24352 this.ds = this.store;
24353 this.ds.xmodule = this.xmodule || false;
24356 this.toolbarItems = [];
24357 if (config.items) {
24358 this.toolbarItems = config.items;
24361 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24366 this.bind(this.ds);
24369 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24373 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24375 * @cfg {Roo.data.Store} dataSource
24376 * The underlying data store providing the paged data
24379 * @cfg {String/HTMLElement/Element} container
24380 * container The id or element that will contain the toolbar
24383 * @cfg {Boolean} displayInfo
24384 * True to display the displayMsg (defaults to false)
24387 * @cfg {Number} pageSize
24388 * The number of records to display per page (defaults to 20)
24392 * @cfg {String} displayMsg
24393 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24395 displayMsg : 'Displaying {0} - {1} of {2}',
24397 * @cfg {String} emptyMsg
24398 * The message to display when no records are found (defaults to "No data to display")
24400 emptyMsg : 'No data to display',
24402 * Customizable piece of the default paging text (defaults to "Page")
24405 beforePageText : "Page",
24407 * Customizable piece of the default paging text (defaults to "of %0")
24410 afterPageText : "of {0}",
24412 * Customizable piece of the default paging text (defaults to "First Page")
24415 firstText : "First Page",
24417 * Customizable piece of the default paging text (defaults to "Previous Page")
24420 prevText : "Previous Page",
24422 * Customizable piece of the default paging text (defaults to "Next Page")
24425 nextText : "Next Page",
24427 * Customizable piece of the default paging text (defaults to "Last Page")
24430 lastText : "Last Page",
24432 * Customizable piece of the default paging text (defaults to "Refresh")
24435 refreshText : "Refresh",
24439 onRender : function(ct, position)
24441 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24442 this.navgroup.parentId = this.id;
24443 this.navgroup.onRender(this.el, null);
24444 // add the buttons to the navgroup
24446 if(this.displayInfo){
24447 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24448 this.displayEl = this.el.select('.x-paging-info', true).first();
24449 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24450 // this.displayEl = navel.el.select('span',true).first();
24456 Roo.each(_this.buttons, function(e){ // this might need to use render????
24457 Roo.factory(e).onRender(_this.el, null);
24461 Roo.each(_this.toolbarItems, function(e) {
24462 _this.navgroup.addItem(e);
24466 this.first = this.navgroup.addItem({
24467 tooltip: this.firstText,
24469 icon : 'fa fa-backward',
24471 preventDefault: true,
24472 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24475 this.prev = this.navgroup.addItem({
24476 tooltip: this.prevText,
24478 icon : 'fa fa-step-backward',
24480 preventDefault: true,
24481 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24483 //this.addSeparator();
24486 var field = this.navgroup.addItem( {
24488 cls : 'x-paging-position',
24490 html : this.beforePageText +
24491 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24492 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24495 this.field = field.el.select('input', true).first();
24496 this.field.on("keydown", this.onPagingKeydown, this);
24497 this.field.on("focus", function(){this.dom.select();});
24500 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24501 //this.field.setHeight(18);
24502 //this.addSeparator();
24503 this.next = this.navgroup.addItem({
24504 tooltip: this.nextText,
24506 html : ' <i class="fa fa-step-forward">',
24508 preventDefault: true,
24509 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24511 this.last = this.navgroup.addItem({
24512 tooltip: this.lastText,
24513 icon : 'fa fa-forward',
24516 preventDefault: true,
24517 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24519 //this.addSeparator();
24520 this.loading = this.navgroup.addItem({
24521 tooltip: this.refreshText,
24522 icon: 'fa fa-refresh',
24523 preventDefault: true,
24524 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24530 updateInfo : function(){
24531 if(this.displayEl){
24532 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24533 var msg = count == 0 ?
24537 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24539 this.displayEl.update(msg);
24544 onLoad : function(ds, r, o)
24546 this.cursor = o.params.start ? o.params.start : 0;
24548 var d = this.getPageData(),
24553 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24554 this.field.dom.value = ap;
24555 this.first.setDisabled(ap == 1);
24556 this.prev.setDisabled(ap == 1);
24557 this.next.setDisabled(ap == ps);
24558 this.last.setDisabled(ap == ps);
24559 this.loading.enable();
24564 getPageData : function(){
24565 var total = this.ds.getTotalCount();
24568 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24569 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24574 onLoadError : function(){
24575 this.loading.enable();
24579 onPagingKeydown : function(e){
24580 var k = e.getKey();
24581 var d = this.getPageData();
24583 var v = this.field.dom.value, pageNum;
24584 if(!v || isNaN(pageNum = parseInt(v, 10))){
24585 this.field.dom.value = d.activePage;
24588 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24589 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24592 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))
24594 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24595 this.field.dom.value = pageNum;
24596 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24599 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24601 var v = this.field.dom.value, pageNum;
24602 var increment = (e.shiftKey) ? 10 : 1;
24603 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24606 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24607 this.field.dom.value = d.activePage;
24610 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24612 this.field.dom.value = parseInt(v, 10) + increment;
24613 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24614 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24621 beforeLoad : function(){
24623 this.loading.disable();
24628 onClick : function(which){
24637 ds.load({params:{start: 0, limit: this.pageSize}});
24640 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24643 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24646 var total = ds.getTotalCount();
24647 var extra = total % this.pageSize;
24648 var lastStart = extra ? (total - extra) : total-this.pageSize;
24649 ds.load({params:{start: lastStart, limit: this.pageSize}});
24652 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24658 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24659 * @param {Roo.data.Store} store The data store to unbind
24661 unbind : function(ds){
24662 ds.un("beforeload", this.beforeLoad, this);
24663 ds.un("load", this.onLoad, this);
24664 ds.un("loadexception", this.onLoadError, this);
24665 ds.un("remove", this.updateInfo, this);
24666 ds.un("add", this.updateInfo, this);
24667 this.ds = undefined;
24671 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24672 * @param {Roo.data.Store} store The data store to bind
24674 bind : function(ds){
24675 ds.on("beforeload", this.beforeLoad, this);
24676 ds.on("load", this.onLoad, this);
24677 ds.on("loadexception", this.onLoadError, this);
24678 ds.on("remove", this.updateInfo, this);
24679 ds.on("add", this.updateInfo, this);
24690 * @class Roo.bootstrap.MessageBar
24691 * @extends Roo.bootstrap.Component
24692 * Bootstrap MessageBar class
24693 * @cfg {String} html contents of the MessageBar
24694 * @cfg {String} weight (info | success | warning | danger) default info
24695 * @cfg {String} beforeClass insert the bar before the given class
24696 * @cfg {Boolean} closable (true | false) default false
24697 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24700 * Create a new Element
24701 * @param {Object} config The config object
24704 Roo.bootstrap.MessageBar = function(config){
24705 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24708 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24714 beforeClass: 'bootstrap-sticky-wrap',
24716 getAutoCreate : function(){
24720 cls: 'alert alert-dismissable alert-' + this.weight,
24725 html: this.html || ''
24731 cfg.cls += ' alert-messages-fixed';
24745 onRender : function(ct, position)
24747 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24750 var cfg = Roo.apply({}, this.getAutoCreate());
24754 cfg.cls += ' ' + this.cls;
24757 cfg.style = this.style;
24759 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24761 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24764 this.el.select('>button.close').on('click', this.hide, this);
24770 if (!this.rendered) {
24776 this.fireEvent('show', this);
24782 if (!this.rendered) {
24788 this.fireEvent('hide', this);
24791 update : function()
24793 // var e = this.el.dom.firstChild;
24795 // if(this.closable){
24796 // e = e.nextSibling;
24799 // e.data = this.html || '';
24801 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24817 * @class Roo.bootstrap.Graph
24818 * @extends Roo.bootstrap.Component
24819 * Bootstrap Graph class
24823 @cfg {String} graphtype bar | vbar | pie
24824 @cfg {number} g_x coodinator | centre x (pie)
24825 @cfg {number} g_y coodinator | centre y (pie)
24826 @cfg {number} g_r radius (pie)
24827 @cfg {number} g_height height of the chart (respected by all elements in the set)
24828 @cfg {number} g_width width of the chart (respected by all elements in the set)
24829 @cfg {Object} title The title of the chart
24832 -opts (object) options for the chart
24834 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24835 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24837 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.
24838 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24840 o stretch (boolean)
24842 -opts (object) options for the pie
24845 o startAngle (number)
24846 o endAngle (number)
24850 * Create a new Input
24851 * @param {Object} config The config object
24854 Roo.bootstrap.Graph = function(config){
24855 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24861 * The img click event for the img.
24862 * @param {Roo.EventObject} e
24868 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24879 //g_colors: this.colors,
24886 getAutoCreate : function(){
24897 onRender : function(ct,position){
24900 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24902 if (typeof(Raphael) == 'undefined') {
24903 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24907 this.raphael = Raphael(this.el.dom);
24909 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24910 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24911 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24912 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24914 r.text(160, 10, "Single Series Chart").attr(txtattr);
24915 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24916 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24917 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24919 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24920 r.barchart(330, 10, 300, 220, data1);
24921 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24922 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24925 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24926 // r.barchart(30, 30, 560, 250, xdata, {
24927 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24928 // axis : "0 0 1 1",
24929 // axisxlabels : xdata
24930 // //yvalues : cols,
24933 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24935 // this.load(null,xdata,{
24936 // axis : "0 0 1 1",
24937 // axisxlabels : xdata
24942 load : function(graphtype,xdata,opts)
24944 this.raphael.clear();
24946 graphtype = this.graphtype;
24951 var r = this.raphael,
24952 fin = function () {
24953 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24955 fout = function () {
24956 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24958 pfin = function() {
24959 this.sector.stop();
24960 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24963 this.label[0].stop();
24964 this.label[0].attr({ r: 7.5 });
24965 this.label[1].attr({ "font-weight": 800 });
24968 pfout = function() {
24969 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24972 this.label[0].animate({ r: 5 }, 500, "bounce");
24973 this.label[1].attr({ "font-weight": 400 });
24979 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24982 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24985 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24986 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24988 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24995 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25000 setTitle: function(o)
25005 initEvents: function() {
25008 this.el.on('click', this.onClick, this);
25012 onClick : function(e)
25014 Roo.log('img onclick');
25015 this.fireEvent('click', this, e);
25027 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25030 * @class Roo.bootstrap.dash.NumberBox
25031 * @extends Roo.bootstrap.Component
25032 * Bootstrap NumberBox class
25033 * @cfg {String} headline Box headline
25034 * @cfg {String} content Box content
25035 * @cfg {String} icon Box icon
25036 * @cfg {String} footer Footer text
25037 * @cfg {String} fhref Footer href
25040 * Create a new NumberBox
25041 * @param {Object} config The config object
25045 Roo.bootstrap.dash.NumberBox = function(config){
25046 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25050 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25059 getAutoCreate : function(){
25063 cls : 'small-box ',
25071 cls : 'roo-headline',
25072 html : this.headline
25076 cls : 'roo-content',
25077 html : this.content
25091 cls : 'ion ' + this.icon
25100 cls : 'small-box-footer',
25101 href : this.fhref || '#',
25105 cfg.cn.push(footer);
25112 onRender : function(ct,position){
25113 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25120 setHeadline: function (value)
25122 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25125 setFooter: function (value, href)
25127 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25130 this.el.select('a.small-box-footer',true).first().attr('href', href);
25135 setContent: function (value)
25137 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25140 initEvents: function()
25154 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25157 * @class Roo.bootstrap.dash.TabBox
25158 * @extends Roo.bootstrap.Component
25159 * Bootstrap TabBox class
25160 * @cfg {String} title Title of the TabBox
25161 * @cfg {String} icon Icon of the TabBox
25162 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25163 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25166 * Create a new TabBox
25167 * @param {Object} config The config object
25171 Roo.bootstrap.dash.TabBox = function(config){
25172 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25177 * When a pane is added
25178 * @param {Roo.bootstrap.dash.TabPane} pane
25182 * @event activatepane
25183 * When a pane is activated
25184 * @param {Roo.bootstrap.dash.TabPane} pane
25186 "activatepane" : true
25194 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25199 tabScrollable : false,
25201 getChildContainer : function()
25203 return this.el.select('.tab-content', true).first();
25206 getAutoCreate : function(){
25210 cls: 'pull-left header',
25218 cls: 'fa ' + this.icon
25224 cls: 'nav nav-tabs pull-right',
25230 if(this.tabScrollable){
25237 cls: 'nav nav-tabs pull-right',
25248 cls: 'nav-tabs-custom',
25253 cls: 'tab-content no-padding',
25261 initEvents : function()
25263 //Roo.log('add add pane handler');
25264 this.on('addpane', this.onAddPane, this);
25267 * Updates the box title
25268 * @param {String} html to set the title to.
25270 setTitle : function(value)
25272 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25274 onAddPane : function(pane)
25276 this.panes.push(pane);
25277 //Roo.log('addpane');
25279 // tabs are rendere left to right..
25280 if(!this.showtabs){
25284 var ctr = this.el.select('.nav-tabs', true).first();
25287 var existing = ctr.select('.nav-tab',true);
25288 var qty = existing.getCount();;
25291 var tab = ctr.createChild({
25293 cls : 'nav-tab' + (qty ? '' : ' active'),
25301 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25304 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25306 pane.el.addClass('active');
25311 onTabClick : function(ev,un,ob,pane)
25313 //Roo.log('tab - prev default');
25314 ev.preventDefault();
25317 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25318 pane.tab.addClass('active');
25319 //Roo.log(pane.title);
25320 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25321 // technically we should have a deactivate event.. but maybe add later.
25322 // and it should not de-activate the selected tab...
25323 this.fireEvent('activatepane', pane);
25324 pane.el.addClass('active');
25325 pane.fireEvent('activate');
25330 getActivePane : function()
25333 Roo.each(this.panes, function(p) {
25334 if(p.el.hasClass('active')){
25355 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25357 * @class Roo.bootstrap.TabPane
25358 * @extends Roo.bootstrap.Component
25359 * Bootstrap TabPane class
25360 * @cfg {Boolean} active (false | true) Default false
25361 * @cfg {String} title title of panel
25365 * Create a new TabPane
25366 * @param {Object} config The config object
25369 Roo.bootstrap.dash.TabPane = function(config){
25370 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25376 * When a pane is activated
25377 * @param {Roo.bootstrap.dash.TabPane} pane
25384 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25389 // the tabBox that this is attached to.
25392 getAutoCreate : function()
25400 cfg.cls += ' active';
25405 initEvents : function()
25407 //Roo.log('trigger add pane handler');
25408 this.parent().fireEvent('addpane', this)
25412 * Updates the tab title
25413 * @param {String} html to set the title to.
25415 setTitle: function(str)
25421 this.tab.select('a', true).first().dom.innerHTML = str;
25438 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25441 * @class Roo.bootstrap.menu.Menu
25442 * @extends Roo.bootstrap.Component
25443 * Bootstrap Menu class - container for Menu
25444 * @cfg {String} html Text of the menu
25445 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25446 * @cfg {String} icon Font awesome icon
25447 * @cfg {String} pos Menu align to (top | bottom) default bottom
25451 * Create a new Menu
25452 * @param {Object} config The config object
25456 Roo.bootstrap.menu.Menu = function(config){
25457 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25461 * @event beforeshow
25462 * Fires before this menu is displayed
25463 * @param {Roo.bootstrap.menu.Menu} this
25467 * @event beforehide
25468 * Fires before this menu is hidden
25469 * @param {Roo.bootstrap.menu.Menu} this
25474 * Fires after this menu is displayed
25475 * @param {Roo.bootstrap.menu.Menu} this
25480 * Fires after this menu is hidden
25481 * @param {Roo.bootstrap.menu.Menu} this
25486 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25487 * @param {Roo.bootstrap.menu.Menu} this
25488 * @param {Roo.EventObject} e
25495 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25499 weight : 'default',
25504 getChildContainer : function() {
25505 if(this.isSubMenu){
25509 return this.el.select('ul.dropdown-menu', true).first();
25512 getAutoCreate : function()
25517 cls : 'roo-menu-text',
25525 cls : 'fa ' + this.icon
25536 cls : 'dropdown-button btn btn-' + this.weight,
25541 cls : 'dropdown-toggle btn btn-' + this.weight,
25551 cls : 'dropdown-menu'
25557 if(this.pos == 'top'){
25558 cfg.cls += ' dropup';
25561 if(this.isSubMenu){
25564 cls : 'dropdown-menu'
25571 onRender : function(ct, position)
25573 this.isSubMenu = ct.hasClass('dropdown-submenu');
25575 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25578 initEvents : function()
25580 if(this.isSubMenu){
25584 this.hidden = true;
25586 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25587 this.triggerEl.on('click', this.onTriggerPress, this);
25589 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25590 this.buttonEl.on('click', this.onClick, this);
25596 if(this.isSubMenu){
25600 return this.el.select('ul.dropdown-menu', true).first();
25603 onClick : function(e)
25605 this.fireEvent("click", this, e);
25608 onTriggerPress : function(e)
25610 if (this.isVisible()) {
25617 isVisible : function(){
25618 return !this.hidden;
25623 this.fireEvent("beforeshow", this);
25625 this.hidden = false;
25626 this.el.addClass('open');
25628 Roo.get(document).on("mouseup", this.onMouseUp, this);
25630 this.fireEvent("show", this);
25637 this.fireEvent("beforehide", this);
25639 this.hidden = true;
25640 this.el.removeClass('open');
25642 Roo.get(document).un("mouseup", this.onMouseUp);
25644 this.fireEvent("hide", this);
25647 onMouseUp : function()
25661 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25664 * @class Roo.bootstrap.menu.Item
25665 * @extends Roo.bootstrap.Component
25666 * Bootstrap MenuItem class
25667 * @cfg {Boolean} submenu (true | false) default false
25668 * @cfg {String} html text of the item
25669 * @cfg {String} href the link
25670 * @cfg {Boolean} disable (true | false) default false
25671 * @cfg {Boolean} preventDefault (true | false) default true
25672 * @cfg {String} icon Font awesome icon
25673 * @cfg {String} pos Submenu align to (left | right) default right
25677 * Create a new Item
25678 * @param {Object} config The config object
25682 Roo.bootstrap.menu.Item = function(config){
25683 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25687 * Fires when the mouse is hovering over this menu
25688 * @param {Roo.bootstrap.menu.Item} this
25689 * @param {Roo.EventObject} e
25694 * Fires when the mouse exits this menu
25695 * @param {Roo.bootstrap.menu.Item} this
25696 * @param {Roo.EventObject} e
25702 * The raw click event for the entire grid.
25703 * @param {Roo.EventObject} e
25709 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25714 preventDefault: true,
25719 getAutoCreate : function()
25724 cls : 'roo-menu-item-text',
25732 cls : 'fa ' + this.icon
25741 href : this.href || '#',
25748 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25752 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25754 if(this.pos == 'left'){
25755 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25762 initEvents : function()
25764 this.el.on('mouseover', this.onMouseOver, this);
25765 this.el.on('mouseout', this.onMouseOut, this);
25767 this.el.select('a', true).first().on('click', this.onClick, this);
25771 onClick : function(e)
25773 if(this.preventDefault){
25774 e.preventDefault();
25777 this.fireEvent("click", this, e);
25780 onMouseOver : function(e)
25782 if(this.submenu && this.pos == 'left'){
25783 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25786 this.fireEvent("mouseover", this, e);
25789 onMouseOut : function(e)
25791 this.fireEvent("mouseout", this, e);
25803 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25806 * @class Roo.bootstrap.menu.Separator
25807 * @extends Roo.bootstrap.Component
25808 * Bootstrap Separator class
25811 * Create a new Separator
25812 * @param {Object} config The config object
25816 Roo.bootstrap.menu.Separator = function(config){
25817 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25820 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25822 getAutoCreate : function(){
25843 * @class Roo.bootstrap.Tooltip
25844 * Bootstrap Tooltip class
25845 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25846 * to determine which dom element triggers the tooltip.
25848 * It needs to add support for additional attributes like tooltip-position
25851 * Create a new Toolti
25852 * @param {Object} config The config object
25855 Roo.bootstrap.Tooltip = function(config){
25856 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25858 this.alignment = Roo.bootstrap.Tooltip.alignment;
25860 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25861 this.alignment = config.alignment;
25866 Roo.apply(Roo.bootstrap.Tooltip, {
25868 * @function init initialize tooltip monitoring.
25872 currentTip : false,
25873 currentRegion : false,
25879 Roo.get(document).on('mouseover', this.enter ,this);
25880 Roo.get(document).on('mouseout', this.leave, this);
25883 this.currentTip = new Roo.bootstrap.Tooltip();
25886 enter : function(ev)
25888 var dom = ev.getTarget();
25890 //Roo.log(['enter',dom]);
25891 var el = Roo.fly(dom);
25892 if (this.currentEl) {
25894 //Roo.log(this.currentEl);
25895 //Roo.log(this.currentEl.contains(dom));
25896 if (this.currentEl == el) {
25899 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25905 if (this.currentTip.el) {
25906 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25910 if(!el || el.dom == document){
25916 // you can not look for children, as if el is the body.. then everythign is the child..
25917 if (!el.attr('tooltip')) { //
25918 if (!el.select("[tooltip]").elements.length) {
25921 // is the mouse over this child...?
25922 bindEl = el.select("[tooltip]").first();
25923 var xy = ev.getXY();
25924 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25925 //Roo.log("not in region.");
25928 //Roo.log("child element over..");
25931 this.currentEl = bindEl;
25932 this.currentTip.bind(bindEl);
25933 this.currentRegion = Roo.lib.Region.getRegion(dom);
25934 this.currentTip.enter();
25937 leave : function(ev)
25939 var dom = ev.getTarget();
25940 //Roo.log(['leave',dom]);
25941 if (!this.currentEl) {
25946 if (dom != this.currentEl.dom) {
25949 var xy = ev.getXY();
25950 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25953 // only activate leave if mouse cursor is outside... bounding box..
25958 if (this.currentTip) {
25959 this.currentTip.leave();
25961 //Roo.log('clear currentEl');
25962 this.currentEl = false;
25967 'left' : ['r-l', [-2,0], 'right'],
25968 'right' : ['l-r', [2,0], 'left'],
25969 'bottom' : ['t-b', [0,2], 'top'],
25970 'top' : [ 'b-t', [0,-2], 'bottom']
25976 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25981 delay : null, // can be { show : 300 , hide: 500}
25985 hoverState : null, //???
25987 placement : 'bottom',
25991 getAutoCreate : function(){
25998 cls : 'tooltip-arrow'
26001 cls : 'tooltip-inner'
26008 bind : function(el)
26014 enter : function () {
26016 if (this.timeout != null) {
26017 clearTimeout(this.timeout);
26020 this.hoverState = 'in';
26021 //Roo.log("enter - show");
26022 if (!this.delay || !this.delay.show) {
26027 this.timeout = setTimeout(function () {
26028 if (_t.hoverState == 'in') {
26031 }, this.delay.show);
26035 clearTimeout(this.timeout);
26037 this.hoverState = 'out';
26038 if (!this.delay || !this.delay.hide) {
26044 this.timeout = setTimeout(function () {
26045 //Roo.log("leave - timeout");
26047 if (_t.hoverState == 'out') {
26049 Roo.bootstrap.Tooltip.currentEl = false;
26054 show : function (msg)
26057 this.render(document.body);
26060 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26062 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26064 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26066 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26068 var placement = typeof this.placement == 'function' ?
26069 this.placement.call(this, this.el, on_el) :
26072 var autoToken = /\s?auto?\s?/i;
26073 var autoPlace = autoToken.test(placement);
26075 placement = placement.replace(autoToken, '') || 'top';
26079 //this.el.setXY([0,0]);
26081 //this.el.dom.style.display='block';
26083 //this.el.appendTo(on_el);
26085 var p = this.getPosition();
26086 var box = this.el.getBox();
26092 var align = this.alignment[placement];
26094 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26096 if(placement == 'top' || placement == 'bottom'){
26098 placement = 'right';
26101 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26102 placement = 'left';
26105 var scroll = Roo.select('body', true).first().getScroll();
26107 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26113 this.el.alignTo(this.bindEl, align[0],align[1]);
26114 //var arrow = this.el.select('.arrow',true).first();
26115 //arrow.set(align[2],
26117 this.el.addClass(placement);
26119 this.el.addClass('in fade');
26121 this.hoverState = null;
26123 if (this.el.hasClass('fade')) {
26134 //this.el.setXY([0,0]);
26135 this.el.removeClass('in');
26151 * @class Roo.bootstrap.LocationPicker
26152 * @extends Roo.bootstrap.Component
26153 * Bootstrap LocationPicker class
26154 * @cfg {Number} latitude Position when init default 0
26155 * @cfg {Number} longitude Position when init default 0
26156 * @cfg {Number} zoom default 15
26157 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26158 * @cfg {Boolean} mapTypeControl default false
26159 * @cfg {Boolean} disableDoubleClickZoom default false
26160 * @cfg {Boolean} scrollwheel default true
26161 * @cfg {Boolean} streetViewControl default false
26162 * @cfg {Number} radius default 0
26163 * @cfg {String} locationName
26164 * @cfg {Boolean} draggable default true
26165 * @cfg {Boolean} enableAutocomplete default false
26166 * @cfg {Boolean} enableReverseGeocode default true
26167 * @cfg {String} markerTitle
26170 * Create a new LocationPicker
26171 * @param {Object} config The config object
26175 Roo.bootstrap.LocationPicker = function(config){
26177 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26182 * Fires when the picker initialized.
26183 * @param {Roo.bootstrap.LocationPicker} this
26184 * @param {Google Location} location
26188 * @event positionchanged
26189 * Fires when the picker position changed.
26190 * @param {Roo.bootstrap.LocationPicker} this
26191 * @param {Google Location} location
26193 positionchanged : true,
26196 * Fires when the map resize.
26197 * @param {Roo.bootstrap.LocationPicker} this
26202 * Fires when the map show.
26203 * @param {Roo.bootstrap.LocationPicker} this
26208 * Fires when the map hide.
26209 * @param {Roo.bootstrap.LocationPicker} this
26214 * Fires when click the map.
26215 * @param {Roo.bootstrap.LocationPicker} this
26216 * @param {Map event} e
26220 * @event mapRightClick
26221 * Fires when right click the map.
26222 * @param {Roo.bootstrap.LocationPicker} this
26223 * @param {Map event} e
26225 mapRightClick : true,
26227 * @event markerClick
26228 * Fires when click the marker.
26229 * @param {Roo.bootstrap.LocationPicker} this
26230 * @param {Map event} e
26232 markerClick : true,
26234 * @event markerRightClick
26235 * Fires when right click the marker.
26236 * @param {Roo.bootstrap.LocationPicker} this
26237 * @param {Map event} e
26239 markerRightClick : true,
26241 * @event OverlayViewDraw
26242 * Fires when OverlayView Draw
26243 * @param {Roo.bootstrap.LocationPicker} this
26245 OverlayViewDraw : true,
26247 * @event OverlayViewOnAdd
26248 * Fires when OverlayView Draw
26249 * @param {Roo.bootstrap.LocationPicker} this
26251 OverlayViewOnAdd : true,
26253 * @event OverlayViewOnRemove
26254 * Fires when OverlayView Draw
26255 * @param {Roo.bootstrap.LocationPicker} this
26257 OverlayViewOnRemove : true,
26259 * @event OverlayViewShow
26260 * Fires when OverlayView Draw
26261 * @param {Roo.bootstrap.LocationPicker} this
26262 * @param {Pixel} cpx
26264 OverlayViewShow : true,
26266 * @event OverlayViewHide
26267 * Fires when OverlayView Draw
26268 * @param {Roo.bootstrap.LocationPicker} this
26270 OverlayViewHide : true,
26272 * @event loadexception
26273 * Fires when load google lib failed.
26274 * @param {Roo.bootstrap.LocationPicker} this
26276 loadexception : true
26281 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26283 gMapContext: false,
26289 mapTypeControl: false,
26290 disableDoubleClickZoom: false,
26292 streetViewControl: false,
26296 enableAutocomplete: false,
26297 enableReverseGeocode: true,
26300 getAutoCreate: function()
26305 cls: 'roo-location-picker'
26311 initEvents: function(ct, position)
26313 if(!this.el.getWidth() || this.isApplied()){
26317 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26322 initial: function()
26324 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26325 this.fireEvent('loadexception', this);
26329 if(!this.mapTypeId){
26330 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26333 this.gMapContext = this.GMapContext();
26335 this.initOverlayView();
26337 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26341 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26342 _this.setPosition(_this.gMapContext.marker.position);
26345 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26346 _this.fireEvent('mapClick', this, event);
26350 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26351 _this.fireEvent('mapRightClick', this, event);
26355 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26356 _this.fireEvent('markerClick', this, event);
26360 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26361 _this.fireEvent('markerRightClick', this, event);
26365 this.setPosition(this.gMapContext.location);
26367 this.fireEvent('initial', this, this.gMapContext.location);
26370 initOverlayView: function()
26374 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26378 _this.fireEvent('OverlayViewDraw', _this);
26383 _this.fireEvent('OverlayViewOnAdd', _this);
26386 onRemove: function()
26388 _this.fireEvent('OverlayViewOnRemove', _this);
26391 show: function(cpx)
26393 _this.fireEvent('OverlayViewShow', _this, cpx);
26398 _this.fireEvent('OverlayViewHide', _this);
26404 fromLatLngToContainerPixel: function(event)
26406 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26409 isApplied: function()
26411 return this.getGmapContext() == false ? false : true;
26414 getGmapContext: function()
26416 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26419 GMapContext: function()
26421 var position = new google.maps.LatLng(this.latitude, this.longitude);
26423 var _map = new google.maps.Map(this.el.dom, {
26426 mapTypeId: this.mapTypeId,
26427 mapTypeControl: this.mapTypeControl,
26428 disableDoubleClickZoom: this.disableDoubleClickZoom,
26429 scrollwheel: this.scrollwheel,
26430 streetViewControl: this.streetViewControl,
26431 locationName: this.locationName,
26432 draggable: this.draggable,
26433 enableAutocomplete: this.enableAutocomplete,
26434 enableReverseGeocode: this.enableReverseGeocode
26437 var _marker = new google.maps.Marker({
26438 position: position,
26440 title: this.markerTitle,
26441 draggable: this.draggable
26448 location: position,
26449 radius: this.radius,
26450 locationName: this.locationName,
26451 addressComponents: {
26452 formatted_address: null,
26453 addressLine1: null,
26454 addressLine2: null,
26456 streetNumber: null,
26460 stateOrProvince: null
26463 domContainer: this.el.dom,
26464 geodecoder: new google.maps.Geocoder()
26468 drawCircle: function(center, radius, options)
26470 if (this.gMapContext.circle != null) {
26471 this.gMapContext.circle.setMap(null);
26475 options = Roo.apply({}, options, {
26476 strokeColor: "#0000FF",
26477 strokeOpacity: .35,
26479 fillColor: "#0000FF",
26483 options.map = this.gMapContext.map;
26484 options.radius = radius;
26485 options.center = center;
26486 this.gMapContext.circle = new google.maps.Circle(options);
26487 return this.gMapContext.circle;
26493 setPosition: function(location)
26495 this.gMapContext.location = location;
26496 this.gMapContext.marker.setPosition(location);
26497 this.gMapContext.map.panTo(location);
26498 this.drawCircle(location, this.gMapContext.radius, {});
26502 if (this.gMapContext.settings.enableReverseGeocode) {
26503 this.gMapContext.geodecoder.geocode({
26504 latLng: this.gMapContext.location
26505 }, function(results, status) {
26507 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26508 _this.gMapContext.locationName = results[0].formatted_address;
26509 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26511 _this.fireEvent('positionchanged', this, location);
26518 this.fireEvent('positionchanged', this, location);
26523 google.maps.event.trigger(this.gMapContext.map, "resize");
26525 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26527 this.fireEvent('resize', this);
26530 setPositionByLatLng: function(latitude, longitude)
26532 this.setPosition(new google.maps.LatLng(latitude, longitude));
26535 getCurrentPosition: function()
26538 latitude: this.gMapContext.location.lat(),
26539 longitude: this.gMapContext.location.lng()
26543 getAddressName: function()
26545 return this.gMapContext.locationName;
26548 getAddressComponents: function()
26550 return this.gMapContext.addressComponents;
26553 address_component_from_google_geocode: function(address_components)
26557 for (var i = 0; i < address_components.length; i++) {
26558 var component = address_components[i];
26559 if (component.types.indexOf("postal_code") >= 0) {
26560 result.postalCode = component.short_name;
26561 } else if (component.types.indexOf("street_number") >= 0) {
26562 result.streetNumber = component.short_name;
26563 } else if (component.types.indexOf("route") >= 0) {
26564 result.streetName = component.short_name;
26565 } else if (component.types.indexOf("neighborhood") >= 0) {
26566 result.city = component.short_name;
26567 } else if (component.types.indexOf("locality") >= 0) {
26568 result.city = component.short_name;
26569 } else if (component.types.indexOf("sublocality") >= 0) {
26570 result.district = component.short_name;
26571 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26572 result.stateOrProvince = component.short_name;
26573 } else if (component.types.indexOf("country") >= 0) {
26574 result.country = component.short_name;
26578 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26579 result.addressLine2 = "";
26583 setZoomLevel: function(zoom)
26585 this.gMapContext.map.setZoom(zoom);
26598 this.fireEvent('show', this);
26609 this.fireEvent('hide', this);
26614 Roo.apply(Roo.bootstrap.LocationPicker, {
26616 OverlayView : function(map, options)
26618 options = options || {};
26632 * @class Roo.bootstrap.Alert
26633 * @extends Roo.bootstrap.Component
26634 * Bootstrap Alert class
26635 * @cfg {String} title The title of alert
26636 * @cfg {String} html The content of alert
26637 * @cfg {String} weight ( success | info | warning | danger )
26638 * @cfg {String} faicon font-awesomeicon
26641 * Create a new alert
26642 * @param {Object} config The config object
26646 Roo.bootstrap.Alert = function(config){
26647 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26651 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26658 getAutoCreate : function()
26667 cls : 'roo-alert-icon'
26672 cls : 'roo-alert-title',
26677 cls : 'roo-alert-text',
26684 cfg.cn[0].cls += ' fa ' + this.faicon;
26688 cfg.cls += ' alert-' + this.weight;
26694 initEvents: function()
26696 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26699 setTitle : function(str)
26701 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26704 setText : function(str)
26706 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26709 setWeight : function(weight)
26712 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26715 this.weight = weight;
26717 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26720 setIcon : function(icon)
26723 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26726 this.faicon = icon;
26728 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26749 * @class Roo.bootstrap.UploadCropbox
26750 * @extends Roo.bootstrap.Component
26751 * Bootstrap UploadCropbox class
26752 * @cfg {String} emptyText show when image has been loaded
26753 * @cfg {String} rotateNotify show when image too small to rotate
26754 * @cfg {Number} errorTimeout default 3000
26755 * @cfg {Number} minWidth default 300
26756 * @cfg {Number} minHeight default 300
26757 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26758 * @cfg {Boolean} isDocument (true|false) default false
26759 * @cfg {String} url action url
26760 * @cfg {String} paramName default 'imageUpload'
26761 * @cfg {String} method default POST
26762 * @cfg {Boolean} loadMask (true|false) default true
26763 * @cfg {Boolean} loadingText default 'Loading...'
26766 * Create a new UploadCropbox
26767 * @param {Object} config The config object
26770 Roo.bootstrap.UploadCropbox = function(config){
26771 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26775 * @event beforeselectfile
26776 * Fire before select file
26777 * @param {Roo.bootstrap.UploadCropbox} this
26779 "beforeselectfile" : true,
26782 * Fire after initEvent
26783 * @param {Roo.bootstrap.UploadCropbox} this
26788 * Fire after initEvent
26789 * @param {Roo.bootstrap.UploadCropbox} this
26790 * @param {String} data
26795 * Fire when preparing the file data
26796 * @param {Roo.bootstrap.UploadCropbox} this
26797 * @param {Object} file
26802 * Fire when get exception
26803 * @param {Roo.bootstrap.UploadCropbox} this
26804 * @param {XMLHttpRequest} xhr
26806 "exception" : true,
26808 * @event beforeloadcanvas
26809 * Fire before load the canvas
26810 * @param {Roo.bootstrap.UploadCropbox} this
26811 * @param {String} src
26813 "beforeloadcanvas" : true,
26816 * Fire when trash image
26817 * @param {Roo.bootstrap.UploadCropbox} this
26822 * Fire when download the image
26823 * @param {Roo.bootstrap.UploadCropbox} this
26827 * @event footerbuttonclick
26828 * Fire when footerbuttonclick
26829 * @param {Roo.bootstrap.UploadCropbox} this
26830 * @param {String} type
26832 "footerbuttonclick" : true,
26836 * @param {Roo.bootstrap.UploadCropbox} this
26841 * Fire when rotate the image
26842 * @param {Roo.bootstrap.UploadCropbox} this
26843 * @param {String} pos
26848 * Fire when inspect the file
26849 * @param {Roo.bootstrap.UploadCropbox} this
26850 * @param {Object} file
26855 * Fire when xhr upload the file
26856 * @param {Roo.bootstrap.UploadCropbox} this
26857 * @param {Object} data
26862 * Fire when arrange the file data
26863 * @param {Roo.bootstrap.UploadCropbox} this
26864 * @param {Object} formData
26869 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26872 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26874 emptyText : 'Click to upload image',
26875 rotateNotify : 'Image is too small to rotate',
26876 errorTimeout : 3000,
26890 cropType : 'image/jpeg',
26892 canvasLoaded : false,
26893 isDocument : false,
26895 paramName : 'imageUpload',
26897 loadingText : 'Loading...',
26900 getAutoCreate : function()
26904 cls : 'roo-upload-cropbox',
26908 cls : 'roo-upload-cropbox-selector',
26913 cls : 'roo-upload-cropbox-body',
26914 style : 'cursor:pointer',
26918 cls : 'roo-upload-cropbox-preview'
26922 cls : 'roo-upload-cropbox-thumb'
26926 cls : 'roo-upload-cropbox-empty-notify',
26927 html : this.emptyText
26931 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26932 html : this.rotateNotify
26938 cls : 'roo-upload-cropbox-footer',
26941 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26951 onRender : function(ct, position)
26953 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26955 if (this.buttons.length) {
26957 Roo.each(this.buttons, function(bb) {
26959 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26961 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26967 this.maskEl = this.el;
26971 initEvents : function()
26973 this.urlAPI = (window.createObjectURL && window) ||
26974 (window.URL && URL.revokeObjectURL && URL) ||
26975 (window.webkitURL && webkitURL);
26977 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26978 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26980 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26981 this.selectorEl.hide();
26983 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26984 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26986 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26987 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26988 this.thumbEl.hide();
26990 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26991 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26993 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26994 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26995 this.errorEl.hide();
26997 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26998 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26999 this.footerEl.hide();
27001 this.setThumbBoxSize();
27007 this.fireEvent('initial', this);
27014 window.addEventListener("resize", function() { _this.resize(); } );
27016 this.bodyEl.on('click', this.beforeSelectFile, this);
27019 this.bodyEl.on('touchstart', this.onTouchStart, this);
27020 this.bodyEl.on('touchmove', this.onTouchMove, this);
27021 this.bodyEl.on('touchend', this.onTouchEnd, this);
27025 this.bodyEl.on('mousedown', this.onMouseDown, this);
27026 this.bodyEl.on('mousemove', this.onMouseMove, this);
27027 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27028 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27029 Roo.get(document).on('mouseup', this.onMouseUp, this);
27032 this.selectorEl.on('change', this.onFileSelected, this);
27038 this.baseScale = 1;
27040 this.baseRotate = 1;
27041 this.dragable = false;
27042 this.pinching = false;
27045 this.cropData = false;
27046 this.notifyEl.dom.innerHTML = this.emptyText;
27048 this.selectorEl.dom.value = '';
27052 resize : function()
27054 if(this.fireEvent('resize', this) != false){
27055 this.setThumbBoxPosition();
27056 this.setCanvasPosition();
27060 onFooterButtonClick : function(e, el, o, type)
27063 case 'rotate-left' :
27064 this.onRotateLeft(e);
27066 case 'rotate-right' :
27067 this.onRotateRight(e);
27070 this.beforeSelectFile(e);
27085 this.fireEvent('footerbuttonclick', this, type);
27088 beforeSelectFile : function(e)
27090 e.preventDefault();
27092 if(this.fireEvent('beforeselectfile', this) != false){
27093 this.selectorEl.dom.click();
27097 onFileSelected : function(e)
27099 e.preventDefault();
27101 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27105 var file = this.selectorEl.dom.files[0];
27107 if(this.fireEvent('inspect', this, file) != false){
27108 this.prepare(file);
27113 trash : function(e)
27115 this.fireEvent('trash', this);
27118 download : function(e)
27120 this.fireEvent('download', this);
27123 loadCanvas : function(src)
27125 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27129 this.imageEl = document.createElement('img');
27133 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27135 this.imageEl.src = src;
27139 onLoadCanvas : function()
27141 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27142 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27144 this.bodyEl.un('click', this.beforeSelectFile, this);
27146 this.notifyEl.hide();
27147 this.thumbEl.show();
27148 this.footerEl.show();
27150 this.baseRotateLevel();
27152 if(this.isDocument){
27153 this.setThumbBoxSize();
27156 this.setThumbBoxPosition();
27158 this.baseScaleLevel();
27164 this.canvasLoaded = true;
27167 this.maskEl.unmask();
27172 setCanvasPosition : function()
27174 if(!this.canvasEl){
27178 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27179 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27181 this.previewEl.setLeft(pw);
27182 this.previewEl.setTop(ph);
27186 onMouseDown : function(e)
27190 this.dragable = true;
27191 this.pinching = false;
27193 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27194 this.dragable = false;
27198 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27199 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27203 onMouseMove : function(e)
27207 if(!this.canvasLoaded){
27211 if (!this.dragable){
27215 var minX = Math.ceil(this.thumbEl.getLeft(true));
27216 var minY = Math.ceil(this.thumbEl.getTop(true));
27218 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27219 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27221 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27222 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27224 x = x - this.mouseX;
27225 y = y - this.mouseY;
27227 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27228 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27230 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27231 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27233 this.previewEl.setLeft(bgX);
27234 this.previewEl.setTop(bgY);
27236 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27237 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27240 onMouseUp : function(e)
27244 this.dragable = false;
27247 onMouseWheel : function(e)
27251 this.startScale = this.scale;
27253 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27255 if(!this.zoomable()){
27256 this.scale = this.startScale;
27265 zoomable : function()
27267 var minScale = this.thumbEl.getWidth() / this.minWidth;
27269 if(this.minWidth < this.minHeight){
27270 minScale = this.thumbEl.getHeight() / this.minHeight;
27273 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27274 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27278 (this.rotate == 0 || this.rotate == 180) &&
27280 width > this.imageEl.OriginWidth ||
27281 height > this.imageEl.OriginHeight ||
27282 (width < this.minWidth && height < this.minHeight)
27290 (this.rotate == 90 || this.rotate == 270) &&
27292 width > this.imageEl.OriginWidth ||
27293 height > this.imageEl.OriginHeight ||
27294 (width < this.minHeight && height < this.minWidth)
27301 !this.isDocument &&
27302 (this.rotate == 0 || this.rotate == 180) &&
27304 width < this.minWidth ||
27305 width > this.imageEl.OriginWidth ||
27306 height < this.minHeight ||
27307 height > this.imageEl.OriginHeight
27314 !this.isDocument &&
27315 (this.rotate == 90 || this.rotate == 270) &&
27317 width < this.minHeight ||
27318 width > this.imageEl.OriginWidth ||
27319 height < this.minWidth ||
27320 height > this.imageEl.OriginHeight
27330 onRotateLeft : function(e)
27332 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27334 var minScale = this.thumbEl.getWidth() / this.minWidth;
27336 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27337 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27339 this.startScale = this.scale;
27341 while (this.getScaleLevel() < minScale){
27343 this.scale = this.scale + 1;
27345 if(!this.zoomable()){
27350 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27351 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27356 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27363 this.scale = this.startScale;
27365 this.onRotateFail();
27370 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27372 if(this.isDocument){
27373 this.setThumbBoxSize();
27374 this.setThumbBoxPosition();
27375 this.setCanvasPosition();
27380 this.fireEvent('rotate', this, 'left');
27384 onRotateRight : function(e)
27386 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27388 var minScale = this.thumbEl.getWidth() / this.minWidth;
27390 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27391 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27393 this.startScale = this.scale;
27395 while (this.getScaleLevel() < minScale){
27397 this.scale = this.scale + 1;
27399 if(!this.zoomable()){
27404 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27405 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27410 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27417 this.scale = this.startScale;
27419 this.onRotateFail();
27424 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27426 if(this.isDocument){
27427 this.setThumbBoxSize();
27428 this.setThumbBoxPosition();
27429 this.setCanvasPosition();
27434 this.fireEvent('rotate', this, 'right');
27437 onRotateFail : function()
27439 this.errorEl.show(true);
27443 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27448 this.previewEl.dom.innerHTML = '';
27450 var canvasEl = document.createElement("canvas");
27452 var contextEl = canvasEl.getContext("2d");
27454 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27455 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27456 var center = this.imageEl.OriginWidth / 2;
27458 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27459 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27460 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27461 center = this.imageEl.OriginHeight / 2;
27464 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27466 contextEl.translate(center, center);
27467 contextEl.rotate(this.rotate * Math.PI / 180);
27469 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27471 this.canvasEl = document.createElement("canvas");
27473 this.contextEl = this.canvasEl.getContext("2d");
27475 switch (this.rotate) {
27478 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27479 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27481 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27486 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27487 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27489 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27490 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);
27494 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27499 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27500 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27502 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27503 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);
27507 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);
27512 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27513 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27515 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27516 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27520 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);
27527 this.previewEl.appendChild(this.canvasEl);
27529 this.setCanvasPosition();
27534 if(!this.canvasLoaded){
27538 var imageCanvas = document.createElement("canvas");
27540 var imageContext = imageCanvas.getContext("2d");
27542 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27543 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27545 var center = imageCanvas.width / 2;
27547 imageContext.translate(center, center);
27549 imageContext.rotate(this.rotate * Math.PI / 180);
27551 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27553 var canvas = document.createElement("canvas");
27555 var context = canvas.getContext("2d");
27557 canvas.width = this.minWidth;
27558 canvas.height = this.minHeight;
27560 switch (this.rotate) {
27563 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27564 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27566 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27567 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27569 var targetWidth = this.minWidth - 2 * x;
27570 var targetHeight = this.minHeight - 2 * y;
27574 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27575 scale = targetWidth / width;
27578 if(x > 0 && y == 0){
27579 scale = targetHeight / height;
27582 if(x > 0 && y > 0){
27583 scale = targetWidth / width;
27585 if(width < height){
27586 scale = targetHeight / height;
27590 context.scale(scale, scale);
27592 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27593 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27595 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27596 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27598 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27603 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27604 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27606 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27607 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27609 var targetWidth = this.minWidth - 2 * x;
27610 var targetHeight = this.minHeight - 2 * y;
27614 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27615 scale = targetWidth / width;
27618 if(x > 0 && y == 0){
27619 scale = targetHeight / height;
27622 if(x > 0 && y > 0){
27623 scale = targetWidth / width;
27625 if(width < height){
27626 scale = targetHeight / height;
27630 context.scale(scale, scale);
27632 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27633 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27635 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27636 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27638 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27640 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27645 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27646 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27648 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27649 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27651 var targetWidth = this.minWidth - 2 * x;
27652 var targetHeight = this.minHeight - 2 * y;
27656 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27657 scale = targetWidth / width;
27660 if(x > 0 && y == 0){
27661 scale = targetHeight / height;
27664 if(x > 0 && y > 0){
27665 scale = targetWidth / width;
27667 if(width < height){
27668 scale = targetHeight / height;
27672 context.scale(scale, scale);
27674 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27675 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27677 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27678 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27680 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27681 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27683 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27688 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27689 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27691 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27692 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27694 var targetWidth = this.minWidth - 2 * x;
27695 var targetHeight = this.minHeight - 2 * y;
27699 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27700 scale = targetWidth / width;
27703 if(x > 0 && y == 0){
27704 scale = targetHeight / height;
27707 if(x > 0 && y > 0){
27708 scale = targetWidth / width;
27710 if(width < height){
27711 scale = targetHeight / height;
27715 context.scale(scale, scale);
27717 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27718 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27720 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27721 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27723 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27725 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27732 this.cropData = canvas.toDataURL(this.cropType);
27734 if(this.fireEvent('crop', this, this.cropData) !== false){
27735 this.process(this.file, this.cropData);
27742 setThumbBoxSize : function()
27746 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27747 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27748 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27750 this.minWidth = width;
27751 this.minHeight = height;
27753 if(this.rotate == 90 || this.rotate == 270){
27754 this.minWidth = height;
27755 this.minHeight = width;
27760 width = Math.ceil(this.minWidth * height / this.minHeight);
27762 if(this.minWidth > this.minHeight){
27764 height = Math.ceil(this.minHeight * width / this.minWidth);
27767 this.thumbEl.setStyle({
27768 width : width + 'px',
27769 height : height + 'px'
27776 setThumbBoxPosition : function()
27778 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27779 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27781 this.thumbEl.setLeft(x);
27782 this.thumbEl.setTop(y);
27786 baseRotateLevel : function()
27788 this.baseRotate = 1;
27791 typeof(this.exif) != 'undefined' &&
27792 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27793 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27795 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27798 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27802 baseScaleLevel : function()
27806 if(this.isDocument){
27808 if(this.baseRotate == 6 || this.baseRotate == 8){
27810 height = this.thumbEl.getHeight();
27811 this.baseScale = height / this.imageEl.OriginWidth;
27813 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27814 width = this.thumbEl.getWidth();
27815 this.baseScale = width / this.imageEl.OriginHeight;
27821 height = this.thumbEl.getHeight();
27822 this.baseScale = height / this.imageEl.OriginHeight;
27824 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27825 width = this.thumbEl.getWidth();
27826 this.baseScale = width / this.imageEl.OriginWidth;
27832 if(this.baseRotate == 6 || this.baseRotate == 8){
27834 width = this.thumbEl.getHeight();
27835 this.baseScale = width / this.imageEl.OriginHeight;
27837 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27838 height = this.thumbEl.getWidth();
27839 this.baseScale = height / this.imageEl.OriginHeight;
27842 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27843 height = this.thumbEl.getWidth();
27844 this.baseScale = height / this.imageEl.OriginHeight;
27846 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27847 width = this.thumbEl.getHeight();
27848 this.baseScale = width / this.imageEl.OriginWidth;
27855 width = this.thumbEl.getWidth();
27856 this.baseScale = width / this.imageEl.OriginWidth;
27858 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27859 height = this.thumbEl.getHeight();
27860 this.baseScale = height / this.imageEl.OriginHeight;
27863 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27865 height = this.thumbEl.getHeight();
27866 this.baseScale = height / this.imageEl.OriginHeight;
27868 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27869 width = this.thumbEl.getWidth();
27870 this.baseScale = width / this.imageEl.OriginWidth;
27878 getScaleLevel : function()
27880 return this.baseScale * Math.pow(1.1, this.scale);
27883 onTouchStart : function(e)
27885 if(!this.canvasLoaded){
27886 this.beforeSelectFile(e);
27890 var touches = e.browserEvent.touches;
27896 if(touches.length == 1){
27897 this.onMouseDown(e);
27901 if(touches.length != 2){
27907 for(var i = 0, finger; finger = touches[i]; i++){
27908 coords.push(finger.pageX, finger.pageY);
27911 var x = Math.pow(coords[0] - coords[2], 2);
27912 var y = Math.pow(coords[1] - coords[3], 2);
27914 this.startDistance = Math.sqrt(x + y);
27916 this.startScale = this.scale;
27918 this.pinching = true;
27919 this.dragable = false;
27923 onTouchMove : function(e)
27925 if(!this.pinching && !this.dragable){
27929 var touches = e.browserEvent.touches;
27936 this.onMouseMove(e);
27942 for(var i = 0, finger; finger = touches[i]; i++){
27943 coords.push(finger.pageX, finger.pageY);
27946 var x = Math.pow(coords[0] - coords[2], 2);
27947 var y = Math.pow(coords[1] - coords[3], 2);
27949 this.endDistance = Math.sqrt(x + y);
27951 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27953 if(!this.zoomable()){
27954 this.scale = this.startScale;
27962 onTouchEnd : function(e)
27964 this.pinching = false;
27965 this.dragable = false;
27969 process : function(file, crop)
27972 this.maskEl.mask(this.loadingText);
27975 this.xhr = new XMLHttpRequest();
27977 file.xhr = this.xhr;
27979 this.xhr.open(this.method, this.url, true);
27982 "Accept": "application/json",
27983 "Cache-Control": "no-cache",
27984 "X-Requested-With": "XMLHttpRequest"
27987 for (var headerName in headers) {
27988 var headerValue = headers[headerName];
27990 this.xhr.setRequestHeader(headerName, headerValue);
27996 this.xhr.onload = function()
27998 _this.xhrOnLoad(_this.xhr);
28001 this.xhr.onerror = function()
28003 _this.xhrOnError(_this.xhr);
28006 var formData = new FormData();
28008 formData.append('returnHTML', 'NO');
28011 formData.append('crop', crop);
28014 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28015 formData.append(this.paramName, file, file.name);
28018 if(typeof(file.filename) != 'undefined'){
28019 formData.append('filename', file.filename);
28022 if(typeof(file.mimetype) != 'undefined'){
28023 formData.append('mimetype', file.mimetype);
28026 if(this.fireEvent('arrange', this, formData) != false){
28027 this.xhr.send(formData);
28031 xhrOnLoad : function(xhr)
28034 this.maskEl.unmask();
28037 if (xhr.readyState !== 4) {
28038 this.fireEvent('exception', this, xhr);
28042 var response = Roo.decode(xhr.responseText);
28044 if(!response.success){
28045 this.fireEvent('exception', this, xhr);
28049 var response = Roo.decode(xhr.responseText);
28051 this.fireEvent('upload', this, response);
28055 xhrOnError : function()
28058 this.maskEl.unmask();
28061 Roo.log('xhr on error');
28063 var response = Roo.decode(xhr.responseText);
28069 prepare : function(file)
28072 this.maskEl.mask(this.loadingText);
28078 if(typeof(file) === 'string'){
28079 this.loadCanvas(file);
28083 if(!file || !this.urlAPI){
28088 this.cropType = file.type;
28092 if(this.fireEvent('prepare', this, this.file) != false){
28094 var reader = new FileReader();
28096 reader.onload = function (e) {
28097 if (e.target.error) {
28098 Roo.log(e.target.error);
28102 var buffer = e.target.result,
28103 dataView = new DataView(buffer),
28105 maxOffset = dataView.byteLength - 4,
28109 if (dataView.getUint16(0) === 0xffd8) {
28110 while (offset < maxOffset) {
28111 markerBytes = dataView.getUint16(offset);
28113 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28114 markerLength = dataView.getUint16(offset + 2) + 2;
28115 if (offset + markerLength > dataView.byteLength) {
28116 Roo.log('Invalid meta data: Invalid segment size.');
28120 if(markerBytes == 0xffe1){
28121 _this.parseExifData(
28128 offset += markerLength;
28138 var url = _this.urlAPI.createObjectURL(_this.file);
28140 _this.loadCanvas(url);
28145 reader.readAsArrayBuffer(this.file);
28151 parseExifData : function(dataView, offset, length)
28153 var tiffOffset = offset + 10,
28157 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28158 // No Exif data, might be XMP data instead
28162 // Check for the ASCII code for "Exif" (0x45786966):
28163 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28164 // No Exif data, might be XMP data instead
28167 if (tiffOffset + 8 > dataView.byteLength) {
28168 Roo.log('Invalid Exif data: Invalid segment size.');
28171 // Check for the two null bytes:
28172 if (dataView.getUint16(offset + 8) !== 0x0000) {
28173 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28176 // Check the byte alignment:
28177 switch (dataView.getUint16(tiffOffset)) {
28179 littleEndian = true;
28182 littleEndian = false;
28185 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28188 // Check for the TIFF tag marker (0x002A):
28189 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28190 Roo.log('Invalid Exif data: Missing TIFF marker.');
28193 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28194 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28196 this.parseExifTags(
28199 tiffOffset + dirOffset,
28204 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28209 if (dirOffset + 6 > dataView.byteLength) {
28210 Roo.log('Invalid Exif data: Invalid directory offset.');
28213 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28214 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28215 if (dirEndOffset + 4 > dataView.byteLength) {
28216 Roo.log('Invalid Exif data: Invalid directory size.');
28219 for (i = 0; i < tagsNumber; i += 1) {
28223 dirOffset + 2 + 12 * i, // tag offset
28227 // Return the offset to the next directory:
28228 return dataView.getUint32(dirEndOffset, littleEndian);
28231 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28233 var tag = dataView.getUint16(offset, littleEndian);
28235 this.exif[tag] = this.getExifValue(
28239 dataView.getUint16(offset + 2, littleEndian), // tag type
28240 dataView.getUint32(offset + 4, littleEndian), // tag length
28245 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28247 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28256 Roo.log('Invalid Exif data: Invalid tag type.');
28260 tagSize = tagType.size * length;
28261 // Determine if the value is contained in the dataOffset bytes,
28262 // or if the value at the dataOffset is a pointer to the actual data:
28263 dataOffset = tagSize > 4 ?
28264 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28265 if (dataOffset + tagSize > dataView.byteLength) {
28266 Roo.log('Invalid Exif data: Invalid data offset.');
28269 if (length === 1) {
28270 return tagType.getValue(dataView, dataOffset, littleEndian);
28273 for (i = 0; i < length; i += 1) {
28274 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28277 if (tagType.ascii) {
28279 // Concatenate the chars:
28280 for (i = 0; i < values.length; i += 1) {
28282 // Ignore the terminating NULL byte(s):
28283 if (c === '\u0000') {
28295 Roo.apply(Roo.bootstrap.UploadCropbox, {
28297 'Orientation': 0x0112
28301 1: 0, //'top-left',
28303 3: 180, //'bottom-right',
28304 // 4: 'bottom-left',
28306 6: 90, //'right-top',
28307 // 7: 'right-bottom',
28308 8: 270 //'left-bottom'
28312 // byte, 8-bit unsigned int:
28314 getValue: function (dataView, dataOffset) {
28315 return dataView.getUint8(dataOffset);
28319 // ascii, 8-bit byte:
28321 getValue: function (dataView, dataOffset) {
28322 return String.fromCharCode(dataView.getUint8(dataOffset));
28327 // short, 16 bit int:
28329 getValue: function (dataView, dataOffset, littleEndian) {
28330 return dataView.getUint16(dataOffset, littleEndian);
28334 // long, 32 bit int:
28336 getValue: function (dataView, dataOffset, littleEndian) {
28337 return dataView.getUint32(dataOffset, littleEndian);
28341 // rational = two long values, first is numerator, second is denominator:
28343 getValue: function (dataView, dataOffset, littleEndian) {
28344 return dataView.getUint32(dataOffset, littleEndian) /
28345 dataView.getUint32(dataOffset + 4, littleEndian);
28349 // slong, 32 bit signed int:
28351 getValue: function (dataView, dataOffset, littleEndian) {
28352 return dataView.getInt32(dataOffset, littleEndian);
28356 // srational, two slongs, first is numerator, second is denominator:
28358 getValue: function (dataView, dataOffset, littleEndian) {
28359 return dataView.getInt32(dataOffset, littleEndian) /
28360 dataView.getInt32(dataOffset + 4, littleEndian);
28370 cls : 'btn-group roo-upload-cropbox-rotate-left',
28371 action : 'rotate-left',
28375 cls : 'btn btn-default',
28376 html : '<i class="fa fa-undo"></i>'
28382 cls : 'btn-group roo-upload-cropbox-picture',
28383 action : 'picture',
28387 cls : 'btn btn-default',
28388 html : '<i class="fa fa-picture-o"></i>'
28394 cls : 'btn-group roo-upload-cropbox-rotate-right',
28395 action : 'rotate-right',
28399 cls : 'btn btn-default',
28400 html : '<i class="fa fa-repeat"></i>'
28408 cls : 'btn-group roo-upload-cropbox-rotate-left',
28409 action : 'rotate-left',
28413 cls : 'btn btn-default',
28414 html : '<i class="fa fa-undo"></i>'
28420 cls : 'btn-group roo-upload-cropbox-download',
28421 action : 'download',
28425 cls : 'btn btn-default',
28426 html : '<i class="fa fa-download"></i>'
28432 cls : 'btn-group roo-upload-cropbox-crop',
28437 cls : 'btn btn-default',
28438 html : '<i class="fa fa-crop"></i>'
28444 cls : 'btn-group roo-upload-cropbox-trash',
28449 cls : 'btn btn-default',
28450 html : '<i class="fa fa-trash"></i>'
28456 cls : 'btn-group roo-upload-cropbox-rotate-right',
28457 action : 'rotate-right',
28461 cls : 'btn btn-default',
28462 html : '<i class="fa fa-repeat"></i>'
28470 cls : 'btn-group roo-upload-cropbox-rotate-left',
28471 action : 'rotate-left',
28475 cls : 'btn btn-default',
28476 html : '<i class="fa fa-undo"></i>'
28482 cls : 'btn-group roo-upload-cropbox-rotate-right',
28483 action : 'rotate-right',
28487 cls : 'btn btn-default',
28488 html : '<i class="fa fa-repeat"></i>'
28501 * @class Roo.bootstrap.DocumentManager
28502 * @extends Roo.bootstrap.Component
28503 * Bootstrap DocumentManager class
28504 * @cfg {String} paramName default 'imageUpload'
28505 * @cfg {String} toolTipName default 'filename'
28506 * @cfg {String} method default POST
28507 * @cfg {String} url action url
28508 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28509 * @cfg {Boolean} multiple multiple upload default true
28510 * @cfg {Number} thumbSize default 300
28511 * @cfg {String} fieldLabel
28512 * @cfg {Number} labelWidth default 4
28513 * @cfg {String} labelAlign (left|top) default left
28514 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28515 * @cfg {Number} labellg set the width of label (1-12)
28516 * @cfg {Number} labelmd set the width of label (1-12)
28517 * @cfg {Number} labelsm set the width of label (1-12)
28518 * @cfg {Number} labelxs set the width of label (1-12)
28521 * Create a new DocumentManager
28522 * @param {Object} config The config object
28525 Roo.bootstrap.DocumentManager = function(config){
28526 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28529 this.delegates = [];
28534 * Fire when initial the DocumentManager
28535 * @param {Roo.bootstrap.DocumentManager} this
28540 * inspect selected file
28541 * @param {Roo.bootstrap.DocumentManager} this
28542 * @param {File} file
28547 * Fire when xhr load exception
28548 * @param {Roo.bootstrap.DocumentManager} this
28549 * @param {XMLHttpRequest} xhr
28551 "exception" : true,
28553 * @event afterupload
28554 * Fire when xhr load exception
28555 * @param {Roo.bootstrap.DocumentManager} this
28556 * @param {XMLHttpRequest} xhr
28558 "afterupload" : true,
28561 * prepare the form data
28562 * @param {Roo.bootstrap.DocumentManager} this
28563 * @param {Object} formData
28568 * Fire when remove the file
28569 * @param {Roo.bootstrap.DocumentManager} this
28570 * @param {Object} file
28575 * Fire after refresh the file
28576 * @param {Roo.bootstrap.DocumentManager} this
28581 * Fire after click the image
28582 * @param {Roo.bootstrap.DocumentManager} this
28583 * @param {Object} file
28588 * Fire when upload a image and editable set to true
28589 * @param {Roo.bootstrap.DocumentManager} this
28590 * @param {Object} file
28594 * @event beforeselectfile
28595 * Fire before select file
28596 * @param {Roo.bootstrap.DocumentManager} this
28598 "beforeselectfile" : true,
28601 * Fire before process file
28602 * @param {Roo.bootstrap.DocumentManager} this
28603 * @param {Object} file
28607 * @event previewrendered
28608 * Fire when preview rendered
28609 * @param {Roo.bootstrap.DocumentManager} this
28610 * @param {Object} file
28612 "previewrendered" : true
28617 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28626 paramName : 'imageUpload',
28627 toolTipName : 'filename',
28630 labelAlign : 'left',
28640 getAutoCreate : function()
28642 var managerWidget = {
28644 cls : 'roo-document-manager',
28648 cls : 'roo-document-manager-selector',
28653 cls : 'roo-document-manager-uploader',
28657 cls : 'roo-document-manager-upload-btn',
28658 html : '<i class="fa fa-plus"></i>'
28669 cls : 'column col-md-12',
28674 if(this.fieldLabel.length){
28679 cls : 'column col-md-12',
28680 html : this.fieldLabel
28684 cls : 'column col-md-12',
28689 if(this.labelAlign == 'left'){
28694 html : this.fieldLabel
28703 if(this.labelWidth > 12){
28704 content[0].style = "width: " + this.labelWidth + 'px';
28707 if(this.labelWidth < 13 && this.labelmd == 0){
28708 this.labelmd = this.labelWidth;
28711 if(this.labellg > 0){
28712 content[0].cls += ' col-lg-' + this.labellg;
28713 content[1].cls += ' col-lg-' + (12 - this.labellg);
28716 if(this.labelmd > 0){
28717 content[0].cls += ' col-md-' + this.labelmd;
28718 content[1].cls += ' col-md-' + (12 - this.labelmd);
28721 if(this.labelsm > 0){
28722 content[0].cls += ' col-sm-' + this.labelsm;
28723 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28726 if(this.labelxs > 0){
28727 content[0].cls += ' col-xs-' + this.labelxs;
28728 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28736 cls : 'row clearfix',
28744 initEvents : function()
28746 this.managerEl = this.el.select('.roo-document-manager', true).first();
28747 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28749 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28750 this.selectorEl.hide();
28753 this.selectorEl.attr('multiple', 'multiple');
28756 this.selectorEl.on('change', this.onFileSelected, this);
28758 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28759 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28761 this.uploader.on('click', this.onUploaderClick, this);
28763 this.renderProgressDialog();
28767 window.addEventListener("resize", function() { _this.refresh(); } );
28769 this.fireEvent('initial', this);
28772 renderProgressDialog : function()
28776 this.progressDialog = new Roo.bootstrap.Modal({
28777 cls : 'roo-document-manager-progress-dialog',
28778 allow_close : false,
28788 btnclick : function() {
28789 _this.uploadCancel();
28795 this.progressDialog.render(Roo.get(document.body));
28797 this.progress = new Roo.bootstrap.Progress({
28798 cls : 'roo-document-manager-progress',
28803 this.progress.render(this.progressDialog.getChildContainer());
28805 this.progressBar = new Roo.bootstrap.ProgressBar({
28806 cls : 'roo-document-manager-progress-bar',
28809 aria_valuemax : 12,
28813 this.progressBar.render(this.progress.getChildContainer());
28816 onUploaderClick : function(e)
28818 e.preventDefault();
28820 if(this.fireEvent('beforeselectfile', this) != false){
28821 this.selectorEl.dom.click();
28826 onFileSelected : function(e)
28828 e.preventDefault();
28830 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28834 Roo.each(this.selectorEl.dom.files, function(file){
28835 if(this.fireEvent('inspect', this, file) != false){
28836 this.files.push(file);
28846 this.selectorEl.dom.value = '';
28848 if(!this.files || !this.files.length){
28852 if(this.boxes > 0 && this.files.length > this.boxes){
28853 this.files = this.files.slice(0, this.boxes);
28856 this.uploader.show();
28858 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28859 this.uploader.hide();
28868 Roo.each(this.files, function(file){
28870 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28871 var f = this.renderPreview(file);
28876 if(file.type.indexOf('image') != -1){
28877 this.delegates.push(
28879 _this.process(file);
28880 }).createDelegate(this)
28888 _this.process(file);
28889 }).createDelegate(this)
28894 this.files = files;
28896 this.delegates = this.delegates.concat(docs);
28898 if(!this.delegates.length){
28903 this.progressBar.aria_valuemax = this.delegates.length;
28910 arrange : function()
28912 if(!this.delegates.length){
28913 this.progressDialog.hide();
28918 var delegate = this.delegates.shift();
28920 this.progressDialog.show();
28922 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28924 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28929 refresh : function()
28931 this.uploader.show();
28933 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28934 this.uploader.hide();
28937 Roo.isTouch ? this.closable(false) : this.closable(true);
28939 this.fireEvent('refresh', this);
28942 onRemove : function(e, el, o)
28944 e.preventDefault();
28946 this.fireEvent('remove', this, o);
28950 remove : function(o)
28954 Roo.each(this.files, function(file){
28955 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28964 this.files = files;
28971 Roo.each(this.files, function(file){
28976 file.target.remove();
28985 onClick : function(e, el, o)
28987 e.preventDefault();
28989 this.fireEvent('click', this, o);
28993 closable : function(closable)
28995 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28997 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29009 xhrOnLoad : function(xhr)
29011 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29015 if (xhr.readyState !== 4) {
29017 this.fireEvent('exception', this, xhr);
29021 var response = Roo.decode(xhr.responseText);
29023 if(!response.success){
29025 this.fireEvent('exception', this, xhr);
29029 var file = this.renderPreview(response.data);
29031 this.files.push(file);
29035 this.fireEvent('afterupload', this, xhr);
29039 xhrOnError : function(xhr)
29041 Roo.log('xhr on error');
29043 var response = Roo.decode(xhr.responseText);
29050 process : function(file)
29052 if(this.fireEvent('process', this, file) !== false){
29053 if(this.editable && file.type.indexOf('image') != -1){
29054 this.fireEvent('edit', this, file);
29058 this.uploadStart(file, false);
29065 uploadStart : function(file, crop)
29067 this.xhr = new XMLHttpRequest();
29069 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29074 file.xhr = this.xhr;
29076 this.managerEl.createChild({
29078 cls : 'roo-document-manager-loading',
29082 tooltip : file.name,
29083 cls : 'roo-document-manager-thumb',
29084 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29090 this.xhr.open(this.method, this.url, true);
29093 "Accept": "application/json",
29094 "Cache-Control": "no-cache",
29095 "X-Requested-With": "XMLHttpRequest"
29098 for (var headerName in headers) {
29099 var headerValue = headers[headerName];
29101 this.xhr.setRequestHeader(headerName, headerValue);
29107 this.xhr.onload = function()
29109 _this.xhrOnLoad(_this.xhr);
29112 this.xhr.onerror = function()
29114 _this.xhrOnError(_this.xhr);
29117 var formData = new FormData();
29119 formData.append('returnHTML', 'NO');
29122 formData.append('crop', crop);
29125 formData.append(this.paramName, file, file.name);
29132 if(this.fireEvent('prepare', this, formData, options) != false){
29134 if(options.manually){
29138 this.xhr.send(formData);
29142 this.uploadCancel();
29145 uploadCancel : function()
29151 this.delegates = [];
29153 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29160 renderPreview : function(file)
29162 if(typeof(file.target) != 'undefined' && file.target){
29166 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29168 var previewEl = this.managerEl.createChild({
29170 cls : 'roo-document-manager-preview',
29174 tooltip : file[this.toolTipName],
29175 cls : 'roo-document-manager-thumb',
29176 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29181 html : '<i class="fa fa-times-circle"></i>'
29186 var close = previewEl.select('button.close', true).first();
29188 close.on('click', this.onRemove, this, file);
29190 file.target = previewEl;
29192 var image = previewEl.select('img', true).first();
29196 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29198 image.on('click', this.onClick, this, file);
29200 this.fireEvent('previewrendered', this, file);
29206 onPreviewLoad : function(file, image)
29208 if(typeof(file.target) == 'undefined' || !file.target){
29212 var width = image.dom.naturalWidth || image.dom.width;
29213 var height = image.dom.naturalHeight || image.dom.height;
29215 if(width > height){
29216 file.target.addClass('wide');
29220 file.target.addClass('tall');
29225 uploadFromSource : function(file, crop)
29227 this.xhr = new XMLHttpRequest();
29229 this.managerEl.createChild({
29231 cls : 'roo-document-manager-loading',
29235 tooltip : file.name,
29236 cls : 'roo-document-manager-thumb',
29237 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29243 this.xhr.open(this.method, this.url, true);
29246 "Accept": "application/json",
29247 "Cache-Control": "no-cache",
29248 "X-Requested-With": "XMLHttpRequest"
29251 for (var headerName in headers) {
29252 var headerValue = headers[headerName];
29254 this.xhr.setRequestHeader(headerName, headerValue);
29260 this.xhr.onload = function()
29262 _this.xhrOnLoad(_this.xhr);
29265 this.xhr.onerror = function()
29267 _this.xhrOnError(_this.xhr);
29270 var formData = new FormData();
29272 formData.append('returnHTML', 'NO');
29274 formData.append('crop', crop);
29276 if(typeof(file.filename) != 'undefined'){
29277 formData.append('filename', file.filename);
29280 if(typeof(file.mimetype) != 'undefined'){
29281 formData.append('mimetype', file.mimetype);
29286 if(this.fireEvent('prepare', this, formData) != false){
29287 this.xhr.send(formData);
29297 * @class Roo.bootstrap.DocumentViewer
29298 * @extends Roo.bootstrap.Component
29299 * Bootstrap DocumentViewer class
29300 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29301 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29304 * Create a new DocumentViewer
29305 * @param {Object} config The config object
29308 Roo.bootstrap.DocumentViewer = function(config){
29309 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29314 * Fire after initEvent
29315 * @param {Roo.bootstrap.DocumentViewer} this
29321 * @param {Roo.bootstrap.DocumentViewer} this
29326 * Fire after download button
29327 * @param {Roo.bootstrap.DocumentViewer} this
29332 * Fire after trash button
29333 * @param {Roo.bootstrap.DocumentViewer} this
29340 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29342 showDownload : true,
29346 getAutoCreate : function()
29350 cls : 'roo-document-viewer',
29354 cls : 'roo-document-viewer-body',
29358 cls : 'roo-document-viewer-thumb',
29362 cls : 'roo-document-viewer-image'
29370 cls : 'roo-document-viewer-footer',
29373 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29377 cls : 'btn-group roo-document-viewer-download',
29381 cls : 'btn btn-default',
29382 html : '<i class="fa fa-download"></i>'
29388 cls : 'btn-group roo-document-viewer-trash',
29392 cls : 'btn btn-default',
29393 html : '<i class="fa fa-trash"></i>'
29406 initEvents : function()
29408 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29409 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29411 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29412 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29414 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29415 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29417 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29418 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29420 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29421 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29423 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29424 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29426 this.bodyEl.on('click', this.onClick, this);
29427 this.downloadBtn.on('click', this.onDownload, this);
29428 this.trashBtn.on('click', this.onTrash, this);
29430 this.downloadBtn.hide();
29431 this.trashBtn.hide();
29433 if(this.showDownload){
29434 this.downloadBtn.show();
29437 if(this.showTrash){
29438 this.trashBtn.show();
29441 if(!this.showDownload && !this.showTrash) {
29442 this.footerEl.hide();
29447 initial : function()
29449 this.fireEvent('initial', this);
29453 onClick : function(e)
29455 e.preventDefault();
29457 this.fireEvent('click', this);
29460 onDownload : function(e)
29462 e.preventDefault();
29464 this.fireEvent('download', this);
29467 onTrash : function(e)
29469 e.preventDefault();
29471 this.fireEvent('trash', this);
29483 * @class Roo.bootstrap.NavProgressBar
29484 * @extends Roo.bootstrap.Component
29485 * Bootstrap NavProgressBar class
29488 * Create a new nav progress bar
29489 * @param {Object} config The config object
29492 Roo.bootstrap.NavProgressBar = function(config){
29493 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29495 this.bullets = this.bullets || [];
29497 // Roo.bootstrap.NavProgressBar.register(this);
29501 * Fires when the active item changes
29502 * @param {Roo.bootstrap.NavProgressBar} this
29503 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29504 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29511 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29516 getAutoCreate : function()
29518 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29522 cls : 'roo-navigation-bar-group',
29526 cls : 'roo-navigation-top-bar'
29530 cls : 'roo-navigation-bullets-bar',
29534 cls : 'roo-navigation-bar'
29541 cls : 'roo-navigation-bottom-bar'
29551 initEvents: function()
29556 onRender : function(ct, position)
29558 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29560 if(this.bullets.length){
29561 Roo.each(this.bullets, function(b){
29570 addItem : function(cfg)
29572 var item = new Roo.bootstrap.NavProgressItem(cfg);
29574 item.parentId = this.id;
29575 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29578 var top = new Roo.bootstrap.Element({
29580 cls : 'roo-navigation-bar-text'
29583 var bottom = new Roo.bootstrap.Element({
29585 cls : 'roo-navigation-bar-text'
29588 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29589 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29591 var topText = new Roo.bootstrap.Element({
29593 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29596 var bottomText = new Roo.bootstrap.Element({
29598 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29601 topText.onRender(top.el, null);
29602 bottomText.onRender(bottom.el, null);
29605 item.bottomEl = bottom;
29608 this.barItems.push(item);
29613 getActive : function()
29615 var active = false;
29617 Roo.each(this.barItems, function(v){
29619 if (!v.isActive()) {
29631 setActiveItem : function(item)
29635 Roo.each(this.barItems, function(v){
29636 if (v.rid == item.rid) {
29640 if (v.isActive()) {
29641 v.setActive(false);
29646 item.setActive(true);
29648 this.fireEvent('changed', this, item, prev);
29651 getBarItem: function(rid)
29655 Roo.each(this.barItems, function(e) {
29656 if (e.rid != rid) {
29667 indexOfItem : function(item)
29671 Roo.each(this.barItems, function(v, i){
29673 if (v.rid != item.rid) {
29684 setActiveNext : function()
29686 var i = this.indexOfItem(this.getActive());
29688 if (i > this.barItems.length) {
29692 this.setActiveItem(this.barItems[i+1]);
29695 setActivePrev : function()
29697 var i = this.indexOfItem(this.getActive());
29703 this.setActiveItem(this.barItems[i-1]);
29706 format : function()
29708 if(!this.barItems.length){
29712 var width = 100 / this.barItems.length;
29714 Roo.each(this.barItems, function(i){
29715 i.el.setStyle('width', width + '%');
29716 i.topEl.el.setStyle('width', width + '%');
29717 i.bottomEl.el.setStyle('width', width + '%');
29726 * Nav Progress Item
29731 * @class Roo.bootstrap.NavProgressItem
29732 * @extends Roo.bootstrap.Component
29733 * Bootstrap NavProgressItem class
29734 * @cfg {String} rid the reference id
29735 * @cfg {Boolean} active (true|false) Is item active default false
29736 * @cfg {Boolean} disabled (true|false) Is item active default false
29737 * @cfg {String} html
29738 * @cfg {String} position (top|bottom) text position default bottom
29739 * @cfg {String} icon show icon instead of number
29742 * Create a new NavProgressItem
29743 * @param {Object} config The config object
29745 Roo.bootstrap.NavProgressItem = function(config){
29746 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29751 * The raw click event for the entire grid.
29752 * @param {Roo.bootstrap.NavProgressItem} this
29753 * @param {Roo.EventObject} e
29760 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29766 position : 'bottom',
29769 getAutoCreate : function()
29771 var iconCls = 'roo-navigation-bar-item-icon';
29773 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29777 cls: 'roo-navigation-bar-item',
29787 cfg.cls += ' active';
29790 cfg.cls += ' disabled';
29796 disable : function()
29798 this.setDisabled(true);
29801 enable : function()
29803 this.setDisabled(false);
29806 initEvents: function()
29808 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29810 this.iconEl.on('click', this.onClick, this);
29813 onClick : function(e)
29815 e.preventDefault();
29821 if(this.fireEvent('click', this, e) === false){
29825 this.parent().setActiveItem(this);
29828 isActive: function ()
29830 return this.active;
29833 setActive : function(state)
29835 if(this.active == state){
29839 this.active = state;
29842 this.el.addClass('active');
29846 this.el.removeClass('active');
29851 setDisabled : function(state)
29853 if(this.disabled == state){
29857 this.disabled = state;
29860 this.el.addClass('disabled');
29864 this.el.removeClass('disabled');
29867 tooltipEl : function()
29869 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29882 * @class Roo.bootstrap.FieldLabel
29883 * @extends Roo.bootstrap.Component
29884 * Bootstrap FieldLabel class
29885 * @cfg {String} html contents of the element
29886 * @cfg {String} tag tag of the element default label
29887 * @cfg {String} cls class of the element
29888 * @cfg {String} target label target
29889 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29890 * @cfg {String} invalidClass default "text-warning"
29891 * @cfg {String} validClass default "text-success"
29892 * @cfg {String} iconTooltip default "This field is required"
29893 * @cfg {String} indicatorpos (left|right) default left
29896 * Create a new FieldLabel
29897 * @param {Object} config The config object
29900 Roo.bootstrap.FieldLabel = function(config){
29901 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29906 * Fires after the field has been marked as invalid.
29907 * @param {Roo.form.FieldLabel} this
29908 * @param {String} msg The validation message
29913 * Fires after the field has been validated with no errors.
29914 * @param {Roo.form.FieldLabel} this
29920 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29927 invalidClass : 'has-warning',
29928 validClass : 'has-success',
29929 iconTooltip : 'This field is required',
29930 indicatorpos : 'left',
29932 getAutoCreate : function(){
29936 cls : 'roo-bootstrap-field-label ' + this.cls,
29941 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29942 tooltip : this.iconTooltip
29951 if(this.indicatorpos == 'right'){
29954 cls : 'roo-bootstrap-field-label ' + this.cls,
29963 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29964 tooltip : this.iconTooltip
29973 initEvents: function()
29975 Roo.bootstrap.Element.superclass.initEvents.call(this);
29977 this.indicator = this.indicatorEl();
29979 if(this.indicator){
29980 this.indicator.removeClass('visible');
29981 this.indicator.addClass('invisible');
29984 Roo.bootstrap.FieldLabel.register(this);
29987 indicatorEl : function()
29989 var indicator = this.el.select('i.roo-required-indicator',true).first();
30000 * Mark this field as valid
30002 markValid : function()
30004 if(this.indicator){
30005 this.indicator.removeClass('visible');
30006 this.indicator.addClass('invisible');
30009 this.el.removeClass(this.invalidClass);
30011 this.el.addClass(this.validClass);
30013 this.fireEvent('valid', this);
30017 * Mark this field as invalid
30018 * @param {String} msg The validation message
30020 markInvalid : function(msg)
30022 if(this.indicator){
30023 this.indicator.removeClass('invisible');
30024 this.indicator.addClass('visible');
30027 this.el.removeClass(this.validClass);
30029 this.el.addClass(this.invalidClass);
30031 this.fireEvent('invalid', this, msg);
30037 Roo.apply(Roo.bootstrap.FieldLabel, {
30042 * register a FieldLabel Group
30043 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30045 register : function(label)
30047 if(this.groups.hasOwnProperty(label.target)){
30051 this.groups[label.target] = label;
30055 * fetch a FieldLabel Group based on the target
30056 * @param {string} target
30057 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30059 get: function(target) {
30060 if (typeof(this.groups[target]) == 'undefined') {
30064 return this.groups[target] ;
30073 * page DateSplitField.
30079 * @class Roo.bootstrap.DateSplitField
30080 * @extends Roo.bootstrap.Component
30081 * Bootstrap DateSplitField class
30082 * @cfg {string} fieldLabel - the label associated
30083 * @cfg {Number} labelWidth set the width of label (0-12)
30084 * @cfg {String} labelAlign (top|left)
30085 * @cfg {Boolean} dayAllowBlank (true|false) default false
30086 * @cfg {Boolean} monthAllowBlank (true|false) default false
30087 * @cfg {Boolean} yearAllowBlank (true|false) default false
30088 * @cfg {string} dayPlaceholder
30089 * @cfg {string} monthPlaceholder
30090 * @cfg {string} yearPlaceholder
30091 * @cfg {string} dayFormat default 'd'
30092 * @cfg {string} monthFormat default 'm'
30093 * @cfg {string} yearFormat default 'Y'
30094 * @cfg {Number} labellg set the width of label (1-12)
30095 * @cfg {Number} labelmd set the width of label (1-12)
30096 * @cfg {Number} labelsm set the width of label (1-12)
30097 * @cfg {Number} labelxs set the width of label (1-12)
30101 * Create a new DateSplitField
30102 * @param {Object} config The config object
30105 Roo.bootstrap.DateSplitField = function(config){
30106 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30112 * getting the data of years
30113 * @param {Roo.bootstrap.DateSplitField} this
30114 * @param {Object} years
30119 * getting the data of days
30120 * @param {Roo.bootstrap.DateSplitField} this
30121 * @param {Object} days
30126 * Fires after the field has been marked as invalid.
30127 * @param {Roo.form.Field} this
30128 * @param {String} msg The validation message
30133 * Fires after the field has been validated with no errors.
30134 * @param {Roo.form.Field} this
30140 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30143 labelAlign : 'top',
30145 dayAllowBlank : false,
30146 monthAllowBlank : false,
30147 yearAllowBlank : false,
30148 dayPlaceholder : '',
30149 monthPlaceholder : '',
30150 yearPlaceholder : '',
30154 isFormField : true,
30160 getAutoCreate : function()
30164 cls : 'row roo-date-split-field-group',
30169 cls : 'form-hidden-field roo-date-split-field-group-value',
30175 var labelCls = 'col-md-12';
30176 var contentCls = 'col-md-4';
30178 if(this.fieldLabel){
30182 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30186 html : this.fieldLabel
30191 if(this.labelAlign == 'left'){
30193 if(this.labelWidth > 12){
30194 label.style = "width: " + this.labelWidth + 'px';
30197 if(this.labelWidth < 13 && this.labelmd == 0){
30198 this.labelmd = this.labelWidth;
30201 if(this.labellg > 0){
30202 labelCls = ' col-lg-' + this.labellg;
30203 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30206 if(this.labelmd > 0){
30207 labelCls = ' col-md-' + this.labelmd;
30208 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30211 if(this.labelsm > 0){
30212 labelCls = ' col-sm-' + this.labelsm;
30213 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30216 if(this.labelxs > 0){
30217 labelCls = ' col-xs-' + this.labelxs;
30218 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30222 label.cls += ' ' + labelCls;
30224 cfg.cn.push(label);
30227 Roo.each(['day', 'month', 'year'], function(t){
30230 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30237 inputEl: function ()
30239 return this.el.select('.roo-date-split-field-group-value', true).first();
30242 onRender : function(ct, position)
30246 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30248 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30250 this.dayField = new Roo.bootstrap.ComboBox({
30251 allowBlank : this.dayAllowBlank,
30252 alwaysQuery : true,
30253 displayField : 'value',
30256 forceSelection : true,
30258 placeholder : this.dayPlaceholder,
30259 selectOnFocus : true,
30260 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30261 triggerAction : 'all',
30263 valueField : 'value',
30264 store : new Roo.data.SimpleStore({
30265 data : (function() {
30267 _this.fireEvent('days', _this, days);
30270 fields : [ 'value' ]
30273 select : function (_self, record, index)
30275 _this.setValue(_this.getValue());
30280 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30282 this.monthField = new Roo.bootstrap.MonthField({
30283 after : '<i class=\"fa fa-calendar\"></i>',
30284 allowBlank : this.monthAllowBlank,
30285 placeholder : this.monthPlaceholder,
30288 render : function (_self)
30290 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30291 e.preventDefault();
30295 select : function (_self, oldvalue, newvalue)
30297 _this.setValue(_this.getValue());
30302 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30304 this.yearField = new Roo.bootstrap.ComboBox({
30305 allowBlank : this.yearAllowBlank,
30306 alwaysQuery : true,
30307 displayField : 'value',
30310 forceSelection : true,
30312 placeholder : this.yearPlaceholder,
30313 selectOnFocus : true,
30314 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30315 triggerAction : 'all',
30317 valueField : 'value',
30318 store : new Roo.data.SimpleStore({
30319 data : (function() {
30321 _this.fireEvent('years', _this, years);
30324 fields : [ 'value' ]
30327 select : function (_self, record, index)
30329 _this.setValue(_this.getValue());
30334 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30337 setValue : function(v, format)
30339 this.inputEl.dom.value = v;
30341 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30343 var d = Date.parseDate(v, f);
30350 this.setDay(d.format(this.dayFormat));
30351 this.setMonth(d.format(this.monthFormat));
30352 this.setYear(d.format(this.yearFormat));
30359 setDay : function(v)
30361 this.dayField.setValue(v);
30362 this.inputEl.dom.value = this.getValue();
30367 setMonth : function(v)
30369 this.monthField.setValue(v, true);
30370 this.inputEl.dom.value = this.getValue();
30375 setYear : function(v)
30377 this.yearField.setValue(v);
30378 this.inputEl.dom.value = this.getValue();
30383 getDay : function()
30385 return this.dayField.getValue();
30388 getMonth : function()
30390 return this.monthField.getValue();
30393 getYear : function()
30395 return this.yearField.getValue();
30398 getValue : function()
30400 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30402 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30412 this.inputEl.dom.value = '';
30417 validate : function()
30419 var d = this.dayField.validate();
30420 var m = this.monthField.validate();
30421 var y = this.yearField.validate();
30426 (!this.dayAllowBlank && !d) ||
30427 (!this.monthAllowBlank && !m) ||
30428 (!this.yearAllowBlank && !y)
30433 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30442 this.markInvalid();
30447 markValid : function()
30450 var label = this.el.select('label', true).first();
30451 var icon = this.el.select('i.fa-star', true).first();
30457 this.fireEvent('valid', this);
30461 * Mark this field as invalid
30462 * @param {String} msg The validation message
30464 markInvalid : function(msg)
30467 var label = this.el.select('label', true).first();
30468 var icon = this.el.select('i.fa-star', true).first();
30470 if(label && !icon){
30471 this.el.select('.roo-date-split-field-label', true).createChild({
30473 cls : 'text-danger fa fa-lg fa-star',
30474 tooltip : 'This field is required',
30475 style : 'margin-right:5px;'
30479 this.fireEvent('invalid', this, msg);
30482 clearInvalid : function()
30484 var label = this.el.select('label', true).first();
30485 var icon = this.el.select('i.fa-star', true).first();
30491 this.fireEvent('valid', this);
30494 getName: function()
30504 * http://masonry.desandro.com
30506 * The idea is to render all the bricks based on vertical width...
30508 * The original code extends 'outlayer' - we might need to use that....
30514 * @class Roo.bootstrap.LayoutMasonry
30515 * @extends Roo.bootstrap.Component
30516 * Bootstrap Layout Masonry class
30519 * Create a new Element
30520 * @param {Object} config The config object
30523 Roo.bootstrap.LayoutMasonry = function(config){
30525 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30529 Roo.bootstrap.LayoutMasonry.register(this);
30535 * Fire after layout the items
30536 * @param {Roo.bootstrap.LayoutMasonry} this
30537 * @param {Roo.EventObject} e
30544 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30547 * @cfg {Boolean} isLayoutInstant = no animation?
30549 isLayoutInstant : false, // needed?
30552 * @cfg {Number} boxWidth width of the columns
30557 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30562 * @cfg {Number} padWidth padding below box..
30567 * @cfg {Number} gutter gutter width..
30572 * @cfg {Number} maxCols maximum number of columns
30578 * @cfg {Boolean} isAutoInitial defalut true
30580 isAutoInitial : true,
30585 * @cfg {Boolean} isHorizontal defalut false
30587 isHorizontal : false,
30589 currentSize : null,
30595 bricks: null, //CompositeElement
30599 _isLayoutInited : false,
30601 // isAlternative : false, // only use for vertical layout...
30604 * @cfg {Number} alternativePadWidth padding below box..
30606 alternativePadWidth : 50,
30608 selectedBrick : [],
30610 getAutoCreate : function(){
30612 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30616 cls: 'blog-masonary-wrapper ' + this.cls,
30618 cls : 'mas-boxes masonary'
30625 getChildContainer: function( )
30627 if (this.boxesEl) {
30628 return this.boxesEl;
30631 this.boxesEl = this.el.select('.mas-boxes').first();
30633 return this.boxesEl;
30637 initEvents : function()
30641 if(this.isAutoInitial){
30642 Roo.log('hook children rendered');
30643 this.on('childrenrendered', function() {
30644 Roo.log('children rendered');
30650 initial : function()
30652 this.selectedBrick = [];
30654 this.currentSize = this.el.getBox(true);
30656 Roo.EventManager.onWindowResize(this.resize, this);
30658 if(!this.isAutoInitial){
30666 //this.layout.defer(500,this);
30670 resize : function()
30672 var cs = this.el.getBox(true);
30675 this.currentSize.width == cs.width &&
30676 this.currentSize.x == cs.x &&
30677 this.currentSize.height == cs.height &&
30678 this.currentSize.y == cs.y
30680 Roo.log("no change in with or X or Y");
30684 this.currentSize = cs;
30690 layout : function()
30692 this._resetLayout();
30694 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30696 this.layoutItems( isInstant );
30698 this._isLayoutInited = true;
30700 this.fireEvent('layout', this);
30704 _resetLayout : function()
30706 if(this.isHorizontal){
30707 this.horizontalMeasureColumns();
30711 this.verticalMeasureColumns();
30715 verticalMeasureColumns : function()
30717 this.getContainerWidth();
30719 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30720 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30724 var boxWidth = this.boxWidth + this.padWidth;
30726 if(this.containerWidth < this.boxWidth){
30727 boxWidth = this.containerWidth
30730 var containerWidth = this.containerWidth;
30732 var cols = Math.floor(containerWidth / boxWidth);
30734 this.cols = Math.max( cols, 1 );
30736 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30738 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30740 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30742 this.colWidth = boxWidth + avail - this.padWidth;
30744 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30745 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30748 horizontalMeasureColumns : function()
30750 this.getContainerWidth();
30752 var boxWidth = this.boxWidth;
30754 if(this.containerWidth < boxWidth){
30755 boxWidth = this.containerWidth;
30758 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30760 this.el.setHeight(boxWidth);
30764 getContainerWidth : function()
30766 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30769 layoutItems : function( isInstant )
30771 Roo.log(this.bricks);
30773 var items = Roo.apply([], this.bricks);
30775 if(this.isHorizontal){
30776 this._horizontalLayoutItems( items , isInstant );
30780 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30781 // this._verticalAlternativeLayoutItems( items , isInstant );
30785 this._verticalLayoutItems( items , isInstant );
30789 _verticalLayoutItems : function ( items , isInstant)
30791 if ( !items || !items.length ) {
30796 ['xs', 'xs', 'xs', 'tall'],
30797 ['xs', 'xs', 'tall'],
30798 ['xs', 'xs', 'sm'],
30799 ['xs', 'xs', 'xs'],
30805 ['sm', 'xs', 'xs'],
30809 ['tall', 'xs', 'xs', 'xs'],
30810 ['tall', 'xs', 'xs'],
30822 Roo.each(items, function(item, k){
30824 switch (item.size) {
30825 // these layouts take up a full box,
30836 boxes.push([item]);
30859 var filterPattern = function(box, length)
30867 var pattern = box.slice(0, length);
30871 Roo.each(pattern, function(i){
30872 format.push(i.size);
30875 Roo.each(standard, function(s){
30877 if(String(s) != String(format)){
30886 if(!match && length == 1){
30891 filterPattern(box, length - 1);
30895 queue.push(pattern);
30897 box = box.slice(length, box.length);
30899 filterPattern(box, 4);
30905 Roo.each(boxes, function(box, k){
30911 if(box.length == 1){
30916 filterPattern(box, 4);
30920 this._processVerticalLayoutQueue( queue, isInstant );
30924 // _verticalAlternativeLayoutItems : function( items , isInstant )
30926 // if ( !items || !items.length ) {
30930 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30934 _horizontalLayoutItems : function ( items , isInstant)
30936 if ( !items || !items.length || items.length < 3) {
30942 var eItems = items.slice(0, 3);
30944 items = items.slice(3, items.length);
30947 ['xs', 'xs', 'xs', 'wide'],
30948 ['xs', 'xs', 'wide'],
30949 ['xs', 'xs', 'sm'],
30950 ['xs', 'xs', 'xs'],
30956 ['sm', 'xs', 'xs'],
30960 ['wide', 'xs', 'xs', 'xs'],
30961 ['wide', 'xs', 'xs'],
30974 Roo.each(items, function(item, k){
30976 switch (item.size) {
30987 boxes.push([item]);
31011 var filterPattern = function(box, length)
31019 var pattern = box.slice(0, length);
31023 Roo.each(pattern, function(i){
31024 format.push(i.size);
31027 Roo.each(standard, function(s){
31029 if(String(s) != String(format)){
31038 if(!match && length == 1){
31043 filterPattern(box, length - 1);
31047 queue.push(pattern);
31049 box = box.slice(length, box.length);
31051 filterPattern(box, 4);
31057 Roo.each(boxes, function(box, k){
31063 if(box.length == 1){
31068 filterPattern(box, 4);
31075 var pos = this.el.getBox(true);
31079 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31081 var hit_end = false;
31083 Roo.each(queue, function(box){
31087 Roo.each(box, function(b){
31089 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31099 Roo.each(box, function(b){
31101 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31104 mx = Math.max(mx, b.x);
31108 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31112 Roo.each(box, function(b){
31114 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31128 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31131 /** Sets position of item in DOM
31132 * @param {Element} item
31133 * @param {Number} x - horizontal position
31134 * @param {Number} y - vertical position
31135 * @param {Boolean} isInstant - disables transitions
31137 _processVerticalLayoutQueue : function( queue, isInstant )
31139 var pos = this.el.getBox(true);
31144 for (var i = 0; i < this.cols; i++){
31148 Roo.each(queue, function(box, k){
31150 var col = k % this.cols;
31152 Roo.each(box, function(b,kk){
31154 b.el.position('absolute');
31156 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31157 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31159 if(b.size == 'md-left' || b.size == 'md-right'){
31160 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31161 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31164 b.el.setWidth(width);
31165 b.el.setHeight(height);
31167 b.el.select('iframe',true).setSize(width,height);
31171 for (var i = 0; i < this.cols; i++){
31173 if(maxY[i] < maxY[col]){
31178 col = Math.min(col, i);
31182 x = pos.x + col * (this.colWidth + this.padWidth);
31186 var positions = [];
31188 switch (box.length){
31190 positions = this.getVerticalOneBoxColPositions(x, y, box);
31193 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31196 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31199 positions = this.getVerticalFourBoxColPositions(x, y, box);
31205 Roo.each(box, function(b,kk){
31207 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31209 var sz = b.el.getSize();
31211 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31219 for (var i = 0; i < this.cols; i++){
31220 mY = Math.max(mY, maxY[i]);
31223 this.el.setHeight(mY - pos.y);
31227 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31229 // var pos = this.el.getBox(true);
31232 // var maxX = pos.right;
31234 // var maxHeight = 0;
31236 // Roo.each(items, function(item, k){
31240 // item.el.position('absolute');
31242 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31244 // item.el.setWidth(width);
31246 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31248 // item.el.setHeight(height);
31251 // item.el.setXY([x, y], isInstant ? false : true);
31253 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31256 // y = y + height + this.alternativePadWidth;
31258 // maxHeight = maxHeight + height + this.alternativePadWidth;
31262 // this.el.setHeight(maxHeight);
31266 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31268 var pos = this.el.getBox(true);
31273 var maxX = pos.right;
31275 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31277 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31279 Roo.each(queue, function(box, k){
31281 Roo.each(box, function(b, kk){
31283 b.el.position('absolute');
31285 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31286 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31288 if(b.size == 'md-left' || b.size == 'md-right'){
31289 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31290 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31293 b.el.setWidth(width);
31294 b.el.setHeight(height);
31302 var positions = [];
31304 switch (box.length){
31306 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31309 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31312 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31315 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31321 Roo.each(box, function(b,kk){
31323 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31325 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31333 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31335 Roo.each(eItems, function(b,k){
31337 b.size = (k == 0) ? 'sm' : 'xs';
31338 b.x = (k == 0) ? 2 : 1;
31339 b.y = (k == 0) ? 2 : 1;
31341 b.el.position('absolute');
31343 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31345 b.el.setWidth(width);
31347 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31349 b.el.setHeight(height);
31353 var positions = [];
31356 x : maxX - this.unitWidth * 2 - this.gutter,
31361 x : maxX - this.unitWidth,
31362 y : minY + (this.unitWidth + this.gutter) * 2
31366 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31370 Roo.each(eItems, function(b,k){
31372 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31378 getVerticalOneBoxColPositions : function(x, y, box)
31382 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31384 if(box[0].size == 'md-left'){
31388 if(box[0].size == 'md-right'){
31393 x : x + (this.unitWidth + this.gutter) * rand,
31400 getVerticalTwoBoxColPositions : function(x, y, box)
31404 if(box[0].size == 'xs'){
31408 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31412 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31426 x : x + (this.unitWidth + this.gutter) * 2,
31427 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31434 getVerticalThreeBoxColPositions : function(x, y, box)
31438 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31446 x : x + (this.unitWidth + this.gutter) * 1,
31451 x : x + (this.unitWidth + this.gutter) * 2,
31459 if(box[0].size == 'xs' && box[1].size == 'xs'){
31468 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31472 x : x + (this.unitWidth + this.gutter) * 1,
31486 x : x + (this.unitWidth + this.gutter) * 2,
31491 x : x + (this.unitWidth + this.gutter) * 2,
31492 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31499 getVerticalFourBoxColPositions : function(x, y, box)
31503 if(box[0].size == 'xs'){
31512 y : y + (this.unitHeight + this.gutter) * 1
31517 y : y + (this.unitHeight + this.gutter) * 2
31521 x : x + (this.unitWidth + this.gutter) * 1,
31535 x : x + (this.unitWidth + this.gutter) * 2,
31540 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31541 y : y + (this.unitHeight + this.gutter) * 1
31545 x : x + (this.unitWidth + this.gutter) * 2,
31546 y : y + (this.unitWidth + this.gutter) * 2
31553 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31557 if(box[0].size == 'md-left'){
31559 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31566 if(box[0].size == 'md-right'){
31568 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31569 y : minY + (this.unitWidth + this.gutter) * 1
31575 var rand = Math.floor(Math.random() * (4 - box[0].y));
31578 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31579 y : minY + (this.unitWidth + this.gutter) * rand
31586 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31590 if(box[0].size == 'xs'){
31593 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31598 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31599 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31607 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31612 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31613 y : minY + (this.unitWidth + this.gutter) * 2
31620 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31624 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31627 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31632 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31633 y : minY + (this.unitWidth + this.gutter) * 1
31637 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31638 y : minY + (this.unitWidth + this.gutter) * 2
31645 if(box[0].size == 'xs' && box[1].size == 'xs'){
31648 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31653 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31658 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31659 y : minY + (this.unitWidth + this.gutter) * 1
31667 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31672 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31673 y : minY + (this.unitWidth + this.gutter) * 2
31677 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31678 y : minY + (this.unitWidth + this.gutter) * 2
31685 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31689 if(box[0].size == 'xs'){
31692 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31697 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31702 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),
31707 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31708 y : minY + (this.unitWidth + this.gutter) * 1
31716 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31721 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31722 y : minY + (this.unitWidth + this.gutter) * 2
31726 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31727 y : minY + (this.unitWidth + this.gutter) * 2
31731 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),
31732 y : minY + (this.unitWidth + this.gutter) * 2
31740 * remove a Masonry Brick
31741 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31743 removeBrick : function(brick_id)
31749 for (var i = 0; i<this.bricks.length; i++) {
31750 if (this.bricks[i].id == brick_id) {
31751 this.bricks.splice(i,1);
31752 this.el.dom.removeChild(Roo.get(brick_id).dom);
31759 * adds a Masonry Brick
31760 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31762 addBrick : function(cfg)
31764 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31765 //this.register(cn);
31766 cn.parentId = this.id;
31767 cn.onRender(this.el, null);
31772 * register a Masonry Brick
31773 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31776 register : function(brick)
31778 this.bricks.push(brick);
31779 brick.masonryId = this.id;
31783 * clear all the Masonry Brick
31785 clearAll : function()
31788 //this.getChildContainer().dom.innerHTML = "";
31789 this.el.dom.innerHTML = '';
31792 getSelected : function()
31794 if (!this.selectedBrick) {
31798 return this.selectedBrick;
31802 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31806 * register a Masonry Layout
31807 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31810 register : function(layout)
31812 this.groups[layout.id] = layout;
31815 * fetch a Masonry Layout based on the masonry layout ID
31816 * @param {string} the masonry layout to add
31817 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31820 get: function(layout_id) {
31821 if (typeof(this.groups[layout_id]) == 'undefined') {
31824 return this.groups[layout_id] ;
31836 * http://masonry.desandro.com
31838 * The idea is to render all the bricks based on vertical width...
31840 * The original code extends 'outlayer' - we might need to use that....
31846 * @class Roo.bootstrap.LayoutMasonryAuto
31847 * @extends Roo.bootstrap.Component
31848 * Bootstrap Layout Masonry class
31851 * Create a new Element
31852 * @param {Object} config The config object
31855 Roo.bootstrap.LayoutMasonryAuto = function(config){
31856 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31859 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31862 * @cfg {Boolean} isFitWidth - resize the width..
31864 isFitWidth : false, // options..
31866 * @cfg {Boolean} isOriginLeft = left align?
31868 isOriginLeft : true,
31870 * @cfg {Boolean} isOriginTop = top align?
31872 isOriginTop : false,
31874 * @cfg {Boolean} isLayoutInstant = no animation?
31876 isLayoutInstant : false, // needed?
31878 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31880 isResizingContainer : true,
31882 * @cfg {Number} columnWidth width of the columns
31888 * @cfg {Number} maxCols maximum number of columns
31893 * @cfg {Number} padHeight padding below box..
31899 * @cfg {Boolean} isAutoInitial defalut true
31902 isAutoInitial : true,
31908 initialColumnWidth : 0,
31909 currentSize : null,
31911 colYs : null, // array.
31918 bricks: null, //CompositeElement
31919 cols : 0, // array?
31920 // element : null, // wrapped now this.el
31921 _isLayoutInited : null,
31924 getAutoCreate : function(){
31928 cls: 'blog-masonary-wrapper ' + this.cls,
31930 cls : 'mas-boxes masonary'
31937 getChildContainer: function( )
31939 if (this.boxesEl) {
31940 return this.boxesEl;
31943 this.boxesEl = this.el.select('.mas-boxes').first();
31945 return this.boxesEl;
31949 initEvents : function()
31953 if(this.isAutoInitial){
31954 Roo.log('hook children rendered');
31955 this.on('childrenrendered', function() {
31956 Roo.log('children rendered');
31963 initial : function()
31965 this.reloadItems();
31967 this.currentSize = this.el.getBox(true);
31969 /// was window resize... - let's see if this works..
31970 Roo.EventManager.onWindowResize(this.resize, this);
31972 if(!this.isAutoInitial){
31977 this.layout.defer(500,this);
31980 reloadItems: function()
31982 this.bricks = this.el.select('.masonry-brick', true);
31984 this.bricks.each(function(b) {
31985 //Roo.log(b.getSize());
31986 if (!b.attr('originalwidth')) {
31987 b.attr('originalwidth', b.getSize().width);
31992 Roo.log(this.bricks.elements.length);
31995 resize : function()
31998 var cs = this.el.getBox(true);
32000 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32001 Roo.log("no change in with or X");
32004 this.currentSize = cs;
32008 layout : function()
32011 this._resetLayout();
32012 //this._manageStamps();
32014 // don't animate first layout
32015 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32016 this.layoutItems( isInstant );
32018 // flag for initalized
32019 this._isLayoutInited = true;
32022 layoutItems : function( isInstant )
32024 //var items = this._getItemsForLayout( this.items );
32025 // original code supports filtering layout items.. we just ignore it..
32027 this._layoutItems( this.bricks , isInstant );
32029 this._postLayout();
32031 _layoutItems : function ( items , isInstant)
32033 //this.fireEvent( 'layout', this, items );
32036 if ( !items || !items.elements.length ) {
32037 // no items, emit event with empty array
32042 items.each(function(item) {
32043 Roo.log("layout item");
32045 // get x/y object from method
32046 var position = this._getItemLayoutPosition( item );
32048 position.item = item;
32049 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32050 queue.push( position );
32053 this._processLayoutQueue( queue );
32055 /** Sets position of item in DOM
32056 * @param {Element} item
32057 * @param {Number} x - horizontal position
32058 * @param {Number} y - vertical position
32059 * @param {Boolean} isInstant - disables transitions
32061 _processLayoutQueue : function( queue )
32063 for ( var i=0, len = queue.length; i < len; i++ ) {
32064 var obj = queue[i];
32065 obj.item.position('absolute');
32066 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32072 * Any logic you want to do after each layout,
32073 * i.e. size the container
32075 _postLayout : function()
32077 this.resizeContainer();
32080 resizeContainer : function()
32082 if ( !this.isResizingContainer ) {
32085 var size = this._getContainerSize();
32087 this.el.setSize(size.width,size.height);
32088 this.boxesEl.setSize(size.width,size.height);
32094 _resetLayout : function()
32096 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32097 this.colWidth = this.el.getWidth();
32098 //this.gutter = this.el.getWidth();
32100 this.measureColumns();
32106 this.colYs.push( 0 );
32112 measureColumns : function()
32114 this.getContainerWidth();
32115 // if columnWidth is 0, default to outerWidth of first item
32116 if ( !this.columnWidth ) {
32117 var firstItem = this.bricks.first();
32118 Roo.log(firstItem);
32119 this.columnWidth = this.containerWidth;
32120 if (firstItem && firstItem.attr('originalwidth') ) {
32121 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32123 // columnWidth fall back to item of first element
32124 Roo.log("set column width?");
32125 this.initialColumnWidth = this.columnWidth ;
32127 // if first elem has no width, default to size of container
32132 if (this.initialColumnWidth) {
32133 this.columnWidth = this.initialColumnWidth;
32138 // column width is fixed at the top - however if container width get's smaller we should
32141 // this bit calcs how man columns..
32143 var columnWidth = this.columnWidth += this.gutter;
32145 // calculate columns
32146 var containerWidth = this.containerWidth + this.gutter;
32148 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32149 // fix rounding errors, typically with gutters
32150 var excess = columnWidth - containerWidth % columnWidth;
32153 // if overshoot is less than a pixel, round up, otherwise floor it
32154 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32155 cols = Math[ mathMethod ]( cols );
32156 this.cols = Math.max( cols, 1 );
32157 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32159 // padding positioning..
32160 var totalColWidth = this.cols * this.columnWidth;
32161 var padavail = this.containerWidth - totalColWidth;
32162 // so for 2 columns - we need 3 'pads'
32164 var padNeeded = (1+this.cols) * this.padWidth;
32166 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32168 this.columnWidth += padExtra
32169 //this.padWidth = Math.floor(padavail / ( this.cols));
32171 // adjust colum width so that padding is fixed??
32173 // we have 3 columns ... total = width * 3
32174 // we have X left over... that should be used by
32176 //if (this.expandC) {
32184 getContainerWidth : function()
32186 /* // container is parent if fit width
32187 var container = this.isFitWidth ? this.element.parentNode : this.element;
32188 // check that this.size and size are there
32189 // IE8 triggers resize on body size change, so they might not be
32191 var size = getSize( container ); //FIXME
32192 this.containerWidth = size && size.innerWidth; //FIXME
32195 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32199 _getItemLayoutPosition : function( item ) // what is item?
32201 // we resize the item to our columnWidth..
32203 item.setWidth(this.columnWidth);
32204 item.autoBoxAdjust = false;
32206 var sz = item.getSize();
32208 // how many columns does this brick span
32209 var remainder = this.containerWidth % this.columnWidth;
32211 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32212 // round if off by 1 pixel, otherwise use ceil
32213 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32214 colSpan = Math.min( colSpan, this.cols );
32216 // normally this should be '1' as we dont' currently allow multi width columns..
32218 var colGroup = this._getColGroup( colSpan );
32219 // get the minimum Y value from the columns
32220 var minimumY = Math.min.apply( Math, colGroup );
32221 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32223 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32225 // position the brick
32227 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32228 y: this.currentSize.y + minimumY + this.padHeight
32232 // apply setHeight to necessary columns
32233 var setHeight = minimumY + sz.height + this.padHeight;
32234 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32236 var setSpan = this.cols + 1 - colGroup.length;
32237 for ( var i = 0; i < setSpan; i++ ) {
32238 this.colYs[ shortColIndex + i ] = setHeight ;
32245 * @param {Number} colSpan - number of columns the element spans
32246 * @returns {Array} colGroup
32248 _getColGroup : function( colSpan )
32250 if ( colSpan < 2 ) {
32251 // if brick spans only one column, use all the column Ys
32256 // how many different places could this brick fit horizontally
32257 var groupCount = this.cols + 1 - colSpan;
32258 // for each group potential horizontal position
32259 for ( var i = 0; i < groupCount; i++ ) {
32260 // make an array of colY values for that one group
32261 var groupColYs = this.colYs.slice( i, i + colSpan );
32262 // and get the max value of the array
32263 colGroup[i] = Math.max.apply( Math, groupColYs );
32268 _manageStamp : function( stamp )
32270 var stampSize = stamp.getSize();
32271 var offset = stamp.getBox();
32272 // get the columns that this stamp affects
32273 var firstX = this.isOriginLeft ? offset.x : offset.right;
32274 var lastX = firstX + stampSize.width;
32275 var firstCol = Math.floor( firstX / this.columnWidth );
32276 firstCol = Math.max( 0, firstCol );
32278 var lastCol = Math.floor( lastX / this.columnWidth );
32279 // lastCol should not go over if multiple of columnWidth #425
32280 lastCol -= lastX % this.columnWidth ? 0 : 1;
32281 lastCol = Math.min( this.cols - 1, lastCol );
32283 // set colYs to bottom of the stamp
32284 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32287 for ( var i = firstCol; i <= lastCol; i++ ) {
32288 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32293 _getContainerSize : function()
32295 this.maxY = Math.max.apply( Math, this.colYs );
32300 if ( this.isFitWidth ) {
32301 size.width = this._getContainerFitWidth();
32307 _getContainerFitWidth : function()
32309 var unusedCols = 0;
32310 // count unused columns
32313 if ( this.colYs[i] !== 0 ) {
32318 // fit container to columns that have been used
32319 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32322 needsResizeLayout : function()
32324 var previousWidth = this.containerWidth;
32325 this.getContainerWidth();
32326 return previousWidth !== this.containerWidth;
32341 * @class Roo.bootstrap.MasonryBrick
32342 * @extends Roo.bootstrap.Component
32343 * Bootstrap MasonryBrick class
32346 * Create a new MasonryBrick
32347 * @param {Object} config The config object
32350 Roo.bootstrap.MasonryBrick = function(config){
32352 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32354 Roo.bootstrap.MasonryBrick.register(this);
32360 * When a MasonryBrick is clcik
32361 * @param {Roo.bootstrap.MasonryBrick} this
32362 * @param {Roo.EventObject} e
32368 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32371 * @cfg {String} title
32375 * @cfg {String} html
32379 * @cfg {String} bgimage
32383 * @cfg {String} videourl
32387 * @cfg {String} cls
32391 * @cfg {String} href
32395 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32400 * @cfg {String} placetitle (center|bottom)
32405 * @cfg {Boolean} isFitContainer defalut true
32407 isFitContainer : true,
32410 * @cfg {Boolean} preventDefault defalut false
32412 preventDefault : false,
32415 * @cfg {Boolean} inverse defalut false
32417 maskInverse : false,
32419 getAutoCreate : function()
32421 if(!this.isFitContainer){
32422 return this.getSplitAutoCreate();
32425 var cls = 'masonry-brick masonry-brick-full';
32427 if(this.href.length){
32428 cls += ' masonry-brick-link';
32431 if(this.bgimage.length){
32432 cls += ' masonry-brick-image';
32435 if(this.maskInverse){
32436 cls += ' mask-inverse';
32439 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32440 cls += ' enable-mask';
32444 cls += ' masonry-' + this.size + '-brick';
32447 if(this.placetitle.length){
32449 switch (this.placetitle) {
32451 cls += ' masonry-center-title';
32454 cls += ' masonry-bottom-title';
32461 if(!this.html.length && !this.bgimage.length){
32462 cls += ' masonry-center-title';
32465 if(!this.html.length && this.bgimage.length){
32466 cls += ' masonry-bottom-title';
32471 cls += ' ' + this.cls;
32475 tag: (this.href.length) ? 'a' : 'div',
32480 cls: 'masonry-brick-mask'
32484 cls: 'masonry-brick-paragraph',
32490 if(this.href.length){
32491 cfg.href = this.href;
32494 var cn = cfg.cn[1].cn;
32496 if(this.title.length){
32499 cls: 'masonry-brick-title',
32504 if(this.html.length){
32507 cls: 'masonry-brick-text',
32512 if (!this.title.length && !this.html.length) {
32513 cfg.cn[1].cls += ' hide';
32516 if(this.bgimage.length){
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?
32529 cls: 'masonry-brick-image-view',
32532 allowfullscreen : true
32540 getSplitAutoCreate : function()
32542 var cls = 'masonry-brick masonry-brick-split';
32544 if(this.href.length){
32545 cls += ' masonry-brick-link';
32548 if(this.bgimage.length){
32549 cls += ' masonry-brick-image';
32553 cls += ' masonry-' + this.size + '-brick';
32556 switch (this.placetitle) {
32558 cls += ' masonry-center-title';
32561 cls += ' masonry-bottom-title';
32564 if(!this.bgimage.length){
32565 cls += ' masonry-center-title';
32568 if(this.bgimage.length){
32569 cls += ' masonry-bottom-title';
32575 cls += ' ' + this.cls;
32579 tag: (this.href.length) ? 'a' : 'div',
32584 cls: 'masonry-brick-split-head',
32588 cls: 'masonry-brick-paragraph',
32595 cls: 'masonry-brick-split-body',
32601 if(this.href.length){
32602 cfg.href = this.href;
32605 if(this.title.length){
32606 cfg.cn[0].cn[0].cn.push({
32608 cls: 'masonry-brick-title',
32613 if(this.html.length){
32614 cfg.cn[1].cn.push({
32616 cls: 'masonry-brick-text',
32621 if(this.bgimage.length){
32622 cfg.cn[0].cn.push({
32624 cls: 'masonry-brick-image-view',
32629 if(this.videourl.length){
32630 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32631 // youtube support only?
32632 cfg.cn[0].cn.cn.push({
32634 cls: 'masonry-brick-image-view',
32637 allowfullscreen : true
32644 initEvents: function()
32646 switch (this.size) {
32679 this.el.on('touchstart', this.onTouchStart, this);
32680 this.el.on('touchmove', this.onTouchMove, this);
32681 this.el.on('touchend', this.onTouchEnd, this);
32682 this.el.on('contextmenu', this.onContextMenu, this);
32684 this.el.on('mouseenter' ,this.enter, this);
32685 this.el.on('mouseleave', this.leave, this);
32686 this.el.on('click', this.onClick, this);
32689 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32690 this.parent().bricks.push(this);
32695 onClick: function(e, el)
32697 var time = this.endTimer - this.startTimer;
32698 // Roo.log(e.preventDefault());
32701 e.preventDefault();
32706 if(!this.preventDefault){
32710 e.preventDefault();
32712 if (this.activcClass != '') {
32713 this.selectBrick();
32716 this.fireEvent('click', this);
32719 enter: function(e, el)
32721 e.preventDefault();
32723 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32727 if(this.bgimage.length && this.html.length){
32728 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32732 leave: function(e, el)
32734 e.preventDefault();
32736 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32740 if(this.bgimage.length && this.html.length){
32741 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32745 onTouchStart: function(e, el)
32747 // e.preventDefault();
32749 this.touchmoved = false;
32751 if(!this.isFitContainer){
32755 if(!this.bgimage.length || !this.html.length){
32759 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32761 this.timer = new Date().getTime();
32765 onTouchMove: function(e, el)
32767 this.touchmoved = true;
32770 onContextMenu : function(e,el)
32772 e.preventDefault();
32773 e.stopPropagation();
32777 onTouchEnd: function(e, el)
32779 // e.preventDefault();
32781 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32788 if(!this.bgimage.length || !this.html.length){
32790 if(this.href.length){
32791 window.location.href = this.href;
32797 if(!this.isFitContainer){
32801 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32803 window.location.href = this.href;
32806 //selection on single brick only
32807 selectBrick : function() {
32809 if (!this.parentId) {
32813 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32814 var index = m.selectedBrick.indexOf(this.id);
32817 m.selectedBrick.splice(index,1);
32818 this.el.removeClass(this.activeClass);
32822 for(var i = 0; i < m.selectedBrick.length; i++) {
32823 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32824 b.el.removeClass(b.activeClass);
32827 m.selectedBrick = [];
32829 m.selectedBrick.push(this.id);
32830 this.el.addClass(this.activeClass);
32836 Roo.apply(Roo.bootstrap.MasonryBrick, {
32839 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32841 * register a Masonry Brick
32842 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32845 register : function(brick)
32847 //this.groups[brick.id] = brick;
32848 this.groups.add(brick.id, brick);
32851 * fetch a masonry brick based on the masonry brick ID
32852 * @param {string} the masonry brick to add
32853 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32856 get: function(brick_id)
32858 // if (typeof(this.groups[brick_id]) == 'undefined') {
32861 // return this.groups[brick_id] ;
32863 if(this.groups.key(brick_id)) {
32864 return this.groups.key(brick_id);
32882 * @class Roo.bootstrap.Brick
32883 * @extends Roo.bootstrap.Component
32884 * Bootstrap Brick class
32887 * Create a new Brick
32888 * @param {Object} config The config object
32891 Roo.bootstrap.Brick = function(config){
32892 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32898 * When a Brick is click
32899 * @param {Roo.bootstrap.Brick} this
32900 * @param {Roo.EventObject} e
32906 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32909 * @cfg {String} title
32913 * @cfg {String} html
32917 * @cfg {String} bgimage
32921 * @cfg {String} cls
32925 * @cfg {String} href
32929 * @cfg {String} video
32933 * @cfg {Boolean} square
32937 getAutoCreate : function()
32939 var cls = 'roo-brick';
32941 if(this.href.length){
32942 cls += ' roo-brick-link';
32945 if(this.bgimage.length){
32946 cls += ' roo-brick-image';
32949 if(!this.html.length && !this.bgimage.length){
32950 cls += ' roo-brick-center-title';
32953 if(!this.html.length && this.bgimage.length){
32954 cls += ' roo-brick-bottom-title';
32958 cls += ' ' + this.cls;
32962 tag: (this.href.length) ? 'a' : 'div',
32967 cls: 'roo-brick-paragraph',
32973 if(this.href.length){
32974 cfg.href = this.href;
32977 var cn = cfg.cn[0].cn;
32979 if(this.title.length){
32982 cls: 'roo-brick-title',
32987 if(this.html.length){
32990 cls: 'roo-brick-text',
32997 if(this.bgimage.length){
33000 cls: 'roo-brick-image-view',
33008 initEvents: function()
33010 if(this.title.length || this.html.length){
33011 this.el.on('mouseenter' ,this.enter, this);
33012 this.el.on('mouseleave', this.leave, this);
33015 Roo.EventManager.onWindowResize(this.resize, this);
33017 if(this.bgimage.length){
33018 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33019 this.imageEl.on('load', this.onImageLoad, this);
33026 onImageLoad : function()
33031 resize : function()
33033 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33035 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33037 if(this.bgimage.length){
33038 var image = this.el.select('.roo-brick-image-view', true).first();
33040 image.setWidth(paragraph.getWidth());
33043 image.setHeight(paragraph.getWidth());
33046 this.el.setHeight(image.getHeight());
33047 paragraph.setHeight(image.getHeight());
33053 enter: function(e, el)
33055 e.preventDefault();
33057 if(this.bgimage.length){
33058 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33059 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33063 leave: function(e, el)
33065 e.preventDefault();
33067 if(this.bgimage.length){
33068 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33069 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33084 * @class Roo.bootstrap.NumberField
33085 * @extends Roo.bootstrap.Input
33086 * Bootstrap NumberField class
33092 * Create a new NumberField
33093 * @param {Object} config The config object
33096 Roo.bootstrap.NumberField = function(config){
33097 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33100 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33103 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33105 allowDecimals : true,
33107 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33109 decimalSeparator : ".",
33111 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33113 decimalPrecision : 2,
33115 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33117 allowNegative : true,
33120 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33124 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33126 minValue : Number.NEGATIVE_INFINITY,
33128 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33130 maxValue : Number.MAX_VALUE,
33132 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33134 minText : "The minimum value for this field is {0}",
33136 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33138 maxText : "The maximum value for this field is {0}",
33140 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33141 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33143 nanText : "{0} is not a valid number",
33145 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
33149 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33151 thousandsDelimiter : false,
33153 * @cfg {String} valueAlign alignment of value
33155 valueAlign : "left",
33157 getAutoCreate : function()
33159 var hiddenInput = {
33163 cls: 'hidden-number-input'
33167 hiddenInput.name = this.name;
33172 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33174 this.name = hiddenInput.name;
33176 if(cfg.cn.length > 0) {
33177 cfg.cn.push(hiddenInput);
33184 initEvents : function()
33186 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33188 var allowed = "0123456789";
33190 if(this.allowDecimals){
33191 allowed += this.decimalSeparator;
33194 if(this.allowNegative){
33198 if(this.thousandsDelimiter) {
33202 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33204 var keyPress = function(e){
33206 var k = e.getKey();
33208 var c = e.getCharCode();
33211 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33212 allowed.indexOf(String.fromCharCode(c)) === -1
33218 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33222 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33227 this.el.on("keypress", keyPress, this);
33230 validateValue : function(value)
33233 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33237 var num = this.parseValue(value);
33240 this.markInvalid(String.format(this.nanText, value));
33244 if(num < this.minValue){
33245 this.markInvalid(String.format(this.minText, this.minValue));
33249 if(num > this.maxValue){
33250 this.markInvalid(String.format(this.maxText, this.maxValue));
33257 getValue : function()
33259 var v = this.hiddenEl().getValue();
33261 return this.fixPrecision(this.parseValue(v));
33264 parseValue : function(value)
33266 if(this.thousandsDelimiter) {
33268 r = new RegExp(",", "g");
33269 value = value.replace(r, "");
33272 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33273 return isNaN(value) ? '' : value;
33276 fixPrecision : function(value)
33278 if(this.thousandsDelimiter) {
33280 r = new RegExp(",", "g");
33281 value = value.replace(r, "");
33284 var nan = isNaN(value);
33286 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33287 return nan ? '' : value;
33289 return parseFloat(value).toFixed(this.decimalPrecision);
33292 setValue : function(v)
33294 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33300 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33302 this.inputEl().dom.value = (v == '') ? '' :
33303 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33305 if(!this.allowZero && v === '0') {
33306 this.hiddenEl().dom.value = '';
33307 this.inputEl().dom.value = '';
33314 decimalPrecisionFcn : function(v)
33316 return Math.floor(v);
33319 beforeBlur : function()
33325 var v = this.parseValue(this.getRawValue());
33332 hiddenEl : function()
33334 return this.el.select('input.hidden-number-input',true).first();
33346 * @class Roo.bootstrap.DocumentSlider
33347 * @extends Roo.bootstrap.Component
33348 * Bootstrap DocumentSlider class
33351 * Create a new DocumentViewer
33352 * @param {Object} config The config object
33355 Roo.bootstrap.DocumentSlider = function(config){
33356 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33363 * Fire after initEvent
33364 * @param {Roo.bootstrap.DocumentSlider} this
33369 * Fire after update
33370 * @param {Roo.bootstrap.DocumentSlider} this
33376 * @param {Roo.bootstrap.DocumentSlider} this
33382 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33388 getAutoCreate : function()
33392 cls : 'roo-document-slider',
33396 cls : 'roo-document-slider-header',
33400 cls : 'roo-document-slider-header-title'
33406 cls : 'roo-document-slider-body',
33410 cls : 'roo-document-slider-prev',
33414 cls : 'fa fa-chevron-left'
33420 cls : 'roo-document-slider-thumb',
33424 cls : 'roo-document-slider-image'
33430 cls : 'roo-document-slider-next',
33434 cls : 'fa fa-chevron-right'
33446 initEvents : function()
33448 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33449 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33451 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33452 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33454 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33455 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33457 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33458 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33460 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33461 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33463 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33464 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33466 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33467 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33469 this.thumbEl.on('click', this.onClick, this);
33471 this.prevIndicator.on('click', this.prev, this);
33473 this.nextIndicator.on('click', this.next, this);
33477 initial : function()
33479 if(this.files.length){
33480 this.indicator = 1;
33484 this.fireEvent('initial', this);
33487 update : function()
33489 this.imageEl.attr('src', this.files[this.indicator - 1]);
33491 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33493 this.prevIndicator.show();
33495 if(this.indicator == 1){
33496 this.prevIndicator.hide();
33499 this.nextIndicator.show();
33501 if(this.indicator == this.files.length){
33502 this.nextIndicator.hide();
33505 this.thumbEl.scrollTo('top');
33507 this.fireEvent('update', this);
33510 onClick : function(e)
33512 e.preventDefault();
33514 this.fireEvent('click', this);
33519 e.preventDefault();
33521 this.indicator = Math.max(1, this.indicator - 1);
33528 e.preventDefault();
33530 this.indicator = Math.min(this.files.length, this.indicator + 1);
33544 * @class Roo.bootstrap.RadioSet
33545 * @extends Roo.bootstrap.Input
33546 * Bootstrap RadioSet class
33547 * @cfg {String} indicatorpos (left|right) default left
33548 * @cfg {Boolean} inline (true|false) inline the element (default true)
33549 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33551 * Create a new RadioSet
33552 * @param {Object} config The config object
33555 Roo.bootstrap.RadioSet = function(config){
33557 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33561 Roo.bootstrap.RadioSet.register(this);
33566 * Fires when the element is checked or unchecked.
33567 * @param {Roo.bootstrap.RadioSet} this This radio
33568 * @param {Roo.bootstrap.Radio} item The checked item
33573 * Fires when the element is click.
33574 * @param {Roo.bootstrap.RadioSet} this This radio set
33575 * @param {Roo.bootstrap.Radio} item The checked item
33576 * @param {Roo.EventObject} e The event object
33583 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33591 indicatorpos : 'left',
33593 getAutoCreate : function()
33597 cls : 'roo-radio-set-label',
33601 html : this.fieldLabel
33606 if(this.indicatorpos == 'left'){
33609 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33610 tooltip : 'This field is required'
33615 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33616 tooltip : 'This field is required'
33622 cls : 'roo-radio-set-items'
33625 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33627 if (align === 'left' && this.fieldLabel.length) {
33630 cls : "roo-radio-set-right",
33636 if(this.labelWidth > 12){
33637 label.style = "width: " + this.labelWidth + 'px';
33640 if(this.labelWidth < 13 && this.labelmd == 0){
33641 this.labelmd = this.labelWidth;
33644 if(this.labellg > 0){
33645 label.cls += ' col-lg-' + this.labellg;
33646 items.cls += ' col-lg-' + (12 - this.labellg);
33649 if(this.labelmd > 0){
33650 label.cls += ' col-md-' + this.labelmd;
33651 items.cls += ' col-md-' + (12 - this.labelmd);
33654 if(this.labelsm > 0){
33655 label.cls += ' col-sm-' + this.labelsm;
33656 items.cls += ' col-sm-' + (12 - this.labelsm);
33659 if(this.labelxs > 0){
33660 label.cls += ' col-xs-' + this.labelxs;
33661 items.cls += ' col-xs-' + (12 - this.labelxs);
33667 cls : 'roo-radio-set',
33671 cls : 'roo-radio-set-input',
33674 value : this.value ? this.value : ''
33681 if(this.weight.length){
33682 cfg.cls += ' roo-radio-' + this.weight;
33686 cfg.cls += ' roo-radio-set-inline';
33690 ['xs','sm','md','lg'].map(function(size){
33691 if (settings[size]) {
33692 cfg.cls += ' col-' + size + '-' + settings[size];
33700 initEvents : function()
33702 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33703 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33705 if(!this.fieldLabel.length){
33706 this.labelEl.hide();
33709 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33710 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33712 this.indicatorEl().addClass('invisible');
33714 this.originalValue = this.getValue();
33718 inputEl: function ()
33720 return this.el.select('.roo-radio-set-input', true).first();
33723 getChildContainer : function()
33725 return this.itemsEl;
33728 register : function(item)
33730 this.radioes.push(item);
33734 validate : function()
33738 Roo.each(this.radioes, function(i){
33747 if(this.allowBlank) {
33751 if(this.disabled || valid){
33756 this.markInvalid();
33761 markValid : function()
33763 if(this.labelEl.isVisible(true)){
33764 this.indicatorEl().removeClass('visible');
33765 this.indicatorEl().addClass('invisible');
33768 this.el.removeClass([this.invalidClass, this.validClass]);
33769 this.el.addClass(this.validClass);
33771 this.fireEvent('valid', this);
33774 markInvalid : function(msg)
33776 if(this.allowBlank || this.disabled){
33780 if(this.labelEl.isVisible(true)){
33781 this.indicatorEl().removeClass('invisible');
33782 this.indicatorEl().addClass('visible');
33785 this.el.removeClass([this.invalidClass, this.validClass]);
33786 this.el.addClass(this.invalidClass);
33788 this.fireEvent('invalid', this, msg);
33792 setValue : function(v, suppressEvent)
33794 if(this.value === v){
33801 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33804 Roo.each(this.radioes, function(i){
33806 i.el.removeClass('checked');
33809 Roo.each(this.radioes, function(i){
33811 if(i.value === v || i.value.toString() === v.toString()){
33813 i.el.addClass('checked');
33815 if(suppressEvent !== true){
33816 this.fireEvent('check', this, i);
33827 clearInvalid : function(){
33829 if(!this.el || this.preventMark){
33833 this.el.removeClass([this.invalidClass]);
33835 this.fireEvent('valid', this);
33840 Roo.apply(Roo.bootstrap.RadioSet, {
33844 register : function(set)
33846 this.groups[set.name] = set;
33849 get: function(name)
33851 if (typeof(this.groups[name]) == 'undefined') {
33855 return this.groups[name] ;
33861 * Ext JS Library 1.1.1
33862 * Copyright(c) 2006-2007, Ext JS, LLC.
33864 * Originally Released Under LGPL - original licence link has changed is not relivant.
33867 * <script type="text/javascript">
33872 * @class Roo.bootstrap.SplitBar
33873 * @extends Roo.util.Observable
33874 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33878 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33879 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33880 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33881 split.minSize = 100;
33882 split.maxSize = 600;
33883 split.animate = true;
33884 split.on('moved', splitterMoved);
33887 * Create a new SplitBar
33888 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33889 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33890 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33891 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33892 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33893 position of the SplitBar).
33895 Roo.bootstrap.SplitBar = function(cfg){
33900 // dragElement : elm
33901 // resizingElement: el,
33903 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33904 // placement : Roo.bootstrap.SplitBar.LEFT ,
33905 // existingProxy ???
33908 this.el = Roo.get(cfg.dragElement, true);
33909 this.el.dom.unselectable = "on";
33911 this.resizingEl = Roo.get(cfg.resizingElement, true);
33915 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33916 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33919 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33922 * The minimum size of the resizing element. (Defaults to 0)
33928 * The maximum size of the resizing element. (Defaults to 2000)
33931 this.maxSize = 2000;
33934 * Whether to animate the transition to the new size
33937 this.animate = false;
33940 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33943 this.useShim = false;
33948 if(!cfg.existingProxy){
33950 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33952 this.proxy = Roo.get(cfg.existingProxy).dom;
33955 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33958 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33961 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33964 this.dragSpecs = {};
33967 * @private The adapter to use to positon and resize elements
33969 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33970 this.adapter.init(this);
33972 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33974 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33975 this.el.addClass("roo-splitbar-h");
33978 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33979 this.el.addClass("roo-splitbar-v");
33985 * Fires when the splitter is moved (alias for {@link #event-moved})
33986 * @param {Roo.bootstrap.SplitBar} this
33987 * @param {Number} newSize the new width or height
33992 * Fires when the splitter is moved
33993 * @param {Roo.bootstrap.SplitBar} this
33994 * @param {Number} newSize the new width or height
33998 * @event beforeresize
33999 * Fires before the splitter is dragged
34000 * @param {Roo.bootstrap.SplitBar} this
34002 "beforeresize" : true,
34004 "beforeapply" : true
34007 Roo.util.Observable.call(this);
34010 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34011 onStartProxyDrag : function(x, y){
34012 this.fireEvent("beforeresize", this);
34014 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34016 o.enableDisplayMode("block");
34017 // all splitbars share the same overlay
34018 Roo.bootstrap.SplitBar.prototype.overlay = o;
34020 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34021 this.overlay.show();
34022 Roo.get(this.proxy).setDisplayed("block");
34023 var size = this.adapter.getElementSize(this);
34024 this.activeMinSize = this.getMinimumSize();;
34025 this.activeMaxSize = this.getMaximumSize();;
34026 var c1 = size - this.activeMinSize;
34027 var c2 = Math.max(this.activeMaxSize - size, 0);
34028 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34029 this.dd.resetConstraints();
34030 this.dd.setXConstraint(
34031 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34032 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34034 this.dd.setYConstraint(0, 0);
34036 this.dd.resetConstraints();
34037 this.dd.setXConstraint(0, 0);
34038 this.dd.setYConstraint(
34039 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34040 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34043 this.dragSpecs.startSize = size;
34044 this.dragSpecs.startPoint = [x, y];
34045 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34049 * @private Called after the drag operation by the DDProxy
34051 onEndProxyDrag : function(e){
34052 Roo.get(this.proxy).setDisplayed(false);
34053 var endPoint = Roo.lib.Event.getXY(e);
34055 this.overlay.hide();
34058 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34059 newSize = this.dragSpecs.startSize +
34060 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34061 endPoint[0] - this.dragSpecs.startPoint[0] :
34062 this.dragSpecs.startPoint[0] - endPoint[0]
34065 newSize = this.dragSpecs.startSize +
34066 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34067 endPoint[1] - this.dragSpecs.startPoint[1] :
34068 this.dragSpecs.startPoint[1] - endPoint[1]
34071 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34072 if(newSize != this.dragSpecs.startSize){
34073 if(this.fireEvent('beforeapply', this, newSize) !== false){
34074 this.adapter.setElementSize(this, newSize);
34075 this.fireEvent("moved", this, newSize);
34076 this.fireEvent("resize", this, newSize);
34082 * Get the adapter this SplitBar uses
34083 * @return The adapter object
34085 getAdapter : function(){
34086 return this.adapter;
34090 * Set the adapter this SplitBar uses
34091 * @param {Object} adapter A SplitBar adapter object
34093 setAdapter : function(adapter){
34094 this.adapter = adapter;
34095 this.adapter.init(this);
34099 * Gets the minimum size for the resizing element
34100 * @return {Number} The minimum size
34102 getMinimumSize : function(){
34103 return this.minSize;
34107 * Sets the minimum size for the resizing element
34108 * @param {Number} minSize The minimum size
34110 setMinimumSize : function(minSize){
34111 this.minSize = minSize;
34115 * Gets the maximum size for the resizing element
34116 * @return {Number} The maximum size
34118 getMaximumSize : function(){
34119 return this.maxSize;
34123 * Sets the maximum size for the resizing element
34124 * @param {Number} maxSize The maximum size
34126 setMaximumSize : function(maxSize){
34127 this.maxSize = maxSize;
34131 * Sets the initialize size for the resizing element
34132 * @param {Number} size The initial size
34134 setCurrentSize : function(size){
34135 var oldAnimate = this.animate;
34136 this.animate = false;
34137 this.adapter.setElementSize(this, size);
34138 this.animate = oldAnimate;
34142 * Destroy this splitbar.
34143 * @param {Boolean} removeEl True to remove the element
34145 destroy : function(removeEl){
34147 this.shim.remove();
34150 this.proxy.parentNode.removeChild(this.proxy);
34158 * @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.
34160 Roo.bootstrap.SplitBar.createProxy = function(dir){
34161 var proxy = new Roo.Element(document.createElement("div"));
34162 proxy.unselectable();
34163 var cls = 'roo-splitbar-proxy';
34164 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34165 document.body.appendChild(proxy.dom);
34170 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34171 * Default Adapter. It assumes the splitter and resizing element are not positioned
34172 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34174 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34177 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34178 // do nothing for now
34179 init : function(s){
34183 * Called before drag operations to get the current size of the resizing element.
34184 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34186 getElementSize : function(s){
34187 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34188 return s.resizingEl.getWidth();
34190 return s.resizingEl.getHeight();
34195 * Called after drag operations to set the size of the resizing element.
34196 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34197 * @param {Number} newSize The new size to set
34198 * @param {Function} onComplete A function to be invoked when resizing is complete
34200 setElementSize : function(s, newSize, onComplete){
34201 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34203 s.resizingEl.setWidth(newSize);
34205 onComplete(s, newSize);
34208 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34213 s.resizingEl.setHeight(newSize);
34215 onComplete(s, newSize);
34218 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34225 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34226 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34227 * Adapter that moves the splitter element to align with the resized sizing element.
34228 * Used with an absolute positioned SplitBar.
34229 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34230 * document.body, make sure you assign an id to the body element.
34232 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34233 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34234 this.container = Roo.get(container);
34237 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34238 init : function(s){
34239 this.basic.init(s);
34242 getElementSize : function(s){
34243 return this.basic.getElementSize(s);
34246 setElementSize : function(s, newSize, onComplete){
34247 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34250 moveSplitter : function(s){
34251 var yes = Roo.bootstrap.SplitBar;
34252 switch(s.placement){
34254 s.el.setX(s.resizingEl.getRight());
34257 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34260 s.el.setY(s.resizingEl.getBottom());
34263 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34270 * Orientation constant - Create a vertical SplitBar
34274 Roo.bootstrap.SplitBar.VERTICAL = 1;
34277 * Orientation constant - Create a horizontal SplitBar
34281 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34284 * Placement constant - The resizing element is to the left of the splitter element
34288 Roo.bootstrap.SplitBar.LEFT = 1;
34291 * Placement constant - The resizing element is to the right of the splitter element
34295 Roo.bootstrap.SplitBar.RIGHT = 2;
34298 * Placement constant - The resizing element is positioned above the splitter element
34302 Roo.bootstrap.SplitBar.TOP = 3;
34305 * Placement constant - The resizing element is positioned under splitter element
34309 Roo.bootstrap.SplitBar.BOTTOM = 4;
34310 Roo.namespace("Roo.bootstrap.layout");/*
34312 * Ext JS Library 1.1.1
34313 * Copyright(c) 2006-2007, Ext JS, LLC.
34315 * Originally Released Under LGPL - original licence link has changed is not relivant.
34318 * <script type="text/javascript">
34322 * @class Roo.bootstrap.layout.Manager
34323 * @extends Roo.bootstrap.Component
34324 * Base class for layout managers.
34326 Roo.bootstrap.layout.Manager = function(config)
34328 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34334 /** false to disable window resize monitoring @type Boolean */
34335 this.monitorWindowResize = true;
34340 * Fires when a layout is performed.
34341 * @param {Roo.LayoutManager} this
34345 * @event regionresized
34346 * Fires when the user resizes a region.
34347 * @param {Roo.LayoutRegion} region The resized region
34348 * @param {Number} newSize The new size (width for east/west, height for north/south)
34350 "regionresized" : true,
34352 * @event regioncollapsed
34353 * Fires when a region is collapsed.
34354 * @param {Roo.LayoutRegion} region The collapsed region
34356 "regioncollapsed" : true,
34358 * @event regionexpanded
34359 * Fires when a region is expanded.
34360 * @param {Roo.LayoutRegion} region The expanded region
34362 "regionexpanded" : true
34364 this.updating = false;
34367 this.el = Roo.get(config.el);
34373 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34378 monitorWindowResize : true,
34384 onRender : function(ct, position)
34387 this.el = Roo.get(ct);
34390 //this.fireEvent('render',this);
34394 initEvents: function()
34398 // ie scrollbar fix
34399 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34400 document.body.scroll = "no";
34401 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34402 this.el.position('relative');
34404 this.id = this.el.id;
34405 this.el.addClass("roo-layout-container");
34406 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34407 if(this.el.dom != document.body ) {
34408 this.el.on('resize', this.layout,this);
34409 this.el.on('show', this.layout,this);
34415 * Returns true if this layout is currently being updated
34416 * @return {Boolean}
34418 isUpdating : function(){
34419 return this.updating;
34423 * Suspend the LayoutManager from doing auto-layouts while
34424 * making multiple add or remove calls
34426 beginUpdate : function(){
34427 this.updating = true;
34431 * Restore auto-layouts and optionally disable the manager from performing a layout
34432 * @param {Boolean} noLayout true to disable a layout update
34434 endUpdate : function(noLayout){
34435 this.updating = false;
34441 layout: function(){
34445 onRegionResized : function(region, newSize){
34446 this.fireEvent("regionresized", region, newSize);
34450 onRegionCollapsed : function(region){
34451 this.fireEvent("regioncollapsed", region);
34454 onRegionExpanded : function(region){
34455 this.fireEvent("regionexpanded", region);
34459 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34460 * performs box-model adjustments.
34461 * @return {Object} The size as an object {width: (the width), height: (the height)}
34463 getViewSize : function()
34466 if(this.el.dom != document.body){
34467 size = this.el.getSize();
34469 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34471 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34472 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34477 * Returns the Element this layout is bound to.
34478 * @return {Roo.Element}
34480 getEl : function(){
34485 * Returns the specified region.
34486 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34487 * @return {Roo.LayoutRegion}
34489 getRegion : function(target){
34490 return this.regions[target.toLowerCase()];
34493 onWindowResize : function(){
34494 if(this.monitorWindowResize){
34501 * Ext JS Library 1.1.1
34502 * Copyright(c) 2006-2007, Ext JS, LLC.
34504 * Originally Released Under LGPL - original licence link has changed is not relivant.
34507 * <script type="text/javascript">
34510 * @class Roo.bootstrap.layout.Border
34511 * @extends Roo.bootstrap.layout.Manager
34512 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34513 * please see: examples/bootstrap/nested.html<br><br>
34515 <b>The container the layout is rendered into can be either the body element or any other element.
34516 If it is not the body element, the container needs to either be an absolute positioned element,
34517 or you will need to add "position:relative" to the css of the container. You will also need to specify
34518 the container size if it is not the body element.</b>
34521 * Create a new Border
34522 * @param {Object} config Configuration options
34524 Roo.bootstrap.layout.Border = function(config){
34525 config = config || {};
34526 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34530 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34531 if(config[region]){
34532 config[region].region = region;
34533 this.addRegion(config[region]);
34539 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34541 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34543 * Creates and adds a new region if it doesn't already exist.
34544 * @param {String} target The target region key (north, south, east, west or center).
34545 * @param {Object} config The regions config object
34546 * @return {BorderLayoutRegion} The new region
34548 addRegion : function(config)
34550 if(!this.regions[config.region]){
34551 var r = this.factory(config);
34552 this.bindRegion(r);
34554 return this.regions[config.region];
34558 bindRegion : function(r){
34559 this.regions[r.config.region] = r;
34561 r.on("visibilitychange", this.layout, this);
34562 r.on("paneladded", this.layout, this);
34563 r.on("panelremoved", this.layout, this);
34564 r.on("invalidated", this.layout, this);
34565 r.on("resized", this.onRegionResized, this);
34566 r.on("collapsed", this.onRegionCollapsed, this);
34567 r.on("expanded", this.onRegionExpanded, this);
34571 * Performs a layout update.
34573 layout : function()
34575 if(this.updating) {
34579 // render all the rebions if they have not been done alreayd?
34580 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34581 if(this.regions[region] && !this.regions[region].bodyEl){
34582 this.regions[region].onRender(this.el)
34586 var size = this.getViewSize();
34587 var w = size.width;
34588 var h = size.height;
34593 //var x = 0, y = 0;
34595 var rs = this.regions;
34596 var north = rs["north"];
34597 var south = rs["south"];
34598 var west = rs["west"];
34599 var east = rs["east"];
34600 var center = rs["center"];
34601 //if(this.hideOnLayout){ // not supported anymore
34602 //c.el.setStyle("display", "none");
34604 if(north && north.isVisible()){
34605 var b = north.getBox();
34606 var m = north.getMargins();
34607 b.width = w - (m.left+m.right);
34610 centerY = b.height + b.y + m.bottom;
34611 centerH -= centerY;
34612 north.updateBox(this.safeBox(b));
34614 if(south && south.isVisible()){
34615 var b = south.getBox();
34616 var m = south.getMargins();
34617 b.width = w - (m.left+m.right);
34619 var totalHeight = (b.height + m.top + m.bottom);
34620 b.y = h - totalHeight + m.top;
34621 centerH -= totalHeight;
34622 south.updateBox(this.safeBox(b));
34624 if(west && west.isVisible()){
34625 var b = west.getBox();
34626 var m = west.getMargins();
34627 b.height = centerH - (m.top+m.bottom);
34629 b.y = centerY + m.top;
34630 var totalWidth = (b.width + m.left + m.right);
34631 centerX += totalWidth;
34632 centerW -= totalWidth;
34633 west.updateBox(this.safeBox(b));
34635 if(east && east.isVisible()){
34636 var b = east.getBox();
34637 var m = east.getMargins();
34638 b.height = centerH - (m.top+m.bottom);
34639 var totalWidth = (b.width + m.left + m.right);
34640 b.x = w - totalWidth + m.left;
34641 b.y = centerY + m.top;
34642 centerW -= totalWidth;
34643 east.updateBox(this.safeBox(b));
34646 var m = center.getMargins();
34648 x: centerX + m.left,
34649 y: centerY + m.top,
34650 width: centerW - (m.left+m.right),
34651 height: centerH - (m.top+m.bottom)
34653 //if(this.hideOnLayout){
34654 //center.el.setStyle("display", "block");
34656 center.updateBox(this.safeBox(centerBox));
34659 this.fireEvent("layout", this);
34663 safeBox : function(box){
34664 box.width = Math.max(0, box.width);
34665 box.height = Math.max(0, box.height);
34670 * Adds a ContentPanel (or subclass) to this layout.
34671 * @param {String} target The target region key (north, south, east, west or center).
34672 * @param {Roo.ContentPanel} panel The panel to add
34673 * @return {Roo.ContentPanel} The added panel
34675 add : function(target, panel){
34677 target = target.toLowerCase();
34678 return this.regions[target].add(panel);
34682 * Remove a ContentPanel (or subclass) to this layout.
34683 * @param {String} target The target region key (north, south, east, west or center).
34684 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34685 * @return {Roo.ContentPanel} The removed panel
34687 remove : function(target, panel){
34688 target = target.toLowerCase();
34689 return this.regions[target].remove(panel);
34693 * Searches all regions for a panel with the specified id
34694 * @param {String} panelId
34695 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34697 findPanel : function(panelId){
34698 var rs = this.regions;
34699 for(var target in rs){
34700 if(typeof rs[target] != "function"){
34701 var p = rs[target].getPanel(panelId);
34711 * Searches all regions for a panel with the specified id and activates (shows) it.
34712 * @param {String/ContentPanel} panelId The panels id or the panel itself
34713 * @return {Roo.ContentPanel} The shown panel or null
34715 showPanel : function(panelId) {
34716 var rs = this.regions;
34717 for(var target in rs){
34718 var r = rs[target];
34719 if(typeof r != "function"){
34720 if(r.hasPanel(panelId)){
34721 return r.showPanel(panelId);
34729 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34730 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34733 restoreState : function(provider){
34735 provider = Roo.state.Manager;
34737 var sm = new Roo.LayoutStateManager();
34738 sm.init(this, provider);
34744 * Adds a xtype elements to the layout.
34748 xtype : 'ContentPanel',
34755 xtype : 'NestedLayoutPanel',
34761 items : [ ... list of content panels or nested layout panels.. ]
34765 * @param {Object} cfg Xtype definition of item to add.
34767 addxtype : function(cfg)
34769 // basically accepts a pannel...
34770 // can accept a layout region..!?!?
34771 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34774 // theory? children can only be panels??
34776 //if (!cfg.xtype.match(/Panel$/)) {
34781 if (typeof(cfg.region) == 'undefined') {
34782 Roo.log("Failed to add Panel, region was not set");
34786 var region = cfg.region;
34792 xitems = cfg.items;
34799 case 'Content': // ContentPanel (el, cfg)
34800 case 'Scroll': // ContentPanel (el, cfg)
34802 cfg.autoCreate = true;
34803 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34805 // var el = this.el.createChild();
34806 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34809 this.add(region, ret);
34813 case 'TreePanel': // our new panel!
34814 cfg.el = this.el.createChild();
34815 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34816 this.add(region, ret);
34821 // create a new Layout (which is a Border Layout...
34823 var clayout = cfg.layout;
34824 clayout.el = this.el.createChild();
34825 clayout.items = clayout.items || [];
34829 // replace this exitems with the clayout ones..
34830 xitems = clayout.items;
34832 // force background off if it's in center...
34833 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34834 cfg.background = false;
34836 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34839 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34840 //console.log('adding nested layout panel ' + cfg.toSource());
34841 this.add(region, ret);
34842 nb = {}; /// find first...
34847 // needs grid and region
34849 //var el = this.getRegion(region).el.createChild();
34851 *var el = this.el.createChild();
34852 // create the grid first...
34853 cfg.grid.container = el;
34854 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34857 if (region == 'center' && this.active ) {
34858 cfg.background = false;
34861 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34863 this.add(region, ret);
34865 if (cfg.background) {
34866 // render grid on panel activation (if panel background)
34867 ret.on('activate', function(gp) {
34868 if (!gp.grid.rendered) {
34869 // gp.grid.render(el);
34873 // cfg.grid.render(el);
34879 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34880 // it was the old xcomponent building that caused this before.
34881 // espeically if border is the top element in the tree.
34891 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34893 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34894 this.add(region, ret);
34898 throw "Can not add '" + cfg.xtype + "' to Border";
34904 this.beginUpdate();
34908 Roo.each(xitems, function(i) {
34909 region = nb && i.region ? i.region : false;
34911 var add = ret.addxtype(i);
34914 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34915 if (!i.background) {
34916 abn[region] = nb[region] ;
34923 // make the last non-background panel active..
34924 //if (nb) { Roo.log(abn); }
34927 for(var r in abn) {
34928 region = this.getRegion(r);
34930 // tried using nb[r], but it does not work..
34932 region.showPanel(abn[r]);
34943 factory : function(cfg)
34946 var validRegions = Roo.bootstrap.layout.Border.regions;
34948 var target = cfg.region;
34951 var r = Roo.bootstrap.layout;
34955 return new r.North(cfg);
34957 return new r.South(cfg);
34959 return new r.East(cfg);
34961 return new r.West(cfg);
34963 return new r.Center(cfg);
34965 throw 'Layout region "'+target+'" not supported.';
34972 * Ext JS Library 1.1.1
34973 * Copyright(c) 2006-2007, Ext JS, LLC.
34975 * Originally Released Under LGPL - original licence link has changed is not relivant.
34978 * <script type="text/javascript">
34982 * @class Roo.bootstrap.layout.Basic
34983 * @extends Roo.util.Observable
34984 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34985 * and does not have a titlebar, tabs or any other features. All it does is size and position
34986 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34987 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34988 * @cfg {string} region the region that it inhabits..
34989 * @cfg {bool} skipConfig skip config?
34993 Roo.bootstrap.layout.Basic = function(config){
34995 this.mgr = config.mgr;
34997 this.position = config.region;
34999 var skipConfig = config.skipConfig;
35003 * @scope Roo.BasicLayoutRegion
35007 * @event beforeremove
35008 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35009 * @param {Roo.LayoutRegion} this
35010 * @param {Roo.ContentPanel} panel The panel
35011 * @param {Object} e The cancel event object
35013 "beforeremove" : true,
35015 * @event invalidated
35016 * Fires when the layout for this region is changed.
35017 * @param {Roo.LayoutRegion} this
35019 "invalidated" : true,
35021 * @event visibilitychange
35022 * Fires when this region is shown or hidden
35023 * @param {Roo.LayoutRegion} this
35024 * @param {Boolean} visibility true or false
35026 "visibilitychange" : true,
35028 * @event paneladded
35029 * Fires when a panel is added.
35030 * @param {Roo.LayoutRegion} this
35031 * @param {Roo.ContentPanel} panel The panel
35033 "paneladded" : true,
35035 * @event panelremoved
35036 * Fires when a panel is removed.
35037 * @param {Roo.LayoutRegion} this
35038 * @param {Roo.ContentPanel} panel The panel
35040 "panelremoved" : true,
35042 * @event beforecollapse
35043 * Fires when this region before collapse.
35044 * @param {Roo.LayoutRegion} this
35046 "beforecollapse" : true,
35049 * Fires when this region is collapsed.
35050 * @param {Roo.LayoutRegion} this
35052 "collapsed" : true,
35055 * Fires when this region is expanded.
35056 * @param {Roo.LayoutRegion} this
35061 * Fires when this region is slid into view.
35062 * @param {Roo.LayoutRegion} this
35064 "slideshow" : true,
35067 * Fires when this region slides out of view.
35068 * @param {Roo.LayoutRegion} this
35070 "slidehide" : true,
35072 * @event panelactivated
35073 * Fires when a panel is activated.
35074 * @param {Roo.LayoutRegion} this
35075 * @param {Roo.ContentPanel} panel The activated panel
35077 "panelactivated" : true,
35080 * Fires when the user resizes this region.
35081 * @param {Roo.LayoutRegion} this
35082 * @param {Number} newSize The new size (width for east/west, height for north/south)
35086 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35087 this.panels = new Roo.util.MixedCollection();
35088 this.panels.getKey = this.getPanelId.createDelegate(this);
35090 this.activePanel = null;
35091 // ensure listeners are added...
35093 if (config.listeners || config.events) {
35094 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35095 listeners : config.listeners || {},
35096 events : config.events || {}
35100 if(skipConfig !== true){
35101 this.applyConfig(config);
35105 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35107 getPanelId : function(p){
35111 applyConfig : function(config){
35112 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35113 this.config = config;
35118 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35119 * the width, for horizontal (north, south) the height.
35120 * @param {Number} newSize The new width or height
35122 resizeTo : function(newSize){
35123 var el = this.el ? this.el :
35124 (this.activePanel ? this.activePanel.getEl() : null);
35126 switch(this.position){
35129 el.setWidth(newSize);
35130 this.fireEvent("resized", this, newSize);
35134 el.setHeight(newSize);
35135 this.fireEvent("resized", this, newSize);
35141 getBox : function(){
35142 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35145 getMargins : function(){
35146 return this.margins;
35149 updateBox : function(box){
35151 var el = this.activePanel.getEl();
35152 el.dom.style.left = box.x + "px";
35153 el.dom.style.top = box.y + "px";
35154 this.activePanel.setSize(box.width, box.height);
35158 * Returns the container element for this region.
35159 * @return {Roo.Element}
35161 getEl : function(){
35162 return this.activePanel;
35166 * Returns true if this region is currently visible.
35167 * @return {Boolean}
35169 isVisible : function(){
35170 return this.activePanel ? true : false;
35173 setActivePanel : function(panel){
35174 panel = this.getPanel(panel);
35175 if(this.activePanel && this.activePanel != panel){
35176 this.activePanel.setActiveState(false);
35177 this.activePanel.getEl().setLeftTop(-10000,-10000);
35179 this.activePanel = panel;
35180 panel.setActiveState(true);
35182 panel.setSize(this.box.width, this.box.height);
35184 this.fireEvent("panelactivated", this, panel);
35185 this.fireEvent("invalidated");
35189 * Show the specified panel.
35190 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35191 * @return {Roo.ContentPanel} The shown panel or null
35193 showPanel : function(panel){
35194 panel = this.getPanel(panel);
35196 this.setActivePanel(panel);
35202 * Get the active panel for this region.
35203 * @return {Roo.ContentPanel} The active panel or null
35205 getActivePanel : function(){
35206 return this.activePanel;
35210 * Add the passed ContentPanel(s)
35211 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35212 * @return {Roo.ContentPanel} The panel added (if only one was added)
35214 add : function(panel){
35215 if(arguments.length > 1){
35216 for(var i = 0, len = arguments.length; i < len; i++) {
35217 this.add(arguments[i]);
35221 if(this.hasPanel(panel)){
35222 this.showPanel(panel);
35225 var el = panel.getEl();
35226 if(el.dom.parentNode != this.mgr.el.dom){
35227 this.mgr.el.dom.appendChild(el.dom);
35229 if(panel.setRegion){
35230 panel.setRegion(this);
35232 this.panels.add(panel);
35233 el.setStyle("position", "absolute");
35234 if(!panel.background){
35235 this.setActivePanel(panel);
35236 if(this.config.initialSize && this.panels.getCount()==1){
35237 this.resizeTo(this.config.initialSize);
35240 this.fireEvent("paneladded", this, panel);
35245 * Returns true if the panel is in this region.
35246 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35247 * @return {Boolean}
35249 hasPanel : function(panel){
35250 if(typeof panel == "object"){ // must be panel obj
35251 panel = panel.getId();
35253 return this.getPanel(panel) ? true : false;
35257 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35258 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35259 * @param {Boolean} preservePanel Overrides the config preservePanel option
35260 * @return {Roo.ContentPanel} The panel that was removed
35262 remove : function(panel, preservePanel){
35263 panel = this.getPanel(panel);
35268 this.fireEvent("beforeremove", this, panel, e);
35269 if(e.cancel === true){
35272 var panelId = panel.getId();
35273 this.panels.removeKey(panelId);
35278 * Returns the panel specified or null if it's not in this region.
35279 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35280 * @return {Roo.ContentPanel}
35282 getPanel : function(id){
35283 if(typeof id == "object"){ // must be panel obj
35286 return this.panels.get(id);
35290 * Returns this regions position (north/south/east/west/center).
35293 getPosition: function(){
35294 return this.position;
35298 * Ext JS Library 1.1.1
35299 * Copyright(c) 2006-2007, Ext JS, LLC.
35301 * Originally Released Under LGPL - original licence link has changed is not relivant.
35304 * <script type="text/javascript">
35308 * @class Roo.bootstrap.layout.Region
35309 * @extends Roo.bootstrap.layout.Basic
35310 * This class represents a region in a layout manager.
35312 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35313 * @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})
35314 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35315 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35316 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35317 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35318 * @cfg {String} title The title for the region (overrides panel titles)
35319 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35320 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35321 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35322 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35323 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35324 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35325 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35326 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35327 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35328 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35330 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35331 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35332 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35333 * @cfg {Number} width For East/West panels
35334 * @cfg {Number} height For North/South panels
35335 * @cfg {Boolean} split To show the splitter
35336 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35338 * @cfg {string} cls Extra CSS classes to add to region
35340 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35341 * @cfg {string} region the region that it inhabits..
35344 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35345 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35347 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35348 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35349 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35351 Roo.bootstrap.layout.Region = function(config)
35353 this.applyConfig(config);
35355 var mgr = config.mgr;
35356 var pos = config.region;
35357 config.skipConfig = true;
35358 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35361 this.onRender(mgr.el);
35364 this.visible = true;
35365 this.collapsed = false;
35366 this.unrendered_panels = [];
35369 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35371 position: '', // set by wrapper (eg. north/south etc..)
35372 unrendered_panels : null, // unrendered panels.
35373 createBody : function(){
35374 /** This region's body element
35375 * @type Roo.Element */
35376 this.bodyEl = this.el.createChild({
35378 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35382 onRender: function(ctr, pos)
35384 var dh = Roo.DomHelper;
35385 /** This region's container element
35386 * @type Roo.Element */
35387 this.el = dh.append(ctr.dom, {
35389 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35391 /** This region's title element
35392 * @type Roo.Element */
35394 this.titleEl = dh.append(this.el.dom,
35397 unselectable: "on",
35398 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35400 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35401 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35404 this.titleEl.enableDisplayMode();
35405 /** This region's title text element
35406 * @type HTMLElement */
35407 this.titleTextEl = this.titleEl.dom.firstChild;
35408 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35410 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35411 this.closeBtn.enableDisplayMode();
35412 this.closeBtn.on("click", this.closeClicked, this);
35413 this.closeBtn.hide();
35415 this.createBody(this.config);
35416 if(this.config.hideWhenEmpty){
35418 this.on("paneladded", this.validateVisibility, this);
35419 this.on("panelremoved", this.validateVisibility, this);
35421 if(this.autoScroll){
35422 this.bodyEl.setStyle("overflow", "auto");
35424 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35426 //if(c.titlebar !== false){
35427 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35428 this.titleEl.hide();
35430 this.titleEl.show();
35431 if(this.config.title){
35432 this.titleTextEl.innerHTML = this.config.title;
35436 if(this.config.collapsed){
35437 this.collapse(true);
35439 if(this.config.hidden){
35443 if (this.unrendered_panels && this.unrendered_panels.length) {
35444 for (var i =0;i< this.unrendered_panels.length; i++) {
35445 this.add(this.unrendered_panels[i]);
35447 this.unrendered_panels = null;
35453 applyConfig : function(c)
35456 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35457 var dh = Roo.DomHelper;
35458 if(c.titlebar !== false){
35459 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35460 this.collapseBtn.on("click", this.collapse, this);
35461 this.collapseBtn.enableDisplayMode();
35463 if(c.showPin === true || this.showPin){
35464 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35465 this.stickBtn.enableDisplayMode();
35466 this.stickBtn.on("click", this.expand, this);
35467 this.stickBtn.hide();
35472 /** This region's collapsed element
35473 * @type Roo.Element */
35476 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35477 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35480 if(c.floatable !== false){
35481 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35482 this.collapsedEl.on("click", this.collapseClick, this);
35485 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35486 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35487 id: "message", unselectable: "on", style:{"float":"left"}});
35488 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35490 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35491 this.expandBtn.on("click", this.expand, this);
35495 if(this.collapseBtn){
35496 this.collapseBtn.setVisible(c.collapsible == true);
35499 this.cmargins = c.cmargins || this.cmargins ||
35500 (this.position == "west" || this.position == "east" ?
35501 {top: 0, left: 2, right:2, bottom: 0} :
35502 {top: 2, left: 0, right:0, bottom: 2});
35504 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35507 this.bottomTabs = c.tabPosition != "top";
35509 this.autoScroll = c.autoScroll || false;
35514 this.duration = c.duration || .30;
35515 this.slideDuration = c.slideDuration || .45;
35520 * Returns true if this region is currently visible.
35521 * @return {Boolean}
35523 isVisible : function(){
35524 return this.visible;
35528 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35529 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35531 //setCollapsedTitle : function(title){
35532 // title = title || " ";
35533 // if(this.collapsedTitleTextEl){
35534 // this.collapsedTitleTextEl.innerHTML = title;
35538 getBox : function(){
35540 // if(!this.collapsed){
35541 b = this.el.getBox(false, true);
35543 // b = this.collapsedEl.getBox(false, true);
35548 getMargins : function(){
35549 return this.margins;
35550 //return this.collapsed ? this.cmargins : this.margins;
35553 highlight : function(){
35554 this.el.addClass("x-layout-panel-dragover");
35557 unhighlight : function(){
35558 this.el.removeClass("x-layout-panel-dragover");
35561 updateBox : function(box)
35563 if (!this.bodyEl) {
35564 return; // not rendered yet..
35568 if(!this.collapsed){
35569 this.el.dom.style.left = box.x + "px";
35570 this.el.dom.style.top = box.y + "px";
35571 this.updateBody(box.width, box.height);
35573 this.collapsedEl.dom.style.left = box.x + "px";
35574 this.collapsedEl.dom.style.top = box.y + "px";
35575 this.collapsedEl.setSize(box.width, box.height);
35578 this.tabs.autoSizeTabs();
35582 updateBody : function(w, h)
35585 this.el.setWidth(w);
35586 w -= this.el.getBorderWidth("rl");
35587 if(this.config.adjustments){
35588 w += this.config.adjustments[0];
35591 if(h !== null && h > 0){
35592 this.el.setHeight(h);
35593 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35594 h -= this.el.getBorderWidth("tb");
35595 if(this.config.adjustments){
35596 h += this.config.adjustments[1];
35598 this.bodyEl.setHeight(h);
35600 h = this.tabs.syncHeight(h);
35603 if(this.panelSize){
35604 w = w !== null ? w : this.panelSize.width;
35605 h = h !== null ? h : this.panelSize.height;
35607 if(this.activePanel){
35608 var el = this.activePanel.getEl();
35609 w = w !== null ? w : el.getWidth();
35610 h = h !== null ? h : el.getHeight();
35611 this.panelSize = {width: w, height: h};
35612 this.activePanel.setSize(w, h);
35614 if(Roo.isIE && this.tabs){
35615 this.tabs.el.repaint();
35620 * Returns the container element for this region.
35621 * @return {Roo.Element}
35623 getEl : function(){
35628 * Hides this region.
35631 //if(!this.collapsed){
35632 this.el.dom.style.left = "-2000px";
35635 // this.collapsedEl.dom.style.left = "-2000px";
35636 // this.collapsedEl.hide();
35638 this.visible = false;
35639 this.fireEvent("visibilitychange", this, false);
35643 * Shows this region if it was previously hidden.
35646 //if(!this.collapsed){
35649 // this.collapsedEl.show();
35651 this.visible = true;
35652 this.fireEvent("visibilitychange", this, true);
35655 closeClicked : function(){
35656 if(this.activePanel){
35657 this.remove(this.activePanel);
35661 collapseClick : function(e){
35663 e.stopPropagation();
35666 e.stopPropagation();
35672 * Collapses this region.
35673 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35676 collapse : function(skipAnim, skipCheck = false){
35677 if(this.collapsed) {
35681 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35683 this.collapsed = true;
35685 this.split.el.hide();
35687 if(this.config.animate && skipAnim !== true){
35688 this.fireEvent("invalidated", this);
35689 this.animateCollapse();
35691 this.el.setLocation(-20000,-20000);
35693 this.collapsedEl.show();
35694 this.fireEvent("collapsed", this);
35695 this.fireEvent("invalidated", this);
35701 animateCollapse : function(){
35706 * Expands this region if it was previously collapsed.
35707 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35708 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35711 expand : function(e, skipAnim){
35713 e.stopPropagation();
35715 if(!this.collapsed || this.el.hasActiveFx()) {
35719 this.afterSlideIn();
35722 this.collapsed = false;
35723 if(this.config.animate && skipAnim !== true){
35724 this.animateExpand();
35728 this.split.el.show();
35730 this.collapsedEl.setLocation(-2000,-2000);
35731 this.collapsedEl.hide();
35732 this.fireEvent("invalidated", this);
35733 this.fireEvent("expanded", this);
35737 animateExpand : function(){
35741 initTabs : function()
35743 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35745 var ts = new Roo.bootstrap.panel.Tabs({
35746 el: this.bodyEl.dom,
35747 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35748 disableTooltips: this.config.disableTabTips,
35749 toolbar : this.config.toolbar
35752 if(this.config.hideTabs){
35753 ts.stripWrap.setDisplayed(false);
35756 ts.resizeTabs = this.config.resizeTabs === true;
35757 ts.minTabWidth = this.config.minTabWidth || 40;
35758 ts.maxTabWidth = this.config.maxTabWidth || 250;
35759 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35760 ts.monitorResize = false;
35761 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35762 ts.bodyEl.addClass('roo-layout-tabs-body');
35763 this.panels.each(this.initPanelAsTab, this);
35766 initPanelAsTab : function(panel){
35767 var ti = this.tabs.addTab(
35771 this.config.closeOnTab && panel.isClosable(),
35774 if(panel.tabTip !== undefined){
35775 ti.setTooltip(panel.tabTip);
35777 ti.on("activate", function(){
35778 this.setActivePanel(panel);
35781 if(this.config.closeOnTab){
35782 ti.on("beforeclose", function(t, e){
35784 this.remove(panel);
35788 panel.tabItem = ti;
35793 updatePanelTitle : function(panel, title)
35795 if(this.activePanel == panel){
35796 this.updateTitle(title);
35799 var ti = this.tabs.getTab(panel.getEl().id);
35801 if(panel.tabTip !== undefined){
35802 ti.setTooltip(panel.tabTip);
35807 updateTitle : function(title){
35808 if(this.titleTextEl && !this.config.title){
35809 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35813 setActivePanel : function(panel)
35815 panel = this.getPanel(panel);
35816 if(this.activePanel && this.activePanel != panel){
35817 if(this.activePanel.setActiveState(false) === false){
35821 this.activePanel = panel;
35822 panel.setActiveState(true);
35823 if(this.panelSize){
35824 panel.setSize(this.panelSize.width, this.panelSize.height);
35827 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35829 this.updateTitle(panel.getTitle());
35831 this.fireEvent("invalidated", this);
35833 this.fireEvent("panelactivated", this, panel);
35837 * Shows the specified panel.
35838 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35839 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35841 showPanel : function(panel)
35843 panel = this.getPanel(panel);
35846 var tab = this.tabs.getTab(panel.getEl().id);
35847 if(tab.isHidden()){
35848 this.tabs.unhideTab(tab.id);
35852 this.setActivePanel(panel);
35859 * Get the active panel for this region.
35860 * @return {Roo.ContentPanel} The active panel or null
35862 getActivePanel : function(){
35863 return this.activePanel;
35866 validateVisibility : function(){
35867 if(this.panels.getCount() < 1){
35868 this.updateTitle(" ");
35869 this.closeBtn.hide();
35872 if(!this.isVisible()){
35879 * Adds the passed ContentPanel(s) to this region.
35880 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35881 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35883 add : function(panel)
35885 if(arguments.length > 1){
35886 for(var i = 0, len = arguments.length; i < len; i++) {
35887 this.add(arguments[i]);
35892 // if we have not been rendered yet, then we can not really do much of this..
35893 if (!this.bodyEl) {
35894 this.unrendered_panels.push(panel);
35901 if(this.hasPanel(panel)){
35902 this.showPanel(panel);
35905 panel.setRegion(this);
35906 this.panels.add(panel);
35907 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35908 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35909 // and hide them... ???
35910 this.bodyEl.dom.appendChild(panel.getEl().dom);
35911 if(panel.background !== true){
35912 this.setActivePanel(panel);
35914 this.fireEvent("paneladded", this, panel);
35921 this.initPanelAsTab(panel);
35925 if(panel.background !== true){
35926 this.tabs.activate(panel.getEl().id);
35928 this.fireEvent("paneladded", this, panel);
35933 * Hides the tab for the specified panel.
35934 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35936 hidePanel : function(panel){
35937 if(this.tabs && (panel = this.getPanel(panel))){
35938 this.tabs.hideTab(panel.getEl().id);
35943 * Unhides the tab for a previously hidden panel.
35944 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35946 unhidePanel : function(panel){
35947 if(this.tabs && (panel = this.getPanel(panel))){
35948 this.tabs.unhideTab(panel.getEl().id);
35952 clearPanels : function(){
35953 while(this.panels.getCount() > 0){
35954 this.remove(this.panels.first());
35959 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35960 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35961 * @param {Boolean} preservePanel Overrides the config preservePanel option
35962 * @return {Roo.ContentPanel} The panel that was removed
35964 remove : function(panel, preservePanel)
35966 panel = this.getPanel(panel);
35971 this.fireEvent("beforeremove", this, panel, e);
35972 if(e.cancel === true){
35975 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35976 var panelId = panel.getId();
35977 this.panels.removeKey(panelId);
35979 document.body.appendChild(panel.getEl().dom);
35982 this.tabs.removeTab(panel.getEl().id);
35983 }else if (!preservePanel){
35984 this.bodyEl.dom.removeChild(panel.getEl().dom);
35986 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35987 var p = this.panels.first();
35988 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35989 tempEl.appendChild(p.getEl().dom);
35990 this.bodyEl.update("");
35991 this.bodyEl.dom.appendChild(p.getEl().dom);
35993 this.updateTitle(p.getTitle());
35995 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35996 this.setActivePanel(p);
35998 panel.setRegion(null);
35999 if(this.activePanel == panel){
36000 this.activePanel = null;
36002 if(this.config.autoDestroy !== false && preservePanel !== true){
36003 try{panel.destroy();}catch(e){}
36005 this.fireEvent("panelremoved", this, panel);
36010 * Returns the TabPanel component used by this region
36011 * @return {Roo.TabPanel}
36013 getTabs : function(){
36017 createTool : function(parentEl, className){
36018 var btn = Roo.DomHelper.append(parentEl, {
36020 cls: "x-layout-tools-button",
36023 cls: "roo-layout-tools-button-inner " + className,
36027 btn.addClassOnOver("roo-layout-tools-button-over");
36032 * Ext JS Library 1.1.1
36033 * Copyright(c) 2006-2007, Ext JS, LLC.
36035 * Originally Released Under LGPL - original licence link has changed is not relivant.
36038 * <script type="text/javascript">
36044 * @class Roo.SplitLayoutRegion
36045 * @extends Roo.LayoutRegion
36046 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36048 Roo.bootstrap.layout.Split = function(config){
36049 this.cursor = config.cursor;
36050 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36053 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36055 splitTip : "Drag to resize.",
36056 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36057 useSplitTips : false,
36059 applyConfig : function(config){
36060 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36063 onRender : function(ctr,pos) {
36065 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36066 if(!this.config.split){
36071 var splitEl = Roo.DomHelper.append(ctr.dom, {
36073 id: this.el.id + "-split",
36074 cls: "roo-layout-split roo-layout-split-"+this.position,
36077 /** The SplitBar for this region
36078 * @type Roo.SplitBar */
36079 // does not exist yet...
36080 Roo.log([this.position, this.orientation]);
36082 this.split = new Roo.bootstrap.SplitBar({
36083 dragElement : splitEl,
36084 resizingElement: this.el,
36085 orientation : this.orientation
36088 this.split.on("moved", this.onSplitMove, this);
36089 this.split.useShim = this.config.useShim === true;
36090 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36091 if(this.useSplitTips){
36092 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36094 //if(config.collapsible){
36095 // this.split.el.on("dblclick", this.collapse, this);
36098 if(typeof this.config.minSize != "undefined"){
36099 this.split.minSize = this.config.minSize;
36101 if(typeof this.config.maxSize != "undefined"){
36102 this.split.maxSize = this.config.maxSize;
36104 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36105 this.hideSplitter();
36110 getHMaxSize : function(){
36111 var cmax = this.config.maxSize || 10000;
36112 var center = this.mgr.getRegion("center");
36113 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36116 getVMaxSize : function(){
36117 var cmax = this.config.maxSize || 10000;
36118 var center = this.mgr.getRegion("center");
36119 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36122 onSplitMove : function(split, newSize){
36123 this.fireEvent("resized", this, newSize);
36127 * Returns the {@link Roo.SplitBar} for this region.
36128 * @return {Roo.SplitBar}
36130 getSplitBar : function(){
36135 this.hideSplitter();
36136 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36139 hideSplitter : function(){
36141 this.split.el.setLocation(-2000,-2000);
36142 this.split.el.hide();
36148 this.split.el.show();
36150 Roo.bootstrap.layout.Split.superclass.show.call(this);
36153 beforeSlide: function(){
36154 if(Roo.isGecko){// firefox overflow auto bug workaround
36155 this.bodyEl.clip();
36157 this.tabs.bodyEl.clip();
36159 if(this.activePanel){
36160 this.activePanel.getEl().clip();
36162 if(this.activePanel.beforeSlide){
36163 this.activePanel.beforeSlide();
36169 afterSlide : function(){
36170 if(Roo.isGecko){// firefox overflow auto bug workaround
36171 this.bodyEl.unclip();
36173 this.tabs.bodyEl.unclip();
36175 if(this.activePanel){
36176 this.activePanel.getEl().unclip();
36177 if(this.activePanel.afterSlide){
36178 this.activePanel.afterSlide();
36184 initAutoHide : function(){
36185 if(this.autoHide !== false){
36186 if(!this.autoHideHd){
36187 var st = new Roo.util.DelayedTask(this.slideIn, this);
36188 this.autoHideHd = {
36189 "mouseout": function(e){
36190 if(!e.within(this.el, true)){
36194 "mouseover" : function(e){
36200 this.el.on(this.autoHideHd);
36204 clearAutoHide : function(){
36205 if(this.autoHide !== false){
36206 this.el.un("mouseout", this.autoHideHd.mouseout);
36207 this.el.un("mouseover", this.autoHideHd.mouseover);
36211 clearMonitor : function(){
36212 Roo.get(document).un("click", this.slideInIf, this);
36215 // these names are backwards but not changed for compat
36216 slideOut : function(){
36217 if(this.isSlid || this.el.hasActiveFx()){
36220 this.isSlid = true;
36221 if(this.collapseBtn){
36222 this.collapseBtn.hide();
36224 this.closeBtnState = this.closeBtn.getStyle('display');
36225 this.closeBtn.hide();
36227 this.stickBtn.show();
36230 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36231 this.beforeSlide();
36232 this.el.setStyle("z-index", 10001);
36233 this.el.slideIn(this.getSlideAnchor(), {
36234 callback: function(){
36236 this.initAutoHide();
36237 Roo.get(document).on("click", this.slideInIf, this);
36238 this.fireEvent("slideshow", this);
36245 afterSlideIn : function(){
36246 this.clearAutoHide();
36247 this.isSlid = false;
36248 this.clearMonitor();
36249 this.el.setStyle("z-index", "");
36250 if(this.collapseBtn){
36251 this.collapseBtn.show();
36253 this.closeBtn.setStyle('display', this.closeBtnState);
36255 this.stickBtn.hide();
36257 this.fireEvent("slidehide", this);
36260 slideIn : function(cb){
36261 if(!this.isSlid || this.el.hasActiveFx()){
36265 this.isSlid = false;
36266 this.beforeSlide();
36267 this.el.slideOut(this.getSlideAnchor(), {
36268 callback: function(){
36269 this.el.setLeftTop(-10000, -10000);
36271 this.afterSlideIn();
36279 slideInIf : function(e){
36280 if(!e.within(this.el)){
36285 animateCollapse : function(){
36286 this.beforeSlide();
36287 this.el.setStyle("z-index", 20000);
36288 var anchor = this.getSlideAnchor();
36289 this.el.slideOut(anchor, {
36290 callback : function(){
36291 this.el.setStyle("z-index", "");
36292 this.collapsedEl.slideIn(anchor, {duration:.3});
36294 this.el.setLocation(-10000,-10000);
36296 this.fireEvent("collapsed", this);
36303 animateExpand : function(){
36304 this.beforeSlide();
36305 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36306 this.el.setStyle("z-index", 20000);
36307 this.collapsedEl.hide({
36310 this.el.slideIn(this.getSlideAnchor(), {
36311 callback : function(){
36312 this.el.setStyle("z-index", "");
36315 this.split.el.show();
36317 this.fireEvent("invalidated", this);
36318 this.fireEvent("expanded", this);
36346 getAnchor : function(){
36347 return this.anchors[this.position];
36350 getCollapseAnchor : function(){
36351 return this.canchors[this.position];
36354 getSlideAnchor : function(){
36355 return this.sanchors[this.position];
36358 getAlignAdj : function(){
36359 var cm = this.cmargins;
36360 switch(this.position){
36376 getExpandAdj : function(){
36377 var c = this.collapsedEl, cm = this.cmargins;
36378 switch(this.position){
36380 return [-(cm.right+c.getWidth()+cm.left), 0];
36383 return [cm.right+c.getWidth()+cm.left, 0];
36386 return [0, -(cm.top+cm.bottom+c.getHeight())];
36389 return [0, cm.top+cm.bottom+c.getHeight()];
36395 * Ext JS Library 1.1.1
36396 * Copyright(c) 2006-2007, Ext JS, LLC.
36398 * Originally Released Under LGPL - original licence link has changed is not relivant.
36401 * <script type="text/javascript">
36404 * These classes are private internal classes
36406 Roo.bootstrap.layout.Center = function(config){
36407 config.region = "center";
36408 Roo.bootstrap.layout.Region.call(this, config);
36409 this.visible = true;
36410 this.minWidth = config.minWidth || 20;
36411 this.minHeight = config.minHeight || 20;
36414 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36416 // center panel can't be hidden
36420 // center panel can't be hidden
36423 getMinWidth: function(){
36424 return this.minWidth;
36427 getMinHeight: function(){
36428 return this.minHeight;
36441 Roo.bootstrap.layout.North = function(config)
36443 config.region = 'north';
36444 config.cursor = 'n-resize';
36446 Roo.bootstrap.layout.Split.call(this, config);
36450 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36451 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36452 this.split.el.addClass("roo-layout-split-v");
36454 var size = config.initialSize || config.height;
36455 if(typeof size != "undefined"){
36456 this.el.setHeight(size);
36459 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36461 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36465 getBox : function(){
36466 if(this.collapsed){
36467 return this.collapsedEl.getBox();
36469 var box = this.el.getBox();
36471 box.height += this.split.el.getHeight();
36476 updateBox : function(box){
36477 if(this.split && !this.collapsed){
36478 box.height -= this.split.el.getHeight();
36479 this.split.el.setLeft(box.x);
36480 this.split.el.setTop(box.y+box.height);
36481 this.split.el.setWidth(box.width);
36483 if(this.collapsed){
36484 this.updateBody(box.width, null);
36486 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36494 Roo.bootstrap.layout.South = function(config){
36495 config.region = 'south';
36496 config.cursor = 's-resize';
36497 Roo.bootstrap.layout.Split.call(this, config);
36499 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36500 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36501 this.split.el.addClass("roo-layout-split-v");
36503 var size = config.initialSize || config.height;
36504 if(typeof size != "undefined"){
36505 this.el.setHeight(size);
36509 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36510 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36511 getBox : function(){
36512 if(this.collapsed){
36513 return this.collapsedEl.getBox();
36515 var box = this.el.getBox();
36517 var sh = this.split.el.getHeight();
36524 updateBox : function(box){
36525 if(this.split && !this.collapsed){
36526 var sh = this.split.el.getHeight();
36529 this.split.el.setLeft(box.x);
36530 this.split.el.setTop(box.y-sh);
36531 this.split.el.setWidth(box.width);
36533 if(this.collapsed){
36534 this.updateBody(box.width, null);
36536 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36540 Roo.bootstrap.layout.East = function(config){
36541 config.region = "east";
36542 config.cursor = "e-resize";
36543 Roo.bootstrap.layout.Split.call(this, config);
36545 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36546 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36547 this.split.el.addClass("roo-layout-split-h");
36549 var size = config.initialSize || config.width;
36550 if(typeof size != "undefined"){
36551 this.el.setWidth(size);
36554 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36555 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36556 getBox : function(){
36557 if(this.collapsed){
36558 return this.collapsedEl.getBox();
36560 var box = this.el.getBox();
36562 var sw = this.split.el.getWidth();
36569 updateBox : function(box){
36570 if(this.split && !this.collapsed){
36571 var sw = this.split.el.getWidth();
36573 this.split.el.setLeft(box.x);
36574 this.split.el.setTop(box.y);
36575 this.split.el.setHeight(box.height);
36578 if(this.collapsed){
36579 this.updateBody(null, box.height);
36581 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36585 Roo.bootstrap.layout.West = function(config){
36586 config.region = "west";
36587 config.cursor = "w-resize";
36589 Roo.bootstrap.layout.Split.call(this, config);
36591 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36592 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36593 this.split.el.addClass("roo-layout-split-h");
36597 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36598 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36600 onRender: function(ctr, pos)
36602 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36603 var size = this.config.initialSize || this.config.width;
36604 if(typeof size != "undefined"){
36605 this.el.setWidth(size);
36609 getBox : function(){
36610 if(this.collapsed){
36611 return this.collapsedEl.getBox();
36613 var box = this.el.getBox();
36615 box.width += this.split.el.getWidth();
36620 updateBox : function(box){
36621 if(this.split && !this.collapsed){
36622 var sw = this.split.el.getWidth();
36624 this.split.el.setLeft(box.x+box.width);
36625 this.split.el.setTop(box.y);
36626 this.split.el.setHeight(box.height);
36628 if(this.collapsed){
36629 this.updateBody(null, box.height);
36631 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36634 Roo.namespace("Roo.bootstrap.panel");/*
36636 * Ext JS Library 1.1.1
36637 * Copyright(c) 2006-2007, Ext JS, LLC.
36639 * Originally Released Under LGPL - original licence link has changed is not relivant.
36642 * <script type="text/javascript">
36645 * @class Roo.ContentPanel
36646 * @extends Roo.util.Observable
36647 * A basic ContentPanel element.
36648 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36649 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36650 * @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
36651 * @cfg {Boolean} closable True if the panel can be closed/removed
36652 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36653 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36654 * @cfg {Toolbar} toolbar A toolbar for this panel
36655 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36656 * @cfg {String} title The title for this panel
36657 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36658 * @cfg {String} url Calls {@link #setUrl} with this value
36659 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36660 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36661 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36662 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36663 * @cfg {Boolean} badges render the badges
36666 * Create a new ContentPanel.
36667 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36668 * @param {String/Object} config A string to set only the title or a config object
36669 * @param {String} content (optional) Set the HTML content for this panel
36670 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36672 Roo.bootstrap.panel.Content = function( config){
36674 this.tpl = config.tpl || false;
36676 var el = config.el;
36677 var content = config.content;
36679 if(config.autoCreate){ // xtype is available if this is called from factory
36682 this.el = Roo.get(el);
36683 if(!this.el && config && config.autoCreate){
36684 if(typeof config.autoCreate == "object"){
36685 if(!config.autoCreate.id){
36686 config.autoCreate.id = config.id||el;
36688 this.el = Roo.DomHelper.append(document.body,
36689 config.autoCreate, true);
36691 var elcfg = { tag: "div",
36692 cls: "roo-layout-inactive-content",
36696 elcfg.html = config.html;
36700 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36703 this.closable = false;
36704 this.loaded = false;
36705 this.active = false;
36708 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36710 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36712 this.wrapEl = this.el; //this.el.wrap();
36714 if (config.toolbar.items) {
36715 ti = config.toolbar.items ;
36716 delete config.toolbar.items ;
36720 this.toolbar.render(this.wrapEl, 'before');
36721 for(var i =0;i < ti.length;i++) {
36722 // Roo.log(['add child', items[i]]);
36723 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36725 this.toolbar.items = nitems;
36726 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36727 delete config.toolbar;
36731 // xtype created footer. - not sure if will work as we normally have to render first..
36732 if (this.footer && !this.footer.el && this.footer.xtype) {
36733 if (!this.wrapEl) {
36734 this.wrapEl = this.el.wrap();
36737 this.footer.container = this.wrapEl.createChild();
36739 this.footer = Roo.factory(this.footer, Roo);
36744 if(typeof config == "string"){
36745 this.title = config;
36747 Roo.apply(this, config);
36751 this.resizeEl = Roo.get(this.resizeEl, true);
36753 this.resizeEl = this.el;
36755 // handle view.xtype
36763 * Fires when this panel is activated.
36764 * @param {Roo.ContentPanel} this
36768 * @event deactivate
36769 * Fires when this panel is activated.
36770 * @param {Roo.ContentPanel} this
36772 "deactivate" : true,
36776 * Fires when this panel is resized if fitToFrame is true.
36777 * @param {Roo.ContentPanel} this
36778 * @param {Number} width The width after any component adjustments
36779 * @param {Number} height The height after any component adjustments
36785 * Fires when this tab is created
36786 * @param {Roo.ContentPanel} this
36797 if(this.autoScroll){
36798 this.resizeEl.setStyle("overflow", "auto");
36800 // fix randome scrolling
36801 //this.el.on('scroll', function() {
36802 // Roo.log('fix random scolling');
36803 // this.scrollTo('top',0);
36806 content = content || this.content;
36808 this.setContent(content);
36810 if(config && config.url){
36811 this.setUrl(this.url, this.params, this.loadOnce);
36816 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36818 if (this.view && typeof(this.view.xtype) != 'undefined') {
36819 this.view.el = this.el.appendChild(document.createElement("div"));
36820 this.view = Roo.factory(this.view);
36821 this.view.render && this.view.render(false, '');
36825 this.fireEvent('render', this);
36828 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36832 setRegion : function(region){
36833 this.region = region;
36834 this.setActiveClass(region && !this.background);
36838 setActiveClass: function(state)
36841 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36842 this.el.setStyle('position','relative');
36844 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36845 this.el.setStyle('position', 'absolute');
36850 * Returns the toolbar for this Panel if one was configured.
36851 * @return {Roo.Toolbar}
36853 getToolbar : function(){
36854 return this.toolbar;
36857 setActiveState : function(active)
36859 this.active = active;
36860 this.setActiveClass(active);
36862 if(this.fireEvent("deactivate", this) === false){
36867 this.fireEvent("activate", this);
36871 * Updates this panel's element
36872 * @param {String} content The new content
36873 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36875 setContent : function(content, loadScripts){
36876 this.el.update(content, loadScripts);
36879 ignoreResize : function(w, h){
36880 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36883 this.lastSize = {width: w, height: h};
36888 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36889 * @return {Roo.UpdateManager} The UpdateManager
36891 getUpdateManager : function(){
36892 return this.el.getUpdateManager();
36895 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36896 * @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:
36899 url: "your-url.php",
36900 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36901 callback: yourFunction,
36902 scope: yourObject, //(optional scope)
36905 text: "Loading...",
36910 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36911 * 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.
36912 * @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}
36913 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36914 * @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.
36915 * @return {Roo.ContentPanel} this
36918 var um = this.el.getUpdateManager();
36919 um.update.apply(um, arguments);
36925 * 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.
36926 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36927 * @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)
36928 * @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)
36929 * @return {Roo.UpdateManager} The UpdateManager
36931 setUrl : function(url, params, loadOnce){
36932 if(this.refreshDelegate){
36933 this.removeListener("activate", this.refreshDelegate);
36935 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36936 this.on("activate", this.refreshDelegate);
36937 return this.el.getUpdateManager();
36940 _handleRefresh : function(url, params, loadOnce){
36941 if(!loadOnce || !this.loaded){
36942 var updater = this.el.getUpdateManager();
36943 updater.update(url, params, this._setLoaded.createDelegate(this));
36947 _setLoaded : function(){
36948 this.loaded = true;
36952 * Returns this panel's id
36955 getId : function(){
36960 * Returns this panel's element - used by regiosn to add.
36961 * @return {Roo.Element}
36963 getEl : function(){
36964 return this.wrapEl || this.el;
36969 adjustForComponents : function(width, height)
36971 //Roo.log('adjustForComponents ');
36972 if(this.resizeEl != this.el){
36973 width -= this.el.getFrameWidth('lr');
36974 height -= this.el.getFrameWidth('tb');
36977 var te = this.toolbar.getEl();
36978 te.setWidth(width);
36979 height -= te.getHeight();
36982 var te = this.footer.getEl();
36983 te.setWidth(width);
36984 height -= te.getHeight();
36988 if(this.adjustments){
36989 width += this.adjustments[0];
36990 height += this.adjustments[1];
36992 return {"width": width, "height": height};
36995 setSize : function(width, height){
36996 if(this.fitToFrame && !this.ignoreResize(width, height)){
36997 if(this.fitContainer && this.resizeEl != this.el){
36998 this.el.setSize(width, height);
37000 var size = this.adjustForComponents(width, height);
37001 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37002 this.fireEvent('resize', this, size.width, size.height);
37007 * Returns this panel's title
37010 getTitle : function(){
37012 if (typeof(this.title) != 'object') {
37017 for (var k in this.title) {
37018 if (!this.title.hasOwnProperty(k)) {
37022 if (k.indexOf('-') >= 0) {
37023 var s = k.split('-');
37024 for (var i = 0; i<s.length; i++) {
37025 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37028 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37035 * Set this panel's title
37036 * @param {String} title
37038 setTitle : function(title){
37039 this.title = title;
37041 this.region.updatePanelTitle(this, title);
37046 * Returns true is this panel was configured to be closable
37047 * @return {Boolean}
37049 isClosable : function(){
37050 return this.closable;
37053 beforeSlide : function(){
37055 this.resizeEl.clip();
37058 afterSlide : function(){
37060 this.resizeEl.unclip();
37064 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37065 * Will fail silently if the {@link #setUrl} method has not been called.
37066 * This does not activate the panel, just updates its content.
37068 refresh : function(){
37069 if(this.refreshDelegate){
37070 this.loaded = false;
37071 this.refreshDelegate();
37076 * Destroys this panel
37078 destroy : function(){
37079 this.el.removeAllListeners();
37080 var tempEl = document.createElement("span");
37081 tempEl.appendChild(this.el.dom);
37082 tempEl.innerHTML = "";
37088 * form - if the content panel contains a form - this is a reference to it.
37089 * @type {Roo.form.Form}
37093 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37094 * This contains a reference to it.
37100 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37110 * @param {Object} cfg Xtype definition of item to add.
37114 getChildContainer: function () {
37115 return this.getEl();
37120 var ret = new Roo.factory(cfg);
37125 if (cfg.xtype.match(/^Form$/)) {
37128 //if (this.footer) {
37129 // el = this.footer.container.insertSibling(false, 'before');
37131 el = this.el.createChild();
37134 this.form = new Roo.form.Form(cfg);
37137 if ( this.form.allItems.length) {
37138 this.form.render(el.dom);
37142 // should only have one of theses..
37143 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37144 // views.. should not be just added - used named prop 'view''
37146 cfg.el = this.el.appendChild(document.createElement("div"));
37149 var ret = new Roo.factory(cfg);
37151 ret.render && ret.render(false, ''); // render blank..
37161 * @class Roo.bootstrap.panel.Grid
37162 * @extends Roo.bootstrap.panel.Content
37164 * Create a new GridPanel.
37165 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37166 * @param {Object} config A the config object
37172 Roo.bootstrap.panel.Grid = function(config)
37176 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37177 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37179 config.el = this.wrapper;
37180 //this.el = this.wrapper;
37182 if (config.container) {
37183 // ctor'ed from a Border/panel.grid
37186 this.wrapper.setStyle("overflow", "hidden");
37187 this.wrapper.addClass('roo-grid-container');
37192 if(config.toolbar){
37193 var tool_el = this.wrapper.createChild();
37194 this.toolbar = Roo.factory(config.toolbar);
37196 if (config.toolbar.items) {
37197 ti = config.toolbar.items ;
37198 delete config.toolbar.items ;
37202 this.toolbar.render(tool_el);
37203 for(var i =0;i < ti.length;i++) {
37204 // Roo.log(['add child', items[i]]);
37205 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37207 this.toolbar.items = nitems;
37209 delete config.toolbar;
37212 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37213 config.grid.scrollBody = true;;
37214 config.grid.monitorWindowResize = false; // turn off autosizing
37215 config.grid.autoHeight = false;
37216 config.grid.autoWidth = false;
37218 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37220 if (config.background) {
37221 // render grid on panel activation (if panel background)
37222 this.on('activate', function(gp) {
37223 if (!gp.grid.rendered) {
37224 gp.grid.render(this.wrapper);
37225 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37230 this.grid.render(this.wrapper);
37231 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37234 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37235 // ??? needed ??? config.el = this.wrapper;
37240 // xtype created footer. - not sure if will work as we normally have to render first..
37241 if (this.footer && !this.footer.el && this.footer.xtype) {
37243 var ctr = this.grid.getView().getFooterPanel(true);
37244 this.footer.dataSource = this.grid.dataSource;
37245 this.footer = Roo.factory(this.footer, Roo);
37246 this.footer.render(ctr);
37256 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37257 getId : function(){
37258 return this.grid.id;
37262 * Returns the grid for this panel
37263 * @return {Roo.bootstrap.Table}
37265 getGrid : function(){
37269 setSize : function(width, height){
37270 if(!this.ignoreResize(width, height)){
37271 var grid = this.grid;
37272 var size = this.adjustForComponents(width, height);
37273 var gridel = grid.getGridEl();
37274 gridel.setSize(size.width, size.height);
37276 var thd = grid.getGridEl().select('thead',true).first();
37277 var tbd = grid.getGridEl().select('tbody', true).first();
37279 tbd.setSize(width, height - thd.getHeight());
37288 beforeSlide : function(){
37289 this.grid.getView().scroller.clip();
37292 afterSlide : function(){
37293 this.grid.getView().scroller.unclip();
37296 destroy : function(){
37297 this.grid.destroy();
37299 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37304 * @class Roo.bootstrap.panel.Nest
37305 * @extends Roo.bootstrap.panel.Content
37307 * Create a new Panel, that can contain a layout.Border.
37310 * @param {Roo.BorderLayout} layout The layout for this panel
37311 * @param {String/Object} config A string to set only the title or a config object
37313 Roo.bootstrap.panel.Nest = function(config)
37315 // construct with only one argument..
37316 /* FIXME - implement nicer consturctors
37317 if (layout.layout) {
37319 layout = config.layout;
37320 delete config.layout;
37322 if (layout.xtype && !layout.getEl) {
37323 // then layout needs constructing..
37324 layout = Roo.factory(layout, Roo);
37328 config.el = config.layout.getEl();
37330 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37332 config.layout.monitorWindowResize = false; // turn off autosizing
37333 this.layout = config.layout;
37334 this.layout.getEl().addClass("roo-layout-nested-layout");
37341 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37343 setSize : function(width, height){
37344 if(!this.ignoreResize(width, height)){
37345 var size = this.adjustForComponents(width, height);
37346 var el = this.layout.getEl();
37347 if (size.height < 1) {
37348 el.setWidth(size.width);
37350 el.setSize(size.width, size.height);
37352 var touch = el.dom.offsetWidth;
37353 this.layout.layout();
37354 // ie requires a double layout on the first pass
37355 if(Roo.isIE && !this.initialized){
37356 this.initialized = true;
37357 this.layout.layout();
37362 // activate all subpanels if not currently active..
37364 setActiveState : function(active){
37365 this.active = active;
37366 this.setActiveClass(active);
37369 this.fireEvent("deactivate", this);
37373 this.fireEvent("activate", this);
37374 // not sure if this should happen before or after..
37375 if (!this.layout) {
37376 return; // should not happen..
37379 for (var r in this.layout.regions) {
37380 reg = this.layout.getRegion(r);
37381 if (reg.getActivePanel()) {
37382 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37383 reg.setActivePanel(reg.getActivePanel());
37386 if (!reg.panels.length) {
37389 reg.showPanel(reg.getPanel(0));
37398 * Returns the nested BorderLayout for this panel
37399 * @return {Roo.BorderLayout}
37401 getLayout : function(){
37402 return this.layout;
37406 * Adds a xtype elements to the layout of the nested panel
37410 xtype : 'ContentPanel',
37417 xtype : 'NestedLayoutPanel',
37423 items : [ ... list of content panels or nested layout panels.. ]
37427 * @param {Object} cfg Xtype definition of item to add.
37429 addxtype : function(cfg) {
37430 return this.layout.addxtype(cfg);
37435 * Ext JS Library 1.1.1
37436 * Copyright(c) 2006-2007, Ext JS, LLC.
37438 * Originally Released Under LGPL - original licence link has changed is not relivant.
37441 * <script type="text/javascript">
37444 * @class Roo.TabPanel
37445 * @extends Roo.util.Observable
37446 * A lightweight tab container.
37450 // basic tabs 1, built from existing content
37451 var tabs = new Roo.TabPanel("tabs1");
37452 tabs.addTab("script", "View Script");
37453 tabs.addTab("markup", "View Markup");
37454 tabs.activate("script");
37456 // more advanced tabs, built from javascript
37457 var jtabs = new Roo.TabPanel("jtabs");
37458 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37460 // set up the UpdateManager
37461 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37462 var updater = tab2.getUpdateManager();
37463 updater.setDefaultUrl("ajax1.htm");
37464 tab2.on('activate', updater.refresh, updater, true);
37466 // Use setUrl for Ajax loading
37467 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37468 tab3.setUrl("ajax2.htm", null, true);
37471 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37474 jtabs.activate("jtabs-1");
37477 * Create a new TabPanel.
37478 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37479 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37481 Roo.bootstrap.panel.Tabs = function(config){
37483 * The container element for this TabPanel.
37484 * @type Roo.Element
37486 this.el = Roo.get(config.el);
37489 if(typeof config == "boolean"){
37490 this.tabPosition = config ? "bottom" : "top";
37492 Roo.apply(this, config);
37496 if(this.tabPosition == "bottom"){
37497 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37498 this.el.addClass("roo-tabs-bottom");
37500 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37501 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37502 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37504 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37506 if(this.tabPosition != "bottom"){
37507 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37508 * @type Roo.Element
37510 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37511 this.el.addClass("roo-tabs-top");
37515 this.bodyEl.setStyle("position", "relative");
37517 this.active = null;
37518 this.activateDelegate = this.activate.createDelegate(this);
37523 * Fires when the active tab changes
37524 * @param {Roo.TabPanel} this
37525 * @param {Roo.TabPanelItem} activePanel The new active tab
37529 * @event beforetabchange
37530 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37531 * @param {Roo.TabPanel} this
37532 * @param {Object} e Set cancel to true on this object to cancel the tab change
37533 * @param {Roo.TabPanelItem} tab The tab being changed to
37535 "beforetabchange" : true
37538 Roo.EventManager.onWindowResize(this.onResize, this);
37539 this.cpad = this.el.getPadding("lr");
37540 this.hiddenCount = 0;
37543 // toolbar on the tabbar support...
37544 if (this.toolbar) {
37545 alert("no toolbar support yet");
37546 this.toolbar = false;
37548 var tcfg = this.toolbar;
37549 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37550 this.toolbar = new Roo.Toolbar(tcfg);
37551 if (Roo.isSafari) {
37552 var tbl = tcfg.container.child('table', true);
37553 tbl.setAttribute('width', '100%');
37561 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37564 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37566 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37568 tabPosition : "top",
37570 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37572 currentTabWidth : 0,
37574 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37578 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37582 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37584 preferredTabWidth : 175,
37586 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37588 resizeTabs : false,
37590 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37592 monitorResize : true,
37594 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37599 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37600 * @param {String} id The id of the div to use <b>or create</b>
37601 * @param {String} text The text for the tab
37602 * @param {String} content (optional) Content to put in the TabPanelItem body
37603 * @param {Boolean} closable (optional) True to create a close icon on the tab
37604 * @return {Roo.TabPanelItem} The created TabPanelItem
37606 addTab : function(id, text, content, closable, tpl)
37608 var item = new Roo.bootstrap.panel.TabItem({
37612 closable : closable,
37615 this.addTabItem(item);
37617 item.setContent(content);
37623 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37624 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37625 * @return {Roo.TabPanelItem}
37627 getTab : function(id){
37628 return this.items[id];
37632 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37633 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37635 hideTab : function(id){
37636 var t = this.items[id];
37639 this.hiddenCount++;
37640 this.autoSizeTabs();
37645 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37646 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37648 unhideTab : function(id){
37649 var t = this.items[id];
37651 t.setHidden(false);
37652 this.hiddenCount--;
37653 this.autoSizeTabs();
37658 * Adds an existing {@link Roo.TabPanelItem}.
37659 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37661 addTabItem : function(item){
37662 this.items[item.id] = item;
37663 this.items.push(item);
37664 // if(this.resizeTabs){
37665 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37666 // this.autoSizeTabs();
37668 // item.autoSize();
37673 * Removes a {@link Roo.TabPanelItem}.
37674 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37676 removeTab : function(id){
37677 var items = this.items;
37678 var tab = items[id];
37679 if(!tab) { return; }
37680 var index = items.indexOf(tab);
37681 if(this.active == tab && items.length > 1){
37682 var newTab = this.getNextAvailable(index);
37687 this.stripEl.dom.removeChild(tab.pnode.dom);
37688 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37689 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37691 items.splice(index, 1);
37692 delete this.items[tab.id];
37693 tab.fireEvent("close", tab);
37694 tab.purgeListeners();
37695 this.autoSizeTabs();
37698 getNextAvailable : function(start){
37699 var items = this.items;
37701 // look for a next tab that will slide over to
37702 // replace the one being removed
37703 while(index < items.length){
37704 var item = items[++index];
37705 if(item && !item.isHidden()){
37709 // if one isn't found select the previous tab (on the left)
37712 var item = items[--index];
37713 if(item && !item.isHidden()){
37721 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37722 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37724 disableTab : function(id){
37725 var tab = this.items[id];
37726 if(tab && this.active != tab){
37732 * Enables a {@link Roo.TabPanelItem} that is disabled.
37733 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37735 enableTab : function(id){
37736 var tab = this.items[id];
37741 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37742 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37743 * @return {Roo.TabPanelItem} The TabPanelItem.
37745 activate : function(id){
37746 var tab = this.items[id];
37750 if(tab == this.active || tab.disabled){
37754 this.fireEvent("beforetabchange", this, e, tab);
37755 if(e.cancel !== true && !tab.disabled){
37757 this.active.hide();
37759 this.active = this.items[id];
37760 this.active.show();
37761 this.fireEvent("tabchange", this, this.active);
37767 * Gets the active {@link Roo.TabPanelItem}.
37768 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37770 getActiveTab : function(){
37771 return this.active;
37775 * Updates the tab body element to fit the height of the container element
37776 * for overflow scrolling
37777 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37779 syncHeight : function(targetHeight){
37780 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37781 var bm = this.bodyEl.getMargins();
37782 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37783 this.bodyEl.setHeight(newHeight);
37787 onResize : function(){
37788 if(this.monitorResize){
37789 this.autoSizeTabs();
37794 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37796 beginUpdate : function(){
37797 this.updating = true;
37801 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37803 endUpdate : function(){
37804 this.updating = false;
37805 this.autoSizeTabs();
37809 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37811 autoSizeTabs : function(){
37812 var count = this.items.length;
37813 var vcount = count - this.hiddenCount;
37814 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37817 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37818 var availWidth = Math.floor(w / vcount);
37819 var b = this.stripBody;
37820 if(b.getWidth() > w){
37821 var tabs = this.items;
37822 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37823 if(availWidth < this.minTabWidth){
37824 /*if(!this.sleft){ // incomplete scrolling code
37825 this.createScrollButtons();
37828 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37831 if(this.currentTabWidth < this.preferredTabWidth){
37832 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37838 * Returns the number of tabs in this TabPanel.
37841 getCount : function(){
37842 return this.items.length;
37846 * Resizes all the tabs to the passed width
37847 * @param {Number} The new width
37849 setTabWidth : function(width){
37850 this.currentTabWidth = width;
37851 for(var i = 0, len = this.items.length; i < len; i++) {
37852 if(!this.items[i].isHidden()) {
37853 this.items[i].setWidth(width);
37859 * Destroys this TabPanel
37860 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37862 destroy : function(removeEl){
37863 Roo.EventManager.removeResizeListener(this.onResize, this);
37864 for(var i = 0, len = this.items.length; i < len; i++){
37865 this.items[i].purgeListeners();
37867 if(removeEl === true){
37868 this.el.update("");
37873 createStrip : function(container)
37875 var strip = document.createElement("nav");
37876 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37877 container.appendChild(strip);
37881 createStripList : function(strip)
37883 // div wrapper for retard IE
37884 // returns the "tr" element.
37885 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37886 //'<div class="x-tabs-strip-wrap">'+
37887 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37888 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37889 return strip.firstChild; //.firstChild.firstChild.firstChild;
37891 createBody : function(container)
37893 var body = document.createElement("div");
37894 Roo.id(body, "tab-body");
37895 //Roo.fly(body).addClass("x-tabs-body");
37896 Roo.fly(body).addClass("tab-content");
37897 container.appendChild(body);
37900 createItemBody :function(bodyEl, id){
37901 var body = Roo.getDom(id);
37903 body = document.createElement("div");
37906 //Roo.fly(body).addClass("x-tabs-item-body");
37907 Roo.fly(body).addClass("tab-pane");
37908 bodyEl.insertBefore(body, bodyEl.firstChild);
37912 createStripElements : function(stripEl, text, closable, tpl)
37914 var td = document.createElement("li"); // was td..
37917 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37920 stripEl.appendChild(td);
37922 td.className = "x-tabs-closable";
37923 if(!this.closeTpl){
37924 this.closeTpl = new Roo.Template(
37925 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37926 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37927 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37930 var el = this.closeTpl.overwrite(td, {"text": text});
37931 var close = el.getElementsByTagName("div")[0];
37932 var inner = el.getElementsByTagName("em")[0];
37933 return {"el": el, "close": close, "inner": inner};
37936 // not sure what this is..
37937 // if(!this.tabTpl){
37938 //this.tabTpl = new Roo.Template(
37939 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37940 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37942 // this.tabTpl = new Roo.Template(
37943 // '<a href="#">' +
37944 // '<span unselectable="on"' +
37945 // (this.disableTooltips ? '' : ' title="{text}"') +
37946 // ' >{text}</span></a>'
37952 var template = tpl || this.tabTpl || false;
37956 template = new Roo.Template(
37958 '<span unselectable="on"' +
37959 (this.disableTooltips ? '' : ' title="{text}"') +
37960 ' >{text}</span></a>'
37964 switch (typeof(template)) {
37968 template = new Roo.Template(template);
37974 var el = template.overwrite(td, {"text": text});
37976 var inner = el.getElementsByTagName("span")[0];
37978 return {"el": el, "inner": inner};
37986 * @class Roo.TabPanelItem
37987 * @extends Roo.util.Observable
37988 * Represents an individual item (tab plus body) in a TabPanel.
37989 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37990 * @param {String} id The id of this TabPanelItem
37991 * @param {String} text The text for the tab of this TabPanelItem
37992 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37994 Roo.bootstrap.panel.TabItem = function(config){
37996 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37997 * @type Roo.TabPanel
37999 this.tabPanel = config.panel;
38001 * The id for this TabPanelItem
38004 this.id = config.id;
38006 this.disabled = false;
38008 this.text = config.text;
38010 this.loaded = false;
38011 this.closable = config.closable;
38014 * The body element for this TabPanelItem.
38015 * @type Roo.Element
38017 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38018 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38019 this.bodyEl.setStyle("display", "block");
38020 this.bodyEl.setStyle("zoom", "1");
38021 //this.hideAction();
38023 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38025 this.el = Roo.get(els.el);
38026 this.inner = Roo.get(els.inner, true);
38027 this.textEl = Roo.get(this.el.dom.firstChild, true);
38028 this.pnode = Roo.get(els.el.parentNode, true);
38029 // this.el.on("mousedown", this.onTabMouseDown, this);
38030 this.el.on("click", this.onTabClick, this);
38032 if(config.closable){
38033 var c = Roo.get(els.close, true);
38034 c.dom.title = this.closeText;
38035 c.addClassOnOver("close-over");
38036 c.on("click", this.closeClick, this);
38042 * Fires when this tab becomes the active tab.
38043 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38044 * @param {Roo.TabPanelItem} this
38048 * @event beforeclose
38049 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38050 * @param {Roo.TabPanelItem} this
38051 * @param {Object} e Set cancel to true on this object to cancel the close.
38053 "beforeclose": true,
38056 * Fires when this tab is closed.
38057 * @param {Roo.TabPanelItem} this
38061 * @event deactivate
38062 * Fires when this tab is no longer the active tab.
38063 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38064 * @param {Roo.TabPanelItem} this
38066 "deactivate" : true
38068 this.hidden = false;
38070 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38073 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38075 purgeListeners : function(){
38076 Roo.util.Observable.prototype.purgeListeners.call(this);
38077 this.el.removeAllListeners();
38080 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38083 this.pnode.addClass("active");
38086 this.tabPanel.stripWrap.repaint();
38088 this.fireEvent("activate", this.tabPanel, this);
38092 * Returns true if this tab is the active tab.
38093 * @return {Boolean}
38095 isActive : function(){
38096 return this.tabPanel.getActiveTab() == this;
38100 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38103 this.pnode.removeClass("active");
38105 this.fireEvent("deactivate", this.tabPanel, this);
38108 hideAction : function(){
38109 this.bodyEl.hide();
38110 this.bodyEl.setStyle("position", "absolute");
38111 this.bodyEl.setLeft("-20000px");
38112 this.bodyEl.setTop("-20000px");
38115 showAction : function(){
38116 this.bodyEl.setStyle("position", "relative");
38117 this.bodyEl.setTop("");
38118 this.bodyEl.setLeft("");
38119 this.bodyEl.show();
38123 * Set the tooltip for the tab.
38124 * @param {String} tooltip The tab's tooltip
38126 setTooltip : function(text){
38127 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38128 this.textEl.dom.qtip = text;
38129 this.textEl.dom.removeAttribute('title');
38131 this.textEl.dom.title = text;
38135 onTabClick : function(e){
38136 e.preventDefault();
38137 this.tabPanel.activate(this.id);
38140 onTabMouseDown : function(e){
38141 e.preventDefault();
38142 this.tabPanel.activate(this.id);
38145 getWidth : function(){
38146 return this.inner.getWidth();
38149 setWidth : function(width){
38150 var iwidth = width - this.pnode.getPadding("lr");
38151 this.inner.setWidth(iwidth);
38152 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38153 this.pnode.setWidth(width);
38157 * Show or hide the tab
38158 * @param {Boolean} hidden True to hide or false to show.
38160 setHidden : function(hidden){
38161 this.hidden = hidden;
38162 this.pnode.setStyle("display", hidden ? "none" : "");
38166 * Returns true if this tab is "hidden"
38167 * @return {Boolean}
38169 isHidden : function(){
38170 return this.hidden;
38174 * Returns the text for this tab
38177 getText : function(){
38181 autoSize : function(){
38182 //this.el.beginMeasure();
38183 this.textEl.setWidth(1);
38185 * #2804 [new] Tabs in Roojs
38186 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38188 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38189 //this.el.endMeasure();
38193 * Sets the text for the tab (Note: this also sets the tooltip text)
38194 * @param {String} text The tab's text and tooltip
38196 setText : function(text){
38198 this.textEl.update(text);
38199 this.setTooltip(text);
38200 //if(!this.tabPanel.resizeTabs){
38201 // this.autoSize();
38205 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38207 activate : function(){
38208 this.tabPanel.activate(this.id);
38212 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38214 disable : function(){
38215 if(this.tabPanel.active != this){
38216 this.disabled = true;
38217 this.pnode.addClass("disabled");
38222 * Enables this TabPanelItem if it was previously disabled.
38224 enable : function(){
38225 this.disabled = false;
38226 this.pnode.removeClass("disabled");
38230 * Sets the content for this TabPanelItem.
38231 * @param {String} content The content
38232 * @param {Boolean} loadScripts true to look for and load scripts
38234 setContent : function(content, loadScripts){
38235 this.bodyEl.update(content, loadScripts);
38239 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38240 * @return {Roo.UpdateManager} The UpdateManager
38242 getUpdateManager : function(){
38243 return this.bodyEl.getUpdateManager();
38247 * Set a URL to be used to load the content for this TabPanelItem.
38248 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38249 * @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)
38250 * @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)
38251 * @return {Roo.UpdateManager} The UpdateManager
38253 setUrl : function(url, params, loadOnce){
38254 if(this.refreshDelegate){
38255 this.un('activate', this.refreshDelegate);
38257 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38258 this.on("activate", this.refreshDelegate);
38259 return this.bodyEl.getUpdateManager();
38263 _handleRefresh : function(url, params, loadOnce){
38264 if(!loadOnce || !this.loaded){
38265 var updater = this.bodyEl.getUpdateManager();
38266 updater.update(url, params, this._setLoaded.createDelegate(this));
38271 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38272 * Will fail silently if the setUrl method has not been called.
38273 * This does not activate the panel, just updates its content.
38275 refresh : function(){
38276 if(this.refreshDelegate){
38277 this.loaded = false;
38278 this.refreshDelegate();
38283 _setLoaded : function(){
38284 this.loaded = true;
38288 closeClick : function(e){
38291 this.fireEvent("beforeclose", this, o);
38292 if(o.cancel !== true){
38293 this.tabPanel.removeTab(this.id);
38297 * The text displayed in the tooltip for the close icon.
38300 closeText : "Close this tab"
38303 * This script refer to:
38304 * Title: International Telephone Input
38305 * Author: Jack O'Connor
38306 * Code version: v12.1.12
38307 * Availability: https://github.com/jackocnr/intl-tel-input.git
38310 Roo.bootstrap.PhoneInputData = function() {
38313 "Afghanistan (افغانستان)",
38318 "Albania (Shqipëri)",
38323 "Algeria (الجزائر)",
38348 "Antigua and Barbuda",
38358 "Armenia (Հայաստան)",
38374 "Austria (Österreich)",
38379 "Azerbaijan (Azərbaycan)",
38389 "Bahrain (البحرين)",
38394 "Bangladesh (বাংলাদেশ)",
38404 "Belarus (Беларусь)",
38409 "Belgium (België)",
38439 "Bosnia and Herzegovina (Босна и Херцеговина)",
38454 "British Indian Ocean Territory",
38459 "British Virgin Islands",
38469 "Bulgaria (България)",
38479 "Burundi (Uburundi)",
38484 "Cambodia (កម្ពុជា)",
38489 "Cameroon (Cameroun)",
38498 ["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"]
38501 "Cape Verde (Kabu Verdi)",
38506 "Caribbean Netherlands",
38517 "Central African Republic (République centrafricaine)",
38537 "Christmas Island",
38543 "Cocos (Keeling) Islands",
38554 "Comoros (جزر القمر)",
38559 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38564 "Congo (Republic) (Congo-Brazzaville)",
38584 "Croatia (Hrvatska)",
38605 "Czech Republic (Česká republika)",
38610 "Denmark (Danmark)",
38625 "Dominican Republic (República Dominicana)",
38629 ["809", "829", "849"]
38647 "Equatorial Guinea (Guinea Ecuatorial)",
38667 "Falkland Islands (Islas Malvinas)",
38672 "Faroe Islands (Føroyar)",
38693 "French Guiana (Guyane française)",
38698 "French Polynesia (Polynésie française)",
38713 "Georgia (საქართველო)",
38718 "Germany (Deutschland)",
38738 "Greenland (Kalaallit Nunaat)",
38775 "Guinea-Bissau (Guiné Bissau)",
38800 "Hungary (Magyarország)",
38805 "Iceland (Ísland)",
38825 "Iraq (العراق)",
38841 "Israel (ישראל)",
38868 "Jordan (الأردن)",
38873 "Kazakhstan (Казахстан)",
38894 "Kuwait (الكويت)",
38899 "Kyrgyzstan (Кыргызстан)",
38909 "Latvia (Latvija)",
38914 "Lebanon (لبنان)",
38929 "Libya (ليبيا)",
38939 "Lithuania (Lietuva)",
38954 "Macedonia (FYROM) (Македонија)",
38959 "Madagascar (Madagasikara)",
38989 "Marshall Islands",
38999 "Mauritania (موريتانيا)",
39004 "Mauritius (Moris)",
39025 "Moldova (Republica Moldova)",
39035 "Mongolia (Монгол)",
39040 "Montenegro (Crna Gora)",
39050 "Morocco (المغرب)",
39056 "Mozambique (Moçambique)",
39061 "Myanmar (Burma) (မြန်မာ)",
39066 "Namibia (Namibië)",
39081 "Netherlands (Nederland)",
39086 "New Caledonia (Nouvelle-Calédonie)",
39121 "North Korea (조선 민주주의 인민 공화국)",
39126 "Northern Mariana Islands",
39142 "Pakistan (پاکستان)",
39152 "Palestine (فلسطين)",
39162 "Papua New Guinea",
39204 "Réunion (La Réunion)",
39210 "Romania (România)",
39226 "Saint Barthélemy",
39237 "Saint Kitts and Nevis",
39247 "Saint Martin (Saint-Martin (partie française))",
39253 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39258 "Saint Vincent and the Grenadines",
39273 "São Tomé and Príncipe (São Tomé e Príncipe)",
39278 "Saudi Arabia (المملكة العربية السعودية)",
39283 "Senegal (Sénégal)",
39313 "Slovakia (Slovensko)",
39318 "Slovenia (Slovenija)",
39328 "Somalia (Soomaaliya)",
39338 "South Korea (대한민국)",
39343 "South Sudan (جنوب السودان)",
39353 "Sri Lanka (ශ්රී ලංකාව)",
39358 "Sudan (السودان)",
39368 "Svalbard and Jan Mayen",
39379 "Sweden (Sverige)",
39384 "Switzerland (Schweiz)",
39389 "Syria (سوريا)",
39434 "Trinidad and Tobago",
39439 "Tunisia (تونس)",
39444 "Turkey (Türkiye)",
39454 "Turks and Caicos Islands",
39464 "U.S. Virgin Islands",
39474 "Ukraine (Україна)",
39479 "United Arab Emirates (الإمارات العربية المتحدة)",
39501 "Uzbekistan (Oʻzbekiston)",
39511 "Vatican City (Città del Vaticano)",
39522 "Vietnam (Việt Nam)",
39527 "Wallis and Futuna (Wallis-et-Futuna)",
39532 "Western Sahara (الصحراء الغربية)",
39538 "Yemen (اليمن)",
39562 * This script refer to:
39563 * Title: International Telephone Input
39564 * Author: Jack O'Connor
39565 * Code version: v12.1.12
39566 * Availability: https://github.com/jackocnr/intl-tel-input.git
39570 * @class Roo.bootstrap.PhoneInput
39571 * @extends Roo.bootstrap.TriggerField
39572 * An input with International dial-code selection
39574 * @cfg {String} defaultDialCode default '+852'
39575 * @cfg {Array} preferedCountries default []
39578 * Create a new PhoneInput.
39579 * @param {Object} config Configuration options
39582 Roo.bootstrap.PhoneInput = function(config) {
39583 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39586 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39588 listWidth: undefined,
39590 selectedClass: 'active',
39592 invalidClass : "has-warning",
39594 validClass: 'has-success',
39596 allowed: '0123456789',
39599 * @cfg {String} defaultDialCode The default dial code when initializing the input
39601 defaultDialCode: '+852',
39604 * @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
39606 preferedCountries: false,
39608 getAutoCreate : function()
39610 var data = Roo.bootstrap.PhoneInputData();
39611 var align = this.labelAlign || this.parentLabelAlign();
39614 this.allCountries = [];
39615 this.dialCodeMapping = [];
39617 for (var i = 0; i < data.length; i++) {
39619 this.allCountries[i] = {
39623 priority: c[3] || 0,
39624 areaCodes: c[4] || null
39626 this.dialCodeMapping[c[2]] = {
39629 priority: c[3] || 0,
39630 areaCodes: c[4] || null
39642 cls : 'form-control tel-input',
39643 autocomplete: 'new-password'
39646 var hiddenInput = {
39649 cls: 'hidden-tel-input'
39653 hiddenInput.name = this.name;
39656 if (this.disabled) {
39657 input.disabled = true;
39660 var flag_container = {
39677 cls: this.hasFeedback ? 'has-feedback' : '',
39683 cls: 'dial-code-holder',
39690 cls: 'roo-select2-container input-group',
39697 if (this.fieldLabel.length) {
39700 tooltip: 'This field is required'
39706 cls: 'control-label',
39712 html: this.fieldLabel
39715 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39721 if(this.indicatorpos == 'right') {
39722 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39729 if(align == 'left') {
39737 if(this.labelWidth > 12){
39738 label.style = "width: " + this.labelWidth + 'px';
39740 if(this.labelWidth < 13 && this.labelmd == 0){
39741 this.labelmd = this.labelWidth;
39743 if(this.labellg > 0){
39744 label.cls += ' col-lg-' + this.labellg;
39745 input.cls += ' col-lg-' + (12 - this.labellg);
39747 if(this.labelmd > 0){
39748 label.cls += ' col-md-' + this.labelmd;
39749 container.cls += ' col-md-' + (12 - this.labelmd);
39751 if(this.labelsm > 0){
39752 label.cls += ' col-sm-' + this.labelsm;
39753 container.cls += ' col-sm-' + (12 - this.labelsm);
39755 if(this.labelxs > 0){
39756 label.cls += ' col-xs-' + this.labelxs;
39757 container.cls += ' col-xs-' + (12 - this.labelxs);
39767 var settings = this;
39769 ['xs','sm','md','lg'].map(function(size){
39770 if (settings[size]) {
39771 cfg.cls += ' col-' + size + '-' + settings[size];
39775 this.store = new Roo.data.Store({
39776 proxy : new Roo.data.MemoryProxy({}),
39777 reader : new Roo.data.JsonReader({
39788 'name' : 'dialCode',
39792 'name' : 'priority',
39796 'name' : 'areaCodes',
39803 if(!this.preferedCountries) {
39804 this.preferedCountries = [
39811 var p = this.preferedCountries.reverse();
39814 for (var i = 0; i < p.length; i++) {
39815 for (var j = 0; j < this.allCountries.length; j++) {
39816 if(this.allCountries[j].iso2 == p[i]) {
39817 var t = this.allCountries[j];
39818 this.allCountries.splice(j,1);
39819 this.allCountries.unshift(t);
39825 this.store.proxy.data = {
39827 data: this.allCountries
39833 initEvents : function()
39836 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39838 this.indicator = this.indicatorEl();
39839 this.flag = this.flagEl();
39840 this.dialCodeHolder = this.dialCodeHolderEl();
39842 this.trigger = this.el.select('div.flag-box',true).first();
39843 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39848 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39849 _this.list.setWidth(lw);
39852 this.list.on('mouseover', this.onViewOver, this);
39853 this.list.on('mousemove', this.onViewMove, this);
39854 this.inputEl().on("keyup", this.onKeyUp, this);
39856 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39858 this.view = new Roo.View(this.list, this.tpl, {
39859 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39862 this.view.on('click', this.onViewClick, this);
39863 this.setValue(this.defaultDialCode);
39866 onTriggerClick : function(e)
39868 Roo.log('trigger click');
39873 if(this.isExpanded()){
39875 this.hasFocus = false;
39877 this.store.load({});
39878 this.hasFocus = true;
39883 isExpanded : function()
39885 return this.list.isVisible();
39888 collapse : function()
39890 if(!this.isExpanded()){
39894 Roo.get(document).un('mousedown', this.collapseIf, this);
39895 Roo.get(document).un('mousewheel', this.collapseIf, this);
39896 this.fireEvent('collapse', this);
39900 expand : function()
39904 if(this.isExpanded() || !this.hasFocus){
39908 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39909 this.list.setWidth(lw);
39912 this.restrictHeight();
39914 Roo.get(document).on('mousedown', this.collapseIf, this);
39915 Roo.get(document).on('mousewheel', this.collapseIf, this);
39917 this.fireEvent('expand', this);
39920 restrictHeight : function()
39922 this.list.alignTo(this.inputEl(), this.listAlign);
39923 this.list.alignTo(this.inputEl(), this.listAlign);
39926 onViewOver : function(e, t)
39928 if(this.inKeyMode){
39931 var item = this.view.findItemFromChild(t);
39934 var index = this.view.indexOf(item);
39935 this.select(index, false);
39940 onViewClick : function(view, doFocus, el, e)
39942 var index = this.view.getSelectedIndexes()[0];
39944 var r = this.store.getAt(index);
39947 this.onSelect(r, index);
39949 if(doFocus !== false && !this.blockFocus){
39950 this.inputEl().focus();
39954 onViewMove : function(e, t)
39956 this.inKeyMode = false;
39959 select : function(index, scrollIntoView)
39961 this.selectedIndex = index;
39962 this.view.select(index);
39963 if(scrollIntoView !== false){
39964 var el = this.view.getNode(index);
39966 this.list.scrollChildIntoView(el, false);
39971 createList : function()
39973 this.list = Roo.get(document.body).createChild({
39975 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39976 style: 'display:none'
39978 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39981 collapseIf : function(e)
39983 var in_combo = e.within(this.el);
39984 var in_list = e.within(this.list);
39985 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39987 if (in_combo || in_list || is_list) {
39993 onSelect : function(record, index)
39995 if(this.fireEvent('beforeselect', this, record, index) !== false){
39997 this.setFlagClass(record.data.iso2);
39998 this.setDialCode(record.data.dialCode);
39999 this.hasFocus = false;
40001 this.fireEvent('select', this, record, index);
40005 flagEl : function()
40007 var flag = this.el.select('div.flag',true).first();
40014 dialCodeHolderEl : function()
40016 var d = this.el.select('input.dial-code-holder',true).first();
40023 setDialCode : function(v)
40025 this.dialCodeHolder.dom.value = '+'+v;
40028 setFlagClass : function(n)
40030 this.flag.dom.className = 'flag '+n;
40033 getValue : function()
40035 var v = this.inputEl().getValue();
40036 if(this.dialCodeHolder) {
40037 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40042 setValue : function(v)
40044 var d = this.getDialCode(v);
40046 //invalid dial code
40047 if(v.length == 0 || !d || d.length == 0) {
40049 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40050 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40056 this.setFlagClass(this.dialCodeMapping[d].iso2);
40057 this.setDialCode(d);
40058 this.inputEl().dom.value = v.replace('+'+d,'');
40059 this.hiddenEl().dom.value = this.getValue();
40064 getDialCode : function(v = '')
40066 if (v.length == 0) {
40067 return this.dialCodeHolder.dom.value;
40071 if (v.charAt(0) != "+") {
40074 var numericChars = "";
40075 for (var i = 1; i < v.length; i++) {
40076 var c = v.charAt(i);
40079 if (this.dialCodeMapping[numericChars]) {
40080 dialCode = v.substr(1, i);
40082 if (numericChars.length == 4) {
40092 this.setValue(this.defaultDialCode);
40096 hiddenEl : function()
40098 return this.el.select('input.hidden-tel-input',true).first();
40101 onKeyUp : function(e){
40103 var k = e.getKey();
40104 var c = e.getCharCode();
40107 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40108 this.allowed.indexOf(String.fromCharCode(c)) === -1
40113 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40116 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
40120 this.setValue(this.getValue());
40125 * @class Roo.bootstrap.MoneyField
40126 * @extends Roo.bootstrap.ComboBox
40127 * Bootstrap MoneyField class
40130 * Create a new MoneyField.
40131 * @param {Object} config Configuration options
40134 Roo.bootstrap.MoneyField = function(config) {
40136 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40140 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40143 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40145 allowDecimals : true,
40147 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40149 decimalSeparator : ".",
40151 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40153 decimalPrecision : 0,
40155 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40157 allowNegative : true,
40159 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40161 minValue : Number.NEGATIVE_INFINITY,
40163 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40165 maxValue : Number.MAX_VALUE,
40167 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40169 minText : "The minimum value for this field is {0}",
40171 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40173 maxText : "The maximum value for this field is {0}",
40175 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40176 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40178 nanText : "{0} is not a valid number",
40180 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40184 * @cfg {String} defaults currency of the MoneyField
40185 * value should be in lkey
40187 defaultCurrency : false,
40189 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40191 thousandsDelimiter : false,
40201 getAutoCreate : function()
40203 var align = this.labelAlign || this.parentLabelAlign();
40215 cls : 'form-control roo-money-amount-input',
40216 autocomplete: 'new-password'
40219 var hiddenInput = {
40223 cls: 'hidden-number-input'
40227 hiddenInput.name = this.name;
40230 if (this.disabled) {
40231 input.disabled = true;
40234 var clg = 12 - this.inputlg;
40235 var cmd = 12 - this.inputmd;
40236 var csm = 12 - this.inputsm;
40237 var cxs = 12 - this.inputxs;
40241 cls : 'row roo-money-field',
40245 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40249 cls: 'roo-select2-container input-group',
40253 cls : 'form-control roo-money-currency-input',
40254 autocomplete: 'new-password',
40256 name : this.currencyName
40260 cls : 'input-group-addon',
40274 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40278 cls: this.hasFeedback ? 'has-feedback' : '',
40289 if (this.fieldLabel.length) {
40292 tooltip: 'This field is required'
40298 cls: 'control-label',
40304 html: this.fieldLabel
40307 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40313 if(this.indicatorpos == 'right') {
40314 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40321 if(align == 'left') {
40329 if(this.labelWidth > 12){
40330 label.style = "width: " + this.labelWidth + 'px';
40332 if(this.labelWidth < 13 && this.labelmd == 0){
40333 this.labelmd = this.labelWidth;
40335 if(this.labellg > 0){
40336 label.cls += ' col-lg-' + this.labellg;
40337 input.cls += ' col-lg-' + (12 - this.labellg);
40339 if(this.labelmd > 0){
40340 label.cls += ' col-md-' + this.labelmd;
40341 container.cls += ' col-md-' + (12 - this.labelmd);
40343 if(this.labelsm > 0){
40344 label.cls += ' col-sm-' + this.labelsm;
40345 container.cls += ' col-sm-' + (12 - this.labelsm);
40347 if(this.labelxs > 0){
40348 label.cls += ' col-xs-' + this.labelxs;
40349 container.cls += ' col-xs-' + (12 - this.labelxs);
40360 var settings = this;
40362 ['xs','sm','md','lg'].map(function(size){
40363 if (settings[size]) {
40364 cfg.cls += ' col-' + size + '-' + settings[size];
40371 initEvents : function()
40373 this.indicator = this.indicatorEl();
40375 this.initCurrencyEvent();
40377 this.initNumberEvent();
40380 initCurrencyEvent : function()
40383 throw "can not find store for combo";
40386 this.store = Roo.factory(this.store, Roo.data);
40387 this.store.parent = this;
40391 this.triggerEl = this.el.select('.input-group-addon', true).first();
40393 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40398 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40399 _this.list.setWidth(lw);
40402 this.list.on('mouseover', this.onViewOver, this);
40403 this.list.on('mousemove', this.onViewMove, this);
40404 this.list.on('scroll', this.onViewScroll, this);
40407 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40410 this.view = new Roo.View(this.list, this.tpl, {
40411 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40414 this.view.on('click', this.onViewClick, this);
40416 this.store.on('beforeload', this.onBeforeLoad, this);
40417 this.store.on('load', this.onLoad, this);
40418 this.store.on('loadexception', this.onLoadException, this);
40420 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40421 "up" : function(e){
40422 this.inKeyMode = true;
40426 "down" : function(e){
40427 if(!this.isExpanded()){
40428 this.onTriggerClick();
40430 this.inKeyMode = true;
40435 "enter" : function(e){
40438 if(this.fireEvent("specialkey", this, e)){
40439 this.onViewClick(false);
40445 "esc" : function(e){
40449 "tab" : function(e){
40452 if(this.fireEvent("specialkey", this, e)){
40453 this.onViewClick(false);
40461 doRelay : function(foo, bar, hname){
40462 if(hname == 'down' || this.scope.isExpanded()){
40463 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40471 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40475 initNumberEvent : function(e)
40477 this.inputEl().on("keydown" , this.fireKey, this);
40478 this.inputEl().on("focus", this.onFocus, this);
40479 this.inputEl().on("blur", this.onBlur, this);
40481 this.inputEl().relayEvent('keyup', this);
40483 if(this.indicator){
40484 this.indicator.addClass('invisible');
40487 this.originalValue = this.getValue();
40489 if(this.validationEvent == 'keyup'){
40490 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40491 this.inputEl().on('keyup', this.filterValidation, this);
40493 else if(this.validationEvent !== false){
40494 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40497 if(this.selectOnFocus){
40498 this.on("focus", this.preFocus, this);
40501 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40502 this.inputEl().on("keypress", this.filterKeys, this);
40504 this.inputEl().relayEvent('keypress', this);
40507 var allowed = "0123456789";
40509 if(this.allowDecimals){
40510 allowed += this.decimalSeparator;
40513 if(this.allowNegative){
40517 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40519 var keyPress = function(e){
40521 var k = e.getKey();
40523 var c = e.getCharCode();
40526 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40527 allowed.indexOf(String.fromCharCode(c)) === -1
40533 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40537 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40542 this.inputEl().on("keypress", keyPress, this);
40546 onTriggerClick : function(e)
40553 this.loadNext = false;
40555 if(this.isExpanded()){
40560 this.hasFocus = true;
40562 if(this.triggerAction == 'all') {
40563 this.doQuery(this.allQuery, true);
40567 this.doQuery(this.getRawValue());
40570 getCurrency : function()
40572 var v = this.currencyEl().getValue();
40577 restrictHeight : function()
40579 this.list.alignTo(this.currencyEl(), this.listAlign);
40580 this.list.alignTo(this.currencyEl(), this.listAlign);
40583 onViewClick : function(view, doFocus, el, e)
40585 var index = this.view.getSelectedIndexes()[0];
40587 var r = this.store.getAt(index);
40590 this.onSelect(r, index);
40594 onSelect : function(record, index){
40596 if(this.fireEvent('beforeselect', this, record, index) !== false){
40598 this.setFromCurrencyData(index > -1 ? record.data : false);
40602 this.fireEvent('select', this, record, index);
40606 setFromCurrencyData : function(o)
40610 this.lastCurrency = o;
40612 if (this.currencyField) {
40613 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40615 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40618 this.lastSelectionText = currency;
40620 //setting default currency
40621 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40622 this.setCurrency(this.defaultCurrency);
40626 this.setCurrency(currency);
40629 setFromData : function(o)
40633 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40635 this.setFromCurrencyData(c);
40640 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40642 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40645 this.setValue(value);
40649 setCurrency : function(v)
40651 this.currencyValue = v;
40654 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40659 setValue : function(v)
40661 v = this.fixPrecision(v);
40663 v = String(v).replace(".", this.decimalSeparator);
40669 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40671 this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
40672 this.thousandsDelimiter || ','
40675 if(this.allowBlank && !v) {
40676 this.inputEl().dom.value = '';
40683 getRawValue : function()
40685 var v = this.inputEl().getValue();
40690 getValue : function()
40692 return this.fixPrecision(this.parseValue(this.getRawValue()));
40695 parseValue : function(value)
40697 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40698 return isNaN(value) ? '' : value;
40701 fixPrecision : function(value)
40703 var nan = isNaN(value);
40705 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40706 return nan ? '' : value;
40709 return parseFloat(value).toFixed(this.decimalPrecision);
40712 decimalPrecisionFcn : function(v)
40714 return Math.floor(v);
40717 validateValue : function(value)
40719 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40723 var num = this.parseValue(value);
40726 this.markInvalid(String.format(this.nanText, value));
40730 if(num < this.minValue){
40731 this.markInvalid(String.format(this.minText, this.minValue));
40735 if(num > this.maxValue){
40736 this.markInvalid(String.format(this.maxText, this.maxValue));
40743 validate : function()
40745 if(this.disabled || this.allowBlank){
40750 var currency = this.getCurrency();
40752 if(this.validateValue(this.getRawValue()) && currency.length){
40757 this.markInvalid();
40761 getName: function()
40766 beforeBlur : function()
40772 var v = this.parseValue(this.getRawValue());
40779 onBlur : function()
40783 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40784 //this.el.removeClass(this.focusClass);
40787 this.hasFocus = false;
40789 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40793 var v = this.getValue();
40795 if(String(v) !== String(this.startValue)){
40796 this.fireEvent('change', this, v, this.startValue);
40799 this.fireEvent("blur", this);
40802 inputEl : function()
40804 return this.el.select('.roo-money-amount-input', true).first();
40807 currencyEl : function()
40809 return this.el.select('.roo-money-currency-input', true).first();
40812 hiddenEl : function()
40814 return this.el.select('input.hidden-number-input',true).first();