4 * base class for bootstrap elements.
8 Roo.bootstrap = Roo.bootstrap || {};
10 * @class Roo.bootstrap.Component
11 * @extends Roo.Component
12 * Bootstrap Component base class
13 * @cfg {String} cls css class
14 * @cfg {String} style any extra css
15 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
16 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
17 * @cfg {string} dataId cutomer id
18 * @cfg {string} name Specifies name attribute
19 * @cfg {string} tooltip Text for the tooltip
20 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
23 * Do not use directly - it does not do anything..
24 * @param {Object} config The config object
29 Roo.bootstrap.Component = function(config){
30 Roo.bootstrap.Component.superclass.constructor.call(this, config);
34 * @event childrenrendered
35 * Fires when the children have been rendered..
36 * @param {Roo.bootstrap.Component} this
38 "childrenrendered" : true
47 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
50 allowDomMove : false, // to stop relocations in parent onRender...
60 * Initialize Events for the element
62 initEvents : function() { },
68 can_build_overlaid : true,
70 container_method : false,
77 // returns the parent component..
78 return Roo.ComponentMgr.get(this.parentId)
84 onRender : function(ct, position)
86 // Roo.log("Call onRender: " + this.xtype);
88 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
91 if (this.el.attr('xtype')) {
92 this.el.attr('xtypex', this.el.attr('xtype'));
93 this.el.dom.removeAttribute('xtype');
103 var cfg = Roo.apply({}, this.getAutoCreate());
105 cfg.id = this.id || Roo.id();
107 // fill in the extra attributes
108 if (this.xattr && typeof(this.xattr) =='object') {
109 for (var i in this.xattr) {
110 cfg[i] = this.xattr[i];
115 cfg.dataId = this.dataId;
119 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
122 if (this.style) { // fixme needs to support more complex style data.
123 cfg.style = this.style;
127 cfg.name = this.name;
130 this.el = ct.createChild(cfg, position);
133 this.tooltipEl().attr('tooltip', this.tooltip);
136 if(this.tabIndex !== undefined){
137 this.el.dom.setAttribute('tabIndex', this.tabIndex);
144 * Fetch the element to add children to
145 * @return {Roo.Element} defaults to this.el
147 getChildContainer : function()
152 * Fetch the element to display the tooltip on.
153 * @return {Roo.Element} defaults to this.el
155 tooltipEl : function()
160 addxtype : function(tree,cntr)
164 cn = Roo.factory(tree);
165 //Roo.log(['addxtype', cn]);
167 cn.parentType = this.xtype; //??
168 cn.parentId = this.id;
170 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
171 if (typeof(cn.container_method) == 'string') {
172 cntr = cn.container_method;
176 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
178 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
180 var build_from_html = Roo.XComponent.build_from_html;
182 var is_body = (tree.xtype == 'Body') ;
184 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
186 var self_cntr_el = Roo.get(this[cntr](false));
188 // do not try and build conditional elements
189 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
193 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
194 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
195 return this.addxtypeChild(tree,cntr, is_body);
198 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
201 return this.addxtypeChild(Roo.apply({}, tree),cntr);
204 Roo.log('skipping render');
210 if (!build_from_html) {
214 // this i think handles overlaying multiple children of the same type
215 // with the sam eelement.. - which might be buggy..
217 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
223 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
227 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
234 addxtypeChild : function (tree, cntr, is_body)
236 Roo.debug && Roo.log('addxtypeChild:' + cntr);
238 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
241 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
242 (typeof(tree['flexy:foreach']) != 'undefined');
246 skip_children = false;
247 // render the element if it's not BODY.
250 cn = Roo.factory(tree);
252 cn.parentType = this.xtype; //??
253 cn.parentId = this.id;
255 var build_from_html = Roo.XComponent.build_from_html;
258 // does the container contain child eleemnts with 'xtype' attributes.
259 // that match this xtype..
260 // note - when we render we create these as well..
261 // so we should check to see if body has xtype set.
262 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
264 var self_cntr_el = Roo.get(this[cntr](false));
265 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
267 //Roo.log(Roo.XComponent.build_from_html);
268 //Roo.log("got echild:");
271 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
272 // and are not displayed -this causes this to use up the wrong element when matching.
273 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
276 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
277 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
283 //echild.dom.removeAttribute('xtype');
285 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
286 Roo.debug && Roo.log(self_cntr_el);
287 Roo.debug && Roo.log(echild);
288 Roo.debug && Roo.log(cn);
294 // if object has flexy:if - then it may or may not be rendered.
295 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
296 // skip a flexy if element.
297 Roo.debug && Roo.log('skipping render');
298 Roo.debug && Roo.log(tree);
300 Roo.debug && Roo.log('skipping all children');
301 skip_children = true;
306 // actually if flexy:foreach is found, we really want to create
307 // multiple copies here...
309 //Roo.log(this[cntr]());
310 // some elements do not have render methods.. like the layouts...
311 cn.render && cn.render(this[cntr](true));
313 // then add the element..
321 if (typeof (tree.menu) != 'undefined') {
322 tree.menu.parentType = cn.xtype;
323 tree.menu.triggerEl = cn.el;
324 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
328 if (!tree.items || !tree.items.length) {
330 //Roo.log(["no children", this]);
335 var items = tree.items;
338 //Roo.log(items.length);
340 if (!skip_children) {
341 for(var i =0;i < items.length;i++) {
342 // Roo.log(['add child', items[i]]);
343 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
349 //Roo.log("fire childrenrendered");
351 cn.fireEvent('childrenrendered', this);
356 * Show a component - removes 'hidden' class
361 this.el.removeClass('hidden');
365 * Hide a component - adds 'hidden' class
369 if (this.el && !this.el.hasClass('hidden')) {
370 this.el.addClass('hidden');
383 * @class Roo.bootstrap.Body
384 * @extends Roo.bootstrap.Component
385 * Bootstrap Body class
389 * @param {Object} config The config object
392 Roo.bootstrap.Body = function(config){
394 config = config || {};
396 Roo.bootstrap.Body.superclass.constructor.call(this, config);
397 this.el = Roo.get(config.el ? config.el : document.body );
398 if (this.cls && this.cls.length) {
399 Roo.get(document.body).addClass(this.cls);
403 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
405 is_body : true,// just to make sure it's constructed?
410 onRender : function(ct, position)
412 /* Roo.log("Roo.bootstrap.Body - onRender");
413 if (this.cls && this.cls.length) {
414 Roo.get(document.body).addClass(this.cls);
433 * @class Roo.bootstrap.ButtonGroup
434 * @extends Roo.bootstrap.Component
435 * Bootstrap ButtonGroup class
436 * @cfg {String} size lg | sm | xs (default empty normal)
437 * @cfg {String} align vertical | justified (default none)
438 * @cfg {String} direction up | down (default down)
439 * @cfg {Boolean} toolbar false | true
440 * @cfg {Boolean} btn true | false
445 * @param {Object} config The config object
448 Roo.bootstrap.ButtonGroup = function(config){
449 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
452 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
460 getAutoCreate : function(){
466 cfg.html = this.html || cfg.html;
477 if (['vertical','justified'].indexOf(this.align)!==-1) {
478 cfg.cls = 'btn-group-' + this.align;
480 if (this.align == 'justified') {
481 console.log(this.items);
485 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
486 cfg.cls += ' btn-group-' + this.size;
489 if (this.direction == 'up') {
490 cfg.cls += ' dropup' ;
506 * @class Roo.bootstrap.Button
507 * @extends Roo.bootstrap.Component
508 * Bootstrap Button class
509 * @cfg {String} html The button content
510 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
511 * @cfg {String} size ( lg | sm | xs)
512 * @cfg {String} tag ( a | input | submit)
513 * @cfg {String} href empty or href
514 * @cfg {Boolean} disabled default false;
515 * @cfg {Boolean} isClose default false;
516 * @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)
517 * @cfg {String} badge text for badge
518 * @cfg {String} theme default
519 * @cfg {Boolean} inverse
520 * @cfg {Boolean} toggle
521 * @cfg {String} ontext text for on toggle state
522 * @cfg {String} offtext text for off toggle state
523 * @cfg {Boolean} defaulton
524 * @cfg {Boolean} preventDefault default true
525 * @cfg {Boolean} removeClass remove the standard class..
526 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
529 * Create a new button
530 * @param {Object} config The config object
534 Roo.bootstrap.Button = function(config){
535 Roo.bootstrap.Button.superclass.constructor.call(this, config);
536 this.weightClass = ["btn-default",
548 * When a butotn is pressed
549 * @param {Roo.bootstrap.Button} this
550 * @param {Roo.EventObject} e
555 * After the button has been toggles
556 * @param {Roo.EventObject} e
557 * @param {boolean} pressed (also available as button.pressed)
563 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
581 preventDefault: true,
590 getAutoCreate : function(){
598 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
599 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
604 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
606 if (this.toggle == true) {
609 cls: 'slider-frame roo-button',
614 'data-off-text':'OFF',
615 cls: 'slider-button',
621 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
622 cfg.cls += ' '+this.weight;
631 cfg["aria-hidden"] = true;
633 cfg.html = "×";
639 if (this.theme==='default') {
640 cfg.cls = 'btn roo-button';
642 //if (this.parentType != 'Navbar') {
643 this.weight = this.weight.length ? this.weight : 'default';
645 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
647 cfg.cls += ' btn-' + this.weight;
649 } else if (this.theme==='glow') {
652 cfg.cls = 'btn-glow roo-button';
654 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
656 cfg.cls += ' ' + this.weight;
662 this.cls += ' inverse';
667 cfg.cls += ' active';
671 cfg.disabled = 'disabled';
675 Roo.log('changing to ul' );
677 this.glyphicon = 'caret';
680 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
682 //gsRoo.log(this.parentType);
683 if (this.parentType === 'Navbar' && !this.parent().bar) {
684 Roo.log('changing to li?');
693 href : this.href || '#'
696 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
697 cfg.cls += ' dropdown';
704 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
706 if (this.glyphicon) {
707 cfg.html = ' ' + cfg.html;
712 cls: 'glyphicon glyphicon-' + this.glyphicon
722 // cfg.cls='btn roo-button';
726 var value = cfg.html;
731 cls: 'glyphicon glyphicon-' + this.glyphicon,
750 cfg.cls += ' dropdown';
751 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
754 if (cfg.tag !== 'a' && this.href !== '') {
755 throw "Tag must be a to set href.";
756 } else if (this.href.length > 0) {
757 cfg.href = this.href;
760 if(this.removeClass){
765 cfg.target = this.target;
770 initEvents: function() {
771 // Roo.log('init events?');
772 // Roo.log(this.el.dom);
775 if (typeof (this.menu) != 'undefined') {
776 this.menu.parentType = this.xtype;
777 this.menu.triggerEl = this.el;
778 this.addxtype(Roo.apply({}, this.menu));
782 if (this.el.hasClass('roo-button')) {
783 this.el.on('click', this.onClick, this);
785 this.el.select('.roo-button').on('click', this.onClick, this);
788 if(this.removeClass){
789 this.el.on('click', this.onClick, this);
792 this.el.enableDisplayMode();
795 onClick : function(e)
802 Roo.log('button on click ');
803 if(this.preventDefault){
806 if (this.pressed === true || this.pressed === false) {
807 this.pressed = !this.pressed;
808 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
809 this.fireEvent('toggle', this, e, this.pressed);
813 this.fireEvent('click', this, e);
817 * Enables this button
821 this.disabled = false;
822 this.el.removeClass('disabled');
826 * Disable this button
830 this.disabled = true;
831 this.el.addClass('disabled');
834 * sets the active state on/off,
835 * @param {Boolean} state (optional) Force a particular state
837 setActive : function(v) {
839 this.el[v ? 'addClass' : 'removeClass']('active');
842 * toggles the current active state
844 toggleActive : function()
846 var active = this.el.hasClass('active');
847 this.setActive(!active);
851 setText : function(str)
853 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
857 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
868 setWeight : function(str)
870 this.el.removeClass(this.weightClass);
871 this.el.addClass('btn-' + str);
885 * @class Roo.bootstrap.Column
886 * @extends Roo.bootstrap.Component
887 * Bootstrap Column class
888 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
889 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
890 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
891 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
892 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
893 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
894 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
895 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
898 * @cfg {Boolean} hidden (true|false) hide the element
899 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
900 * @cfg {String} fa (ban|check|...) font awesome icon
901 * @cfg {Number} fasize (1|2|....) font awsome size
903 * @cfg {String} icon (info-sign|check|...) glyphicon name
905 * @cfg {String} html content of column.
908 * Create a new Column
909 * @param {Object} config The config object
912 Roo.bootstrap.Column = function(config){
913 Roo.bootstrap.Column.superclass.constructor.call(this, config);
916 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
934 getAutoCreate : function(){
935 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
943 ['xs','sm','md','lg'].map(function(size){
944 //Roo.log( size + ':' + settings[size]);
946 if (settings[size+'off'] !== false) {
947 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
950 if (settings[size] === false) {
954 if (!settings[size]) { // 0 = hidden
955 cfg.cls += ' hidden-' + size;
958 cfg.cls += ' col-' + size + '-' + settings[size];
963 cfg.cls += ' hidden';
966 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
967 cfg.cls +=' alert alert-' + this.alert;
971 if (this.html.length) {
972 cfg.html = this.html;
976 if (this.fasize > 1) {
977 fasize = ' fa-' + this.fasize + 'x';
979 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
984 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1003 * @class Roo.bootstrap.Container
1004 * @extends Roo.bootstrap.Component
1005 * Bootstrap Container class
1006 * @cfg {Boolean} jumbotron is it a jumbotron element
1007 * @cfg {String} html content of element
1008 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1009 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1010 * @cfg {String} header content of header (for panel)
1011 * @cfg {String} footer content of footer (for panel)
1012 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1013 * @cfg {String} tag (header|aside|section) type of HTML tag.
1014 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1015 * @cfg {String} fa font awesome icon
1016 * @cfg {String} icon (info-sign|check|...) glyphicon name
1017 * @cfg {Boolean} hidden (true|false) hide the element
1018 * @cfg {Boolean} expandable (true|false) default false
1019 * @cfg {Boolean} expanded (true|false) default true
1020 * @cfg {String} rheader contet on the right of header
1021 * @cfg {Boolean} clickable (true|false) default false
1025 * Create a new Container
1026 * @param {Object} config The config object
1029 Roo.bootstrap.Container = function(config){
1030 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1036 * After the panel has been expand
1038 * @param {Roo.bootstrap.Container} this
1043 * After the panel has been collapsed
1045 * @param {Roo.bootstrap.Container} this
1050 * When a element is chick
1051 * @param {Roo.bootstrap.Container} this
1052 * @param {Roo.EventObject} e
1058 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1076 getChildContainer : function() {
1082 if (this.panel.length) {
1083 return this.el.select('.panel-body',true).first();
1090 getAutoCreate : function(){
1093 tag : this.tag || 'div',
1097 if (this.jumbotron) {
1098 cfg.cls = 'jumbotron';
1103 // - this is applied by the parent..
1105 // cfg.cls = this.cls + '';
1108 if (this.sticky.length) {
1110 var bd = Roo.get(document.body);
1111 if (!bd.hasClass('bootstrap-sticky')) {
1112 bd.addClass('bootstrap-sticky');
1113 Roo.select('html',true).setStyle('height', '100%');
1116 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1120 if (this.well.length) {
1121 switch (this.well) {
1124 cfg.cls +=' well well-' +this.well;
1133 cfg.cls += ' hidden';
1137 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1138 cfg.cls +=' alert alert-' + this.alert;
1143 if (this.panel.length) {
1144 cfg.cls += ' panel panel-' + this.panel;
1146 if (this.header.length) {
1150 if(this.expandable){
1152 cfg.cls = cfg.cls + ' expandable';
1156 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1164 cls : 'panel-title',
1165 html : (this.expandable ? ' ' : '') + this.header
1169 cls: 'panel-header-right',
1175 cls : 'panel-heading',
1176 style : this.expandable ? 'cursor: pointer' : '',
1184 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1189 if (this.footer.length) {
1191 cls : 'panel-footer',
1200 body.html = this.html || cfg.html;
1201 // prefix with the icons..
1203 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1206 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1211 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1212 cfg.cls = 'container';
1218 initEvents: function()
1220 if(this.expandable){
1221 var headerEl = this.headerEl();
1224 headerEl.on('click', this.onToggleClick, this);
1229 this.el.on('click', this.onClick, this);
1234 onToggleClick : function()
1236 var headerEl = this.headerEl();
1252 if(this.fireEvent('expand', this)) {
1254 this.expanded = true;
1256 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1258 this.el.select('.panel-body',true).first().removeClass('hide');
1260 var toggleEl = this.toggleEl();
1266 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1271 collapse : function()
1273 if(this.fireEvent('collapse', this)) {
1275 this.expanded = false;
1277 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1278 this.el.select('.panel-body',true).first().addClass('hide');
1280 var toggleEl = this.toggleEl();
1286 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1290 toggleEl : function()
1292 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1296 return this.el.select('.panel-heading .fa',true).first();
1299 headerEl : function()
1301 if(!this.el || !this.panel.length || !this.header.length){
1305 return this.el.select('.panel-heading',true).first()
1310 if(!this.el || !this.panel.length){
1314 return this.el.select('.panel-body',true).first()
1317 titleEl : function()
1319 if(!this.el || !this.panel.length || !this.header.length){
1323 return this.el.select('.panel-title',true).first();
1326 setTitle : function(v)
1328 var titleEl = this.titleEl();
1334 titleEl.dom.innerHTML = v;
1337 getTitle : function()
1340 var titleEl = this.titleEl();
1346 return titleEl.dom.innerHTML;
1349 setRightTitle : function(v)
1351 var t = this.el.select('.panel-header-right',true).first();
1357 t.dom.innerHTML = v;
1360 onClick : function(e)
1364 this.fireEvent('click', this, e);
1378 * @class Roo.bootstrap.Img
1379 * @extends Roo.bootstrap.Component
1380 * Bootstrap Img class
1381 * @cfg {Boolean} imgResponsive false | true
1382 * @cfg {String} border rounded | circle | thumbnail
1383 * @cfg {String} src image source
1384 * @cfg {String} alt image alternative text
1385 * @cfg {String} href a tag href
1386 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1387 * @cfg {String} xsUrl xs image source
1388 * @cfg {String} smUrl sm image source
1389 * @cfg {String} mdUrl md image source
1390 * @cfg {String} lgUrl lg image source
1393 * Create a new Input
1394 * @param {Object} config The config object
1397 Roo.bootstrap.Img = function(config){
1398 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1404 * The img click event for the img.
1405 * @param {Roo.EventObject} e
1411 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1413 imgResponsive: true,
1423 getAutoCreate : function()
1425 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1426 return this.createSingleImg();
1431 cls: 'roo-image-responsive-group',
1436 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1438 if(!_this[size + 'Url']){
1444 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1445 html: _this.html || cfg.html,
1446 src: _this[size + 'Url']
1449 img.cls += ' roo-image-responsive-' + size;
1451 var s = ['xs', 'sm', 'md', 'lg'];
1453 s.splice(s.indexOf(size), 1);
1455 Roo.each(s, function(ss){
1456 img.cls += ' hidden-' + ss;
1459 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1460 cfg.cls += ' img-' + _this.border;
1464 cfg.alt = _this.alt;
1477 a.target = _this.target;
1481 cfg.cn.push((_this.href) ? a : img);
1488 createSingleImg : function()
1492 cls: (this.imgResponsive) ? 'img-responsive' : '',
1494 src : 'about:blank' // just incase src get's set to undefined?!?
1497 cfg.html = this.html || cfg.html;
1499 cfg.src = this.src || cfg.src;
1501 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1502 cfg.cls += ' img-' + this.border;
1519 a.target = this.target;
1524 return (this.href) ? a : cfg;
1527 initEvents: function()
1530 this.el.on('click', this.onClick, this);
1535 onClick : function(e)
1537 Roo.log('img onclick');
1538 this.fireEvent('click', this, e);
1541 * Sets the url of the image - used to update it
1542 * @param {String} url the url of the image
1545 setSrc : function(url)
1549 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1550 this.el.dom.src = url;
1554 this.el.select('img', true).first().dom.src = url;
1570 * @class Roo.bootstrap.Link
1571 * @extends Roo.bootstrap.Component
1572 * Bootstrap Link Class
1573 * @cfg {String} alt image alternative text
1574 * @cfg {String} href a tag href
1575 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1576 * @cfg {String} html the content of the link.
1577 * @cfg {String} anchor name for the anchor link
1578 * @cfg {String} fa - favicon
1580 * @cfg {Boolean} preventDefault (true | false) default false
1584 * Create a new Input
1585 * @param {Object} config The config object
1588 Roo.bootstrap.Link = function(config){
1589 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1595 * The img click event for the img.
1596 * @param {Roo.EventObject} e
1602 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1606 preventDefault: false,
1612 getAutoCreate : function()
1614 var html = this.html || '';
1616 if (this.fa !== false) {
1617 html = '<i class="fa fa-' + this.fa + '"></i>';
1622 // anchor's do not require html/href...
1623 if (this.anchor === false) {
1625 cfg.href = this.href || '#';
1627 cfg.name = this.anchor;
1628 if (this.html !== false || this.fa !== false) {
1631 if (this.href !== false) {
1632 cfg.href = this.href;
1636 if(this.alt !== false){
1641 if(this.target !== false) {
1642 cfg.target = this.target;
1648 initEvents: function() {
1650 if(!this.href || this.preventDefault){
1651 this.el.on('click', this.onClick, this);
1655 onClick : function(e)
1657 if(this.preventDefault){
1660 //Roo.log('img onclick');
1661 this.fireEvent('click', this, e);
1674 * @class Roo.bootstrap.Header
1675 * @extends Roo.bootstrap.Component
1676 * Bootstrap Header class
1677 * @cfg {String} html content of header
1678 * @cfg {Number} level (1|2|3|4|5|6) default 1
1681 * Create a new Header
1682 * @param {Object} config The config object
1686 Roo.bootstrap.Header = function(config){
1687 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1690 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1698 getAutoCreate : function(){
1703 tag: 'h' + (1 *this.level),
1704 html: this.html || ''
1716 * Ext JS Library 1.1.1
1717 * Copyright(c) 2006-2007, Ext JS, LLC.
1719 * Originally Released Under LGPL - original licence link has changed is not relivant.
1722 * <script type="text/javascript">
1726 * @class Roo.bootstrap.MenuMgr
1727 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1730 Roo.bootstrap.MenuMgr = function(){
1731 var menus, active, groups = {}, attached = false, lastShow = new Date();
1733 // private - called when first menu is created
1736 active = new Roo.util.MixedCollection();
1737 Roo.get(document).addKeyListener(27, function(){
1738 if(active.length > 0){
1746 if(active && active.length > 0){
1747 var c = active.clone();
1757 if(active.length < 1){
1758 Roo.get(document).un("mouseup", onMouseDown);
1766 var last = active.last();
1767 lastShow = new Date();
1770 Roo.get(document).on("mouseup", onMouseDown);
1775 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1776 m.parentMenu.activeChild = m;
1777 }else if(last && last.isVisible()){
1778 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1783 function onBeforeHide(m){
1785 m.activeChild.hide();
1787 if(m.autoHideTimer){
1788 clearTimeout(m.autoHideTimer);
1789 delete m.autoHideTimer;
1794 function onBeforeShow(m){
1795 var pm = m.parentMenu;
1796 if(!pm && !m.allowOtherMenus){
1798 }else if(pm && pm.activeChild && active != m){
1799 pm.activeChild.hide();
1803 // private this should really trigger on mouseup..
1804 function onMouseDown(e){
1805 Roo.log("on Mouse Up");
1807 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1808 Roo.log("MenuManager hideAll");
1817 function onBeforeCheck(mi, state){
1819 var g = groups[mi.group];
1820 for(var i = 0, l = g.length; i < l; i++){
1822 g[i].setChecked(false);
1831 * Hides all menus that are currently visible
1833 hideAll : function(){
1838 register : function(menu){
1842 menus[menu.id] = menu;
1843 menu.on("beforehide", onBeforeHide);
1844 menu.on("hide", onHide);
1845 menu.on("beforeshow", onBeforeShow);
1846 menu.on("show", onShow);
1848 if(g && menu.events["checkchange"]){
1852 groups[g].push(menu);
1853 menu.on("checkchange", onCheck);
1858 * Returns a {@link Roo.menu.Menu} object
1859 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1860 * be used to generate and return a new Menu instance.
1862 get : function(menu){
1863 if(typeof menu == "string"){ // menu id
1865 }else if(menu.events){ // menu instance
1868 /*else if(typeof menu.length == 'number'){ // array of menu items?
1869 return new Roo.bootstrap.Menu({items:menu});
1870 }else{ // otherwise, must be a config
1871 return new Roo.bootstrap.Menu(menu);
1878 unregister : function(menu){
1879 delete menus[menu.id];
1880 menu.un("beforehide", onBeforeHide);
1881 menu.un("hide", onHide);
1882 menu.un("beforeshow", onBeforeShow);
1883 menu.un("show", onShow);
1885 if(g && menu.events["checkchange"]){
1886 groups[g].remove(menu);
1887 menu.un("checkchange", onCheck);
1892 registerCheckable : function(menuItem){
1893 var g = menuItem.group;
1898 groups[g].push(menuItem);
1899 menuItem.on("beforecheckchange", onBeforeCheck);
1904 unregisterCheckable : function(menuItem){
1905 var g = menuItem.group;
1907 groups[g].remove(menuItem);
1908 menuItem.un("beforecheckchange", onBeforeCheck);
1920 * @class Roo.bootstrap.Menu
1921 * @extends Roo.bootstrap.Component
1922 * Bootstrap Menu class - container for MenuItems
1923 * @cfg {String} type (dropdown|treeview|submenu) type of menu
1924 * @cfg {bool} hidden if the menu should be hidden when rendered.
1925 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
1926 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
1930 * @param {Object} config The config object
1934 Roo.bootstrap.Menu = function(config){
1935 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
1936 if (this.registerMenu && this.type != 'treeview') {
1937 Roo.bootstrap.MenuMgr.register(this);
1942 * Fires before this menu is displayed
1943 * @param {Roo.menu.Menu} this
1948 * Fires before this menu is hidden
1949 * @param {Roo.menu.Menu} this
1954 * Fires after this menu is displayed
1955 * @param {Roo.menu.Menu} this
1960 * Fires after this menu is hidden
1961 * @param {Roo.menu.Menu} this
1966 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
1967 * @param {Roo.menu.Menu} this
1968 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1969 * @param {Roo.EventObject} e
1974 * Fires when the mouse is hovering over this menu
1975 * @param {Roo.menu.Menu} this
1976 * @param {Roo.EventObject} e
1977 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1982 * Fires when the mouse exits this menu
1983 * @param {Roo.menu.Menu} this
1984 * @param {Roo.EventObject} e
1985 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1990 * Fires when a menu item contained in this menu is clicked
1991 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
1992 * @param {Roo.EventObject} e
1996 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
1999 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2003 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2006 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2008 registerMenu : true,
2010 menuItems :false, // stores the menu items..
2020 getChildContainer : function() {
2024 getAutoCreate : function(){
2026 //if (['right'].indexOf(this.align)!==-1) {
2027 // cfg.cn[1].cls += ' pull-right'
2033 cls : 'dropdown-menu' ,
2034 style : 'z-index:1000'
2038 if (this.type === 'submenu') {
2039 cfg.cls = 'submenu active';
2041 if (this.type === 'treeview') {
2042 cfg.cls = 'treeview-menu';
2047 initEvents : function() {
2049 // Roo.log("ADD event");
2050 // Roo.log(this.triggerEl.dom);
2052 this.triggerEl.on('click', this.onTriggerClick, this);
2054 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2056 this.triggerEl.addClass('dropdown-toggle');
2059 this.el.on('touchstart' , this.onTouch, this);
2061 this.el.on('click' , this.onClick, this);
2063 this.el.on("mouseover", this.onMouseOver, this);
2064 this.el.on("mouseout", this.onMouseOut, this);
2068 findTargetItem : function(e)
2070 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2074 //Roo.log(t); Roo.log(t.id);
2076 //Roo.log(this.menuitems);
2077 return this.menuitems.get(t.id);
2079 //return this.items.get(t.menuItemId);
2085 onTouch : function(e)
2087 Roo.log("menu.onTouch");
2088 //e.stopEvent(); this make the user popdown broken
2092 onClick : function(e)
2094 Roo.log("menu.onClick");
2096 var t = this.findTargetItem(e);
2097 if(!t || t.isContainer){
2102 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2103 if(t == this.activeItem && t.shouldDeactivate(e)){
2104 this.activeItem.deactivate();
2105 delete this.activeItem;
2109 this.setActiveItem(t, true);
2117 Roo.log('pass click event');
2121 this.fireEvent("click", this, t, e);
2125 if(!t.href.length || t.href == '#'){
2126 (function() { _this.hide(); }).defer(100);
2131 onMouseOver : function(e){
2132 var t = this.findTargetItem(e);
2135 // if(t.canActivate && !t.disabled){
2136 // this.setActiveItem(t, true);
2140 this.fireEvent("mouseover", this, e, t);
2142 isVisible : function(){
2143 return !this.hidden;
2145 onMouseOut : function(e){
2146 var t = this.findTargetItem(e);
2149 // if(t == this.activeItem && t.shouldDeactivate(e)){
2150 // this.activeItem.deactivate();
2151 // delete this.activeItem;
2154 this.fireEvent("mouseout", this, e, t);
2159 * Displays this menu relative to another element
2160 * @param {String/HTMLElement/Roo.Element} element The element to align to
2161 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2162 * the element (defaults to this.defaultAlign)
2163 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2165 show : function(el, pos, parentMenu){
2166 this.parentMenu = parentMenu;
2170 this.fireEvent("beforeshow", this);
2171 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2174 * Displays this menu at a specific xy position
2175 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2176 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2178 showAt : function(xy, parentMenu, /* private: */_e){
2179 this.parentMenu = parentMenu;
2184 this.fireEvent("beforeshow", this);
2185 //xy = this.el.adjustForConstraints(xy);
2189 this.hideMenuItems();
2190 this.hidden = false;
2191 this.triggerEl.addClass('open');
2193 if(this.el.getWidth() + xy[0] > Roo.lib.Dom.getViewWidth()){
2194 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2197 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2202 this.fireEvent("show", this);
2208 this.doFocus.defer(50, this);
2212 doFocus : function(){
2214 this.focusEl.focus();
2219 * Hides this menu and optionally all parent menus
2220 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2222 hide : function(deep)
2225 this.hideMenuItems();
2226 if(this.el && this.isVisible()){
2227 this.fireEvent("beforehide", this);
2228 if(this.activeItem){
2229 this.activeItem.deactivate();
2230 this.activeItem = null;
2232 this.triggerEl.removeClass('open');;
2234 this.fireEvent("hide", this);
2236 if(deep === true && this.parentMenu){
2237 this.parentMenu.hide(true);
2241 onTriggerClick : function(e)
2243 Roo.log('trigger click');
2245 var target = e.getTarget();
2247 Roo.log(target.nodeName.toLowerCase());
2249 if(target.nodeName.toLowerCase() === 'i'){
2255 onTriggerPress : function(e)
2257 Roo.log('trigger press');
2258 //Roo.log(e.getTarget());
2259 // Roo.log(this.triggerEl.dom);
2261 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2262 var pel = Roo.get(e.getTarget());
2263 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2264 Roo.log('is treeview or dropdown?');
2268 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2272 if (this.isVisible()) {
2277 this.show(this.triggerEl, false, false);
2280 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2287 hideMenuItems : function()
2289 Roo.log("hide Menu Items");
2293 //$(backdrop).remove()
2294 this.el.select('.open',true).each(function(aa) {
2296 aa.removeClass('open');
2297 //var parent = getParent($(this))
2298 //var relatedTarget = { relatedTarget: this }
2300 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2301 //if (e.isDefaultPrevented()) return
2302 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2305 addxtypeChild : function (tree, cntr) {
2306 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2308 this.menuitems.add(comp);
2329 * @class Roo.bootstrap.MenuItem
2330 * @extends Roo.bootstrap.Component
2331 * Bootstrap MenuItem class
2332 * @cfg {String} html the menu label
2333 * @cfg {String} href the link
2334 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2335 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2336 * @cfg {Boolean} active used on sidebars to highlight active itesm
2337 * @cfg {String} fa favicon to show on left of menu item.
2338 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2342 * Create a new MenuItem
2343 * @param {Object} config The config object
2347 Roo.bootstrap.MenuItem = function(config){
2348 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2353 * The raw click event for the entire grid.
2354 * @param {Roo.bootstrap.MenuItem} this
2355 * @param {Roo.EventObject} e
2361 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2365 preventDefault: false,
2366 isContainer : false,
2370 getAutoCreate : function(){
2372 if(this.isContainer){
2375 cls: 'dropdown-menu-item'
2389 if (this.fa !== false) {
2392 cls : 'fa fa-' + this.fa
2401 cls: 'dropdown-menu-item',
2404 if (this.parent().type == 'treeview') {
2405 cfg.cls = 'treeview-menu';
2408 cfg.cls += ' active';
2413 anc.href = this.href || cfg.cn[0].href ;
2414 ctag.html = this.html || cfg.cn[0].html ;
2418 initEvents: function()
2420 if (this.parent().type == 'treeview') {
2421 this.el.select('a').on('click', this.onClick, this);
2425 this.menu.parentType = this.xtype;
2426 this.menu.triggerEl = this.el;
2427 this.menu = this.addxtype(Roo.apply({}, this.menu));
2431 onClick : function(e)
2433 Roo.log('item on click ');
2435 if(this.preventDefault){
2438 //this.parent().hideMenuItems();
2440 this.fireEvent('click', this, e);
2459 * @class Roo.bootstrap.MenuSeparator
2460 * @extends Roo.bootstrap.Component
2461 * Bootstrap MenuSeparator class
2464 * Create a new MenuItem
2465 * @param {Object} config The config object
2469 Roo.bootstrap.MenuSeparator = function(config){
2470 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2473 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2475 getAutoCreate : function(){
2494 * @class Roo.bootstrap.Modal
2495 * @extends Roo.bootstrap.Component
2496 * Bootstrap Modal class
2497 * @cfg {String} title Title of dialog
2498 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2499 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2500 * @cfg {Boolean} specificTitle default false
2501 * @cfg {Array} buttons Array of buttons or standard button set..
2502 * @cfg {String} buttonPosition (left|right|center) default right
2503 * @cfg {Boolean} animate default true
2504 * @cfg {Boolean} allow_close default true
2505 * @cfg {Boolean} fitwindow default false
2506 * @cfg {String} size (sm|lg) default empty
2510 * Create a new Modal Dialog
2511 * @param {Object} config The config object
2514 Roo.bootstrap.Modal = function(config){
2515 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2520 * The raw btnclick event for the button
2521 * @param {Roo.EventObject} e
2526 * Fire when dialog resize
2527 * @param {Roo.bootstrap.Modal} this
2528 * @param {Roo.EventObject} e
2532 this.buttons = this.buttons || [];
2535 this.tmpl = Roo.factory(this.tmpl);
2540 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2542 title : 'test dialog',
2552 specificTitle: false,
2554 buttonPosition: 'right',
2573 onRender : function(ct, position)
2575 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2578 var cfg = Roo.apply({}, this.getAutoCreate());
2581 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2583 //if (!cfg.name.length) {
2587 cfg.cls += ' ' + this.cls;
2590 cfg.style = this.style;
2592 this.el = Roo.get(document.body).createChild(cfg, position);
2594 //var type = this.el.dom.type;
2597 if(this.tabIndex !== undefined){
2598 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2601 this.dialogEl = this.el.select('.modal-dialog',true).first();
2602 this.bodyEl = this.el.select('.modal-body',true).first();
2603 this.closeEl = this.el.select('.modal-header .close', true).first();
2604 this.headerEl = this.el.select('.modal-header',true).first();
2605 this.titleEl = this.el.select('.modal-title',true).first();
2606 this.footerEl = this.el.select('.modal-footer',true).first();
2608 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2609 this.maskEl.enableDisplayMode("block");
2611 //this.el.addClass("x-dlg-modal");
2613 if (this.buttons.length) {
2614 Roo.each(this.buttons, function(bb) {
2615 var b = Roo.apply({}, bb);
2616 b.xns = b.xns || Roo.bootstrap;
2617 b.xtype = b.xtype || 'Button';
2618 if (typeof(b.listeners) == 'undefined') {
2619 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2622 var btn = Roo.factory(b);
2624 btn.render(this.el.select('.modal-footer div').first());
2628 // render the children.
2631 if(typeof(this.items) != 'undefined'){
2632 var items = this.items;
2635 for(var i =0;i < items.length;i++) {
2636 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2640 this.items = nitems;
2642 // where are these used - they used to be body/close/footer
2646 //this.el.addClass([this.fieldClass, this.cls]);
2650 getAutoCreate : function(){
2655 html : this.html || ''
2660 cls : 'modal-title',
2664 if(this.specificTitle){
2670 if (this.allow_close) {
2682 if(this.size.length){
2683 size = 'modal-' + this.size;
2688 style : 'display: none',
2691 cls: "modal-dialog " + size,
2694 cls : "modal-content",
2697 cls : 'modal-header',
2702 cls : 'modal-footer',
2706 cls: 'btn-' + this.buttonPosition
2723 modal.cls += ' fade';
2729 getChildContainer : function() {
2734 getButtonContainer : function() {
2735 return this.el.select('.modal-footer div',true).first();
2738 initEvents : function()
2740 if (this.allow_close) {
2741 this.closeEl.on('click', this.hide, this);
2743 Roo.EventManager.onWindowResize(this.resize, this, true);
2750 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2751 if (this.fitwindow) {
2752 var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
2753 var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
2758 setSize : function(w,h)
2768 if (!this.rendered) {
2772 this.el.setStyle('display', 'block');
2774 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2777 this.el.addClass('in');
2780 this.el.addClass('in');
2784 // not sure how we can show data in here..
2786 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2789 Roo.get(document.body).addClass("x-body-masked");
2791 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2792 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2797 this.fireEvent('show', this);
2799 // set zindex here - otherwise it appears to be ignored...
2800 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2803 this.items.forEach( function(e) {
2804 e.layout ? e.layout() : false;
2812 if(this.fireEvent("beforehide", this) !== false){
2814 Roo.get(document.body).removeClass("x-body-masked");
2815 this.el.removeClass('in');
2816 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2818 if(this.animate){ // why
2820 (function(){ _this.el.setStyle('display', 'none'); }).defer(150);
2822 this.el.setStyle('display', 'none');
2824 this.fireEvent('hide', this);
2828 addButton : function(str, cb)
2832 var b = Roo.apply({}, { html : str } );
2833 b.xns = b.xns || Roo.bootstrap;
2834 b.xtype = b.xtype || 'Button';
2835 if (typeof(b.listeners) == 'undefined') {
2836 b.listeners = { click : cb.createDelegate(this) };
2839 var btn = Roo.factory(b);
2841 btn.render(this.el.select('.modal-footer div').first());
2847 setDefaultButton : function(btn)
2849 //this.el.select('.modal-footer').()
2853 resizeTo: function(w,h)
2857 this.dialogEl.setWidth(w);
2858 if (this.diff === false) {
2859 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
2862 this.bodyEl.setHeight(h-this.diff);
2864 this.fireEvent('resize', this);
2867 setContentSize : function(w, h)
2871 onButtonClick: function(btn,e)
2874 this.fireEvent('btnclick', btn.name, e);
2877 * Set the title of the Dialog
2878 * @param {String} str new Title
2880 setTitle: function(str) {
2881 this.titleEl.dom.innerHTML = str;
2884 * Set the body of the Dialog
2885 * @param {String} str new Title
2887 setBody: function(str) {
2888 this.bodyEl.dom.innerHTML = str;
2891 * Set the body of the Dialog using the template
2892 * @param {Obj} data - apply this data to the template and replace the body contents.
2894 applyBody: function(obj)
2897 Roo.log("Error - using apply Body without a template");
2900 this.tmpl.overwrite(this.bodyEl, obj);
2906 Roo.apply(Roo.bootstrap.Modal, {
2908 * Button config that displays a single OK button
2917 * Button config that displays Yes and No buttons
2933 * Button config that displays OK and Cancel buttons
2948 * Button config that displays Yes, No and Cancel buttons
2972 * messagebox - can be used as a replace
2976 * @class Roo.MessageBox
2977 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
2981 Roo.Msg.alert('Status', 'Changes saved successfully.');
2983 // Prompt for user data:
2984 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
2986 // process text value...
2990 // Show a dialog using config options:
2992 title:'Save Changes?',
2993 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
2994 buttons: Roo.Msg.YESNOCANCEL,
3001 Roo.bootstrap.MessageBox = function(){
3002 var dlg, opt, mask, waitTimer;
3003 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3004 var buttons, activeTextEl, bwidth;
3008 var handleButton = function(button){
3010 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3014 var handleHide = function(){
3016 dlg.el.removeClass(opt.cls);
3019 // Roo.TaskMgr.stop(waitTimer);
3020 // waitTimer = null;
3025 var updateButtons = function(b){
3028 buttons["ok"].hide();
3029 buttons["cancel"].hide();
3030 buttons["yes"].hide();
3031 buttons["no"].hide();
3032 //dlg.footer.dom.style.display = 'none';
3035 dlg.footerEl.dom.style.display = '';
3036 for(var k in buttons){
3037 if(typeof buttons[k] != "function"){
3040 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3041 width += buttons[k].el.getWidth()+15;
3051 var handleEsc = function(d, k, e){
3052 if(opt && opt.closable !== false){
3062 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3063 * @return {Roo.BasicDialog} The BasicDialog element
3065 getDialog : function(){
3067 dlg = new Roo.bootstrap.Modal( {
3070 //constraintoviewport:false,
3072 //collapsible : false,
3077 //buttonAlign:"center",
3078 closeClick : function(){
3079 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3082 handleButton("cancel");
3087 dlg.on("hide", handleHide);
3089 //dlg.addKeyListener(27, handleEsc);
3091 this.buttons = buttons;
3092 var bt = this.buttonText;
3093 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3094 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3095 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3096 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3098 bodyEl = dlg.bodyEl.createChild({
3100 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3101 '<textarea class="roo-mb-textarea"></textarea>' +
3102 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3104 msgEl = bodyEl.dom.firstChild;
3105 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3106 textboxEl.enableDisplayMode();
3107 textboxEl.addKeyListener([10,13], function(){
3108 if(dlg.isVisible() && opt && opt.buttons){
3111 }else if(opt.buttons.yes){
3112 handleButton("yes");
3116 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3117 textareaEl.enableDisplayMode();
3118 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3119 progressEl.enableDisplayMode();
3121 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3122 //var pf = progressEl.dom.firstChild;
3124 //pp = Roo.get(pf.firstChild);
3125 //pp.setHeight(pf.offsetHeight);
3133 * Updates the message box body text
3134 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3135 * the XHTML-compliant non-breaking space character '&#160;')
3136 * @return {Roo.MessageBox} This message box
3138 updateText : function(text)
3140 if(!dlg.isVisible() && !opt.width){
3141 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3142 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3144 msgEl.innerHTML = text || ' ';
3146 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3147 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3149 Math.min(opt.width || cw , this.maxWidth),
3150 Math.max(opt.minWidth || this.minWidth, bwidth)
3153 activeTextEl.setWidth(w);
3155 if(dlg.isVisible()){
3156 dlg.fixedcenter = false;
3158 // to big, make it scroll. = But as usual stupid IE does not support
3161 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3162 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3163 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3165 bodyEl.dom.style.height = '';
3166 bodyEl.dom.style.overflowY = '';
3169 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3171 bodyEl.dom.style.overflowX = '';
3174 dlg.setContentSize(w, bodyEl.getHeight());
3175 if(dlg.isVisible()){
3176 dlg.fixedcenter = true;
3182 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3183 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3184 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3185 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3186 * @return {Roo.MessageBox} This message box
3188 updateProgress : function(value, text){
3190 this.updateText(text);
3192 if (pp) { // weird bug on my firefox - for some reason this is not defined
3193 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3199 * Returns true if the message box is currently displayed
3200 * @return {Boolean} True if the message box is visible, else false
3202 isVisible : function(){
3203 return dlg && dlg.isVisible();
3207 * Hides the message box if it is displayed
3210 if(this.isVisible()){
3216 * Displays a new message box, or reinitializes an existing message box, based on the config options
3217 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3218 * The following config object properties are supported:
3220 Property Type Description
3221 ---------- --------------- ------------------------------------------------------------------------------------
3222 animEl String/Element An id or Element from which the message box should animate as it opens and
3223 closes (defaults to undefined)
3224 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3225 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3226 closable Boolean False to hide the top-right close button (defaults to true). Note that
3227 progress and wait dialogs will ignore this property and always hide the
3228 close button as they can only be closed programmatically.
3229 cls String A custom CSS class to apply to the message box element
3230 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3231 displayed (defaults to 75)
3232 fn Function A callback function to execute after closing the dialog. The arguments to the
3233 function will be btn (the name of the button that was clicked, if applicable,
3234 e.g. "ok"), and text (the value of the active text field, if applicable).
3235 Progress and wait dialogs will ignore this option since they do not respond to
3236 user actions and can only be closed programmatically, so any required function
3237 should be called by the same code after it closes the dialog.
3238 icon String A CSS class that provides a background image to be used as an icon for
3239 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3240 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3241 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3242 modal Boolean False to allow user interaction with the page while the message box is
3243 displayed (defaults to true)
3244 msg String A string that will replace the existing message box body text (defaults
3245 to the XHTML-compliant non-breaking space character ' ')
3246 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3247 progress Boolean True to display a progress bar (defaults to false)
3248 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3249 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3250 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3251 title String The title text
3252 value String The string value to set into the active textbox element if displayed
3253 wait Boolean True to display a progress bar (defaults to false)
3254 width Number The width of the dialog in pixels
3261 msg: 'Please enter your address:',
3263 buttons: Roo.MessageBox.OKCANCEL,
3266 animEl: 'addAddressBtn'
3269 * @param {Object} config Configuration options
3270 * @return {Roo.MessageBox} This message box
3272 show : function(options)
3275 // this causes nightmares if you show one dialog after another
3276 // especially on callbacks..
3278 if(this.isVisible()){
3281 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3282 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3283 Roo.log("New Dialog Message:" + options.msg )
3284 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3285 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3288 var d = this.getDialog();
3290 d.setTitle(opt.title || " ");
3291 d.closeEl.setDisplayed(opt.closable !== false);
3292 activeTextEl = textboxEl;
3293 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3298 textareaEl.setHeight(typeof opt.multiline == "number" ?
3299 opt.multiline : this.defaultTextHeight);
3300 activeTextEl = textareaEl;
3309 progressEl.setDisplayed(opt.progress === true);
3310 this.updateProgress(0);
3311 activeTextEl.dom.value = opt.value || "";
3313 dlg.setDefaultButton(activeTextEl);
3315 var bs = opt.buttons;
3319 }else if(bs && bs.yes){
3320 db = buttons["yes"];
3322 dlg.setDefaultButton(db);
3324 bwidth = updateButtons(opt.buttons);
3325 this.updateText(opt.msg);
3327 d.el.addClass(opt.cls);
3329 d.proxyDrag = opt.proxyDrag === true;
3330 d.modal = opt.modal !== false;
3331 d.mask = opt.modal !== false ? mask : false;
3333 // force it to the end of the z-index stack so it gets a cursor in FF
3334 document.body.appendChild(dlg.el.dom);
3335 d.animateTarget = null;
3336 d.show(options.animEl);
3342 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3343 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3344 * and closing the message box when the process is complete.
3345 * @param {String} title The title bar text
3346 * @param {String} msg The message box body text
3347 * @return {Roo.MessageBox} This message box
3349 progress : function(title, msg){
3356 minWidth: this.minProgressWidth,
3363 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3364 * If a callback function is passed it will be called after the user clicks the button, and the
3365 * id of the button that was clicked will be passed as the only parameter to the callback
3366 * (could also be the top-right close button).
3367 * @param {String} title The title bar text
3368 * @param {String} msg The message box body text
3369 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3370 * @param {Object} scope (optional) The scope of the callback function
3371 * @return {Roo.MessageBox} This message box
3373 alert : function(title, msg, fn, scope)
3388 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3389 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3390 * You are responsible for closing the message box when the process is complete.
3391 * @param {String} msg The message box body text
3392 * @param {String} title (optional) The title bar text
3393 * @return {Roo.MessageBox} This message box
3395 wait : function(msg, title){
3406 waitTimer = Roo.TaskMgr.start({
3408 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3416 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3417 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3418 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3419 * @param {String} title The title bar text
3420 * @param {String} msg The message box body text
3421 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3422 * @param {Object} scope (optional) The scope of the callback function
3423 * @return {Roo.MessageBox} This message box
3425 confirm : function(title, msg, fn, scope){
3429 buttons: this.YESNO,
3438 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3439 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3440 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3441 * (could also be the top-right close button) and the text that was entered will be passed as the two
3442 * parameters to the callback.
3443 * @param {String} title The title bar text
3444 * @param {String} msg The message box body text
3445 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3446 * @param {Object} scope (optional) The scope of the callback function
3447 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3448 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3449 * @return {Roo.MessageBox} This message box
3451 prompt : function(title, msg, fn, scope, multiline){
3455 buttons: this.OKCANCEL,
3460 multiline: multiline,
3467 * Button config that displays a single OK button
3472 * Button config that displays Yes and No buttons
3475 YESNO : {yes:true, no:true},
3477 * Button config that displays OK and Cancel buttons
3480 OKCANCEL : {ok:true, cancel:true},
3482 * Button config that displays Yes, No and Cancel buttons
3485 YESNOCANCEL : {yes:true, no:true, cancel:true},
3488 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3491 defaultTextHeight : 75,
3493 * The maximum width in pixels of the message box (defaults to 600)
3498 * The minimum width in pixels of the message box (defaults to 100)
3503 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3504 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3507 minProgressWidth : 250,
3509 * An object containing the default button text strings that can be overriden for localized language support.
3510 * Supported properties are: ok, cancel, yes and no.
3511 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3524 * Shorthand for {@link Roo.MessageBox}
3526 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3527 Roo.Msg = Roo.Msg || Roo.MessageBox;
3536 * @class Roo.bootstrap.Navbar
3537 * @extends Roo.bootstrap.Component
3538 * Bootstrap Navbar class
3541 * Create a new Navbar
3542 * @param {Object} config The config object
3546 Roo.bootstrap.Navbar = function(config){
3547 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3551 * @event beforetoggle
3552 * Fire before toggle the menu
3553 * @param {Roo.EventObject} e
3555 "beforetoggle" : true
3559 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3568 getAutoCreate : function(){
3571 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3575 initEvents :function ()
3577 //Roo.log(this.el.select('.navbar-toggle',true));
3578 this.el.select('.navbar-toggle',true).on('click', function() {
3579 if(this.fireEvent('beforetoggle', this) !== false){
3580 this.el.select('.navbar-collapse',true).toggleClass('in');
3590 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3592 var size = this.el.getSize();
3593 this.maskEl.setSize(size.width, size.height);
3594 this.maskEl.enableDisplayMode("block");
3603 getChildContainer : function()
3605 if (this.el.select('.collapse').getCount()) {
3606 return this.el.select('.collapse',true).first();
3639 * @class Roo.bootstrap.NavSimplebar
3640 * @extends Roo.bootstrap.Navbar
3641 * Bootstrap Sidebar class
3643 * @cfg {Boolean} inverse is inverted color
3645 * @cfg {String} type (nav | pills | tabs)
3646 * @cfg {Boolean} arrangement stacked | justified
3647 * @cfg {String} align (left | right) alignment
3649 * @cfg {Boolean} main (true|false) main nav bar? default false
3650 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3652 * @cfg {String} tag (header|footer|nav|div) default is nav
3658 * Create a new Sidebar
3659 * @param {Object} config The config object
3663 Roo.bootstrap.NavSimplebar = function(config){
3664 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3667 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3683 getAutoCreate : function(){
3687 tag : this.tag || 'div',
3700 this.type = this.type || 'nav';
3701 if (['tabs','pills'].indexOf(this.type)!==-1) {
3702 cfg.cn[0].cls += ' nav-' + this.type
3706 if (this.type!=='nav') {
3707 Roo.log('nav type must be nav/tabs/pills')
3709 cfg.cn[0].cls += ' navbar-nav'
3715 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3716 cfg.cn[0].cls += ' nav-' + this.arrangement;
3720 if (this.align === 'right') {
3721 cfg.cn[0].cls += ' navbar-right';
3725 cfg.cls += ' navbar-inverse';
3752 * @class Roo.bootstrap.NavHeaderbar
3753 * @extends Roo.bootstrap.NavSimplebar
3754 * Bootstrap Sidebar class
3756 * @cfg {String} brand what is brand
3757 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
3758 * @cfg {String} brand_href href of the brand
3759 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
3760 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
3761 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
3762 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
3765 * Create a new Sidebar
3766 * @param {Object} config The config object
3770 Roo.bootstrap.NavHeaderbar = function(config){
3771 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
3775 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
3782 desktopCenter : false,
3785 getAutoCreate : function(){
3788 tag: this.nav || 'nav',
3795 if (this.desktopCenter) {
3796 cn.push({cls : 'container', cn : []});
3803 cls: 'navbar-header',
3808 cls: 'navbar-toggle',
3809 'data-toggle': 'collapse',
3814 html: 'Toggle navigation'
3836 cls: 'collapse navbar-collapse',
3840 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
3842 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
3843 cfg.cls += ' navbar-' + this.position;
3845 // tag can override this..
3847 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
3850 if (this.brand !== '') {
3853 href: this.brand_href ? this.brand_href : '#',
3854 cls: 'navbar-brand',
3862 cfg.cls += ' main-nav';
3870 getHeaderChildContainer : function()
3872 if (this.srButton && this.el.select('.navbar-header').getCount()) {
3873 return this.el.select('.navbar-header',true).first();
3876 return this.getChildContainer();
3880 initEvents : function()
3882 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
3884 if (this.autohide) {
3889 Roo.get(document).on('scroll',function(e) {
3890 var ns = Roo.get(document).getScroll().top;
3891 var os = prevScroll;
3895 ft.removeClass('slideDown');
3896 ft.addClass('slideUp');
3899 ft.removeClass('slideUp');
3900 ft.addClass('slideDown');
3921 * @class Roo.bootstrap.NavSidebar
3922 * @extends Roo.bootstrap.Navbar
3923 * Bootstrap Sidebar class
3926 * Create a new Sidebar
3927 * @param {Object} config The config object
3931 Roo.bootstrap.NavSidebar = function(config){
3932 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
3935 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
3937 sidebar : true, // used by Navbar Item and NavbarGroup at present...
3939 getAutoCreate : function(){
3944 cls: 'sidebar sidebar-nav'
3966 * @class Roo.bootstrap.NavGroup
3967 * @extends Roo.bootstrap.Component
3968 * Bootstrap NavGroup class
3969 * @cfg {String} align (left|right)
3970 * @cfg {Boolean} inverse
3971 * @cfg {String} type (nav|pills|tab) default nav
3972 * @cfg {String} navId - reference Id for navbar.
3976 * Create a new nav group
3977 * @param {Object} config The config object
3980 Roo.bootstrap.NavGroup = function(config){
3981 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
3984 Roo.bootstrap.NavGroup.register(this);
3988 * Fires when the active item changes
3989 * @param {Roo.bootstrap.NavGroup} this
3990 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
3991 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
3998 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4009 getAutoCreate : function()
4011 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4018 if (['tabs','pills'].indexOf(this.type)!==-1) {
4019 cfg.cls += ' nav-' + this.type
4021 if (this.type!=='nav') {
4022 Roo.log('nav type must be nav/tabs/pills')
4024 cfg.cls += ' navbar-nav'
4027 if (this.parent() && this.parent().sidebar) {
4030 cls: 'dashboard-menu sidebar-menu'
4036 if (this.form === true) {
4042 if (this.align === 'right') {
4043 cfg.cls += ' navbar-right';
4045 cfg.cls += ' navbar-left';
4049 if (this.align === 'right') {
4050 cfg.cls += ' navbar-right';
4054 cfg.cls += ' navbar-inverse';
4062 * sets the active Navigation item
4063 * @param {Roo.bootstrap.NavItem} the new current navitem
4065 setActiveItem : function(item)
4068 Roo.each(this.navItems, function(v){
4073 v.setActive(false, true);
4080 item.setActive(true, true);
4081 this.fireEvent('changed', this, item, prev);
4086 * gets the active Navigation item
4087 * @return {Roo.bootstrap.NavItem} the current navitem
4089 getActive : function()
4093 Roo.each(this.navItems, function(v){
4104 indexOfNav : function()
4108 Roo.each(this.navItems, function(v,i){
4119 * adds a Navigation item
4120 * @param {Roo.bootstrap.NavItem} the navitem to add
4122 addItem : function(cfg)
4124 var cn = new Roo.bootstrap.NavItem(cfg);
4126 cn.parentId = this.id;
4127 cn.onRender(this.el, null);
4131 * register a Navigation item
4132 * @param {Roo.bootstrap.NavItem} the navitem to add
4134 register : function(item)
4136 this.navItems.push( item);
4137 item.navId = this.navId;
4142 * clear all the Navigation item
4145 clearAll : function()
4148 this.el.dom.innerHTML = '';
4151 getNavItem: function(tabId)
4154 Roo.each(this.navItems, function(e) {
4155 if (e.tabId == tabId) {
4165 setActiveNext : function()
4167 var i = this.indexOfNav(this.getActive());
4168 if (i > this.navItems.length) {
4171 this.setActiveItem(this.navItems[i+1]);
4173 setActivePrev : function()
4175 var i = this.indexOfNav(this.getActive());
4179 this.setActiveItem(this.navItems[i-1]);
4181 clearWasActive : function(except) {
4182 Roo.each(this.navItems, function(e) {
4183 if (e.tabId != except.tabId && e.was_active) {
4184 e.was_active = false;
4191 getWasActive : function ()
4194 Roo.each(this.navItems, function(e) {
4209 Roo.apply(Roo.bootstrap.NavGroup, {
4213 * register a Navigation Group
4214 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4216 register : function(navgrp)
4218 this.groups[navgrp.navId] = navgrp;
4222 * fetch a Navigation Group based on the navigation ID
4223 * @param {string} the navgroup to add
4224 * @returns {Roo.bootstrap.NavGroup} the navgroup
4226 get: function(navId) {
4227 if (typeof(this.groups[navId]) == 'undefined') {
4229 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4231 return this.groups[navId] ;
4246 * @class Roo.bootstrap.NavItem
4247 * @extends Roo.bootstrap.Component
4248 * Bootstrap Navbar.NavItem class
4249 * @cfg {String} href link to
4250 * @cfg {String} html content of button
4251 * @cfg {String} badge text inside badge
4252 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4253 * @cfg {String} glyphicon name of glyphicon
4254 * @cfg {String} icon name of font awesome icon
4255 * @cfg {Boolean} active Is item active
4256 * @cfg {Boolean} disabled Is item disabled
4258 * @cfg {Boolean} preventDefault (true | false) default false
4259 * @cfg {String} tabId the tab that this item activates.
4260 * @cfg {String} tagtype (a|span) render as a href or span?
4261 * @cfg {Boolean} animateRef (true|false) link to element default false
4264 * Create a new Navbar Item
4265 * @param {Object} config The config object
4267 Roo.bootstrap.NavItem = function(config){
4268 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4273 * The raw click event for the entire grid.
4274 * @param {Roo.EventObject} e
4279 * Fires when the active item active state changes
4280 * @param {Roo.bootstrap.NavItem} this
4281 * @param {boolean} state the new state
4287 * Fires when scroll to element
4288 * @param {Roo.bootstrap.NavItem} this
4289 * @param {Object} options
4290 * @param {Roo.EventObject} e
4298 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4306 preventDefault : false,
4313 getAutoCreate : function(){
4322 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4324 if (this.disabled) {
4325 cfg.cls += ' disabled';
4328 if (this.href || this.html || this.glyphicon || this.icon) {
4332 href : this.href || "#",
4333 html: this.html || ''
4338 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4341 if(this.glyphicon) {
4342 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4347 cfg.cn[0].html += " <span class='caret'></span>";
4351 if (this.badge !== '') {
4353 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
4361 initEvents: function()
4363 if (typeof (this.menu) != 'undefined') {
4364 this.menu.parentType = this.xtype;
4365 this.menu.triggerEl = this.el;
4366 this.menu = this.addxtype(Roo.apply({}, this.menu));
4369 this.el.select('a',true).on('click', this.onClick, this);
4371 if(this.tagtype == 'span'){
4372 this.el.select('span',true).on('click', this.onClick, this);
4375 // at this point parent should be available..
4376 this.parent().register(this);
4379 onClick : function(e)
4381 if (e.getTarget('.dropdown-menu-item')) {
4382 // did you click on a menu itemm.... - then don't trigger onclick..
4387 this.preventDefault ||
4390 Roo.log("NavItem - prevent Default?");
4394 if (this.disabled) {
4398 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4399 if (tg && tg.transition) {
4400 Roo.log("waiting for the transitionend");
4406 //Roo.log("fire event clicked");
4407 if(this.fireEvent('click', this, e) === false){
4411 if(this.tagtype == 'span'){
4415 //Roo.log(this.href);
4416 var ael = this.el.select('a',true).first();
4419 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4420 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4421 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4422 return; // ignore... - it's a 'hash' to another page.
4424 Roo.log("NavItem - prevent Default?");
4426 this.scrollToElement(e);
4430 var p = this.parent();
4432 if (['tabs','pills'].indexOf(p.type)!==-1) {
4433 if (typeof(p.setActiveItem) !== 'undefined') {
4434 p.setActiveItem(this);
4438 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4439 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4440 // remove the collapsed menu expand...
4441 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4445 isActive: function () {
4448 setActive : function(state, fire, is_was_active)
4450 if (this.active && !state && this.navId) {
4451 this.was_active = true;
4452 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4454 nv.clearWasActive(this);
4458 this.active = state;
4461 this.el.removeClass('active');
4462 } else if (!this.el.hasClass('active')) {
4463 this.el.addClass('active');
4466 this.fireEvent('changed', this, state);
4469 // show a panel if it's registered and related..
4471 if (!this.navId || !this.tabId || !state || is_was_active) {
4475 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4479 var pan = tg.getPanelByName(this.tabId);
4483 // if we can not flip to new panel - go back to old nav highlight..
4484 if (false == tg.showPanel(pan)) {
4485 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4487 var onav = nv.getWasActive();
4489 onav.setActive(true, false, true);
4498 // this should not be here...
4499 setDisabled : function(state)
4501 this.disabled = state;
4503 this.el.removeClass('disabled');
4504 } else if (!this.el.hasClass('disabled')) {
4505 this.el.addClass('disabled');
4511 * Fetch the element to display the tooltip on.
4512 * @return {Roo.Element} defaults to this.el
4514 tooltipEl : function()
4516 return this.el.select('' + this.tagtype + '', true).first();
4519 scrollToElement : function(e)
4521 var c = document.body;
4524 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4526 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4527 c = document.documentElement;
4530 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4536 var o = target.calcOffsetsTo(c);
4543 this.fireEvent('scrollto', this, options, e);
4545 Roo.get(c).scrollTo('top', options.value, true);
4558 * <span> icon </span>
4559 * <span> text </span>
4560 * <span>badge </span>
4564 * @class Roo.bootstrap.NavSidebarItem
4565 * @extends Roo.bootstrap.NavItem
4566 * Bootstrap Navbar.NavSidebarItem class
4567 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4568 * {Boolean} open is the menu open
4569 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4570 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4571 * {String} buttonSize (sm|md|lg)the extra classes for the button
4572 * {Boolean} showArrow show arrow next to the text (default true)
4574 * Create a new Navbar Button
4575 * @param {Object} config The config object
4577 Roo.bootstrap.NavSidebarItem = function(config){
4578 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4583 * The raw click event for the entire grid.
4584 * @param {Roo.EventObject} e
4589 * Fires when the active item active state changes
4590 * @param {Roo.bootstrap.NavSidebarItem} this
4591 * @param {boolean} state the new state
4599 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4601 badgeWeight : 'default',
4607 buttonWeight : 'default',
4613 getAutoCreate : function(){
4618 href : this.href || '#',
4624 if(this.buttonView){
4627 href : this.href || '#',
4628 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4641 cfg.cls += ' active';
4644 if (this.disabled) {
4645 cfg.cls += ' disabled';
4648 cfg.cls += ' open x-open';
4651 if (this.glyphicon || this.icon) {
4652 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4653 a.cn.push({ tag : 'i', cls : c }) ;
4656 if(!this.buttonView){
4659 html : this.html || ''
4666 if (this.badge !== '') {
4667 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4673 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4676 a.cls += ' dropdown-toggle treeview' ;
4682 initEvents : function()
4684 if (typeof (this.menu) != 'undefined') {
4685 this.menu.parentType = this.xtype;
4686 this.menu.triggerEl = this.el;
4687 this.menu = this.addxtype(Roo.apply({}, this.menu));
4690 this.el.on('click', this.onClick, this);
4692 if(this.badge !== ''){
4693 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4698 onClick : function(e)
4705 if(this.preventDefault){
4709 this.fireEvent('click', this);
4712 disable : function()
4714 this.setDisabled(true);
4719 this.setDisabled(false);
4722 setDisabled : function(state)
4724 if(this.disabled == state){
4728 this.disabled = state;
4731 this.el.addClass('disabled');
4735 this.el.removeClass('disabled');
4740 setActive : function(state)
4742 if(this.active == state){
4746 this.active = state;
4749 this.el.addClass('active');
4753 this.el.removeClass('active');
4758 isActive: function ()
4763 setBadge : function(str)
4769 this.badgeEl.dom.innerHTML = str;
4786 * @class Roo.bootstrap.Row
4787 * @extends Roo.bootstrap.Component
4788 * Bootstrap Row class (contains columns...)
4792 * @param {Object} config The config object
4795 Roo.bootstrap.Row = function(config){
4796 Roo.bootstrap.Row.superclass.constructor.call(this, config);
4799 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
4801 getAutoCreate : function(){
4820 * @class Roo.bootstrap.Element
4821 * @extends Roo.bootstrap.Component
4822 * Bootstrap Element class
4823 * @cfg {String} html contents of the element
4824 * @cfg {String} tag tag of the element
4825 * @cfg {String} cls class of the element
4826 * @cfg {Boolean} preventDefault (true|false) default false
4827 * @cfg {Boolean} clickable (true|false) default false
4830 * Create a new Element
4831 * @param {Object} config The config object
4834 Roo.bootstrap.Element = function(config){
4835 Roo.bootstrap.Element.superclass.constructor.call(this, config);
4841 * When a element is chick
4842 * @param {Roo.bootstrap.Element} this
4843 * @param {Roo.EventObject} e
4849 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
4854 preventDefault: false,
4857 getAutoCreate : function(){
4868 initEvents: function()
4870 Roo.bootstrap.Element.superclass.initEvents.call(this);
4873 this.el.on('click', this.onClick, this);
4878 onClick : function(e)
4880 if(this.preventDefault){
4884 this.fireEvent('click', this, e);
4887 getValue : function()
4889 return this.el.dom.innerHTML;
4892 setValue : function(value)
4894 this.el.dom.innerHTML = value;
4909 * @class Roo.bootstrap.Pagination
4910 * @extends Roo.bootstrap.Component
4911 * Bootstrap Pagination class
4912 * @cfg {String} size xs | sm | md | lg
4913 * @cfg {Boolean} inverse false | true
4916 * Create a new Pagination
4917 * @param {Object} config The config object
4920 Roo.bootstrap.Pagination = function(config){
4921 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
4924 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
4930 getAutoCreate : function(){
4936 cfg.cls += ' inverse';
4942 cfg.cls += " " + this.cls;
4960 * @class Roo.bootstrap.PaginationItem
4961 * @extends Roo.bootstrap.Component
4962 * Bootstrap PaginationItem class
4963 * @cfg {String} html text
4964 * @cfg {String} href the link
4965 * @cfg {Boolean} preventDefault (true | false) default true
4966 * @cfg {Boolean} active (true | false) default false
4967 * @cfg {Boolean} disabled default false
4971 * Create a new PaginationItem
4972 * @param {Object} config The config object
4976 Roo.bootstrap.PaginationItem = function(config){
4977 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
4982 * The raw click event for the entire grid.
4983 * @param {Roo.EventObject} e
4989 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
4993 preventDefault: true,
4998 getAutoCreate : function(){
5004 href : this.href ? this.href : '#',
5005 html : this.html ? this.html : ''
5015 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5019 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5025 initEvents: function() {
5027 this.el.on('click', this.onClick, this);
5030 onClick : function(e)
5032 Roo.log('PaginationItem on click ');
5033 if(this.preventDefault){
5041 this.fireEvent('click', this, e);
5057 * @class Roo.bootstrap.Slider
5058 * @extends Roo.bootstrap.Component
5059 * Bootstrap Slider class
5062 * Create a new Slider
5063 * @param {Object} config The config object
5066 Roo.bootstrap.Slider = function(config){
5067 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5070 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5072 getAutoCreate : function(){
5076 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5080 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5092 * Ext JS Library 1.1.1
5093 * Copyright(c) 2006-2007, Ext JS, LLC.
5095 * Originally Released Under LGPL - original licence link has changed is not relivant.
5098 * <script type="text/javascript">
5103 * @class Roo.grid.ColumnModel
5104 * @extends Roo.util.Observable
5105 * This is the default implementation of a ColumnModel used by the Grid. It defines
5106 * the columns in the grid.
5109 var colModel = new Roo.grid.ColumnModel([
5110 {header: "Ticker", width: 60, sortable: true, locked: true},
5111 {header: "Company Name", width: 150, sortable: true},
5112 {header: "Market Cap.", width: 100, sortable: true},
5113 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5114 {header: "Employees", width: 100, sortable: true, resizable: false}
5119 * The config options listed for this class are options which may appear in each
5120 * individual column definition.
5121 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5123 * @param {Object} config An Array of column config objects. See this class's
5124 * config objects for details.
5126 Roo.grid.ColumnModel = function(config){
5128 * The config passed into the constructor
5130 this.config = config;
5133 // if no id, create one
5134 // if the column does not have a dataIndex mapping,
5135 // map it to the order it is in the config
5136 for(var i = 0, len = config.length; i < len; i++){
5138 if(typeof c.dataIndex == "undefined"){
5141 if(typeof c.renderer == "string"){
5142 c.renderer = Roo.util.Format[c.renderer];
5144 if(typeof c.id == "undefined"){
5147 if(c.editor && c.editor.xtype){
5148 c.editor = Roo.factory(c.editor, Roo.grid);
5150 if(c.editor && c.editor.isFormField){
5151 c.editor = new Roo.grid.GridEditor(c.editor);
5153 this.lookup[c.id] = c;
5157 * The width of columns which have no width specified (defaults to 100)
5160 this.defaultWidth = 100;
5163 * Default sortable of columns which have no sortable specified (defaults to false)
5166 this.defaultSortable = false;
5170 * @event widthchange
5171 * Fires when the width of a column changes.
5172 * @param {ColumnModel} this
5173 * @param {Number} columnIndex The column index
5174 * @param {Number} newWidth The new width
5176 "widthchange": true,
5178 * @event headerchange
5179 * Fires when the text of a header changes.
5180 * @param {ColumnModel} this
5181 * @param {Number} columnIndex The column index
5182 * @param {Number} newText The new header text
5184 "headerchange": true,
5186 * @event hiddenchange
5187 * Fires when a column is hidden or "unhidden".
5188 * @param {ColumnModel} this
5189 * @param {Number} columnIndex The column index
5190 * @param {Boolean} hidden true if hidden, false otherwise
5192 "hiddenchange": true,
5194 * @event columnmoved
5195 * Fires when a column is moved.
5196 * @param {ColumnModel} this
5197 * @param {Number} oldIndex
5198 * @param {Number} newIndex
5200 "columnmoved" : true,
5202 * @event columlockchange
5203 * Fires when a column's locked state is changed
5204 * @param {ColumnModel} this
5205 * @param {Number} colIndex
5206 * @param {Boolean} locked true if locked
5208 "columnlockchange" : true
5210 Roo.grid.ColumnModel.superclass.constructor.call(this);
5212 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5214 * @cfg {String} header The header text to display in the Grid view.
5217 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5218 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5219 * specified, the column's index is used as an index into the Record's data Array.
5222 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5223 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5226 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5227 * Defaults to the value of the {@link #defaultSortable} property.
5228 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5231 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5234 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5237 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5240 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5243 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5244 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5245 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5246 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5249 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5252 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5255 * @cfg {String} cursor (Optional)
5258 * @cfg {String} tooltip (Optional)
5261 * @cfg {Number} xs (Optional)
5264 * @cfg {Number} sm (Optional)
5267 * @cfg {Number} md (Optional)
5270 * @cfg {Number} lg (Optional)
5273 * Returns the id of the column at the specified index.
5274 * @param {Number} index The column index
5275 * @return {String} the id
5277 getColumnId : function(index){
5278 return this.config[index].id;
5282 * Returns the column for a specified id.
5283 * @param {String} id The column id
5284 * @return {Object} the column
5286 getColumnById : function(id){
5287 return this.lookup[id];
5292 * Returns the column for a specified dataIndex.
5293 * @param {String} dataIndex The column dataIndex
5294 * @return {Object|Boolean} the column or false if not found
5296 getColumnByDataIndex: function(dataIndex){
5297 var index = this.findColumnIndex(dataIndex);
5298 return index > -1 ? this.config[index] : false;
5302 * Returns the index for a specified column id.
5303 * @param {String} id The column id
5304 * @return {Number} the index, or -1 if not found
5306 getIndexById : function(id){
5307 for(var i = 0, len = this.config.length; i < len; i++){
5308 if(this.config[i].id == id){
5316 * Returns the index for a specified column dataIndex.
5317 * @param {String} dataIndex The column dataIndex
5318 * @return {Number} the index, or -1 if not found
5321 findColumnIndex : function(dataIndex){
5322 for(var i = 0, len = this.config.length; i < len; i++){
5323 if(this.config[i].dataIndex == dataIndex){
5331 moveColumn : function(oldIndex, newIndex){
5332 var c = this.config[oldIndex];
5333 this.config.splice(oldIndex, 1);
5334 this.config.splice(newIndex, 0, c);
5335 this.dataMap = null;
5336 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5339 isLocked : function(colIndex){
5340 return this.config[colIndex].locked === true;
5343 setLocked : function(colIndex, value, suppressEvent){
5344 if(this.isLocked(colIndex) == value){
5347 this.config[colIndex].locked = value;
5349 this.fireEvent("columnlockchange", this, colIndex, value);
5353 getTotalLockedWidth : function(){
5355 for(var i = 0; i < this.config.length; i++){
5356 if(this.isLocked(i) && !this.isHidden(i)){
5357 this.totalWidth += this.getColumnWidth(i);
5363 getLockedCount : function(){
5364 for(var i = 0, len = this.config.length; i < len; i++){
5365 if(!this.isLocked(i)){
5370 return this.config.length;
5374 * Returns the number of columns.
5377 getColumnCount : function(visibleOnly){
5378 if(visibleOnly === true){
5380 for(var i = 0, len = this.config.length; i < len; i++){
5381 if(!this.isHidden(i)){
5387 return this.config.length;
5391 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5392 * @param {Function} fn
5393 * @param {Object} scope (optional)
5394 * @return {Array} result
5396 getColumnsBy : function(fn, scope){
5398 for(var i = 0, len = this.config.length; i < len; i++){
5399 var c = this.config[i];
5400 if(fn.call(scope||this, c, i) === true){
5408 * Returns true if the specified column is sortable.
5409 * @param {Number} col The column index
5412 isSortable : function(col){
5413 if(typeof this.config[col].sortable == "undefined"){
5414 return this.defaultSortable;
5416 return this.config[col].sortable;
5420 * Returns the rendering (formatting) function defined for the column.
5421 * @param {Number} col The column index.
5422 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5424 getRenderer : function(col){
5425 if(!this.config[col].renderer){
5426 return Roo.grid.ColumnModel.defaultRenderer;
5428 return this.config[col].renderer;
5432 * Sets the rendering (formatting) function for a column.
5433 * @param {Number} col The column index
5434 * @param {Function} fn The function to use to process the cell's raw data
5435 * to return HTML markup for the grid view. The render function is called with
5436 * the following parameters:<ul>
5437 * <li>Data value.</li>
5438 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5439 * <li>css A CSS style string to apply to the table cell.</li>
5440 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5441 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5442 * <li>Row index</li>
5443 * <li>Column index</li>
5444 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5446 setRenderer : function(col, fn){
5447 this.config[col].renderer = fn;
5451 * Returns the width for the specified column.
5452 * @param {Number} col The column index
5455 getColumnWidth : function(col){
5456 return this.config[col].width * 1 || this.defaultWidth;
5460 * Sets the width for a column.
5461 * @param {Number} col The column index
5462 * @param {Number} width The new width
5464 setColumnWidth : function(col, width, suppressEvent){
5465 this.config[col].width = width;
5466 this.totalWidth = null;
5468 this.fireEvent("widthchange", this, col, width);
5473 * Returns the total width of all columns.
5474 * @param {Boolean} includeHidden True to include hidden column widths
5477 getTotalWidth : function(includeHidden){
5478 if(!this.totalWidth){
5479 this.totalWidth = 0;
5480 for(var i = 0, len = this.config.length; i < len; i++){
5481 if(includeHidden || !this.isHidden(i)){
5482 this.totalWidth += this.getColumnWidth(i);
5486 return this.totalWidth;
5490 * Returns the header for the specified column.
5491 * @param {Number} col The column index
5494 getColumnHeader : function(col){
5495 return this.config[col].header;
5499 * Sets the header for a column.
5500 * @param {Number} col The column index
5501 * @param {String} header The new header
5503 setColumnHeader : function(col, header){
5504 this.config[col].header = header;
5505 this.fireEvent("headerchange", this, col, header);
5509 * Returns the tooltip for the specified column.
5510 * @param {Number} col The column index
5513 getColumnTooltip : function(col){
5514 return this.config[col].tooltip;
5517 * Sets the tooltip for a column.
5518 * @param {Number} col The column index
5519 * @param {String} tooltip The new tooltip
5521 setColumnTooltip : function(col, tooltip){
5522 this.config[col].tooltip = tooltip;
5526 * Returns the dataIndex for the specified column.
5527 * @param {Number} col The column index
5530 getDataIndex : function(col){
5531 return this.config[col].dataIndex;
5535 * Sets the dataIndex for a column.
5536 * @param {Number} col The column index
5537 * @param {Number} dataIndex The new dataIndex
5539 setDataIndex : function(col, dataIndex){
5540 this.config[col].dataIndex = dataIndex;
5546 * Returns true if the cell is editable.
5547 * @param {Number} colIndex The column index
5548 * @param {Number} rowIndex The row index - this is nto actually used..?
5551 isCellEditable : function(colIndex, rowIndex){
5552 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5556 * Returns the editor defined for the cell/column.
5557 * return false or null to disable editing.
5558 * @param {Number} colIndex The column index
5559 * @param {Number} rowIndex The row index
5562 getCellEditor : function(colIndex, rowIndex){
5563 return this.config[colIndex].editor;
5567 * Sets if a column is editable.
5568 * @param {Number} col The column index
5569 * @param {Boolean} editable True if the column is editable
5571 setEditable : function(col, editable){
5572 this.config[col].editable = editable;
5577 * Returns true if the column is hidden.
5578 * @param {Number} colIndex The column index
5581 isHidden : function(colIndex){
5582 return this.config[colIndex].hidden;
5587 * Returns true if the column width cannot be changed
5589 isFixed : function(colIndex){
5590 return this.config[colIndex].fixed;
5594 * Returns true if the column can be resized
5597 isResizable : function(colIndex){
5598 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5601 * Sets if a column is hidden.
5602 * @param {Number} colIndex The column index
5603 * @param {Boolean} hidden True if the column is hidden
5605 setHidden : function(colIndex, hidden){
5606 this.config[colIndex].hidden = hidden;
5607 this.totalWidth = null;
5608 this.fireEvent("hiddenchange", this, colIndex, hidden);
5612 * Sets the editor for a column.
5613 * @param {Number} col The column index
5614 * @param {Object} editor The editor object
5616 setEditor : function(col, editor){
5617 this.config[col].editor = editor;
5621 Roo.grid.ColumnModel.defaultRenderer = function(value)
5623 if(typeof value == "object") {
5626 if(typeof value == "string" && value.length < 1){
5630 return String.format("{0}", value);
5633 // Alias for backwards compatibility
5634 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5637 * Ext JS Library 1.1.1
5638 * Copyright(c) 2006-2007, Ext JS, LLC.
5640 * Originally Released Under LGPL - original licence link has changed is not relivant.
5643 * <script type="text/javascript">
5647 * @class Roo.LoadMask
5648 * A simple utility class for generically masking elements while loading data. If the element being masked has
5649 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5650 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5651 * element's UpdateManager load indicator and will be destroyed after the initial load.
5653 * Create a new LoadMask
5654 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5655 * @param {Object} config The config object
5657 Roo.LoadMask = function(el, config){
5658 this.el = Roo.get(el);
5659 Roo.apply(this, config);
5661 this.store.on('beforeload', this.onBeforeLoad, this);
5662 this.store.on('load', this.onLoad, this);
5663 this.store.on('loadexception', this.onLoadException, this);
5664 this.removeMask = false;
5666 var um = this.el.getUpdateManager();
5667 um.showLoadIndicator = false; // disable the default indicator
5668 um.on('beforeupdate', this.onBeforeLoad, this);
5669 um.on('update', this.onLoad, this);
5670 um.on('failure', this.onLoad, this);
5671 this.removeMask = true;
5675 Roo.LoadMask.prototype = {
5677 * @cfg {Boolean} removeMask
5678 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5679 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5683 * The text to display in a centered loading message box (defaults to 'Loading...')
5687 * @cfg {String} msgCls
5688 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5690 msgCls : 'x-mask-loading',
5693 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5699 * Disables the mask to prevent it from being displayed
5701 disable : function(){
5702 this.disabled = true;
5706 * Enables the mask so that it can be displayed
5708 enable : function(){
5709 this.disabled = false;
5712 onLoadException : function()
5716 if (typeof(arguments[3]) != 'undefined') {
5717 Roo.MessageBox.alert("Error loading",arguments[3]);
5721 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5722 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5729 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5734 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5738 onBeforeLoad : function(){
5740 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5745 destroy : function(){
5747 this.store.un('beforeload', this.onBeforeLoad, this);
5748 this.store.un('load', this.onLoad, this);
5749 this.store.un('loadexception', this.onLoadException, this);
5751 var um = this.el.getUpdateManager();
5752 um.un('beforeupdate', this.onBeforeLoad, this);
5753 um.un('update', this.onLoad, this);
5754 um.un('failure', this.onLoad, this);
5765 * @class Roo.bootstrap.Table
5766 * @extends Roo.bootstrap.Component
5767 * Bootstrap Table class
5768 * @cfg {String} cls table class
5769 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
5770 * @cfg {String} bgcolor Specifies the background color for a table
5771 * @cfg {Number} border Specifies whether the table cells should have borders or not
5772 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
5773 * @cfg {Number} cellspacing Specifies the space between cells
5774 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
5775 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
5776 * @cfg {String} sortable Specifies that the table should be sortable
5777 * @cfg {String} summary Specifies a summary of the content of a table
5778 * @cfg {Number} width Specifies the width of a table
5779 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
5781 * @cfg {boolean} striped Should the rows be alternative striped
5782 * @cfg {boolean} bordered Add borders to the table
5783 * @cfg {boolean} hover Add hover highlighting
5784 * @cfg {boolean} condensed Format condensed
5785 * @cfg {boolean} responsive Format condensed
5786 * @cfg {Boolean} loadMask (true|false) default false
5787 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
5788 * @cfg {Boolean} headerShow (true|false) generate thead, default true
5789 * @cfg {Boolean} rowSelection (true|false) default false
5790 * @cfg {Boolean} cellSelection (true|false) default false
5791 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
5792 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
5793 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
5797 * Create a new Table
5798 * @param {Object} config The config object
5801 Roo.bootstrap.Table = function(config){
5802 Roo.bootstrap.Table.superclass.constructor.call(this, config);
5807 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
5808 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
5809 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
5810 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
5812 this.sm = this.sm || {xtype: 'RowSelectionModel'};
5814 this.sm.grid = this;
5815 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
5816 this.sm = this.selModel;
5817 this.sm.xmodule = this.xmodule || false;
5820 if (this.cm && typeof(this.cm.config) == 'undefined') {
5821 this.colModel = new Roo.grid.ColumnModel(this.cm);
5822 this.cm = this.colModel;
5823 this.cm.xmodule = this.xmodule || false;
5826 this.store= Roo.factory(this.store, Roo.data);
5827 this.ds = this.store;
5828 this.ds.xmodule = this.xmodule || false;
5831 if (this.footer && this.store) {
5832 this.footer.dataSource = this.ds;
5833 this.footer = Roo.factory(this.footer);
5840 * Fires when a cell is clicked
5841 * @param {Roo.bootstrap.Table} this
5842 * @param {Roo.Element} el
5843 * @param {Number} rowIndex
5844 * @param {Number} columnIndex
5845 * @param {Roo.EventObject} e
5849 * @event celldblclick
5850 * Fires when a cell is double clicked
5851 * @param {Roo.bootstrap.Table} this
5852 * @param {Roo.Element} el
5853 * @param {Number} rowIndex
5854 * @param {Number} columnIndex
5855 * @param {Roo.EventObject} e
5857 "celldblclick" : true,
5860 * Fires when a row is clicked
5861 * @param {Roo.bootstrap.Table} this
5862 * @param {Roo.Element} el
5863 * @param {Number} rowIndex
5864 * @param {Roo.EventObject} e
5868 * @event rowdblclick
5869 * Fires when a row is double clicked
5870 * @param {Roo.bootstrap.Table} this
5871 * @param {Roo.Element} el
5872 * @param {Number} rowIndex
5873 * @param {Roo.EventObject} e
5875 "rowdblclick" : true,
5878 * Fires when a mouseover occur
5879 * @param {Roo.bootstrap.Table} this
5880 * @param {Roo.Element} el
5881 * @param {Number} rowIndex
5882 * @param {Number} columnIndex
5883 * @param {Roo.EventObject} e
5888 * Fires when a mouseout occur
5889 * @param {Roo.bootstrap.Table} this
5890 * @param {Roo.Element} el
5891 * @param {Number} rowIndex
5892 * @param {Number} columnIndex
5893 * @param {Roo.EventObject} e
5898 * Fires when a row is rendered, so you can change add a style to it.
5899 * @param {Roo.bootstrap.Table} this
5900 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
5904 * @event rowsrendered
5905 * Fires when all the rows have been rendered
5906 * @param {Roo.bootstrap.Table} this
5908 'rowsrendered' : true,
5910 * @event contextmenu
5911 * The raw contextmenu event for the entire grid.
5912 * @param {Roo.EventObject} e
5914 "contextmenu" : true,
5916 * @event rowcontextmenu
5917 * Fires when a row is right clicked
5918 * @param {Roo.bootstrap.Table} this
5919 * @param {Number} rowIndex
5920 * @param {Roo.EventObject} e
5922 "rowcontextmenu" : true,
5924 * @event cellcontextmenu
5925 * Fires when a cell is right clicked
5926 * @param {Roo.bootstrap.Table} this
5927 * @param {Number} rowIndex
5928 * @param {Number} cellIndex
5929 * @param {Roo.EventObject} e
5931 "cellcontextmenu" : true,
5933 * @event headercontextmenu
5934 * Fires when a header is right clicked
5935 * @param {Roo.bootstrap.Table} this
5936 * @param {Number} columnIndex
5937 * @param {Roo.EventObject} e
5939 "headercontextmenu" : true
5943 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
5969 rowSelection : false,
5970 cellSelection : false,
5973 // Roo.Element - the tbody
5975 // Roo.Element - thead element
5978 container: false, // used by gridpanel...
5982 getAutoCreate : function()
5984 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
5991 if (this.scrollBody) {
5992 cfg.cls += ' table-body-fixed';
5995 cfg.cls += ' table-striped';
5999 cfg.cls += ' table-hover';
6001 if (this.bordered) {
6002 cfg.cls += ' table-bordered';
6004 if (this.condensed) {
6005 cfg.cls += ' table-condensed';
6007 if (this.responsive) {
6008 cfg.cls += ' table-responsive';
6012 cfg.cls+= ' ' +this.cls;
6015 // this lot should be simplifed...
6018 cfg.align=this.align;
6021 cfg.bgcolor=this.bgcolor;
6024 cfg.border=this.border;
6026 if (this.cellpadding) {
6027 cfg.cellpadding=this.cellpadding;
6029 if (this.cellspacing) {
6030 cfg.cellspacing=this.cellspacing;
6033 cfg.frame=this.frame;
6036 cfg.rules=this.rules;
6038 if (this.sortable) {
6039 cfg.sortable=this.sortable;
6042 cfg.summary=this.summary;
6045 cfg.width=this.width;
6048 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6051 if(this.store || this.cm){
6052 if(this.headerShow){
6053 cfg.cn.push(this.renderHeader());
6056 cfg.cn.push(this.renderBody());
6058 if(this.footerShow){
6059 cfg.cn.push(this.renderFooter());
6061 // where does this come from?
6062 //cfg.cls+= ' TableGrid';
6065 return { cn : [ cfg ] };
6068 initEvents : function()
6070 if(!this.store || !this.cm){
6073 if (this.selModel) {
6074 this.selModel.initEvents();
6078 //Roo.log('initEvents with ds!!!!');
6080 this.mainBody = this.el.select('tbody', true).first();
6081 this.mainHead = this.el.select('thead', true).first();
6088 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6089 e.on('click', _this.sort, _this);
6092 this.mainBody.on("click", this.onClick, this);
6093 this.mainBody.on("dblclick", this.onDblClick, this);
6095 // why is this done????? = it breaks dialogs??
6096 //this.parent().el.setStyle('position', 'relative');
6100 this.footer.parentId = this.id;
6101 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6104 this.el.select('tfoot tr td').first().addClass('hide');
6108 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6110 this.store.on('load', this.onLoad, this);
6111 this.store.on('beforeload', this.onBeforeLoad, this);
6112 this.store.on('update', this.onUpdate, this);
6113 this.store.on('add', this.onAdd, this);
6114 this.store.on("clear", this.clear, this);
6116 this.el.on("contextmenu", this.onContextMenu, this);
6118 this.mainBody.on('scroll', this.onBodyScroll, this);
6123 onContextMenu : function(e, t)
6125 this.processEvent("contextmenu", e);
6128 processEvent : function(name, e)
6130 if (name != 'touchstart' ) {
6131 this.fireEvent(name, e);
6134 var t = e.getTarget();
6136 var cell = Roo.get(t);
6142 if(cell.findParent('tfoot', false, true)){
6146 if(cell.findParent('thead', false, true)){
6148 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6149 cell = Roo.get(t).findParent('th', false, true);
6151 Roo.log("failed to find th in thead?");
6152 Roo.log(e.getTarget());
6157 var cellIndex = cell.dom.cellIndex;
6159 var ename = name == 'touchstart' ? 'click' : name;
6160 this.fireEvent("header" + ename, this, cellIndex, e);
6165 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6166 cell = Roo.get(t).findParent('td', false, true);
6168 Roo.log("failed to find th in tbody?");
6169 Roo.log(e.getTarget());
6174 var row = cell.findParent('tr', false, true);
6175 var cellIndex = cell.dom.cellIndex;
6176 var rowIndex = row.dom.rowIndex - 1;
6180 this.fireEvent("row" + name, this, rowIndex, e);
6184 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6190 onMouseover : function(e, el)
6192 var cell = Roo.get(el);
6198 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6199 cell = cell.findParent('td', false, true);
6202 var row = cell.findParent('tr', false, true);
6203 var cellIndex = cell.dom.cellIndex;
6204 var rowIndex = row.dom.rowIndex - 1; // start from 0
6206 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6210 onMouseout : function(e, el)
6212 var cell = Roo.get(el);
6218 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6219 cell = cell.findParent('td', false, true);
6222 var row = cell.findParent('tr', false, true);
6223 var cellIndex = cell.dom.cellIndex;
6224 var rowIndex = row.dom.rowIndex - 1; // start from 0
6226 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6230 onClick : function(e, el)
6232 var cell = Roo.get(el);
6234 if(!cell || (!this.cellSelection && !this.rowSelection)){
6238 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6239 cell = cell.findParent('td', false, true);
6242 if(!cell || typeof(cell) == 'undefined'){
6246 var row = cell.findParent('tr', false, true);
6248 if(!row || typeof(row) == 'undefined'){
6252 var cellIndex = cell.dom.cellIndex;
6253 var rowIndex = this.getRowIndex(row);
6255 // why??? - should these not be based on SelectionModel?
6256 if(this.cellSelection){
6257 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6260 if(this.rowSelection){
6261 this.fireEvent('rowclick', this, row, rowIndex, e);
6267 onDblClick : function(e,el)
6269 var cell = Roo.get(el);
6271 if(!cell || (!this.cellSelection && !this.rowSelection)){
6275 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6276 cell = cell.findParent('td', false, true);
6279 if(!cell || typeof(cell) == 'undefined'){
6283 var row = cell.findParent('tr', false, true);
6285 if(!row || typeof(row) == 'undefined'){
6289 var cellIndex = cell.dom.cellIndex;
6290 var rowIndex = this.getRowIndex(row);
6292 if(this.cellSelection){
6293 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6296 if(this.rowSelection){
6297 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6301 sort : function(e,el)
6303 var col = Roo.get(el);
6305 if(!col.hasClass('sortable')){
6309 var sort = col.attr('sort');
6312 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6316 this.store.sortInfo = {field : sort, direction : dir};
6319 Roo.log("calling footer first");
6320 this.footer.onClick('first');
6323 this.store.load({ params : { start : 0 } });
6327 renderHeader : function()
6335 this.totalWidth = 0;
6337 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6339 var config = cm.config[i];
6344 html: cm.getColumnHeader(i)
6349 if(typeof(config.sortable) != 'undefined' && config.sortable){
6351 c.html = '<i class="glyphicon"></i>' + c.html;
6354 if(typeof(config.lgHeader) != 'undefined'){
6355 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6358 if(typeof(config.mdHeader) != 'undefined'){
6359 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6362 if(typeof(config.smHeader) != 'undefined'){
6363 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6366 if(typeof(config.xsHeader) != 'undefined'){
6367 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6374 if(typeof(config.tooltip) != 'undefined'){
6375 c.tooltip = config.tooltip;
6378 if(typeof(config.colspan) != 'undefined'){
6379 c.colspan = config.colspan;
6382 if(typeof(config.hidden) != 'undefined' && config.hidden){
6383 c.style += ' display:none;';
6386 if(typeof(config.dataIndex) != 'undefined'){
6387 c.sort = config.dataIndex;
6392 if(typeof(config.align) != 'undefined' && config.align.length){
6393 c.style += ' text-align:' + config.align + ';';
6396 if(typeof(config.width) != 'undefined'){
6397 c.style += ' width:' + config.width + 'px;';
6398 this.totalWidth += config.width;
6400 this.totalWidth += 100; // assume minimum of 100 per column?
6403 if(typeof(config.cls) != 'undefined'){
6404 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6407 ['xs','sm','md','lg'].map(function(size){
6409 if(typeof(config[size]) == 'undefined'){
6413 if (!config[size]) { // 0 = hidden
6414 c.cls += ' hidden-' + size;
6418 c.cls += ' col-' + size + '-' + config[size];
6428 renderBody : function()
6438 colspan : this.cm.getColumnCount()
6448 renderFooter : function()
6458 colspan : this.cm.getColumnCount()
6472 // Roo.log('ds onload');
6477 var ds = this.store;
6479 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6480 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6481 if (_this.store.sortInfo) {
6483 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6484 e.select('i', true).addClass(['glyphicon-arrow-up']);
6487 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6488 e.select('i', true).addClass(['glyphicon-arrow-down']);
6493 var tbody = this.mainBody;
6495 if(ds.getCount() > 0){
6496 ds.data.each(function(d,rowIndex){
6497 var row = this.renderRow(cm, ds, rowIndex);
6499 tbody.createChild(row);
6503 if(row.cellObjects.length){
6504 Roo.each(row.cellObjects, function(r){
6505 _this.renderCellObject(r);
6512 Roo.each(this.el.select('tbody td', true).elements, function(e){
6513 e.on('mouseover', _this.onMouseover, _this);
6516 Roo.each(this.el.select('tbody td', true).elements, function(e){
6517 e.on('mouseout', _this.onMouseout, _this);
6519 this.fireEvent('rowsrendered', this);
6520 //if(this.loadMask){
6521 // this.maskEl.hide();
6528 onUpdate : function(ds,record)
6530 this.refreshRow(record);
6534 onRemove : function(ds, record, index, isUpdate){
6535 if(isUpdate !== true){
6536 this.fireEvent("beforerowremoved", this, index, record);
6538 var bt = this.mainBody.dom;
6540 var rows = this.el.select('tbody > tr', true).elements;
6542 if(typeof(rows[index]) != 'undefined'){
6543 bt.removeChild(rows[index].dom);
6546 // if(bt.rows[index]){
6547 // bt.removeChild(bt.rows[index]);
6550 if(isUpdate !== true){
6551 //this.stripeRows(index);
6552 //this.syncRowHeights(index, index);
6554 this.fireEvent("rowremoved", this, index, record);
6558 onAdd : function(ds, records, rowIndex)
6560 //Roo.log('on Add called');
6561 // - note this does not handle multiple adding very well..
6562 var bt = this.mainBody.dom;
6563 for (var i =0 ; i < records.length;i++) {
6564 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6565 //Roo.log(records[i]);
6566 //Roo.log(this.store.getAt(rowIndex+i));
6567 this.insertRow(this.store, rowIndex + i, false);
6574 refreshRow : function(record){
6575 var ds = this.store, index;
6576 if(typeof record == 'number'){
6578 record = ds.getAt(index);
6580 index = ds.indexOf(record);
6582 this.insertRow(ds, index, true);
6584 this.onRemove(ds, record, index+1, true);
6586 //this.syncRowHeights(index, index);
6588 this.fireEvent("rowupdated", this, index, record);
6591 insertRow : function(dm, rowIndex, isUpdate){
6594 this.fireEvent("beforerowsinserted", this, rowIndex);
6596 //var s = this.getScrollState();
6597 var row = this.renderRow(this.cm, this.store, rowIndex);
6598 // insert before rowIndex..
6599 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6603 if(row.cellObjects.length){
6604 Roo.each(row.cellObjects, function(r){
6605 _this.renderCellObject(r);
6610 this.fireEvent("rowsinserted", this, rowIndex);
6611 //this.syncRowHeights(firstRow, lastRow);
6612 //this.stripeRows(firstRow);
6619 getRowDom : function(rowIndex)
6621 var rows = this.el.select('tbody > tr', true).elements;
6623 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6626 // returns the object tree for a tr..
6629 renderRow : function(cm, ds, rowIndex)
6632 var d = ds.getAt(rowIndex);
6639 var cellObjects = [];
6641 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6642 var config = cm.config[i];
6644 var renderer = cm.getRenderer(i);
6648 if(typeof(renderer) !== 'undefined'){
6649 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6651 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6652 // and are rendered into the cells after the row is rendered - using the id for the element.
6654 if(typeof(value) === 'object'){
6664 rowIndex : rowIndex,
6669 this.fireEvent('rowclass', this, rowcfg);
6673 cls : rowcfg.rowClass,
6675 html: (typeof(value) === 'object') ? '' : value
6682 if(typeof(config.colspan) != 'undefined'){
6683 td.colspan = config.colspan;
6686 if(typeof(config.hidden) != 'undefined' && config.hidden){
6687 td.style += ' display:none;';
6690 if(typeof(config.align) != 'undefined' && config.align.length){
6691 td.style += ' text-align:' + config.align + ';';
6694 if(typeof(config.width) != 'undefined'){
6695 td.style += ' width:' + config.width + 'px;';
6698 if(typeof(config.cursor) != 'undefined'){
6699 td.style += ' cursor:' + config.cursor + ';';
6702 if(typeof(config.cls) != 'undefined'){
6703 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6706 ['xs','sm','md','lg'].map(function(size){
6708 if(typeof(config[size]) == 'undefined'){
6712 if (!config[size]) { // 0 = hidden
6713 td.cls += ' hidden-' + size;
6717 td.cls += ' col-' + size + '-' + config[size];
6725 row.cellObjects = cellObjects;
6733 onBeforeLoad : function()
6735 //Roo.log('ds onBeforeLoad');
6739 //if(this.loadMask){
6740 // this.maskEl.show();
6748 this.el.select('tbody', true).first().dom.innerHTML = '';
6751 * Show or hide a row.
6752 * @param {Number} rowIndex to show or hide
6753 * @param {Boolean} state hide
6755 setRowVisibility : function(rowIndex, state)
6757 var bt = this.mainBody.dom;
6759 var rows = this.el.select('tbody > tr', true).elements;
6761 if(typeof(rows[rowIndex]) == 'undefined'){
6764 rows[rowIndex].dom.style.display = state ? '' : 'none';
6768 getSelectionModel : function(){
6770 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
6772 return this.selModel;
6775 * Render the Roo.bootstrap object from renderder
6777 renderCellObject : function(r)
6781 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
6783 var t = r.cfg.render(r.container);
6786 Roo.each(r.cfg.cn, function(c){
6788 container: t.getChildContainer(),
6791 _this.renderCellObject(child);
6796 getRowIndex : function(row)
6800 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
6811 * Returns the grid's underlying element = used by panel.Grid
6812 * @return {Element} The element
6814 getGridEl : function(){
6818 * Forces a resize - used by panel.Grid
6819 * @return {Element} The element
6821 autoSize : function()
6823 //var ctr = Roo.get(this.container.dom.parentElement);
6824 var ctr = Roo.get(this.el.dom);
6826 var thd = this.getGridEl().select('thead',true).first();
6827 var tbd = this.getGridEl().select('tbody', true).first();
6828 var tfd = this.getGridEl().select('tfoot', true).first();
6830 var cw = ctr.getWidth();
6834 tbd.setSize(ctr.getWidth(),
6835 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
6837 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
6840 cw = Math.max(cw, this.totalWidth);
6841 this.getGridEl().select('tr',true).setWidth(cw);
6842 // resize 'expandable coloumn?
6844 return; // we doe not have a view in this design..
6847 onBodyScroll: function()
6849 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
6850 this.mainHead.setStyle({
6851 'position' : 'relative',
6852 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6857 var scrollHeight = this.mainBody.dom.scrollHeight;
6859 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
6861 var height = this.mainBody.getHeight();
6863 if(scrollHeight - height == scrollTop) {
6865 var total = this.ds.getTotalCount();
6867 if(this.footer.cursor + this.footer.pageSize < total){
6869 this.footer.ds.load({
6871 start : this.footer.cursor + this.footer.pageSize,
6872 limit : this.footer.pageSize
6893 * @class Roo.bootstrap.TableCell
6894 * @extends Roo.bootstrap.Component
6895 * Bootstrap TableCell class
6896 * @cfg {String} html cell contain text
6897 * @cfg {String} cls cell class
6898 * @cfg {String} tag cell tag (td|th) default td
6899 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6900 * @cfg {String} align Aligns the content in a cell
6901 * @cfg {String} axis Categorizes cells
6902 * @cfg {String} bgcolor Specifies the background color of a cell
6903 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6904 * @cfg {Number} colspan Specifies the number of columns a cell should span
6905 * @cfg {String} headers Specifies one or more header cells a cell is related to
6906 * @cfg {Number} height Sets the height of a cell
6907 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
6908 * @cfg {Number} rowspan Sets the number of rows a cell should span
6909 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
6910 * @cfg {String} valign Vertical aligns the content in a cell
6911 * @cfg {Number} width Specifies the width of a cell
6914 * Create a new TableCell
6915 * @param {Object} config The config object
6918 Roo.bootstrap.TableCell = function(config){
6919 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
6922 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
6942 getAutoCreate : function(){
6943 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
6963 cfg.align=this.align
6969 cfg.bgcolor=this.bgcolor
6972 cfg.charoff=this.charoff
6975 cfg.colspan=this.colspan
6978 cfg.headers=this.headers
6981 cfg.height=this.height
6984 cfg.nowrap=this.nowrap
6987 cfg.rowspan=this.rowspan
6990 cfg.scope=this.scope
6993 cfg.valign=this.valign
6996 cfg.width=this.width
7015 * @class Roo.bootstrap.TableRow
7016 * @extends Roo.bootstrap.Component
7017 * Bootstrap TableRow class
7018 * @cfg {String} cls row class
7019 * @cfg {String} align Aligns the content in a table row
7020 * @cfg {String} bgcolor Specifies a background color for a table row
7021 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7022 * @cfg {String} valign Vertical aligns the content in a table row
7025 * Create a new TableRow
7026 * @param {Object} config The config object
7029 Roo.bootstrap.TableRow = function(config){
7030 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7033 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7041 getAutoCreate : function(){
7042 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7052 cfg.align = this.align;
7055 cfg.bgcolor = this.bgcolor;
7058 cfg.charoff = this.charoff;
7061 cfg.valign = this.valign;
7079 * @class Roo.bootstrap.TableBody
7080 * @extends Roo.bootstrap.Component
7081 * Bootstrap TableBody class
7082 * @cfg {String} cls element class
7083 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7084 * @cfg {String} align Aligns the content inside the element
7085 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7086 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7089 * Create a new TableBody
7090 * @param {Object} config The config object
7093 Roo.bootstrap.TableBody = function(config){
7094 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7097 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7105 getAutoCreate : function(){
7106 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7120 cfg.align = this.align;
7123 cfg.charoff = this.charoff;
7126 cfg.valign = this.valign;
7133 // initEvents : function()
7140 // this.store = Roo.factory(this.store, Roo.data);
7141 // this.store.on('load', this.onLoad, this);
7143 // this.store.load();
7147 // onLoad: function ()
7149 // this.fireEvent('load', this);
7159 * Ext JS Library 1.1.1
7160 * Copyright(c) 2006-2007, Ext JS, LLC.
7162 * Originally Released Under LGPL - original licence link has changed is not relivant.
7165 * <script type="text/javascript">
7168 // as we use this in bootstrap.
7169 Roo.namespace('Roo.form');
7171 * @class Roo.form.Action
7172 * Internal Class used to handle form actions
7174 * @param {Roo.form.BasicForm} el The form element or its id
7175 * @param {Object} config Configuration options
7180 // define the action interface
7181 Roo.form.Action = function(form, options){
7183 this.options = options || {};
7186 * Client Validation Failed
7189 Roo.form.Action.CLIENT_INVALID = 'client';
7191 * Server Validation Failed
7194 Roo.form.Action.SERVER_INVALID = 'server';
7196 * Connect to Server Failed
7199 Roo.form.Action.CONNECT_FAILURE = 'connect';
7201 * Reading Data from Server Failed
7204 Roo.form.Action.LOAD_FAILURE = 'load';
7206 Roo.form.Action.prototype = {
7208 failureType : undefined,
7209 response : undefined,
7213 run : function(options){
7218 success : function(response){
7223 handleResponse : function(response){
7227 // default connection failure
7228 failure : function(response){
7230 this.response = response;
7231 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7232 this.form.afterAction(this, false);
7235 processResponse : function(response){
7236 this.response = response;
7237 if(!response.responseText){
7240 this.result = this.handleResponse(response);
7244 // utility functions used internally
7245 getUrl : function(appendParams){
7246 var url = this.options.url || this.form.url || this.form.el.dom.action;
7248 var p = this.getParams();
7250 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7256 getMethod : function(){
7257 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7260 getParams : function(){
7261 var bp = this.form.baseParams;
7262 var p = this.options.params;
7264 if(typeof p == "object"){
7265 p = Roo.urlEncode(Roo.applyIf(p, bp));
7266 }else if(typeof p == 'string' && bp){
7267 p += '&' + Roo.urlEncode(bp);
7270 p = Roo.urlEncode(bp);
7275 createCallback : function(){
7277 success: this.success,
7278 failure: this.failure,
7280 timeout: (this.form.timeout*1000),
7281 upload: this.form.fileUpload ? this.success : undefined
7286 Roo.form.Action.Submit = function(form, options){
7287 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7290 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7293 haveProgress : false,
7294 uploadComplete : false,
7296 // uploadProgress indicator.
7297 uploadProgress : function()
7299 if (!this.form.progressUrl) {
7303 if (!this.haveProgress) {
7304 Roo.MessageBox.progress("Uploading", "Uploading");
7306 if (this.uploadComplete) {
7307 Roo.MessageBox.hide();
7311 this.haveProgress = true;
7313 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7315 var c = new Roo.data.Connection();
7317 url : this.form.progressUrl,
7322 success : function(req){
7323 //console.log(data);
7327 rdata = Roo.decode(req.responseText)
7329 Roo.log("Invalid data from server..");
7333 if (!rdata || !rdata.success) {
7335 Roo.MessageBox.alert(Roo.encode(rdata));
7338 var data = rdata.data;
7340 if (this.uploadComplete) {
7341 Roo.MessageBox.hide();
7346 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7347 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7350 this.uploadProgress.defer(2000,this);
7353 failure: function(data) {
7354 Roo.log('progress url failed ');
7365 // run get Values on the form, so it syncs any secondary forms.
7366 this.form.getValues();
7368 var o = this.options;
7369 var method = this.getMethod();
7370 var isPost = method == 'POST';
7371 if(o.clientValidation === false || this.form.isValid()){
7373 if (this.form.progressUrl) {
7374 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7375 (new Date() * 1) + '' + Math.random());
7380 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7381 form:this.form.el.dom,
7382 url:this.getUrl(!isPost),
7384 params:isPost ? this.getParams() : null,
7385 isUpload: this.form.fileUpload
7388 this.uploadProgress();
7390 }else if (o.clientValidation !== false){ // client validation failed
7391 this.failureType = Roo.form.Action.CLIENT_INVALID;
7392 this.form.afterAction(this, false);
7396 success : function(response)
7398 this.uploadComplete= true;
7399 if (this.haveProgress) {
7400 Roo.MessageBox.hide();
7404 var result = this.processResponse(response);
7405 if(result === true || result.success){
7406 this.form.afterAction(this, true);
7410 this.form.markInvalid(result.errors);
7411 this.failureType = Roo.form.Action.SERVER_INVALID;
7413 this.form.afterAction(this, false);
7415 failure : function(response)
7417 this.uploadComplete= true;
7418 if (this.haveProgress) {
7419 Roo.MessageBox.hide();
7422 this.response = response;
7423 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7424 this.form.afterAction(this, false);
7427 handleResponse : function(response){
7428 if(this.form.errorReader){
7429 var rs = this.form.errorReader.read(response);
7432 for(var i = 0, len = rs.records.length; i < len; i++) {
7433 var r = rs.records[i];
7437 if(errors.length < 1){
7441 success : rs.success,
7447 ret = Roo.decode(response.responseText);
7451 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7461 Roo.form.Action.Load = function(form, options){
7462 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7463 this.reader = this.form.reader;
7466 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7471 Roo.Ajax.request(Roo.apply(
7472 this.createCallback(), {
7473 method:this.getMethod(),
7474 url:this.getUrl(false),
7475 params:this.getParams()
7479 success : function(response){
7481 var result = this.processResponse(response);
7482 if(result === true || !result.success || !result.data){
7483 this.failureType = Roo.form.Action.LOAD_FAILURE;
7484 this.form.afterAction(this, false);
7487 this.form.clearInvalid();
7488 this.form.setValues(result.data);
7489 this.form.afterAction(this, true);
7492 handleResponse : function(response){
7493 if(this.form.reader){
7494 var rs = this.form.reader.read(response);
7495 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7497 success : rs.success,
7501 return Roo.decode(response.responseText);
7505 Roo.form.Action.ACTION_TYPES = {
7506 'load' : Roo.form.Action.Load,
7507 'submit' : Roo.form.Action.Submit
7516 * @class Roo.bootstrap.Form
7517 * @extends Roo.bootstrap.Component
7518 * Bootstrap Form class
7519 * @cfg {String} method GET | POST (default POST)
7520 * @cfg {String} labelAlign top | left (default top)
7521 * @cfg {String} align left | right - for navbars
7522 * @cfg {Boolean} loadMask load mask when submit (default true)
7527 * @param {Object} config The config object
7531 Roo.bootstrap.Form = function(config){
7532 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7534 Roo.bootstrap.Form.popover.apply();
7538 * @event clientvalidation
7539 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7540 * @param {Form} this
7541 * @param {Boolean} valid true if the form has passed client-side validation
7543 clientvalidation: true,
7545 * @event beforeaction
7546 * Fires before any action is performed. Return false to cancel the action.
7547 * @param {Form} this
7548 * @param {Action} action The action to be performed
7552 * @event actionfailed
7553 * Fires when an action fails.
7554 * @param {Form} this
7555 * @param {Action} action The action that failed
7557 actionfailed : true,
7559 * @event actioncomplete
7560 * Fires when an action is completed.
7561 * @param {Form} this
7562 * @param {Action} action The action that completed
7564 actioncomplete : true
7569 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7572 * @cfg {String} method
7573 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7578 * The URL to use for form actions if one isn't supplied in the action options.
7581 * @cfg {Boolean} fileUpload
7582 * Set to true if this form is a file upload.
7586 * @cfg {Object} baseParams
7587 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7591 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7595 * @cfg {Sting} align (left|right) for navbar forms
7600 activeAction : null,
7603 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7604 * element by passing it or its id or mask the form itself by passing in true.
7607 waitMsgTarget : false,
7612 * @cfg {Boolean} errorMask (true|false) default false
7617 * @cfg {Number} maskOffset Default 100
7621 getAutoCreate : function(){
7625 method : this.method || 'POST',
7626 id : this.id || Roo.id(),
7629 if (this.parent().xtype.match(/^Nav/)) {
7630 cfg.cls = 'navbar-form navbar-' + this.align;
7634 if (this.labelAlign == 'left' ) {
7635 cfg.cls += ' form-horizontal';
7641 initEvents : function()
7643 this.el.on('submit', this.onSubmit, this);
7644 // this was added as random key presses on the form where triggering form submit.
7645 this.el.on('keypress', function(e) {
7646 if (e.getCharCode() != 13) {
7649 // we might need to allow it for textareas.. and some other items.
7650 // check e.getTarget().
7652 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7656 Roo.log("keypress blocked");
7664 onSubmit : function(e){
7669 * Returns true if client-side validation on the form is successful.
7672 isValid : function(){
7673 var items = this.getItems();
7677 items.each(function(f){
7683 if(!target && f.el.isVisible(true)){
7689 if(this.errorMask && !valid){
7690 Roo.bootstrap.Form.popover.mask(this, target);
7697 * Returns true if any fields in this form have changed since their original load.
7700 isDirty : function(){
7702 var items = this.getItems();
7703 items.each(function(f){
7713 * Performs a predefined action (submit or load) or custom actions you define on this form.
7714 * @param {String} actionName The name of the action type
7715 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7716 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7717 * accept other config options):
7719 Property Type Description
7720 ---------------- --------------- ----------------------------------------------------------------------------------
7721 url String The url for the action (defaults to the form's url)
7722 method String The form method to use (defaults to the form's method, or POST if not defined)
7723 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7724 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7725 validate the form on the client (defaults to false)
7727 * @return {BasicForm} this
7729 doAction : function(action, options){
7730 if(typeof action == 'string'){
7731 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7733 if(this.fireEvent('beforeaction', this, action) !== false){
7734 this.beforeAction(action);
7735 action.run.defer(100, action);
7741 beforeAction : function(action){
7742 var o = action.options;
7745 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7747 // not really supported yet.. ??
7749 //if(this.waitMsgTarget === true){
7750 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7751 //}else if(this.waitMsgTarget){
7752 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7753 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7755 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7761 afterAction : function(action, success){
7762 this.activeAction = null;
7763 var o = action.options;
7765 //if(this.waitMsgTarget === true){
7767 //}else if(this.waitMsgTarget){
7768 // this.waitMsgTarget.unmask();
7770 // Roo.MessageBox.updateProgress(1);
7771 // Roo.MessageBox.hide();
7778 Roo.callback(o.success, o.scope, [this, action]);
7779 this.fireEvent('actioncomplete', this, action);
7783 // failure condition..
7784 // we have a scenario where updates need confirming.
7785 // eg. if a locking scenario exists..
7786 // we look for { errors : { needs_confirm : true }} in the response.
7788 (typeof(action.result) != 'undefined') &&
7789 (typeof(action.result.errors) != 'undefined') &&
7790 (typeof(action.result.errors.needs_confirm) != 'undefined')
7793 Roo.log("not supported yet");
7796 Roo.MessageBox.confirm(
7797 "Change requires confirmation",
7798 action.result.errorMsg,
7803 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7813 Roo.callback(o.failure, o.scope, [this, action]);
7814 // show an error message if no failed handler is set..
7815 if (!this.hasListener('actionfailed')) {
7816 Roo.log("need to add dialog support");
7818 Roo.MessageBox.alert("Error",
7819 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7820 action.result.errorMsg :
7821 "Saving Failed, please check your entries or try again"
7826 this.fireEvent('actionfailed', this, action);
7831 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7832 * @param {String} id The value to search for
7835 findField : function(id){
7836 var items = this.getItems();
7837 var field = items.get(id);
7839 items.each(function(f){
7840 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7847 return field || null;
7850 * Mark fields in this form invalid in bulk.
7851 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7852 * @return {BasicForm} this
7854 markInvalid : function(errors){
7855 if(errors instanceof Array){
7856 for(var i = 0, len = errors.length; i < len; i++){
7857 var fieldError = errors[i];
7858 var f = this.findField(fieldError.id);
7860 f.markInvalid(fieldError.msg);
7866 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7867 field.markInvalid(errors[id]);
7871 //Roo.each(this.childForms || [], function (f) {
7872 // f.markInvalid(errors);
7879 * Set values for fields in this form in bulk.
7880 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7881 * @return {BasicForm} this
7883 setValues : function(values){
7884 if(values instanceof Array){ // array of objects
7885 for(var i = 0, len = values.length; i < len; i++){
7887 var f = this.findField(v.id);
7889 f.setValue(v.value);
7890 if(this.trackResetOnLoad){
7891 f.originalValue = f.getValue();
7895 }else{ // object hash
7898 if(typeof values[id] != 'function' && (field = this.findField(id))){
7900 if (field.setFromData &&
7902 field.displayField &&
7903 // combos' with local stores can
7904 // be queried via setValue()
7905 // to set their value..
7906 (field.store && !field.store.isLocal)
7910 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
7911 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
7912 field.setFromData(sd);
7914 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
7916 field.setFromData(values);
7919 field.setValue(values[id]);
7923 if(this.trackResetOnLoad){
7924 field.originalValue = field.getValue();
7930 //Roo.each(this.childForms || [], function (f) {
7931 // f.setValues(values);
7938 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
7939 * they are returned as an array.
7940 * @param {Boolean} asString
7943 getValues : function(asString){
7944 //if (this.childForms) {
7945 // copy values from the child forms
7946 // Roo.each(this.childForms, function (f) {
7947 // this.setValues(f.getValues());
7953 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
7954 if(asString === true){
7957 return Roo.urlDecode(fs);
7961 * Returns the fields in this form as an object with key/value pairs.
7962 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
7965 getFieldValues : function(with_hidden)
7967 var items = this.getItems();
7969 items.each(function(f){
7975 var v = f.getValue();
7977 if (f.inputType =='radio') {
7978 if (typeof(ret[f.getName()]) == 'undefined') {
7979 ret[f.getName()] = ''; // empty..
7982 if (!f.el.dom.checked) {
7990 if(f.xtype == 'MoneyField'){
7991 ret[f.currencyName] = f.getCurrency();
7994 // not sure if this supported any more..
7995 if ((typeof(v) == 'object') && f.getRawValue) {
7996 v = f.getRawValue() ; // dates..
7998 // combo boxes where name != hiddenName...
7999 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8000 ret[f.name] = f.getRawValue();
8002 ret[f.getName()] = v;
8009 * Clears all invalid messages in this form.
8010 * @return {BasicForm} this
8012 clearInvalid : function(){
8013 var items = this.getItems();
8015 items.each(function(f){
8026 * @return {BasicForm} this
8029 var items = this.getItems();
8030 items.each(function(f){
8034 Roo.each(this.childForms || [], function (f) {
8042 getItems : function()
8044 var r=new Roo.util.MixedCollection(false, function(o){
8045 return o.id || (o.id = Roo.id());
8047 var iter = function(el) {
8054 Roo.each(el.items,function(e) {
8068 Roo.apply(Roo.bootstrap.Form, {
8095 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8096 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8097 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8098 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8101 this.maskEl.top.enableDisplayMode("block");
8102 this.maskEl.left.enableDisplayMode("block");
8103 this.maskEl.bottom.enableDisplayMode("block");
8104 this.maskEl.right.enableDisplayMode("block");
8106 this.toolTip = new Roo.bootstrap.Tooltip({
8107 cls : 'roo-form-error-popover',
8109 'left' : ['r-l', [-2,0], 'right'],
8110 'right' : ['l-r', [2,0], 'left'],
8111 'bottom' : ['tl-bl', [0,2], 'top'],
8112 'top' : [ 'bl-tl', [0,-2], 'bottom']
8116 this.toolTip.render(Roo.get(document.body));
8118 this.toolTip.el.enableDisplayMode("block");
8120 Roo.get(document.body).on('click', function(){
8124 Roo.get(document.body).on('touchstart', function(){
8128 this.isApplied = true
8131 mask : function(form, target)
8135 this.target = target;
8137 if(!this.form.errorMask || !target.el){
8141 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8143 Roo.log(scrollable);
8145 var ot = this.target.el.calcOffsetsTo(scrollable);
8147 var scrollTo = ot[1] - this.form.maskOffset;
8149 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8151 scrollable.scrollTo('top', scrollTo);
8153 var box = this.target.el.getBox();
8155 var zIndex = Roo.bootstrap.Modal.zIndex++;
8158 this.maskEl.top.setStyle('position', 'absolute');
8159 this.maskEl.top.setStyle('z-index', zIndex);
8160 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8161 this.maskEl.top.setLeft(0);
8162 this.maskEl.top.setTop(0);
8163 this.maskEl.top.show();
8165 this.maskEl.left.setStyle('position', 'absolute');
8166 this.maskEl.left.setStyle('z-index', zIndex);
8167 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8168 this.maskEl.left.setLeft(0);
8169 this.maskEl.left.setTop(box.y - this.padding);
8170 this.maskEl.left.show();
8172 this.maskEl.bottom.setStyle('position', 'absolute');
8173 this.maskEl.bottom.setStyle('z-index', zIndex);
8174 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8175 this.maskEl.bottom.setLeft(0);
8176 this.maskEl.bottom.setTop(box.bottom + this.padding);
8177 this.maskEl.bottom.show();
8179 this.maskEl.right.setStyle('position', 'absolute');
8180 this.maskEl.right.setStyle('z-index', zIndex);
8181 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8182 this.maskEl.right.setLeft(box.right + this.padding);
8183 this.maskEl.right.setTop(box.y - this.padding);
8184 this.maskEl.right.show();
8186 this.toolTip.bindEl = this.target.el;
8188 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8190 var tip = this.target.blankText;
8192 if(this.target.getValue() !== '' ) {
8194 if (this.target.invalidText.length) {
8195 tip = this.target.invalidText;
8196 } else if (this.target.regexText.length){
8197 tip = this.target.regexText;
8201 this.toolTip.show(tip);
8203 this.intervalID = window.setInterval(function() {
8204 Roo.bootstrap.Form.popover.unmask();
8207 window.onwheel = function(){ return false;};
8209 (function(){ this.isMasked = true; }).defer(500, this);
8215 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8219 this.maskEl.top.setStyle('position', 'absolute');
8220 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8221 this.maskEl.top.hide();
8223 this.maskEl.left.setStyle('position', 'absolute');
8224 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8225 this.maskEl.left.hide();
8227 this.maskEl.bottom.setStyle('position', 'absolute');
8228 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8229 this.maskEl.bottom.hide();
8231 this.maskEl.right.setStyle('position', 'absolute');
8232 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8233 this.maskEl.right.hide();
8235 this.toolTip.hide();
8237 this.toolTip.el.hide();
8239 window.onwheel = function(){ return true;};
8241 if(this.intervalID){
8242 window.clearInterval(this.intervalID);
8243 this.intervalID = false;
8246 this.isMasked = false;
8256 * Ext JS Library 1.1.1
8257 * Copyright(c) 2006-2007, Ext JS, LLC.
8259 * Originally Released Under LGPL - original licence link has changed is not relivant.
8262 * <script type="text/javascript">
8265 * @class Roo.form.VTypes
8266 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8269 Roo.form.VTypes = function(){
8270 // closure these in so they are only created once.
8271 var alpha = /^[a-zA-Z_]+$/;
8272 var alphanum = /^[a-zA-Z0-9_]+$/;
8273 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8274 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8276 // All these messages and functions are configurable
8279 * The function used to validate email addresses
8280 * @param {String} value The email address
8282 'email' : function(v){
8283 return email.test(v);
8286 * The error text to display when the email validation function returns false
8289 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8291 * The keystroke filter mask to be applied on email input
8294 'emailMask' : /[a-z0-9_\.\-@]/i,
8297 * The function used to validate URLs
8298 * @param {String} value The URL
8300 'url' : function(v){
8304 * The error text to display when the url validation function returns false
8307 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8310 * The function used to validate alpha values
8311 * @param {String} value The value
8313 'alpha' : function(v){
8314 return alpha.test(v);
8317 * The error text to display when the alpha validation function returns false
8320 'alphaText' : 'This field should only contain letters and _',
8322 * The keystroke filter mask to be applied on alpha input
8325 'alphaMask' : /[a-z_]/i,
8328 * The function used to validate alphanumeric values
8329 * @param {String} value The value
8331 'alphanum' : function(v){
8332 return alphanum.test(v);
8335 * The error text to display when the alphanumeric validation function returns false
8338 'alphanumText' : 'This field should only contain letters, numbers and _',
8340 * The keystroke filter mask to be applied on alphanumeric input
8343 'alphanumMask' : /[a-z0-9_]/i
8353 * @class Roo.bootstrap.Input
8354 * @extends Roo.bootstrap.Component
8355 * Bootstrap Input class
8356 * @cfg {Boolean} disabled is it disabled
8357 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8358 * @cfg {String} name name of the input
8359 * @cfg {string} fieldLabel - the label associated
8360 * @cfg {string} placeholder - placeholder to put in text.
8361 * @cfg {string} before - input group add on before
8362 * @cfg {string} after - input group add on after
8363 * @cfg {string} size - (lg|sm) or leave empty..
8364 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8365 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8366 * @cfg {Number} md colspan out of 12 for computer-sized screens
8367 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8368 * @cfg {string} value default value of the input
8369 * @cfg {Number} labelWidth set the width of label
8370 * @cfg {Number} labellg set the width of label (1-12)
8371 * @cfg {Number} labelmd set the width of label (1-12)
8372 * @cfg {Number} labelsm set the width of label (1-12)
8373 * @cfg {Number} labelxs set the width of label (1-12)
8374 * @cfg {String} labelAlign (top|left)
8375 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8376 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8377 * @cfg {String} indicatorpos (left|right) default left
8379 * @cfg {String} align (left|center|right) Default left
8380 * @cfg {Boolean} forceFeedback (true|false) Default false
8386 * Create a new Input
8387 * @param {Object} config The config object
8390 Roo.bootstrap.Input = function(config){
8392 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8397 * Fires when this field receives input focus.
8398 * @param {Roo.form.Field} this
8403 * Fires when this field loses input focus.
8404 * @param {Roo.form.Field} this
8409 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8410 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8411 * @param {Roo.form.Field} this
8412 * @param {Roo.EventObject} e The event object
8417 * Fires just before the field blurs if the field value has changed.
8418 * @param {Roo.form.Field} this
8419 * @param {Mixed} newValue The new value
8420 * @param {Mixed} oldValue The original value
8425 * Fires after the field has been marked as invalid.
8426 * @param {Roo.form.Field} this
8427 * @param {String} msg The validation message
8432 * Fires after the field has been validated with no errors.
8433 * @param {Roo.form.Field} this
8438 * Fires after the key up
8439 * @param {Roo.form.Field} this
8440 * @param {Roo.EventObject} e The event Object
8446 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8448 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8449 automatic validation (defaults to "keyup").
8451 validationEvent : "keyup",
8453 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8455 validateOnBlur : true,
8457 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8459 validationDelay : 250,
8461 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8463 focusClass : "x-form-focus", // not needed???
8467 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8469 invalidClass : "has-warning",
8472 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8474 validClass : "has-success",
8477 * @cfg {Boolean} hasFeedback (true|false) default true
8482 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8484 invalidFeedbackClass : "glyphicon-warning-sign",
8487 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8489 validFeedbackClass : "glyphicon-ok",
8492 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8494 selectOnFocus : false,
8497 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8501 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8506 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8508 disableKeyFilter : false,
8511 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8515 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8519 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8521 blankText : "Please complete this mandatory field",
8524 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8528 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8530 maxLength : Number.MAX_VALUE,
8532 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8534 minLengthText : "The minimum length for this field is {0}",
8536 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8538 maxLengthText : "The maximum length for this field is {0}",
8542 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8543 * If available, this function will be called only after the basic validators all return true, and will be passed the
8544 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8548 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8549 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8550 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8554 * @cfg {String} regexText -- Depricated - use Invalid Text
8559 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8565 autocomplete: false,
8584 formatedValue : false,
8585 forceFeedback : false,
8587 indicatorpos : 'left',
8594 parentLabelAlign : function()
8597 while (parent.parent()) {
8598 parent = parent.parent();
8599 if (typeof(parent.labelAlign) !='undefined') {
8600 return parent.labelAlign;
8607 getAutoCreate : function()
8609 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8615 if(this.inputType != 'hidden'){
8616 cfg.cls = 'form-group' //input-group
8622 type : this.inputType,
8624 cls : 'form-control',
8625 placeholder : this.placeholder || '',
8626 autocomplete : this.autocomplete || 'new-password'
8630 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8633 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8634 input.maxLength = this.maxLength;
8637 if (this.disabled) {
8638 input.disabled=true;
8641 if (this.readOnly) {
8642 input.readonly=true;
8646 input.name = this.name;
8650 input.cls += ' input-' + this.size;
8654 ['xs','sm','md','lg'].map(function(size){
8655 if (settings[size]) {
8656 cfg.cls += ' col-' + size + '-' + settings[size];
8660 var inputblock = input;
8664 cls: 'glyphicon form-control-feedback'
8667 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8670 cls : 'has-feedback',
8678 if (this.before || this.after) {
8681 cls : 'input-group',
8685 if (this.before && typeof(this.before) == 'string') {
8687 inputblock.cn.push({
8689 cls : 'roo-input-before input-group-addon',
8693 if (this.before && typeof(this.before) == 'object') {
8694 this.before = Roo.factory(this.before);
8696 inputblock.cn.push({
8698 cls : 'roo-input-before input-group-' +
8699 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8703 inputblock.cn.push(input);
8705 if (this.after && typeof(this.after) == 'string') {
8706 inputblock.cn.push({
8708 cls : 'roo-input-after input-group-addon',
8712 if (this.after && typeof(this.after) == 'object') {
8713 this.after = Roo.factory(this.after);
8715 inputblock.cn.push({
8717 cls : 'roo-input-after input-group-' +
8718 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8722 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8723 inputblock.cls += ' has-feedback';
8724 inputblock.cn.push(feedback);
8728 if (align ==='left' && this.fieldLabel.length) {
8730 cfg.cls += ' roo-form-group-label-left';
8735 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8736 tooltip : 'This field is required'
8741 cls : 'control-label',
8742 html : this.fieldLabel
8753 var labelCfg = cfg.cn[1];
8754 var contentCfg = cfg.cn[2];
8756 if(this.indicatorpos == 'right'){
8761 cls : 'control-label',
8765 html : this.fieldLabel
8769 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8770 tooltip : 'This field is required'
8783 labelCfg = cfg.cn[0];
8784 contentCfg = cfg.cn[1];
8788 if(this.labelWidth > 12){
8789 labelCfg.style = "width: " + this.labelWidth + 'px';
8792 if(this.labelWidth < 13 && this.labelmd == 0){
8793 this.labelmd = this.labelWidth;
8796 if(this.labellg > 0){
8797 labelCfg.cls += ' col-lg-' + this.labellg;
8798 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8801 if(this.labelmd > 0){
8802 labelCfg.cls += ' col-md-' + this.labelmd;
8803 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8806 if(this.labelsm > 0){
8807 labelCfg.cls += ' col-sm-' + this.labelsm;
8808 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8811 if(this.labelxs > 0){
8812 labelCfg.cls += ' col-xs-' + this.labelxs;
8813 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8817 } else if ( this.fieldLabel.length) {
8822 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8823 tooltip : 'This field is required'
8827 //cls : 'input-group-addon',
8828 html : this.fieldLabel
8836 if(this.indicatorpos == 'right'){
8841 //cls : 'input-group-addon',
8842 html : this.fieldLabel
8847 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8848 tooltip : 'This field is required'
8868 if (this.parentType === 'Navbar' && this.parent().bar) {
8869 cfg.cls += ' navbar-form';
8872 if (this.parentType === 'NavGroup') {
8873 cfg.cls += ' navbar-form';
8881 * return the real input element.
8883 inputEl: function ()
8885 return this.el.select('input.form-control',true).first();
8888 tooltipEl : function()
8890 return this.inputEl();
8893 indicatorEl : function()
8895 var indicator = this.el.select('i.roo-required-indicator',true).first();
8905 setDisabled : function(v)
8907 var i = this.inputEl().dom;
8909 i.removeAttribute('disabled');
8913 i.setAttribute('disabled','true');
8915 initEvents : function()
8918 this.inputEl().on("keydown" , this.fireKey, this);
8919 this.inputEl().on("focus", this.onFocus, this);
8920 this.inputEl().on("blur", this.onBlur, this);
8922 this.inputEl().relayEvent('keyup', this);
8924 this.indicator = this.indicatorEl();
8927 this.indicator.addClass('invisible');
8931 // reference to original value for reset
8932 this.originalValue = this.getValue();
8933 //Roo.form.TextField.superclass.initEvents.call(this);
8934 if(this.validationEvent == 'keyup'){
8935 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8936 this.inputEl().on('keyup', this.filterValidation, this);
8938 else if(this.validationEvent !== false){
8939 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8942 if(this.selectOnFocus){
8943 this.on("focus", this.preFocus, this);
8946 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8947 this.inputEl().on("keypress", this.filterKeys, this);
8949 this.inputEl().relayEvent('keypress', this);
8952 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8953 this.el.on("click", this.autoSize, this);
8956 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
8957 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
8960 if (typeof(this.before) == 'object') {
8961 this.before.render(this.el.select('.roo-input-before',true).first());
8963 if (typeof(this.after) == 'object') {
8964 this.after.render(this.el.select('.roo-input-after',true).first());
8969 filterValidation : function(e){
8970 if(!e.isNavKeyPress()){
8971 this.validationTask.delay(this.validationDelay);
8975 * Validates the field value
8976 * @return {Boolean} True if the value is valid, else false
8978 validate : function(){
8979 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
8980 if(this.disabled || this.validateValue(this.getRawValue())){
8991 * Validates a value according to the field's validation rules and marks the field as invalid
8992 * if the validation fails
8993 * @param {Mixed} value The value to validate
8994 * @return {Boolean} True if the value is valid, else false
8996 validateValue : function(value){
8997 if(value.length < 1) { // if it's blank
8998 if(this.allowBlank){
9001 return this.inputEl().hasClass('hide') ? true : false;
9004 if(value.length < this.minLength){
9007 if(value.length > this.maxLength){
9011 var vt = Roo.form.VTypes;
9012 if(!vt[this.vtype](value, this)){
9016 if(typeof this.validator == "function"){
9017 var msg = this.validator(value);
9021 if (typeof(msg) == 'string') {
9022 this.invalidText = msg;
9026 if(this.regex && !this.regex.test(value)){
9036 fireKey : function(e){
9037 //Roo.log('field ' + e.getKey());
9038 if(e.isNavKeyPress()){
9039 this.fireEvent("specialkey", this, e);
9042 focus : function (selectText){
9044 this.inputEl().focus();
9045 if(selectText === true){
9046 this.inputEl().dom.select();
9052 onFocus : function(){
9053 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9054 // this.el.addClass(this.focusClass);
9057 this.hasFocus = true;
9058 this.startValue = this.getValue();
9059 this.fireEvent("focus", this);
9063 beforeBlur : Roo.emptyFn,
9067 onBlur : function(){
9069 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9070 //this.el.removeClass(this.focusClass);
9072 this.hasFocus = false;
9073 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9076 var v = this.getValue();
9077 if(String(v) !== String(this.startValue)){
9078 this.fireEvent('change', this, v, this.startValue);
9080 this.fireEvent("blur", this);
9084 * Resets the current field value to the originally loaded value and clears any validation messages
9087 this.setValue(this.originalValue);
9091 * Returns the name of the field
9092 * @return {Mixed} name The name field
9094 getName: function(){
9098 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9099 * @return {Mixed} value The field value
9101 getValue : function(){
9103 var v = this.inputEl().getValue();
9108 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9109 * @return {Mixed} value The field value
9111 getRawValue : function(){
9112 var v = this.inputEl().getValue();
9118 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9119 * @param {Mixed} value The value to set
9121 setRawValue : function(v){
9122 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9125 selectText : function(start, end){
9126 var v = this.getRawValue();
9128 start = start === undefined ? 0 : start;
9129 end = end === undefined ? v.length : end;
9130 var d = this.inputEl().dom;
9131 if(d.setSelectionRange){
9132 d.setSelectionRange(start, end);
9133 }else if(d.createTextRange){
9134 var range = d.createTextRange();
9135 range.moveStart("character", start);
9136 range.moveEnd("character", v.length-end);
9143 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9144 * @param {Mixed} value The value to set
9146 setValue : function(v){
9149 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9155 processValue : function(value){
9156 if(this.stripCharsRe){
9157 var newValue = value.replace(this.stripCharsRe, '');
9158 if(newValue !== value){
9159 this.setRawValue(newValue);
9166 preFocus : function(){
9168 if(this.selectOnFocus){
9169 this.inputEl().dom.select();
9172 filterKeys : function(e){
9174 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9177 var c = e.getCharCode(), cc = String.fromCharCode(c);
9178 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9181 if(!this.maskRe.test(cc)){
9186 * Clear any invalid styles/messages for this field
9188 clearInvalid : function(){
9190 if(!this.el || this.preventMark){ // not rendered
9195 this.el.removeClass(this.invalidClass);
9197 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9199 var feedback = this.el.select('.form-control-feedback', true).first();
9202 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9207 this.fireEvent('valid', this);
9211 * Mark this field as valid
9213 markValid : function()
9215 if(!this.el || this.preventMark){ // not rendered...
9219 this.el.removeClass([this.invalidClass, this.validClass]);
9221 var feedback = this.el.select('.form-control-feedback', true).first();
9224 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9231 if(this.allowBlank && !this.getRawValue().length){
9236 this.indicator.removeClass('visible');
9237 this.indicator.addClass('invisible');
9240 this.el.addClass(this.validClass);
9242 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9244 var feedback = this.el.select('.form-control-feedback', true).first();
9247 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9248 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9253 this.fireEvent('valid', this);
9257 * Mark this field as invalid
9258 * @param {String} msg The validation message
9260 markInvalid : function(msg)
9262 if(!this.el || this.preventMark){ // not rendered
9266 this.el.removeClass([this.invalidClass, this.validClass]);
9268 var feedback = this.el.select('.form-control-feedback', true).first();
9271 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9278 if(this.allowBlank && !this.getRawValue().length){
9283 this.indicator.removeClass('invisible');
9284 this.indicator.addClass('visible');
9287 this.el.addClass(this.invalidClass);
9289 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9291 var feedback = this.el.select('.form-control-feedback', true).first();
9294 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9296 if(this.getValue().length || this.forceFeedback){
9297 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9304 this.fireEvent('invalid', this, msg);
9307 SafariOnKeyDown : function(event)
9309 // this is a workaround for a password hang bug on chrome/ webkit.
9310 if (this.inputEl().dom.type != 'password') {
9314 var isSelectAll = false;
9316 if(this.inputEl().dom.selectionEnd > 0){
9317 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9319 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9320 event.preventDefault();
9325 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9327 event.preventDefault();
9328 // this is very hacky as keydown always get's upper case.
9330 var cc = String.fromCharCode(event.getCharCode());
9331 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9335 adjustWidth : function(tag, w){
9336 tag = tag.toLowerCase();
9337 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9338 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9342 if(tag == 'textarea'){
9345 }else if(Roo.isOpera){
9349 if(tag == 'textarea'){
9357 setFieldLabel : function(v)
9363 this.fieldLabel = v;
9366 var ar = this.el.select('label > span',true);
9367 if (!ar.elements.length) {
9368 Roo.log("could not find label > span on element");
9372 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9376 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9389 * @class Roo.bootstrap.TextArea
9390 * @extends Roo.bootstrap.Input
9391 * Bootstrap TextArea class
9392 * @cfg {Number} cols Specifies the visible width of a text area
9393 * @cfg {Number} rows Specifies the visible number of lines in a text area
9394 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9395 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9396 * @cfg {string} html text
9399 * Create a new TextArea
9400 * @param {Object} config The config object
9403 Roo.bootstrap.TextArea = function(config){
9404 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9408 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9418 getAutoCreate : function(){
9420 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9426 if(this.inputType != 'hidden'){
9427 cfg.cls = 'form-group' //input-group
9435 value : this.value || '',
9436 html: this.html || '',
9437 cls : 'form-control',
9438 placeholder : this.placeholder || ''
9442 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9443 input.maxLength = this.maxLength;
9447 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9451 input.cols = this.cols;
9454 if (this.readOnly) {
9455 input.readonly = true;
9459 input.name = this.name;
9463 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9467 ['xs','sm','md','lg'].map(function(size){
9468 if (settings[size]) {
9469 cfg.cls += ' col-' + size + '-' + settings[size];
9473 var inputblock = input;
9475 if(this.hasFeedback && !this.allowBlank){
9479 cls: 'glyphicon form-control-feedback'
9483 cls : 'has-feedback',
9492 if (this.before || this.after) {
9495 cls : 'input-group',
9499 inputblock.cn.push({
9501 cls : 'input-group-addon',
9506 inputblock.cn.push(input);
9508 if(this.hasFeedback && !this.allowBlank){
9509 inputblock.cls += ' has-feedback';
9510 inputblock.cn.push(feedback);
9514 inputblock.cn.push({
9516 cls : 'input-group-addon',
9523 if (align ==='left' && this.fieldLabel.length) {
9528 cls : 'control-label',
9529 html : this.fieldLabel
9540 if(this.labelWidth > 12){
9541 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9544 if(this.labelWidth < 13 && this.labelmd == 0){
9545 this.labelmd = this.labelWidth;
9548 if(this.labellg > 0){
9549 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9550 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9553 if(this.labelmd > 0){
9554 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9555 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9558 if(this.labelsm > 0){
9559 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9560 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9563 if(this.labelxs > 0){
9564 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9565 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9568 } else if ( this.fieldLabel.length) {
9573 //cls : 'input-group-addon',
9574 html : this.fieldLabel
9592 if (this.disabled) {
9593 input.disabled=true;
9600 * return the real textarea element.
9602 inputEl: function ()
9604 return this.el.select('textarea.form-control',true).first();
9608 * Clear any invalid styles/messages for this field
9610 clearInvalid : function()
9613 if(!this.el || this.preventMark){ // not rendered
9617 var label = this.el.select('label', true).first();
9618 var icon = this.el.select('i.fa-star', true).first();
9624 this.el.removeClass(this.invalidClass);
9626 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9628 var feedback = this.el.select('.form-control-feedback', true).first();
9631 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9636 this.fireEvent('valid', this);
9640 * Mark this field as valid
9642 markValid : function()
9644 if(!this.el || this.preventMark){ // not rendered
9648 this.el.removeClass([this.invalidClass, this.validClass]);
9650 var feedback = this.el.select('.form-control-feedback', true).first();
9653 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9656 if(this.disabled || this.allowBlank){
9660 var label = this.el.select('label', true).first();
9661 var icon = this.el.select('i.fa-star', true).first();
9667 this.el.addClass(this.validClass);
9669 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9671 var feedback = this.el.select('.form-control-feedback', true).first();
9674 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9675 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9680 this.fireEvent('valid', this);
9684 * Mark this field as invalid
9685 * @param {String} msg The validation message
9687 markInvalid : function(msg)
9689 if(!this.el || this.preventMark){ // not rendered
9693 this.el.removeClass([this.invalidClass, this.validClass]);
9695 var feedback = this.el.select('.form-control-feedback', true).first();
9698 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9701 if(this.disabled || this.allowBlank){
9705 var label = this.el.select('label', true).first();
9706 var icon = this.el.select('i.fa-star', true).first();
9708 if(!this.getValue().length && label && !icon){
9709 this.el.createChild({
9711 cls : 'text-danger fa fa-lg fa-star',
9712 tooltip : 'This field is required',
9713 style : 'margin-right:5px;'
9717 this.el.addClass(this.invalidClass);
9719 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9721 var feedback = this.el.select('.form-control-feedback', true).first();
9724 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9726 if(this.getValue().length || this.forceFeedback){
9727 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9734 this.fireEvent('invalid', this, msg);
9742 * trigger field - base class for combo..
9747 * @class Roo.bootstrap.TriggerField
9748 * @extends Roo.bootstrap.Input
9749 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9750 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9751 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9752 * for which you can provide a custom implementation. For example:
9754 var trigger = new Roo.bootstrap.TriggerField();
9755 trigger.onTriggerClick = myTriggerFn;
9756 trigger.applyTo('my-field');
9759 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9760 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9761 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9762 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9763 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9766 * Create a new TriggerField.
9767 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9768 * to the base TextField)
9770 Roo.bootstrap.TriggerField = function(config){
9771 this.mimicing = false;
9772 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9775 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9777 * @cfg {String} triggerClass A CSS class to apply to the trigger
9780 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9785 * @cfg {Boolean} removable (true|false) special filter default false
9789 /** @cfg {Boolean} grow @hide */
9790 /** @cfg {Number} growMin @hide */
9791 /** @cfg {Number} growMax @hide */
9797 autoSize: Roo.emptyFn,
9804 actionMode : 'wrap',
9809 getAutoCreate : function(){
9811 var align = this.labelAlign || this.parentLabelAlign();
9816 cls: 'form-group' //input-group
9823 type : this.inputType,
9824 cls : 'form-control',
9825 autocomplete: 'new-password',
9826 placeholder : this.placeholder || ''
9830 input.name = this.name;
9833 input.cls += ' input-' + this.size;
9836 if (this.disabled) {
9837 input.disabled=true;
9840 var inputblock = input;
9842 if(this.hasFeedback && !this.allowBlank){
9846 cls: 'glyphicon form-control-feedback'
9849 if(this.removable && !this.editable && !this.tickable){
9851 cls : 'has-feedback',
9857 cls : 'roo-combo-removable-btn close'
9864 cls : 'has-feedback',
9873 if(this.removable && !this.editable && !this.tickable){
9875 cls : 'roo-removable',
9881 cls : 'roo-combo-removable-btn close'
9888 if (this.before || this.after) {
9891 cls : 'input-group',
9895 inputblock.cn.push({
9897 cls : 'input-group-addon',
9902 inputblock.cn.push(input);
9904 if(this.hasFeedback && !this.allowBlank){
9905 inputblock.cls += ' has-feedback';
9906 inputblock.cn.push(feedback);
9910 inputblock.cn.push({
9912 cls : 'input-group-addon',
9925 cls: 'form-hidden-field'
9939 cls: 'form-hidden-field'
9943 cls: 'roo-select2-choices',
9947 cls: 'roo-select2-search-field',
9960 cls: 'roo-select2-container input-group',
9965 // cls: 'typeahead typeahead-long dropdown-menu',
9966 // style: 'display:none'
9971 if(!this.multiple && this.showToggleBtn){
9977 if (this.caret != false) {
9980 cls: 'fa fa-' + this.caret
9987 cls : 'input-group-addon btn dropdown-toggle',
9992 cls: 'combobox-clear',
10006 combobox.cls += ' roo-select2-container-multi';
10009 if (align ==='left' && this.fieldLabel.length) {
10011 cfg.cls += ' roo-form-group-label-left';
10016 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10017 tooltip : 'This field is required'
10022 cls : 'control-label',
10023 html : this.fieldLabel
10035 var labelCfg = cfg.cn[1];
10036 var contentCfg = cfg.cn[2];
10038 if(this.indicatorpos == 'right'){
10043 cls : 'control-label',
10047 html : this.fieldLabel
10051 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10052 tooltip : 'This field is required'
10065 labelCfg = cfg.cn[0];
10066 contentCfg = cfg.cn[1];
10069 if(this.labelWidth > 12){
10070 labelCfg.style = "width: " + this.labelWidth + 'px';
10073 if(this.labelWidth < 13 && this.labelmd == 0){
10074 this.labelmd = this.labelWidth;
10077 if(this.labellg > 0){
10078 labelCfg.cls += ' col-lg-' + this.labellg;
10079 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10082 if(this.labelmd > 0){
10083 labelCfg.cls += ' col-md-' + this.labelmd;
10084 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10087 if(this.labelsm > 0){
10088 labelCfg.cls += ' col-sm-' + this.labelsm;
10089 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10092 if(this.labelxs > 0){
10093 labelCfg.cls += ' col-xs-' + this.labelxs;
10094 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10097 } else if ( this.fieldLabel.length) {
10098 // Roo.log(" label");
10102 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10103 tooltip : 'This field is required'
10107 //cls : 'input-group-addon',
10108 html : this.fieldLabel
10116 if(this.indicatorpos == 'right'){
10124 html : this.fieldLabel
10128 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10129 tooltip : 'This field is required'
10142 // Roo.log(" no label && no align");
10149 ['xs','sm','md','lg'].map(function(size){
10150 if (settings[size]) {
10151 cfg.cls += ' col-' + size + '-' + settings[size];
10162 onResize : function(w, h){
10163 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10164 // if(typeof w == 'number'){
10165 // var x = w - this.trigger.getWidth();
10166 // this.inputEl().setWidth(this.adjustWidth('input', x));
10167 // this.trigger.setStyle('left', x+'px');
10172 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10175 getResizeEl : function(){
10176 return this.inputEl();
10180 getPositionEl : function(){
10181 return this.inputEl();
10185 alignErrorIcon : function(){
10186 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10190 initEvents : function(){
10194 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10195 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10196 if(!this.multiple && this.showToggleBtn){
10197 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10198 if(this.hideTrigger){
10199 this.trigger.setDisplayed(false);
10201 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10205 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10208 if(this.removable && !this.editable && !this.tickable){
10209 var close = this.closeTriggerEl();
10212 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10213 close.on('click', this.removeBtnClick, this, close);
10217 //this.trigger.addClassOnOver('x-form-trigger-over');
10218 //this.trigger.addClassOnClick('x-form-trigger-click');
10221 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10225 closeTriggerEl : function()
10227 var close = this.el.select('.roo-combo-removable-btn', true).first();
10228 return close ? close : false;
10231 removeBtnClick : function(e, h, el)
10233 e.preventDefault();
10235 if(this.fireEvent("remove", this) !== false){
10237 this.fireEvent("afterremove", this)
10241 createList : function()
10243 this.list = Roo.get(document.body).createChild({
10245 cls: 'typeahead typeahead-long dropdown-menu',
10246 style: 'display:none'
10249 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10254 initTrigger : function(){
10259 onDestroy : function(){
10261 this.trigger.removeAllListeners();
10262 // this.trigger.remove();
10265 // this.wrap.remove();
10267 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10271 onFocus : function(){
10272 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10274 if(!this.mimicing){
10275 this.wrap.addClass('x-trigger-wrap-focus');
10276 this.mimicing = true;
10277 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10278 if(this.monitorTab){
10279 this.el.on("keydown", this.checkTab, this);
10286 checkTab : function(e){
10287 if(e.getKey() == e.TAB){
10288 this.triggerBlur();
10293 onBlur : function(){
10298 mimicBlur : function(e, t){
10300 if(!this.wrap.contains(t) && this.validateBlur()){
10301 this.triggerBlur();
10307 triggerBlur : function(){
10308 this.mimicing = false;
10309 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10310 if(this.monitorTab){
10311 this.el.un("keydown", this.checkTab, this);
10313 //this.wrap.removeClass('x-trigger-wrap-focus');
10314 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10318 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10319 validateBlur : function(e, t){
10324 onDisable : function(){
10325 this.inputEl().dom.disabled = true;
10326 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10328 // this.wrap.addClass('x-item-disabled');
10333 onEnable : function(){
10334 this.inputEl().dom.disabled = false;
10335 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10337 // this.el.removeClass('x-item-disabled');
10342 onShow : function(){
10343 var ae = this.getActionEl();
10346 ae.dom.style.display = '';
10347 ae.dom.style.visibility = 'visible';
10353 onHide : function(){
10354 var ae = this.getActionEl();
10355 ae.dom.style.display = 'none';
10359 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10360 * by an implementing function.
10362 * @param {EventObject} e
10364 onTriggerClick : Roo.emptyFn
10368 * Ext JS Library 1.1.1
10369 * Copyright(c) 2006-2007, Ext JS, LLC.
10371 * Originally Released Under LGPL - original licence link has changed is not relivant.
10374 * <script type="text/javascript">
10379 * @class Roo.data.SortTypes
10381 * Defines the default sorting (casting?) comparison functions used when sorting data.
10383 Roo.data.SortTypes = {
10385 * Default sort that does nothing
10386 * @param {Mixed} s The value being converted
10387 * @return {Mixed} The comparison value
10389 none : function(s){
10394 * The regular expression used to strip tags
10398 stripTagsRE : /<\/?[^>]+>/gi,
10401 * Strips all HTML tags to sort on text only
10402 * @param {Mixed} s The value being converted
10403 * @return {String} The comparison value
10405 asText : function(s){
10406 return String(s).replace(this.stripTagsRE, "");
10410 * Strips all HTML tags to sort on text only - Case insensitive
10411 * @param {Mixed} s The value being converted
10412 * @return {String} The comparison value
10414 asUCText : function(s){
10415 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10419 * Case insensitive string
10420 * @param {Mixed} s The value being converted
10421 * @return {String} The comparison value
10423 asUCString : function(s) {
10424 return String(s).toUpperCase();
10429 * @param {Mixed} s The value being converted
10430 * @return {Number} The comparison value
10432 asDate : function(s) {
10436 if(s instanceof Date){
10437 return s.getTime();
10439 return Date.parse(String(s));
10444 * @param {Mixed} s The value being converted
10445 * @return {Float} The comparison value
10447 asFloat : function(s) {
10448 var val = parseFloat(String(s).replace(/,/g, ""));
10457 * @param {Mixed} s The value being converted
10458 * @return {Number} The comparison value
10460 asInt : function(s) {
10461 var val = parseInt(String(s).replace(/,/g, ""));
10469 * Ext JS Library 1.1.1
10470 * Copyright(c) 2006-2007, Ext JS, LLC.
10472 * Originally Released Under LGPL - original licence link has changed is not relivant.
10475 * <script type="text/javascript">
10479 * @class Roo.data.Record
10480 * Instances of this class encapsulate both record <em>definition</em> information, and record
10481 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10482 * to access Records cached in an {@link Roo.data.Store} object.<br>
10484 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10485 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10488 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10490 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10491 * {@link #create}. The parameters are the same.
10492 * @param {Array} data An associative Array of data values keyed by the field name.
10493 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10494 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10495 * not specified an integer id is generated.
10497 Roo.data.Record = function(data, id){
10498 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10503 * Generate a constructor for a specific record layout.
10504 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10505 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10506 * Each field definition object may contain the following properties: <ul>
10507 * <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,
10508 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10509 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10510 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10511 * is being used, then this is a string containing the javascript expression to reference the data relative to
10512 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10513 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10514 * this may be omitted.</p></li>
10515 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10516 * <ul><li>auto (Default, implies no conversion)</li>
10521 * <li>date</li></ul></p></li>
10522 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10523 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10524 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10525 * by the Reader into an object that will be stored in the Record. It is passed the
10526 * following parameters:<ul>
10527 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10529 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10531 * <br>usage:<br><pre><code>
10532 var TopicRecord = Roo.data.Record.create(
10533 {name: 'title', mapping: 'topic_title'},
10534 {name: 'author', mapping: 'username'},
10535 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10536 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10537 {name: 'lastPoster', mapping: 'user2'},
10538 {name: 'excerpt', mapping: 'post_text'}
10541 var myNewRecord = new TopicRecord({
10542 title: 'Do my job please',
10545 lastPost: new Date(),
10546 lastPoster: 'Animal',
10547 excerpt: 'No way dude!'
10549 myStore.add(myNewRecord);
10554 Roo.data.Record.create = function(o){
10555 var f = function(){
10556 f.superclass.constructor.apply(this, arguments);
10558 Roo.extend(f, Roo.data.Record);
10559 var p = f.prototype;
10560 p.fields = new Roo.util.MixedCollection(false, function(field){
10563 for(var i = 0, len = o.length; i < len; i++){
10564 p.fields.add(new Roo.data.Field(o[i]));
10566 f.getField = function(name){
10567 return p.fields.get(name);
10572 Roo.data.Record.AUTO_ID = 1000;
10573 Roo.data.Record.EDIT = 'edit';
10574 Roo.data.Record.REJECT = 'reject';
10575 Roo.data.Record.COMMIT = 'commit';
10577 Roo.data.Record.prototype = {
10579 * Readonly flag - true if this record has been modified.
10588 join : function(store){
10589 this.store = store;
10593 * Set the named field to the specified value.
10594 * @param {String} name The name of the field to set.
10595 * @param {Object} value The value to set the field to.
10597 set : function(name, value){
10598 if(this.data[name] == value){
10602 if(!this.modified){
10603 this.modified = {};
10605 if(typeof this.modified[name] == 'undefined'){
10606 this.modified[name] = this.data[name];
10608 this.data[name] = value;
10609 if(!this.editing && this.store){
10610 this.store.afterEdit(this);
10615 * Get the value of the named field.
10616 * @param {String} name The name of the field to get the value of.
10617 * @return {Object} The value of the field.
10619 get : function(name){
10620 return this.data[name];
10624 beginEdit : function(){
10625 this.editing = true;
10626 this.modified = {};
10630 cancelEdit : function(){
10631 this.editing = false;
10632 delete this.modified;
10636 endEdit : function(){
10637 this.editing = false;
10638 if(this.dirty && this.store){
10639 this.store.afterEdit(this);
10644 * Usually called by the {@link Roo.data.Store} which owns the Record.
10645 * Rejects all changes made to the Record since either creation, or the last commit operation.
10646 * Modified fields are reverted to their original values.
10648 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10649 * of reject operations.
10651 reject : function(){
10652 var m = this.modified;
10654 if(typeof m[n] != "function"){
10655 this.data[n] = m[n];
10658 this.dirty = false;
10659 delete this.modified;
10660 this.editing = false;
10662 this.store.afterReject(this);
10667 * Usually called by the {@link Roo.data.Store} which owns the Record.
10668 * Commits all changes made to the Record since either creation, or the last commit operation.
10670 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10671 * of commit operations.
10673 commit : function(){
10674 this.dirty = false;
10675 delete this.modified;
10676 this.editing = false;
10678 this.store.afterCommit(this);
10683 hasError : function(){
10684 return this.error != null;
10688 clearError : function(){
10693 * Creates a copy of this record.
10694 * @param {String} id (optional) A new record id if you don't want to use this record's id
10697 copy : function(newId) {
10698 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10702 * Ext JS Library 1.1.1
10703 * Copyright(c) 2006-2007, Ext JS, LLC.
10705 * Originally Released Under LGPL - original licence link has changed is not relivant.
10708 * <script type="text/javascript">
10714 * @class Roo.data.Store
10715 * @extends Roo.util.Observable
10716 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10717 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10719 * 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
10720 * has no knowledge of the format of the data returned by the Proxy.<br>
10722 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10723 * instances from the data object. These records are cached and made available through accessor functions.
10725 * Creates a new Store.
10726 * @param {Object} config A config object containing the objects needed for the Store to access data,
10727 * and read the data into Records.
10729 Roo.data.Store = function(config){
10730 this.data = new Roo.util.MixedCollection(false);
10731 this.data.getKey = function(o){
10734 this.baseParams = {};
10736 this.paramNames = {
10741 "multisort" : "_multisort"
10744 if(config && config.data){
10745 this.inlineData = config.data;
10746 delete config.data;
10749 Roo.apply(this, config);
10751 if(this.reader){ // reader passed
10752 this.reader = Roo.factory(this.reader, Roo.data);
10753 this.reader.xmodule = this.xmodule || false;
10754 if(!this.recordType){
10755 this.recordType = this.reader.recordType;
10757 if(this.reader.onMetaChange){
10758 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10762 if(this.recordType){
10763 this.fields = this.recordType.prototype.fields;
10765 this.modified = [];
10769 * @event datachanged
10770 * Fires when the data cache has changed, and a widget which is using this Store
10771 * as a Record cache should refresh its view.
10772 * @param {Store} this
10774 datachanged : true,
10776 * @event metachange
10777 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10778 * @param {Store} this
10779 * @param {Object} meta The JSON metadata
10784 * Fires when Records have been added to the Store
10785 * @param {Store} this
10786 * @param {Roo.data.Record[]} records The array of Records added
10787 * @param {Number} index The index at which the record(s) were added
10792 * Fires when a Record has been removed from the Store
10793 * @param {Store} this
10794 * @param {Roo.data.Record} record The Record that was removed
10795 * @param {Number} index The index at which the record was removed
10800 * Fires when a Record has been updated
10801 * @param {Store} this
10802 * @param {Roo.data.Record} record The Record that was updated
10803 * @param {String} operation The update operation being performed. Value may be one of:
10805 Roo.data.Record.EDIT
10806 Roo.data.Record.REJECT
10807 Roo.data.Record.COMMIT
10813 * Fires when the data cache has been cleared.
10814 * @param {Store} this
10818 * @event beforeload
10819 * Fires before a request is made for a new data object. If the beforeload handler returns false
10820 * the load action will be canceled.
10821 * @param {Store} this
10822 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10826 * @event beforeloadadd
10827 * Fires after a new set of Records has been loaded.
10828 * @param {Store} this
10829 * @param {Roo.data.Record[]} records The Records that were loaded
10830 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10832 beforeloadadd : true,
10835 * Fires after a new set of Records has been loaded, before they are added to the store.
10836 * @param {Store} this
10837 * @param {Roo.data.Record[]} records The Records that were loaded
10838 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10839 * @params {Object} return from reader
10843 * @event loadexception
10844 * Fires if an exception occurs in the Proxy during loading.
10845 * Called with the signature of the Proxy's "loadexception" event.
10846 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10849 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10850 * @param {Object} load options
10851 * @param {Object} jsonData from your request (normally this contains the Exception)
10853 loadexception : true
10857 this.proxy = Roo.factory(this.proxy, Roo.data);
10858 this.proxy.xmodule = this.xmodule || false;
10859 this.relayEvents(this.proxy, ["loadexception"]);
10861 this.sortToggle = {};
10862 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10864 Roo.data.Store.superclass.constructor.call(this);
10866 if(this.inlineData){
10867 this.loadData(this.inlineData);
10868 delete this.inlineData;
10872 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10874 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10875 * without a remote query - used by combo/forms at present.
10879 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10882 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10885 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10886 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10889 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10890 * on any HTTP request
10893 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10896 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10900 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10901 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10903 remoteSort : false,
10906 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10907 * loaded or when a record is removed. (defaults to false).
10909 pruneModifiedRecords : false,
10912 lastOptions : null,
10915 * Add Records to the Store and fires the add event.
10916 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10918 add : function(records){
10919 records = [].concat(records);
10920 for(var i = 0, len = records.length; i < len; i++){
10921 records[i].join(this);
10923 var index = this.data.length;
10924 this.data.addAll(records);
10925 this.fireEvent("add", this, records, index);
10929 * Remove a Record from the Store and fires the remove event.
10930 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10932 remove : function(record){
10933 var index = this.data.indexOf(record);
10934 this.data.removeAt(index);
10935 if(this.pruneModifiedRecords){
10936 this.modified.remove(record);
10938 this.fireEvent("remove", this, record, index);
10942 * Remove all Records from the Store and fires the clear event.
10944 removeAll : function(){
10946 if(this.pruneModifiedRecords){
10947 this.modified = [];
10949 this.fireEvent("clear", this);
10953 * Inserts Records to the Store at the given index and fires the add event.
10954 * @param {Number} index The start index at which to insert the passed Records.
10955 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10957 insert : function(index, records){
10958 records = [].concat(records);
10959 for(var i = 0, len = records.length; i < len; i++){
10960 this.data.insert(index, records[i]);
10961 records[i].join(this);
10963 this.fireEvent("add", this, records, index);
10967 * Get the index within the cache of the passed Record.
10968 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
10969 * @return {Number} The index of the passed Record. Returns -1 if not found.
10971 indexOf : function(record){
10972 return this.data.indexOf(record);
10976 * Get the index within the cache of the Record with the passed id.
10977 * @param {String} id The id of the Record to find.
10978 * @return {Number} The index of the Record. Returns -1 if not found.
10980 indexOfId : function(id){
10981 return this.data.indexOfKey(id);
10985 * Get the Record with the specified id.
10986 * @param {String} id The id of the Record to find.
10987 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
10989 getById : function(id){
10990 return this.data.key(id);
10994 * Get the Record at the specified index.
10995 * @param {Number} index The index of the Record to find.
10996 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
10998 getAt : function(index){
10999 return this.data.itemAt(index);
11003 * Returns a range of Records between specified indices.
11004 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11005 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11006 * @return {Roo.data.Record[]} An array of Records
11008 getRange : function(start, end){
11009 return this.data.getRange(start, end);
11013 storeOptions : function(o){
11014 o = Roo.apply({}, o);
11017 this.lastOptions = o;
11021 * Loads the Record cache from the configured Proxy using the configured Reader.
11023 * If using remote paging, then the first load call must specify the <em>start</em>
11024 * and <em>limit</em> properties in the options.params property to establish the initial
11025 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11027 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11028 * and this call will return before the new data has been loaded. Perform any post-processing
11029 * in a callback function, or in a "load" event handler.</strong>
11031 * @param {Object} options An object containing properties which control loading options:<ul>
11032 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11033 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11034 * passed the following arguments:<ul>
11035 * <li>r : Roo.data.Record[]</li>
11036 * <li>options: Options object from the load call</li>
11037 * <li>success: Boolean success indicator</li></ul></li>
11038 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11039 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11042 load : function(options){
11043 options = options || {};
11044 if(this.fireEvent("beforeload", this, options) !== false){
11045 this.storeOptions(options);
11046 var p = Roo.apply(options.params || {}, this.baseParams);
11047 // if meta was not loaded from remote source.. try requesting it.
11048 if (!this.reader.metaFromRemote) {
11049 p._requestMeta = 1;
11051 if(this.sortInfo && this.remoteSort){
11052 var pn = this.paramNames;
11053 p[pn["sort"]] = this.sortInfo.field;
11054 p[pn["dir"]] = this.sortInfo.direction;
11056 if (this.multiSort) {
11057 var pn = this.paramNames;
11058 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11061 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11066 * Reloads the Record cache from the configured Proxy using the configured Reader and
11067 * the options from the last load operation performed.
11068 * @param {Object} options (optional) An object containing properties which may override the options
11069 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11070 * the most recently used options are reused).
11072 reload : function(options){
11073 this.load(Roo.applyIf(options||{}, this.lastOptions));
11077 // Called as a callback by the Reader during a load operation.
11078 loadRecords : function(o, options, success){
11079 if(!o || success === false){
11080 if(success !== false){
11081 this.fireEvent("load", this, [], options, o);
11083 if(options.callback){
11084 options.callback.call(options.scope || this, [], options, false);
11088 // if data returned failure - throw an exception.
11089 if (o.success === false) {
11090 // show a message if no listener is registered.
11091 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11092 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11094 // loadmask wil be hooked into this..
11095 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11098 var r = o.records, t = o.totalRecords || r.length;
11100 this.fireEvent("beforeloadadd", this, r, options, o);
11102 if(!options || options.add !== true){
11103 if(this.pruneModifiedRecords){
11104 this.modified = [];
11106 for(var i = 0, len = r.length; i < len; i++){
11110 this.data = this.snapshot;
11111 delete this.snapshot;
11114 this.data.addAll(r);
11115 this.totalLength = t;
11117 this.fireEvent("datachanged", this);
11119 this.totalLength = Math.max(t, this.data.length+r.length);
11123 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11125 var e = new Roo.data.Record({});
11127 e.set(this.parent.displayField, this.parent.emptyTitle);
11128 e.set(this.parent.valueField, '');
11133 this.fireEvent("load", this, r, options, o);
11134 if(options.callback){
11135 options.callback.call(options.scope || this, r, options, true);
11141 * Loads data from a passed data block. A Reader which understands the format of the data
11142 * must have been configured in the constructor.
11143 * @param {Object} data The data block from which to read the Records. The format of the data expected
11144 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11145 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11147 loadData : function(o, append){
11148 var r = this.reader.readRecords(o);
11149 this.loadRecords(r, {add: append}, true);
11153 * Gets the number of cached records.
11155 * <em>If using paging, this may not be the total size of the dataset. If the data object
11156 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11157 * the data set size</em>
11159 getCount : function(){
11160 return this.data.length || 0;
11164 * Gets the total number of records in the dataset as returned by the server.
11166 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11167 * the dataset size</em>
11169 getTotalCount : function(){
11170 return this.totalLength || 0;
11174 * Returns the sort state of the Store as an object with two properties:
11176 field {String} The name of the field by which the Records are sorted
11177 direction {String} The sort order, "ASC" or "DESC"
11180 getSortState : function(){
11181 return this.sortInfo;
11185 applySort : function(){
11186 if(this.sortInfo && !this.remoteSort){
11187 var s = this.sortInfo, f = s.field;
11188 var st = this.fields.get(f).sortType;
11189 var fn = function(r1, r2){
11190 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11191 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11193 this.data.sort(s.direction, fn);
11194 if(this.snapshot && this.snapshot != this.data){
11195 this.snapshot.sort(s.direction, fn);
11201 * Sets the default sort column and order to be used by the next load operation.
11202 * @param {String} fieldName The name of the field to sort by.
11203 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11205 setDefaultSort : function(field, dir){
11206 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11210 * Sort the Records.
11211 * If remote sorting is used, the sort is performed on the server, and the cache is
11212 * reloaded. If local sorting is used, the cache is sorted internally.
11213 * @param {String} fieldName The name of the field to sort by.
11214 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11216 sort : function(fieldName, dir){
11217 var f = this.fields.get(fieldName);
11219 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11221 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11222 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11227 this.sortToggle[f.name] = dir;
11228 this.sortInfo = {field: f.name, direction: dir};
11229 if(!this.remoteSort){
11231 this.fireEvent("datachanged", this);
11233 this.load(this.lastOptions);
11238 * Calls the specified function for each of the Records in the cache.
11239 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11240 * Returning <em>false</em> aborts and exits the iteration.
11241 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11243 each : function(fn, scope){
11244 this.data.each(fn, scope);
11248 * Gets all records modified since the last commit. Modified records are persisted across load operations
11249 * (e.g., during paging).
11250 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11252 getModifiedRecords : function(){
11253 return this.modified;
11257 createFilterFn : function(property, value, anyMatch){
11258 if(!value.exec){ // not a regex
11259 value = String(value);
11260 if(value.length == 0){
11263 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11265 return function(r){
11266 return value.test(r.data[property]);
11271 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11272 * @param {String} property A field on your records
11273 * @param {Number} start The record index to start at (defaults to 0)
11274 * @param {Number} end The last record index to include (defaults to length - 1)
11275 * @return {Number} The sum
11277 sum : function(property, start, end){
11278 var rs = this.data.items, v = 0;
11279 start = start || 0;
11280 end = (end || end === 0) ? end : rs.length-1;
11282 for(var i = start; i <= end; i++){
11283 v += (rs[i].data[property] || 0);
11289 * Filter the records by a specified property.
11290 * @param {String} field A field on your records
11291 * @param {String/RegExp} value Either a string that the field
11292 * should start with or a RegExp to test against the field
11293 * @param {Boolean} anyMatch True to match any part not just the beginning
11295 filter : function(property, value, anyMatch){
11296 var fn = this.createFilterFn(property, value, anyMatch);
11297 return fn ? this.filterBy(fn) : this.clearFilter();
11301 * Filter by a function. The specified function will be called with each
11302 * record in this data source. If the function returns true the record is included,
11303 * otherwise it is filtered.
11304 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11305 * @param {Object} scope (optional) The scope of the function (defaults to this)
11307 filterBy : function(fn, scope){
11308 this.snapshot = this.snapshot || this.data;
11309 this.data = this.queryBy(fn, scope||this);
11310 this.fireEvent("datachanged", this);
11314 * Query the records by a specified property.
11315 * @param {String} field A field on your records
11316 * @param {String/RegExp} value Either a string that the field
11317 * should start with or a RegExp to test against the field
11318 * @param {Boolean} anyMatch True to match any part not just the beginning
11319 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11321 query : function(property, value, anyMatch){
11322 var fn = this.createFilterFn(property, value, anyMatch);
11323 return fn ? this.queryBy(fn) : this.data.clone();
11327 * Query by a function. The specified function will be called with each
11328 * record in this data source. If the function returns true the record is included
11330 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11331 * @param {Object} scope (optional) The scope of the function (defaults to this)
11332 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11334 queryBy : function(fn, scope){
11335 var data = this.snapshot || this.data;
11336 return data.filterBy(fn, scope||this);
11340 * Collects unique values for a particular dataIndex from this store.
11341 * @param {String} dataIndex The property to collect
11342 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11343 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11344 * @return {Array} An array of the unique values
11346 collect : function(dataIndex, allowNull, bypassFilter){
11347 var d = (bypassFilter === true && this.snapshot) ?
11348 this.snapshot.items : this.data.items;
11349 var v, sv, r = [], l = {};
11350 for(var i = 0, len = d.length; i < len; i++){
11351 v = d[i].data[dataIndex];
11353 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11362 * Revert to a view of the Record cache with no filtering applied.
11363 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11365 clearFilter : function(suppressEvent){
11366 if(this.snapshot && this.snapshot != this.data){
11367 this.data = this.snapshot;
11368 delete this.snapshot;
11369 if(suppressEvent !== true){
11370 this.fireEvent("datachanged", this);
11376 afterEdit : function(record){
11377 if(this.modified.indexOf(record) == -1){
11378 this.modified.push(record);
11380 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11384 afterReject : function(record){
11385 this.modified.remove(record);
11386 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11390 afterCommit : function(record){
11391 this.modified.remove(record);
11392 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11396 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11397 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11399 commitChanges : function(){
11400 var m = this.modified.slice(0);
11401 this.modified = [];
11402 for(var i = 0, len = m.length; i < len; i++){
11408 * Cancel outstanding changes on all changed records.
11410 rejectChanges : function(){
11411 var m = this.modified.slice(0);
11412 this.modified = [];
11413 for(var i = 0, len = m.length; i < len; i++){
11418 onMetaChange : function(meta, rtype, o){
11419 this.recordType = rtype;
11420 this.fields = rtype.prototype.fields;
11421 delete this.snapshot;
11422 this.sortInfo = meta.sortInfo || this.sortInfo;
11423 this.modified = [];
11424 this.fireEvent('metachange', this, this.reader.meta);
11427 moveIndex : function(data, type)
11429 var index = this.indexOf(data);
11431 var newIndex = index + type;
11435 this.insert(newIndex, data);
11440 * Ext JS Library 1.1.1
11441 * Copyright(c) 2006-2007, Ext JS, LLC.
11443 * Originally Released Under LGPL - original licence link has changed is not relivant.
11446 * <script type="text/javascript">
11450 * @class Roo.data.SimpleStore
11451 * @extends Roo.data.Store
11452 * Small helper class to make creating Stores from Array data easier.
11453 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11454 * @cfg {Array} fields An array of field definition objects, or field name strings.
11455 * @cfg {Array} data The multi-dimensional array of data
11457 * @param {Object} config
11459 Roo.data.SimpleStore = function(config){
11460 Roo.data.SimpleStore.superclass.constructor.call(this, {
11462 reader: new Roo.data.ArrayReader({
11465 Roo.data.Record.create(config.fields)
11467 proxy : new Roo.data.MemoryProxy(config.data)
11471 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11473 * Ext JS Library 1.1.1
11474 * Copyright(c) 2006-2007, Ext JS, LLC.
11476 * Originally Released Under LGPL - original licence link has changed is not relivant.
11479 * <script type="text/javascript">
11484 * @extends Roo.data.Store
11485 * @class Roo.data.JsonStore
11486 * Small helper class to make creating Stores for JSON data easier. <br/>
11488 var store = new Roo.data.JsonStore({
11489 url: 'get-images.php',
11491 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11494 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11495 * JsonReader and HttpProxy (unless inline data is provided).</b>
11496 * @cfg {Array} fields An array of field definition objects, or field name strings.
11498 * @param {Object} config
11500 Roo.data.JsonStore = function(c){
11501 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11502 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11503 reader: new Roo.data.JsonReader(c, c.fields)
11506 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11508 * Ext JS Library 1.1.1
11509 * Copyright(c) 2006-2007, Ext JS, LLC.
11511 * Originally Released Under LGPL - original licence link has changed is not relivant.
11514 * <script type="text/javascript">
11518 Roo.data.Field = function(config){
11519 if(typeof config == "string"){
11520 config = {name: config};
11522 Roo.apply(this, config);
11525 this.type = "auto";
11528 var st = Roo.data.SortTypes;
11529 // named sortTypes are supported, here we look them up
11530 if(typeof this.sortType == "string"){
11531 this.sortType = st[this.sortType];
11534 // set default sortType for strings and dates
11535 if(!this.sortType){
11538 this.sortType = st.asUCString;
11541 this.sortType = st.asDate;
11544 this.sortType = st.none;
11549 var stripRe = /[\$,%]/g;
11551 // prebuilt conversion function for this field, instead of
11552 // switching every time we're reading a value
11554 var cv, dateFormat = this.dateFormat;
11559 cv = function(v){ return v; };
11562 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11566 return v !== undefined && v !== null && v !== '' ?
11567 parseInt(String(v).replace(stripRe, ""), 10) : '';
11572 return v !== undefined && v !== null && v !== '' ?
11573 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11578 cv = function(v){ return v === true || v === "true" || v == 1; };
11585 if(v instanceof Date){
11589 if(dateFormat == "timestamp"){
11590 return new Date(v*1000);
11592 return Date.parseDate(v, dateFormat);
11594 var parsed = Date.parse(v);
11595 return parsed ? new Date(parsed) : null;
11604 Roo.data.Field.prototype = {
11612 * Ext JS Library 1.1.1
11613 * Copyright(c) 2006-2007, Ext JS, LLC.
11615 * Originally Released Under LGPL - original licence link has changed is not relivant.
11618 * <script type="text/javascript">
11621 // Base class for reading structured data from a data source. This class is intended to be
11622 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11625 * @class Roo.data.DataReader
11626 * Base class for reading structured data from a data source. This class is intended to be
11627 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11630 Roo.data.DataReader = function(meta, recordType){
11634 this.recordType = recordType instanceof Array ?
11635 Roo.data.Record.create(recordType) : recordType;
11638 Roo.data.DataReader.prototype = {
11640 * Create an empty record
11641 * @param {Object} data (optional) - overlay some values
11642 * @return {Roo.data.Record} record created.
11644 newRow : function(d) {
11646 this.recordType.prototype.fields.each(function(c) {
11648 case 'int' : da[c.name] = 0; break;
11649 case 'date' : da[c.name] = new Date(); break;
11650 case 'float' : da[c.name] = 0.0; break;
11651 case 'boolean' : da[c.name] = false; break;
11652 default : da[c.name] = ""; break;
11656 return new this.recordType(Roo.apply(da, d));
11661 * Ext JS Library 1.1.1
11662 * Copyright(c) 2006-2007, Ext JS, LLC.
11664 * Originally Released Under LGPL - original licence link has changed is not relivant.
11667 * <script type="text/javascript">
11671 * @class Roo.data.DataProxy
11672 * @extends Roo.data.Observable
11673 * This class is an abstract base class for implementations which provide retrieval of
11674 * unformatted data objects.<br>
11676 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11677 * (of the appropriate type which knows how to parse the data object) to provide a block of
11678 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11680 * Custom implementations must implement the load method as described in
11681 * {@link Roo.data.HttpProxy#load}.
11683 Roo.data.DataProxy = function(){
11686 * @event beforeload
11687 * Fires before a network request is made to retrieve a data object.
11688 * @param {Object} This DataProxy object.
11689 * @param {Object} params The params parameter to the load function.
11694 * Fires before the load method's callback is called.
11695 * @param {Object} This DataProxy object.
11696 * @param {Object} o The data object.
11697 * @param {Object} arg The callback argument object passed to the load function.
11701 * @event loadexception
11702 * Fires if an Exception occurs during data retrieval.
11703 * @param {Object} This DataProxy object.
11704 * @param {Object} o The data object.
11705 * @param {Object} arg The callback argument object passed to the load function.
11706 * @param {Object} e The Exception.
11708 loadexception : true
11710 Roo.data.DataProxy.superclass.constructor.call(this);
11713 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11716 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11720 * Ext JS Library 1.1.1
11721 * Copyright(c) 2006-2007, Ext JS, LLC.
11723 * Originally Released Under LGPL - original licence link has changed is not relivant.
11726 * <script type="text/javascript">
11729 * @class Roo.data.MemoryProxy
11730 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11731 * to the Reader when its load method is called.
11733 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11735 Roo.data.MemoryProxy = function(data){
11739 Roo.data.MemoryProxy.superclass.constructor.call(this);
11743 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11746 * Load data from the requested source (in this case an in-memory
11747 * data object passed to the constructor), read the data object into
11748 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11749 * process that block using the passed callback.
11750 * @param {Object} params This parameter is not used by the MemoryProxy class.
11751 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11752 * object into a block of Roo.data.Records.
11753 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11754 * The function must be passed <ul>
11755 * <li>The Record block object</li>
11756 * <li>The "arg" argument from the load function</li>
11757 * <li>A boolean success indicator</li>
11759 * @param {Object} scope The scope in which to call the callback
11760 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11762 load : function(params, reader, callback, scope, arg){
11763 params = params || {};
11766 result = reader.readRecords(this.data);
11768 this.fireEvent("loadexception", this, arg, null, e);
11769 callback.call(scope, null, arg, false);
11772 callback.call(scope, result, arg, true);
11776 update : function(params, records){
11781 * Ext JS Library 1.1.1
11782 * Copyright(c) 2006-2007, Ext JS, LLC.
11784 * Originally Released Under LGPL - original licence link has changed is not relivant.
11787 * <script type="text/javascript">
11790 * @class Roo.data.HttpProxy
11791 * @extends Roo.data.DataProxy
11792 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11793 * configured to reference a certain URL.<br><br>
11795 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11796 * from which the running page was served.<br><br>
11798 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11800 * Be aware that to enable the browser to parse an XML document, the server must set
11801 * the Content-Type header in the HTTP response to "text/xml".
11803 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11804 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11805 * will be used to make the request.
11807 Roo.data.HttpProxy = function(conn){
11808 Roo.data.HttpProxy.superclass.constructor.call(this);
11809 // is conn a conn config or a real conn?
11811 this.useAjax = !conn || !conn.events;
11815 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11816 // thse are take from connection...
11819 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11822 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11823 * extra parameters to each request made by this object. (defaults to undefined)
11826 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11827 * to each request made by this object. (defaults to undefined)
11830 * @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)
11833 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11836 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11842 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11846 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11847 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11848 * a finer-grained basis than the DataProxy events.
11850 getConnection : function(){
11851 return this.useAjax ? Roo.Ajax : this.conn;
11855 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11856 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11857 * process that block using the passed callback.
11858 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11859 * for the request to the remote server.
11860 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11861 * object into a block of Roo.data.Records.
11862 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11863 * The function must be passed <ul>
11864 * <li>The Record block object</li>
11865 * <li>The "arg" argument from the load function</li>
11866 * <li>A boolean success indicator</li>
11868 * @param {Object} scope The scope in which to call the callback
11869 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11871 load : function(params, reader, callback, scope, arg){
11872 if(this.fireEvent("beforeload", this, params) !== false){
11874 params : params || {},
11876 callback : callback,
11881 callback : this.loadResponse,
11885 Roo.applyIf(o, this.conn);
11886 if(this.activeRequest){
11887 Roo.Ajax.abort(this.activeRequest);
11889 this.activeRequest = Roo.Ajax.request(o);
11891 this.conn.request(o);
11894 callback.call(scope||this, null, arg, false);
11899 loadResponse : function(o, success, response){
11900 delete this.activeRequest;
11902 this.fireEvent("loadexception", this, o, response);
11903 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11908 result = o.reader.read(response);
11910 this.fireEvent("loadexception", this, o, response, e);
11911 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11915 this.fireEvent("load", this, o, o.request.arg);
11916 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11920 update : function(dataSet){
11925 updateResponse : function(dataSet){
11930 * Ext JS Library 1.1.1
11931 * Copyright(c) 2006-2007, Ext JS, LLC.
11933 * Originally Released Under LGPL - original licence link has changed is not relivant.
11936 * <script type="text/javascript">
11940 * @class Roo.data.ScriptTagProxy
11941 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11942 * other than the originating domain of the running page.<br><br>
11944 * <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
11945 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
11947 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
11948 * source code that is used as the source inside a <script> tag.<br><br>
11950 * In order for the browser to process the returned data, the server must wrap the data object
11951 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
11952 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
11953 * depending on whether the callback name was passed:
11956 boolean scriptTag = false;
11957 String cb = request.getParameter("callback");
11960 response.setContentType("text/javascript");
11962 response.setContentType("application/x-json");
11964 Writer out = response.getWriter();
11966 out.write(cb + "(");
11968 out.print(dataBlock.toJsonString());
11975 * @param {Object} config A configuration object.
11977 Roo.data.ScriptTagProxy = function(config){
11978 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
11979 Roo.apply(this, config);
11980 this.head = document.getElementsByTagName("head")[0];
11983 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
11985 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
11987 * @cfg {String} url The URL from which to request the data object.
11990 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
11994 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
11995 * the server the name of the callback function set up by the load call to process the returned data object.
11996 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
11997 * javascript output which calls this named function passing the data object as its only parameter.
11999 callbackParam : "callback",
12001 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12002 * name to the request.
12007 * Load data from the configured URL, read the data object into
12008 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12009 * process that block using the passed callback.
12010 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12011 * for the request to the remote server.
12012 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12013 * object into a block of Roo.data.Records.
12014 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12015 * The function must be passed <ul>
12016 * <li>The Record block object</li>
12017 * <li>The "arg" argument from the load function</li>
12018 * <li>A boolean success indicator</li>
12020 * @param {Object} scope The scope in which to call the callback
12021 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12023 load : function(params, reader, callback, scope, arg){
12024 if(this.fireEvent("beforeload", this, params) !== false){
12026 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12028 var url = this.url;
12029 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12031 url += "&_dc=" + (new Date().getTime());
12033 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12036 cb : "stcCallback"+transId,
12037 scriptId : "stcScript"+transId,
12041 callback : callback,
12047 window[trans.cb] = function(o){
12048 conn.handleResponse(o, trans);
12051 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12053 if(this.autoAbort !== false){
12057 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12059 var script = document.createElement("script");
12060 script.setAttribute("src", url);
12061 script.setAttribute("type", "text/javascript");
12062 script.setAttribute("id", trans.scriptId);
12063 this.head.appendChild(script);
12065 this.trans = trans;
12067 callback.call(scope||this, null, arg, false);
12072 isLoading : function(){
12073 return this.trans ? true : false;
12077 * Abort the current server request.
12079 abort : function(){
12080 if(this.isLoading()){
12081 this.destroyTrans(this.trans);
12086 destroyTrans : function(trans, isLoaded){
12087 this.head.removeChild(document.getElementById(trans.scriptId));
12088 clearTimeout(trans.timeoutId);
12090 window[trans.cb] = undefined;
12092 delete window[trans.cb];
12095 // if hasn't been loaded, wait for load to remove it to prevent script error
12096 window[trans.cb] = function(){
12097 window[trans.cb] = undefined;
12099 delete window[trans.cb];
12106 handleResponse : function(o, trans){
12107 this.trans = false;
12108 this.destroyTrans(trans, true);
12111 result = trans.reader.readRecords(o);
12113 this.fireEvent("loadexception", this, o, trans.arg, e);
12114 trans.callback.call(trans.scope||window, null, trans.arg, false);
12117 this.fireEvent("load", this, o, trans.arg);
12118 trans.callback.call(trans.scope||window, result, trans.arg, true);
12122 handleFailure : function(trans){
12123 this.trans = false;
12124 this.destroyTrans(trans, false);
12125 this.fireEvent("loadexception", this, null, trans.arg);
12126 trans.callback.call(trans.scope||window, null, trans.arg, false);
12130 * Ext JS Library 1.1.1
12131 * Copyright(c) 2006-2007, Ext JS, LLC.
12133 * Originally Released Under LGPL - original licence link has changed is not relivant.
12136 * <script type="text/javascript">
12140 * @class Roo.data.JsonReader
12141 * @extends Roo.data.DataReader
12142 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12143 * based on mappings in a provided Roo.data.Record constructor.
12145 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12146 * in the reply previously.
12151 var RecordDef = Roo.data.Record.create([
12152 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12153 {name: 'occupation'} // This field will use "occupation" as the mapping.
12155 var myReader = new Roo.data.JsonReader({
12156 totalProperty: "results", // The property which contains the total dataset size (optional)
12157 root: "rows", // The property which contains an Array of row objects
12158 id: "id" // The property within each row object that provides an ID for the record (optional)
12162 * This would consume a JSON file like this:
12164 { 'results': 2, 'rows': [
12165 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12166 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12169 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12170 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12171 * paged from the remote server.
12172 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12173 * @cfg {String} root name of the property which contains the Array of row objects.
12174 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12175 * @cfg {Array} fields Array of field definition objects
12177 * Create a new JsonReader
12178 * @param {Object} meta Metadata configuration options
12179 * @param {Object} recordType Either an Array of field definition objects,
12180 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12182 Roo.data.JsonReader = function(meta, recordType){
12185 // set some defaults:
12186 Roo.applyIf(meta, {
12187 totalProperty: 'total',
12188 successProperty : 'success',
12193 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12195 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12198 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12199 * Used by Store query builder to append _requestMeta to params.
12202 metaFromRemote : false,
12204 * This method is only used by a DataProxy which has retrieved data from a remote server.
12205 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12206 * @return {Object} data A data block which is used by an Roo.data.Store object as
12207 * a cache of Roo.data.Records.
12209 read : function(response){
12210 var json = response.responseText;
12212 var o = /* eval:var:o */ eval("("+json+")");
12214 throw {message: "JsonReader.read: Json object not found"};
12220 this.metaFromRemote = true;
12221 this.meta = o.metaData;
12222 this.recordType = Roo.data.Record.create(o.metaData.fields);
12223 this.onMetaChange(this.meta, this.recordType, o);
12225 return this.readRecords(o);
12228 // private function a store will implement
12229 onMetaChange : function(meta, recordType, o){
12236 simpleAccess: function(obj, subsc) {
12243 getJsonAccessor: function(){
12245 return function(expr) {
12247 return(re.test(expr))
12248 ? new Function("obj", "return obj." + expr)
12253 return Roo.emptyFn;
12258 * Create a data block containing Roo.data.Records from an XML document.
12259 * @param {Object} o An object which contains an Array of row objects in the property specified
12260 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12261 * which contains the total size of the dataset.
12262 * @return {Object} data A data block which is used by an Roo.data.Store object as
12263 * a cache of Roo.data.Records.
12265 readRecords : function(o){
12267 * After any data loads, the raw JSON data is available for further custom processing.
12271 var s = this.meta, Record = this.recordType,
12272 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12274 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12276 if(s.totalProperty) {
12277 this.getTotal = this.getJsonAccessor(s.totalProperty);
12279 if(s.successProperty) {
12280 this.getSuccess = this.getJsonAccessor(s.successProperty);
12282 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12284 var g = this.getJsonAccessor(s.id);
12285 this.getId = function(rec) {
12287 return (r === undefined || r === "") ? null : r;
12290 this.getId = function(){return null;};
12293 for(var jj = 0; jj < fl; jj++){
12295 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12296 this.ef[jj] = this.getJsonAccessor(map);
12300 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12301 if(s.totalProperty){
12302 var vt = parseInt(this.getTotal(o), 10);
12307 if(s.successProperty){
12308 var vs = this.getSuccess(o);
12309 if(vs === false || vs === 'false'){
12314 for(var i = 0; i < c; i++){
12317 var id = this.getId(n);
12318 for(var j = 0; j < fl; j++){
12320 var v = this.ef[j](n);
12322 Roo.log('missing convert for ' + f.name);
12326 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12328 var record = new Record(values, id);
12330 records[i] = record;
12336 totalRecords : totalRecords
12341 * Ext JS Library 1.1.1
12342 * Copyright(c) 2006-2007, Ext JS, LLC.
12344 * Originally Released Under LGPL - original licence link has changed is not relivant.
12347 * <script type="text/javascript">
12351 * @class Roo.data.ArrayReader
12352 * @extends Roo.data.DataReader
12353 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12354 * Each element of that Array represents a row of data fields. The
12355 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12356 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12360 var RecordDef = Roo.data.Record.create([
12361 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12362 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12364 var myReader = new Roo.data.ArrayReader({
12365 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12369 * This would consume an Array like this:
12371 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12373 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12375 * Create a new JsonReader
12376 * @param {Object} meta Metadata configuration options.
12377 * @param {Object} recordType Either an Array of field definition objects
12378 * as specified to {@link Roo.data.Record#create},
12379 * or an {@link Roo.data.Record} object
12380 * created using {@link Roo.data.Record#create}.
12382 Roo.data.ArrayReader = function(meta, recordType){
12383 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12386 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12388 * Create a data block containing Roo.data.Records from an XML document.
12389 * @param {Object} o An Array of row objects which represents the dataset.
12390 * @return {Object} data A data block which is used by an Roo.data.Store object as
12391 * a cache of Roo.data.Records.
12393 readRecords : function(o){
12394 var sid = this.meta ? this.meta.id : null;
12395 var recordType = this.recordType, fields = recordType.prototype.fields;
12398 for(var i = 0; i < root.length; i++){
12401 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12402 for(var j = 0, jlen = fields.length; j < jlen; j++){
12403 var f = fields.items[j];
12404 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12405 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12407 values[f.name] = v;
12409 var record = new recordType(values, id);
12411 records[records.length] = record;
12415 totalRecords : records.length
12424 * @class Roo.bootstrap.ComboBox
12425 * @extends Roo.bootstrap.TriggerField
12426 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12427 * @cfg {Boolean} append (true|false) default false
12428 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12429 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12430 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12431 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12432 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12433 * @cfg {Boolean} animate default true
12434 * @cfg {Boolean} emptyResultText only for touch device
12435 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12436 * @cfg {String} emptyTitle default ''
12438 * Create a new ComboBox.
12439 * @param {Object} config Configuration options
12441 Roo.bootstrap.ComboBox = function(config){
12442 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12446 * Fires when the dropdown list is expanded
12447 * @param {Roo.bootstrap.ComboBox} combo This combo box
12452 * Fires when the dropdown list is collapsed
12453 * @param {Roo.bootstrap.ComboBox} combo This combo box
12457 * @event beforeselect
12458 * Fires before a list item is selected. Return false to cancel the selection.
12459 * @param {Roo.bootstrap.ComboBox} combo This combo box
12460 * @param {Roo.data.Record} record The data record returned from the underlying store
12461 * @param {Number} index The index of the selected item in the dropdown list
12463 'beforeselect' : true,
12466 * Fires when a list item is selected
12467 * @param {Roo.bootstrap.ComboBox} combo This combo box
12468 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12469 * @param {Number} index The index of the selected item in the dropdown list
12473 * @event beforequery
12474 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12475 * The event object passed has these properties:
12476 * @param {Roo.bootstrap.ComboBox} combo This combo box
12477 * @param {String} query The query
12478 * @param {Boolean} forceAll true to force "all" query
12479 * @param {Boolean} cancel true to cancel the query
12480 * @param {Object} e The query event object
12482 'beforequery': true,
12485 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12486 * @param {Roo.bootstrap.ComboBox} combo This combo box
12491 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12492 * @param {Roo.bootstrap.ComboBox} combo This combo box
12493 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12498 * Fires when the remove value from the combobox array
12499 * @param {Roo.bootstrap.ComboBox} combo This combo box
12503 * @event afterremove
12504 * Fires when the remove value from the combobox array
12505 * @param {Roo.bootstrap.ComboBox} combo This combo box
12507 'afterremove' : true,
12509 * @event specialfilter
12510 * Fires when specialfilter
12511 * @param {Roo.bootstrap.ComboBox} combo This combo box
12513 'specialfilter' : true,
12516 * Fires when tick the element
12517 * @param {Roo.bootstrap.ComboBox} combo This combo box
12521 * @event touchviewdisplay
12522 * Fires when touch view require special display (default is using displayField)
12523 * @param {Roo.bootstrap.ComboBox} combo This combo box
12524 * @param {Object} cfg set html .
12526 'touchviewdisplay' : true
12531 this.tickItems = [];
12533 this.selectedIndex = -1;
12534 if(this.mode == 'local'){
12535 if(config.queryDelay === undefined){
12536 this.queryDelay = 10;
12538 if(config.minChars === undefined){
12544 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12547 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12548 * rendering into an Roo.Editor, defaults to false)
12551 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12552 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12555 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12558 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12559 * the dropdown list (defaults to undefined, with no header element)
12563 * @cfg {String/Roo.Template} tpl The template to use to render the output
12567 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12569 listWidth: undefined,
12571 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12572 * mode = 'remote' or 'text' if mode = 'local')
12574 displayField: undefined,
12577 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12578 * mode = 'remote' or 'value' if mode = 'local').
12579 * Note: use of a valueField requires the user make a selection
12580 * in order for a value to be mapped.
12582 valueField: undefined,
12584 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12589 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12590 * field's data value (defaults to the underlying DOM element's name)
12592 hiddenName: undefined,
12594 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12598 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12600 selectedClass: 'active',
12603 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12607 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12608 * anchor positions (defaults to 'tl-bl')
12610 listAlign: 'tl-bl?',
12612 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12616 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12617 * query specified by the allQuery config option (defaults to 'query')
12619 triggerAction: 'query',
12621 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12622 * (defaults to 4, does not apply if editable = false)
12626 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12627 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12631 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12632 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12636 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12637 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12641 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12642 * when editable = true (defaults to false)
12644 selectOnFocus:false,
12646 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12648 queryParam: 'query',
12650 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12651 * when mode = 'remote' (defaults to 'Loading...')
12653 loadingText: 'Loading...',
12655 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12659 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12663 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12664 * traditional select (defaults to true)
12668 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12672 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12676 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12677 * listWidth has a higher value)
12681 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12682 * allow the user to set arbitrary text into the field (defaults to false)
12684 forceSelection:false,
12686 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12687 * if typeAhead = true (defaults to 250)
12689 typeAheadDelay : 250,
12691 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12692 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12694 valueNotFoundText : undefined,
12696 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12698 blockFocus : false,
12701 * @cfg {Boolean} disableClear Disable showing of clear button.
12703 disableClear : false,
12705 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12707 alwaysQuery : false,
12710 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12715 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12717 invalidClass : "has-warning",
12720 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12722 validClass : "has-success",
12725 * @cfg {Boolean} specialFilter (true|false) special filter default false
12727 specialFilter : false,
12730 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12732 mobileTouchView : true,
12735 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12737 useNativeIOS : false,
12739 ios_options : false,
12751 btnPosition : 'right',
12752 triggerList : true,
12753 showToggleBtn : true,
12755 emptyResultText: 'Empty',
12756 triggerText : 'Select',
12759 // element that contains real text value.. (when hidden is used..)
12761 getAutoCreate : function()
12766 * Render classic select for iso
12769 if(Roo.isIOS && this.useNativeIOS){
12770 cfg = this.getAutoCreateNativeIOS();
12778 if(Roo.isTouch && this.mobileTouchView){
12779 cfg = this.getAutoCreateTouchView();
12786 if(!this.tickable){
12787 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12792 * ComboBox with tickable selections
12795 var align = this.labelAlign || this.parentLabelAlign();
12798 cls : 'form-group roo-combobox-tickable' //input-group
12801 var btn_text_select = '';
12802 var btn_text_done = '';
12803 var btn_text_cancel = '';
12805 if (this.btn_text_show) {
12806 btn_text_select = 'Select';
12807 btn_text_done = 'Done';
12808 btn_text_cancel = 'Cancel';
12813 cls : 'tickable-buttons',
12818 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12819 //html : this.triggerText
12820 html: btn_text_select
12826 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12828 html: btn_text_done
12834 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12836 html: btn_text_cancel
12842 buttons.cn.unshift({
12844 cls: 'roo-select2-search-field-input'
12850 Roo.each(buttons.cn, function(c){
12852 c.cls += ' btn-' + _this.size;
12855 if (_this.disabled) {
12866 cls: 'form-hidden-field'
12870 cls: 'roo-select2-choices',
12874 cls: 'roo-select2-search-field',
12885 cls: 'roo-select2-container input-group roo-select2-container-multi',
12890 // cls: 'typeahead typeahead-long dropdown-menu',
12891 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12896 if(this.hasFeedback && !this.allowBlank){
12900 cls: 'glyphicon form-control-feedback'
12903 combobox.cn.push(feedback);
12907 if (align ==='left' && this.fieldLabel.length) {
12909 cfg.cls += ' roo-form-group-label-left';
12914 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12915 tooltip : 'This field is required'
12920 cls : 'control-label',
12921 html : this.fieldLabel
12933 var labelCfg = cfg.cn[1];
12934 var contentCfg = cfg.cn[2];
12937 if(this.indicatorpos == 'right'){
12943 cls : 'control-label',
12947 html : this.fieldLabel
12951 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12952 tooltip : 'This field is required'
12967 labelCfg = cfg.cn[0];
12968 contentCfg = cfg.cn[1];
12972 if(this.labelWidth > 12){
12973 labelCfg.style = "width: " + this.labelWidth + 'px';
12976 if(this.labelWidth < 13 && this.labelmd == 0){
12977 this.labelmd = this.labelWidth;
12980 if(this.labellg > 0){
12981 labelCfg.cls += ' col-lg-' + this.labellg;
12982 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12985 if(this.labelmd > 0){
12986 labelCfg.cls += ' col-md-' + this.labelmd;
12987 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12990 if(this.labelsm > 0){
12991 labelCfg.cls += ' col-sm-' + this.labelsm;
12992 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12995 if(this.labelxs > 0){
12996 labelCfg.cls += ' col-xs-' + this.labelxs;
12997 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13001 } else if ( this.fieldLabel.length) {
13002 // Roo.log(" label");
13006 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13007 tooltip : 'This field is required'
13011 //cls : 'input-group-addon',
13012 html : this.fieldLabel
13017 if(this.indicatorpos == 'right'){
13021 //cls : 'input-group-addon',
13022 html : this.fieldLabel
13026 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13027 tooltip : 'This field is required'
13036 // Roo.log(" no label && no align");
13043 ['xs','sm','md','lg'].map(function(size){
13044 if (settings[size]) {
13045 cfg.cls += ' col-' + size + '-' + settings[size];
13053 _initEventsCalled : false,
13056 initEvents: function()
13058 if (this._initEventsCalled) { // as we call render... prevent looping...
13061 this._initEventsCalled = true;
13064 throw "can not find store for combo";
13067 this.indicator = this.indicatorEl();
13069 this.store = Roo.factory(this.store, Roo.data);
13070 this.store.parent = this;
13072 // if we are building from html. then this element is so complex, that we can not really
13073 // use the rendered HTML.
13074 // so we have to trash and replace the previous code.
13075 if (Roo.XComponent.build_from_html) {
13076 // remove this element....
13077 var e = this.el.dom, k=0;
13078 while (e ) { e = e.previousSibling; ++k;}
13083 this.rendered = false;
13085 this.render(this.parent().getChildContainer(true), k);
13088 if(Roo.isIOS && this.useNativeIOS){
13089 this.initIOSView();
13097 if(Roo.isTouch && this.mobileTouchView){
13098 this.initTouchView();
13103 this.initTickableEvents();
13107 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13109 if(this.hiddenName){
13111 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13113 this.hiddenField.dom.value =
13114 this.hiddenValue !== undefined ? this.hiddenValue :
13115 this.value !== undefined ? this.value : '';
13117 // prevent input submission
13118 this.el.dom.removeAttribute('name');
13119 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13124 // this.el.dom.setAttribute('autocomplete', 'off');
13127 var cls = 'x-combo-list';
13129 //this.list = new Roo.Layer({
13130 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13136 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13137 _this.list.setWidth(lw);
13140 this.list.on('mouseover', this.onViewOver, this);
13141 this.list.on('mousemove', this.onViewMove, this);
13142 this.list.on('scroll', this.onViewScroll, this);
13145 this.list.swallowEvent('mousewheel');
13146 this.assetHeight = 0;
13149 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13150 this.assetHeight += this.header.getHeight();
13153 this.innerList = this.list.createChild({cls:cls+'-inner'});
13154 this.innerList.on('mouseover', this.onViewOver, this);
13155 this.innerList.on('mousemove', this.onViewMove, this);
13156 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13158 if(this.allowBlank && !this.pageSize && !this.disableClear){
13159 this.footer = this.list.createChild({cls:cls+'-ft'});
13160 this.pageTb = new Roo.Toolbar(this.footer);
13164 this.footer = this.list.createChild({cls:cls+'-ft'});
13165 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13166 {pageSize: this.pageSize});
13170 if (this.pageTb && this.allowBlank && !this.disableClear) {
13172 this.pageTb.add(new Roo.Toolbar.Fill(), {
13173 cls: 'x-btn-icon x-btn-clear',
13175 handler: function()
13178 _this.clearValue();
13179 _this.onSelect(false, -1);
13184 this.assetHeight += this.footer.getHeight();
13189 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13192 this.view = new Roo.View(this.list, this.tpl, {
13193 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13195 //this.view.wrapEl.setDisplayed(false);
13196 this.view.on('click', this.onViewClick, this);
13199 this.store.on('beforeload', this.onBeforeLoad, this);
13200 this.store.on('load', this.onLoad, this);
13201 this.store.on('loadexception', this.onLoadException, this);
13203 if(this.resizable){
13204 this.resizer = new Roo.Resizable(this.list, {
13205 pinned:true, handles:'se'
13207 this.resizer.on('resize', function(r, w, h){
13208 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13209 this.listWidth = w;
13210 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13211 this.restrictHeight();
13213 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13216 if(!this.editable){
13217 this.editable = true;
13218 this.setEditable(false);
13223 if (typeof(this.events.add.listeners) != 'undefined') {
13225 this.addicon = this.wrap.createChild(
13226 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13228 this.addicon.on('click', function(e) {
13229 this.fireEvent('add', this);
13232 if (typeof(this.events.edit.listeners) != 'undefined') {
13234 this.editicon = this.wrap.createChild(
13235 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13236 if (this.addicon) {
13237 this.editicon.setStyle('margin-left', '40px');
13239 this.editicon.on('click', function(e) {
13241 // we fire even if inothing is selected..
13242 this.fireEvent('edit', this, this.lastData );
13248 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13249 "up" : function(e){
13250 this.inKeyMode = true;
13254 "down" : function(e){
13255 if(!this.isExpanded()){
13256 this.onTriggerClick();
13258 this.inKeyMode = true;
13263 "enter" : function(e){
13264 // this.onViewClick();
13268 if(this.fireEvent("specialkey", this, e)){
13269 this.onViewClick(false);
13275 "esc" : function(e){
13279 "tab" : function(e){
13282 if(this.fireEvent("specialkey", this, e)){
13283 this.onViewClick(false);
13291 doRelay : function(foo, bar, hname){
13292 if(hname == 'down' || this.scope.isExpanded()){
13293 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13302 this.queryDelay = Math.max(this.queryDelay || 10,
13303 this.mode == 'local' ? 10 : 250);
13306 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13308 if(this.typeAhead){
13309 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13311 if(this.editable !== false){
13312 this.inputEl().on("keyup", this.onKeyUp, this);
13314 if(this.forceSelection){
13315 this.inputEl().on('blur', this.doForce, this);
13319 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13320 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13324 initTickableEvents: function()
13328 if(this.hiddenName){
13330 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13332 this.hiddenField.dom.value =
13333 this.hiddenValue !== undefined ? this.hiddenValue :
13334 this.value !== undefined ? this.value : '';
13336 // prevent input submission
13337 this.el.dom.removeAttribute('name');
13338 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13343 // this.list = this.el.select('ul.dropdown-menu',true).first();
13345 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13346 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13347 if(this.triggerList){
13348 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13351 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13352 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13354 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13355 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13357 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13358 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13360 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13361 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13362 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13365 this.cancelBtn.hide();
13370 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13371 _this.list.setWidth(lw);
13374 this.list.on('mouseover', this.onViewOver, this);
13375 this.list.on('mousemove', this.onViewMove, this);
13377 this.list.on('scroll', this.onViewScroll, this);
13380 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>';
13383 this.view = new Roo.View(this.list, this.tpl, {
13384 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13387 //this.view.wrapEl.setDisplayed(false);
13388 this.view.on('click', this.onViewClick, this);
13392 this.store.on('beforeload', this.onBeforeLoad, this);
13393 this.store.on('load', this.onLoad, this);
13394 this.store.on('loadexception', this.onLoadException, this);
13397 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13398 "up" : function(e){
13399 this.inKeyMode = true;
13403 "down" : function(e){
13404 this.inKeyMode = true;
13408 "enter" : function(e){
13409 if(this.fireEvent("specialkey", this, e)){
13410 this.onViewClick(false);
13416 "esc" : function(e){
13417 this.onTickableFooterButtonClick(e, false, false);
13420 "tab" : function(e){
13421 this.fireEvent("specialkey", this, e);
13423 this.onTickableFooterButtonClick(e, false, false);
13430 doRelay : function(e, fn, key){
13431 if(this.scope.isExpanded()){
13432 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13441 this.queryDelay = Math.max(this.queryDelay || 10,
13442 this.mode == 'local' ? 10 : 250);
13445 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13447 if(this.typeAhead){
13448 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13451 if(this.editable !== false){
13452 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13455 this.indicator = this.indicatorEl();
13457 if(this.indicator){
13458 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13459 this.indicator.hide();
13464 onDestroy : function(){
13466 this.view.setStore(null);
13467 this.view.el.removeAllListeners();
13468 this.view.el.remove();
13469 this.view.purgeListeners();
13472 this.list.dom.innerHTML = '';
13476 this.store.un('beforeload', this.onBeforeLoad, this);
13477 this.store.un('load', this.onLoad, this);
13478 this.store.un('loadexception', this.onLoadException, this);
13480 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13484 fireKey : function(e){
13485 if(e.isNavKeyPress() && !this.list.isVisible()){
13486 this.fireEvent("specialkey", this, e);
13491 onResize: function(w, h){
13492 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13494 // if(typeof w != 'number'){
13495 // // we do not handle it!?!?
13498 // var tw = this.trigger.getWidth();
13499 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13500 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13502 // this.inputEl().setWidth( this.adjustWidth('input', x));
13504 // //this.trigger.setStyle('left', x+'px');
13506 // if(this.list && this.listWidth === undefined){
13507 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13508 // this.list.setWidth(lw);
13509 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13517 * Allow or prevent the user from directly editing the field text. If false is passed,
13518 * the user will only be able to select from the items defined in the dropdown list. This method
13519 * is the runtime equivalent of setting the 'editable' config option at config time.
13520 * @param {Boolean} value True to allow the user to directly edit the field text
13522 setEditable : function(value){
13523 if(value == this.editable){
13526 this.editable = value;
13528 this.inputEl().dom.setAttribute('readOnly', true);
13529 this.inputEl().on('mousedown', this.onTriggerClick, this);
13530 this.inputEl().addClass('x-combo-noedit');
13532 this.inputEl().dom.setAttribute('readOnly', false);
13533 this.inputEl().un('mousedown', this.onTriggerClick, this);
13534 this.inputEl().removeClass('x-combo-noedit');
13540 onBeforeLoad : function(combo,opts){
13541 if(!this.hasFocus){
13545 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13547 this.restrictHeight();
13548 this.selectedIndex = -1;
13552 onLoad : function(){
13554 this.hasQuery = false;
13556 if(!this.hasFocus){
13560 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13561 this.loading.hide();
13564 if(this.store.getCount() > 0){
13567 this.restrictHeight();
13568 if(this.lastQuery == this.allQuery){
13569 if(this.editable && !this.tickable){
13570 this.inputEl().dom.select();
13574 !this.selectByValue(this.value, true) &&
13577 !this.store.lastOptions ||
13578 typeof(this.store.lastOptions.add) == 'undefined' ||
13579 this.store.lastOptions.add != true
13582 this.select(0, true);
13585 if(this.autoFocus){
13588 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13589 this.taTask.delay(this.typeAheadDelay);
13593 this.onEmptyResults();
13599 onLoadException : function()
13601 this.hasQuery = false;
13603 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13604 this.loading.hide();
13607 if(this.tickable && this.editable){
13612 // only causes errors at present
13613 //Roo.log(this.store.reader.jsonData);
13614 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13616 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13622 onTypeAhead : function(){
13623 if(this.store.getCount() > 0){
13624 var r = this.store.getAt(0);
13625 var newValue = r.data[this.displayField];
13626 var len = newValue.length;
13627 var selStart = this.getRawValue().length;
13629 if(selStart != len){
13630 this.setRawValue(newValue);
13631 this.selectText(selStart, newValue.length);
13637 onSelect : function(record, index){
13639 if(this.fireEvent('beforeselect', this, record, index) !== false){
13641 this.setFromData(index > -1 ? record.data : false);
13644 this.fireEvent('select', this, record, index);
13649 * Returns the currently selected field value or empty string if no value is set.
13650 * @return {String} value The selected value
13652 getValue : function()
13654 if(Roo.isIOS && this.useNativeIOS){
13655 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13659 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13662 if(this.valueField){
13663 return typeof this.value != 'undefined' ? this.value : '';
13665 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13669 getRawValue : function()
13671 if(Roo.isIOS && this.useNativeIOS){
13672 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13675 var v = this.inputEl().getValue();
13681 * Clears any text/value currently set in the field
13683 clearValue : function(){
13685 if(this.hiddenField){
13686 this.hiddenField.dom.value = '';
13689 this.setRawValue('');
13690 this.lastSelectionText = '';
13691 this.lastData = false;
13693 var close = this.closeTriggerEl();
13704 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13705 * will be displayed in the field. If the value does not match the data value of an existing item,
13706 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13707 * Otherwise the field will be blank (although the value will still be set).
13708 * @param {String} value The value to match
13710 setValue : function(v)
13712 if(Roo.isIOS && this.useNativeIOS){
13713 this.setIOSValue(v);
13723 if(this.valueField){
13724 var r = this.findRecord(this.valueField, v);
13726 text = r.data[this.displayField];
13727 }else if(this.valueNotFoundText !== undefined){
13728 text = this.valueNotFoundText;
13731 this.lastSelectionText = text;
13732 if(this.hiddenField){
13733 this.hiddenField.dom.value = v;
13735 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13738 var close = this.closeTriggerEl();
13741 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13747 * @property {Object} the last set data for the element
13752 * Sets the value of the field based on a object which is related to the record format for the store.
13753 * @param {Object} value the value to set as. or false on reset?
13755 setFromData : function(o){
13762 var dv = ''; // display value
13763 var vv = ''; // value value..
13765 if (this.displayField) {
13766 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13768 // this is an error condition!!!
13769 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13772 if(this.valueField){
13773 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13776 var close = this.closeTriggerEl();
13779 if(dv.length || vv * 1 > 0){
13781 this.blockFocus=true;
13787 if(this.hiddenField){
13788 this.hiddenField.dom.value = vv;
13790 this.lastSelectionText = dv;
13791 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13795 // no hidden field.. - we store the value in 'value', but still display
13796 // display field!!!!
13797 this.lastSelectionText = dv;
13798 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13805 reset : function(){
13806 // overridden so that last data is reset..
13813 this.setValue(this.originalValue);
13814 //this.clearInvalid();
13815 this.lastData = false;
13817 this.view.clearSelections();
13823 findRecord : function(prop, value){
13825 if(this.store.getCount() > 0){
13826 this.store.each(function(r){
13827 if(r.data[prop] == value){
13837 getName: function()
13839 // returns hidden if it's set..
13840 if (!this.rendered) {return ''};
13841 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13845 onViewMove : function(e, t){
13846 this.inKeyMode = false;
13850 onViewOver : function(e, t){
13851 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13854 var item = this.view.findItemFromChild(t);
13857 var index = this.view.indexOf(item);
13858 this.select(index, false);
13863 onViewClick : function(view, doFocus, el, e)
13865 var index = this.view.getSelectedIndexes()[0];
13867 var r = this.store.getAt(index);
13871 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13878 Roo.each(this.tickItems, function(v,k){
13880 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13882 _this.tickItems.splice(k, 1);
13884 if(typeof(e) == 'undefined' && view == false){
13885 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13897 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13898 this.tickItems.push(r.data);
13901 if(typeof(e) == 'undefined' && view == false){
13902 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13909 this.onSelect(r, index);
13911 if(doFocus !== false && !this.blockFocus){
13912 this.inputEl().focus();
13917 restrictHeight : function(){
13918 //this.innerList.dom.style.height = '';
13919 //var inner = this.innerList.dom;
13920 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13921 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13922 //this.list.beginUpdate();
13923 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13924 this.list.alignTo(this.inputEl(), this.listAlign);
13925 this.list.alignTo(this.inputEl(), this.listAlign);
13926 //this.list.endUpdate();
13930 onEmptyResults : function(){
13932 if(this.tickable && this.editable){
13933 this.restrictHeight();
13941 * Returns true if the dropdown list is expanded, else false.
13943 isExpanded : function(){
13944 return this.list.isVisible();
13948 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
13949 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13950 * @param {String} value The data value of the item to select
13951 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13952 * selected item if it is not currently in view (defaults to true)
13953 * @return {Boolean} True if the value matched an item in the list, else false
13955 selectByValue : function(v, scrollIntoView){
13956 if(v !== undefined && v !== null){
13957 var r = this.findRecord(this.valueField || this.displayField, v);
13959 this.select(this.store.indexOf(r), scrollIntoView);
13967 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
13968 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13969 * @param {Number} index The zero-based index of the list item to select
13970 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13971 * selected item if it is not currently in view (defaults to true)
13973 select : function(index, scrollIntoView){
13974 this.selectedIndex = index;
13975 this.view.select(index);
13976 if(scrollIntoView !== false){
13977 var el = this.view.getNode(index);
13979 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
13982 this.list.scrollChildIntoView(el, false);
13988 selectNext : function(){
13989 var ct = this.store.getCount();
13991 if(this.selectedIndex == -1){
13993 }else if(this.selectedIndex < ct-1){
13994 this.select(this.selectedIndex+1);
14000 selectPrev : function(){
14001 var ct = this.store.getCount();
14003 if(this.selectedIndex == -1){
14005 }else if(this.selectedIndex != 0){
14006 this.select(this.selectedIndex-1);
14012 onKeyUp : function(e){
14013 if(this.editable !== false && !e.isSpecialKey()){
14014 this.lastKey = e.getKey();
14015 this.dqTask.delay(this.queryDelay);
14020 validateBlur : function(){
14021 return !this.list || !this.list.isVisible();
14025 initQuery : function(){
14027 var v = this.getRawValue();
14029 if(this.tickable && this.editable){
14030 v = this.tickableInputEl().getValue();
14037 doForce : function(){
14038 if(this.inputEl().dom.value.length > 0){
14039 this.inputEl().dom.value =
14040 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14046 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14047 * query allowing the query action to be canceled if needed.
14048 * @param {String} query The SQL query to execute
14049 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14050 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14051 * saved in the current store (defaults to false)
14053 doQuery : function(q, forceAll){
14055 if(q === undefined || q === null){
14060 forceAll: forceAll,
14064 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14069 forceAll = qe.forceAll;
14070 if(forceAll === true || (q.length >= this.minChars)){
14072 this.hasQuery = true;
14074 if(this.lastQuery != q || this.alwaysQuery){
14075 this.lastQuery = q;
14076 if(this.mode == 'local'){
14077 this.selectedIndex = -1;
14079 this.store.clearFilter();
14082 if(this.specialFilter){
14083 this.fireEvent('specialfilter', this);
14088 this.store.filter(this.displayField, q);
14091 this.store.fireEvent("datachanged", this.store);
14098 this.store.baseParams[this.queryParam] = q;
14100 var options = {params : this.getParams(q)};
14103 options.add = true;
14104 options.params.start = this.page * this.pageSize;
14107 this.store.load(options);
14110 * this code will make the page width larger, at the beginning, the list not align correctly,
14111 * we should expand the list on onLoad
14112 * so command out it
14117 this.selectedIndex = -1;
14122 this.loadNext = false;
14126 getParams : function(q){
14128 //p[this.queryParam] = q;
14132 p.limit = this.pageSize;
14138 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14140 collapse : function(){
14141 if(!this.isExpanded()){
14147 this.hasFocus = false;
14151 this.cancelBtn.hide();
14152 this.trigger.show();
14155 this.tickableInputEl().dom.value = '';
14156 this.tickableInputEl().blur();
14161 Roo.get(document).un('mousedown', this.collapseIf, this);
14162 Roo.get(document).un('mousewheel', this.collapseIf, this);
14163 if (!this.editable) {
14164 Roo.get(document).un('keydown', this.listKeyPress, this);
14166 this.fireEvent('collapse', this);
14172 collapseIf : function(e){
14173 var in_combo = e.within(this.el);
14174 var in_list = e.within(this.list);
14175 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14177 if (in_combo || in_list || is_list) {
14178 //e.stopPropagation();
14183 this.onTickableFooterButtonClick(e, false, false);
14191 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14193 expand : function(){
14195 if(this.isExpanded() || !this.hasFocus){
14199 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14200 this.list.setWidth(lw);
14206 this.restrictHeight();
14210 this.tickItems = Roo.apply([], this.item);
14213 this.cancelBtn.show();
14214 this.trigger.hide();
14217 this.tickableInputEl().focus();
14222 Roo.get(document).on('mousedown', this.collapseIf, this);
14223 Roo.get(document).on('mousewheel', this.collapseIf, this);
14224 if (!this.editable) {
14225 Roo.get(document).on('keydown', this.listKeyPress, this);
14228 this.fireEvent('expand', this);
14232 // Implements the default empty TriggerField.onTriggerClick function
14233 onTriggerClick : function(e)
14235 Roo.log('trigger click');
14237 if(this.disabled || !this.triggerList){
14242 this.loadNext = false;
14244 if(this.isExpanded()){
14246 if (!this.blockFocus) {
14247 this.inputEl().focus();
14251 this.hasFocus = true;
14252 if(this.triggerAction == 'all') {
14253 this.doQuery(this.allQuery, true);
14255 this.doQuery(this.getRawValue());
14257 if (!this.blockFocus) {
14258 this.inputEl().focus();
14263 onTickableTriggerClick : function(e)
14270 this.loadNext = false;
14271 this.hasFocus = true;
14273 if(this.triggerAction == 'all') {
14274 this.doQuery(this.allQuery, true);
14276 this.doQuery(this.getRawValue());
14280 onSearchFieldClick : function(e)
14282 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14283 this.onTickableFooterButtonClick(e, false, false);
14287 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14292 this.loadNext = false;
14293 this.hasFocus = true;
14295 if(this.triggerAction == 'all') {
14296 this.doQuery(this.allQuery, true);
14298 this.doQuery(this.getRawValue());
14302 listKeyPress : function(e)
14304 //Roo.log('listkeypress');
14305 // scroll to first matching element based on key pres..
14306 if (e.isSpecialKey()) {
14309 var k = String.fromCharCode(e.getKey()).toUpperCase();
14312 var csel = this.view.getSelectedNodes();
14313 var cselitem = false;
14315 var ix = this.view.indexOf(csel[0]);
14316 cselitem = this.store.getAt(ix);
14317 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14323 this.store.each(function(v) {
14325 // start at existing selection.
14326 if (cselitem.id == v.id) {
14332 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14333 match = this.store.indexOf(v);
14339 if (match === false) {
14340 return true; // no more action?
14343 this.view.select(match);
14344 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14345 sn.scrollIntoView(sn.dom.parentNode, false);
14348 onViewScroll : function(e, t){
14350 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){
14354 this.hasQuery = true;
14356 this.loading = this.list.select('.loading', true).first();
14358 if(this.loading === null){
14359 this.list.createChild({
14361 cls: 'loading roo-select2-more-results roo-select2-active',
14362 html: 'Loading more results...'
14365 this.loading = this.list.select('.loading', true).first();
14367 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14369 this.loading.hide();
14372 this.loading.show();
14377 this.loadNext = true;
14379 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14384 addItem : function(o)
14386 var dv = ''; // display value
14388 if (this.displayField) {
14389 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14391 // this is an error condition!!!
14392 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14399 var choice = this.choices.createChild({
14401 cls: 'roo-select2-search-choice',
14410 cls: 'roo-select2-search-choice-close fa fa-times',
14415 }, this.searchField);
14417 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14419 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14427 this.inputEl().dom.value = '';
14432 onRemoveItem : function(e, _self, o)
14434 e.preventDefault();
14436 this.lastItem = Roo.apply([], this.item);
14438 var index = this.item.indexOf(o.data) * 1;
14441 Roo.log('not this item?!');
14445 this.item.splice(index, 1);
14450 this.fireEvent('remove', this, e);
14456 syncValue : function()
14458 if(!this.item.length){
14465 Roo.each(this.item, function(i){
14466 if(_this.valueField){
14467 value.push(i[_this.valueField]);
14474 this.value = value.join(',');
14476 if(this.hiddenField){
14477 this.hiddenField.dom.value = this.value;
14480 this.store.fireEvent("datachanged", this.store);
14485 clearItem : function()
14487 if(!this.multiple){
14493 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14501 if(this.tickable && !Roo.isTouch){
14502 this.view.refresh();
14506 inputEl: function ()
14508 if(Roo.isIOS && this.useNativeIOS){
14509 return this.el.select('select.roo-ios-select', true).first();
14512 if(Roo.isTouch && this.mobileTouchView){
14513 return this.el.select('input.form-control',true).first();
14517 return this.searchField;
14520 return this.el.select('input.form-control',true).first();
14523 onTickableFooterButtonClick : function(e, btn, el)
14525 e.preventDefault();
14527 this.lastItem = Roo.apply([], this.item);
14529 if(btn && btn.name == 'cancel'){
14530 this.tickItems = Roo.apply([], this.item);
14539 Roo.each(this.tickItems, function(o){
14547 validate : function()
14549 var v = this.getRawValue();
14552 v = this.getValue();
14555 if(this.disabled || this.allowBlank || v.length){
14560 this.markInvalid();
14564 tickableInputEl : function()
14566 if(!this.tickable || !this.editable){
14567 return this.inputEl();
14570 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14574 getAutoCreateTouchView : function()
14579 cls: 'form-group' //input-group
14585 type : this.inputType,
14586 cls : 'form-control x-combo-noedit',
14587 autocomplete: 'new-password',
14588 placeholder : this.placeholder || '',
14593 input.name = this.name;
14597 input.cls += ' input-' + this.size;
14600 if (this.disabled) {
14601 input.disabled = true;
14612 inputblock.cls += ' input-group';
14614 inputblock.cn.unshift({
14616 cls : 'input-group-addon',
14621 if(this.removable && !this.multiple){
14622 inputblock.cls += ' roo-removable';
14624 inputblock.cn.push({
14627 cls : 'roo-combo-removable-btn close'
14631 if(this.hasFeedback && !this.allowBlank){
14633 inputblock.cls += ' has-feedback';
14635 inputblock.cn.push({
14637 cls: 'glyphicon form-control-feedback'
14644 inputblock.cls += (this.before) ? '' : ' input-group';
14646 inputblock.cn.push({
14648 cls : 'input-group-addon',
14659 cls: 'form-hidden-field'
14673 cls: 'form-hidden-field'
14677 cls: 'roo-select2-choices',
14681 cls: 'roo-select2-search-field',
14694 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14700 if(!this.multiple && this.showToggleBtn){
14707 if (this.caret != false) {
14710 cls: 'fa fa-' + this.caret
14717 cls : 'input-group-addon btn dropdown-toggle',
14722 cls: 'combobox-clear',
14736 combobox.cls += ' roo-select2-container-multi';
14739 var align = this.labelAlign || this.parentLabelAlign();
14741 if (align ==='left' && this.fieldLabel.length) {
14746 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14747 tooltip : 'This field is required'
14751 cls : 'control-label',
14752 html : this.fieldLabel
14763 var labelCfg = cfg.cn[1];
14764 var contentCfg = cfg.cn[2];
14767 if(this.indicatorpos == 'right'){
14772 cls : 'control-label',
14776 html : this.fieldLabel
14780 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14781 tooltip : 'This field is required'
14794 labelCfg = cfg.cn[0];
14795 contentCfg = cfg.cn[1];
14800 if(this.labelWidth > 12){
14801 labelCfg.style = "width: " + this.labelWidth + 'px';
14804 if(this.labelWidth < 13 && this.labelmd == 0){
14805 this.labelmd = this.labelWidth;
14808 if(this.labellg > 0){
14809 labelCfg.cls += ' col-lg-' + this.labellg;
14810 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14813 if(this.labelmd > 0){
14814 labelCfg.cls += ' col-md-' + this.labelmd;
14815 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14818 if(this.labelsm > 0){
14819 labelCfg.cls += ' col-sm-' + this.labelsm;
14820 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14823 if(this.labelxs > 0){
14824 labelCfg.cls += ' col-xs-' + this.labelxs;
14825 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14829 } else if ( this.fieldLabel.length) {
14833 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14834 tooltip : 'This field is required'
14838 cls : 'control-label',
14839 html : this.fieldLabel
14850 if(this.indicatorpos == 'right'){
14854 cls : 'control-label',
14855 html : this.fieldLabel,
14859 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14860 tooltip : 'This field is required'
14877 var settings = this;
14879 ['xs','sm','md','lg'].map(function(size){
14880 if (settings[size]) {
14881 cfg.cls += ' col-' + size + '-' + settings[size];
14888 initTouchView : function()
14890 this.renderTouchView();
14892 this.touchViewEl.on('scroll', function(){
14893 this.el.dom.scrollTop = 0;
14896 this.originalValue = this.getValue();
14898 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14900 this.inputEl().on("click", this.showTouchView, this);
14901 if (this.triggerEl) {
14902 this.triggerEl.on("click", this.showTouchView, this);
14906 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14907 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14909 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14911 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14912 this.store.on('load', this.onTouchViewLoad, this);
14913 this.store.on('loadexception', this.onTouchViewLoadException, this);
14915 if(this.hiddenName){
14917 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14919 this.hiddenField.dom.value =
14920 this.hiddenValue !== undefined ? this.hiddenValue :
14921 this.value !== undefined ? this.value : '';
14923 this.el.dom.removeAttribute('name');
14924 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14928 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14929 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14932 if(this.removable && !this.multiple){
14933 var close = this.closeTriggerEl();
14935 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14936 close.on('click', this.removeBtnClick, this, close);
14940 * fix the bug in Safari iOS8
14942 this.inputEl().on("focus", function(e){
14943 document.activeElement.blur();
14951 renderTouchView : function()
14953 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
14954 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14956 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
14957 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14959 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
14960 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14961 this.touchViewBodyEl.setStyle('overflow', 'auto');
14963 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
14964 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14966 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
14967 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14971 showTouchView : function()
14977 this.touchViewHeaderEl.hide();
14979 if(this.modalTitle.length){
14980 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
14981 this.touchViewHeaderEl.show();
14984 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
14985 this.touchViewEl.show();
14987 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
14989 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
14990 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
14992 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
14994 if(this.modalTitle.length){
14995 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
14998 this.touchViewBodyEl.setHeight(bodyHeight);
15002 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15004 this.touchViewEl.addClass('in');
15007 this.doTouchViewQuery();
15011 hideTouchView : function()
15013 this.touchViewEl.removeClass('in');
15017 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15019 this.touchViewEl.setStyle('display', 'none');
15024 setTouchViewValue : function()
15031 Roo.each(this.tickItems, function(o){
15036 this.hideTouchView();
15039 doTouchViewQuery : function()
15048 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15052 if(!this.alwaysQuery || this.mode == 'local'){
15053 this.onTouchViewLoad();
15060 onTouchViewBeforeLoad : function(combo,opts)
15066 onTouchViewLoad : function()
15068 if(this.store.getCount() < 1){
15069 this.onTouchViewEmptyResults();
15073 this.clearTouchView();
15075 var rawValue = this.getRawValue();
15077 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15079 this.tickItems = [];
15081 this.store.data.each(function(d, rowIndex){
15082 var row = this.touchViewListGroup.createChild(template);
15084 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15085 row.addClass(d.data.cls);
15088 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15091 html : d.data[this.displayField]
15094 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15095 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15098 row.removeClass('selected');
15099 if(!this.multiple && this.valueField &&
15100 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15103 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15104 row.addClass('selected');
15107 if(this.multiple && this.valueField &&
15108 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15112 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15113 this.tickItems.push(d.data);
15116 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15120 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15122 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15124 if(this.modalTitle.length){
15125 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15128 var listHeight = this.touchViewListGroup.getHeight();
15132 if(firstChecked && listHeight > bodyHeight){
15133 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15138 onTouchViewLoadException : function()
15140 this.hideTouchView();
15143 onTouchViewEmptyResults : function()
15145 this.clearTouchView();
15147 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15149 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15153 clearTouchView : function()
15155 this.touchViewListGroup.dom.innerHTML = '';
15158 onTouchViewClick : function(e, el, o)
15160 e.preventDefault();
15163 var rowIndex = o.rowIndex;
15165 var r = this.store.getAt(rowIndex);
15167 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15169 if(!this.multiple){
15170 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15171 c.dom.removeAttribute('checked');
15174 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15176 this.setFromData(r.data);
15178 var close = this.closeTriggerEl();
15184 this.hideTouchView();
15186 this.fireEvent('select', this, r, rowIndex);
15191 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15192 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15193 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15197 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15198 this.addItem(r.data);
15199 this.tickItems.push(r.data);
15203 getAutoCreateNativeIOS : function()
15206 cls: 'form-group' //input-group,
15211 cls : 'roo-ios-select'
15215 combobox.name = this.name;
15218 if (this.disabled) {
15219 combobox.disabled = true;
15222 var settings = this;
15224 ['xs','sm','md','lg'].map(function(size){
15225 if (settings[size]) {
15226 cfg.cls += ' col-' + size + '-' + settings[size];
15236 initIOSView : function()
15238 this.store.on('load', this.onIOSViewLoad, this);
15243 onIOSViewLoad : function()
15245 if(this.store.getCount() < 1){
15249 this.clearIOSView();
15251 if(this.allowBlank) {
15253 var default_text = '-- SELECT --';
15255 if(this.placeholder.length){
15256 default_text = this.placeholder;
15259 if(this.emptyTitle.length){
15260 default_text += ' - ' + this.emptyTitle + ' -';
15263 var opt = this.inputEl().createChild({
15266 html : default_text
15270 o[this.valueField] = 0;
15271 o[this.displayField] = default_text;
15273 this.ios_options.push({
15280 this.store.data.each(function(d, rowIndex){
15284 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15285 html = d.data[this.displayField];
15290 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15291 value = d.data[this.valueField];
15300 if(this.value == d.data[this.valueField]){
15301 option['selected'] = true;
15304 var opt = this.inputEl().createChild(option);
15306 this.ios_options.push({
15313 this.inputEl().on('change', function(){
15314 this.fireEvent('select', this);
15319 clearIOSView: function()
15321 this.inputEl().dom.innerHTML = '';
15323 this.ios_options = [];
15326 setIOSValue: function(v)
15330 if(!this.ios_options){
15334 Roo.each(this.ios_options, function(opts){
15336 opts.el.dom.removeAttribute('selected');
15338 if(opts.data[this.valueField] != v){
15342 opts.el.dom.setAttribute('selected', true);
15348 * @cfg {Boolean} grow
15352 * @cfg {Number} growMin
15356 * @cfg {Number} growMax
15365 Roo.apply(Roo.bootstrap.ComboBox, {
15369 cls: 'modal-header',
15391 cls: 'list-group-item',
15395 cls: 'roo-combobox-list-group-item-value'
15399 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15413 listItemCheckbox : {
15415 cls: 'list-group-item',
15419 cls: 'roo-combobox-list-group-item-value'
15423 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15439 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15444 cls: 'modal-footer',
15452 cls: 'col-xs-6 text-left',
15455 cls: 'btn btn-danger roo-touch-view-cancel',
15461 cls: 'col-xs-6 text-right',
15464 cls: 'btn btn-success roo-touch-view-ok',
15475 Roo.apply(Roo.bootstrap.ComboBox, {
15477 touchViewTemplate : {
15479 cls: 'modal fade roo-combobox-touch-view',
15483 cls: 'modal-dialog',
15484 style : 'position:fixed', // we have to fix position....
15488 cls: 'modal-content',
15490 Roo.bootstrap.ComboBox.header,
15491 Roo.bootstrap.ComboBox.body,
15492 Roo.bootstrap.ComboBox.footer
15501 * Ext JS Library 1.1.1
15502 * Copyright(c) 2006-2007, Ext JS, LLC.
15504 * Originally Released Under LGPL - original licence link has changed is not relivant.
15507 * <script type="text/javascript">
15512 * @extends Roo.util.Observable
15513 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15514 * This class also supports single and multi selection modes. <br>
15515 * Create a data model bound view:
15517 var store = new Roo.data.Store(...);
15519 var view = new Roo.View({
15521 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15523 singleSelect: true,
15524 selectedClass: "ydataview-selected",
15528 // listen for node click?
15529 view.on("click", function(vw, index, node, e){
15530 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15534 dataModel.load("foobar.xml");
15536 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15538 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15539 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15541 * Note: old style constructor is still suported (container, template, config)
15544 * Create a new View
15545 * @param {Object} config The config object
15548 Roo.View = function(config, depreciated_tpl, depreciated_config){
15550 this.parent = false;
15552 if (typeof(depreciated_tpl) == 'undefined') {
15553 // new way.. - universal constructor.
15554 Roo.apply(this, config);
15555 this.el = Roo.get(this.el);
15558 this.el = Roo.get(config);
15559 this.tpl = depreciated_tpl;
15560 Roo.apply(this, depreciated_config);
15562 this.wrapEl = this.el.wrap().wrap();
15563 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15566 if(typeof(this.tpl) == "string"){
15567 this.tpl = new Roo.Template(this.tpl);
15569 // support xtype ctors..
15570 this.tpl = new Roo.factory(this.tpl, Roo);
15574 this.tpl.compile();
15579 * @event beforeclick
15580 * Fires before a click is processed. Returns false to cancel the default action.
15581 * @param {Roo.View} this
15582 * @param {Number} index The index of the target node
15583 * @param {HTMLElement} node The target node
15584 * @param {Roo.EventObject} e The raw event object
15586 "beforeclick" : true,
15589 * Fires when a template node is clicked.
15590 * @param {Roo.View} this
15591 * @param {Number} index The index of the target node
15592 * @param {HTMLElement} node The target node
15593 * @param {Roo.EventObject} e The raw event object
15598 * Fires when a template node is double clicked.
15599 * @param {Roo.View} this
15600 * @param {Number} index The index of the target node
15601 * @param {HTMLElement} node The target node
15602 * @param {Roo.EventObject} e The raw event object
15606 * @event contextmenu
15607 * Fires when a template node is right clicked.
15608 * @param {Roo.View} this
15609 * @param {Number} index The index of the target node
15610 * @param {HTMLElement} node The target node
15611 * @param {Roo.EventObject} e The raw event object
15613 "contextmenu" : true,
15615 * @event selectionchange
15616 * Fires when the selected nodes change.
15617 * @param {Roo.View} this
15618 * @param {Array} selections Array of the selected nodes
15620 "selectionchange" : true,
15623 * @event beforeselect
15624 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15625 * @param {Roo.View} this
15626 * @param {HTMLElement} node The node to be selected
15627 * @param {Array} selections Array of currently selected nodes
15629 "beforeselect" : true,
15631 * @event preparedata
15632 * Fires on every row to render, to allow you to change the data.
15633 * @param {Roo.View} this
15634 * @param {Object} data to be rendered (change this)
15636 "preparedata" : true
15644 "click": this.onClick,
15645 "dblclick": this.onDblClick,
15646 "contextmenu": this.onContextMenu,
15650 this.selections = [];
15652 this.cmp = new Roo.CompositeElementLite([]);
15654 this.store = Roo.factory(this.store, Roo.data);
15655 this.setStore(this.store, true);
15658 if ( this.footer && this.footer.xtype) {
15660 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15662 this.footer.dataSource = this.store;
15663 this.footer.container = fctr;
15664 this.footer = Roo.factory(this.footer, Roo);
15665 fctr.insertFirst(this.el);
15667 // this is a bit insane - as the paging toolbar seems to detach the el..
15668 // dom.parentNode.parentNode.parentNode
15669 // they get detached?
15673 Roo.View.superclass.constructor.call(this);
15678 Roo.extend(Roo.View, Roo.util.Observable, {
15681 * @cfg {Roo.data.Store} store Data store to load data from.
15686 * @cfg {String|Roo.Element} el The container element.
15691 * @cfg {String|Roo.Template} tpl The template used by this View
15695 * @cfg {String} dataName the named area of the template to use as the data area
15696 * Works with domtemplates roo-name="name"
15700 * @cfg {String} selectedClass The css class to add to selected nodes
15702 selectedClass : "x-view-selected",
15704 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15709 * @cfg {String} text to display on mask (default Loading)
15713 * @cfg {Boolean} multiSelect Allow multiple selection
15715 multiSelect : false,
15717 * @cfg {Boolean} singleSelect Allow single selection
15719 singleSelect: false,
15722 * @cfg {Boolean} toggleSelect - selecting
15724 toggleSelect : false,
15727 * @cfg {Boolean} tickable - selecting
15732 * Returns the element this view is bound to.
15733 * @return {Roo.Element}
15735 getEl : function(){
15736 return this.wrapEl;
15742 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15744 refresh : function(){
15745 //Roo.log('refresh');
15748 // if we are using something like 'domtemplate', then
15749 // the what gets used is:
15750 // t.applySubtemplate(NAME, data, wrapping data..)
15751 // the outer template then get' applied with
15752 // the store 'extra data'
15753 // and the body get's added to the
15754 // roo-name="data" node?
15755 // <span class='roo-tpl-{name}'></span> ?????
15759 this.clearSelections();
15760 this.el.update("");
15762 var records = this.store.getRange();
15763 if(records.length < 1) {
15765 // is this valid?? = should it render a template??
15767 this.el.update(this.emptyText);
15771 if (this.dataName) {
15772 this.el.update(t.apply(this.store.meta)); //????
15773 el = this.el.child('.roo-tpl-' + this.dataName);
15776 for(var i = 0, len = records.length; i < len; i++){
15777 var data = this.prepareData(records[i].data, i, records[i]);
15778 this.fireEvent("preparedata", this, data, i, records[i]);
15780 var d = Roo.apply({}, data);
15783 Roo.apply(d, {'roo-id' : Roo.id()});
15787 Roo.each(this.parent.item, function(item){
15788 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15791 Roo.apply(d, {'roo-data-checked' : 'checked'});
15795 html[html.length] = Roo.util.Format.trim(
15797 t.applySubtemplate(this.dataName, d, this.store.meta) :
15804 el.update(html.join(""));
15805 this.nodes = el.dom.childNodes;
15806 this.updateIndexes(0);
15811 * Function to override to reformat the data that is sent to
15812 * the template for each node.
15813 * DEPRICATED - use the preparedata event handler.
15814 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15815 * a JSON object for an UpdateManager bound view).
15817 prepareData : function(data, index, record)
15819 this.fireEvent("preparedata", this, data, index, record);
15823 onUpdate : function(ds, record){
15824 // Roo.log('on update');
15825 this.clearSelections();
15826 var index = this.store.indexOf(record);
15827 var n = this.nodes[index];
15828 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15829 n.parentNode.removeChild(n);
15830 this.updateIndexes(index, index);
15836 onAdd : function(ds, records, index)
15838 //Roo.log(['on Add', ds, records, index] );
15839 this.clearSelections();
15840 if(this.nodes.length == 0){
15844 var n = this.nodes[index];
15845 for(var i = 0, len = records.length; i < len; i++){
15846 var d = this.prepareData(records[i].data, i, records[i]);
15848 this.tpl.insertBefore(n, d);
15851 this.tpl.append(this.el, d);
15854 this.updateIndexes(index);
15857 onRemove : function(ds, record, index){
15858 // Roo.log('onRemove');
15859 this.clearSelections();
15860 var el = this.dataName ?
15861 this.el.child('.roo-tpl-' + this.dataName) :
15864 el.dom.removeChild(this.nodes[index]);
15865 this.updateIndexes(index);
15869 * Refresh an individual node.
15870 * @param {Number} index
15872 refreshNode : function(index){
15873 this.onUpdate(this.store, this.store.getAt(index));
15876 updateIndexes : function(startIndex, endIndex){
15877 var ns = this.nodes;
15878 startIndex = startIndex || 0;
15879 endIndex = endIndex || ns.length - 1;
15880 for(var i = startIndex; i <= endIndex; i++){
15881 ns[i].nodeIndex = i;
15886 * Changes the data store this view uses and refresh the view.
15887 * @param {Store} store
15889 setStore : function(store, initial){
15890 if(!initial && this.store){
15891 this.store.un("datachanged", this.refresh);
15892 this.store.un("add", this.onAdd);
15893 this.store.un("remove", this.onRemove);
15894 this.store.un("update", this.onUpdate);
15895 this.store.un("clear", this.refresh);
15896 this.store.un("beforeload", this.onBeforeLoad);
15897 this.store.un("load", this.onLoad);
15898 this.store.un("loadexception", this.onLoad);
15902 store.on("datachanged", this.refresh, this);
15903 store.on("add", this.onAdd, this);
15904 store.on("remove", this.onRemove, this);
15905 store.on("update", this.onUpdate, this);
15906 store.on("clear", this.refresh, this);
15907 store.on("beforeload", this.onBeforeLoad, this);
15908 store.on("load", this.onLoad, this);
15909 store.on("loadexception", this.onLoad, this);
15917 * onbeforeLoad - masks the loading area.
15920 onBeforeLoad : function(store,opts)
15922 //Roo.log('onBeforeLoad');
15924 this.el.update("");
15926 this.el.mask(this.mask ? this.mask : "Loading" );
15928 onLoad : function ()
15935 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15936 * @param {HTMLElement} node
15937 * @return {HTMLElement} The template node
15939 findItemFromChild : function(node){
15940 var el = this.dataName ?
15941 this.el.child('.roo-tpl-' + this.dataName,true) :
15944 if(!node || node.parentNode == el){
15947 var p = node.parentNode;
15948 while(p && p != el){
15949 if(p.parentNode == el){
15958 onClick : function(e){
15959 var item = this.findItemFromChild(e.getTarget());
15961 var index = this.indexOf(item);
15962 if(this.onItemClick(item, index, e) !== false){
15963 this.fireEvent("click", this, index, item, e);
15966 this.clearSelections();
15971 onContextMenu : function(e){
15972 var item = this.findItemFromChild(e.getTarget());
15974 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
15979 onDblClick : function(e){
15980 var item = this.findItemFromChild(e.getTarget());
15982 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
15986 onItemClick : function(item, index, e)
15988 if(this.fireEvent("beforeclick", this, index, item, e) === false){
15991 if (this.toggleSelect) {
15992 var m = this.isSelected(item) ? 'unselect' : 'select';
15995 _t[m](item, true, false);
15998 if(this.multiSelect || this.singleSelect){
15999 if(this.multiSelect && e.shiftKey && this.lastSelection){
16000 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16002 this.select(item, this.multiSelect && e.ctrlKey);
16003 this.lastSelection = item;
16006 if(!this.tickable){
16007 e.preventDefault();
16015 * Get the number of selected nodes.
16018 getSelectionCount : function(){
16019 return this.selections.length;
16023 * Get the currently selected nodes.
16024 * @return {Array} An array of HTMLElements
16026 getSelectedNodes : function(){
16027 return this.selections;
16031 * Get the indexes of the selected nodes.
16034 getSelectedIndexes : function(){
16035 var indexes = [], s = this.selections;
16036 for(var i = 0, len = s.length; i < len; i++){
16037 indexes.push(s[i].nodeIndex);
16043 * Clear all selections
16044 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16046 clearSelections : function(suppressEvent){
16047 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16048 this.cmp.elements = this.selections;
16049 this.cmp.removeClass(this.selectedClass);
16050 this.selections = [];
16051 if(!suppressEvent){
16052 this.fireEvent("selectionchange", this, this.selections);
16058 * Returns true if the passed node is selected
16059 * @param {HTMLElement/Number} node The node or node index
16060 * @return {Boolean}
16062 isSelected : function(node){
16063 var s = this.selections;
16067 node = this.getNode(node);
16068 return s.indexOf(node) !== -1;
16073 * @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
16074 * @param {Boolean} keepExisting (optional) true to keep existing selections
16075 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16077 select : function(nodeInfo, keepExisting, suppressEvent){
16078 if(nodeInfo instanceof Array){
16080 this.clearSelections(true);
16082 for(var i = 0, len = nodeInfo.length; i < len; i++){
16083 this.select(nodeInfo[i], true, true);
16087 var node = this.getNode(nodeInfo);
16088 if(!node || this.isSelected(node)){
16089 return; // already selected.
16092 this.clearSelections(true);
16095 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16096 Roo.fly(node).addClass(this.selectedClass);
16097 this.selections.push(node);
16098 if(!suppressEvent){
16099 this.fireEvent("selectionchange", this, this.selections);
16107 * @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
16108 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16109 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16111 unselect : function(nodeInfo, keepExisting, suppressEvent)
16113 if(nodeInfo instanceof Array){
16114 Roo.each(this.selections, function(s) {
16115 this.unselect(s, nodeInfo);
16119 var node = this.getNode(nodeInfo);
16120 if(!node || !this.isSelected(node)){
16121 //Roo.log("not selected");
16122 return; // not selected.
16126 Roo.each(this.selections, function(s) {
16128 Roo.fly(node).removeClass(this.selectedClass);
16135 this.selections= ns;
16136 this.fireEvent("selectionchange", this, this.selections);
16140 * Gets a template node.
16141 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16142 * @return {HTMLElement} The node or null if it wasn't found
16144 getNode : function(nodeInfo){
16145 if(typeof nodeInfo == "string"){
16146 return document.getElementById(nodeInfo);
16147 }else if(typeof nodeInfo == "number"){
16148 return this.nodes[nodeInfo];
16154 * Gets a range template nodes.
16155 * @param {Number} startIndex
16156 * @param {Number} endIndex
16157 * @return {Array} An array of nodes
16159 getNodes : function(start, end){
16160 var ns = this.nodes;
16161 start = start || 0;
16162 end = typeof end == "undefined" ? ns.length - 1 : end;
16165 for(var i = start; i <= end; i++){
16169 for(var i = start; i >= end; i--){
16177 * Finds the index of the passed node
16178 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16179 * @return {Number} The index of the node or -1
16181 indexOf : function(node){
16182 node = this.getNode(node);
16183 if(typeof node.nodeIndex == "number"){
16184 return node.nodeIndex;
16186 var ns = this.nodes;
16187 for(var i = 0, len = ns.length; i < len; i++){
16198 * based on jquery fullcalendar
16202 Roo.bootstrap = Roo.bootstrap || {};
16204 * @class Roo.bootstrap.Calendar
16205 * @extends Roo.bootstrap.Component
16206 * Bootstrap Calendar class
16207 * @cfg {Boolean} loadMask (true|false) default false
16208 * @cfg {Object} header generate the user specific header of the calendar, default false
16211 * Create a new Container
16212 * @param {Object} config The config object
16217 Roo.bootstrap.Calendar = function(config){
16218 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16222 * Fires when a date is selected
16223 * @param {DatePicker} this
16224 * @param {Date} date The selected date
16228 * @event monthchange
16229 * Fires when the displayed month changes
16230 * @param {DatePicker} this
16231 * @param {Date} date The selected month
16233 'monthchange': true,
16235 * @event evententer
16236 * Fires when mouse over an event
16237 * @param {Calendar} this
16238 * @param {event} Event
16240 'evententer': true,
16242 * @event eventleave
16243 * Fires when the mouse leaves an
16244 * @param {Calendar} this
16247 'eventleave': true,
16249 * @event eventclick
16250 * Fires when the mouse click an
16251 * @param {Calendar} this
16260 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16263 * @cfg {Number} startDay
16264 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16272 getAutoCreate : function(){
16275 var fc_button = function(name, corner, style, content ) {
16276 return Roo.apply({},{
16278 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16280 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16283 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16294 style : 'width:100%',
16301 cls : 'fc-header-left',
16303 fc_button('prev', 'left', 'arrow', '‹' ),
16304 fc_button('next', 'right', 'arrow', '›' ),
16305 { tag: 'span', cls: 'fc-header-space' },
16306 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16314 cls : 'fc-header-center',
16318 cls: 'fc-header-title',
16321 html : 'month / year'
16329 cls : 'fc-header-right',
16331 /* fc_button('month', 'left', '', 'month' ),
16332 fc_button('week', '', '', 'week' ),
16333 fc_button('day', 'right', '', 'day' )
16345 header = this.header;
16348 var cal_heads = function() {
16350 // fixme - handle this.
16352 for (var i =0; i < Date.dayNames.length; i++) {
16353 var d = Date.dayNames[i];
16356 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16357 html : d.substring(0,3)
16361 ret[0].cls += ' fc-first';
16362 ret[6].cls += ' fc-last';
16365 var cal_cell = function(n) {
16368 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16373 cls: 'fc-day-number',
16377 cls: 'fc-day-content',
16381 style: 'position: relative;' // height: 17px;
16393 var cal_rows = function() {
16396 for (var r = 0; r < 6; r++) {
16403 for (var i =0; i < Date.dayNames.length; i++) {
16404 var d = Date.dayNames[i];
16405 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16408 row.cn[0].cls+=' fc-first';
16409 row.cn[0].cn[0].style = 'min-height:90px';
16410 row.cn[6].cls+=' fc-last';
16414 ret[0].cls += ' fc-first';
16415 ret[4].cls += ' fc-prev-last';
16416 ret[5].cls += ' fc-last';
16423 cls: 'fc-border-separate',
16424 style : 'width:100%',
16432 cls : 'fc-first fc-last',
16450 cls : 'fc-content',
16451 style : "position: relative;",
16454 cls : 'fc-view fc-view-month fc-grid',
16455 style : 'position: relative',
16456 unselectable : 'on',
16459 cls : 'fc-event-container',
16460 style : 'position:absolute;z-index:8;top:0;left:0;'
16478 initEvents : function()
16481 throw "can not find store for calendar";
16487 style: "text-align:center",
16491 style: "background-color:white;width:50%;margin:250 auto",
16495 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16506 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16508 var size = this.el.select('.fc-content', true).first().getSize();
16509 this.maskEl.setSize(size.width, size.height);
16510 this.maskEl.enableDisplayMode("block");
16511 if(!this.loadMask){
16512 this.maskEl.hide();
16515 this.store = Roo.factory(this.store, Roo.data);
16516 this.store.on('load', this.onLoad, this);
16517 this.store.on('beforeload', this.onBeforeLoad, this);
16521 this.cells = this.el.select('.fc-day',true);
16522 //Roo.log(this.cells);
16523 this.textNodes = this.el.query('.fc-day-number');
16524 this.cells.addClassOnOver('fc-state-hover');
16526 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16527 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16528 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16529 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16531 this.on('monthchange', this.onMonthChange, this);
16533 this.update(new Date().clearTime());
16536 resize : function() {
16537 var sz = this.el.getSize();
16539 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16540 this.el.select('.fc-day-content div',true).setHeight(34);
16545 showPrevMonth : function(e){
16546 this.update(this.activeDate.add("mo", -1));
16548 showToday : function(e){
16549 this.update(new Date().clearTime());
16552 showNextMonth : function(e){
16553 this.update(this.activeDate.add("mo", 1));
16557 showPrevYear : function(){
16558 this.update(this.activeDate.add("y", -1));
16562 showNextYear : function(){
16563 this.update(this.activeDate.add("y", 1));
16568 update : function(date)
16570 var vd = this.activeDate;
16571 this.activeDate = date;
16572 // if(vd && this.el){
16573 // var t = date.getTime();
16574 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16575 // Roo.log('using add remove');
16577 // this.fireEvent('monthchange', this, date);
16579 // this.cells.removeClass("fc-state-highlight");
16580 // this.cells.each(function(c){
16581 // if(c.dateValue == t){
16582 // c.addClass("fc-state-highlight");
16583 // setTimeout(function(){
16584 // try{c.dom.firstChild.focus();}catch(e){}
16594 var days = date.getDaysInMonth();
16596 var firstOfMonth = date.getFirstDateOfMonth();
16597 var startingPos = firstOfMonth.getDay()-this.startDay;
16599 if(startingPos < this.startDay){
16603 var pm = date.add(Date.MONTH, -1);
16604 var prevStart = pm.getDaysInMonth()-startingPos;
16606 this.cells = this.el.select('.fc-day',true);
16607 this.textNodes = this.el.query('.fc-day-number');
16608 this.cells.addClassOnOver('fc-state-hover');
16610 var cells = this.cells.elements;
16611 var textEls = this.textNodes;
16613 Roo.each(cells, function(cell){
16614 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16617 days += startingPos;
16619 // convert everything to numbers so it's fast
16620 var day = 86400000;
16621 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16624 //Roo.log(prevStart);
16626 var today = new Date().clearTime().getTime();
16627 var sel = date.clearTime().getTime();
16628 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16629 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16630 var ddMatch = this.disabledDatesRE;
16631 var ddText = this.disabledDatesText;
16632 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16633 var ddaysText = this.disabledDaysText;
16634 var format = this.format;
16636 var setCellClass = function(cal, cell){
16640 //Roo.log('set Cell Class');
16642 var t = d.getTime();
16646 cell.dateValue = t;
16648 cell.className += " fc-today";
16649 cell.className += " fc-state-highlight";
16650 cell.title = cal.todayText;
16653 // disable highlight in other month..
16654 //cell.className += " fc-state-highlight";
16659 cell.className = " fc-state-disabled";
16660 cell.title = cal.minText;
16664 cell.className = " fc-state-disabled";
16665 cell.title = cal.maxText;
16669 if(ddays.indexOf(d.getDay()) != -1){
16670 cell.title = ddaysText;
16671 cell.className = " fc-state-disabled";
16674 if(ddMatch && format){
16675 var fvalue = d.dateFormat(format);
16676 if(ddMatch.test(fvalue)){
16677 cell.title = ddText.replace("%0", fvalue);
16678 cell.className = " fc-state-disabled";
16682 if (!cell.initialClassName) {
16683 cell.initialClassName = cell.dom.className;
16686 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16691 for(; i < startingPos; i++) {
16692 textEls[i].innerHTML = (++prevStart);
16693 d.setDate(d.getDate()+1);
16695 cells[i].className = "fc-past fc-other-month";
16696 setCellClass(this, cells[i]);
16701 for(; i < days; i++){
16702 intDay = i - startingPos + 1;
16703 textEls[i].innerHTML = (intDay);
16704 d.setDate(d.getDate()+1);
16706 cells[i].className = ''; // "x-date-active";
16707 setCellClass(this, cells[i]);
16711 for(; i < 42; i++) {
16712 textEls[i].innerHTML = (++extraDays);
16713 d.setDate(d.getDate()+1);
16715 cells[i].className = "fc-future fc-other-month";
16716 setCellClass(this, cells[i]);
16719 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16721 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16723 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16724 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16726 if(totalRows != 6){
16727 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16728 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16731 this.fireEvent('monthchange', this, date);
16735 if(!this.internalRender){
16736 var main = this.el.dom.firstChild;
16737 var w = main.offsetWidth;
16738 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16739 Roo.fly(main).setWidth(w);
16740 this.internalRender = true;
16741 // opera does not respect the auto grow header center column
16742 // then, after it gets a width opera refuses to recalculate
16743 // without a second pass
16744 if(Roo.isOpera && !this.secondPass){
16745 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16746 this.secondPass = true;
16747 this.update.defer(10, this, [date]);
16754 findCell : function(dt) {
16755 dt = dt.clearTime().getTime();
16757 this.cells.each(function(c){
16758 //Roo.log("check " +c.dateValue + '?=' + dt);
16759 if(c.dateValue == dt){
16769 findCells : function(ev) {
16770 var s = ev.start.clone().clearTime().getTime();
16772 var e= ev.end.clone().clearTime().getTime();
16775 this.cells.each(function(c){
16776 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16778 if(c.dateValue > e){
16781 if(c.dateValue < s){
16790 // findBestRow: function(cells)
16794 // for (var i =0 ; i < cells.length;i++) {
16795 // ret = Math.max(cells[i].rows || 0,ret);
16802 addItem : function(ev)
16804 // look for vertical location slot in
16805 var cells = this.findCells(ev);
16807 // ev.row = this.findBestRow(cells);
16809 // work out the location.
16813 for(var i =0; i < cells.length; i++) {
16815 cells[i].row = cells[0].row;
16818 cells[i].row = cells[i].row + 1;
16828 if (crow.start.getY() == cells[i].getY()) {
16830 crow.end = cells[i];
16847 cells[0].events.push(ev);
16849 this.calevents.push(ev);
16852 clearEvents: function() {
16854 if(!this.calevents){
16858 Roo.each(this.cells.elements, function(c){
16864 Roo.each(this.calevents, function(e) {
16865 Roo.each(e.els, function(el) {
16866 el.un('mouseenter' ,this.onEventEnter, this);
16867 el.un('mouseleave' ,this.onEventLeave, this);
16872 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16878 renderEvents: function()
16882 this.cells.each(function(c) {
16891 if(c.row != c.events.length){
16892 r = 4 - (4 - (c.row - c.events.length));
16895 c.events = ev.slice(0, r);
16896 c.more = ev.slice(r);
16898 if(c.more.length && c.more.length == 1){
16899 c.events.push(c.more.pop());
16902 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16906 this.cells.each(function(c) {
16908 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16911 for (var e = 0; e < c.events.length; e++){
16912 var ev = c.events[e];
16913 var rows = ev.rows;
16915 for(var i = 0; i < rows.length; i++) {
16917 // how many rows should it span..
16920 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16921 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16923 unselectable : "on",
16926 cls: 'fc-event-inner',
16930 // cls: 'fc-event-time',
16931 // html : cells.length > 1 ? '' : ev.time
16935 cls: 'fc-event-title',
16936 html : String.format('{0}', ev.title)
16943 cls: 'ui-resizable-handle ui-resizable-e',
16944 html : '  '
16951 cfg.cls += ' fc-event-start';
16953 if ((i+1) == rows.length) {
16954 cfg.cls += ' fc-event-end';
16957 var ctr = _this.el.select('.fc-event-container',true).first();
16958 var cg = ctr.createChild(cfg);
16960 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
16961 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
16963 var r = (c.more.length) ? 1 : 0;
16964 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
16965 cg.setWidth(ebox.right - sbox.x -2);
16967 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
16968 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
16969 cg.on('click', _this.onEventClick, _this, ev);
16980 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
16981 style : 'position: absolute',
16982 unselectable : "on",
16985 cls: 'fc-event-inner',
16989 cls: 'fc-event-title',
16997 cls: 'ui-resizable-handle ui-resizable-e',
16998 html : '  '
17004 var ctr = _this.el.select('.fc-event-container',true).first();
17005 var cg = ctr.createChild(cfg);
17007 var sbox = c.select('.fc-day-content',true).first().getBox();
17008 var ebox = c.select('.fc-day-content',true).first().getBox();
17010 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17011 cg.setWidth(ebox.right - sbox.x -2);
17013 cg.on('click', _this.onMoreEventClick, _this, c.more);
17023 onEventEnter: function (e, el,event,d) {
17024 this.fireEvent('evententer', this, el, event);
17027 onEventLeave: function (e, el,event,d) {
17028 this.fireEvent('eventleave', this, el, event);
17031 onEventClick: function (e, el,event,d) {
17032 this.fireEvent('eventclick', this, el, event);
17035 onMonthChange: function () {
17039 onMoreEventClick: function(e, el, more)
17043 this.calpopover.placement = 'right';
17044 this.calpopover.setTitle('More');
17046 this.calpopover.setContent('');
17048 var ctr = this.calpopover.el.select('.popover-content', true).first();
17050 Roo.each(more, function(m){
17052 cls : 'fc-event-hori fc-event-draggable',
17055 var cg = ctr.createChild(cfg);
17057 cg.on('click', _this.onEventClick, _this, m);
17060 this.calpopover.show(el);
17065 onLoad: function ()
17067 this.calevents = [];
17070 if(this.store.getCount() > 0){
17071 this.store.data.each(function(d){
17074 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17075 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17076 time : d.data.start_time,
17077 title : d.data.title,
17078 description : d.data.description,
17079 venue : d.data.venue
17084 this.renderEvents();
17086 if(this.calevents.length && this.loadMask){
17087 this.maskEl.hide();
17091 onBeforeLoad: function()
17093 this.clearEvents();
17095 this.maskEl.show();
17109 * @class Roo.bootstrap.Popover
17110 * @extends Roo.bootstrap.Component
17111 * Bootstrap Popover class
17112 * @cfg {String} html contents of the popover (or false to use children..)
17113 * @cfg {String} title of popover (or false to hide)
17114 * @cfg {String} placement how it is placed
17115 * @cfg {String} trigger click || hover (or false to trigger manually)
17116 * @cfg {String} over what (parent or false to trigger manually.)
17117 * @cfg {Number} delay - delay before showing
17120 * Create a new Popover
17121 * @param {Object} config The config object
17124 Roo.bootstrap.Popover = function(config){
17125 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17131 * After the popover show
17133 * @param {Roo.bootstrap.Popover} this
17138 * After the popover hide
17140 * @param {Roo.bootstrap.Popover} this
17146 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17148 title: 'Fill in a title',
17151 placement : 'right',
17152 trigger : 'hover', // hover
17158 can_build_overlaid : false,
17160 getChildContainer : function()
17162 return this.el.select('.popover-content',true).first();
17165 getAutoCreate : function(){
17168 cls : 'popover roo-dynamic',
17169 style: 'display:block',
17175 cls : 'popover-inner',
17179 cls: 'popover-title',
17183 cls : 'popover-content',
17194 setTitle: function(str)
17197 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17199 setContent: function(str)
17202 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17204 // as it get's added to the bottom of the page.
17205 onRender : function(ct, position)
17207 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17209 var cfg = Roo.apply({}, this.getAutoCreate());
17213 cfg.cls += ' ' + this.cls;
17216 cfg.style = this.style;
17218 //Roo.log("adding to ");
17219 this.el = Roo.get(document.body).createChild(cfg, position);
17220 // Roo.log(this.el);
17225 initEvents : function()
17227 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17228 this.el.enableDisplayMode('block');
17230 if (this.over === false) {
17233 if (this.triggers === false) {
17236 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17237 var triggers = this.trigger ? this.trigger.split(' ') : [];
17238 Roo.each(triggers, function(trigger) {
17240 if (trigger == 'click') {
17241 on_el.on('click', this.toggle, this);
17242 } else if (trigger != 'manual') {
17243 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17244 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17246 on_el.on(eventIn ,this.enter, this);
17247 on_el.on(eventOut, this.leave, this);
17258 toggle : function () {
17259 this.hoverState == 'in' ? this.leave() : this.enter();
17262 enter : function () {
17264 clearTimeout(this.timeout);
17266 this.hoverState = 'in';
17268 if (!this.delay || !this.delay.show) {
17273 this.timeout = setTimeout(function () {
17274 if (_t.hoverState == 'in') {
17277 }, this.delay.show)
17280 leave : function() {
17281 clearTimeout(this.timeout);
17283 this.hoverState = 'out';
17285 if (!this.delay || !this.delay.hide) {
17290 this.timeout = setTimeout(function () {
17291 if (_t.hoverState == 'out') {
17294 }, this.delay.hide)
17297 show : function (on_el)
17300 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17304 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17305 if (this.html !== false) {
17306 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17308 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17309 if (!this.title.length) {
17310 this.el.select('.popover-title',true).hide();
17313 var placement = typeof this.placement == 'function' ?
17314 this.placement.call(this, this.el, on_el) :
17317 var autoToken = /\s?auto?\s?/i;
17318 var autoPlace = autoToken.test(placement);
17320 placement = placement.replace(autoToken, '') || 'top';
17324 //this.el.setXY([0,0]);
17326 this.el.dom.style.display='block';
17327 this.el.addClass(placement);
17329 //this.el.appendTo(on_el);
17331 var p = this.getPosition();
17332 var box = this.el.getBox();
17337 var align = Roo.bootstrap.Popover.alignment[placement];
17340 this.el.alignTo(on_el, align[0],align[1]);
17341 //var arrow = this.el.select('.arrow',true).first();
17342 //arrow.set(align[2],
17344 this.el.addClass('in');
17347 if (this.el.hasClass('fade')) {
17351 this.hoverState = 'in';
17353 this.fireEvent('show', this);
17358 this.el.setXY([0,0]);
17359 this.el.removeClass('in');
17361 this.hoverState = null;
17363 this.fireEvent('hide', this);
17368 Roo.bootstrap.Popover.alignment = {
17369 'left' : ['r-l', [-10,0], 'right'],
17370 'right' : ['l-r', [10,0], 'left'],
17371 'bottom' : ['t-b', [0,10], 'top'],
17372 'top' : [ 'b-t', [0,-10], 'bottom']
17383 * @class Roo.bootstrap.Progress
17384 * @extends Roo.bootstrap.Component
17385 * Bootstrap Progress class
17386 * @cfg {Boolean} striped striped of the progress bar
17387 * @cfg {Boolean} active animated of the progress bar
17391 * Create a new Progress
17392 * @param {Object} config The config object
17395 Roo.bootstrap.Progress = function(config){
17396 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17399 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17404 getAutoCreate : function(){
17412 cfg.cls += ' progress-striped';
17416 cfg.cls += ' active';
17435 * @class Roo.bootstrap.ProgressBar
17436 * @extends Roo.bootstrap.Component
17437 * Bootstrap ProgressBar class
17438 * @cfg {Number} aria_valuenow aria-value now
17439 * @cfg {Number} aria_valuemin aria-value min
17440 * @cfg {Number} aria_valuemax aria-value max
17441 * @cfg {String} label label for the progress bar
17442 * @cfg {String} panel (success | info | warning | danger )
17443 * @cfg {String} role role of the progress bar
17444 * @cfg {String} sr_only text
17448 * Create a new ProgressBar
17449 * @param {Object} config The config object
17452 Roo.bootstrap.ProgressBar = function(config){
17453 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17456 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17460 aria_valuemax : 100,
17466 getAutoCreate : function()
17471 cls: 'progress-bar',
17472 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17484 cfg.role = this.role;
17487 if(this.aria_valuenow){
17488 cfg['aria-valuenow'] = this.aria_valuenow;
17491 if(this.aria_valuemin){
17492 cfg['aria-valuemin'] = this.aria_valuemin;
17495 if(this.aria_valuemax){
17496 cfg['aria-valuemax'] = this.aria_valuemax;
17499 if(this.label && !this.sr_only){
17500 cfg.html = this.label;
17504 cfg.cls += ' progress-bar-' + this.panel;
17510 update : function(aria_valuenow)
17512 this.aria_valuenow = aria_valuenow;
17514 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17529 * @class Roo.bootstrap.TabGroup
17530 * @extends Roo.bootstrap.Column
17531 * Bootstrap Column class
17532 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17533 * @cfg {Boolean} carousel true to make the group behave like a carousel
17534 * @cfg {Boolean} bullets show bullets for the panels
17535 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17536 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17537 * @cfg {Boolean} showarrow (true|false) show arrow default true
17540 * Create a new TabGroup
17541 * @param {Object} config The config object
17544 Roo.bootstrap.TabGroup = function(config){
17545 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17547 this.navId = Roo.id();
17550 Roo.bootstrap.TabGroup.register(this);
17554 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17557 transition : false,
17562 slideOnTouch : false,
17565 getAutoCreate : function()
17567 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17569 cfg.cls += ' tab-content';
17571 if (this.carousel) {
17572 cfg.cls += ' carousel slide';
17575 cls : 'carousel-inner',
17579 if(this.bullets && !Roo.isTouch){
17582 cls : 'carousel-bullets',
17586 if(this.bullets_cls){
17587 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17594 cfg.cn[0].cn.push(bullets);
17597 if(this.showarrow){
17598 cfg.cn[0].cn.push({
17600 class : 'carousel-arrow',
17604 class : 'carousel-prev',
17608 class : 'fa fa-chevron-left'
17614 class : 'carousel-next',
17618 class : 'fa fa-chevron-right'
17631 initEvents: function()
17633 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17634 // this.el.on("touchstart", this.onTouchStart, this);
17637 if(this.autoslide){
17640 this.slideFn = window.setInterval(function() {
17641 _this.showPanelNext();
17645 if(this.showarrow){
17646 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17647 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17653 // onTouchStart : function(e, el, o)
17655 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17659 // this.showPanelNext();
17663 getChildContainer : function()
17665 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17669 * register a Navigation item
17670 * @param {Roo.bootstrap.NavItem} the navitem to add
17672 register : function(item)
17674 this.tabs.push( item);
17675 item.navId = this.navId; // not really needed..
17680 getActivePanel : function()
17683 Roo.each(this.tabs, function(t) {
17693 getPanelByName : function(n)
17696 Roo.each(this.tabs, function(t) {
17697 if (t.tabId == n) {
17705 indexOfPanel : function(p)
17708 Roo.each(this.tabs, function(t,i) {
17709 if (t.tabId == p.tabId) {
17718 * show a specific panel
17719 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17720 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17722 showPanel : function (pan)
17724 if(this.transition || typeof(pan) == 'undefined'){
17725 Roo.log("waiting for the transitionend");
17729 if (typeof(pan) == 'number') {
17730 pan = this.tabs[pan];
17733 if (typeof(pan) == 'string') {
17734 pan = this.getPanelByName(pan);
17737 var cur = this.getActivePanel();
17740 Roo.log('pan or acitve pan is undefined');
17744 if (pan.tabId == this.getActivePanel().tabId) {
17748 if (false === cur.fireEvent('beforedeactivate')) {
17752 if(this.bullets > 0 && !Roo.isTouch){
17753 this.setActiveBullet(this.indexOfPanel(pan));
17756 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17758 this.transition = true;
17759 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17760 var lr = dir == 'next' ? 'left' : 'right';
17761 pan.el.addClass(dir); // or prev
17762 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17763 cur.el.addClass(lr); // or right
17764 pan.el.addClass(lr);
17767 cur.el.on('transitionend', function() {
17768 Roo.log("trans end?");
17770 pan.el.removeClass([lr,dir]);
17771 pan.setActive(true);
17773 cur.el.removeClass([lr]);
17774 cur.setActive(false);
17776 _this.transition = false;
17778 }, this, { single: true } );
17783 cur.setActive(false);
17784 pan.setActive(true);
17789 showPanelNext : function()
17791 var i = this.indexOfPanel(this.getActivePanel());
17793 if (i >= this.tabs.length - 1 && !this.autoslide) {
17797 if (i >= this.tabs.length - 1 && this.autoslide) {
17801 this.showPanel(this.tabs[i+1]);
17804 showPanelPrev : function()
17806 var i = this.indexOfPanel(this.getActivePanel());
17808 if (i < 1 && !this.autoslide) {
17812 if (i < 1 && this.autoslide) {
17813 i = this.tabs.length;
17816 this.showPanel(this.tabs[i-1]);
17820 addBullet: function()
17822 if(!this.bullets || Roo.isTouch){
17825 var ctr = this.el.select('.carousel-bullets',true).first();
17826 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17827 var bullet = ctr.createChild({
17828 cls : 'bullet bullet-' + i
17829 },ctr.dom.lastChild);
17834 bullet.on('click', (function(e, el, o, ii, t){
17836 e.preventDefault();
17838 this.showPanel(ii);
17840 if(this.autoslide && this.slideFn){
17841 clearInterval(this.slideFn);
17842 this.slideFn = window.setInterval(function() {
17843 _this.showPanelNext();
17847 }).createDelegate(this, [i, bullet], true));
17852 setActiveBullet : function(i)
17858 Roo.each(this.el.select('.bullet', true).elements, function(el){
17859 el.removeClass('selected');
17862 var bullet = this.el.select('.bullet-' + i, true).first();
17868 bullet.addClass('selected');
17879 Roo.apply(Roo.bootstrap.TabGroup, {
17883 * register a Navigation Group
17884 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17886 register : function(navgrp)
17888 this.groups[navgrp.navId] = navgrp;
17892 * fetch a Navigation Group based on the navigation ID
17893 * if one does not exist , it will get created.
17894 * @param {string} the navgroup to add
17895 * @returns {Roo.bootstrap.NavGroup} the navgroup
17897 get: function(navId) {
17898 if (typeof(this.groups[navId]) == 'undefined') {
17899 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17901 return this.groups[navId] ;
17916 * @class Roo.bootstrap.TabPanel
17917 * @extends Roo.bootstrap.Component
17918 * Bootstrap TabPanel class
17919 * @cfg {Boolean} active panel active
17920 * @cfg {String} html panel content
17921 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17922 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17923 * @cfg {String} href click to link..
17927 * Create a new TabPanel
17928 * @param {Object} config The config object
17931 Roo.bootstrap.TabPanel = function(config){
17932 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17936 * Fires when the active status changes
17937 * @param {Roo.bootstrap.TabPanel} this
17938 * @param {Boolean} state the new state
17943 * @event beforedeactivate
17944 * Fires before a tab is de-activated - can be used to do validation on a form.
17945 * @param {Roo.bootstrap.TabPanel} this
17946 * @return {Boolean} false if there is an error
17949 'beforedeactivate': true
17952 this.tabId = this.tabId || Roo.id();
17956 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
17964 getAutoCreate : function(){
17967 // item is needed for carousel - not sure if it has any effect otherwise
17968 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
17969 html: this.html || ''
17973 cfg.cls += ' active';
17977 cfg.tabId = this.tabId;
17984 initEvents: function()
17986 var p = this.parent();
17988 this.navId = this.navId || p.navId;
17990 if (typeof(this.navId) != 'undefined') {
17991 // not really needed.. but just in case.. parent should be a NavGroup.
17992 var tg = Roo.bootstrap.TabGroup.get(this.navId);
17996 var i = tg.tabs.length - 1;
17998 if(this.active && tg.bullets > 0 && i < tg.bullets){
17999 tg.setActiveBullet(i);
18003 this.el.on('click', this.onClick, this);
18006 this.el.on("touchstart", this.onTouchStart, this);
18007 this.el.on("touchmove", this.onTouchMove, this);
18008 this.el.on("touchend", this.onTouchEnd, this);
18013 onRender : function(ct, position)
18015 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18018 setActive : function(state)
18020 Roo.log("panel - set active " + this.tabId + "=" + state);
18022 this.active = state;
18024 this.el.removeClass('active');
18026 } else if (!this.el.hasClass('active')) {
18027 this.el.addClass('active');
18030 this.fireEvent('changed', this, state);
18033 onClick : function(e)
18035 e.preventDefault();
18037 if(!this.href.length){
18041 window.location.href = this.href;
18050 onTouchStart : function(e)
18052 this.swiping = false;
18054 this.startX = e.browserEvent.touches[0].clientX;
18055 this.startY = e.browserEvent.touches[0].clientY;
18058 onTouchMove : function(e)
18060 this.swiping = true;
18062 this.endX = e.browserEvent.touches[0].clientX;
18063 this.endY = e.browserEvent.touches[0].clientY;
18066 onTouchEnd : function(e)
18073 var tabGroup = this.parent();
18075 if(this.endX > this.startX){ // swiping right
18076 tabGroup.showPanelPrev();
18080 if(this.startX > this.endX){ // swiping left
18081 tabGroup.showPanelNext();
18100 * @class Roo.bootstrap.DateField
18101 * @extends Roo.bootstrap.Input
18102 * Bootstrap DateField class
18103 * @cfg {Number} weekStart default 0
18104 * @cfg {String} viewMode default empty, (months|years)
18105 * @cfg {String} minViewMode default empty, (months|years)
18106 * @cfg {Number} startDate default -Infinity
18107 * @cfg {Number} endDate default Infinity
18108 * @cfg {Boolean} todayHighlight default false
18109 * @cfg {Boolean} todayBtn default false
18110 * @cfg {Boolean} calendarWeeks default false
18111 * @cfg {Object} daysOfWeekDisabled default empty
18112 * @cfg {Boolean} singleMode default false (true | false)
18114 * @cfg {Boolean} keyboardNavigation default true
18115 * @cfg {String} language default en
18118 * Create a new DateField
18119 * @param {Object} config The config object
18122 Roo.bootstrap.DateField = function(config){
18123 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18127 * Fires when this field show.
18128 * @param {Roo.bootstrap.DateField} this
18129 * @param {Mixed} date The date value
18134 * Fires when this field hide.
18135 * @param {Roo.bootstrap.DateField} this
18136 * @param {Mixed} date The date value
18141 * Fires when select a date.
18142 * @param {Roo.bootstrap.DateField} this
18143 * @param {Mixed} date The date value
18147 * @event beforeselect
18148 * Fires when before select a date.
18149 * @param {Roo.bootstrap.DateField} this
18150 * @param {Mixed} date The date value
18152 beforeselect : true
18156 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18159 * @cfg {String} format
18160 * The default date format string which can be overriden for localization support. The format must be
18161 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18165 * @cfg {String} altFormats
18166 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18167 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18169 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18177 todayHighlight : false,
18183 keyboardNavigation: true,
18185 calendarWeeks: false,
18187 startDate: -Infinity,
18191 daysOfWeekDisabled: [],
18195 singleMode : false,
18197 UTCDate: function()
18199 return new Date(Date.UTC.apply(Date, arguments));
18202 UTCToday: function()
18204 var today = new Date();
18205 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18208 getDate: function() {
18209 var d = this.getUTCDate();
18210 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18213 getUTCDate: function() {
18217 setDate: function(d) {
18218 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18221 setUTCDate: function(d) {
18223 this.setValue(this.formatDate(this.date));
18226 onRender: function(ct, position)
18229 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18231 this.language = this.language || 'en';
18232 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18233 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18235 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18236 this.format = this.format || 'm/d/y';
18237 this.isInline = false;
18238 this.isInput = true;
18239 this.component = this.el.select('.add-on', true).first() || false;
18240 this.component = (this.component && this.component.length === 0) ? false : this.component;
18241 this.hasInput = this.component && this.inputEl().length;
18243 if (typeof(this.minViewMode === 'string')) {
18244 switch (this.minViewMode) {
18246 this.minViewMode = 1;
18249 this.minViewMode = 2;
18252 this.minViewMode = 0;
18257 if (typeof(this.viewMode === 'string')) {
18258 switch (this.viewMode) {
18271 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18273 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18275 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18277 this.picker().on('mousedown', this.onMousedown, this);
18278 this.picker().on('click', this.onClick, this);
18280 this.picker().addClass('datepicker-dropdown');
18282 this.startViewMode = this.viewMode;
18284 if(this.singleMode){
18285 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18286 v.setVisibilityMode(Roo.Element.DISPLAY);
18290 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18291 v.setStyle('width', '189px');
18295 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18296 if(!this.calendarWeeks){
18301 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18302 v.attr('colspan', function(i, val){
18303 return parseInt(val) + 1;
18308 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18310 this.setStartDate(this.startDate);
18311 this.setEndDate(this.endDate);
18313 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18320 if(this.isInline) {
18325 picker : function()
18327 return this.pickerEl;
18328 // return this.el.select('.datepicker', true).first();
18331 fillDow: function()
18333 var dowCnt = this.weekStart;
18342 if(this.calendarWeeks){
18350 while (dowCnt < this.weekStart + 7) {
18354 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18358 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18361 fillMonths: function()
18364 var months = this.picker().select('>.datepicker-months td', true).first();
18366 months.dom.innerHTML = '';
18372 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18375 months.createChild(month);
18382 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;
18384 if (this.date < this.startDate) {
18385 this.viewDate = new Date(this.startDate);
18386 } else if (this.date > this.endDate) {
18387 this.viewDate = new Date(this.endDate);
18389 this.viewDate = new Date(this.date);
18397 var d = new Date(this.viewDate),
18398 year = d.getUTCFullYear(),
18399 month = d.getUTCMonth(),
18400 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18401 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18402 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18403 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18404 currentDate = this.date && this.date.valueOf(),
18405 today = this.UTCToday();
18407 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18409 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18411 // this.picker.select('>tfoot th.today').
18412 // .text(dates[this.language].today)
18413 // .toggle(this.todayBtn !== false);
18415 this.updateNavArrows();
18418 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18420 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18422 prevMonth.setUTCDate(day);
18424 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18426 var nextMonth = new Date(prevMonth);
18428 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18430 nextMonth = nextMonth.valueOf();
18432 var fillMonths = false;
18434 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18436 while(prevMonth.valueOf() < nextMonth) {
18439 if (prevMonth.getUTCDay() === this.weekStart) {
18441 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18449 if(this.calendarWeeks){
18450 // ISO 8601: First week contains first thursday.
18451 // ISO also states week starts on Monday, but we can be more abstract here.
18453 // Start of current week: based on weekstart/current date
18454 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18455 // Thursday of this week
18456 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18457 // First Thursday of year, year from thursday
18458 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18459 // Calendar week: ms between thursdays, div ms per day, div 7 days
18460 calWeek = (th - yth) / 864e5 / 7 + 1;
18462 fillMonths.cn.push({
18470 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18472 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18475 if (this.todayHighlight &&
18476 prevMonth.getUTCFullYear() == today.getFullYear() &&
18477 prevMonth.getUTCMonth() == today.getMonth() &&
18478 prevMonth.getUTCDate() == today.getDate()) {
18479 clsName += ' today';
18482 if (currentDate && prevMonth.valueOf() === currentDate) {
18483 clsName += ' active';
18486 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18487 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18488 clsName += ' disabled';
18491 fillMonths.cn.push({
18493 cls: 'day ' + clsName,
18494 html: prevMonth.getDate()
18497 prevMonth.setDate(prevMonth.getDate()+1);
18500 var currentYear = this.date && this.date.getUTCFullYear();
18501 var currentMonth = this.date && this.date.getUTCMonth();
18503 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18505 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18506 v.removeClass('active');
18508 if(currentYear === year && k === currentMonth){
18509 v.addClass('active');
18512 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18513 v.addClass('disabled');
18519 year = parseInt(year/10, 10) * 10;
18521 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18523 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18526 for (var i = -1; i < 11; i++) {
18527 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18529 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18537 showMode: function(dir)
18540 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18543 Roo.each(this.picker().select('>div',true).elements, function(v){
18544 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18547 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18552 if(this.isInline) {
18556 this.picker().removeClass(['bottom', 'top']);
18558 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18560 * place to the top of element!
18564 this.picker().addClass('top');
18565 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18570 this.picker().addClass('bottom');
18572 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18575 parseDate : function(value)
18577 if(!value || value instanceof Date){
18580 var v = Date.parseDate(value, this.format);
18581 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18582 v = Date.parseDate(value, 'Y-m-d');
18584 if(!v && this.altFormats){
18585 if(!this.altFormatsArray){
18586 this.altFormatsArray = this.altFormats.split("|");
18588 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18589 v = Date.parseDate(value, this.altFormatsArray[i]);
18595 formatDate : function(date, fmt)
18597 return (!date || !(date instanceof Date)) ?
18598 date : date.dateFormat(fmt || this.format);
18601 onFocus : function()
18603 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18607 onBlur : function()
18609 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18611 var d = this.inputEl().getValue();
18620 this.picker().show();
18624 this.fireEvent('show', this, this.date);
18629 if(this.isInline) {
18632 this.picker().hide();
18633 this.viewMode = this.startViewMode;
18636 this.fireEvent('hide', this, this.date);
18640 onMousedown: function(e)
18642 e.stopPropagation();
18643 e.preventDefault();
18648 Roo.bootstrap.DateField.superclass.keyup.call(this);
18652 setValue: function(v)
18654 if(this.fireEvent('beforeselect', this, v) !== false){
18655 var d = new Date(this.parseDate(v) ).clearTime();
18657 if(isNaN(d.getTime())){
18658 this.date = this.viewDate = '';
18659 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18663 v = this.formatDate(d);
18665 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18667 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18671 this.fireEvent('select', this, this.date);
18675 getValue: function()
18677 return this.formatDate(this.date);
18680 fireKey: function(e)
18682 if (!this.picker().isVisible()){
18683 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18689 var dateChanged = false,
18691 newDate, newViewDate;
18696 e.preventDefault();
18700 if (!this.keyboardNavigation) {
18703 dir = e.keyCode == 37 ? -1 : 1;
18706 newDate = this.moveYear(this.date, dir);
18707 newViewDate = this.moveYear(this.viewDate, dir);
18708 } else if (e.shiftKey){
18709 newDate = this.moveMonth(this.date, dir);
18710 newViewDate = this.moveMonth(this.viewDate, dir);
18712 newDate = new Date(this.date);
18713 newDate.setUTCDate(this.date.getUTCDate() + dir);
18714 newViewDate = new Date(this.viewDate);
18715 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18717 if (this.dateWithinRange(newDate)){
18718 this.date = newDate;
18719 this.viewDate = newViewDate;
18720 this.setValue(this.formatDate(this.date));
18722 e.preventDefault();
18723 dateChanged = true;
18728 if (!this.keyboardNavigation) {
18731 dir = e.keyCode == 38 ? -1 : 1;
18733 newDate = this.moveYear(this.date, dir);
18734 newViewDate = this.moveYear(this.viewDate, dir);
18735 } else if (e.shiftKey){
18736 newDate = this.moveMonth(this.date, dir);
18737 newViewDate = this.moveMonth(this.viewDate, dir);
18739 newDate = new Date(this.date);
18740 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18741 newViewDate = new Date(this.viewDate);
18742 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18744 if (this.dateWithinRange(newDate)){
18745 this.date = newDate;
18746 this.viewDate = newViewDate;
18747 this.setValue(this.formatDate(this.date));
18749 e.preventDefault();
18750 dateChanged = true;
18754 this.setValue(this.formatDate(this.date));
18756 e.preventDefault();
18759 this.setValue(this.formatDate(this.date));
18773 onClick: function(e)
18775 e.stopPropagation();
18776 e.preventDefault();
18778 var target = e.getTarget();
18780 if(target.nodeName.toLowerCase() === 'i'){
18781 target = Roo.get(target).dom.parentNode;
18784 var nodeName = target.nodeName;
18785 var className = target.className;
18786 var html = target.innerHTML;
18787 //Roo.log(nodeName);
18789 switch(nodeName.toLowerCase()) {
18791 switch(className) {
18797 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18798 switch(this.viewMode){
18800 this.viewDate = this.moveMonth(this.viewDate, dir);
18804 this.viewDate = this.moveYear(this.viewDate, dir);
18810 var date = new Date();
18811 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18813 this.setValue(this.formatDate(this.date));
18820 if (className.indexOf('disabled') < 0) {
18821 this.viewDate.setUTCDate(1);
18822 if (className.indexOf('month') > -1) {
18823 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18825 var year = parseInt(html, 10) || 0;
18826 this.viewDate.setUTCFullYear(year);
18830 if(this.singleMode){
18831 this.setValue(this.formatDate(this.viewDate));
18842 //Roo.log(className);
18843 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18844 var day = parseInt(html, 10) || 1;
18845 var year = this.viewDate.getUTCFullYear(),
18846 month = this.viewDate.getUTCMonth();
18848 if (className.indexOf('old') > -1) {
18855 } else if (className.indexOf('new') > -1) {
18863 //Roo.log([year,month,day]);
18864 this.date = this.UTCDate(year, month, day,0,0,0,0);
18865 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18867 //Roo.log(this.formatDate(this.date));
18868 this.setValue(this.formatDate(this.date));
18875 setStartDate: function(startDate)
18877 this.startDate = startDate || -Infinity;
18878 if (this.startDate !== -Infinity) {
18879 this.startDate = this.parseDate(this.startDate);
18882 this.updateNavArrows();
18885 setEndDate: function(endDate)
18887 this.endDate = endDate || Infinity;
18888 if (this.endDate !== Infinity) {
18889 this.endDate = this.parseDate(this.endDate);
18892 this.updateNavArrows();
18895 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18897 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18898 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18899 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18901 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18902 return parseInt(d, 10);
18905 this.updateNavArrows();
18908 updateNavArrows: function()
18910 if(this.singleMode){
18914 var d = new Date(this.viewDate),
18915 year = d.getUTCFullYear(),
18916 month = d.getUTCMonth();
18918 Roo.each(this.picker().select('.prev', true).elements, function(v){
18920 switch (this.viewMode) {
18923 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18929 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18936 Roo.each(this.picker().select('.next', true).elements, function(v){
18938 switch (this.viewMode) {
18941 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
18947 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
18955 moveMonth: function(date, dir)
18960 var new_date = new Date(date.valueOf()),
18961 day = new_date.getUTCDate(),
18962 month = new_date.getUTCMonth(),
18963 mag = Math.abs(dir),
18965 dir = dir > 0 ? 1 : -1;
18968 // If going back one month, make sure month is not current month
18969 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
18971 return new_date.getUTCMonth() == month;
18973 // If going forward one month, make sure month is as expected
18974 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
18976 return new_date.getUTCMonth() != new_month;
18978 new_month = month + dir;
18979 new_date.setUTCMonth(new_month);
18980 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
18981 if (new_month < 0 || new_month > 11) {
18982 new_month = (new_month + 12) % 12;
18985 // For magnitudes >1, move one month at a time...
18986 for (var i=0; i<mag; i++) {
18987 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
18988 new_date = this.moveMonth(new_date, dir);
18990 // ...then reset the day, keeping it in the new month
18991 new_month = new_date.getUTCMonth();
18992 new_date.setUTCDate(day);
18994 return new_month != new_date.getUTCMonth();
18997 // Common date-resetting loop -- if date is beyond end of month, make it
19000 new_date.setUTCDate(--day);
19001 new_date.setUTCMonth(new_month);
19006 moveYear: function(date, dir)
19008 return this.moveMonth(date, dir*12);
19011 dateWithinRange: function(date)
19013 return date >= this.startDate && date <= this.endDate;
19019 this.picker().remove();
19022 validateValue : function(value)
19024 if(value.length < 1) {
19025 if(this.allowBlank){
19031 if(value.length < this.minLength){
19034 if(value.length > this.maxLength){
19038 var vt = Roo.form.VTypes;
19039 if(!vt[this.vtype](value, this)){
19043 if(typeof this.validator == "function"){
19044 var msg = this.validator(value);
19050 if(this.regex && !this.regex.test(value)){
19054 if(typeof(this.parseDate(value)) == 'undefined'){
19058 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19062 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19072 Roo.apply(Roo.bootstrap.DateField, {
19083 html: '<i class="fa fa-arrow-left"/>'
19093 html: '<i class="fa fa-arrow-right"/>'
19135 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19136 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19137 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19138 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19139 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19152 navFnc: 'FullYear',
19157 navFnc: 'FullYear',
19162 Roo.apply(Roo.bootstrap.DateField, {
19166 cls: 'datepicker dropdown-menu roo-dynamic',
19170 cls: 'datepicker-days',
19174 cls: 'table-condensed',
19176 Roo.bootstrap.DateField.head,
19180 Roo.bootstrap.DateField.footer
19187 cls: 'datepicker-months',
19191 cls: 'table-condensed',
19193 Roo.bootstrap.DateField.head,
19194 Roo.bootstrap.DateField.content,
19195 Roo.bootstrap.DateField.footer
19202 cls: 'datepicker-years',
19206 cls: 'table-condensed',
19208 Roo.bootstrap.DateField.head,
19209 Roo.bootstrap.DateField.content,
19210 Roo.bootstrap.DateField.footer
19229 * @class Roo.bootstrap.TimeField
19230 * @extends Roo.bootstrap.Input
19231 * Bootstrap DateField class
19235 * Create a new TimeField
19236 * @param {Object} config The config object
19239 Roo.bootstrap.TimeField = function(config){
19240 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19244 * Fires when this field show.
19245 * @param {Roo.bootstrap.DateField} thisthis
19246 * @param {Mixed} date The date value
19251 * Fires when this field hide.
19252 * @param {Roo.bootstrap.DateField} this
19253 * @param {Mixed} date The date value
19258 * Fires when select a date.
19259 * @param {Roo.bootstrap.DateField} this
19260 * @param {Mixed} date The date value
19266 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19269 * @cfg {String} format
19270 * The default time format string which can be overriden for localization support. The format must be
19271 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19275 onRender: function(ct, position)
19278 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19280 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19282 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19284 this.pop = this.picker().select('>.datepicker-time',true).first();
19285 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19287 this.picker().on('mousedown', this.onMousedown, this);
19288 this.picker().on('click', this.onClick, this);
19290 this.picker().addClass('datepicker-dropdown');
19295 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19296 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19297 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19298 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19299 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19300 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19304 fireKey: function(e){
19305 if (!this.picker().isVisible()){
19306 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19312 e.preventDefault();
19320 this.onTogglePeriod();
19323 this.onIncrementMinutes();
19326 this.onDecrementMinutes();
19335 onClick: function(e) {
19336 e.stopPropagation();
19337 e.preventDefault();
19340 picker : function()
19342 return this.el.select('.datepicker', true).first();
19345 fillTime: function()
19347 var time = this.pop.select('tbody', true).first();
19349 time.dom.innerHTML = '';
19364 cls: 'hours-up glyphicon glyphicon-chevron-up'
19384 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19405 cls: 'timepicker-hour',
19420 cls: 'timepicker-minute',
19435 cls: 'btn btn-primary period',
19457 cls: 'hours-down glyphicon glyphicon-chevron-down'
19477 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19495 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19502 var hours = this.time.getHours();
19503 var minutes = this.time.getMinutes();
19516 hours = hours - 12;
19520 hours = '0' + hours;
19524 minutes = '0' + minutes;
19527 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19528 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19529 this.pop.select('button', true).first().dom.innerHTML = period;
19535 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19537 var cls = ['bottom'];
19539 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19546 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19551 this.picker().addClass(cls.join('-'));
19555 Roo.each(cls, function(c){
19557 _this.picker().setTop(_this.inputEl().getHeight());
19561 _this.picker().setTop(0 - _this.picker().getHeight());
19566 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19570 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19577 onFocus : function()
19579 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19583 onBlur : function()
19585 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19591 this.picker().show();
19596 this.fireEvent('show', this, this.date);
19601 this.picker().hide();
19604 this.fireEvent('hide', this, this.date);
19607 setTime : function()
19610 this.setValue(this.time.format(this.format));
19612 this.fireEvent('select', this, this.date);
19617 onMousedown: function(e){
19618 e.stopPropagation();
19619 e.preventDefault();
19622 onIncrementHours: function()
19624 Roo.log('onIncrementHours');
19625 this.time = this.time.add(Date.HOUR, 1);
19630 onDecrementHours: function()
19632 Roo.log('onDecrementHours');
19633 this.time = this.time.add(Date.HOUR, -1);
19637 onIncrementMinutes: function()
19639 Roo.log('onIncrementMinutes');
19640 this.time = this.time.add(Date.MINUTE, 1);
19644 onDecrementMinutes: function()
19646 Roo.log('onDecrementMinutes');
19647 this.time = this.time.add(Date.MINUTE, -1);
19651 onTogglePeriod: function()
19653 Roo.log('onTogglePeriod');
19654 this.time = this.time.add(Date.HOUR, 12);
19661 Roo.apply(Roo.bootstrap.TimeField, {
19691 cls: 'btn btn-info ok',
19703 Roo.apply(Roo.bootstrap.TimeField, {
19707 cls: 'datepicker dropdown-menu',
19711 cls: 'datepicker-time',
19715 cls: 'table-condensed',
19717 Roo.bootstrap.TimeField.content,
19718 Roo.bootstrap.TimeField.footer
19737 * @class Roo.bootstrap.MonthField
19738 * @extends Roo.bootstrap.Input
19739 * Bootstrap MonthField class
19741 * @cfg {String} language default en
19744 * Create a new MonthField
19745 * @param {Object} config The config object
19748 Roo.bootstrap.MonthField = function(config){
19749 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19754 * Fires when this field show.
19755 * @param {Roo.bootstrap.MonthField} this
19756 * @param {Mixed} date The date value
19761 * Fires when this field hide.
19762 * @param {Roo.bootstrap.MonthField} this
19763 * @param {Mixed} date The date value
19768 * Fires when select a date.
19769 * @param {Roo.bootstrap.MonthField} this
19770 * @param {String} oldvalue The old value
19771 * @param {String} newvalue The new value
19777 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19779 onRender: function(ct, position)
19782 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19784 this.language = this.language || 'en';
19785 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19786 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19788 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19789 this.isInline = false;
19790 this.isInput = true;
19791 this.component = this.el.select('.add-on', true).first() || false;
19792 this.component = (this.component && this.component.length === 0) ? false : this.component;
19793 this.hasInput = this.component && this.inputEL().length;
19795 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19797 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19799 this.picker().on('mousedown', this.onMousedown, this);
19800 this.picker().on('click', this.onClick, this);
19802 this.picker().addClass('datepicker-dropdown');
19804 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19805 v.setStyle('width', '189px');
19812 if(this.isInline) {
19818 setValue: function(v, suppressEvent)
19820 var o = this.getValue();
19822 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19826 if(suppressEvent !== true){
19827 this.fireEvent('select', this, o, v);
19832 getValue: function()
19837 onClick: function(e)
19839 e.stopPropagation();
19840 e.preventDefault();
19842 var target = e.getTarget();
19844 if(target.nodeName.toLowerCase() === 'i'){
19845 target = Roo.get(target).dom.parentNode;
19848 var nodeName = target.nodeName;
19849 var className = target.className;
19850 var html = target.innerHTML;
19852 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19856 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19858 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19864 picker : function()
19866 return this.pickerEl;
19869 fillMonths: function()
19872 var months = this.picker().select('>.datepicker-months td', true).first();
19874 months.dom.innerHTML = '';
19880 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19883 months.createChild(month);
19892 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19893 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19896 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19897 e.removeClass('active');
19899 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19900 e.addClass('active');
19907 if(this.isInline) {
19911 this.picker().removeClass(['bottom', 'top']);
19913 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19915 * place to the top of element!
19919 this.picker().addClass('top');
19920 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19925 this.picker().addClass('bottom');
19927 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19930 onFocus : function()
19932 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19936 onBlur : function()
19938 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19940 var d = this.inputEl().getValue();
19949 this.picker().show();
19950 this.picker().select('>.datepicker-months', true).first().show();
19954 this.fireEvent('show', this, this.date);
19959 if(this.isInline) {
19962 this.picker().hide();
19963 this.fireEvent('hide', this, this.date);
19967 onMousedown: function(e)
19969 e.stopPropagation();
19970 e.preventDefault();
19975 Roo.bootstrap.MonthField.superclass.keyup.call(this);
19979 fireKey: function(e)
19981 if (!this.picker().isVisible()){
19982 if (e.keyCode == 27) {// allow escape to hide and re-show picker
19993 e.preventDefault();
19997 dir = e.keyCode == 37 ? -1 : 1;
19999 this.vIndex = this.vIndex + dir;
20001 if(this.vIndex < 0){
20005 if(this.vIndex > 11){
20009 if(isNaN(this.vIndex)){
20013 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20019 dir = e.keyCode == 38 ? -1 : 1;
20021 this.vIndex = this.vIndex + dir * 4;
20023 if(this.vIndex < 0){
20027 if(this.vIndex > 11){
20031 if(isNaN(this.vIndex)){
20035 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20040 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20041 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20045 e.preventDefault();
20048 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20049 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20065 this.picker().remove();
20070 Roo.apply(Roo.bootstrap.MonthField, {
20089 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20090 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20095 Roo.apply(Roo.bootstrap.MonthField, {
20099 cls: 'datepicker dropdown-menu roo-dynamic',
20103 cls: 'datepicker-months',
20107 cls: 'table-condensed',
20109 Roo.bootstrap.DateField.content
20129 * @class Roo.bootstrap.CheckBox
20130 * @extends Roo.bootstrap.Input
20131 * Bootstrap CheckBox class
20133 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20134 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20135 * @cfg {String} boxLabel The text that appears beside the checkbox
20136 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20137 * @cfg {Boolean} checked initnal the element
20138 * @cfg {Boolean} inline inline the element (default false)
20139 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20140 * @cfg {String} tooltip label tooltip
20143 * Create a new CheckBox
20144 * @param {Object} config The config object
20147 Roo.bootstrap.CheckBox = function(config){
20148 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20153 * Fires when the element is checked or unchecked.
20154 * @param {Roo.bootstrap.CheckBox} this This input
20155 * @param {Boolean} checked The new checked value
20160 * Fires when the element is click.
20161 * @param {Roo.bootstrap.CheckBox} this This input
20168 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20170 inputType: 'checkbox',
20179 getAutoCreate : function()
20181 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20187 cfg.cls = 'form-group ' + this.inputType; //input-group
20190 cfg.cls += ' ' + this.inputType + '-inline';
20196 type : this.inputType,
20197 value : this.inputValue,
20198 cls : 'roo-' + this.inputType, //'form-box',
20199 placeholder : this.placeholder || ''
20203 if(this.inputType != 'radio'){
20207 cls : 'roo-hidden-value',
20208 value : this.checked ? this.inputValue : this.valueOff
20213 if (this.weight) { // Validity check?
20214 cfg.cls += " " + this.inputType + "-" + this.weight;
20217 if (this.disabled) {
20218 input.disabled=true;
20222 input.checked = this.checked;
20227 input.name = this.name;
20229 if(this.inputType != 'radio'){
20230 hidden.name = this.name;
20231 input.name = '_hidden_' + this.name;
20236 input.cls += ' input-' + this.size;
20241 ['xs','sm','md','lg'].map(function(size){
20242 if (settings[size]) {
20243 cfg.cls += ' col-' + size + '-' + settings[size];
20247 var inputblock = input;
20249 if (this.before || this.after) {
20252 cls : 'input-group',
20257 inputblock.cn.push({
20259 cls : 'input-group-addon',
20264 inputblock.cn.push(input);
20266 if(this.inputType != 'radio'){
20267 inputblock.cn.push(hidden);
20271 inputblock.cn.push({
20273 cls : 'input-group-addon',
20280 if (align ==='left' && this.fieldLabel.length) {
20281 // Roo.log("left and has label");
20286 cls : 'control-label',
20287 html : this.fieldLabel
20297 if(this.labelWidth > 12){
20298 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20301 if(this.labelWidth < 13 && this.labelmd == 0){
20302 this.labelmd = this.labelWidth;
20305 if(this.labellg > 0){
20306 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20307 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20310 if(this.labelmd > 0){
20311 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20312 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20315 if(this.labelsm > 0){
20316 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20317 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20320 if(this.labelxs > 0){
20321 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20322 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20325 } else if ( this.fieldLabel.length) {
20326 // Roo.log(" label");
20330 tag: this.boxLabel ? 'span' : 'label',
20332 cls: 'control-label box-input-label',
20333 //cls : 'input-group-addon',
20334 html : this.fieldLabel
20343 // Roo.log(" no label && no align");
20344 cfg.cn = [ inputblock ] ;
20350 var boxLabelCfg = {
20352 //'for': id, // box label is handled by onclick - so no for...
20354 html: this.boxLabel
20358 boxLabelCfg.tooltip = this.tooltip;
20361 cfg.cn.push(boxLabelCfg);
20364 if(this.inputType != 'radio'){
20365 cfg.cn.push(hidden);
20373 * return the real input element.
20375 inputEl: function ()
20377 return this.el.select('input.roo-' + this.inputType,true).first();
20379 hiddenEl: function ()
20381 return this.el.select('input.roo-hidden-value',true).first();
20384 labelEl: function()
20386 return this.el.select('label.control-label',true).first();
20388 /* depricated... */
20392 return this.labelEl();
20395 boxLabelEl: function()
20397 return this.el.select('label.box-label',true).first();
20400 initEvents : function()
20402 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20404 this.inputEl().on('click', this.onClick, this);
20406 if (this.boxLabel) {
20407 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20410 this.startValue = this.getValue();
20413 Roo.bootstrap.CheckBox.register(this);
20417 onClick : function(e)
20419 if(this.fireEvent('click', this, e) !== false){
20420 this.setChecked(!this.checked);
20425 setChecked : function(state,suppressEvent)
20427 this.startValue = this.getValue();
20429 if(this.inputType == 'radio'){
20431 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20432 e.dom.checked = false;
20435 this.inputEl().dom.checked = true;
20437 this.inputEl().dom.value = this.inputValue;
20439 if(suppressEvent !== true){
20440 this.fireEvent('check', this, true);
20448 this.checked = state;
20450 this.inputEl().dom.checked = state;
20453 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20455 if(suppressEvent !== true){
20456 this.fireEvent('check', this, state);
20462 getValue : function()
20464 if(this.inputType == 'radio'){
20465 return this.getGroupValue();
20468 return this.hiddenEl().dom.value;
20472 getGroupValue : function()
20474 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20478 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20481 setValue : function(v,suppressEvent)
20483 if(this.inputType == 'radio'){
20484 this.setGroupValue(v, suppressEvent);
20488 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20493 setGroupValue : function(v, suppressEvent)
20495 this.startValue = this.getValue();
20497 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20498 e.dom.checked = false;
20500 if(e.dom.value == v){
20501 e.dom.checked = true;
20505 if(suppressEvent !== true){
20506 this.fireEvent('check', this, true);
20514 validate : function()
20518 (this.inputType == 'radio' && this.validateRadio()) ||
20519 (this.inputType == 'checkbox' && this.validateCheckbox())
20525 this.markInvalid();
20529 validateRadio : function()
20531 if(this.allowBlank){
20537 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20538 if(!e.dom.checked){
20550 validateCheckbox : function()
20553 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20554 //return (this.getValue() == this.inputValue) ? true : false;
20557 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20565 for(var i in group){
20566 if(group[i].el.isVisible(true)){
20574 for(var i in group){
20579 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20586 * Mark this field as valid
20588 markValid : function()
20592 this.fireEvent('valid', this);
20594 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20597 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20604 if(this.inputType == 'radio'){
20605 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20606 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20607 e.findParent('.form-group', false, true).addClass(_this.validClass);
20614 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20615 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20619 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20625 for(var i in group){
20626 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20627 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20632 * Mark this field as invalid
20633 * @param {String} msg The validation message
20635 markInvalid : function(msg)
20637 if(this.allowBlank){
20643 this.fireEvent('invalid', this, msg);
20645 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20648 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20652 label.markInvalid();
20655 if(this.inputType == 'radio'){
20656 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20657 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20658 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20665 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20666 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20670 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20676 for(var i in group){
20677 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20678 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20683 clearInvalid : function()
20685 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20687 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20689 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20691 if (label && label.iconEl) {
20692 label.iconEl.removeClass(label.validClass);
20693 label.iconEl.removeClass(label.invalidClass);
20697 disable : function()
20699 if(this.inputType != 'radio'){
20700 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20707 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20708 _this.getActionEl().addClass(this.disabledClass);
20709 e.dom.disabled = true;
20713 this.disabled = true;
20714 this.fireEvent("disable", this);
20718 enable : function()
20720 if(this.inputType != 'radio'){
20721 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20728 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20729 _this.getActionEl().removeClass(this.disabledClass);
20730 e.dom.disabled = false;
20734 this.disabled = false;
20735 this.fireEvent("enable", this);
20741 Roo.apply(Roo.bootstrap.CheckBox, {
20746 * register a CheckBox Group
20747 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20749 register : function(checkbox)
20751 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20752 this.groups[checkbox.groupId] = {};
20755 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20759 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20763 * fetch a CheckBox Group based on the group ID
20764 * @param {string} the group ID
20765 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20767 get: function(groupId) {
20768 if (typeof(this.groups[groupId]) == 'undefined') {
20772 return this.groups[groupId] ;
20785 * @class Roo.bootstrap.Radio
20786 * @extends Roo.bootstrap.Component
20787 * Bootstrap Radio class
20788 * @cfg {String} boxLabel - the label associated
20789 * @cfg {String} value - the value of radio
20792 * Create a new Radio
20793 * @param {Object} config The config object
20795 Roo.bootstrap.Radio = function(config){
20796 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20800 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20806 getAutoCreate : function()
20810 cls : 'form-group radio',
20815 html : this.boxLabel
20823 initEvents : function()
20825 this.parent().register(this);
20827 this.el.on('click', this.onClick, this);
20831 onClick : function()
20833 this.setChecked(true);
20836 setChecked : function(state, suppressEvent)
20838 this.parent().setValue(this.value, suppressEvent);
20842 setBoxLabel : function(v)
20847 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20862 * @class Roo.bootstrap.SecurePass
20863 * @extends Roo.bootstrap.Input
20864 * Bootstrap SecurePass class
20868 * Create a new SecurePass
20869 * @param {Object} config The config object
20872 Roo.bootstrap.SecurePass = function (config) {
20873 // these go here, so the translation tool can replace them..
20875 PwdEmpty: "Please type a password, and then retype it to confirm.",
20876 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20877 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20878 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20879 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20880 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20881 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20882 TooWeak: "Your password is Too Weak."
20884 this.meterLabel = "Password strength:";
20885 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20886 this.meterClass = [
20887 "roo-password-meter-tooweak",
20888 "roo-password-meter-weak",
20889 "roo-password-meter-medium",
20890 "roo-password-meter-strong",
20891 "roo-password-meter-grey"
20896 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20899 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20901 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20903 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20904 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20905 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20906 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20907 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20908 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20909 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20919 * @cfg {String/Object} Label for the strength meter (defaults to
20920 * 'Password strength:')
20925 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20926 * ['Weak', 'Medium', 'Strong'])
20929 pwdStrengths: false,
20942 initEvents: function ()
20944 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
20946 if (this.el.is('input[type=password]') && Roo.isSafari) {
20947 this.el.on('keydown', this.SafariOnKeyDown, this);
20950 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
20953 onRender: function (ct, position)
20955 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
20956 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
20957 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
20959 this.trigger.createChild({
20964 cls: 'roo-password-meter-grey col-xs-12',
20967 //width: this.meterWidth + 'px'
20971 cls: 'roo-password-meter-text'
20977 if (this.hideTrigger) {
20978 this.trigger.setDisplayed(false);
20980 this.setSize(this.width || '', this.height || '');
20983 onDestroy: function ()
20985 if (this.trigger) {
20986 this.trigger.removeAllListeners();
20987 this.trigger.remove();
20990 this.wrap.remove();
20992 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
20995 checkStrength: function ()
20997 var pwd = this.inputEl().getValue();
20998 if (pwd == this._lastPwd) {
21003 if (this.ClientSideStrongPassword(pwd)) {
21005 } else if (this.ClientSideMediumPassword(pwd)) {
21007 } else if (this.ClientSideWeakPassword(pwd)) {
21013 Roo.log('strength1: ' + strength);
21015 //var pm = this.trigger.child('div/div/div').dom;
21016 var pm = this.trigger.child('div/div');
21017 pm.removeClass(this.meterClass);
21018 pm.addClass(this.meterClass[strength]);
21021 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21023 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21025 this._lastPwd = pwd;
21029 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21031 this._lastPwd = '';
21033 var pm = this.trigger.child('div/div');
21034 pm.removeClass(this.meterClass);
21035 pm.addClass('roo-password-meter-grey');
21038 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21041 this.inputEl().dom.type='password';
21044 validateValue: function (value)
21047 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21050 if (value.length == 0) {
21051 if (this.allowBlank) {
21052 this.clearInvalid();
21056 this.markInvalid(this.errors.PwdEmpty);
21057 this.errorMsg = this.errors.PwdEmpty;
21065 if ('[\x21-\x7e]*'.match(value)) {
21066 this.markInvalid(this.errors.PwdBadChar);
21067 this.errorMsg = this.errors.PwdBadChar;
21070 if (value.length < 6) {
21071 this.markInvalid(this.errors.PwdShort);
21072 this.errorMsg = this.errors.PwdShort;
21075 if (value.length > 16) {
21076 this.markInvalid(this.errors.PwdLong);
21077 this.errorMsg = this.errors.PwdLong;
21081 if (this.ClientSideStrongPassword(value)) {
21083 } else if (this.ClientSideMediumPassword(value)) {
21085 } else if (this.ClientSideWeakPassword(value)) {
21092 if (strength < 2) {
21093 //this.markInvalid(this.errors.TooWeak);
21094 this.errorMsg = this.errors.TooWeak;
21099 console.log('strength2: ' + strength);
21101 //var pm = this.trigger.child('div/div/div').dom;
21103 var pm = this.trigger.child('div/div');
21104 pm.removeClass(this.meterClass);
21105 pm.addClass(this.meterClass[strength]);
21107 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21109 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21111 this.errorMsg = '';
21115 CharacterSetChecks: function (type)
21118 this.fResult = false;
21121 isctype: function (character, type)
21124 case this.kCapitalLetter:
21125 if (character >= 'A' && character <= 'Z') {
21130 case this.kSmallLetter:
21131 if (character >= 'a' && character <= 'z') {
21137 if (character >= '0' && character <= '9') {
21142 case this.kPunctuation:
21143 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21154 IsLongEnough: function (pwd, size)
21156 return !(pwd == null || isNaN(size) || pwd.length < size);
21159 SpansEnoughCharacterSets: function (word, nb)
21161 if (!this.IsLongEnough(word, nb))
21166 var characterSetChecks = new Array(
21167 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21168 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21171 for (var index = 0; index < word.length; ++index) {
21172 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21173 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21174 characterSetChecks[nCharSet].fResult = true;
21181 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21182 if (characterSetChecks[nCharSet].fResult) {
21187 if (nCharSets < nb) {
21193 ClientSideStrongPassword: function (pwd)
21195 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21198 ClientSideMediumPassword: function (pwd)
21200 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21203 ClientSideWeakPassword: function (pwd)
21205 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21208 })//<script type="text/javascript">
21211 * Based Ext JS Library 1.1.1
21212 * Copyright(c) 2006-2007, Ext JS, LLC.
21218 * @class Roo.HtmlEditorCore
21219 * @extends Roo.Component
21220 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21222 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21225 Roo.HtmlEditorCore = function(config){
21228 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21233 * @event initialize
21234 * Fires when the editor is fully initialized (including the iframe)
21235 * @param {Roo.HtmlEditorCore} this
21240 * Fires when the editor is first receives the focus. Any insertion must wait
21241 * until after this event.
21242 * @param {Roo.HtmlEditorCore} this
21246 * @event beforesync
21247 * Fires before the textarea is updated with content from the editor iframe. Return false
21248 * to cancel the sync.
21249 * @param {Roo.HtmlEditorCore} this
21250 * @param {String} html
21254 * @event beforepush
21255 * Fires before the iframe editor is updated with content from the textarea. Return false
21256 * to cancel the push.
21257 * @param {Roo.HtmlEditorCore} this
21258 * @param {String} html
21263 * Fires when the textarea is updated with content from the editor iframe.
21264 * @param {Roo.HtmlEditorCore} this
21265 * @param {String} html
21270 * Fires when the iframe editor is updated with content from the textarea.
21271 * @param {Roo.HtmlEditorCore} this
21272 * @param {String} html
21277 * @event editorevent
21278 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21279 * @param {Roo.HtmlEditorCore} this
21285 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21287 // defaults : white / black...
21288 this.applyBlacklists();
21295 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21299 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21305 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21310 * @cfg {Number} height (in pixels)
21314 * @cfg {Number} width (in pixels)
21319 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21322 stylesheets: false,
21327 // private properties
21328 validationEvent : false,
21330 initialized : false,
21332 sourceEditMode : false,
21333 onFocus : Roo.emptyFn,
21335 hideMode:'offsets',
21339 // blacklist + whitelisted elements..
21346 * Protected method that will not generally be called directly. It
21347 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21348 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21350 getDocMarkup : function(){
21354 // inherit styels from page...??
21355 if (this.stylesheets === false) {
21357 Roo.get(document.head).select('style').each(function(node) {
21358 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21361 Roo.get(document.head).select('link').each(function(node) {
21362 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21365 } else if (!this.stylesheets.length) {
21367 st = '<style type="text/css">' +
21368 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21371 st = '<style type="text/css">' +
21376 st += '<style type="text/css">' +
21377 'IMG { cursor: pointer } ' +
21380 var cls = 'roo-htmleditor-body';
21382 if(this.bodyCls.length){
21383 cls += ' ' + this.bodyCls;
21386 return '<html><head>' + st +
21387 //<style type="text/css">' +
21388 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21390 ' </head><body class="' + cls + '"></body></html>';
21394 onRender : function(ct, position)
21397 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21398 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21401 this.el.dom.style.border = '0 none';
21402 this.el.dom.setAttribute('tabIndex', -1);
21403 this.el.addClass('x-hidden hide');
21407 if(Roo.isIE){ // fix IE 1px bogus margin
21408 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21412 this.frameId = Roo.id();
21416 var iframe = this.owner.wrap.createChild({
21418 cls: 'form-control', // bootstrap..
21420 name: this.frameId,
21421 frameBorder : 'no',
21422 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21427 this.iframe = iframe.dom;
21429 this.assignDocWin();
21431 this.doc.designMode = 'on';
21434 this.doc.write(this.getDocMarkup());
21438 var task = { // must defer to wait for browser to be ready
21440 //console.log("run task?" + this.doc.readyState);
21441 this.assignDocWin();
21442 if(this.doc.body || this.doc.readyState == 'complete'){
21444 this.doc.designMode="on";
21448 Roo.TaskMgr.stop(task);
21449 this.initEditor.defer(10, this);
21456 Roo.TaskMgr.start(task);
21461 onResize : function(w, h)
21463 Roo.log('resize: ' +w + ',' + h );
21464 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21468 if(typeof w == 'number'){
21470 this.iframe.style.width = w + 'px';
21472 if(typeof h == 'number'){
21474 this.iframe.style.height = h + 'px';
21476 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21483 * Toggles the editor between standard and source edit mode.
21484 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21486 toggleSourceEdit : function(sourceEditMode){
21488 this.sourceEditMode = sourceEditMode === true;
21490 if(this.sourceEditMode){
21492 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21495 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21496 //this.iframe.className = '';
21499 //this.setSize(this.owner.wrap.getSize());
21500 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21507 * Protected method that will not generally be called directly. If you need/want
21508 * custom HTML cleanup, this is the method you should override.
21509 * @param {String} html The HTML to be cleaned
21510 * return {String} The cleaned HTML
21512 cleanHtml : function(html){
21513 html = String(html);
21514 if(html.length > 5){
21515 if(Roo.isSafari){ // strip safari nonsense
21516 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21519 if(html == ' '){
21526 * HTML Editor -> Textarea
21527 * Protected method that will not generally be called directly. Syncs the contents
21528 * of the editor iframe with the textarea.
21530 syncValue : function(){
21531 if(this.initialized){
21532 var bd = (this.doc.body || this.doc.documentElement);
21533 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21534 var html = bd.innerHTML;
21536 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21537 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21539 html = '<div style="'+m[0]+'">' + html + '</div>';
21542 html = this.cleanHtml(html);
21543 // fix up the special chars.. normaly like back quotes in word...
21544 // however we do not want to do this with chinese..
21545 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21546 var cc = b.charCodeAt();
21548 (cc >= 0x4E00 && cc < 0xA000 ) ||
21549 (cc >= 0x3400 && cc < 0x4E00 ) ||
21550 (cc >= 0xf900 && cc < 0xfb00 )
21556 if(this.owner.fireEvent('beforesync', this, html) !== false){
21557 this.el.dom.value = html;
21558 this.owner.fireEvent('sync', this, html);
21564 * Protected method that will not generally be called directly. Pushes the value of the textarea
21565 * into the iframe editor.
21567 pushValue : function(){
21568 if(this.initialized){
21569 var v = this.el.dom.value.trim();
21571 // if(v.length < 1){
21575 if(this.owner.fireEvent('beforepush', this, v) !== false){
21576 var d = (this.doc.body || this.doc.documentElement);
21578 this.cleanUpPaste();
21579 this.el.dom.value = d.innerHTML;
21580 this.owner.fireEvent('push', this, v);
21586 deferFocus : function(){
21587 this.focus.defer(10, this);
21591 focus : function(){
21592 if(this.win && !this.sourceEditMode){
21599 assignDocWin: function()
21601 var iframe = this.iframe;
21604 this.doc = iframe.contentWindow.document;
21605 this.win = iframe.contentWindow;
21607 // if (!Roo.get(this.frameId)) {
21610 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21611 // this.win = Roo.get(this.frameId).dom.contentWindow;
21613 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21617 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21618 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21623 initEditor : function(){
21624 //console.log("INIT EDITOR");
21625 this.assignDocWin();
21629 this.doc.designMode="on";
21631 this.doc.write(this.getDocMarkup());
21634 var dbody = (this.doc.body || this.doc.documentElement);
21635 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21636 // this copies styles from the containing element into thsi one..
21637 // not sure why we need all of this..
21638 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21640 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21641 //ss['background-attachment'] = 'fixed'; // w3c
21642 dbody.bgProperties = 'fixed'; // ie
21643 //Roo.DomHelper.applyStyles(dbody, ss);
21644 Roo.EventManager.on(this.doc, {
21645 //'mousedown': this.onEditorEvent,
21646 'mouseup': this.onEditorEvent,
21647 'dblclick': this.onEditorEvent,
21648 'click': this.onEditorEvent,
21649 'keyup': this.onEditorEvent,
21654 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21656 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21657 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21659 this.initialized = true;
21661 this.owner.fireEvent('initialize', this);
21666 onDestroy : function(){
21672 //for (var i =0; i < this.toolbars.length;i++) {
21673 // // fixme - ask toolbars for heights?
21674 // this.toolbars[i].onDestroy();
21677 //this.wrap.dom.innerHTML = '';
21678 //this.wrap.remove();
21683 onFirstFocus : function(){
21685 this.assignDocWin();
21688 this.activated = true;
21691 if(Roo.isGecko){ // prevent silly gecko errors
21693 var s = this.win.getSelection();
21694 if(!s.focusNode || s.focusNode.nodeType != 3){
21695 var r = s.getRangeAt(0);
21696 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21701 this.execCmd('useCSS', true);
21702 this.execCmd('styleWithCSS', false);
21705 this.owner.fireEvent('activate', this);
21709 adjustFont: function(btn){
21710 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21711 //if(Roo.isSafari){ // safari
21714 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21715 if(Roo.isSafari){ // safari
21716 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21717 v = (v < 10) ? 10 : v;
21718 v = (v > 48) ? 48 : v;
21719 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21724 v = Math.max(1, v+adjust);
21726 this.execCmd('FontSize', v );
21729 onEditorEvent : function(e)
21731 this.owner.fireEvent('editorevent', this, e);
21732 // this.updateToolbar();
21733 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21736 insertTag : function(tg)
21738 // could be a bit smarter... -> wrap the current selected tRoo..
21739 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21741 range = this.createRange(this.getSelection());
21742 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21743 wrappingNode.appendChild(range.extractContents());
21744 range.insertNode(wrappingNode);
21751 this.execCmd("formatblock", tg);
21755 insertText : function(txt)
21759 var range = this.createRange();
21760 range.deleteContents();
21761 //alert(Sender.getAttribute('label'));
21763 range.insertNode(this.doc.createTextNode(txt));
21769 * Executes a Midas editor command on the editor document and performs necessary focus and
21770 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21771 * @param {String} cmd The Midas command
21772 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21774 relayCmd : function(cmd, value){
21776 this.execCmd(cmd, value);
21777 this.owner.fireEvent('editorevent', this);
21778 //this.updateToolbar();
21779 this.owner.deferFocus();
21783 * Executes a Midas editor command directly on the editor document.
21784 * For visual commands, you should use {@link #relayCmd} instead.
21785 * <b>This should only be called after the editor is initialized.</b>
21786 * @param {String} cmd The Midas command
21787 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21789 execCmd : function(cmd, value){
21790 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21797 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21799 * @param {String} text | dom node..
21801 insertAtCursor : function(text)
21804 if(!this.activated){
21810 var r = this.doc.selection.createRange();
21821 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21825 // from jquery ui (MIT licenced)
21827 var win = this.win;
21829 if (win.getSelection && win.getSelection().getRangeAt) {
21830 range = win.getSelection().getRangeAt(0);
21831 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21832 range.insertNode(node);
21833 } else if (win.document.selection && win.document.selection.createRange) {
21834 // no firefox support
21835 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21836 win.document.selection.createRange().pasteHTML(txt);
21838 // no firefox support
21839 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21840 this.execCmd('InsertHTML', txt);
21849 mozKeyPress : function(e){
21851 var c = e.getCharCode(), cmd;
21854 c = String.fromCharCode(c).toLowerCase();
21868 this.cleanUpPaste.defer(100, this);
21876 e.preventDefault();
21884 fixKeys : function(){ // load time branching for fastest keydown performance
21886 return function(e){
21887 var k = e.getKey(), r;
21890 r = this.doc.selection.createRange();
21893 r.pasteHTML('    ');
21900 r = this.doc.selection.createRange();
21902 var target = r.parentElement();
21903 if(!target || target.tagName.toLowerCase() != 'li'){
21905 r.pasteHTML('<br />');
21911 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21912 this.cleanUpPaste.defer(100, this);
21918 }else if(Roo.isOpera){
21919 return function(e){
21920 var k = e.getKey();
21924 this.execCmd('InsertHTML','    ');
21927 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21928 this.cleanUpPaste.defer(100, this);
21933 }else if(Roo.isSafari){
21934 return function(e){
21935 var k = e.getKey();
21939 this.execCmd('InsertText','\t');
21943 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21944 this.cleanUpPaste.defer(100, this);
21952 getAllAncestors: function()
21954 var p = this.getSelectedNode();
21957 a.push(p); // push blank onto stack..
21958 p = this.getParentElement();
21962 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
21966 a.push(this.doc.body);
21970 lastSelNode : false,
21973 getSelection : function()
21975 this.assignDocWin();
21976 return Roo.isIE ? this.doc.selection : this.win.getSelection();
21979 getSelectedNode: function()
21981 // this may only work on Gecko!!!
21983 // should we cache this!!!!
21988 var range = this.createRange(this.getSelection()).cloneRange();
21991 var parent = range.parentElement();
21993 var testRange = range.duplicate();
21994 testRange.moveToElementText(parent);
21995 if (testRange.inRange(range)) {
21998 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22001 parent = parent.parentElement;
22006 // is ancestor a text element.
22007 var ac = range.commonAncestorContainer;
22008 if (ac.nodeType == 3) {
22009 ac = ac.parentNode;
22012 var ar = ac.childNodes;
22015 var other_nodes = [];
22016 var has_other_nodes = false;
22017 for (var i=0;i<ar.length;i++) {
22018 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22021 // fullly contained node.
22023 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22028 // probably selected..
22029 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22030 other_nodes.push(ar[i]);
22034 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22039 has_other_nodes = true;
22041 if (!nodes.length && other_nodes.length) {
22042 nodes= other_nodes;
22044 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22050 createRange: function(sel)
22052 // this has strange effects when using with
22053 // top toolbar - not sure if it's a great idea.
22054 //this.editor.contentWindow.focus();
22055 if (typeof sel != "undefined") {
22057 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22059 return this.doc.createRange();
22062 return this.doc.createRange();
22065 getParentElement: function()
22068 this.assignDocWin();
22069 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22071 var range = this.createRange(sel);
22074 var p = range.commonAncestorContainer;
22075 while (p.nodeType == 3) { // text node
22086 * Range intersection.. the hard stuff...
22090 * [ -- selected range --- ]
22094 * if end is before start or hits it. fail.
22095 * if start is after end or hits it fail.
22097 * if either hits (but other is outside. - then it's not
22103 // @see http://www.thismuchiknow.co.uk/?p=64.
22104 rangeIntersectsNode : function(range, node)
22106 var nodeRange = node.ownerDocument.createRange();
22108 nodeRange.selectNode(node);
22110 nodeRange.selectNodeContents(node);
22113 var rangeStartRange = range.cloneRange();
22114 rangeStartRange.collapse(true);
22116 var rangeEndRange = range.cloneRange();
22117 rangeEndRange.collapse(false);
22119 var nodeStartRange = nodeRange.cloneRange();
22120 nodeStartRange.collapse(true);
22122 var nodeEndRange = nodeRange.cloneRange();
22123 nodeEndRange.collapse(false);
22125 return rangeStartRange.compareBoundaryPoints(
22126 Range.START_TO_START, nodeEndRange) == -1 &&
22127 rangeEndRange.compareBoundaryPoints(
22128 Range.START_TO_START, nodeStartRange) == 1;
22132 rangeCompareNode : function(range, node)
22134 var nodeRange = node.ownerDocument.createRange();
22136 nodeRange.selectNode(node);
22138 nodeRange.selectNodeContents(node);
22142 range.collapse(true);
22144 nodeRange.collapse(true);
22146 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22147 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22149 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22151 var nodeIsBefore = ss == 1;
22152 var nodeIsAfter = ee == -1;
22154 if (nodeIsBefore && nodeIsAfter) {
22157 if (!nodeIsBefore && nodeIsAfter) {
22158 return 1; //right trailed.
22161 if (nodeIsBefore && !nodeIsAfter) {
22162 return 2; // left trailed.
22168 // private? - in a new class?
22169 cleanUpPaste : function()
22171 // cleans up the whole document..
22172 Roo.log('cleanuppaste');
22174 this.cleanUpChildren(this.doc.body);
22175 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22176 if (clean != this.doc.body.innerHTML) {
22177 this.doc.body.innerHTML = clean;
22182 cleanWordChars : function(input) {// change the chars to hex code
22183 var he = Roo.HtmlEditorCore;
22185 var output = input;
22186 Roo.each(he.swapCodes, function(sw) {
22187 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22189 output = output.replace(swapper, sw[1]);
22196 cleanUpChildren : function (n)
22198 if (!n.childNodes.length) {
22201 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22202 this.cleanUpChild(n.childNodes[i]);
22209 cleanUpChild : function (node)
22212 //console.log(node);
22213 if (node.nodeName == "#text") {
22214 // clean up silly Windows -- stuff?
22217 if (node.nodeName == "#comment") {
22218 node.parentNode.removeChild(node);
22219 // clean up silly Windows -- stuff?
22222 var lcname = node.tagName.toLowerCase();
22223 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22224 // whitelist of tags..
22226 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22228 node.parentNode.removeChild(node);
22233 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22235 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22236 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22238 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22239 // remove_keep_children = true;
22242 if (remove_keep_children) {
22243 this.cleanUpChildren(node);
22244 // inserts everything just before this node...
22245 while (node.childNodes.length) {
22246 var cn = node.childNodes[0];
22247 node.removeChild(cn);
22248 node.parentNode.insertBefore(cn, node);
22250 node.parentNode.removeChild(node);
22254 if (!node.attributes || !node.attributes.length) {
22255 this.cleanUpChildren(node);
22259 function cleanAttr(n,v)
22262 if (v.match(/^\./) || v.match(/^\//)) {
22265 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22268 if (v.match(/^#/)) {
22271 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22272 node.removeAttribute(n);
22276 var cwhite = this.cwhite;
22277 var cblack = this.cblack;
22279 function cleanStyle(n,v)
22281 if (v.match(/expression/)) { //XSS?? should we even bother..
22282 node.removeAttribute(n);
22286 var parts = v.split(/;/);
22289 Roo.each(parts, function(p) {
22290 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22294 var l = p.split(':').shift().replace(/\s+/g,'');
22295 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22297 if ( cwhite.length && cblack.indexOf(l) > -1) {
22298 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22299 //node.removeAttribute(n);
22303 // only allow 'c whitelisted system attributes'
22304 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22305 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22306 //node.removeAttribute(n);
22316 if (clean.length) {
22317 node.setAttribute(n, clean.join(';'));
22319 node.removeAttribute(n);
22325 for (var i = node.attributes.length-1; i > -1 ; i--) {
22326 var a = node.attributes[i];
22329 if (a.name.toLowerCase().substr(0,2)=='on') {
22330 node.removeAttribute(a.name);
22333 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22334 node.removeAttribute(a.name);
22337 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22338 cleanAttr(a.name,a.value); // fixme..
22341 if (a.name == 'style') {
22342 cleanStyle(a.name,a.value);
22345 /// clean up MS crap..
22346 // tecnically this should be a list of valid class'es..
22349 if (a.name == 'class') {
22350 if (a.value.match(/^Mso/)) {
22351 node.className = '';
22354 if (a.value.match(/^body$/)) {
22355 node.className = '';
22366 this.cleanUpChildren(node);
22372 * Clean up MS wordisms...
22374 cleanWord : function(node)
22379 this.cleanWord(this.doc.body);
22382 if (node.nodeName == "#text") {
22383 // clean up silly Windows -- stuff?
22386 if (node.nodeName == "#comment") {
22387 node.parentNode.removeChild(node);
22388 // clean up silly Windows -- stuff?
22392 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22393 node.parentNode.removeChild(node);
22397 // remove - but keep children..
22398 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22399 while (node.childNodes.length) {
22400 var cn = node.childNodes[0];
22401 node.removeChild(cn);
22402 node.parentNode.insertBefore(cn, node);
22404 node.parentNode.removeChild(node);
22405 this.iterateChildren(node, this.cleanWord);
22409 if (node.className.length) {
22411 var cn = node.className.split(/\W+/);
22413 Roo.each(cn, function(cls) {
22414 if (cls.match(/Mso[a-zA-Z]+/)) {
22419 node.className = cna.length ? cna.join(' ') : '';
22421 node.removeAttribute("class");
22425 if (node.hasAttribute("lang")) {
22426 node.removeAttribute("lang");
22429 if (node.hasAttribute("style")) {
22431 var styles = node.getAttribute("style").split(";");
22433 Roo.each(styles, function(s) {
22434 if (!s.match(/:/)) {
22437 var kv = s.split(":");
22438 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22441 // what ever is left... we allow.
22444 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22445 if (!nstyle.length) {
22446 node.removeAttribute('style');
22449 this.iterateChildren(node, this.cleanWord);
22455 * iterateChildren of a Node, calling fn each time, using this as the scole..
22456 * @param {DomNode} node node to iterate children of.
22457 * @param {Function} fn method of this class to call on each item.
22459 iterateChildren : function(node, fn)
22461 if (!node.childNodes.length) {
22464 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22465 fn.call(this, node.childNodes[i])
22471 * cleanTableWidths.
22473 * Quite often pasting from word etc.. results in tables with column and widths.
22474 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22477 cleanTableWidths : function(node)
22482 this.cleanTableWidths(this.doc.body);
22487 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22490 Roo.log(node.tagName);
22491 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22492 this.iterateChildren(node, this.cleanTableWidths);
22495 if (node.hasAttribute('width')) {
22496 node.removeAttribute('width');
22500 if (node.hasAttribute("style")) {
22503 var styles = node.getAttribute("style").split(";");
22505 Roo.each(styles, function(s) {
22506 if (!s.match(/:/)) {
22509 var kv = s.split(":");
22510 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22513 // what ever is left... we allow.
22516 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22517 if (!nstyle.length) {
22518 node.removeAttribute('style');
22522 this.iterateChildren(node, this.cleanTableWidths);
22530 domToHTML : function(currentElement, depth, nopadtext) {
22532 depth = depth || 0;
22533 nopadtext = nopadtext || false;
22535 if (!currentElement) {
22536 return this.domToHTML(this.doc.body);
22539 //Roo.log(currentElement);
22541 var allText = false;
22542 var nodeName = currentElement.nodeName;
22543 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22545 if (nodeName == '#text') {
22547 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22552 if (nodeName != 'BODY') {
22555 // Prints the node tagName, such as <A>, <IMG>, etc
22558 for(i = 0; i < currentElement.attributes.length;i++) {
22560 var aname = currentElement.attributes.item(i).name;
22561 if (!currentElement.attributes.item(i).value.length) {
22564 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22567 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22576 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22579 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22584 // Traverse the tree
22586 var currentElementChild = currentElement.childNodes.item(i);
22587 var allText = true;
22588 var innerHTML = '';
22590 while (currentElementChild) {
22591 // Formatting code (indent the tree so it looks nice on the screen)
22592 var nopad = nopadtext;
22593 if (lastnode == 'SPAN') {
22597 if (currentElementChild.nodeName == '#text') {
22598 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22599 toadd = nopadtext ? toadd : toadd.trim();
22600 if (!nopad && toadd.length > 80) {
22601 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22603 innerHTML += toadd;
22606 currentElementChild = currentElement.childNodes.item(i);
22612 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22614 // Recursively traverse the tree structure of the child node
22615 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22616 lastnode = currentElementChild.nodeName;
22618 currentElementChild=currentElement.childNodes.item(i);
22624 // The remaining code is mostly for formatting the tree
22625 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22630 ret+= "</"+tagName+">";
22636 applyBlacklists : function()
22638 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22639 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22643 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22644 if (b.indexOf(tag) > -1) {
22647 this.white.push(tag);
22651 Roo.each(w, function(tag) {
22652 if (b.indexOf(tag) > -1) {
22655 if (this.white.indexOf(tag) > -1) {
22658 this.white.push(tag);
22663 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22664 if (w.indexOf(tag) > -1) {
22667 this.black.push(tag);
22671 Roo.each(b, function(tag) {
22672 if (w.indexOf(tag) > -1) {
22675 if (this.black.indexOf(tag) > -1) {
22678 this.black.push(tag);
22683 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22684 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22688 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22689 if (b.indexOf(tag) > -1) {
22692 this.cwhite.push(tag);
22696 Roo.each(w, function(tag) {
22697 if (b.indexOf(tag) > -1) {
22700 if (this.cwhite.indexOf(tag) > -1) {
22703 this.cwhite.push(tag);
22708 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22709 if (w.indexOf(tag) > -1) {
22712 this.cblack.push(tag);
22716 Roo.each(b, function(tag) {
22717 if (w.indexOf(tag) > -1) {
22720 if (this.cblack.indexOf(tag) > -1) {
22723 this.cblack.push(tag);
22728 setStylesheets : function(stylesheets)
22730 if(typeof(stylesheets) == 'string'){
22731 Roo.get(this.iframe.contentDocument.head).createChild({
22733 rel : 'stylesheet',
22742 Roo.each(stylesheets, function(s) {
22747 Roo.get(_this.iframe.contentDocument.head).createChild({
22749 rel : 'stylesheet',
22758 removeStylesheets : function()
22762 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22767 setStyle : function(style)
22769 Roo.get(this.iframe.contentDocument.head).createChild({
22778 // hide stuff that is not compatible
22792 * @event specialkey
22796 * @cfg {String} fieldClass @hide
22799 * @cfg {String} focusClass @hide
22802 * @cfg {String} autoCreate @hide
22805 * @cfg {String} inputType @hide
22808 * @cfg {String} invalidClass @hide
22811 * @cfg {String} invalidText @hide
22814 * @cfg {String} msgFx @hide
22817 * @cfg {String} validateOnBlur @hide
22821 Roo.HtmlEditorCore.white = [
22822 'area', 'br', 'img', 'input', 'hr', 'wbr',
22824 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22825 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22826 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22827 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22828 'table', 'ul', 'xmp',
22830 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22833 'dir', 'menu', 'ol', 'ul', 'dl',
22839 Roo.HtmlEditorCore.black = [
22840 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22842 'base', 'basefont', 'bgsound', 'blink', 'body',
22843 'frame', 'frameset', 'head', 'html', 'ilayer',
22844 'iframe', 'layer', 'link', 'meta', 'object',
22845 'script', 'style' ,'title', 'xml' // clean later..
22847 Roo.HtmlEditorCore.clean = [
22848 'script', 'style', 'title', 'xml'
22850 Roo.HtmlEditorCore.remove = [
22855 Roo.HtmlEditorCore.ablack = [
22859 Roo.HtmlEditorCore.aclean = [
22860 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22864 Roo.HtmlEditorCore.pwhite= [
22865 'http', 'https', 'mailto'
22868 // white listed style attributes.
22869 Roo.HtmlEditorCore.cwhite= [
22870 // 'text-align', /// default is to allow most things..
22876 // black listed style attributes.
22877 Roo.HtmlEditorCore.cblack= [
22878 // 'font-size' -- this can be set by the project
22882 Roo.HtmlEditorCore.swapCodes =[
22901 * @class Roo.bootstrap.HtmlEditor
22902 * @extends Roo.bootstrap.TextArea
22903 * Bootstrap HtmlEditor class
22906 * Create a new HtmlEditor
22907 * @param {Object} config The config object
22910 Roo.bootstrap.HtmlEditor = function(config){
22911 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22912 if (!this.toolbars) {
22913 this.toolbars = [];
22916 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22919 * @event initialize
22920 * Fires when the editor is fully initialized (including the iframe)
22921 * @param {HtmlEditor} this
22926 * Fires when the editor is first receives the focus. Any insertion must wait
22927 * until after this event.
22928 * @param {HtmlEditor} this
22932 * @event beforesync
22933 * Fires before the textarea is updated with content from the editor iframe. Return false
22934 * to cancel the sync.
22935 * @param {HtmlEditor} this
22936 * @param {String} html
22940 * @event beforepush
22941 * Fires before the iframe editor is updated with content from the textarea. Return false
22942 * to cancel the push.
22943 * @param {HtmlEditor} this
22944 * @param {String} html
22949 * Fires when the textarea is updated with content from the editor iframe.
22950 * @param {HtmlEditor} this
22951 * @param {String} html
22956 * Fires when the iframe editor is updated with content from the textarea.
22957 * @param {HtmlEditor} this
22958 * @param {String} html
22962 * @event editmodechange
22963 * Fires when the editor switches edit modes
22964 * @param {HtmlEditor} this
22965 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
22967 editmodechange: true,
22969 * @event editorevent
22970 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22971 * @param {HtmlEditor} this
22975 * @event firstfocus
22976 * Fires when on first focus - needed by toolbars..
22977 * @param {HtmlEditor} this
22982 * Auto save the htmlEditor value as a file into Events
22983 * @param {HtmlEditor} this
22987 * @event savedpreview
22988 * preview the saved version of htmlEditor
22989 * @param {HtmlEditor} this
22996 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23000 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23005 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23010 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23015 * @cfg {Number} height (in pixels)
23019 * @cfg {Number} width (in pixels)
23024 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23027 stylesheets: false,
23032 // private properties
23033 validationEvent : false,
23035 initialized : false,
23038 onFocus : Roo.emptyFn,
23040 hideMode:'offsets',
23042 tbContainer : false,
23046 toolbarContainer :function() {
23047 return this.wrap.select('.x-html-editor-tb',true).first();
23051 * Protected method that will not generally be called directly. It
23052 * is called when the editor creates its toolbar. Override this method if you need to
23053 * add custom toolbar buttons.
23054 * @param {HtmlEditor} editor
23056 createToolbar : function(){
23057 Roo.log('renewing');
23058 Roo.log("create toolbars");
23060 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23061 this.toolbars[0].render(this.toolbarContainer());
23065 // if (!editor.toolbars || !editor.toolbars.length) {
23066 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23069 // for (var i =0 ; i < editor.toolbars.length;i++) {
23070 // editor.toolbars[i] = Roo.factory(
23071 // typeof(editor.toolbars[i]) == 'string' ?
23072 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23073 // Roo.bootstrap.HtmlEditor);
23074 // editor.toolbars[i].init(editor);
23080 onRender : function(ct, position)
23082 // Roo.log("Call onRender: " + this.xtype);
23084 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23086 this.wrap = this.inputEl().wrap({
23087 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23090 this.editorcore.onRender(ct, position);
23092 if (this.resizable) {
23093 this.resizeEl = new Roo.Resizable(this.wrap, {
23097 minHeight : this.height,
23098 height: this.height,
23099 handles : this.resizable,
23102 resize : function(r, w, h) {
23103 _t.onResize(w,h); // -something
23109 this.createToolbar(this);
23112 if(!this.width && this.resizable){
23113 this.setSize(this.wrap.getSize());
23115 if (this.resizeEl) {
23116 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23117 // should trigger onReize..
23123 onResize : function(w, h)
23125 Roo.log('resize: ' +w + ',' + h );
23126 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23130 if(this.inputEl() ){
23131 if(typeof w == 'number'){
23132 var aw = w - this.wrap.getFrameWidth('lr');
23133 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23136 if(typeof h == 'number'){
23137 var tbh = -11; // fixme it needs to tool bar size!
23138 for (var i =0; i < this.toolbars.length;i++) {
23139 // fixme - ask toolbars for heights?
23140 tbh += this.toolbars[i].el.getHeight();
23141 //if (this.toolbars[i].footer) {
23142 // tbh += this.toolbars[i].footer.el.getHeight();
23150 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23151 ah -= 5; // knock a few pixes off for look..
23152 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23156 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23157 this.editorcore.onResize(ew,eh);
23162 * Toggles the editor between standard and source edit mode.
23163 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23165 toggleSourceEdit : function(sourceEditMode)
23167 this.editorcore.toggleSourceEdit(sourceEditMode);
23169 if(this.editorcore.sourceEditMode){
23170 Roo.log('editor - showing textarea');
23173 // Roo.log(this.syncValue());
23175 this.inputEl().removeClass(['hide', 'x-hidden']);
23176 this.inputEl().dom.removeAttribute('tabIndex');
23177 this.inputEl().focus();
23179 Roo.log('editor - hiding textarea');
23181 // Roo.log(this.pushValue());
23184 this.inputEl().addClass(['hide', 'x-hidden']);
23185 this.inputEl().dom.setAttribute('tabIndex', -1);
23186 //this.deferFocus();
23189 if(this.resizable){
23190 this.setSize(this.wrap.getSize());
23193 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23196 // private (for BoxComponent)
23197 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23199 // private (for BoxComponent)
23200 getResizeEl : function(){
23204 // private (for BoxComponent)
23205 getPositionEl : function(){
23210 initEvents : function(){
23211 this.originalValue = this.getValue();
23215 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23218 // markInvalid : Roo.emptyFn,
23220 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23223 // clearInvalid : Roo.emptyFn,
23225 setValue : function(v){
23226 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23227 this.editorcore.pushValue();
23232 deferFocus : function(){
23233 this.focus.defer(10, this);
23237 focus : function(){
23238 this.editorcore.focus();
23244 onDestroy : function(){
23250 for (var i =0; i < this.toolbars.length;i++) {
23251 // fixme - ask toolbars for heights?
23252 this.toolbars[i].onDestroy();
23255 this.wrap.dom.innerHTML = '';
23256 this.wrap.remove();
23261 onFirstFocus : function(){
23262 //Roo.log("onFirstFocus");
23263 this.editorcore.onFirstFocus();
23264 for (var i =0; i < this.toolbars.length;i++) {
23265 this.toolbars[i].onFirstFocus();
23271 syncValue : function()
23273 this.editorcore.syncValue();
23276 pushValue : function()
23278 this.editorcore.pushValue();
23282 // hide stuff that is not compatible
23296 * @event specialkey
23300 * @cfg {String} fieldClass @hide
23303 * @cfg {String} focusClass @hide
23306 * @cfg {String} autoCreate @hide
23309 * @cfg {String} inputType @hide
23312 * @cfg {String} invalidClass @hide
23315 * @cfg {String} invalidText @hide
23318 * @cfg {String} msgFx @hide
23321 * @cfg {String} validateOnBlur @hide
23330 Roo.namespace('Roo.bootstrap.htmleditor');
23332 * @class Roo.bootstrap.HtmlEditorToolbar1
23337 new Roo.bootstrap.HtmlEditor({
23340 new Roo.bootstrap.HtmlEditorToolbar1({
23341 disable : { fonts: 1 , format: 1, ..., ... , ...],
23347 * @cfg {Object} disable List of elements to disable..
23348 * @cfg {Array} btns List of additional buttons.
23352 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23355 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23358 Roo.apply(this, config);
23360 // default disabled, based on 'good practice'..
23361 this.disable = this.disable || {};
23362 Roo.applyIf(this.disable, {
23365 specialElements : true
23367 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23369 this.editor = config.editor;
23370 this.editorcore = config.editor.editorcore;
23372 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23374 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23375 // dont call parent... till later.
23377 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23382 editorcore : false,
23387 "h1","h2","h3","h4","h5","h6",
23389 "abbr", "acronym", "address", "cite", "samp", "var",
23393 onRender : function(ct, position)
23395 // Roo.log("Call onRender: " + this.xtype);
23397 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23399 this.el.dom.style.marginBottom = '0';
23401 var editorcore = this.editorcore;
23402 var editor= this.editor;
23405 var btn = function(id,cmd , toggle, handler, html){
23407 var event = toggle ? 'toggle' : 'click';
23412 xns: Roo.bootstrap,
23415 enableToggle:toggle !== false,
23417 pressed : toggle ? false : null,
23420 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23421 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23427 // var cb_box = function...
23432 xns: Roo.bootstrap,
23433 glyphicon : 'font',
23437 xns: Roo.bootstrap,
23441 Roo.each(this.formats, function(f) {
23442 style.menu.items.push({
23444 xns: Roo.bootstrap,
23445 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23450 editorcore.insertTag(this.tagname);
23457 children.push(style);
23459 btn('bold',false,true);
23460 btn('italic',false,true);
23461 btn('align-left', 'justifyleft',true);
23462 btn('align-center', 'justifycenter',true);
23463 btn('align-right' , 'justifyright',true);
23464 btn('link', false, false, function(btn) {
23465 //Roo.log("create link?");
23466 var url = prompt(this.createLinkText, this.defaultLinkValue);
23467 if(url && url != 'http:/'+'/'){
23468 this.editorcore.relayCmd('createlink', url);
23471 btn('list','insertunorderedlist',true);
23472 btn('pencil', false,true, function(btn){
23474 this.toggleSourceEdit(btn.pressed);
23477 if (this.editor.btns.length > 0) {
23478 for (var i = 0; i<this.editor.btns.length; i++) {
23479 children.push(this.editor.btns[i]);
23487 xns: Roo.bootstrap,
23492 xns: Roo.bootstrap,
23497 cog.menu.items.push({
23499 xns: Roo.bootstrap,
23500 html : Clean styles,
23505 editorcore.insertTag(this.tagname);
23514 this.xtype = 'NavSimplebar';
23516 for(var i=0;i< children.length;i++) {
23518 this.buttons.add(this.addxtypeChild(children[i]));
23522 editor.on('editorevent', this.updateToolbar, this);
23524 onBtnClick : function(id)
23526 this.editorcore.relayCmd(id);
23527 this.editorcore.focus();
23531 * Protected method that will not generally be called directly. It triggers
23532 * a toolbar update by reading the markup state of the current selection in the editor.
23534 updateToolbar: function(){
23536 if(!this.editorcore.activated){
23537 this.editor.onFirstFocus(); // is this neeed?
23541 var btns = this.buttons;
23542 var doc = this.editorcore.doc;
23543 btns.get('bold').setActive(doc.queryCommandState('bold'));
23544 btns.get('italic').setActive(doc.queryCommandState('italic'));
23545 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23547 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23548 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23549 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23551 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23552 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23555 var ans = this.editorcore.getAllAncestors();
23556 if (this.formatCombo) {
23559 var store = this.formatCombo.store;
23560 this.formatCombo.setValue("");
23561 for (var i =0; i < ans.length;i++) {
23562 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23564 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23572 // hides menus... - so this cant be on a menu...
23573 Roo.bootstrap.MenuMgr.hideAll();
23575 Roo.bootstrap.MenuMgr.hideAll();
23576 //this.editorsyncValue();
23578 onFirstFocus: function() {
23579 this.buttons.each(function(item){
23583 toggleSourceEdit : function(sourceEditMode){
23586 if(sourceEditMode){
23587 Roo.log("disabling buttons");
23588 this.buttons.each( function(item){
23589 if(item.cmd != 'pencil'){
23595 Roo.log("enabling buttons");
23596 if(this.editorcore.initialized){
23597 this.buttons.each( function(item){
23603 Roo.log("calling toggole on editor");
23604 // tell the editor that it's been pressed..
23605 this.editor.toggleSourceEdit(sourceEditMode);
23615 * @class Roo.bootstrap.Table.AbstractSelectionModel
23616 * @extends Roo.util.Observable
23617 * Abstract base class for grid SelectionModels. It provides the interface that should be
23618 * implemented by descendant classes. This class should not be directly instantiated.
23621 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23622 this.locked = false;
23623 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23627 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23628 /** @ignore Called by the grid automatically. Do not call directly. */
23629 init : function(grid){
23635 * Locks the selections.
23638 this.locked = true;
23642 * Unlocks the selections.
23644 unlock : function(){
23645 this.locked = false;
23649 * Returns true if the selections are locked.
23650 * @return {Boolean}
23652 isLocked : function(){
23653 return this.locked;
23657 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23658 * @class Roo.bootstrap.Table.RowSelectionModel
23659 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23660 * It supports multiple selections and keyboard selection/navigation.
23662 * @param {Object} config
23665 Roo.bootstrap.Table.RowSelectionModel = function(config){
23666 Roo.apply(this, config);
23667 this.selections = new Roo.util.MixedCollection(false, function(o){
23672 this.lastActive = false;
23676 * @event selectionchange
23677 * Fires when the selection changes
23678 * @param {SelectionModel} this
23680 "selectionchange" : true,
23682 * @event afterselectionchange
23683 * Fires after the selection changes (eg. by key press or clicking)
23684 * @param {SelectionModel} this
23686 "afterselectionchange" : true,
23688 * @event beforerowselect
23689 * Fires when a row is selected being selected, return false to cancel.
23690 * @param {SelectionModel} this
23691 * @param {Number} rowIndex The selected index
23692 * @param {Boolean} keepExisting False if other selections will be cleared
23694 "beforerowselect" : true,
23697 * Fires when a row is selected.
23698 * @param {SelectionModel} this
23699 * @param {Number} rowIndex The selected index
23700 * @param {Roo.data.Record} r The record
23702 "rowselect" : true,
23704 * @event rowdeselect
23705 * Fires when a row is deselected.
23706 * @param {SelectionModel} this
23707 * @param {Number} rowIndex The selected index
23709 "rowdeselect" : true
23711 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23712 this.locked = false;
23715 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23717 * @cfg {Boolean} singleSelect
23718 * True to allow selection of only one row at a time (defaults to false)
23720 singleSelect : false,
23723 initEvents : function()
23726 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23727 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23728 //}else{ // allow click to work like normal
23729 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23731 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23732 this.grid.on("rowclick", this.handleMouseDown, this);
23734 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23735 "up" : function(e){
23737 this.selectPrevious(e.shiftKey);
23738 }else if(this.last !== false && this.lastActive !== false){
23739 var last = this.last;
23740 this.selectRange(this.last, this.lastActive-1);
23741 this.grid.getView().focusRow(this.lastActive);
23742 if(last !== false){
23746 this.selectFirstRow();
23748 this.fireEvent("afterselectionchange", this);
23750 "down" : function(e){
23752 this.selectNext(e.shiftKey);
23753 }else if(this.last !== false && this.lastActive !== false){
23754 var last = this.last;
23755 this.selectRange(this.last, this.lastActive+1);
23756 this.grid.getView().focusRow(this.lastActive);
23757 if(last !== false){
23761 this.selectFirstRow();
23763 this.fireEvent("afterselectionchange", this);
23767 this.grid.store.on('load', function(){
23768 this.selections.clear();
23771 var view = this.grid.view;
23772 view.on("refresh", this.onRefresh, this);
23773 view.on("rowupdated", this.onRowUpdated, this);
23774 view.on("rowremoved", this.onRemove, this);
23779 onRefresh : function()
23781 var ds = this.grid.store, i, v = this.grid.view;
23782 var s = this.selections;
23783 s.each(function(r){
23784 if((i = ds.indexOfId(r.id)) != -1){
23793 onRemove : function(v, index, r){
23794 this.selections.remove(r);
23798 onRowUpdated : function(v, index, r){
23799 if(this.isSelected(r)){
23800 v.onRowSelect(index);
23806 * @param {Array} records The records to select
23807 * @param {Boolean} keepExisting (optional) True to keep existing selections
23809 selectRecords : function(records, keepExisting)
23812 this.clearSelections();
23814 var ds = this.grid.store;
23815 for(var i = 0, len = records.length; i < len; i++){
23816 this.selectRow(ds.indexOf(records[i]), true);
23821 * Gets the number of selected rows.
23824 getCount : function(){
23825 return this.selections.length;
23829 * Selects the first row in the grid.
23831 selectFirstRow : function(){
23836 * Select the last row.
23837 * @param {Boolean} keepExisting (optional) True to keep existing selections
23839 selectLastRow : function(keepExisting){
23840 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23841 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23845 * Selects the row immediately following the last selected row.
23846 * @param {Boolean} keepExisting (optional) True to keep existing selections
23848 selectNext : function(keepExisting)
23850 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23851 this.selectRow(this.last+1, keepExisting);
23852 this.grid.getView().focusRow(this.last);
23857 * Selects the row that precedes the last selected row.
23858 * @param {Boolean} keepExisting (optional) True to keep existing selections
23860 selectPrevious : function(keepExisting){
23862 this.selectRow(this.last-1, keepExisting);
23863 this.grid.getView().focusRow(this.last);
23868 * Returns the selected records
23869 * @return {Array} Array of selected records
23871 getSelections : function(){
23872 return [].concat(this.selections.items);
23876 * Returns the first selected record.
23879 getSelected : function(){
23880 return this.selections.itemAt(0);
23885 * Clears all selections.
23887 clearSelections : function(fast)
23893 var ds = this.grid.store;
23894 var s = this.selections;
23895 s.each(function(r){
23896 this.deselectRow(ds.indexOfId(r.id));
23900 this.selections.clear();
23907 * Selects all rows.
23909 selectAll : function(){
23913 this.selections.clear();
23914 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23915 this.selectRow(i, true);
23920 * Returns True if there is a selection.
23921 * @return {Boolean}
23923 hasSelection : function(){
23924 return this.selections.length > 0;
23928 * Returns True if the specified row is selected.
23929 * @param {Number/Record} record The record or index of the record to check
23930 * @return {Boolean}
23932 isSelected : function(index){
23933 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
23934 return (r && this.selections.key(r.id) ? true : false);
23938 * Returns True if the specified record id is selected.
23939 * @param {String} id The id of record to check
23940 * @return {Boolean}
23942 isIdSelected : function(id){
23943 return (this.selections.key(id) ? true : false);
23948 handleMouseDBClick : function(e, t){
23952 handleMouseDown : function(e, t)
23954 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
23955 if(this.isLocked() || rowIndex < 0 ){
23958 if(e.shiftKey && this.last !== false){
23959 var last = this.last;
23960 this.selectRange(last, rowIndex, e.ctrlKey);
23961 this.last = last; // reset the last
23965 var isSelected = this.isSelected(rowIndex);
23966 //Roo.log("select row:" + rowIndex);
23968 this.deselectRow(rowIndex);
23970 this.selectRow(rowIndex, true);
23974 if(e.button !== 0 && isSelected){
23975 alert('rowIndex 2: ' + rowIndex);
23976 view.focusRow(rowIndex);
23977 }else if(e.ctrlKey && isSelected){
23978 this.deselectRow(rowIndex);
23979 }else if(!isSelected){
23980 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
23981 view.focusRow(rowIndex);
23985 this.fireEvent("afterselectionchange", this);
23988 handleDragableRowClick : function(grid, rowIndex, e)
23990 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
23991 this.selectRow(rowIndex, false);
23992 grid.view.focusRow(rowIndex);
23993 this.fireEvent("afterselectionchange", this);
23998 * Selects multiple rows.
23999 * @param {Array} rows Array of the indexes of the row to select
24000 * @param {Boolean} keepExisting (optional) True to keep existing selections
24002 selectRows : function(rows, keepExisting){
24004 this.clearSelections();
24006 for(var i = 0, len = rows.length; i < len; i++){
24007 this.selectRow(rows[i], true);
24012 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24013 * @param {Number} startRow The index of the first row in the range
24014 * @param {Number} endRow The index of the last row in the range
24015 * @param {Boolean} keepExisting (optional) True to retain existing selections
24017 selectRange : function(startRow, endRow, keepExisting){
24022 this.clearSelections();
24024 if(startRow <= endRow){
24025 for(var i = startRow; i <= endRow; i++){
24026 this.selectRow(i, true);
24029 for(var i = startRow; i >= endRow; i--){
24030 this.selectRow(i, true);
24036 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24037 * @param {Number} startRow The index of the first row in the range
24038 * @param {Number} endRow The index of the last row in the range
24040 deselectRange : function(startRow, endRow, preventViewNotify){
24044 for(var i = startRow; i <= endRow; i++){
24045 this.deselectRow(i, preventViewNotify);
24051 * @param {Number} row The index of the row to select
24052 * @param {Boolean} keepExisting (optional) True to keep existing selections
24054 selectRow : function(index, keepExisting, preventViewNotify)
24056 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24059 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24060 if(!keepExisting || this.singleSelect){
24061 this.clearSelections();
24064 var r = this.grid.store.getAt(index);
24065 //console.log('selectRow - record id :' + r.id);
24067 this.selections.add(r);
24068 this.last = this.lastActive = index;
24069 if(!preventViewNotify){
24070 var proxy = new Roo.Element(
24071 this.grid.getRowDom(index)
24073 proxy.addClass('bg-info info');
24075 this.fireEvent("rowselect", this, index, r);
24076 this.fireEvent("selectionchange", this);
24082 * @param {Number} row The index of the row to deselect
24084 deselectRow : function(index, preventViewNotify)
24089 if(this.last == index){
24092 if(this.lastActive == index){
24093 this.lastActive = false;
24096 var r = this.grid.store.getAt(index);
24101 this.selections.remove(r);
24102 //.console.log('deselectRow - record id :' + r.id);
24103 if(!preventViewNotify){
24105 var proxy = new Roo.Element(
24106 this.grid.getRowDom(index)
24108 proxy.removeClass('bg-info info');
24110 this.fireEvent("rowdeselect", this, index);
24111 this.fireEvent("selectionchange", this);
24115 restoreLast : function(){
24117 this.last = this._last;
24122 acceptsNav : function(row, col, cm){
24123 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24127 onEditorKey : function(field, e){
24128 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24133 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24135 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24137 }else if(k == e.ENTER && !e.ctrlKey){
24141 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24143 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24145 }else if(k == e.ESC){
24149 g.startEditing(newCell[0], newCell[1]);
24155 * Ext JS Library 1.1.1
24156 * Copyright(c) 2006-2007, Ext JS, LLC.
24158 * Originally Released Under LGPL - original licence link has changed is not relivant.
24161 * <script type="text/javascript">
24165 * @class Roo.bootstrap.PagingToolbar
24166 * @extends Roo.bootstrap.NavSimplebar
24167 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24169 * Create a new PagingToolbar
24170 * @param {Object} config The config object
24171 * @param {Roo.data.Store} store
24173 Roo.bootstrap.PagingToolbar = function(config)
24175 // old args format still supported... - xtype is prefered..
24176 // created from xtype...
24178 this.ds = config.dataSource;
24180 if (config.store && !this.ds) {
24181 this.store= Roo.factory(config.store, Roo.data);
24182 this.ds = this.store;
24183 this.ds.xmodule = this.xmodule || false;
24186 this.toolbarItems = [];
24187 if (config.items) {
24188 this.toolbarItems = config.items;
24191 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24196 this.bind(this.ds);
24199 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24203 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24205 * @cfg {Roo.data.Store} dataSource
24206 * The underlying data store providing the paged data
24209 * @cfg {String/HTMLElement/Element} container
24210 * container The id or element that will contain the toolbar
24213 * @cfg {Boolean} displayInfo
24214 * True to display the displayMsg (defaults to false)
24217 * @cfg {Number} pageSize
24218 * The number of records to display per page (defaults to 20)
24222 * @cfg {String} displayMsg
24223 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24225 displayMsg : 'Displaying {0} - {1} of {2}',
24227 * @cfg {String} emptyMsg
24228 * The message to display when no records are found (defaults to "No data to display")
24230 emptyMsg : 'No data to display',
24232 * Customizable piece of the default paging text (defaults to "Page")
24235 beforePageText : "Page",
24237 * Customizable piece of the default paging text (defaults to "of %0")
24240 afterPageText : "of {0}",
24242 * Customizable piece of the default paging text (defaults to "First Page")
24245 firstText : "First Page",
24247 * Customizable piece of the default paging text (defaults to "Previous Page")
24250 prevText : "Previous Page",
24252 * Customizable piece of the default paging text (defaults to "Next Page")
24255 nextText : "Next Page",
24257 * Customizable piece of the default paging text (defaults to "Last Page")
24260 lastText : "Last Page",
24262 * Customizable piece of the default paging text (defaults to "Refresh")
24265 refreshText : "Refresh",
24269 onRender : function(ct, position)
24271 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24272 this.navgroup.parentId = this.id;
24273 this.navgroup.onRender(this.el, null);
24274 // add the buttons to the navgroup
24276 if(this.displayInfo){
24277 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24278 this.displayEl = this.el.select('.x-paging-info', true).first();
24279 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24280 // this.displayEl = navel.el.select('span',true).first();
24286 Roo.each(_this.buttons, function(e){ // this might need to use render????
24287 Roo.factory(e).onRender(_this.el, null);
24291 Roo.each(_this.toolbarItems, function(e) {
24292 _this.navgroup.addItem(e);
24296 this.first = this.navgroup.addItem({
24297 tooltip: this.firstText,
24299 icon : 'fa fa-backward',
24301 preventDefault: true,
24302 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24305 this.prev = this.navgroup.addItem({
24306 tooltip: this.prevText,
24308 icon : 'fa fa-step-backward',
24310 preventDefault: true,
24311 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24313 //this.addSeparator();
24316 var field = this.navgroup.addItem( {
24318 cls : 'x-paging-position',
24320 html : this.beforePageText +
24321 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24322 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24325 this.field = field.el.select('input', true).first();
24326 this.field.on("keydown", this.onPagingKeydown, this);
24327 this.field.on("focus", function(){this.dom.select();});
24330 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24331 //this.field.setHeight(18);
24332 //this.addSeparator();
24333 this.next = this.navgroup.addItem({
24334 tooltip: this.nextText,
24336 html : ' <i class="fa fa-step-forward">',
24338 preventDefault: true,
24339 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24341 this.last = this.navgroup.addItem({
24342 tooltip: this.lastText,
24343 icon : 'fa fa-forward',
24346 preventDefault: true,
24347 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24349 //this.addSeparator();
24350 this.loading = this.navgroup.addItem({
24351 tooltip: this.refreshText,
24352 icon: 'fa fa-refresh',
24353 preventDefault: true,
24354 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24360 updateInfo : function(){
24361 if(this.displayEl){
24362 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24363 var msg = count == 0 ?
24367 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24369 this.displayEl.update(msg);
24374 onLoad : function(ds, r, o)
24376 this.cursor = o.params ? o.params.start : 0;
24377 var d = this.getPageData(),
24382 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24383 this.field.dom.value = ap;
24384 this.first.setDisabled(ap == 1);
24385 this.prev.setDisabled(ap == 1);
24386 this.next.setDisabled(ap == ps);
24387 this.last.setDisabled(ap == ps);
24388 this.loading.enable();
24393 getPageData : function(){
24394 var total = this.ds.getTotalCount();
24397 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24398 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24403 onLoadError : function(){
24404 this.loading.enable();
24408 onPagingKeydown : function(e){
24409 var k = e.getKey();
24410 var d = this.getPageData();
24412 var v = this.field.dom.value, pageNum;
24413 if(!v || isNaN(pageNum = parseInt(v, 10))){
24414 this.field.dom.value = d.activePage;
24417 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24418 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24421 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))
24423 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24424 this.field.dom.value = pageNum;
24425 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24428 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24430 var v = this.field.dom.value, pageNum;
24431 var increment = (e.shiftKey) ? 10 : 1;
24432 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24435 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24436 this.field.dom.value = d.activePage;
24439 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24441 this.field.dom.value = parseInt(v, 10) + increment;
24442 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24443 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24450 beforeLoad : function(){
24452 this.loading.disable();
24457 onClick : function(which){
24466 ds.load({params:{start: 0, limit: this.pageSize}});
24469 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24472 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24475 var total = ds.getTotalCount();
24476 var extra = total % this.pageSize;
24477 var lastStart = extra ? (total - extra) : total-this.pageSize;
24478 ds.load({params:{start: lastStart, limit: this.pageSize}});
24481 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24487 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24488 * @param {Roo.data.Store} store The data store to unbind
24490 unbind : function(ds){
24491 ds.un("beforeload", this.beforeLoad, this);
24492 ds.un("load", this.onLoad, this);
24493 ds.un("loadexception", this.onLoadError, this);
24494 ds.un("remove", this.updateInfo, this);
24495 ds.un("add", this.updateInfo, this);
24496 this.ds = undefined;
24500 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24501 * @param {Roo.data.Store} store The data store to bind
24503 bind : function(ds){
24504 ds.on("beforeload", this.beforeLoad, this);
24505 ds.on("load", this.onLoad, this);
24506 ds.on("loadexception", this.onLoadError, this);
24507 ds.on("remove", this.updateInfo, this);
24508 ds.on("add", this.updateInfo, this);
24519 * @class Roo.bootstrap.MessageBar
24520 * @extends Roo.bootstrap.Component
24521 * Bootstrap MessageBar class
24522 * @cfg {String} html contents of the MessageBar
24523 * @cfg {String} weight (info | success | warning | danger) default info
24524 * @cfg {String} beforeClass insert the bar before the given class
24525 * @cfg {Boolean} closable (true | false) default false
24526 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24529 * Create a new Element
24530 * @param {Object} config The config object
24533 Roo.bootstrap.MessageBar = function(config){
24534 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24537 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24543 beforeClass: 'bootstrap-sticky-wrap',
24545 getAutoCreate : function(){
24549 cls: 'alert alert-dismissable alert-' + this.weight,
24554 html: this.html || ''
24560 cfg.cls += ' alert-messages-fixed';
24574 onRender : function(ct, position)
24576 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24579 var cfg = Roo.apply({}, this.getAutoCreate());
24583 cfg.cls += ' ' + this.cls;
24586 cfg.style = this.style;
24588 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24590 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24593 this.el.select('>button.close').on('click', this.hide, this);
24599 if (!this.rendered) {
24605 this.fireEvent('show', this);
24611 if (!this.rendered) {
24617 this.fireEvent('hide', this);
24620 update : function()
24622 // var e = this.el.dom.firstChild;
24624 // if(this.closable){
24625 // e = e.nextSibling;
24628 // e.data = this.html || '';
24630 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24646 * @class Roo.bootstrap.Graph
24647 * @extends Roo.bootstrap.Component
24648 * Bootstrap Graph class
24652 @cfg {String} graphtype bar | vbar | pie
24653 @cfg {number} g_x coodinator | centre x (pie)
24654 @cfg {number} g_y coodinator | centre y (pie)
24655 @cfg {number} g_r radius (pie)
24656 @cfg {number} g_height height of the chart (respected by all elements in the set)
24657 @cfg {number} g_width width of the chart (respected by all elements in the set)
24658 @cfg {Object} title The title of the chart
24661 -opts (object) options for the chart
24663 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24664 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24666 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.
24667 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24669 o stretch (boolean)
24671 -opts (object) options for the pie
24674 o startAngle (number)
24675 o endAngle (number)
24679 * Create a new Input
24680 * @param {Object} config The config object
24683 Roo.bootstrap.Graph = function(config){
24684 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24690 * The img click event for the img.
24691 * @param {Roo.EventObject} e
24697 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24708 //g_colors: this.colors,
24715 getAutoCreate : function(){
24726 onRender : function(ct,position){
24729 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24731 if (typeof(Raphael) == 'undefined') {
24732 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24736 this.raphael = Raphael(this.el.dom);
24738 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24739 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24740 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24741 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24743 r.text(160, 10, "Single Series Chart").attr(txtattr);
24744 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24745 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24746 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24748 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24749 r.barchart(330, 10, 300, 220, data1);
24750 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24751 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24754 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24755 // r.barchart(30, 30, 560, 250, xdata, {
24756 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24757 // axis : "0 0 1 1",
24758 // axisxlabels : xdata
24759 // //yvalues : cols,
24762 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24764 // this.load(null,xdata,{
24765 // axis : "0 0 1 1",
24766 // axisxlabels : xdata
24771 load : function(graphtype,xdata,opts)
24773 this.raphael.clear();
24775 graphtype = this.graphtype;
24780 var r = this.raphael,
24781 fin = function () {
24782 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24784 fout = function () {
24785 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24787 pfin = function() {
24788 this.sector.stop();
24789 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24792 this.label[0].stop();
24793 this.label[0].attr({ r: 7.5 });
24794 this.label[1].attr({ "font-weight": 800 });
24797 pfout = function() {
24798 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24801 this.label[0].animate({ r: 5 }, 500, "bounce");
24802 this.label[1].attr({ "font-weight": 400 });
24808 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24811 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24814 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24815 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24817 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24824 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24829 setTitle: function(o)
24834 initEvents: function() {
24837 this.el.on('click', this.onClick, this);
24841 onClick : function(e)
24843 Roo.log('img onclick');
24844 this.fireEvent('click', this, e);
24856 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24859 * @class Roo.bootstrap.dash.NumberBox
24860 * @extends Roo.bootstrap.Component
24861 * Bootstrap NumberBox class
24862 * @cfg {String} headline Box headline
24863 * @cfg {String} content Box content
24864 * @cfg {String} icon Box icon
24865 * @cfg {String} footer Footer text
24866 * @cfg {String} fhref Footer href
24869 * Create a new NumberBox
24870 * @param {Object} config The config object
24874 Roo.bootstrap.dash.NumberBox = function(config){
24875 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24879 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24888 getAutoCreate : function(){
24892 cls : 'small-box ',
24900 cls : 'roo-headline',
24901 html : this.headline
24905 cls : 'roo-content',
24906 html : this.content
24920 cls : 'ion ' + this.icon
24929 cls : 'small-box-footer',
24930 href : this.fhref || '#',
24934 cfg.cn.push(footer);
24941 onRender : function(ct,position){
24942 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
24949 setHeadline: function (value)
24951 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
24954 setFooter: function (value, href)
24956 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
24959 this.el.select('a.small-box-footer',true).first().attr('href', href);
24964 setContent: function (value)
24966 this.el.select('.roo-content',true).first().dom.innerHTML = value;
24969 initEvents: function()
24983 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24986 * @class Roo.bootstrap.dash.TabBox
24987 * @extends Roo.bootstrap.Component
24988 * Bootstrap TabBox class
24989 * @cfg {String} title Title of the TabBox
24990 * @cfg {String} icon Icon of the TabBox
24991 * @cfg {Boolean} showtabs (true|false) show the tabs default true
24992 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
24995 * Create a new TabBox
24996 * @param {Object} config The config object
25000 Roo.bootstrap.dash.TabBox = function(config){
25001 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25006 * When a pane is added
25007 * @param {Roo.bootstrap.dash.TabPane} pane
25011 * @event activatepane
25012 * When a pane is activated
25013 * @param {Roo.bootstrap.dash.TabPane} pane
25015 "activatepane" : true
25023 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25028 tabScrollable : false,
25030 getChildContainer : function()
25032 return this.el.select('.tab-content', true).first();
25035 getAutoCreate : function(){
25039 cls: 'pull-left header',
25047 cls: 'fa ' + this.icon
25053 cls: 'nav nav-tabs pull-right',
25059 if(this.tabScrollable){
25066 cls: 'nav nav-tabs pull-right',
25077 cls: 'nav-tabs-custom',
25082 cls: 'tab-content no-padding',
25090 initEvents : function()
25092 //Roo.log('add add pane handler');
25093 this.on('addpane', this.onAddPane, this);
25096 * Updates the box title
25097 * @param {String} html to set the title to.
25099 setTitle : function(value)
25101 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25103 onAddPane : function(pane)
25105 this.panes.push(pane);
25106 //Roo.log('addpane');
25108 // tabs are rendere left to right..
25109 if(!this.showtabs){
25113 var ctr = this.el.select('.nav-tabs', true).first();
25116 var existing = ctr.select('.nav-tab',true);
25117 var qty = existing.getCount();;
25120 var tab = ctr.createChild({
25122 cls : 'nav-tab' + (qty ? '' : ' active'),
25130 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25133 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25135 pane.el.addClass('active');
25140 onTabClick : function(ev,un,ob,pane)
25142 //Roo.log('tab - prev default');
25143 ev.preventDefault();
25146 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25147 pane.tab.addClass('active');
25148 //Roo.log(pane.title);
25149 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25150 // technically we should have a deactivate event.. but maybe add later.
25151 // and it should not de-activate the selected tab...
25152 this.fireEvent('activatepane', pane);
25153 pane.el.addClass('active');
25154 pane.fireEvent('activate');
25159 getActivePane : function()
25162 Roo.each(this.panes, function(p) {
25163 if(p.el.hasClass('active')){
25184 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25186 * @class Roo.bootstrap.TabPane
25187 * @extends Roo.bootstrap.Component
25188 * Bootstrap TabPane class
25189 * @cfg {Boolean} active (false | true) Default false
25190 * @cfg {String} title title of panel
25194 * Create a new TabPane
25195 * @param {Object} config The config object
25198 Roo.bootstrap.dash.TabPane = function(config){
25199 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25205 * When a pane is activated
25206 * @param {Roo.bootstrap.dash.TabPane} pane
25213 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25218 // the tabBox that this is attached to.
25221 getAutoCreate : function()
25229 cfg.cls += ' active';
25234 initEvents : function()
25236 //Roo.log('trigger add pane handler');
25237 this.parent().fireEvent('addpane', this)
25241 * Updates the tab title
25242 * @param {String} html to set the title to.
25244 setTitle: function(str)
25250 this.tab.select('a', true).first().dom.innerHTML = str;
25267 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25270 * @class Roo.bootstrap.menu.Menu
25271 * @extends Roo.bootstrap.Component
25272 * Bootstrap Menu class - container for Menu
25273 * @cfg {String} html Text of the menu
25274 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25275 * @cfg {String} icon Font awesome icon
25276 * @cfg {String} pos Menu align to (top | bottom) default bottom
25280 * Create a new Menu
25281 * @param {Object} config The config object
25285 Roo.bootstrap.menu.Menu = function(config){
25286 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25290 * @event beforeshow
25291 * Fires before this menu is displayed
25292 * @param {Roo.bootstrap.menu.Menu} this
25296 * @event beforehide
25297 * Fires before this menu is hidden
25298 * @param {Roo.bootstrap.menu.Menu} this
25303 * Fires after this menu is displayed
25304 * @param {Roo.bootstrap.menu.Menu} this
25309 * Fires after this menu is hidden
25310 * @param {Roo.bootstrap.menu.Menu} this
25315 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25316 * @param {Roo.bootstrap.menu.Menu} this
25317 * @param {Roo.EventObject} e
25324 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25328 weight : 'default',
25333 getChildContainer : function() {
25334 if(this.isSubMenu){
25338 return this.el.select('ul.dropdown-menu', true).first();
25341 getAutoCreate : function()
25346 cls : 'roo-menu-text',
25354 cls : 'fa ' + this.icon
25365 cls : 'dropdown-button btn btn-' + this.weight,
25370 cls : 'dropdown-toggle btn btn-' + this.weight,
25380 cls : 'dropdown-menu'
25386 if(this.pos == 'top'){
25387 cfg.cls += ' dropup';
25390 if(this.isSubMenu){
25393 cls : 'dropdown-menu'
25400 onRender : function(ct, position)
25402 this.isSubMenu = ct.hasClass('dropdown-submenu');
25404 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25407 initEvents : function()
25409 if(this.isSubMenu){
25413 this.hidden = true;
25415 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25416 this.triggerEl.on('click', this.onTriggerPress, this);
25418 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25419 this.buttonEl.on('click', this.onClick, this);
25425 if(this.isSubMenu){
25429 return this.el.select('ul.dropdown-menu', true).first();
25432 onClick : function(e)
25434 this.fireEvent("click", this, e);
25437 onTriggerPress : function(e)
25439 if (this.isVisible()) {
25446 isVisible : function(){
25447 return !this.hidden;
25452 this.fireEvent("beforeshow", this);
25454 this.hidden = false;
25455 this.el.addClass('open');
25457 Roo.get(document).on("mouseup", this.onMouseUp, this);
25459 this.fireEvent("show", this);
25466 this.fireEvent("beforehide", this);
25468 this.hidden = true;
25469 this.el.removeClass('open');
25471 Roo.get(document).un("mouseup", this.onMouseUp);
25473 this.fireEvent("hide", this);
25476 onMouseUp : function()
25490 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25493 * @class Roo.bootstrap.menu.Item
25494 * @extends Roo.bootstrap.Component
25495 * Bootstrap MenuItem class
25496 * @cfg {Boolean} submenu (true | false) default false
25497 * @cfg {String} html text of the item
25498 * @cfg {String} href the link
25499 * @cfg {Boolean} disable (true | false) default false
25500 * @cfg {Boolean} preventDefault (true | false) default true
25501 * @cfg {String} icon Font awesome icon
25502 * @cfg {String} pos Submenu align to (left | right) default right
25506 * Create a new Item
25507 * @param {Object} config The config object
25511 Roo.bootstrap.menu.Item = function(config){
25512 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25516 * Fires when the mouse is hovering over this menu
25517 * @param {Roo.bootstrap.menu.Item} this
25518 * @param {Roo.EventObject} e
25523 * Fires when the mouse exits this menu
25524 * @param {Roo.bootstrap.menu.Item} this
25525 * @param {Roo.EventObject} e
25531 * The raw click event for the entire grid.
25532 * @param {Roo.EventObject} e
25538 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25543 preventDefault: true,
25548 getAutoCreate : function()
25553 cls : 'roo-menu-item-text',
25561 cls : 'fa ' + this.icon
25570 href : this.href || '#',
25577 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25581 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25583 if(this.pos == 'left'){
25584 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25591 initEvents : function()
25593 this.el.on('mouseover', this.onMouseOver, this);
25594 this.el.on('mouseout', this.onMouseOut, this);
25596 this.el.select('a', true).first().on('click', this.onClick, this);
25600 onClick : function(e)
25602 if(this.preventDefault){
25603 e.preventDefault();
25606 this.fireEvent("click", this, e);
25609 onMouseOver : function(e)
25611 if(this.submenu && this.pos == 'left'){
25612 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25615 this.fireEvent("mouseover", this, e);
25618 onMouseOut : function(e)
25620 this.fireEvent("mouseout", this, e);
25632 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25635 * @class Roo.bootstrap.menu.Separator
25636 * @extends Roo.bootstrap.Component
25637 * Bootstrap Separator class
25640 * Create a new Separator
25641 * @param {Object} config The config object
25645 Roo.bootstrap.menu.Separator = function(config){
25646 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25649 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25651 getAutoCreate : function(){
25672 * @class Roo.bootstrap.Tooltip
25673 * Bootstrap Tooltip class
25674 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25675 * to determine which dom element triggers the tooltip.
25677 * It needs to add support for additional attributes like tooltip-position
25680 * Create a new Toolti
25681 * @param {Object} config The config object
25684 Roo.bootstrap.Tooltip = function(config){
25685 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25687 this.alignment = Roo.bootstrap.Tooltip.alignment;
25689 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25690 this.alignment = config.alignment;
25695 Roo.apply(Roo.bootstrap.Tooltip, {
25697 * @function init initialize tooltip monitoring.
25701 currentTip : false,
25702 currentRegion : false,
25708 Roo.get(document).on('mouseover', this.enter ,this);
25709 Roo.get(document).on('mouseout', this.leave, this);
25712 this.currentTip = new Roo.bootstrap.Tooltip();
25715 enter : function(ev)
25717 var dom = ev.getTarget();
25719 //Roo.log(['enter',dom]);
25720 var el = Roo.fly(dom);
25721 if (this.currentEl) {
25723 //Roo.log(this.currentEl);
25724 //Roo.log(this.currentEl.contains(dom));
25725 if (this.currentEl == el) {
25728 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25734 if (this.currentTip.el) {
25735 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25739 if(!el || el.dom == document){
25745 // you can not look for children, as if el is the body.. then everythign is the child..
25746 if (!el.attr('tooltip')) { //
25747 if (!el.select("[tooltip]").elements.length) {
25750 // is the mouse over this child...?
25751 bindEl = el.select("[tooltip]").first();
25752 var xy = ev.getXY();
25753 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25754 //Roo.log("not in region.");
25757 //Roo.log("child element over..");
25760 this.currentEl = bindEl;
25761 this.currentTip.bind(bindEl);
25762 this.currentRegion = Roo.lib.Region.getRegion(dom);
25763 this.currentTip.enter();
25766 leave : function(ev)
25768 var dom = ev.getTarget();
25769 //Roo.log(['leave',dom]);
25770 if (!this.currentEl) {
25775 if (dom != this.currentEl.dom) {
25778 var xy = ev.getXY();
25779 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25782 // only activate leave if mouse cursor is outside... bounding box..
25787 if (this.currentTip) {
25788 this.currentTip.leave();
25790 //Roo.log('clear currentEl');
25791 this.currentEl = false;
25796 'left' : ['r-l', [-2,0], 'right'],
25797 'right' : ['l-r', [2,0], 'left'],
25798 'bottom' : ['t-b', [0,2], 'top'],
25799 'top' : [ 'b-t', [0,-2], 'bottom']
25805 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25810 delay : null, // can be { show : 300 , hide: 500}
25814 hoverState : null, //???
25816 placement : 'bottom',
25820 getAutoCreate : function(){
25827 cls : 'tooltip-arrow'
25830 cls : 'tooltip-inner'
25837 bind : function(el)
25843 enter : function () {
25845 if (this.timeout != null) {
25846 clearTimeout(this.timeout);
25849 this.hoverState = 'in';
25850 //Roo.log("enter - show");
25851 if (!this.delay || !this.delay.show) {
25856 this.timeout = setTimeout(function () {
25857 if (_t.hoverState == 'in') {
25860 }, this.delay.show);
25864 clearTimeout(this.timeout);
25866 this.hoverState = 'out';
25867 if (!this.delay || !this.delay.hide) {
25873 this.timeout = setTimeout(function () {
25874 //Roo.log("leave - timeout");
25876 if (_t.hoverState == 'out') {
25878 Roo.bootstrap.Tooltip.currentEl = false;
25883 show : function (msg)
25886 this.render(document.body);
25889 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25891 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25893 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25895 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25897 var placement = typeof this.placement == 'function' ?
25898 this.placement.call(this, this.el, on_el) :
25901 var autoToken = /\s?auto?\s?/i;
25902 var autoPlace = autoToken.test(placement);
25904 placement = placement.replace(autoToken, '') || 'top';
25908 //this.el.setXY([0,0]);
25910 //this.el.dom.style.display='block';
25912 //this.el.appendTo(on_el);
25914 var p = this.getPosition();
25915 var box = this.el.getBox();
25921 var align = this.alignment[placement];
25923 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25925 if(placement == 'top' || placement == 'bottom'){
25927 placement = 'right';
25930 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25931 placement = 'left';
25934 var scroll = Roo.select('body', true).first().getScroll();
25936 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
25942 this.el.alignTo(this.bindEl, align[0],align[1]);
25943 //var arrow = this.el.select('.arrow',true).first();
25944 //arrow.set(align[2],
25946 this.el.addClass(placement);
25948 this.el.addClass('in fade');
25950 this.hoverState = null;
25952 if (this.el.hasClass('fade')) {
25963 //this.el.setXY([0,0]);
25964 this.el.removeClass('in');
25980 * @class Roo.bootstrap.LocationPicker
25981 * @extends Roo.bootstrap.Component
25982 * Bootstrap LocationPicker class
25983 * @cfg {Number} latitude Position when init default 0
25984 * @cfg {Number} longitude Position when init default 0
25985 * @cfg {Number} zoom default 15
25986 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
25987 * @cfg {Boolean} mapTypeControl default false
25988 * @cfg {Boolean} disableDoubleClickZoom default false
25989 * @cfg {Boolean} scrollwheel default true
25990 * @cfg {Boolean} streetViewControl default false
25991 * @cfg {Number} radius default 0
25992 * @cfg {String} locationName
25993 * @cfg {Boolean} draggable default true
25994 * @cfg {Boolean} enableAutocomplete default false
25995 * @cfg {Boolean} enableReverseGeocode default true
25996 * @cfg {String} markerTitle
25999 * Create a new LocationPicker
26000 * @param {Object} config The config object
26004 Roo.bootstrap.LocationPicker = function(config){
26006 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26011 * Fires when the picker initialized.
26012 * @param {Roo.bootstrap.LocationPicker} this
26013 * @param {Google Location} location
26017 * @event positionchanged
26018 * Fires when the picker position changed.
26019 * @param {Roo.bootstrap.LocationPicker} this
26020 * @param {Google Location} location
26022 positionchanged : true,
26025 * Fires when the map resize.
26026 * @param {Roo.bootstrap.LocationPicker} this
26031 * Fires when the map show.
26032 * @param {Roo.bootstrap.LocationPicker} this
26037 * Fires when the map hide.
26038 * @param {Roo.bootstrap.LocationPicker} this
26043 * Fires when click the map.
26044 * @param {Roo.bootstrap.LocationPicker} this
26045 * @param {Map event} e
26049 * @event mapRightClick
26050 * Fires when right click the map.
26051 * @param {Roo.bootstrap.LocationPicker} this
26052 * @param {Map event} e
26054 mapRightClick : true,
26056 * @event markerClick
26057 * Fires when click the marker.
26058 * @param {Roo.bootstrap.LocationPicker} this
26059 * @param {Map event} e
26061 markerClick : true,
26063 * @event markerRightClick
26064 * Fires when right click the marker.
26065 * @param {Roo.bootstrap.LocationPicker} this
26066 * @param {Map event} e
26068 markerRightClick : true,
26070 * @event OverlayViewDraw
26071 * Fires when OverlayView Draw
26072 * @param {Roo.bootstrap.LocationPicker} this
26074 OverlayViewDraw : true,
26076 * @event OverlayViewOnAdd
26077 * Fires when OverlayView Draw
26078 * @param {Roo.bootstrap.LocationPicker} this
26080 OverlayViewOnAdd : true,
26082 * @event OverlayViewOnRemove
26083 * Fires when OverlayView Draw
26084 * @param {Roo.bootstrap.LocationPicker} this
26086 OverlayViewOnRemove : true,
26088 * @event OverlayViewShow
26089 * Fires when OverlayView Draw
26090 * @param {Roo.bootstrap.LocationPicker} this
26091 * @param {Pixel} cpx
26093 OverlayViewShow : true,
26095 * @event OverlayViewHide
26096 * Fires when OverlayView Draw
26097 * @param {Roo.bootstrap.LocationPicker} this
26099 OverlayViewHide : true,
26101 * @event loadexception
26102 * Fires when load google lib failed.
26103 * @param {Roo.bootstrap.LocationPicker} this
26105 loadexception : true
26110 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26112 gMapContext: false,
26118 mapTypeControl: false,
26119 disableDoubleClickZoom: false,
26121 streetViewControl: false,
26125 enableAutocomplete: false,
26126 enableReverseGeocode: true,
26129 getAutoCreate: function()
26134 cls: 'roo-location-picker'
26140 initEvents: function(ct, position)
26142 if(!this.el.getWidth() || this.isApplied()){
26146 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26151 initial: function()
26153 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26154 this.fireEvent('loadexception', this);
26158 if(!this.mapTypeId){
26159 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26162 this.gMapContext = this.GMapContext();
26164 this.initOverlayView();
26166 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26170 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26171 _this.setPosition(_this.gMapContext.marker.position);
26174 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26175 _this.fireEvent('mapClick', this, event);
26179 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26180 _this.fireEvent('mapRightClick', this, event);
26184 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26185 _this.fireEvent('markerClick', this, event);
26189 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26190 _this.fireEvent('markerRightClick', this, event);
26194 this.setPosition(this.gMapContext.location);
26196 this.fireEvent('initial', this, this.gMapContext.location);
26199 initOverlayView: function()
26203 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26207 _this.fireEvent('OverlayViewDraw', _this);
26212 _this.fireEvent('OverlayViewOnAdd', _this);
26215 onRemove: function()
26217 _this.fireEvent('OverlayViewOnRemove', _this);
26220 show: function(cpx)
26222 _this.fireEvent('OverlayViewShow', _this, cpx);
26227 _this.fireEvent('OverlayViewHide', _this);
26233 fromLatLngToContainerPixel: function(event)
26235 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26238 isApplied: function()
26240 return this.getGmapContext() == false ? false : true;
26243 getGmapContext: function()
26245 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26248 GMapContext: function()
26250 var position = new google.maps.LatLng(this.latitude, this.longitude);
26252 var _map = new google.maps.Map(this.el.dom, {
26255 mapTypeId: this.mapTypeId,
26256 mapTypeControl: this.mapTypeControl,
26257 disableDoubleClickZoom: this.disableDoubleClickZoom,
26258 scrollwheel: this.scrollwheel,
26259 streetViewControl: this.streetViewControl,
26260 locationName: this.locationName,
26261 draggable: this.draggable,
26262 enableAutocomplete: this.enableAutocomplete,
26263 enableReverseGeocode: this.enableReverseGeocode
26266 var _marker = new google.maps.Marker({
26267 position: position,
26269 title: this.markerTitle,
26270 draggable: this.draggable
26277 location: position,
26278 radius: this.radius,
26279 locationName: this.locationName,
26280 addressComponents: {
26281 formatted_address: null,
26282 addressLine1: null,
26283 addressLine2: null,
26285 streetNumber: null,
26289 stateOrProvince: null
26292 domContainer: this.el.dom,
26293 geodecoder: new google.maps.Geocoder()
26297 drawCircle: function(center, radius, options)
26299 if (this.gMapContext.circle != null) {
26300 this.gMapContext.circle.setMap(null);
26304 options = Roo.apply({}, options, {
26305 strokeColor: "#0000FF",
26306 strokeOpacity: .35,
26308 fillColor: "#0000FF",
26312 options.map = this.gMapContext.map;
26313 options.radius = radius;
26314 options.center = center;
26315 this.gMapContext.circle = new google.maps.Circle(options);
26316 return this.gMapContext.circle;
26322 setPosition: function(location)
26324 this.gMapContext.location = location;
26325 this.gMapContext.marker.setPosition(location);
26326 this.gMapContext.map.panTo(location);
26327 this.drawCircle(location, this.gMapContext.radius, {});
26331 if (this.gMapContext.settings.enableReverseGeocode) {
26332 this.gMapContext.geodecoder.geocode({
26333 latLng: this.gMapContext.location
26334 }, function(results, status) {
26336 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26337 _this.gMapContext.locationName = results[0].formatted_address;
26338 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26340 _this.fireEvent('positionchanged', this, location);
26347 this.fireEvent('positionchanged', this, location);
26352 google.maps.event.trigger(this.gMapContext.map, "resize");
26354 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26356 this.fireEvent('resize', this);
26359 setPositionByLatLng: function(latitude, longitude)
26361 this.setPosition(new google.maps.LatLng(latitude, longitude));
26364 getCurrentPosition: function()
26367 latitude: this.gMapContext.location.lat(),
26368 longitude: this.gMapContext.location.lng()
26372 getAddressName: function()
26374 return this.gMapContext.locationName;
26377 getAddressComponents: function()
26379 return this.gMapContext.addressComponents;
26382 address_component_from_google_geocode: function(address_components)
26386 for (var i = 0; i < address_components.length; i++) {
26387 var component = address_components[i];
26388 if (component.types.indexOf("postal_code") >= 0) {
26389 result.postalCode = component.short_name;
26390 } else if (component.types.indexOf("street_number") >= 0) {
26391 result.streetNumber = component.short_name;
26392 } else if (component.types.indexOf("route") >= 0) {
26393 result.streetName = component.short_name;
26394 } else if (component.types.indexOf("neighborhood") >= 0) {
26395 result.city = component.short_name;
26396 } else if (component.types.indexOf("locality") >= 0) {
26397 result.city = component.short_name;
26398 } else if (component.types.indexOf("sublocality") >= 0) {
26399 result.district = component.short_name;
26400 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26401 result.stateOrProvince = component.short_name;
26402 } else if (component.types.indexOf("country") >= 0) {
26403 result.country = component.short_name;
26407 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26408 result.addressLine2 = "";
26412 setZoomLevel: function(zoom)
26414 this.gMapContext.map.setZoom(zoom);
26427 this.fireEvent('show', this);
26438 this.fireEvent('hide', this);
26443 Roo.apply(Roo.bootstrap.LocationPicker, {
26445 OverlayView : function(map, options)
26447 options = options || {};
26461 * @class Roo.bootstrap.Alert
26462 * @extends Roo.bootstrap.Component
26463 * Bootstrap Alert class
26464 * @cfg {String} title The title of alert
26465 * @cfg {String} html The content of alert
26466 * @cfg {String} weight ( success | info | warning | danger )
26467 * @cfg {String} faicon font-awesomeicon
26470 * Create a new alert
26471 * @param {Object} config The config object
26475 Roo.bootstrap.Alert = function(config){
26476 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26480 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26487 getAutoCreate : function()
26496 cls : 'roo-alert-icon'
26501 cls : 'roo-alert-title',
26506 cls : 'roo-alert-text',
26513 cfg.cn[0].cls += ' fa ' + this.faicon;
26517 cfg.cls += ' alert-' + this.weight;
26523 initEvents: function()
26525 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26528 setTitle : function(str)
26530 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26533 setText : function(str)
26535 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26538 setWeight : function(weight)
26541 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26544 this.weight = weight;
26546 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26549 setIcon : function(icon)
26552 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26555 this.faicon = icon;
26557 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26578 * @class Roo.bootstrap.UploadCropbox
26579 * @extends Roo.bootstrap.Component
26580 * Bootstrap UploadCropbox class
26581 * @cfg {String} emptyText show when image has been loaded
26582 * @cfg {String} rotateNotify show when image too small to rotate
26583 * @cfg {Number} errorTimeout default 3000
26584 * @cfg {Number} minWidth default 300
26585 * @cfg {Number} minHeight default 300
26586 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26587 * @cfg {Boolean} isDocument (true|false) default false
26588 * @cfg {String} url action url
26589 * @cfg {String} paramName default 'imageUpload'
26590 * @cfg {String} method default POST
26591 * @cfg {Boolean} loadMask (true|false) default true
26592 * @cfg {Boolean} loadingText default 'Loading...'
26595 * Create a new UploadCropbox
26596 * @param {Object} config The config object
26599 Roo.bootstrap.UploadCropbox = function(config){
26600 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26604 * @event beforeselectfile
26605 * Fire before select file
26606 * @param {Roo.bootstrap.UploadCropbox} this
26608 "beforeselectfile" : true,
26611 * Fire after initEvent
26612 * @param {Roo.bootstrap.UploadCropbox} this
26617 * Fire after initEvent
26618 * @param {Roo.bootstrap.UploadCropbox} this
26619 * @param {String} data
26624 * Fire when preparing the file data
26625 * @param {Roo.bootstrap.UploadCropbox} this
26626 * @param {Object} file
26631 * Fire when get exception
26632 * @param {Roo.bootstrap.UploadCropbox} this
26633 * @param {XMLHttpRequest} xhr
26635 "exception" : true,
26637 * @event beforeloadcanvas
26638 * Fire before load the canvas
26639 * @param {Roo.bootstrap.UploadCropbox} this
26640 * @param {String} src
26642 "beforeloadcanvas" : true,
26645 * Fire when trash image
26646 * @param {Roo.bootstrap.UploadCropbox} this
26651 * Fire when download the image
26652 * @param {Roo.bootstrap.UploadCropbox} this
26656 * @event footerbuttonclick
26657 * Fire when footerbuttonclick
26658 * @param {Roo.bootstrap.UploadCropbox} this
26659 * @param {String} type
26661 "footerbuttonclick" : true,
26665 * @param {Roo.bootstrap.UploadCropbox} this
26670 * Fire when rotate the image
26671 * @param {Roo.bootstrap.UploadCropbox} this
26672 * @param {String} pos
26677 * Fire when inspect the file
26678 * @param {Roo.bootstrap.UploadCropbox} this
26679 * @param {Object} file
26684 * Fire when xhr upload the file
26685 * @param {Roo.bootstrap.UploadCropbox} this
26686 * @param {Object} data
26691 * Fire when arrange the file data
26692 * @param {Roo.bootstrap.UploadCropbox} this
26693 * @param {Object} formData
26698 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26701 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26703 emptyText : 'Click to upload image',
26704 rotateNotify : 'Image is too small to rotate',
26705 errorTimeout : 3000,
26719 cropType : 'image/jpeg',
26721 canvasLoaded : false,
26722 isDocument : false,
26724 paramName : 'imageUpload',
26726 loadingText : 'Loading...',
26729 getAutoCreate : function()
26733 cls : 'roo-upload-cropbox',
26737 cls : 'roo-upload-cropbox-selector',
26742 cls : 'roo-upload-cropbox-body',
26743 style : 'cursor:pointer',
26747 cls : 'roo-upload-cropbox-preview'
26751 cls : 'roo-upload-cropbox-thumb'
26755 cls : 'roo-upload-cropbox-empty-notify',
26756 html : this.emptyText
26760 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26761 html : this.rotateNotify
26767 cls : 'roo-upload-cropbox-footer',
26770 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26780 onRender : function(ct, position)
26782 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26784 if (this.buttons.length) {
26786 Roo.each(this.buttons, function(bb) {
26788 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26790 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26796 this.maskEl = this.el;
26800 initEvents : function()
26802 this.urlAPI = (window.createObjectURL && window) ||
26803 (window.URL && URL.revokeObjectURL && URL) ||
26804 (window.webkitURL && webkitURL);
26806 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26807 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26809 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26810 this.selectorEl.hide();
26812 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26813 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26815 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26816 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26817 this.thumbEl.hide();
26819 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26820 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26822 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26823 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26824 this.errorEl.hide();
26826 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26827 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26828 this.footerEl.hide();
26830 this.setThumbBoxSize();
26836 this.fireEvent('initial', this);
26843 window.addEventListener("resize", function() { _this.resize(); } );
26845 this.bodyEl.on('click', this.beforeSelectFile, this);
26848 this.bodyEl.on('touchstart', this.onTouchStart, this);
26849 this.bodyEl.on('touchmove', this.onTouchMove, this);
26850 this.bodyEl.on('touchend', this.onTouchEnd, this);
26854 this.bodyEl.on('mousedown', this.onMouseDown, this);
26855 this.bodyEl.on('mousemove', this.onMouseMove, this);
26856 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26857 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26858 Roo.get(document).on('mouseup', this.onMouseUp, this);
26861 this.selectorEl.on('change', this.onFileSelected, this);
26867 this.baseScale = 1;
26869 this.baseRotate = 1;
26870 this.dragable = false;
26871 this.pinching = false;
26874 this.cropData = false;
26875 this.notifyEl.dom.innerHTML = this.emptyText;
26877 this.selectorEl.dom.value = '';
26881 resize : function()
26883 if(this.fireEvent('resize', this) != false){
26884 this.setThumbBoxPosition();
26885 this.setCanvasPosition();
26889 onFooterButtonClick : function(e, el, o, type)
26892 case 'rotate-left' :
26893 this.onRotateLeft(e);
26895 case 'rotate-right' :
26896 this.onRotateRight(e);
26899 this.beforeSelectFile(e);
26914 this.fireEvent('footerbuttonclick', this, type);
26917 beforeSelectFile : function(e)
26919 e.preventDefault();
26921 if(this.fireEvent('beforeselectfile', this) != false){
26922 this.selectorEl.dom.click();
26926 onFileSelected : function(e)
26928 e.preventDefault();
26930 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
26934 var file = this.selectorEl.dom.files[0];
26936 if(this.fireEvent('inspect', this, file) != false){
26937 this.prepare(file);
26942 trash : function(e)
26944 this.fireEvent('trash', this);
26947 download : function(e)
26949 this.fireEvent('download', this);
26952 loadCanvas : function(src)
26954 if(this.fireEvent('beforeloadcanvas', this, src) != false){
26958 this.imageEl = document.createElement('img');
26962 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
26964 this.imageEl.src = src;
26968 onLoadCanvas : function()
26970 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
26971 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
26973 this.bodyEl.un('click', this.beforeSelectFile, this);
26975 this.notifyEl.hide();
26976 this.thumbEl.show();
26977 this.footerEl.show();
26979 this.baseRotateLevel();
26981 if(this.isDocument){
26982 this.setThumbBoxSize();
26985 this.setThumbBoxPosition();
26987 this.baseScaleLevel();
26993 this.canvasLoaded = true;
26996 this.maskEl.unmask();
27001 setCanvasPosition : function()
27003 if(!this.canvasEl){
27007 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27008 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27010 this.previewEl.setLeft(pw);
27011 this.previewEl.setTop(ph);
27015 onMouseDown : function(e)
27019 this.dragable = true;
27020 this.pinching = false;
27022 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27023 this.dragable = false;
27027 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27028 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27032 onMouseMove : function(e)
27036 if(!this.canvasLoaded){
27040 if (!this.dragable){
27044 var minX = Math.ceil(this.thumbEl.getLeft(true));
27045 var minY = Math.ceil(this.thumbEl.getTop(true));
27047 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27048 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27050 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27051 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27053 x = x - this.mouseX;
27054 y = y - this.mouseY;
27056 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27057 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27059 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27060 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27062 this.previewEl.setLeft(bgX);
27063 this.previewEl.setTop(bgY);
27065 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27066 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27069 onMouseUp : function(e)
27073 this.dragable = false;
27076 onMouseWheel : function(e)
27080 this.startScale = this.scale;
27082 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27084 if(!this.zoomable()){
27085 this.scale = this.startScale;
27094 zoomable : function()
27096 var minScale = this.thumbEl.getWidth() / this.minWidth;
27098 if(this.minWidth < this.minHeight){
27099 minScale = this.thumbEl.getHeight() / this.minHeight;
27102 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27103 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27107 (this.rotate == 0 || this.rotate == 180) &&
27109 width > this.imageEl.OriginWidth ||
27110 height > this.imageEl.OriginHeight ||
27111 (width < this.minWidth && height < this.minHeight)
27119 (this.rotate == 90 || this.rotate == 270) &&
27121 width > this.imageEl.OriginWidth ||
27122 height > this.imageEl.OriginHeight ||
27123 (width < this.minHeight && height < this.minWidth)
27130 !this.isDocument &&
27131 (this.rotate == 0 || this.rotate == 180) &&
27133 width < this.minWidth ||
27134 width > this.imageEl.OriginWidth ||
27135 height < this.minHeight ||
27136 height > this.imageEl.OriginHeight
27143 !this.isDocument &&
27144 (this.rotate == 90 || this.rotate == 270) &&
27146 width < this.minHeight ||
27147 width > this.imageEl.OriginWidth ||
27148 height < this.minWidth ||
27149 height > this.imageEl.OriginHeight
27159 onRotateLeft : function(e)
27161 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27163 var minScale = this.thumbEl.getWidth() / this.minWidth;
27165 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27166 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27168 this.startScale = this.scale;
27170 while (this.getScaleLevel() < minScale){
27172 this.scale = this.scale + 1;
27174 if(!this.zoomable()){
27179 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27180 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27185 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27192 this.scale = this.startScale;
27194 this.onRotateFail();
27199 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27201 if(this.isDocument){
27202 this.setThumbBoxSize();
27203 this.setThumbBoxPosition();
27204 this.setCanvasPosition();
27209 this.fireEvent('rotate', this, 'left');
27213 onRotateRight : function(e)
27215 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27217 var minScale = this.thumbEl.getWidth() / this.minWidth;
27219 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27220 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27222 this.startScale = this.scale;
27224 while (this.getScaleLevel() < minScale){
27226 this.scale = this.scale + 1;
27228 if(!this.zoomable()){
27233 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27234 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27239 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27246 this.scale = this.startScale;
27248 this.onRotateFail();
27253 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27255 if(this.isDocument){
27256 this.setThumbBoxSize();
27257 this.setThumbBoxPosition();
27258 this.setCanvasPosition();
27263 this.fireEvent('rotate', this, 'right');
27266 onRotateFail : function()
27268 this.errorEl.show(true);
27272 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27277 this.previewEl.dom.innerHTML = '';
27279 var canvasEl = document.createElement("canvas");
27281 var contextEl = canvasEl.getContext("2d");
27283 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27284 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27285 var center = this.imageEl.OriginWidth / 2;
27287 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27288 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27289 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27290 center = this.imageEl.OriginHeight / 2;
27293 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27295 contextEl.translate(center, center);
27296 contextEl.rotate(this.rotate * Math.PI / 180);
27298 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27300 this.canvasEl = document.createElement("canvas");
27302 this.contextEl = this.canvasEl.getContext("2d");
27304 switch (this.rotate) {
27307 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27308 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27310 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27315 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27316 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27318 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27319 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);
27323 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27328 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27329 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27331 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27332 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);
27336 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);
27341 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27342 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27344 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27345 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27349 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);
27356 this.previewEl.appendChild(this.canvasEl);
27358 this.setCanvasPosition();
27363 if(!this.canvasLoaded){
27367 var imageCanvas = document.createElement("canvas");
27369 var imageContext = imageCanvas.getContext("2d");
27371 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27372 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27374 var center = imageCanvas.width / 2;
27376 imageContext.translate(center, center);
27378 imageContext.rotate(this.rotate * Math.PI / 180);
27380 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27382 var canvas = document.createElement("canvas");
27384 var context = canvas.getContext("2d");
27386 canvas.width = this.minWidth;
27387 canvas.height = this.minHeight;
27389 switch (this.rotate) {
27392 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27393 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27395 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27396 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27398 var targetWidth = this.minWidth - 2 * x;
27399 var targetHeight = this.minHeight - 2 * y;
27403 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27404 scale = targetWidth / width;
27407 if(x > 0 && y == 0){
27408 scale = targetHeight / height;
27411 if(x > 0 && y > 0){
27412 scale = targetWidth / width;
27414 if(width < height){
27415 scale = targetHeight / height;
27419 context.scale(scale, scale);
27421 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27422 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27424 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27425 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27427 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27432 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27433 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27435 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27436 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27438 var targetWidth = this.minWidth - 2 * x;
27439 var targetHeight = this.minHeight - 2 * y;
27443 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27444 scale = targetWidth / width;
27447 if(x > 0 && y == 0){
27448 scale = targetHeight / height;
27451 if(x > 0 && y > 0){
27452 scale = targetWidth / width;
27454 if(width < height){
27455 scale = targetHeight / height;
27459 context.scale(scale, scale);
27461 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27462 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27464 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27465 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27467 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27469 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27474 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27475 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27477 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27478 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27480 var targetWidth = this.minWidth - 2 * x;
27481 var targetHeight = this.minHeight - 2 * y;
27485 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27486 scale = targetWidth / width;
27489 if(x > 0 && y == 0){
27490 scale = targetHeight / height;
27493 if(x > 0 && y > 0){
27494 scale = targetWidth / width;
27496 if(width < height){
27497 scale = targetHeight / height;
27501 context.scale(scale, scale);
27503 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27504 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27506 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27507 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27509 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27510 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27512 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27517 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27518 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27520 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27521 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27523 var targetWidth = this.minWidth - 2 * x;
27524 var targetHeight = this.minHeight - 2 * y;
27528 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27529 scale = targetWidth / width;
27532 if(x > 0 && y == 0){
27533 scale = targetHeight / height;
27536 if(x > 0 && y > 0){
27537 scale = targetWidth / width;
27539 if(width < height){
27540 scale = targetHeight / height;
27544 context.scale(scale, scale);
27546 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27547 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27549 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27550 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27552 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27554 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27561 this.cropData = canvas.toDataURL(this.cropType);
27563 if(this.fireEvent('crop', this, this.cropData) !== false){
27564 this.process(this.file, this.cropData);
27571 setThumbBoxSize : function()
27575 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27576 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27577 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27579 this.minWidth = width;
27580 this.minHeight = height;
27582 if(this.rotate == 90 || this.rotate == 270){
27583 this.minWidth = height;
27584 this.minHeight = width;
27589 width = Math.ceil(this.minWidth * height / this.minHeight);
27591 if(this.minWidth > this.minHeight){
27593 height = Math.ceil(this.minHeight * width / this.minWidth);
27596 this.thumbEl.setStyle({
27597 width : width + 'px',
27598 height : height + 'px'
27605 setThumbBoxPosition : function()
27607 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27608 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27610 this.thumbEl.setLeft(x);
27611 this.thumbEl.setTop(y);
27615 baseRotateLevel : function()
27617 this.baseRotate = 1;
27620 typeof(this.exif) != 'undefined' &&
27621 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27622 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27624 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27627 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27631 baseScaleLevel : function()
27635 if(this.isDocument){
27637 if(this.baseRotate == 6 || this.baseRotate == 8){
27639 height = this.thumbEl.getHeight();
27640 this.baseScale = height / this.imageEl.OriginWidth;
27642 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27643 width = this.thumbEl.getWidth();
27644 this.baseScale = width / this.imageEl.OriginHeight;
27650 height = this.thumbEl.getHeight();
27651 this.baseScale = height / this.imageEl.OriginHeight;
27653 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27654 width = this.thumbEl.getWidth();
27655 this.baseScale = width / this.imageEl.OriginWidth;
27661 if(this.baseRotate == 6 || this.baseRotate == 8){
27663 width = this.thumbEl.getHeight();
27664 this.baseScale = width / this.imageEl.OriginHeight;
27666 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27667 height = this.thumbEl.getWidth();
27668 this.baseScale = height / this.imageEl.OriginHeight;
27671 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27672 height = this.thumbEl.getWidth();
27673 this.baseScale = height / this.imageEl.OriginHeight;
27675 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27676 width = this.thumbEl.getHeight();
27677 this.baseScale = width / this.imageEl.OriginWidth;
27684 width = this.thumbEl.getWidth();
27685 this.baseScale = width / this.imageEl.OriginWidth;
27687 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27688 height = this.thumbEl.getHeight();
27689 this.baseScale = height / this.imageEl.OriginHeight;
27692 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27694 height = this.thumbEl.getHeight();
27695 this.baseScale = height / this.imageEl.OriginHeight;
27697 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27698 width = this.thumbEl.getWidth();
27699 this.baseScale = width / this.imageEl.OriginWidth;
27707 getScaleLevel : function()
27709 return this.baseScale * Math.pow(1.1, this.scale);
27712 onTouchStart : function(e)
27714 if(!this.canvasLoaded){
27715 this.beforeSelectFile(e);
27719 var touches = e.browserEvent.touches;
27725 if(touches.length == 1){
27726 this.onMouseDown(e);
27730 if(touches.length != 2){
27736 for(var i = 0, finger; finger = touches[i]; i++){
27737 coords.push(finger.pageX, finger.pageY);
27740 var x = Math.pow(coords[0] - coords[2], 2);
27741 var y = Math.pow(coords[1] - coords[3], 2);
27743 this.startDistance = Math.sqrt(x + y);
27745 this.startScale = this.scale;
27747 this.pinching = true;
27748 this.dragable = false;
27752 onTouchMove : function(e)
27754 if(!this.pinching && !this.dragable){
27758 var touches = e.browserEvent.touches;
27765 this.onMouseMove(e);
27771 for(var i = 0, finger; finger = touches[i]; i++){
27772 coords.push(finger.pageX, finger.pageY);
27775 var x = Math.pow(coords[0] - coords[2], 2);
27776 var y = Math.pow(coords[1] - coords[3], 2);
27778 this.endDistance = Math.sqrt(x + y);
27780 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27782 if(!this.zoomable()){
27783 this.scale = this.startScale;
27791 onTouchEnd : function(e)
27793 this.pinching = false;
27794 this.dragable = false;
27798 process : function(file, crop)
27801 this.maskEl.mask(this.loadingText);
27804 this.xhr = new XMLHttpRequest();
27806 file.xhr = this.xhr;
27808 this.xhr.open(this.method, this.url, true);
27811 "Accept": "application/json",
27812 "Cache-Control": "no-cache",
27813 "X-Requested-With": "XMLHttpRequest"
27816 for (var headerName in headers) {
27817 var headerValue = headers[headerName];
27819 this.xhr.setRequestHeader(headerName, headerValue);
27825 this.xhr.onload = function()
27827 _this.xhrOnLoad(_this.xhr);
27830 this.xhr.onerror = function()
27832 _this.xhrOnError(_this.xhr);
27835 var formData = new FormData();
27837 formData.append('returnHTML', 'NO');
27840 formData.append('crop', crop);
27843 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27844 formData.append(this.paramName, file, file.name);
27847 if(typeof(file.filename) != 'undefined'){
27848 formData.append('filename', file.filename);
27851 if(typeof(file.mimetype) != 'undefined'){
27852 formData.append('mimetype', file.mimetype);
27855 if(this.fireEvent('arrange', this, formData) != false){
27856 this.xhr.send(formData);
27860 xhrOnLoad : function(xhr)
27863 this.maskEl.unmask();
27866 if (xhr.readyState !== 4) {
27867 this.fireEvent('exception', this, xhr);
27871 var response = Roo.decode(xhr.responseText);
27873 if(!response.success){
27874 this.fireEvent('exception', this, xhr);
27878 var response = Roo.decode(xhr.responseText);
27880 this.fireEvent('upload', this, response);
27884 xhrOnError : function()
27887 this.maskEl.unmask();
27890 Roo.log('xhr on error');
27892 var response = Roo.decode(xhr.responseText);
27898 prepare : function(file)
27901 this.maskEl.mask(this.loadingText);
27907 if(typeof(file) === 'string'){
27908 this.loadCanvas(file);
27912 if(!file || !this.urlAPI){
27917 this.cropType = file.type;
27921 if(this.fireEvent('prepare', this, this.file) != false){
27923 var reader = new FileReader();
27925 reader.onload = function (e) {
27926 if (e.target.error) {
27927 Roo.log(e.target.error);
27931 var buffer = e.target.result,
27932 dataView = new DataView(buffer),
27934 maxOffset = dataView.byteLength - 4,
27938 if (dataView.getUint16(0) === 0xffd8) {
27939 while (offset < maxOffset) {
27940 markerBytes = dataView.getUint16(offset);
27942 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
27943 markerLength = dataView.getUint16(offset + 2) + 2;
27944 if (offset + markerLength > dataView.byteLength) {
27945 Roo.log('Invalid meta data: Invalid segment size.');
27949 if(markerBytes == 0xffe1){
27950 _this.parseExifData(
27957 offset += markerLength;
27967 var url = _this.urlAPI.createObjectURL(_this.file);
27969 _this.loadCanvas(url);
27974 reader.readAsArrayBuffer(this.file);
27980 parseExifData : function(dataView, offset, length)
27982 var tiffOffset = offset + 10,
27986 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27987 // No Exif data, might be XMP data instead
27991 // Check for the ASCII code for "Exif" (0x45786966):
27992 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27993 // No Exif data, might be XMP data instead
27996 if (tiffOffset + 8 > dataView.byteLength) {
27997 Roo.log('Invalid Exif data: Invalid segment size.');
28000 // Check for the two null bytes:
28001 if (dataView.getUint16(offset + 8) !== 0x0000) {
28002 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28005 // Check the byte alignment:
28006 switch (dataView.getUint16(tiffOffset)) {
28008 littleEndian = true;
28011 littleEndian = false;
28014 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28017 // Check for the TIFF tag marker (0x002A):
28018 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28019 Roo.log('Invalid Exif data: Missing TIFF marker.');
28022 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28023 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28025 this.parseExifTags(
28028 tiffOffset + dirOffset,
28033 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28038 if (dirOffset + 6 > dataView.byteLength) {
28039 Roo.log('Invalid Exif data: Invalid directory offset.');
28042 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28043 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28044 if (dirEndOffset + 4 > dataView.byteLength) {
28045 Roo.log('Invalid Exif data: Invalid directory size.');
28048 for (i = 0; i < tagsNumber; i += 1) {
28052 dirOffset + 2 + 12 * i, // tag offset
28056 // Return the offset to the next directory:
28057 return dataView.getUint32(dirEndOffset, littleEndian);
28060 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28062 var tag = dataView.getUint16(offset, littleEndian);
28064 this.exif[tag] = this.getExifValue(
28068 dataView.getUint16(offset + 2, littleEndian), // tag type
28069 dataView.getUint32(offset + 4, littleEndian), // tag length
28074 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28076 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28085 Roo.log('Invalid Exif data: Invalid tag type.');
28089 tagSize = tagType.size * length;
28090 // Determine if the value is contained in the dataOffset bytes,
28091 // or if the value at the dataOffset is a pointer to the actual data:
28092 dataOffset = tagSize > 4 ?
28093 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28094 if (dataOffset + tagSize > dataView.byteLength) {
28095 Roo.log('Invalid Exif data: Invalid data offset.');
28098 if (length === 1) {
28099 return tagType.getValue(dataView, dataOffset, littleEndian);
28102 for (i = 0; i < length; i += 1) {
28103 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28106 if (tagType.ascii) {
28108 // Concatenate the chars:
28109 for (i = 0; i < values.length; i += 1) {
28111 // Ignore the terminating NULL byte(s):
28112 if (c === '\u0000') {
28124 Roo.apply(Roo.bootstrap.UploadCropbox, {
28126 'Orientation': 0x0112
28130 1: 0, //'top-left',
28132 3: 180, //'bottom-right',
28133 // 4: 'bottom-left',
28135 6: 90, //'right-top',
28136 // 7: 'right-bottom',
28137 8: 270 //'left-bottom'
28141 // byte, 8-bit unsigned int:
28143 getValue: function (dataView, dataOffset) {
28144 return dataView.getUint8(dataOffset);
28148 // ascii, 8-bit byte:
28150 getValue: function (dataView, dataOffset) {
28151 return String.fromCharCode(dataView.getUint8(dataOffset));
28156 // short, 16 bit int:
28158 getValue: function (dataView, dataOffset, littleEndian) {
28159 return dataView.getUint16(dataOffset, littleEndian);
28163 // long, 32 bit int:
28165 getValue: function (dataView, dataOffset, littleEndian) {
28166 return dataView.getUint32(dataOffset, littleEndian);
28170 // rational = two long values, first is numerator, second is denominator:
28172 getValue: function (dataView, dataOffset, littleEndian) {
28173 return dataView.getUint32(dataOffset, littleEndian) /
28174 dataView.getUint32(dataOffset + 4, littleEndian);
28178 // slong, 32 bit signed int:
28180 getValue: function (dataView, dataOffset, littleEndian) {
28181 return dataView.getInt32(dataOffset, littleEndian);
28185 // srational, two slongs, first is numerator, second is denominator:
28187 getValue: function (dataView, dataOffset, littleEndian) {
28188 return dataView.getInt32(dataOffset, littleEndian) /
28189 dataView.getInt32(dataOffset + 4, littleEndian);
28199 cls : 'btn-group roo-upload-cropbox-rotate-left',
28200 action : 'rotate-left',
28204 cls : 'btn btn-default',
28205 html : '<i class="fa fa-undo"></i>'
28211 cls : 'btn-group roo-upload-cropbox-picture',
28212 action : 'picture',
28216 cls : 'btn btn-default',
28217 html : '<i class="fa fa-picture-o"></i>'
28223 cls : 'btn-group roo-upload-cropbox-rotate-right',
28224 action : 'rotate-right',
28228 cls : 'btn btn-default',
28229 html : '<i class="fa fa-repeat"></i>'
28237 cls : 'btn-group roo-upload-cropbox-rotate-left',
28238 action : 'rotate-left',
28242 cls : 'btn btn-default',
28243 html : '<i class="fa fa-undo"></i>'
28249 cls : 'btn-group roo-upload-cropbox-download',
28250 action : 'download',
28254 cls : 'btn btn-default',
28255 html : '<i class="fa fa-download"></i>'
28261 cls : 'btn-group roo-upload-cropbox-crop',
28266 cls : 'btn btn-default',
28267 html : '<i class="fa fa-crop"></i>'
28273 cls : 'btn-group roo-upload-cropbox-trash',
28278 cls : 'btn btn-default',
28279 html : '<i class="fa fa-trash"></i>'
28285 cls : 'btn-group roo-upload-cropbox-rotate-right',
28286 action : 'rotate-right',
28290 cls : 'btn btn-default',
28291 html : '<i class="fa fa-repeat"></i>'
28299 cls : 'btn-group roo-upload-cropbox-rotate-left',
28300 action : 'rotate-left',
28304 cls : 'btn btn-default',
28305 html : '<i class="fa fa-undo"></i>'
28311 cls : 'btn-group roo-upload-cropbox-rotate-right',
28312 action : 'rotate-right',
28316 cls : 'btn btn-default',
28317 html : '<i class="fa fa-repeat"></i>'
28330 * @class Roo.bootstrap.DocumentManager
28331 * @extends Roo.bootstrap.Component
28332 * Bootstrap DocumentManager class
28333 * @cfg {String} paramName default 'imageUpload'
28334 * @cfg {String} toolTipName default 'filename'
28335 * @cfg {String} method default POST
28336 * @cfg {String} url action url
28337 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28338 * @cfg {Boolean} multiple multiple upload default true
28339 * @cfg {Number} thumbSize default 300
28340 * @cfg {String} fieldLabel
28341 * @cfg {Number} labelWidth default 4
28342 * @cfg {String} labelAlign (left|top) default left
28343 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28344 * @cfg {Number} labellg set the width of label (1-12)
28345 * @cfg {Number} labelmd set the width of label (1-12)
28346 * @cfg {Number} labelsm set the width of label (1-12)
28347 * @cfg {Number} labelxs set the width of label (1-12)
28350 * Create a new DocumentManager
28351 * @param {Object} config The config object
28354 Roo.bootstrap.DocumentManager = function(config){
28355 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28358 this.delegates = [];
28363 * Fire when initial the DocumentManager
28364 * @param {Roo.bootstrap.DocumentManager} this
28369 * inspect selected file
28370 * @param {Roo.bootstrap.DocumentManager} this
28371 * @param {File} file
28376 * Fire when xhr load exception
28377 * @param {Roo.bootstrap.DocumentManager} this
28378 * @param {XMLHttpRequest} xhr
28380 "exception" : true,
28382 * @event afterupload
28383 * Fire when xhr load exception
28384 * @param {Roo.bootstrap.DocumentManager} this
28385 * @param {XMLHttpRequest} xhr
28387 "afterupload" : true,
28390 * prepare the form data
28391 * @param {Roo.bootstrap.DocumentManager} this
28392 * @param {Object} formData
28397 * Fire when remove the file
28398 * @param {Roo.bootstrap.DocumentManager} this
28399 * @param {Object} file
28404 * Fire after refresh the file
28405 * @param {Roo.bootstrap.DocumentManager} this
28410 * Fire after click the image
28411 * @param {Roo.bootstrap.DocumentManager} this
28412 * @param {Object} file
28417 * Fire when upload a image and editable set to true
28418 * @param {Roo.bootstrap.DocumentManager} this
28419 * @param {Object} file
28423 * @event beforeselectfile
28424 * Fire before select file
28425 * @param {Roo.bootstrap.DocumentManager} this
28427 "beforeselectfile" : true,
28430 * Fire before process file
28431 * @param {Roo.bootstrap.DocumentManager} this
28432 * @param {Object} file
28436 * @event previewrendered
28437 * Fire when preview rendered
28438 * @param {Roo.bootstrap.DocumentManager} this
28439 * @param {Object} file
28441 "previewrendered" : true
28446 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28455 paramName : 'imageUpload',
28456 toolTipName : 'filename',
28459 labelAlign : 'left',
28469 getAutoCreate : function()
28471 var managerWidget = {
28473 cls : 'roo-document-manager',
28477 cls : 'roo-document-manager-selector',
28482 cls : 'roo-document-manager-uploader',
28486 cls : 'roo-document-manager-upload-btn',
28487 html : '<i class="fa fa-plus"></i>'
28498 cls : 'column col-md-12',
28503 if(this.fieldLabel.length){
28508 cls : 'column col-md-12',
28509 html : this.fieldLabel
28513 cls : 'column col-md-12',
28518 if(this.labelAlign == 'left'){
28523 html : this.fieldLabel
28532 if(this.labelWidth > 12){
28533 content[0].style = "width: " + this.labelWidth + 'px';
28536 if(this.labelWidth < 13 && this.labelmd == 0){
28537 this.labelmd = this.labelWidth;
28540 if(this.labellg > 0){
28541 content[0].cls += ' col-lg-' + this.labellg;
28542 content[1].cls += ' col-lg-' + (12 - this.labellg);
28545 if(this.labelmd > 0){
28546 content[0].cls += ' col-md-' + this.labelmd;
28547 content[1].cls += ' col-md-' + (12 - this.labelmd);
28550 if(this.labelsm > 0){
28551 content[0].cls += ' col-sm-' + this.labelsm;
28552 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28555 if(this.labelxs > 0){
28556 content[0].cls += ' col-xs-' + this.labelxs;
28557 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28565 cls : 'row clearfix',
28573 initEvents : function()
28575 this.managerEl = this.el.select('.roo-document-manager', true).first();
28576 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28578 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28579 this.selectorEl.hide();
28582 this.selectorEl.attr('multiple', 'multiple');
28585 this.selectorEl.on('change', this.onFileSelected, this);
28587 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28588 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28590 this.uploader.on('click', this.onUploaderClick, this);
28592 this.renderProgressDialog();
28596 window.addEventListener("resize", function() { _this.refresh(); } );
28598 this.fireEvent('initial', this);
28601 renderProgressDialog : function()
28605 this.progressDialog = new Roo.bootstrap.Modal({
28606 cls : 'roo-document-manager-progress-dialog',
28607 allow_close : false,
28617 btnclick : function() {
28618 _this.uploadCancel();
28624 this.progressDialog.render(Roo.get(document.body));
28626 this.progress = new Roo.bootstrap.Progress({
28627 cls : 'roo-document-manager-progress',
28632 this.progress.render(this.progressDialog.getChildContainer());
28634 this.progressBar = new Roo.bootstrap.ProgressBar({
28635 cls : 'roo-document-manager-progress-bar',
28638 aria_valuemax : 12,
28642 this.progressBar.render(this.progress.getChildContainer());
28645 onUploaderClick : function(e)
28647 e.preventDefault();
28649 if(this.fireEvent('beforeselectfile', this) != false){
28650 this.selectorEl.dom.click();
28655 onFileSelected : function(e)
28657 e.preventDefault();
28659 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28663 Roo.each(this.selectorEl.dom.files, function(file){
28664 if(this.fireEvent('inspect', this, file) != false){
28665 this.files.push(file);
28675 this.selectorEl.dom.value = '';
28677 if(!this.files || !this.files.length){
28681 if(this.boxes > 0 && this.files.length > this.boxes){
28682 this.files = this.files.slice(0, this.boxes);
28685 this.uploader.show();
28687 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28688 this.uploader.hide();
28697 Roo.each(this.files, function(file){
28699 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28700 var f = this.renderPreview(file);
28705 if(file.type.indexOf('image') != -1){
28706 this.delegates.push(
28708 _this.process(file);
28709 }).createDelegate(this)
28717 _this.process(file);
28718 }).createDelegate(this)
28723 this.files = files;
28725 this.delegates = this.delegates.concat(docs);
28727 if(!this.delegates.length){
28732 this.progressBar.aria_valuemax = this.delegates.length;
28739 arrange : function()
28741 if(!this.delegates.length){
28742 this.progressDialog.hide();
28747 var delegate = this.delegates.shift();
28749 this.progressDialog.show();
28751 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28753 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28758 refresh : function()
28760 this.uploader.show();
28762 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28763 this.uploader.hide();
28766 Roo.isTouch ? this.closable(false) : this.closable(true);
28768 this.fireEvent('refresh', this);
28771 onRemove : function(e, el, o)
28773 e.preventDefault();
28775 this.fireEvent('remove', this, o);
28779 remove : function(o)
28783 Roo.each(this.files, function(file){
28784 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28793 this.files = files;
28800 Roo.each(this.files, function(file){
28805 file.target.remove();
28814 onClick : function(e, el, o)
28816 e.preventDefault();
28818 this.fireEvent('click', this, o);
28822 closable : function(closable)
28824 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28826 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28838 xhrOnLoad : function(xhr)
28840 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28844 if (xhr.readyState !== 4) {
28846 this.fireEvent('exception', this, xhr);
28850 var response = Roo.decode(xhr.responseText);
28852 if(!response.success){
28854 this.fireEvent('exception', this, xhr);
28858 var file = this.renderPreview(response.data);
28860 this.files.push(file);
28864 this.fireEvent('afterupload', this, xhr);
28868 xhrOnError : function(xhr)
28870 Roo.log('xhr on error');
28872 var response = Roo.decode(xhr.responseText);
28879 process : function(file)
28881 if(this.fireEvent('process', this, file) !== false){
28882 if(this.editable && file.type.indexOf('image') != -1){
28883 this.fireEvent('edit', this, file);
28887 this.uploadStart(file, false);
28894 uploadStart : function(file, crop)
28896 this.xhr = new XMLHttpRequest();
28898 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28903 file.xhr = this.xhr;
28905 this.managerEl.createChild({
28907 cls : 'roo-document-manager-loading',
28911 tooltip : file.name,
28912 cls : 'roo-document-manager-thumb',
28913 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28919 this.xhr.open(this.method, this.url, true);
28922 "Accept": "application/json",
28923 "Cache-Control": "no-cache",
28924 "X-Requested-With": "XMLHttpRequest"
28927 for (var headerName in headers) {
28928 var headerValue = headers[headerName];
28930 this.xhr.setRequestHeader(headerName, headerValue);
28936 this.xhr.onload = function()
28938 _this.xhrOnLoad(_this.xhr);
28941 this.xhr.onerror = function()
28943 _this.xhrOnError(_this.xhr);
28946 var formData = new FormData();
28948 formData.append('returnHTML', 'NO');
28951 formData.append('crop', crop);
28954 formData.append(this.paramName, file, file.name);
28961 if(this.fireEvent('prepare', this, formData, options) != false){
28963 if(options.manually){
28967 this.xhr.send(formData);
28971 this.uploadCancel();
28974 uploadCancel : function()
28980 this.delegates = [];
28982 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28989 renderPreview : function(file)
28991 if(typeof(file.target) != 'undefined' && file.target){
28995 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
28997 var previewEl = this.managerEl.createChild({
28999 cls : 'roo-document-manager-preview',
29003 tooltip : file[this.toolTipName],
29004 cls : 'roo-document-manager-thumb',
29005 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29010 html : '<i class="fa fa-times-circle"></i>'
29015 var close = previewEl.select('button.close', true).first();
29017 close.on('click', this.onRemove, this, file);
29019 file.target = previewEl;
29021 var image = previewEl.select('img', true).first();
29025 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29027 image.on('click', this.onClick, this, file);
29029 this.fireEvent('previewrendered', this, file);
29035 onPreviewLoad : function(file, image)
29037 if(typeof(file.target) == 'undefined' || !file.target){
29041 var width = image.dom.naturalWidth || image.dom.width;
29042 var height = image.dom.naturalHeight || image.dom.height;
29044 if(width > height){
29045 file.target.addClass('wide');
29049 file.target.addClass('tall');
29054 uploadFromSource : function(file, crop)
29056 this.xhr = new XMLHttpRequest();
29058 this.managerEl.createChild({
29060 cls : 'roo-document-manager-loading',
29064 tooltip : file.name,
29065 cls : 'roo-document-manager-thumb',
29066 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29072 this.xhr.open(this.method, this.url, true);
29075 "Accept": "application/json",
29076 "Cache-Control": "no-cache",
29077 "X-Requested-With": "XMLHttpRequest"
29080 for (var headerName in headers) {
29081 var headerValue = headers[headerName];
29083 this.xhr.setRequestHeader(headerName, headerValue);
29089 this.xhr.onload = function()
29091 _this.xhrOnLoad(_this.xhr);
29094 this.xhr.onerror = function()
29096 _this.xhrOnError(_this.xhr);
29099 var formData = new FormData();
29101 formData.append('returnHTML', 'NO');
29103 formData.append('crop', crop);
29105 if(typeof(file.filename) != 'undefined'){
29106 formData.append('filename', file.filename);
29109 if(typeof(file.mimetype) != 'undefined'){
29110 formData.append('mimetype', file.mimetype);
29115 if(this.fireEvent('prepare', this, formData) != false){
29116 this.xhr.send(formData);
29126 * @class Roo.bootstrap.DocumentViewer
29127 * @extends Roo.bootstrap.Component
29128 * Bootstrap DocumentViewer class
29129 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29130 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29133 * Create a new DocumentViewer
29134 * @param {Object} config The config object
29137 Roo.bootstrap.DocumentViewer = function(config){
29138 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29143 * Fire after initEvent
29144 * @param {Roo.bootstrap.DocumentViewer} this
29150 * @param {Roo.bootstrap.DocumentViewer} this
29155 * Fire after download button
29156 * @param {Roo.bootstrap.DocumentViewer} this
29161 * Fire after trash button
29162 * @param {Roo.bootstrap.DocumentViewer} this
29169 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29171 showDownload : true,
29175 getAutoCreate : function()
29179 cls : 'roo-document-viewer',
29183 cls : 'roo-document-viewer-body',
29187 cls : 'roo-document-viewer-thumb',
29191 cls : 'roo-document-viewer-image'
29199 cls : 'roo-document-viewer-footer',
29202 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29206 cls : 'btn-group roo-document-viewer-download',
29210 cls : 'btn btn-default',
29211 html : '<i class="fa fa-download"></i>'
29217 cls : 'btn-group roo-document-viewer-trash',
29221 cls : 'btn btn-default',
29222 html : '<i class="fa fa-trash"></i>'
29235 initEvents : function()
29237 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29238 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29240 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29241 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29243 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29244 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29246 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29247 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29249 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29250 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29252 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29253 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29255 this.bodyEl.on('click', this.onClick, this);
29256 this.downloadBtn.on('click', this.onDownload, this);
29257 this.trashBtn.on('click', this.onTrash, this);
29259 this.downloadBtn.hide();
29260 this.trashBtn.hide();
29262 if(this.showDownload){
29263 this.downloadBtn.show();
29266 if(this.showTrash){
29267 this.trashBtn.show();
29270 if(!this.showDownload && !this.showTrash) {
29271 this.footerEl.hide();
29276 initial : function()
29278 this.fireEvent('initial', this);
29282 onClick : function(e)
29284 e.preventDefault();
29286 this.fireEvent('click', this);
29289 onDownload : function(e)
29291 e.preventDefault();
29293 this.fireEvent('download', this);
29296 onTrash : function(e)
29298 e.preventDefault();
29300 this.fireEvent('trash', this);
29312 * @class Roo.bootstrap.NavProgressBar
29313 * @extends Roo.bootstrap.Component
29314 * Bootstrap NavProgressBar class
29317 * Create a new nav progress bar
29318 * @param {Object} config The config object
29321 Roo.bootstrap.NavProgressBar = function(config){
29322 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29324 this.bullets = this.bullets || [];
29326 // Roo.bootstrap.NavProgressBar.register(this);
29330 * Fires when the active item changes
29331 * @param {Roo.bootstrap.NavProgressBar} this
29332 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29333 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29340 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29345 getAutoCreate : function()
29347 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29351 cls : 'roo-navigation-bar-group',
29355 cls : 'roo-navigation-top-bar'
29359 cls : 'roo-navigation-bullets-bar',
29363 cls : 'roo-navigation-bar'
29370 cls : 'roo-navigation-bottom-bar'
29380 initEvents: function()
29385 onRender : function(ct, position)
29387 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29389 if(this.bullets.length){
29390 Roo.each(this.bullets, function(b){
29399 addItem : function(cfg)
29401 var item = new Roo.bootstrap.NavProgressItem(cfg);
29403 item.parentId = this.id;
29404 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29407 var top = new Roo.bootstrap.Element({
29409 cls : 'roo-navigation-bar-text'
29412 var bottom = new Roo.bootstrap.Element({
29414 cls : 'roo-navigation-bar-text'
29417 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29418 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29420 var topText = new Roo.bootstrap.Element({
29422 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29425 var bottomText = new Roo.bootstrap.Element({
29427 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29430 topText.onRender(top.el, null);
29431 bottomText.onRender(bottom.el, null);
29434 item.bottomEl = bottom;
29437 this.barItems.push(item);
29442 getActive : function()
29444 var active = false;
29446 Roo.each(this.barItems, function(v){
29448 if (!v.isActive()) {
29460 setActiveItem : function(item)
29464 Roo.each(this.barItems, function(v){
29465 if (v.rid == item.rid) {
29469 if (v.isActive()) {
29470 v.setActive(false);
29475 item.setActive(true);
29477 this.fireEvent('changed', this, item, prev);
29480 getBarItem: function(rid)
29484 Roo.each(this.barItems, function(e) {
29485 if (e.rid != rid) {
29496 indexOfItem : function(item)
29500 Roo.each(this.barItems, function(v, i){
29502 if (v.rid != item.rid) {
29513 setActiveNext : function()
29515 var i = this.indexOfItem(this.getActive());
29517 if (i > this.barItems.length) {
29521 this.setActiveItem(this.barItems[i+1]);
29524 setActivePrev : function()
29526 var i = this.indexOfItem(this.getActive());
29532 this.setActiveItem(this.barItems[i-1]);
29535 format : function()
29537 if(!this.barItems.length){
29541 var width = 100 / this.barItems.length;
29543 Roo.each(this.barItems, function(i){
29544 i.el.setStyle('width', width + '%');
29545 i.topEl.el.setStyle('width', width + '%');
29546 i.bottomEl.el.setStyle('width', width + '%');
29555 * Nav Progress Item
29560 * @class Roo.bootstrap.NavProgressItem
29561 * @extends Roo.bootstrap.Component
29562 * Bootstrap NavProgressItem class
29563 * @cfg {String} rid the reference id
29564 * @cfg {Boolean} active (true|false) Is item active default false
29565 * @cfg {Boolean} disabled (true|false) Is item active default false
29566 * @cfg {String} html
29567 * @cfg {String} position (top|bottom) text position default bottom
29568 * @cfg {String} icon show icon instead of number
29571 * Create a new NavProgressItem
29572 * @param {Object} config The config object
29574 Roo.bootstrap.NavProgressItem = function(config){
29575 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29580 * The raw click event for the entire grid.
29581 * @param {Roo.bootstrap.NavProgressItem} this
29582 * @param {Roo.EventObject} e
29589 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29595 position : 'bottom',
29598 getAutoCreate : function()
29600 var iconCls = 'roo-navigation-bar-item-icon';
29602 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29606 cls: 'roo-navigation-bar-item',
29616 cfg.cls += ' active';
29619 cfg.cls += ' disabled';
29625 disable : function()
29627 this.setDisabled(true);
29630 enable : function()
29632 this.setDisabled(false);
29635 initEvents: function()
29637 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29639 this.iconEl.on('click', this.onClick, this);
29642 onClick : function(e)
29644 e.preventDefault();
29650 if(this.fireEvent('click', this, e) === false){
29654 this.parent().setActiveItem(this);
29657 isActive: function ()
29659 return this.active;
29662 setActive : function(state)
29664 if(this.active == state){
29668 this.active = state;
29671 this.el.addClass('active');
29675 this.el.removeClass('active');
29680 setDisabled : function(state)
29682 if(this.disabled == state){
29686 this.disabled = state;
29689 this.el.addClass('disabled');
29693 this.el.removeClass('disabled');
29696 tooltipEl : function()
29698 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29711 * @class Roo.bootstrap.FieldLabel
29712 * @extends Roo.bootstrap.Component
29713 * Bootstrap FieldLabel class
29714 * @cfg {String} html contents of the element
29715 * @cfg {String} tag tag of the element default label
29716 * @cfg {String} cls class of the element
29717 * @cfg {String} target label target
29718 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29719 * @cfg {String} invalidClass default "text-warning"
29720 * @cfg {String} validClass default "text-success"
29721 * @cfg {String} iconTooltip default "This field is required"
29722 * @cfg {String} indicatorpos (left|right) default left
29725 * Create a new FieldLabel
29726 * @param {Object} config The config object
29729 Roo.bootstrap.FieldLabel = function(config){
29730 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29735 * Fires after the field has been marked as invalid.
29736 * @param {Roo.form.FieldLabel} this
29737 * @param {String} msg The validation message
29742 * Fires after the field has been validated with no errors.
29743 * @param {Roo.form.FieldLabel} this
29749 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29756 invalidClass : 'has-warning',
29757 validClass : 'has-success',
29758 iconTooltip : 'This field is required',
29759 indicatorpos : 'left',
29761 getAutoCreate : function(){
29765 cls : 'roo-bootstrap-field-label ' + this.cls,
29770 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29771 tooltip : this.iconTooltip
29780 if(this.indicatorpos == 'right'){
29783 cls : 'roo-bootstrap-field-label ' + this.cls,
29792 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29793 tooltip : this.iconTooltip
29802 initEvents: function()
29804 Roo.bootstrap.Element.superclass.initEvents.call(this);
29806 this.indicator = this.indicatorEl();
29808 if(this.indicator){
29809 this.indicator.removeClass('visible');
29810 this.indicator.addClass('invisible');
29813 Roo.bootstrap.FieldLabel.register(this);
29816 indicatorEl : function()
29818 var indicator = this.el.select('i.roo-required-indicator',true).first();
29829 * Mark this field as valid
29831 markValid : function()
29833 if(this.indicator){
29834 this.indicator.removeClass('visible');
29835 this.indicator.addClass('invisible');
29838 this.el.removeClass(this.invalidClass);
29840 this.el.addClass(this.validClass);
29842 this.fireEvent('valid', this);
29846 * Mark this field as invalid
29847 * @param {String} msg The validation message
29849 markInvalid : function(msg)
29851 if(this.indicator){
29852 this.indicator.removeClass('invisible');
29853 this.indicator.addClass('visible');
29856 this.el.removeClass(this.validClass);
29858 this.el.addClass(this.invalidClass);
29860 this.fireEvent('invalid', this, msg);
29866 Roo.apply(Roo.bootstrap.FieldLabel, {
29871 * register a FieldLabel Group
29872 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29874 register : function(label)
29876 if(this.groups.hasOwnProperty(label.target)){
29880 this.groups[label.target] = label;
29884 * fetch a FieldLabel Group based on the target
29885 * @param {string} target
29886 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29888 get: function(target) {
29889 if (typeof(this.groups[target]) == 'undefined') {
29893 return this.groups[target] ;
29902 * page DateSplitField.
29908 * @class Roo.bootstrap.DateSplitField
29909 * @extends Roo.bootstrap.Component
29910 * Bootstrap DateSplitField class
29911 * @cfg {string} fieldLabel - the label associated
29912 * @cfg {Number} labelWidth set the width of label (0-12)
29913 * @cfg {String} labelAlign (top|left)
29914 * @cfg {Boolean} dayAllowBlank (true|false) default false
29915 * @cfg {Boolean} monthAllowBlank (true|false) default false
29916 * @cfg {Boolean} yearAllowBlank (true|false) default false
29917 * @cfg {string} dayPlaceholder
29918 * @cfg {string} monthPlaceholder
29919 * @cfg {string} yearPlaceholder
29920 * @cfg {string} dayFormat default 'd'
29921 * @cfg {string} monthFormat default 'm'
29922 * @cfg {string} yearFormat default 'Y'
29923 * @cfg {Number} labellg set the width of label (1-12)
29924 * @cfg {Number} labelmd set the width of label (1-12)
29925 * @cfg {Number} labelsm set the width of label (1-12)
29926 * @cfg {Number} labelxs set the width of label (1-12)
29930 * Create a new DateSplitField
29931 * @param {Object} config The config object
29934 Roo.bootstrap.DateSplitField = function(config){
29935 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
29941 * getting the data of years
29942 * @param {Roo.bootstrap.DateSplitField} this
29943 * @param {Object} years
29948 * getting the data of days
29949 * @param {Roo.bootstrap.DateSplitField} this
29950 * @param {Object} days
29955 * Fires after the field has been marked as invalid.
29956 * @param {Roo.form.Field} this
29957 * @param {String} msg The validation message
29962 * Fires after the field has been validated with no errors.
29963 * @param {Roo.form.Field} this
29969 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
29972 labelAlign : 'top',
29974 dayAllowBlank : false,
29975 monthAllowBlank : false,
29976 yearAllowBlank : false,
29977 dayPlaceholder : '',
29978 monthPlaceholder : '',
29979 yearPlaceholder : '',
29983 isFormField : true,
29989 getAutoCreate : function()
29993 cls : 'row roo-date-split-field-group',
29998 cls : 'form-hidden-field roo-date-split-field-group-value',
30004 var labelCls = 'col-md-12';
30005 var contentCls = 'col-md-4';
30007 if(this.fieldLabel){
30011 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30015 html : this.fieldLabel
30020 if(this.labelAlign == 'left'){
30022 if(this.labelWidth > 12){
30023 label.style = "width: " + this.labelWidth + 'px';
30026 if(this.labelWidth < 13 && this.labelmd == 0){
30027 this.labelmd = this.labelWidth;
30030 if(this.labellg > 0){
30031 labelCls = ' col-lg-' + this.labellg;
30032 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30035 if(this.labelmd > 0){
30036 labelCls = ' col-md-' + this.labelmd;
30037 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30040 if(this.labelsm > 0){
30041 labelCls = ' col-sm-' + this.labelsm;
30042 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30045 if(this.labelxs > 0){
30046 labelCls = ' col-xs-' + this.labelxs;
30047 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30051 label.cls += ' ' + labelCls;
30053 cfg.cn.push(label);
30056 Roo.each(['day', 'month', 'year'], function(t){
30059 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30066 inputEl: function ()
30068 return this.el.select('.roo-date-split-field-group-value', true).first();
30071 onRender : function(ct, position)
30075 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30077 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30079 this.dayField = new Roo.bootstrap.ComboBox({
30080 allowBlank : this.dayAllowBlank,
30081 alwaysQuery : true,
30082 displayField : 'value',
30085 forceSelection : true,
30087 placeholder : this.dayPlaceholder,
30088 selectOnFocus : true,
30089 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30090 triggerAction : 'all',
30092 valueField : 'value',
30093 store : new Roo.data.SimpleStore({
30094 data : (function() {
30096 _this.fireEvent('days', _this, days);
30099 fields : [ 'value' ]
30102 select : function (_self, record, index)
30104 _this.setValue(_this.getValue());
30109 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30111 this.monthField = new Roo.bootstrap.MonthField({
30112 after : '<i class=\"fa fa-calendar\"></i>',
30113 allowBlank : this.monthAllowBlank,
30114 placeholder : this.monthPlaceholder,
30117 render : function (_self)
30119 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30120 e.preventDefault();
30124 select : function (_self, oldvalue, newvalue)
30126 _this.setValue(_this.getValue());
30131 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30133 this.yearField = new Roo.bootstrap.ComboBox({
30134 allowBlank : this.yearAllowBlank,
30135 alwaysQuery : true,
30136 displayField : 'value',
30139 forceSelection : true,
30141 placeholder : this.yearPlaceholder,
30142 selectOnFocus : true,
30143 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30144 triggerAction : 'all',
30146 valueField : 'value',
30147 store : new Roo.data.SimpleStore({
30148 data : (function() {
30150 _this.fireEvent('years', _this, years);
30153 fields : [ 'value' ]
30156 select : function (_self, record, index)
30158 _this.setValue(_this.getValue());
30163 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30166 setValue : function(v, format)
30168 this.inputEl.dom.value = v;
30170 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30172 var d = Date.parseDate(v, f);
30179 this.setDay(d.format(this.dayFormat));
30180 this.setMonth(d.format(this.monthFormat));
30181 this.setYear(d.format(this.yearFormat));
30188 setDay : function(v)
30190 this.dayField.setValue(v);
30191 this.inputEl.dom.value = this.getValue();
30196 setMonth : function(v)
30198 this.monthField.setValue(v, true);
30199 this.inputEl.dom.value = this.getValue();
30204 setYear : function(v)
30206 this.yearField.setValue(v);
30207 this.inputEl.dom.value = this.getValue();
30212 getDay : function()
30214 return this.dayField.getValue();
30217 getMonth : function()
30219 return this.monthField.getValue();
30222 getYear : function()
30224 return this.yearField.getValue();
30227 getValue : function()
30229 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30231 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30241 this.inputEl.dom.value = '';
30246 validate : function()
30248 var d = this.dayField.validate();
30249 var m = this.monthField.validate();
30250 var y = this.yearField.validate();
30255 (!this.dayAllowBlank && !d) ||
30256 (!this.monthAllowBlank && !m) ||
30257 (!this.yearAllowBlank && !y)
30262 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30271 this.markInvalid();
30276 markValid : function()
30279 var label = this.el.select('label', true).first();
30280 var icon = this.el.select('i.fa-star', true).first();
30286 this.fireEvent('valid', this);
30290 * Mark this field as invalid
30291 * @param {String} msg The validation message
30293 markInvalid : function(msg)
30296 var label = this.el.select('label', true).first();
30297 var icon = this.el.select('i.fa-star', true).first();
30299 if(label && !icon){
30300 this.el.select('.roo-date-split-field-label', true).createChild({
30302 cls : 'text-danger fa fa-lg fa-star',
30303 tooltip : 'This field is required',
30304 style : 'margin-right:5px;'
30308 this.fireEvent('invalid', this, msg);
30311 clearInvalid : function()
30313 var label = this.el.select('label', true).first();
30314 var icon = this.el.select('i.fa-star', true).first();
30320 this.fireEvent('valid', this);
30323 getName: function()
30333 * http://masonry.desandro.com
30335 * The idea is to render all the bricks based on vertical width...
30337 * The original code extends 'outlayer' - we might need to use that....
30343 * @class Roo.bootstrap.LayoutMasonry
30344 * @extends Roo.bootstrap.Component
30345 * Bootstrap Layout Masonry class
30348 * Create a new Element
30349 * @param {Object} config The config object
30352 Roo.bootstrap.LayoutMasonry = function(config){
30354 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30358 Roo.bootstrap.LayoutMasonry.register(this);
30364 * Fire after layout the items
30365 * @param {Roo.bootstrap.LayoutMasonry} this
30366 * @param {Roo.EventObject} e
30373 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30376 * @cfg {Boolean} isLayoutInstant = no animation?
30378 isLayoutInstant : false, // needed?
30381 * @cfg {Number} boxWidth width of the columns
30386 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30391 * @cfg {Number} padWidth padding below box..
30396 * @cfg {Number} gutter gutter width..
30401 * @cfg {Number} maxCols maximum number of columns
30407 * @cfg {Boolean} isAutoInitial defalut true
30409 isAutoInitial : true,
30414 * @cfg {Boolean} isHorizontal defalut false
30416 isHorizontal : false,
30418 currentSize : null,
30424 bricks: null, //CompositeElement
30428 _isLayoutInited : false,
30430 // isAlternative : false, // only use for vertical layout...
30433 * @cfg {Number} alternativePadWidth padding below box..
30435 alternativePadWidth : 50,
30437 selectedBrick : [],
30439 getAutoCreate : function(){
30441 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30445 cls: 'blog-masonary-wrapper ' + this.cls,
30447 cls : 'mas-boxes masonary'
30454 getChildContainer: function( )
30456 if (this.boxesEl) {
30457 return this.boxesEl;
30460 this.boxesEl = this.el.select('.mas-boxes').first();
30462 return this.boxesEl;
30466 initEvents : function()
30470 if(this.isAutoInitial){
30471 Roo.log('hook children rendered');
30472 this.on('childrenrendered', function() {
30473 Roo.log('children rendered');
30479 initial : function()
30481 this.selectedBrick = [];
30483 this.currentSize = this.el.getBox(true);
30485 Roo.EventManager.onWindowResize(this.resize, this);
30487 if(!this.isAutoInitial){
30495 //this.layout.defer(500,this);
30499 resize : function()
30501 var cs = this.el.getBox(true);
30504 this.currentSize.width == cs.width &&
30505 this.currentSize.x == cs.x &&
30506 this.currentSize.height == cs.height &&
30507 this.currentSize.y == cs.y
30509 Roo.log("no change in with or X or Y");
30513 this.currentSize = cs;
30519 layout : function()
30521 this._resetLayout();
30523 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30525 this.layoutItems( isInstant );
30527 this._isLayoutInited = true;
30529 this.fireEvent('layout', this);
30533 _resetLayout : function()
30535 if(this.isHorizontal){
30536 this.horizontalMeasureColumns();
30540 this.verticalMeasureColumns();
30544 verticalMeasureColumns : function()
30546 this.getContainerWidth();
30548 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30549 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30553 var boxWidth = this.boxWidth + this.padWidth;
30555 if(this.containerWidth < this.boxWidth){
30556 boxWidth = this.containerWidth
30559 var containerWidth = this.containerWidth;
30561 var cols = Math.floor(containerWidth / boxWidth);
30563 this.cols = Math.max( cols, 1 );
30565 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30567 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30569 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30571 this.colWidth = boxWidth + avail - this.padWidth;
30573 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30574 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30577 horizontalMeasureColumns : function()
30579 this.getContainerWidth();
30581 var boxWidth = this.boxWidth;
30583 if(this.containerWidth < boxWidth){
30584 boxWidth = this.containerWidth;
30587 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30589 this.el.setHeight(boxWidth);
30593 getContainerWidth : function()
30595 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30598 layoutItems : function( isInstant )
30600 Roo.log(this.bricks);
30602 var items = Roo.apply([], this.bricks);
30604 if(this.isHorizontal){
30605 this._horizontalLayoutItems( items , isInstant );
30609 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30610 // this._verticalAlternativeLayoutItems( items , isInstant );
30614 this._verticalLayoutItems( items , isInstant );
30618 _verticalLayoutItems : function ( items , isInstant)
30620 if ( !items || !items.length ) {
30625 ['xs', 'xs', 'xs', 'tall'],
30626 ['xs', 'xs', 'tall'],
30627 ['xs', 'xs', 'sm'],
30628 ['xs', 'xs', 'xs'],
30634 ['sm', 'xs', 'xs'],
30638 ['tall', 'xs', 'xs', 'xs'],
30639 ['tall', 'xs', 'xs'],
30651 Roo.each(items, function(item, k){
30653 switch (item.size) {
30654 // these layouts take up a full box,
30665 boxes.push([item]);
30688 var filterPattern = function(box, length)
30696 var pattern = box.slice(0, length);
30700 Roo.each(pattern, function(i){
30701 format.push(i.size);
30704 Roo.each(standard, function(s){
30706 if(String(s) != String(format)){
30715 if(!match && length == 1){
30720 filterPattern(box, length - 1);
30724 queue.push(pattern);
30726 box = box.slice(length, box.length);
30728 filterPattern(box, 4);
30734 Roo.each(boxes, function(box, k){
30740 if(box.length == 1){
30745 filterPattern(box, 4);
30749 this._processVerticalLayoutQueue( queue, isInstant );
30753 // _verticalAlternativeLayoutItems : function( items , isInstant )
30755 // if ( !items || !items.length ) {
30759 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30763 _horizontalLayoutItems : function ( items , isInstant)
30765 if ( !items || !items.length || items.length < 3) {
30771 var eItems = items.slice(0, 3);
30773 items = items.slice(3, items.length);
30776 ['xs', 'xs', 'xs', 'wide'],
30777 ['xs', 'xs', 'wide'],
30778 ['xs', 'xs', 'sm'],
30779 ['xs', 'xs', 'xs'],
30785 ['sm', 'xs', 'xs'],
30789 ['wide', 'xs', 'xs', 'xs'],
30790 ['wide', 'xs', 'xs'],
30803 Roo.each(items, function(item, k){
30805 switch (item.size) {
30816 boxes.push([item]);
30840 var filterPattern = function(box, length)
30848 var pattern = box.slice(0, length);
30852 Roo.each(pattern, function(i){
30853 format.push(i.size);
30856 Roo.each(standard, function(s){
30858 if(String(s) != String(format)){
30867 if(!match && length == 1){
30872 filterPattern(box, length - 1);
30876 queue.push(pattern);
30878 box = box.slice(length, box.length);
30880 filterPattern(box, 4);
30886 Roo.each(boxes, function(box, k){
30892 if(box.length == 1){
30897 filterPattern(box, 4);
30904 var pos = this.el.getBox(true);
30908 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30910 var hit_end = false;
30912 Roo.each(queue, function(box){
30916 Roo.each(box, function(b){
30918 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30928 Roo.each(box, function(b){
30930 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30933 mx = Math.max(mx, b.x);
30937 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
30941 Roo.each(box, function(b){
30943 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30957 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
30960 /** Sets position of item in DOM
30961 * @param {Element} item
30962 * @param {Number} x - horizontal position
30963 * @param {Number} y - vertical position
30964 * @param {Boolean} isInstant - disables transitions
30966 _processVerticalLayoutQueue : function( queue, isInstant )
30968 var pos = this.el.getBox(true);
30973 for (var i = 0; i < this.cols; i++){
30977 Roo.each(queue, function(box, k){
30979 var col = k % this.cols;
30981 Roo.each(box, function(b,kk){
30983 b.el.position('absolute');
30985 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30986 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30988 if(b.size == 'md-left' || b.size == 'md-right'){
30989 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
30990 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
30993 b.el.setWidth(width);
30994 b.el.setHeight(height);
30996 b.el.select('iframe',true).setSize(width,height);
31000 for (var i = 0; i < this.cols; i++){
31002 if(maxY[i] < maxY[col]){
31007 col = Math.min(col, i);
31011 x = pos.x + col * (this.colWidth + this.padWidth);
31015 var positions = [];
31017 switch (box.length){
31019 positions = this.getVerticalOneBoxColPositions(x, y, box);
31022 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31025 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31028 positions = this.getVerticalFourBoxColPositions(x, y, box);
31034 Roo.each(box, function(b,kk){
31036 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31038 var sz = b.el.getSize();
31040 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31048 for (var i = 0; i < this.cols; i++){
31049 mY = Math.max(mY, maxY[i]);
31052 this.el.setHeight(mY - pos.y);
31056 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31058 // var pos = this.el.getBox(true);
31061 // var maxX = pos.right;
31063 // var maxHeight = 0;
31065 // Roo.each(items, function(item, k){
31069 // item.el.position('absolute');
31071 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31073 // item.el.setWidth(width);
31075 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31077 // item.el.setHeight(height);
31080 // item.el.setXY([x, y], isInstant ? false : true);
31082 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31085 // y = y + height + this.alternativePadWidth;
31087 // maxHeight = maxHeight + height + this.alternativePadWidth;
31091 // this.el.setHeight(maxHeight);
31095 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31097 var pos = this.el.getBox(true);
31102 var maxX = pos.right;
31104 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31106 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31108 Roo.each(queue, function(box, k){
31110 Roo.each(box, function(b, kk){
31112 b.el.position('absolute');
31114 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31115 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31117 if(b.size == 'md-left' || b.size == 'md-right'){
31118 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31119 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31122 b.el.setWidth(width);
31123 b.el.setHeight(height);
31131 var positions = [];
31133 switch (box.length){
31135 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31138 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31141 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31144 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31150 Roo.each(box, function(b,kk){
31152 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31154 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31162 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31164 Roo.each(eItems, function(b,k){
31166 b.size = (k == 0) ? 'sm' : 'xs';
31167 b.x = (k == 0) ? 2 : 1;
31168 b.y = (k == 0) ? 2 : 1;
31170 b.el.position('absolute');
31172 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31174 b.el.setWidth(width);
31176 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31178 b.el.setHeight(height);
31182 var positions = [];
31185 x : maxX - this.unitWidth * 2 - this.gutter,
31190 x : maxX - this.unitWidth,
31191 y : minY + (this.unitWidth + this.gutter) * 2
31195 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31199 Roo.each(eItems, function(b,k){
31201 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31207 getVerticalOneBoxColPositions : function(x, y, box)
31211 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31213 if(box[0].size == 'md-left'){
31217 if(box[0].size == 'md-right'){
31222 x : x + (this.unitWidth + this.gutter) * rand,
31229 getVerticalTwoBoxColPositions : function(x, y, box)
31233 if(box[0].size == 'xs'){
31237 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31241 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31255 x : x + (this.unitWidth + this.gutter) * 2,
31256 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31263 getVerticalThreeBoxColPositions : function(x, y, box)
31267 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31275 x : x + (this.unitWidth + this.gutter) * 1,
31280 x : x + (this.unitWidth + this.gutter) * 2,
31288 if(box[0].size == 'xs' && box[1].size == 'xs'){
31297 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31301 x : x + (this.unitWidth + this.gutter) * 1,
31315 x : x + (this.unitWidth + this.gutter) * 2,
31320 x : x + (this.unitWidth + this.gutter) * 2,
31321 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31328 getVerticalFourBoxColPositions : function(x, y, box)
31332 if(box[0].size == 'xs'){
31341 y : y + (this.unitHeight + this.gutter) * 1
31346 y : y + (this.unitHeight + this.gutter) * 2
31350 x : x + (this.unitWidth + this.gutter) * 1,
31364 x : x + (this.unitWidth + this.gutter) * 2,
31369 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31370 y : y + (this.unitHeight + this.gutter) * 1
31374 x : x + (this.unitWidth + this.gutter) * 2,
31375 y : y + (this.unitWidth + this.gutter) * 2
31382 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31386 if(box[0].size == 'md-left'){
31388 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31395 if(box[0].size == 'md-right'){
31397 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31398 y : minY + (this.unitWidth + this.gutter) * 1
31404 var rand = Math.floor(Math.random() * (4 - box[0].y));
31407 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31408 y : minY + (this.unitWidth + this.gutter) * rand
31415 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31419 if(box[0].size == 'xs'){
31422 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31427 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31428 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31436 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31441 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31442 y : minY + (this.unitWidth + this.gutter) * 2
31449 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31453 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31456 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31461 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31462 y : minY + (this.unitWidth + this.gutter) * 1
31466 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31467 y : minY + (this.unitWidth + this.gutter) * 2
31474 if(box[0].size == 'xs' && box[1].size == 'xs'){
31477 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31482 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31487 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31488 y : minY + (this.unitWidth + this.gutter) * 1
31496 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31501 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31502 y : minY + (this.unitWidth + this.gutter) * 2
31506 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31507 y : minY + (this.unitWidth + this.gutter) * 2
31514 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31518 if(box[0].size == 'xs'){
31521 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31526 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31531 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),
31536 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31537 y : minY + (this.unitWidth + this.gutter) * 1
31545 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31550 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31551 y : minY + (this.unitWidth + this.gutter) * 2
31555 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31556 y : minY + (this.unitWidth + this.gutter) * 2
31560 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),
31561 y : minY + (this.unitWidth + this.gutter) * 2
31569 * remove a Masonry Brick
31570 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31572 removeBrick : function(brick_id)
31578 for (var i = 0; i<this.bricks.length; i++) {
31579 if (this.bricks[i].id == brick_id) {
31580 this.bricks.splice(i,1);
31581 this.el.dom.removeChild(Roo.get(brick_id).dom);
31588 * adds a Masonry Brick
31589 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31591 addBrick : function(cfg)
31593 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31594 //this.register(cn);
31595 cn.parentId = this.id;
31596 cn.onRender(this.el, null);
31601 * register a Masonry Brick
31602 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31605 register : function(brick)
31607 this.bricks.push(brick);
31608 brick.masonryId = this.id;
31612 * clear all the Masonry Brick
31614 clearAll : function()
31617 //this.getChildContainer().dom.innerHTML = "";
31618 this.el.dom.innerHTML = '';
31621 getSelected : function()
31623 if (!this.selectedBrick) {
31627 return this.selectedBrick;
31631 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31635 * register a Masonry Layout
31636 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31639 register : function(layout)
31641 this.groups[layout.id] = layout;
31644 * fetch a Masonry Layout based on the masonry layout ID
31645 * @param {string} the masonry layout to add
31646 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31649 get: function(layout_id) {
31650 if (typeof(this.groups[layout_id]) == 'undefined') {
31653 return this.groups[layout_id] ;
31665 * http://masonry.desandro.com
31667 * The idea is to render all the bricks based on vertical width...
31669 * The original code extends 'outlayer' - we might need to use that....
31675 * @class Roo.bootstrap.LayoutMasonryAuto
31676 * @extends Roo.bootstrap.Component
31677 * Bootstrap Layout Masonry class
31680 * Create a new Element
31681 * @param {Object} config The config object
31684 Roo.bootstrap.LayoutMasonryAuto = function(config){
31685 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31688 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31691 * @cfg {Boolean} isFitWidth - resize the width..
31693 isFitWidth : false, // options..
31695 * @cfg {Boolean} isOriginLeft = left align?
31697 isOriginLeft : true,
31699 * @cfg {Boolean} isOriginTop = top align?
31701 isOriginTop : false,
31703 * @cfg {Boolean} isLayoutInstant = no animation?
31705 isLayoutInstant : false, // needed?
31707 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31709 isResizingContainer : true,
31711 * @cfg {Number} columnWidth width of the columns
31717 * @cfg {Number} maxCols maximum number of columns
31722 * @cfg {Number} padHeight padding below box..
31728 * @cfg {Boolean} isAutoInitial defalut true
31731 isAutoInitial : true,
31737 initialColumnWidth : 0,
31738 currentSize : null,
31740 colYs : null, // array.
31747 bricks: null, //CompositeElement
31748 cols : 0, // array?
31749 // element : null, // wrapped now this.el
31750 _isLayoutInited : null,
31753 getAutoCreate : function(){
31757 cls: 'blog-masonary-wrapper ' + this.cls,
31759 cls : 'mas-boxes masonary'
31766 getChildContainer: function( )
31768 if (this.boxesEl) {
31769 return this.boxesEl;
31772 this.boxesEl = this.el.select('.mas-boxes').first();
31774 return this.boxesEl;
31778 initEvents : function()
31782 if(this.isAutoInitial){
31783 Roo.log('hook children rendered');
31784 this.on('childrenrendered', function() {
31785 Roo.log('children rendered');
31792 initial : function()
31794 this.reloadItems();
31796 this.currentSize = this.el.getBox(true);
31798 /// was window resize... - let's see if this works..
31799 Roo.EventManager.onWindowResize(this.resize, this);
31801 if(!this.isAutoInitial){
31806 this.layout.defer(500,this);
31809 reloadItems: function()
31811 this.bricks = this.el.select('.masonry-brick', true);
31813 this.bricks.each(function(b) {
31814 //Roo.log(b.getSize());
31815 if (!b.attr('originalwidth')) {
31816 b.attr('originalwidth', b.getSize().width);
31821 Roo.log(this.bricks.elements.length);
31824 resize : function()
31827 var cs = this.el.getBox(true);
31829 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31830 Roo.log("no change in with or X");
31833 this.currentSize = cs;
31837 layout : function()
31840 this._resetLayout();
31841 //this._manageStamps();
31843 // don't animate first layout
31844 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31845 this.layoutItems( isInstant );
31847 // flag for initalized
31848 this._isLayoutInited = true;
31851 layoutItems : function( isInstant )
31853 //var items = this._getItemsForLayout( this.items );
31854 // original code supports filtering layout items.. we just ignore it..
31856 this._layoutItems( this.bricks , isInstant );
31858 this._postLayout();
31860 _layoutItems : function ( items , isInstant)
31862 //this.fireEvent( 'layout', this, items );
31865 if ( !items || !items.elements.length ) {
31866 // no items, emit event with empty array
31871 items.each(function(item) {
31872 Roo.log("layout item");
31874 // get x/y object from method
31875 var position = this._getItemLayoutPosition( item );
31877 position.item = item;
31878 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31879 queue.push( position );
31882 this._processLayoutQueue( queue );
31884 /** Sets position of item in DOM
31885 * @param {Element} item
31886 * @param {Number} x - horizontal position
31887 * @param {Number} y - vertical position
31888 * @param {Boolean} isInstant - disables transitions
31890 _processLayoutQueue : function( queue )
31892 for ( var i=0, len = queue.length; i < len; i++ ) {
31893 var obj = queue[i];
31894 obj.item.position('absolute');
31895 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31901 * Any logic you want to do after each layout,
31902 * i.e. size the container
31904 _postLayout : function()
31906 this.resizeContainer();
31909 resizeContainer : function()
31911 if ( !this.isResizingContainer ) {
31914 var size = this._getContainerSize();
31916 this.el.setSize(size.width,size.height);
31917 this.boxesEl.setSize(size.width,size.height);
31923 _resetLayout : function()
31925 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31926 this.colWidth = this.el.getWidth();
31927 //this.gutter = this.el.getWidth();
31929 this.measureColumns();
31935 this.colYs.push( 0 );
31941 measureColumns : function()
31943 this.getContainerWidth();
31944 // if columnWidth is 0, default to outerWidth of first item
31945 if ( !this.columnWidth ) {
31946 var firstItem = this.bricks.first();
31947 Roo.log(firstItem);
31948 this.columnWidth = this.containerWidth;
31949 if (firstItem && firstItem.attr('originalwidth') ) {
31950 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
31952 // columnWidth fall back to item of first element
31953 Roo.log("set column width?");
31954 this.initialColumnWidth = this.columnWidth ;
31956 // if first elem has no width, default to size of container
31961 if (this.initialColumnWidth) {
31962 this.columnWidth = this.initialColumnWidth;
31967 // column width is fixed at the top - however if container width get's smaller we should
31970 // this bit calcs how man columns..
31972 var columnWidth = this.columnWidth += this.gutter;
31974 // calculate columns
31975 var containerWidth = this.containerWidth + this.gutter;
31977 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
31978 // fix rounding errors, typically with gutters
31979 var excess = columnWidth - containerWidth % columnWidth;
31982 // if overshoot is less than a pixel, round up, otherwise floor it
31983 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
31984 cols = Math[ mathMethod ]( cols );
31985 this.cols = Math.max( cols, 1 );
31986 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31988 // padding positioning..
31989 var totalColWidth = this.cols * this.columnWidth;
31990 var padavail = this.containerWidth - totalColWidth;
31991 // so for 2 columns - we need 3 'pads'
31993 var padNeeded = (1+this.cols) * this.padWidth;
31995 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
31997 this.columnWidth += padExtra
31998 //this.padWidth = Math.floor(padavail / ( this.cols));
32000 // adjust colum width so that padding is fixed??
32002 // we have 3 columns ... total = width * 3
32003 // we have X left over... that should be used by
32005 //if (this.expandC) {
32013 getContainerWidth : function()
32015 /* // container is parent if fit width
32016 var container = this.isFitWidth ? this.element.parentNode : this.element;
32017 // check that this.size and size are there
32018 // IE8 triggers resize on body size change, so they might not be
32020 var size = getSize( container ); //FIXME
32021 this.containerWidth = size && size.innerWidth; //FIXME
32024 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32028 _getItemLayoutPosition : function( item ) // what is item?
32030 // we resize the item to our columnWidth..
32032 item.setWidth(this.columnWidth);
32033 item.autoBoxAdjust = false;
32035 var sz = item.getSize();
32037 // how many columns does this brick span
32038 var remainder = this.containerWidth % this.columnWidth;
32040 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32041 // round if off by 1 pixel, otherwise use ceil
32042 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32043 colSpan = Math.min( colSpan, this.cols );
32045 // normally this should be '1' as we dont' currently allow multi width columns..
32047 var colGroup = this._getColGroup( colSpan );
32048 // get the minimum Y value from the columns
32049 var minimumY = Math.min.apply( Math, colGroup );
32050 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32052 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32054 // position the brick
32056 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32057 y: this.currentSize.y + minimumY + this.padHeight
32061 // apply setHeight to necessary columns
32062 var setHeight = minimumY + sz.height + this.padHeight;
32063 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32065 var setSpan = this.cols + 1 - colGroup.length;
32066 for ( var i = 0; i < setSpan; i++ ) {
32067 this.colYs[ shortColIndex + i ] = setHeight ;
32074 * @param {Number} colSpan - number of columns the element spans
32075 * @returns {Array} colGroup
32077 _getColGroup : function( colSpan )
32079 if ( colSpan < 2 ) {
32080 // if brick spans only one column, use all the column Ys
32085 // how many different places could this brick fit horizontally
32086 var groupCount = this.cols + 1 - colSpan;
32087 // for each group potential horizontal position
32088 for ( var i = 0; i < groupCount; i++ ) {
32089 // make an array of colY values for that one group
32090 var groupColYs = this.colYs.slice( i, i + colSpan );
32091 // and get the max value of the array
32092 colGroup[i] = Math.max.apply( Math, groupColYs );
32097 _manageStamp : function( stamp )
32099 var stampSize = stamp.getSize();
32100 var offset = stamp.getBox();
32101 // get the columns that this stamp affects
32102 var firstX = this.isOriginLeft ? offset.x : offset.right;
32103 var lastX = firstX + stampSize.width;
32104 var firstCol = Math.floor( firstX / this.columnWidth );
32105 firstCol = Math.max( 0, firstCol );
32107 var lastCol = Math.floor( lastX / this.columnWidth );
32108 // lastCol should not go over if multiple of columnWidth #425
32109 lastCol -= lastX % this.columnWidth ? 0 : 1;
32110 lastCol = Math.min( this.cols - 1, lastCol );
32112 // set colYs to bottom of the stamp
32113 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32116 for ( var i = firstCol; i <= lastCol; i++ ) {
32117 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32122 _getContainerSize : function()
32124 this.maxY = Math.max.apply( Math, this.colYs );
32129 if ( this.isFitWidth ) {
32130 size.width = this._getContainerFitWidth();
32136 _getContainerFitWidth : function()
32138 var unusedCols = 0;
32139 // count unused columns
32142 if ( this.colYs[i] !== 0 ) {
32147 // fit container to columns that have been used
32148 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32151 needsResizeLayout : function()
32153 var previousWidth = this.containerWidth;
32154 this.getContainerWidth();
32155 return previousWidth !== this.containerWidth;
32170 * @class Roo.bootstrap.MasonryBrick
32171 * @extends Roo.bootstrap.Component
32172 * Bootstrap MasonryBrick class
32175 * Create a new MasonryBrick
32176 * @param {Object} config The config object
32179 Roo.bootstrap.MasonryBrick = function(config){
32181 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32183 Roo.bootstrap.MasonryBrick.register(this);
32189 * When a MasonryBrick is clcik
32190 * @param {Roo.bootstrap.MasonryBrick} this
32191 * @param {Roo.EventObject} e
32197 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32200 * @cfg {String} title
32204 * @cfg {String} html
32208 * @cfg {String} bgimage
32212 * @cfg {String} videourl
32216 * @cfg {String} cls
32220 * @cfg {String} href
32224 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32229 * @cfg {String} placetitle (center|bottom)
32234 * @cfg {Boolean} isFitContainer defalut true
32236 isFitContainer : true,
32239 * @cfg {Boolean} preventDefault defalut false
32241 preventDefault : false,
32244 * @cfg {Boolean} inverse defalut false
32246 maskInverse : false,
32248 getAutoCreate : function()
32250 if(!this.isFitContainer){
32251 return this.getSplitAutoCreate();
32254 var cls = 'masonry-brick masonry-brick-full';
32256 if(this.href.length){
32257 cls += ' masonry-brick-link';
32260 if(this.bgimage.length){
32261 cls += ' masonry-brick-image';
32264 if(this.maskInverse){
32265 cls += ' mask-inverse';
32268 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32269 cls += ' enable-mask';
32273 cls += ' masonry-' + this.size + '-brick';
32276 if(this.placetitle.length){
32278 switch (this.placetitle) {
32280 cls += ' masonry-center-title';
32283 cls += ' masonry-bottom-title';
32290 if(!this.html.length && !this.bgimage.length){
32291 cls += ' masonry-center-title';
32294 if(!this.html.length && this.bgimage.length){
32295 cls += ' masonry-bottom-title';
32300 cls += ' ' + this.cls;
32304 tag: (this.href.length) ? 'a' : 'div',
32309 cls: 'masonry-brick-mask'
32313 cls: 'masonry-brick-paragraph',
32319 if(this.href.length){
32320 cfg.href = this.href;
32323 var cn = cfg.cn[1].cn;
32325 if(this.title.length){
32328 cls: 'masonry-brick-title',
32333 if(this.html.length){
32336 cls: 'masonry-brick-text',
32341 if (!this.title.length && !this.html.length) {
32342 cfg.cn[1].cls += ' hide';
32345 if(this.bgimage.length){
32348 cls: 'masonry-brick-image-view',
32353 if(this.videourl.length){
32354 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32355 // youtube support only?
32358 cls: 'masonry-brick-image-view',
32361 allowfullscreen : true
32369 getSplitAutoCreate : function()
32371 var cls = 'masonry-brick masonry-brick-split';
32373 if(this.href.length){
32374 cls += ' masonry-brick-link';
32377 if(this.bgimage.length){
32378 cls += ' masonry-brick-image';
32382 cls += ' masonry-' + this.size + '-brick';
32385 switch (this.placetitle) {
32387 cls += ' masonry-center-title';
32390 cls += ' masonry-bottom-title';
32393 if(!this.bgimage.length){
32394 cls += ' masonry-center-title';
32397 if(this.bgimage.length){
32398 cls += ' masonry-bottom-title';
32404 cls += ' ' + this.cls;
32408 tag: (this.href.length) ? 'a' : 'div',
32413 cls: 'masonry-brick-split-head',
32417 cls: 'masonry-brick-paragraph',
32424 cls: 'masonry-brick-split-body',
32430 if(this.href.length){
32431 cfg.href = this.href;
32434 if(this.title.length){
32435 cfg.cn[0].cn[0].cn.push({
32437 cls: 'masonry-brick-title',
32442 if(this.html.length){
32443 cfg.cn[1].cn.push({
32445 cls: 'masonry-brick-text',
32450 if(this.bgimage.length){
32451 cfg.cn[0].cn.push({
32453 cls: 'masonry-brick-image-view',
32458 if(this.videourl.length){
32459 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32460 // youtube support only?
32461 cfg.cn[0].cn.cn.push({
32463 cls: 'masonry-brick-image-view',
32466 allowfullscreen : true
32473 initEvents: function()
32475 switch (this.size) {
32508 this.el.on('touchstart', this.onTouchStart, this);
32509 this.el.on('touchmove', this.onTouchMove, this);
32510 this.el.on('touchend', this.onTouchEnd, this);
32511 this.el.on('contextmenu', this.onContextMenu, this);
32513 this.el.on('mouseenter' ,this.enter, this);
32514 this.el.on('mouseleave', this.leave, this);
32515 this.el.on('click', this.onClick, this);
32518 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32519 this.parent().bricks.push(this);
32524 onClick: function(e, el)
32526 var time = this.endTimer - this.startTimer;
32527 // Roo.log(e.preventDefault());
32530 e.preventDefault();
32535 if(!this.preventDefault){
32539 e.preventDefault();
32541 if (this.activcClass != '') {
32542 this.selectBrick();
32545 this.fireEvent('click', this);
32548 enter: function(e, el)
32550 e.preventDefault();
32552 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32556 if(this.bgimage.length && this.html.length){
32557 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32561 leave: function(e, el)
32563 e.preventDefault();
32565 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32569 if(this.bgimage.length && this.html.length){
32570 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32574 onTouchStart: function(e, el)
32576 // e.preventDefault();
32578 this.touchmoved = false;
32580 if(!this.isFitContainer){
32584 if(!this.bgimage.length || !this.html.length){
32588 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32590 this.timer = new Date().getTime();
32594 onTouchMove: function(e, el)
32596 this.touchmoved = true;
32599 onContextMenu : function(e,el)
32601 e.preventDefault();
32602 e.stopPropagation();
32606 onTouchEnd: function(e, el)
32608 // e.preventDefault();
32610 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32617 if(!this.bgimage.length || !this.html.length){
32619 if(this.href.length){
32620 window.location.href = this.href;
32626 if(!this.isFitContainer){
32630 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32632 window.location.href = this.href;
32635 //selection on single brick only
32636 selectBrick : function() {
32638 if (!this.parentId) {
32642 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32643 var index = m.selectedBrick.indexOf(this.id);
32646 m.selectedBrick.splice(index,1);
32647 this.el.removeClass(this.activeClass);
32651 for(var i = 0; i < m.selectedBrick.length; i++) {
32652 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32653 b.el.removeClass(b.activeClass);
32656 m.selectedBrick = [];
32658 m.selectedBrick.push(this.id);
32659 this.el.addClass(this.activeClass);
32665 Roo.apply(Roo.bootstrap.MasonryBrick, {
32668 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32670 * register a Masonry Brick
32671 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32674 register : function(brick)
32676 //this.groups[brick.id] = brick;
32677 this.groups.add(brick.id, brick);
32680 * fetch a masonry brick based on the masonry brick ID
32681 * @param {string} the masonry brick to add
32682 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32685 get: function(brick_id)
32687 // if (typeof(this.groups[brick_id]) == 'undefined') {
32690 // return this.groups[brick_id] ;
32692 if(this.groups.key(brick_id)) {
32693 return this.groups.key(brick_id);
32711 * @class Roo.bootstrap.Brick
32712 * @extends Roo.bootstrap.Component
32713 * Bootstrap Brick class
32716 * Create a new Brick
32717 * @param {Object} config The config object
32720 Roo.bootstrap.Brick = function(config){
32721 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32727 * When a Brick is click
32728 * @param {Roo.bootstrap.Brick} this
32729 * @param {Roo.EventObject} e
32735 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32738 * @cfg {String} title
32742 * @cfg {String} html
32746 * @cfg {String} bgimage
32750 * @cfg {String} cls
32754 * @cfg {String} href
32758 * @cfg {String} video
32762 * @cfg {Boolean} square
32766 getAutoCreate : function()
32768 var cls = 'roo-brick';
32770 if(this.href.length){
32771 cls += ' roo-brick-link';
32774 if(this.bgimage.length){
32775 cls += ' roo-brick-image';
32778 if(!this.html.length && !this.bgimage.length){
32779 cls += ' roo-brick-center-title';
32782 if(!this.html.length && this.bgimage.length){
32783 cls += ' roo-brick-bottom-title';
32787 cls += ' ' + this.cls;
32791 tag: (this.href.length) ? 'a' : 'div',
32796 cls: 'roo-brick-paragraph',
32802 if(this.href.length){
32803 cfg.href = this.href;
32806 var cn = cfg.cn[0].cn;
32808 if(this.title.length){
32811 cls: 'roo-brick-title',
32816 if(this.html.length){
32819 cls: 'roo-brick-text',
32826 if(this.bgimage.length){
32829 cls: 'roo-brick-image-view',
32837 initEvents: function()
32839 if(this.title.length || this.html.length){
32840 this.el.on('mouseenter' ,this.enter, this);
32841 this.el.on('mouseleave', this.leave, this);
32844 Roo.EventManager.onWindowResize(this.resize, this);
32846 if(this.bgimage.length){
32847 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32848 this.imageEl.on('load', this.onImageLoad, this);
32855 onImageLoad : function()
32860 resize : function()
32862 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32864 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32866 if(this.bgimage.length){
32867 var image = this.el.select('.roo-brick-image-view', true).first();
32869 image.setWidth(paragraph.getWidth());
32872 image.setHeight(paragraph.getWidth());
32875 this.el.setHeight(image.getHeight());
32876 paragraph.setHeight(image.getHeight());
32882 enter: function(e, el)
32884 e.preventDefault();
32886 if(this.bgimage.length){
32887 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32888 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32892 leave: function(e, el)
32894 e.preventDefault();
32896 if(this.bgimage.length){
32897 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32898 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32914 * @class Roo.bootstrap.NumberField
32915 * @extends Roo.bootstrap.Input
32916 * Bootstrap NumberField class
32922 * Create a new NumberField
32923 * @param {Object} config The config object
32926 Roo.bootstrap.NumberField = function(config){
32927 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32930 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32933 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
32935 allowDecimals : true,
32937 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
32939 decimalSeparator : ".",
32941 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
32943 decimalPrecision : 2,
32945 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
32947 allowNegative : true,
32949 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
32951 minValue : Number.NEGATIVE_INFINITY,
32953 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
32955 maxValue : Number.MAX_VALUE,
32957 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
32959 minText : "The minimum value for this field is {0}",
32961 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
32963 maxText : "The maximum value for this field is {0}",
32965 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
32966 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
32968 nanText : "{0} is not a valid number",
32970 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
32975 initEvents : function()
32977 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
32979 var allowed = "0123456789";
32981 if(this.allowDecimals){
32982 allowed += this.decimalSeparator;
32985 if(this.allowNegative){
32989 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
32991 var keyPress = function(e){
32993 var k = e.getKey();
32995 var c = e.getCharCode();
32998 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
32999 allowed.indexOf(String.fromCharCode(c)) === -1
33005 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33009 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33014 this.el.on("keypress", keyPress, this);
33017 validateValue : function(value)
33020 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33024 var num = this.parseValue(value);
33027 this.markInvalid(String.format(this.nanText, value));
33031 if(num < this.minValue){
33032 this.markInvalid(String.format(this.minText, this.minValue));
33036 if(num > this.maxValue){
33037 this.markInvalid(String.format(this.maxText, this.maxValue));
33044 getValue : function()
33046 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
33049 parseValue : function(value)
33051 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33052 return isNaN(value) ? '' : value;
33055 fixPrecision : function(value)
33057 var nan = isNaN(value);
33059 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33060 return nan ? '' : value;
33062 return parseFloat(value).toFixed(this.decimalPrecision);
33065 setValue : function(v)
33067 v = this.fixPrecision(v);
33068 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
33071 decimalPrecisionFcn : function(v)
33073 return Math.floor(v);
33076 beforeBlur : function()
33082 var v = this.parseValue(this.getRawValue());
33097 * @class Roo.bootstrap.DocumentSlider
33098 * @extends Roo.bootstrap.Component
33099 * Bootstrap DocumentSlider class
33102 * Create a new DocumentViewer
33103 * @param {Object} config The config object
33106 Roo.bootstrap.DocumentSlider = function(config){
33107 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33114 * Fire after initEvent
33115 * @param {Roo.bootstrap.DocumentSlider} this
33120 * Fire after update
33121 * @param {Roo.bootstrap.DocumentSlider} this
33127 * @param {Roo.bootstrap.DocumentSlider} this
33133 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33139 getAutoCreate : function()
33143 cls : 'roo-document-slider',
33147 cls : 'roo-document-slider-header',
33151 cls : 'roo-document-slider-header-title'
33157 cls : 'roo-document-slider-body',
33161 cls : 'roo-document-slider-prev',
33165 cls : 'fa fa-chevron-left'
33171 cls : 'roo-document-slider-thumb',
33175 cls : 'roo-document-slider-image'
33181 cls : 'roo-document-slider-next',
33185 cls : 'fa fa-chevron-right'
33197 initEvents : function()
33199 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33200 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33202 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33203 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33205 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33206 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33208 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33209 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33211 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33212 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33214 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33215 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33217 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33218 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33220 this.thumbEl.on('click', this.onClick, this);
33222 this.prevIndicator.on('click', this.prev, this);
33224 this.nextIndicator.on('click', this.next, this);
33228 initial : function()
33230 if(this.files.length){
33231 this.indicator = 1;
33235 this.fireEvent('initial', this);
33238 update : function()
33240 this.imageEl.attr('src', this.files[this.indicator - 1]);
33242 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33244 this.prevIndicator.show();
33246 if(this.indicator == 1){
33247 this.prevIndicator.hide();
33250 this.nextIndicator.show();
33252 if(this.indicator == this.files.length){
33253 this.nextIndicator.hide();
33256 this.thumbEl.scrollTo('top');
33258 this.fireEvent('update', this);
33261 onClick : function(e)
33263 e.preventDefault();
33265 this.fireEvent('click', this);
33270 e.preventDefault();
33272 this.indicator = Math.max(1, this.indicator - 1);
33279 e.preventDefault();
33281 this.indicator = Math.min(this.files.length, this.indicator + 1);
33295 * @class Roo.bootstrap.RadioSet
33296 * @extends Roo.bootstrap.Input
33297 * Bootstrap RadioSet class
33298 * @cfg {String} indicatorpos (left|right) default left
33299 * @cfg {Boolean} inline (true|false) inline the element (default true)
33300 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33302 * Create a new RadioSet
33303 * @param {Object} config The config object
33306 Roo.bootstrap.RadioSet = function(config){
33308 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33312 Roo.bootstrap.RadioSet.register(this);
33317 * Fires when the element is checked or unchecked.
33318 * @param {Roo.bootstrap.RadioSet} this This radio
33319 * @param {Roo.bootstrap.Radio} item The checked item
33326 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33334 indicatorpos : 'left',
33336 getAutoCreate : function()
33340 cls : 'roo-radio-set-label',
33344 html : this.fieldLabel
33349 if(this.indicatorpos == 'left'){
33352 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33353 tooltip : 'This field is required'
33358 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33359 tooltip : 'This field is required'
33365 cls : 'roo-radio-set-items'
33368 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33370 if (align === 'left' && this.fieldLabel.length) {
33373 cls : "roo-radio-set-right",
33379 if(this.labelWidth > 12){
33380 label.style = "width: " + this.labelWidth + 'px';
33383 if(this.labelWidth < 13 && this.labelmd == 0){
33384 this.labelmd = this.labelWidth;
33387 if(this.labellg > 0){
33388 label.cls += ' col-lg-' + this.labellg;
33389 items.cls += ' col-lg-' + (12 - this.labellg);
33392 if(this.labelmd > 0){
33393 label.cls += ' col-md-' + this.labelmd;
33394 items.cls += ' col-md-' + (12 - this.labelmd);
33397 if(this.labelsm > 0){
33398 label.cls += ' col-sm-' + this.labelsm;
33399 items.cls += ' col-sm-' + (12 - this.labelsm);
33402 if(this.labelxs > 0){
33403 label.cls += ' col-xs-' + this.labelxs;
33404 items.cls += ' col-xs-' + (12 - this.labelxs);
33410 cls : 'roo-radio-set',
33414 cls : 'roo-radio-set-input',
33417 value : this.value ? this.value : ''
33424 if(this.weight.length){
33425 cfg.cls += ' roo-radio-' + this.weight;
33429 cfg.cls += ' roo-radio-set-inline';
33433 ['xs','sm','md','lg'].map(function(size){
33434 if (settings[size]) {
33435 cfg.cls += ' col-' + size + '-' + settings[size];
33443 initEvents : function()
33445 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33446 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33448 if(!this.fieldLabel.length){
33449 this.labelEl.hide();
33452 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33453 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33455 this.indicatorEl().addClass('invisible');
33457 this.originalValue = this.getValue();
33461 inputEl: function ()
33463 return this.el.select('.roo-radio-set-input', true).first();
33466 getChildContainer : function()
33468 return this.itemsEl;
33471 register : function(item)
33473 this.radioes.push(item);
33477 validate : function()
33481 Roo.each(this.radioes, function(i){
33490 if(this.allowBlank) {
33494 if(this.disabled || valid){
33499 this.markInvalid();
33504 markValid : function()
33506 if(this.labelEl.isVisible(true)){
33507 this.indicatorEl().removeClass('visible');
33508 this.indicatorEl().addClass('invisible');
33511 this.el.removeClass([this.invalidClass, this.validClass]);
33512 this.el.addClass(this.validClass);
33514 this.fireEvent('valid', this);
33517 markInvalid : function(msg)
33519 if(this.allowBlank || this.disabled){
33523 if(this.labelEl.isVisible(true)){
33524 this.indicatorEl().removeClass('invisible');
33525 this.indicatorEl().addClass('visible');
33528 this.el.removeClass([this.invalidClass, this.validClass]);
33529 this.el.addClass(this.invalidClass);
33531 this.fireEvent('invalid', this, msg);
33535 setValue : function(v, suppressEvent)
33537 if(this.value === v){
33544 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33547 Roo.each(this.radioes, function(i){
33550 i.el.removeClass('checked');
33552 if(i.value === v || i.value.toString() === v.toString()){
33554 i.el.addClass('checked');
33556 if(suppressEvent !== true){
33557 this.fireEvent('check', this, i);
33566 clearInvalid : function(){
33568 if(!this.el || this.preventMark){
33572 this.el.removeClass([this.invalidClass]);
33574 this.fireEvent('valid', this);
33579 Roo.apply(Roo.bootstrap.RadioSet, {
33583 register : function(set)
33585 this.groups[set.name] = set;
33588 get: function(name)
33590 if (typeof(this.groups[name]) == 'undefined') {
33594 return this.groups[name] ;
33600 * Ext JS Library 1.1.1
33601 * Copyright(c) 2006-2007, Ext JS, LLC.
33603 * Originally Released Under LGPL - original licence link has changed is not relivant.
33606 * <script type="text/javascript">
33611 * @class Roo.bootstrap.SplitBar
33612 * @extends Roo.util.Observable
33613 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33617 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33618 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33619 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33620 split.minSize = 100;
33621 split.maxSize = 600;
33622 split.animate = true;
33623 split.on('moved', splitterMoved);
33626 * Create a new SplitBar
33627 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33628 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33629 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33630 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33631 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33632 position of the SplitBar).
33634 Roo.bootstrap.SplitBar = function(cfg){
33639 // dragElement : elm
33640 // resizingElement: el,
33642 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33643 // placement : Roo.bootstrap.SplitBar.LEFT ,
33644 // existingProxy ???
33647 this.el = Roo.get(cfg.dragElement, true);
33648 this.el.dom.unselectable = "on";
33650 this.resizingEl = Roo.get(cfg.resizingElement, true);
33654 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33655 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33658 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33661 * The minimum size of the resizing element. (Defaults to 0)
33667 * The maximum size of the resizing element. (Defaults to 2000)
33670 this.maxSize = 2000;
33673 * Whether to animate the transition to the new size
33676 this.animate = false;
33679 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33682 this.useShim = false;
33687 if(!cfg.existingProxy){
33689 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33691 this.proxy = Roo.get(cfg.existingProxy).dom;
33694 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33697 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33700 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33703 this.dragSpecs = {};
33706 * @private The adapter to use to positon and resize elements
33708 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33709 this.adapter.init(this);
33711 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33713 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33714 this.el.addClass("roo-splitbar-h");
33717 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33718 this.el.addClass("roo-splitbar-v");
33724 * Fires when the splitter is moved (alias for {@link #event-moved})
33725 * @param {Roo.bootstrap.SplitBar} this
33726 * @param {Number} newSize the new width or height
33731 * Fires when the splitter is moved
33732 * @param {Roo.bootstrap.SplitBar} this
33733 * @param {Number} newSize the new width or height
33737 * @event beforeresize
33738 * Fires before the splitter is dragged
33739 * @param {Roo.bootstrap.SplitBar} this
33741 "beforeresize" : true,
33743 "beforeapply" : true
33746 Roo.util.Observable.call(this);
33749 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33750 onStartProxyDrag : function(x, y){
33751 this.fireEvent("beforeresize", this);
33753 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33755 o.enableDisplayMode("block");
33756 // all splitbars share the same overlay
33757 Roo.bootstrap.SplitBar.prototype.overlay = o;
33759 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33760 this.overlay.show();
33761 Roo.get(this.proxy).setDisplayed("block");
33762 var size = this.adapter.getElementSize(this);
33763 this.activeMinSize = this.getMinimumSize();;
33764 this.activeMaxSize = this.getMaximumSize();;
33765 var c1 = size - this.activeMinSize;
33766 var c2 = Math.max(this.activeMaxSize - size, 0);
33767 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33768 this.dd.resetConstraints();
33769 this.dd.setXConstraint(
33770 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33771 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33773 this.dd.setYConstraint(0, 0);
33775 this.dd.resetConstraints();
33776 this.dd.setXConstraint(0, 0);
33777 this.dd.setYConstraint(
33778 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33779 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33782 this.dragSpecs.startSize = size;
33783 this.dragSpecs.startPoint = [x, y];
33784 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33788 * @private Called after the drag operation by the DDProxy
33790 onEndProxyDrag : function(e){
33791 Roo.get(this.proxy).setDisplayed(false);
33792 var endPoint = Roo.lib.Event.getXY(e);
33794 this.overlay.hide();
33797 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33798 newSize = this.dragSpecs.startSize +
33799 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33800 endPoint[0] - this.dragSpecs.startPoint[0] :
33801 this.dragSpecs.startPoint[0] - endPoint[0]
33804 newSize = this.dragSpecs.startSize +
33805 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33806 endPoint[1] - this.dragSpecs.startPoint[1] :
33807 this.dragSpecs.startPoint[1] - endPoint[1]
33810 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33811 if(newSize != this.dragSpecs.startSize){
33812 if(this.fireEvent('beforeapply', this, newSize) !== false){
33813 this.adapter.setElementSize(this, newSize);
33814 this.fireEvent("moved", this, newSize);
33815 this.fireEvent("resize", this, newSize);
33821 * Get the adapter this SplitBar uses
33822 * @return The adapter object
33824 getAdapter : function(){
33825 return this.adapter;
33829 * Set the adapter this SplitBar uses
33830 * @param {Object} adapter A SplitBar adapter object
33832 setAdapter : function(adapter){
33833 this.adapter = adapter;
33834 this.adapter.init(this);
33838 * Gets the minimum size for the resizing element
33839 * @return {Number} The minimum size
33841 getMinimumSize : function(){
33842 return this.minSize;
33846 * Sets the minimum size for the resizing element
33847 * @param {Number} minSize The minimum size
33849 setMinimumSize : function(minSize){
33850 this.minSize = minSize;
33854 * Gets the maximum size for the resizing element
33855 * @return {Number} The maximum size
33857 getMaximumSize : function(){
33858 return this.maxSize;
33862 * Sets the maximum size for the resizing element
33863 * @param {Number} maxSize The maximum size
33865 setMaximumSize : function(maxSize){
33866 this.maxSize = maxSize;
33870 * Sets the initialize size for the resizing element
33871 * @param {Number} size The initial size
33873 setCurrentSize : function(size){
33874 var oldAnimate = this.animate;
33875 this.animate = false;
33876 this.adapter.setElementSize(this, size);
33877 this.animate = oldAnimate;
33881 * Destroy this splitbar.
33882 * @param {Boolean} removeEl True to remove the element
33884 destroy : function(removeEl){
33886 this.shim.remove();
33889 this.proxy.parentNode.removeChild(this.proxy);
33897 * @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.
33899 Roo.bootstrap.SplitBar.createProxy = function(dir){
33900 var proxy = new Roo.Element(document.createElement("div"));
33901 proxy.unselectable();
33902 var cls = 'roo-splitbar-proxy';
33903 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
33904 document.body.appendChild(proxy.dom);
33909 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
33910 * Default Adapter. It assumes the splitter and resizing element are not positioned
33911 * elements and only gets/sets the width of the element. Generally used for table based layouts.
33913 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
33916 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
33917 // do nothing for now
33918 init : function(s){
33922 * Called before drag operations to get the current size of the resizing element.
33923 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33925 getElementSize : function(s){
33926 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33927 return s.resizingEl.getWidth();
33929 return s.resizingEl.getHeight();
33934 * Called after drag operations to set the size of the resizing element.
33935 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33936 * @param {Number} newSize The new size to set
33937 * @param {Function} onComplete A function to be invoked when resizing is complete
33939 setElementSize : function(s, newSize, onComplete){
33940 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33942 s.resizingEl.setWidth(newSize);
33944 onComplete(s, newSize);
33947 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
33952 s.resizingEl.setHeight(newSize);
33954 onComplete(s, newSize);
33957 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
33964 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
33965 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
33966 * Adapter that moves the splitter element to align with the resized sizing element.
33967 * Used with an absolute positioned SplitBar.
33968 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
33969 * document.body, make sure you assign an id to the body element.
33971 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
33972 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33973 this.container = Roo.get(container);
33976 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
33977 init : function(s){
33978 this.basic.init(s);
33981 getElementSize : function(s){
33982 return this.basic.getElementSize(s);
33985 setElementSize : function(s, newSize, onComplete){
33986 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
33989 moveSplitter : function(s){
33990 var yes = Roo.bootstrap.SplitBar;
33991 switch(s.placement){
33993 s.el.setX(s.resizingEl.getRight());
33996 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
33999 s.el.setY(s.resizingEl.getBottom());
34002 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34009 * Orientation constant - Create a vertical SplitBar
34013 Roo.bootstrap.SplitBar.VERTICAL = 1;
34016 * Orientation constant - Create a horizontal SplitBar
34020 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34023 * Placement constant - The resizing element is to the left of the splitter element
34027 Roo.bootstrap.SplitBar.LEFT = 1;
34030 * Placement constant - The resizing element is to the right of the splitter element
34034 Roo.bootstrap.SplitBar.RIGHT = 2;
34037 * Placement constant - The resizing element is positioned above the splitter element
34041 Roo.bootstrap.SplitBar.TOP = 3;
34044 * Placement constant - The resizing element is positioned under splitter element
34048 Roo.bootstrap.SplitBar.BOTTOM = 4;
34049 Roo.namespace("Roo.bootstrap.layout");/*
34051 * Ext JS Library 1.1.1
34052 * Copyright(c) 2006-2007, Ext JS, LLC.
34054 * Originally Released Under LGPL - original licence link has changed is not relivant.
34057 * <script type="text/javascript">
34061 * @class Roo.bootstrap.layout.Manager
34062 * @extends Roo.bootstrap.Component
34063 * Base class for layout managers.
34065 Roo.bootstrap.layout.Manager = function(config)
34067 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34073 /** false to disable window resize monitoring @type Boolean */
34074 this.monitorWindowResize = true;
34079 * Fires when a layout is performed.
34080 * @param {Roo.LayoutManager} this
34084 * @event regionresized
34085 * Fires when the user resizes a region.
34086 * @param {Roo.LayoutRegion} region The resized region
34087 * @param {Number} newSize The new size (width for east/west, height for north/south)
34089 "regionresized" : true,
34091 * @event regioncollapsed
34092 * Fires when a region is collapsed.
34093 * @param {Roo.LayoutRegion} region The collapsed region
34095 "regioncollapsed" : true,
34097 * @event regionexpanded
34098 * Fires when a region is expanded.
34099 * @param {Roo.LayoutRegion} region The expanded region
34101 "regionexpanded" : true
34103 this.updating = false;
34106 this.el = Roo.get(config.el);
34112 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34117 monitorWindowResize : true,
34123 onRender : function(ct, position)
34126 this.el = Roo.get(ct);
34129 //this.fireEvent('render',this);
34133 initEvents: function()
34137 // ie scrollbar fix
34138 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34139 document.body.scroll = "no";
34140 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34141 this.el.position('relative');
34143 this.id = this.el.id;
34144 this.el.addClass("roo-layout-container");
34145 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34146 if(this.el.dom != document.body ) {
34147 this.el.on('resize', this.layout,this);
34148 this.el.on('show', this.layout,this);
34154 * Returns true if this layout is currently being updated
34155 * @return {Boolean}
34157 isUpdating : function(){
34158 return this.updating;
34162 * Suspend the LayoutManager from doing auto-layouts while
34163 * making multiple add or remove calls
34165 beginUpdate : function(){
34166 this.updating = true;
34170 * Restore auto-layouts and optionally disable the manager from performing a layout
34171 * @param {Boolean} noLayout true to disable a layout update
34173 endUpdate : function(noLayout){
34174 this.updating = false;
34180 layout: function(){
34184 onRegionResized : function(region, newSize){
34185 this.fireEvent("regionresized", region, newSize);
34189 onRegionCollapsed : function(region){
34190 this.fireEvent("regioncollapsed", region);
34193 onRegionExpanded : function(region){
34194 this.fireEvent("regionexpanded", region);
34198 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34199 * performs box-model adjustments.
34200 * @return {Object} The size as an object {width: (the width), height: (the height)}
34202 getViewSize : function()
34205 if(this.el.dom != document.body){
34206 size = this.el.getSize();
34208 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34210 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34211 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34216 * Returns the Element this layout is bound to.
34217 * @return {Roo.Element}
34219 getEl : function(){
34224 * Returns the specified region.
34225 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34226 * @return {Roo.LayoutRegion}
34228 getRegion : function(target){
34229 return this.regions[target.toLowerCase()];
34232 onWindowResize : function(){
34233 if(this.monitorWindowResize){
34240 * Ext JS Library 1.1.1
34241 * Copyright(c) 2006-2007, Ext JS, LLC.
34243 * Originally Released Under LGPL - original licence link has changed is not relivant.
34246 * <script type="text/javascript">
34249 * @class Roo.bootstrap.layout.Border
34250 * @extends Roo.bootstrap.layout.Manager
34251 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34252 * please see: examples/bootstrap/nested.html<br><br>
34254 <b>The container the layout is rendered into can be either the body element or any other element.
34255 If it is not the body element, the container needs to either be an absolute positioned element,
34256 or you will need to add "position:relative" to the css of the container. You will also need to specify
34257 the container size if it is not the body element.</b>
34260 * Create a new Border
34261 * @param {Object} config Configuration options
34263 Roo.bootstrap.layout.Border = function(config){
34264 config = config || {};
34265 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34269 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34270 if(config[region]){
34271 config[region].region = region;
34272 this.addRegion(config[region]);
34278 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34280 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34282 * Creates and adds a new region if it doesn't already exist.
34283 * @param {String} target The target region key (north, south, east, west or center).
34284 * @param {Object} config The regions config object
34285 * @return {BorderLayoutRegion} The new region
34287 addRegion : function(config)
34289 if(!this.regions[config.region]){
34290 var r = this.factory(config);
34291 this.bindRegion(r);
34293 return this.regions[config.region];
34297 bindRegion : function(r){
34298 this.regions[r.config.region] = r;
34300 r.on("visibilitychange", this.layout, this);
34301 r.on("paneladded", this.layout, this);
34302 r.on("panelremoved", this.layout, this);
34303 r.on("invalidated", this.layout, this);
34304 r.on("resized", this.onRegionResized, this);
34305 r.on("collapsed", this.onRegionCollapsed, this);
34306 r.on("expanded", this.onRegionExpanded, this);
34310 * Performs a layout update.
34312 layout : function()
34314 if(this.updating) {
34318 // render all the rebions if they have not been done alreayd?
34319 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34320 if(this.regions[region] && !this.regions[region].bodyEl){
34321 this.regions[region].onRender(this.el)
34325 var size = this.getViewSize();
34326 var w = size.width;
34327 var h = size.height;
34332 //var x = 0, y = 0;
34334 var rs = this.regions;
34335 var north = rs["north"];
34336 var south = rs["south"];
34337 var west = rs["west"];
34338 var east = rs["east"];
34339 var center = rs["center"];
34340 //if(this.hideOnLayout){ // not supported anymore
34341 //c.el.setStyle("display", "none");
34343 if(north && north.isVisible()){
34344 var b = north.getBox();
34345 var m = north.getMargins();
34346 b.width = w - (m.left+m.right);
34349 centerY = b.height + b.y + m.bottom;
34350 centerH -= centerY;
34351 north.updateBox(this.safeBox(b));
34353 if(south && south.isVisible()){
34354 var b = south.getBox();
34355 var m = south.getMargins();
34356 b.width = w - (m.left+m.right);
34358 var totalHeight = (b.height + m.top + m.bottom);
34359 b.y = h - totalHeight + m.top;
34360 centerH -= totalHeight;
34361 south.updateBox(this.safeBox(b));
34363 if(west && west.isVisible()){
34364 var b = west.getBox();
34365 var m = west.getMargins();
34366 b.height = centerH - (m.top+m.bottom);
34368 b.y = centerY + m.top;
34369 var totalWidth = (b.width + m.left + m.right);
34370 centerX += totalWidth;
34371 centerW -= totalWidth;
34372 west.updateBox(this.safeBox(b));
34374 if(east && east.isVisible()){
34375 var b = east.getBox();
34376 var m = east.getMargins();
34377 b.height = centerH - (m.top+m.bottom);
34378 var totalWidth = (b.width + m.left + m.right);
34379 b.x = w - totalWidth + m.left;
34380 b.y = centerY + m.top;
34381 centerW -= totalWidth;
34382 east.updateBox(this.safeBox(b));
34385 var m = center.getMargins();
34387 x: centerX + m.left,
34388 y: centerY + m.top,
34389 width: centerW - (m.left+m.right),
34390 height: centerH - (m.top+m.bottom)
34392 //if(this.hideOnLayout){
34393 //center.el.setStyle("display", "block");
34395 center.updateBox(this.safeBox(centerBox));
34398 this.fireEvent("layout", this);
34402 safeBox : function(box){
34403 box.width = Math.max(0, box.width);
34404 box.height = Math.max(0, box.height);
34409 * Adds a ContentPanel (or subclass) to this layout.
34410 * @param {String} target The target region key (north, south, east, west or center).
34411 * @param {Roo.ContentPanel} panel The panel to add
34412 * @return {Roo.ContentPanel} The added panel
34414 add : function(target, panel){
34416 target = target.toLowerCase();
34417 return this.regions[target].add(panel);
34421 * Remove a ContentPanel (or subclass) to this layout.
34422 * @param {String} target The target region key (north, south, east, west or center).
34423 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34424 * @return {Roo.ContentPanel} The removed panel
34426 remove : function(target, panel){
34427 target = target.toLowerCase();
34428 return this.regions[target].remove(panel);
34432 * Searches all regions for a panel with the specified id
34433 * @param {String} panelId
34434 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34436 findPanel : function(panelId){
34437 var rs = this.regions;
34438 for(var target in rs){
34439 if(typeof rs[target] != "function"){
34440 var p = rs[target].getPanel(panelId);
34450 * Searches all regions for a panel with the specified id and activates (shows) it.
34451 * @param {String/ContentPanel} panelId The panels id or the panel itself
34452 * @return {Roo.ContentPanel} The shown panel or null
34454 showPanel : function(panelId) {
34455 var rs = this.regions;
34456 for(var target in rs){
34457 var r = rs[target];
34458 if(typeof r != "function"){
34459 if(r.hasPanel(panelId)){
34460 return r.showPanel(panelId);
34468 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34469 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34472 restoreState : function(provider){
34474 provider = Roo.state.Manager;
34476 var sm = new Roo.LayoutStateManager();
34477 sm.init(this, provider);
34483 * Adds a xtype elements to the layout.
34487 xtype : 'ContentPanel',
34494 xtype : 'NestedLayoutPanel',
34500 items : [ ... list of content panels or nested layout panels.. ]
34504 * @param {Object} cfg Xtype definition of item to add.
34506 addxtype : function(cfg)
34508 // basically accepts a pannel...
34509 // can accept a layout region..!?!?
34510 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34513 // theory? children can only be panels??
34515 //if (!cfg.xtype.match(/Panel$/)) {
34520 if (typeof(cfg.region) == 'undefined') {
34521 Roo.log("Failed to add Panel, region was not set");
34525 var region = cfg.region;
34531 xitems = cfg.items;
34538 case 'Content': // ContentPanel (el, cfg)
34539 case 'Scroll': // ContentPanel (el, cfg)
34541 cfg.autoCreate = true;
34542 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34544 // var el = this.el.createChild();
34545 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34548 this.add(region, ret);
34552 case 'TreePanel': // our new panel!
34553 cfg.el = this.el.createChild();
34554 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34555 this.add(region, ret);
34560 // create a new Layout (which is a Border Layout...
34562 var clayout = cfg.layout;
34563 clayout.el = this.el.createChild();
34564 clayout.items = clayout.items || [];
34568 // replace this exitems with the clayout ones..
34569 xitems = clayout.items;
34571 // force background off if it's in center...
34572 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34573 cfg.background = false;
34575 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34578 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34579 //console.log('adding nested layout panel ' + cfg.toSource());
34580 this.add(region, ret);
34581 nb = {}; /// find first...
34586 // needs grid and region
34588 //var el = this.getRegion(region).el.createChild();
34590 *var el = this.el.createChild();
34591 // create the grid first...
34592 cfg.grid.container = el;
34593 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34596 if (region == 'center' && this.active ) {
34597 cfg.background = false;
34600 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34602 this.add(region, ret);
34604 if (cfg.background) {
34605 // render grid on panel activation (if panel background)
34606 ret.on('activate', function(gp) {
34607 if (!gp.grid.rendered) {
34608 // gp.grid.render(el);
34612 // cfg.grid.render(el);
34618 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34619 // it was the old xcomponent building that caused this before.
34620 // espeically if border is the top element in the tree.
34630 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34632 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34633 this.add(region, ret);
34637 throw "Can not add '" + cfg.xtype + "' to Border";
34643 this.beginUpdate();
34647 Roo.each(xitems, function(i) {
34648 region = nb && i.region ? i.region : false;
34650 var add = ret.addxtype(i);
34653 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34654 if (!i.background) {
34655 abn[region] = nb[region] ;
34662 // make the last non-background panel active..
34663 //if (nb) { Roo.log(abn); }
34666 for(var r in abn) {
34667 region = this.getRegion(r);
34669 // tried using nb[r], but it does not work..
34671 region.showPanel(abn[r]);
34682 factory : function(cfg)
34685 var validRegions = Roo.bootstrap.layout.Border.regions;
34687 var target = cfg.region;
34690 var r = Roo.bootstrap.layout;
34694 return new r.North(cfg);
34696 return new r.South(cfg);
34698 return new r.East(cfg);
34700 return new r.West(cfg);
34702 return new r.Center(cfg);
34704 throw 'Layout region "'+target+'" not supported.';
34711 * Ext JS Library 1.1.1
34712 * Copyright(c) 2006-2007, Ext JS, LLC.
34714 * Originally Released Under LGPL - original licence link has changed is not relivant.
34717 * <script type="text/javascript">
34721 * @class Roo.bootstrap.layout.Basic
34722 * @extends Roo.util.Observable
34723 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34724 * and does not have a titlebar, tabs or any other features. All it does is size and position
34725 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34726 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34727 * @cfg {string} region the region that it inhabits..
34728 * @cfg {bool} skipConfig skip config?
34732 Roo.bootstrap.layout.Basic = function(config){
34734 this.mgr = config.mgr;
34736 this.position = config.region;
34738 var skipConfig = config.skipConfig;
34742 * @scope Roo.BasicLayoutRegion
34746 * @event beforeremove
34747 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34748 * @param {Roo.LayoutRegion} this
34749 * @param {Roo.ContentPanel} panel The panel
34750 * @param {Object} e The cancel event object
34752 "beforeremove" : true,
34754 * @event invalidated
34755 * Fires when the layout for this region is changed.
34756 * @param {Roo.LayoutRegion} this
34758 "invalidated" : true,
34760 * @event visibilitychange
34761 * Fires when this region is shown or hidden
34762 * @param {Roo.LayoutRegion} this
34763 * @param {Boolean} visibility true or false
34765 "visibilitychange" : true,
34767 * @event paneladded
34768 * Fires when a panel is added.
34769 * @param {Roo.LayoutRegion} this
34770 * @param {Roo.ContentPanel} panel The panel
34772 "paneladded" : true,
34774 * @event panelremoved
34775 * Fires when a panel is removed.
34776 * @param {Roo.LayoutRegion} this
34777 * @param {Roo.ContentPanel} panel The panel
34779 "panelremoved" : true,
34781 * @event beforecollapse
34782 * Fires when this region before collapse.
34783 * @param {Roo.LayoutRegion} this
34785 "beforecollapse" : true,
34788 * Fires when this region is collapsed.
34789 * @param {Roo.LayoutRegion} this
34791 "collapsed" : true,
34794 * Fires when this region is expanded.
34795 * @param {Roo.LayoutRegion} this
34800 * Fires when this region is slid into view.
34801 * @param {Roo.LayoutRegion} this
34803 "slideshow" : true,
34806 * Fires when this region slides out of view.
34807 * @param {Roo.LayoutRegion} this
34809 "slidehide" : true,
34811 * @event panelactivated
34812 * Fires when a panel is activated.
34813 * @param {Roo.LayoutRegion} this
34814 * @param {Roo.ContentPanel} panel The activated panel
34816 "panelactivated" : true,
34819 * Fires when the user resizes this region.
34820 * @param {Roo.LayoutRegion} this
34821 * @param {Number} newSize The new size (width for east/west, height for north/south)
34825 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34826 this.panels = new Roo.util.MixedCollection();
34827 this.panels.getKey = this.getPanelId.createDelegate(this);
34829 this.activePanel = null;
34830 // ensure listeners are added...
34832 if (config.listeners || config.events) {
34833 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34834 listeners : config.listeners || {},
34835 events : config.events || {}
34839 if(skipConfig !== true){
34840 this.applyConfig(config);
34844 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34846 getPanelId : function(p){
34850 applyConfig : function(config){
34851 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34852 this.config = config;
34857 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34858 * the width, for horizontal (north, south) the height.
34859 * @param {Number} newSize The new width or height
34861 resizeTo : function(newSize){
34862 var el = this.el ? this.el :
34863 (this.activePanel ? this.activePanel.getEl() : null);
34865 switch(this.position){
34868 el.setWidth(newSize);
34869 this.fireEvent("resized", this, newSize);
34873 el.setHeight(newSize);
34874 this.fireEvent("resized", this, newSize);
34880 getBox : function(){
34881 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34884 getMargins : function(){
34885 return this.margins;
34888 updateBox : function(box){
34890 var el = this.activePanel.getEl();
34891 el.dom.style.left = box.x + "px";
34892 el.dom.style.top = box.y + "px";
34893 this.activePanel.setSize(box.width, box.height);
34897 * Returns the container element for this region.
34898 * @return {Roo.Element}
34900 getEl : function(){
34901 return this.activePanel;
34905 * Returns true if this region is currently visible.
34906 * @return {Boolean}
34908 isVisible : function(){
34909 return this.activePanel ? true : false;
34912 setActivePanel : function(panel){
34913 panel = this.getPanel(panel);
34914 if(this.activePanel && this.activePanel != panel){
34915 this.activePanel.setActiveState(false);
34916 this.activePanel.getEl().setLeftTop(-10000,-10000);
34918 this.activePanel = panel;
34919 panel.setActiveState(true);
34921 panel.setSize(this.box.width, this.box.height);
34923 this.fireEvent("panelactivated", this, panel);
34924 this.fireEvent("invalidated");
34928 * Show the specified panel.
34929 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
34930 * @return {Roo.ContentPanel} The shown panel or null
34932 showPanel : function(panel){
34933 panel = this.getPanel(panel);
34935 this.setActivePanel(panel);
34941 * Get the active panel for this region.
34942 * @return {Roo.ContentPanel} The active panel or null
34944 getActivePanel : function(){
34945 return this.activePanel;
34949 * Add the passed ContentPanel(s)
34950 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
34951 * @return {Roo.ContentPanel} The panel added (if only one was added)
34953 add : function(panel){
34954 if(arguments.length > 1){
34955 for(var i = 0, len = arguments.length; i < len; i++) {
34956 this.add(arguments[i]);
34960 if(this.hasPanel(panel)){
34961 this.showPanel(panel);
34964 var el = panel.getEl();
34965 if(el.dom.parentNode != this.mgr.el.dom){
34966 this.mgr.el.dom.appendChild(el.dom);
34968 if(panel.setRegion){
34969 panel.setRegion(this);
34971 this.panels.add(panel);
34972 el.setStyle("position", "absolute");
34973 if(!panel.background){
34974 this.setActivePanel(panel);
34975 if(this.config.initialSize && this.panels.getCount()==1){
34976 this.resizeTo(this.config.initialSize);
34979 this.fireEvent("paneladded", this, panel);
34984 * Returns true if the panel is in this region.
34985 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34986 * @return {Boolean}
34988 hasPanel : function(panel){
34989 if(typeof panel == "object"){ // must be panel obj
34990 panel = panel.getId();
34992 return this.getPanel(panel) ? true : false;
34996 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
34997 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34998 * @param {Boolean} preservePanel Overrides the config preservePanel option
34999 * @return {Roo.ContentPanel} The panel that was removed
35001 remove : function(panel, preservePanel){
35002 panel = this.getPanel(panel);
35007 this.fireEvent("beforeremove", this, panel, e);
35008 if(e.cancel === true){
35011 var panelId = panel.getId();
35012 this.panels.removeKey(panelId);
35017 * Returns the panel specified or null if it's not in this region.
35018 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35019 * @return {Roo.ContentPanel}
35021 getPanel : function(id){
35022 if(typeof id == "object"){ // must be panel obj
35025 return this.panels.get(id);
35029 * Returns this regions position (north/south/east/west/center).
35032 getPosition: function(){
35033 return this.position;
35037 * Ext JS Library 1.1.1
35038 * Copyright(c) 2006-2007, Ext JS, LLC.
35040 * Originally Released Under LGPL - original licence link has changed is not relivant.
35043 * <script type="text/javascript">
35047 * @class Roo.bootstrap.layout.Region
35048 * @extends Roo.bootstrap.layout.Basic
35049 * This class represents a region in a layout manager.
35051 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35052 * @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})
35053 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35054 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35055 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35056 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35057 * @cfg {String} title The title for the region (overrides panel titles)
35058 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35059 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35060 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35061 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35062 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35063 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35064 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35065 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35066 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35067 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35069 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35070 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35071 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35072 * @cfg {Number} width For East/West panels
35073 * @cfg {Number} height For North/South panels
35074 * @cfg {Boolean} split To show the splitter
35075 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35077 * @cfg {string} cls Extra CSS classes to add to region
35079 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35080 * @cfg {string} region the region that it inhabits..
35083 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35084 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35086 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35087 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35088 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35090 Roo.bootstrap.layout.Region = function(config)
35092 this.applyConfig(config);
35094 var mgr = config.mgr;
35095 var pos = config.region;
35096 config.skipConfig = true;
35097 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35100 this.onRender(mgr.el);
35103 this.visible = true;
35104 this.collapsed = false;
35105 this.unrendered_panels = [];
35108 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35110 position: '', // set by wrapper (eg. north/south etc..)
35111 unrendered_panels : null, // unrendered panels.
35112 createBody : function(){
35113 /** This region's body element
35114 * @type Roo.Element */
35115 this.bodyEl = this.el.createChild({
35117 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35121 onRender: function(ctr, pos)
35123 var dh = Roo.DomHelper;
35124 /** This region's container element
35125 * @type Roo.Element */
35126 this.el = dh.append(ctr.dom, {
35128 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35130 /** This region's title element
35131 * @type Roo.Element */
35133 this.titleEl = dh.append(this.el.dom,
35136 unselectable: "on",
35137 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35139 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35140 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35143 this.titleEl.enableDisplayMode();
35144 /** This region's title text element
35145 * @type HTMLElement */
35146 this.titleTextEl = this.titleEl.dom.firstChild;
35147 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35149 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35150 this.closeBtn.enableDisplayMode();
35151 this.closeBtn.on("click", this.closeClicked, this);
35152 this.closeBtn.hide();
35154 this.createBody(this.config);
35155 if(this.config.hideWhenEmpty){
35157 this.on("paneladded", this.validateVisibility, this);
35158 this.on("panelremoved", this.validateVisibility, this);
35160 if(this.autoScroll){
35161 this.bodyEl.setStyle("overflow", "auto");
35163 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35165 //if(c.titlebar !== false){
35166 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35167 this.titleEl.hide();
35169 this.titleEl.show();
35170 if(this.config.title){
35171 this.titleTextEl.innerHTML = this.config.title;
35175 if(this.config.collapsed){
35176 this.collapse(true);
35178 if(this.config.hidden){
35182 if (this.unrendered_panels && this.unrendered_panels.length) {
35183 for (var i =0;i< this.unrendered_panels.length; i++) {
35184 this.add(this.unrendered_panels[i]);
35186 this.unrendered_panels = null;
35192 applyConfig : function(c)
35195 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35196 var dh = Roo.DomHelper;
35197 if(c.titlebar !== false){
35198 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35199 this.collapseBtn.on("click", this.collapse, this);
35200 this.collapseBtn.enableDisplayMode();
35202 if(c.showPin === true || this.showPin){
35203 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35204 this.stickBtn.enableDisplayMode();
35205 this.stickBtn.on("click", this.expand, this);
35206 this.stickBtn.hide();
35211 /** This region's collapsed element
35212 * @type Roo.Element */
35215 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35216 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35219 if(c.floatable !== false){
35220 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35221 this.collapsedEl.on("click", this.collapseClick, this);
35224 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35225 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35226 id: "message", unselectable: "on", style:{"float":"left"}});
35227 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35229 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35230 this.expandBtn.on("click", this.expand, this);
35234 if(this.collapseBtn){
35235 this.collapseBtn.setVisible(c.collapsible == true);
35238 this.cmargins = c.cmargins || this.cmargins ||
35239 (this.position == "west" || this.position == "east" ?
35240 {top: 0, left: 2, right:2, bottom: 0} :
35241 {top: 2, left: 0, right:0, bottom: 2});
35243 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35246 this.bottomTabs = c.tabPosition != "top";
35248 this.autoScroll = c.autoScroll || false;
35253 this.duration = c.duration || .30;
35254 this.slideDuration = c.slideDuration || .45;
35259 * Returns true if this region is currently visible.
35260 * @return {Boolean}
35262 isVisible : function(){
35263 return this.visible;
35267 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35268 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35270 //setCollapsedTitle : function(title){
35271 // title = title || " ";
35272 // if(this.collapsedTitleTextEl){
35273 // this.collapsedTitleTextEl.innerHTML = title;
35277 getBox : function(){
35279 // if(!this.collapsed){
35280 b = this.el.getBox(false, true);
35282 // b = this.collapsedEl.getBox(false, true);
35287 getMargins : function(){
35288 return this.margins;
35289 //return this.collapsed ? this.cmargins : this.margins;
35292 highlight : function(){
35293 this.el.addClass("x-layout-panel-dragover");
35296 unhighlight : function(){
35297 this.el.removeClass("x-layout-panel-dragover");
35300 updateBox : function(box)
35302 if (!this.bodyEl) {
35303 return; // not rendered yet..
35307 if(!this.collapsed){
35308 this.el.dom.style.left = box.x + "px";
35309 this.el.dom.style.top = box.y + "px";
35310 this.updateBody(box.width, box.height);
35312 this.collapsedEl.dom.style.left = box.x + "px";
35313 this.collapsedEl.dom.style.top = box.y + "px";
35314 this.collapsedEl.setSize(box.width, box.height);
35317 this.tabs.autoSizeTabs();
35321 updateBody : function(w, h)
35324 this.el.setWidth(w);
35325 w -= this.el.getBorderWidth("rl");
35326 if(this.config.adjustments){
35327 w += this.config.adjustments[0];
35330 if(h !== null && h > 0){
35331 this.el.setHeight(h);
35332 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35333 h -= this.el.getBorderWidth("tb");
35334 if(this.config.adjustments){
35335 h += this.config.adjustments[1];
35337 this.bodyEl.setHeight(h);
35339 h = this.tabs.syncHeight(h);
35342 if(this.panelSize){
35343 w = w !== null ? w : this.panelSize.width;
35344 h = h !== null ? h : this.panelSize.height;
35346 if(this.activePanel){
35347 var el = this.activePanel.getEl();
35348 w = w !== null ? w : el.getWidth();
35349 h = h !== null ? h : el.getHeight();
35350 this.panelSize = {width: w, height: h};
35351 this.activePanel.setSize(w, h);
35353 if(Roo.isIE && this.tabs){
35354 this.tabs.el.repaint();
35359 * Returns the container element for this region.
35360 * @return {Roo.Element}
35362 getEl : function(){
35367 * Hides this region.
35370 //if(!this.collapsed){
35371 this.el.dom.style.left = "-2000px";
35374 // this.collapsedEl.dom.style.left = "-2000px";
35375 // this.collapsedEl.hide();
35377 this.visible = false;
35378 this.fireEvent("visibilitychange", this, false);
35382 * Shows this region if it was previously hidden.
35385 //if(!this.collapsed){
35388 // this.collapsedEl.show();
35390 this.visible = true;
35391 this.fireEvent("visibilitychange", this, true);
35394 closeClicked : function(){
35395 if(this.activePanel){
35396 this.remove(this.activePanel);
35400 collapseClick : function(e){
35402 e.stopPropagation();
35405 e.stopPropagation();
35411 * Collapses this region.
35412 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35415 collapse : function(skipAnim, skipCheck = false){
35416 if(this.collapsed) {
35420 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35422 this.collapsed = true;
35424 this.split.el.hide();
35426 if(this.config.animate && skipAnim !== true){
35427 this.fireEvent("invalidated", this);
35428 this.animateCollapse();
35430 this.el.setLocation(-20000,-20000);
35432 this.collapsedEl.show();
35433 this.fireEvent("collapsed", this);
35434 this.fireEvent("invalidated", this);
35440 animateCollapse : function(){
35445 * Expands this region if it was previously collapsed.
35446 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35447 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35450 expand : function(e, skipAnim){
35452 e.stopPropagation();
35454 if(!this.collapsed || this.el.hasActiveFx()) {
35458 this.afterSlideIn();
35461 this.collapsed = false;
35462 if(this.config.animate && skipAnim !== true){
35463 this.animateExpand();
35467 this.split.el.show();
35469 this.collapsedEl.setLocation(-2000,-2000);
35470 this.collapsedEl.hide();
35471 this.fireEvent("invalidated", this);
35472 this.fireEvent("expanded", this);
35476 animateExpand : function(){
35480 initTabs : function()
35482 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35484 var ts = new Roo.bootstrap.panel.Tabs({
35485 el: this.bodyEl.dom,
35486 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35487 disableTooltips: this.config.disableTabTips,
35488 toolbar : this.config.toolbar
35491 if(this.config.hideTabs){
35492 ts.stripWrap.setDisplayed(false);
35495 ts.resizeTabs = this.config.resizeTabs === true;
35496 ts.minTabWidth = this.config.minTabWidth || 40;
35497 ts.maxTabWidth = this.config.maxTabWidth || 250;
35498 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35499 ts.monitorResize = false;
35500 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35501 ts.bodyEl.addClass('roo-layout-tabs-body');
35502 this.panels.each(this.initPanelAsTab, this);
35505 initPanelAsTab : function(panel){
35506 var ti = this.tabs.addTab(
35510 this.config.closeOnTab && panel.isClosable(),
35513 if(panel.tabTip !== undefined){
35514 ti.setTooltip(panel.tabTip);
35516 ti.on("activate", function(){
35517 this.setActivePanel(panel);
35520 if(this.config.closeOnTab){
35521 ti.on("beforeclose", function(t, e){
35523 this.remove(panel);
35527 panel.tabItem = ti;
35532 updatePanelTitle : function(panel, title)
35534 if(this.activePanel == panel){
35535 this.updateTitle(title);
35538 var ti = this.tabs.getTab(panel.getEl().id);
35540 if(panel.tabTip !== undefined){
35541 ti.setTooltip(panel.tabTip);
35546 updateTitle : function(title){
35547 if(this.titleTextEl && !this.config.title){
35548 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35552 setActivePanel : function(panel)
35554 panel = this.getPanel(panel);
35555 if(this.activePanel && this.activePanel != panel){
35556 if(this.activePanel.setActiveState(false) === false){
35560 this.activePanel = panel;
35561 panel.setActiveState(true);
35562 if(this.panelSize){
35563 panel.setSize(this.panelSize.width, this.panelSize.height);
35566 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35568 this.updateTitle(panel.getTitle());
35570 this.fireEvent("invalidated", this);
35572 this.fireEvent("panelactivated", this, panel);
35576 * Shows the specified panel.
35577 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35578 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35580 showPanel : function(panel)
35582 panel = this.getPanel(panel);
35585 var tab = this.tabs.getTab(panel.getEl().id);
35586 if(tab.isHidden()){
35587 this.tabs.unhideTab(tab.id);
35591 this.setActivePanel(panel);
35598 * Get the active panel for this region.
35599 * @return {Roo.ContentPanel} The active panel or null
35601 getActivePanel : function(){
35602 return this.activePanel;
35605 validateVisibility : function(){
35606 if(this.panels.getCount() < 1){
35607 this.updateTitle(" ");
35608 this.closeBtn.hide();
35611 if(!this.isVisible()){
35618 * Adds the passed ContentPanel(s) to this region.
35619 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35620 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35622 add : function(panel)
35624 if(arguments.length > 1){
35625 for(var i = 0, len = arguments.length; i < len; i++) {
35626 this.add(arguments[i]);
35631 // if we have not been rendered yet, then we can not really do much of this..
35632 if (!this.bodyEl) {
35633 this.unrendered_panels.push(panel);
35640 if(this.hasPanel(panel)){
35641 this.showPanel(panel);
35644 panel.setRegion(this);
35645 this.panels.add(panel);
35646 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35647 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35648 // and hide them... ???
35649 this.bodyEl.dom.appendChild(panel.getEl().dom);
35650 if(panel.background !== true){
35651 this.setActivePanel(panel);
35653 this.fireEvent("paneladded", this, panel);
35660 this.initPanelAsTab(panel);
35664 if(panel.background !== true){
35665 this.tabs.activate(panel.getEl().id);
35667 this.fireEvent("paneladded", this, panel);
35672 * Hides the tab for the specified panel.
35673 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35675 hidePanel : function(panel){
35676 if(this.tabs && (panel = this.getPanel(panel))){
35677 this.tabs.hideTab(panel.getEl().id);
35682 * Unhides the tab for a previously hidden panel.
35683 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35685 unhidePanel : function(panel){
35686 if(this.tabs && (panel = this.getPanel(panel))){
35687 this.tabs.unhideTab(panel.getEl().id);
35691 clearPanels : function(){
35692 while(this.panels.getCount() > 0){
35693 this.remove(this.panels.first());
35698 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35699 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35700 * @param {Boolean} preservePanel Overrides the config preservePanel option
35701 * @return {Roo.ContentPanel} The panel that was removed
35703 remove : function(panel, preservePanel)
35705 panel = this.getPanel(panel);
35710 this.fireEvent("beforeremove", this, panel, e);
35711 if(e.cancel === true){
35714 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35715 var panelId = panel.getId();
35716 this.panels.removeKey(panelId);
35718 document.body.appendChild(panel.getEl().dom);
35721 this.tabs.removeTab(panel.getEl().id);
35722 }else if (!preservePanel){
35723 this.bodyEl.dom.removeChild(panel.getEl().dom);
35725 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35726 var p = this.panels.first();
35727 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35728 tempEl.appendChild(p.getEl().dom);
35729 this.bodyEl.update("");
35730 this.bodyEl.dom.appendChild(p.getEl().dom);
35732 this.updateTitle(p.getTitle());
35734 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35735 this.setActivePanel(p);
35737 panel.setRegion(null);
35738 if(this.activePanel == panel){
35739 this.activePanel = null;
35741 if(this.config.autoDestroy !== false && preservePanel !== true){
35742 try{panel.destroy();}catch(e){}
35744 this.fireEvent("panelremoved", this, panel);
35749 * Returns the TabPanel component used by this region
35750 * @return {Roo.TabPanel}
35752 getTabs : function(){
35756 createTool : function(parentEl, className){
35757 var btn = Roo.DomHelper.append(parentEl, {
35759 cls: "x-layout-tools-button",
35762 cls: "roo-layout-tools-button-inner " + className,
35766 btn.addClassOnOver("roo-layout-tools-button-over");
35771 * Ext JS Library 1.1.1
35772 * Copyright(c) 2006-2007, Ext JS, LLC.
35774 * Originally Released Under LGPL - original licence link has changed is not relivant.
35777 * <script type="text/javascript">
35783 * @class Roo.SplitLayoutRegion
35784 * @extends Roo.LayoutRegion
35785 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35787 Roo.bootstrap.layout.Split = function(config){
35788 this.cursor = config.cursor;
35789 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35792 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35794 splitTip : "Drag to resize.",
35795 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35796 useSplitTips : false,
35798 applyConfig : function(config){
35799 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35802 onRender : function(ctr,pos) {
35804 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35805 if(!this.config.split){
35810 var splitEl = Roo.DomHelper.append(ctr.dom, {
35812 id: this.el.id + "-split",
35813 cls: "roo-layout-split roo-layout-split-"+this.position,
35816 /** The SplitBar for this region
35817 * @type Roo.SplitBar */
35818 // does not exist yet...
35819 Roo.log([this.position, this.orientation]);
35821 this.split = new Roo.bootstrap.SplitBar({
35822 dragElement : splitEl,
35823 resizingElement: this.el,
35824 orientation : this.orientation
35827 this.split.on("moved", this.onSplitMove, this);
35828 this.split.useShim = this.config.useShim === true;
35829 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35830 if(this.useSplitTips){
35831 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35833 //if(config.collapsible){
35834 // this.split.el.on("dblclick", this.collapse, this);
35837 if(typeof this.config.minSize != "undefined"){
35838 this.split.minSize = this.config.minSize;
35840 if(typeof this.config.maxSize != "undefined"){
35841 this.split.maxSize = this.config.maxSize;
35843 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35844 this.hideSplitter();
35849 getHMaxSize : function(){
35850 var cmax = this.config.maxSize || 10000;
35851 var center = this.mgr.getRegion("center");
35852 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35855 getVMaxSize : function(){
35856 var cmax = this.config.maxSize || 10000;
35857 var center = this.mgr.getRegion("center");
35858 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35861 onSplitMove : function(split, newSize){
35862 this.fireEvent("resized", this, newSize);
35866 * Returns the {@link Roo.SplitBar} for this region.
35867 * @return {Roo.SplitBar}
35869 getSplitBar : function(){
35874 this.hideSplitter();
35875 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35878 hideSplitter : function(){
35880 this.split.el.setLocation(-2000,-2000);
35881 this.split.el.hide();
35887 this.split.el.show();
35889 Roo.bootstrap.layout.Split.superclass.show.call(this);
35892 beforeSlide: function(){
35893 if(Roo.isGecko){// firefox overflow auto bug workaround
35894 this.bodyEl.clip();
35896 this.tabs.bodyEl.clip();
35898 if(this.activePanel){
35899 this.activePanel.getEl().clip();
35901 if(this.activePanel.beforeSlide){
35902 this.activePanel.beforeSlide();
35908 afterSlide : function(){
35909 if(Roo.isGecko){// firefox overflow auto bug workaround
35910 this.bodyEl.unclip();
35912 this.tabs.bodyEl.unclip();
35914 if(this.activePanel){
35915 this.activePanel.getEl().unclip();
35916 if(this.activePanel.afterSlide){
35917 this.activePanel.afterSlide();
35923 initAutoHide : function(){
35924 if(this.autoHide !== false){
35925 if(!this.autoHideHd){
35926 var st = new Roo.util.DelayedTask(this.slideIn, this);
35927 this.autoHideHd = {
35928 "mouseout": function(e){
35929 if(!e.within(this.el, true)){
35933 "mouseover" : function(e){
35939 this.el.on(this.autoHideHd);
35943 clearAutoHide : function(){
35944 if(this.autoHide !== false){
35945 this.el.un("mouseout", this.autoHideHd.mouseout);
35946 this.el.un("mouseover", this.autoHideHd.mouseover);
35950 clearMonitor : function(){
35951 Roo.get(document).un("click", this.slideInIf, this);
35954 // these names are backwards but not changed for compat
35955 slideOut : function(){
35956 if(this.isSlid || this.el.hasActiveFx()){
35959 this.isSlid = true;
35960 if(this.collapseBtn){
35961 this.collapseBtn.hide();
35963 this.closeBtnState = this.closeBtn.getStyle('display');
35964 this.closeBtn.hide();
35966 this.stickBtn.show();
35969 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
35970 this.beforeSlide();
35971 this.el.setStyle("z-index", 10001);
35972 this.el.slideIn(this.getSlideAnchor(), {
35973 callback: function(){
35975 this.initAutoHide();
35976 Roo.get(document).on("click", this.slideInIf, this);
35977 this.fireEvent("slideshow", this);
35984 afterSlideIn : function(){
35985 this.clearAutoHide();
35986 this.isSlid = false;
35987 this.clearMonitor();
35988 this.el.setStyle("z-index", "");
35989 if(this.collapseBtn){
35990 this.collapseBtn.show();
35992 this.closeBtn.setStyle('display', this.closeBtnState);
35994 this.stickBtn.hide();
35996 this.fireEvent("slidehide", this);
35999 slideIn : function(cb){
36000 if(!this.isSlid || this.el.hasActiveFx()){
36004 this.isSlid = false;
36005 this.beforeSlide();
36006 this.el.slideOut(this.getSlideAnchor(), {
36007 callback: function(){
36008 this.el.setLeftTop(-10000, -10000);
36010 this.afterSlideIn();
36018 slideInIf : function(e){
36019 if(!e.within(this.el)){
36024 animateCollapse : function(){
36025 this.beforeSlide();
36026 this.el.setStyle("z-index", 20000);
36027 var anchor = this.getSlideAnchor();
36028 this.el.slideOut(anchor, {
36029 callback : function(){
36030 this.el.setStyle("z-index", "");
36031 this.collapsedEl.slideIn(anchor, {duration:.3});
36033 this.el.setLocation(-10000,-10000);
36035 this.fireEvent("collapsed", this);
36042 animateExpand : function(){
36043 this.beforeSlide();
36044 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36045 this.el.setStyle("z-index", 20000);
36046 this.collapsedEl.hide({
36049 this.el.slideIn(this.getSlideAnchor(), {
36050 callback : function(){
36051 this.el.setStyle("z-index", "");
36054 this.split.el.show();
36056 this.fireEvent("invalidated", this);
36057 this.fireEvent("expanded", this);
36085 getAnchor : function(){
36086 return this.anchors[this.position];
36089 getCollapseAnchor : function(){
36090 return this.canchors[this.position];
36093 getSlideAnchor : function(){
36094 return this.sanchors[this.position];
36097 getAlignAdj : function(){
36098 var cm = this.cmargins;
36099 switch(this.position){
36115 getExpandAdj : function(){
36116 var c = this.collapsedEl, cm = this.cmargins;
36117 switch(this.position){
36119 return [-(cm.right+c.getWidth()+cm.left), 0];
36122 return [cm.right+c.getWidth()+cm.left, 0];
36125 return [0, -(cm.top+cm.bottom+c.getHeight())];
36128 return [0, cm.top+cm.bottom+c.getHeight()];
36134 * Ext JS Library 1.1.1
36135 * Copyright(c) 2006-2007, Ext JS, LLC.
36137 * Originally Released Under LGPL - original licence link has changed is not relivant.
36140 * <script type="text/javascript">
36143 * These classes are private internal classes
36145 Roo.bootstrap.layout.Center = function(config){
36146 config.region = "center";
36147 Roo.bootstrap.layout.Region.call(this, config);
36148 this.visible = true;
36149 this.minWidth = config.minWidth || 20;
36150 this.minHeight = config.minHeight || 20;
36153 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36155 // center panel can't be hidden
36159 // center panel can't be hidden
36162 getMinWidth: function(){
36163 return this.minWidth;
36166 getMinHeight: function(){
36167 return this.minHeight;
36180 Roo.bootstrap.layout.North = function(config)
36182 config.region = 'north';
36183 config.cursor = 'n-resize';
36185 Roo.bootstrap.layout.Split.call(this, config);
36189 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36190 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36191 this.split.el.addClass("roo-layout-split-v");
36193 var size = config.initialSize || config.height;
36194 if(typeof size != "undefined"){
36195 this.el.setHeight(size);
36198 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36200 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36204 getBox : function(){
36205 if(this.collapsed){
36206 return this.collapsedEl.getBox();
36208 var box = this.el.getBox();
36210 box.height += this.split.el.getHeight();
36215 updateBox : function(box){
36216 if(this.split && !this.collapsed){
36217 box.height -= this.split.el.getHeight();
36218 this.split.el.setLeft(box.x);
36219 this.split.el.setTop(box.y+box.height);
36220 this.split.el.setWidth(box.width);
36222 if(this.collapsed){
36223 this.updateBody(box.width, null);
36225 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36233 Roo.bootstrap.layout.South = function(config){
36234 config.region = 'south';
36235 config.cursor = 's-resize';
36236 Roo.bootstrap.layout.Split.call(this, config);
36238 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36239 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36240 this.split.el.addClass("roo-layout-split-v");
36242 var size = config.initialSize || config.height;
36243 if(typeof size != "undefined"){
36244 this.el.setHeight(size);
36248 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36249 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36250 getBox : function(){
36251 if(this.collapsed){
36252 return this.collapsedEl.getBox();
36254 var box = this.el.getBox();
36256 var sh = this.split.el.getHeight();
36263 updateBox : function(box){
36264 if(this.split && !this.collapsed){
36265 var sh = this.split.el.getHeight();
36268 this.split.el.setLeft(box.x);
36269 this.split.el.setTop(box.y-sh);
36270 this.split.el.setWidth(box.width);
36272 if(this.collapsed){
36273 this.updateBody(box.width, null);
36275 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36279 Roo.bootstrap.layout.East = function(config){
36280 config.region = "east";
36281 config.cursor = "e-resize";
36282 Roo.bootstrap.layout.Split.call(this, config);
36284 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36285 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36286 this.split.el.addClass("roo-layout-split-h");
36288 var size = config.initialSize || config.width;
36289 if(typeof size != "undefined"){
36290 this.el.setWidth(size);
36293 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36294 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36295 getBox : function(){
36296 if(this.collapsed){
36297 return this.collapsedEl.getBox();
36299 var box = this.el.getBox();
36301 var sw = this.split.el.getWidth();
36308 updateBox : function(box){
36309 if(this.split && !this.collapsed){
36310 var sw = this.split.el.getWidth();
36312 this.split.el.setLeft(box.x);
36313 this.split.el.setTop(box.y);
36314 this.split.el.setHeight(box.height);
36317 if(this.collapsed){
36318 this.updateBody(null, box.height);
36320 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36324 Roo.bootstrap.layout.West = function(config){
36325 config.region = "west";
36326 config.cursor = "w-resize";
36328 Roo.bootstrap.layout.Split.call(this, config);
36330 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36331 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36332 this.split.el.addClass("roo-layout-split-h");
36336 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36337 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36339 onRender: function(ctr, pos)
36341 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36342 var size = this.config.initialSize || this.config.width;
36343 if(typeof size != "undefined"){
36344 this.el.setWidth(size);
36348 getBox : function(){
36349 if(this.collapsed){
36350 return this.collapsedEl.getBox();
36352 var box = this.el.getBox();
36354 box.width += this.split.el.getWidth();
36359 updateBox : function(box){
36360 if(this.split && !this.collapsed){
36361 var sw = this.split.el.getWidth();
36363 this.split.el.setLeft(box.x+box.width);
36364 this.split.el.setTop(box.y);
36365 this.split.el.setHeight(box.height);
36367 if(this.collapsed){
36368 this.updateBody(null, box.height);
36370 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36373 Roo.namespace("Roo.bootstrap.panel");/*
36375 * Ext JS Library 1.1.1
36376 * Copyright(c) 2006-2007, Ext JS, LLC.
36378 * Originally Released Under LGPL - original licence link has changed is not relivant.
36381 * <script type="text/javascript">
36384 * @class Roo.ContentPanel
36385 * @extends Roo.util.Observable
36386 * A basic ContentPanel element.
36387 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36388 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36389 * @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
36390 * @cfg {Boolean} closable True if the panel can be closed/removed
36391 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36392 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36393 * @cfg {Toolbar} toolbar A toolbar for this panel
36394 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36395 * @cfg {String} title The title for this panel
36396 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36397 * @cfg {String} url Calls {@link #setUrl} with this value
36398 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36399 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36400 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36401 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36402 * @cfg {Boolean} badges render the badges
36405 * Create a new ContentPanel.
36406 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36407 * @param {String/Object} config A string to set only the title or a config object
36408 * @param {String} content (optional) Set the HTML content for this panel
36409 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36411 Roo.bootstrap.panel.Content = function( config){
36413 this.tpl = config.tpl || false;
36415 var el = config.el;
36416 var content = config.content;
36418 if(config.autoCreate){ // xtype is available if this is called from factory
36421 this.el = Roo.get(el);
36422 if(!this.el && config && config.autoCreate){
36423 if(typeof config.autoCreate == "object"){
36424 if(!config.autoCreate.id){
36425 config.autoCreate.id = config.id||el;
36427 this.el = Roo.DomHelper.append(document.body,
36428 config.autoCreate, true);
36430 var elcfg = { tag: "div",
36431 cls: "roo-layout-inactive-content",
36435 elcfg.html = config.html;
36439 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36442 this.closable = false;
36443 this.loaded = false;
36444 this.active = false;
36447 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36449 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36451 this.wrapEl = this.el; //this.el.wrap();
36453 if (config.toolbar.items) {
36454 ti = config.toolbar.items ;
36455 delete config.toolbar.items ;
36459 this.toolbar.render(this.wrapEl, 'before');
36460 for(var i =0;i < ti.length;i++) {
36461 // Roo.log(['add child', items[i]]);
36462 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36464 this.toolbar.items = nitems;
36465 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36466 delete config.toolbar;
36470 // xtype created footer. - not sure if will work as we normally have to render first..
36471 if (this.footer && !this.footer.el && this.footer.xtype) {
36472 if (!this.wrapEl) {
36473 this.wrapEl = this.el.wrap();
36476 this.footer.container = this.wrapEl.createChild();
36478 this.footer = Roo.factory(this.footer, Roo);
36483 if(typeof config == "string"){
36484 this.title = config;
36486 Roo.apply(this, config);
36490 this.resizeEl = Roo.get(this.resizeEl, true);
36492 this.resizeEl = this.el;
36494 // handle view.xtype
36502 * Fires when this panel is activated.
36503 * @param {Roo.ContentPanel} this
36507 * @event deactivate
36508 * Fires when this panel is activated.
36509 * @param {Roo.ContentPanel} this
36511 "deactivate" : true,
36515 * Fires when this panel is resized if fitToFrame is true.
36516 * @param {Roo.ContentPanel} this
36517 * @param {Number} width The width after any component adjustments
36518 * @param {Number} height The height after any component adjustments
36524 * Fires when this tab is created
36525 * @param {Roo.ContentPanel} this
36536 if(this.autoScroll){
36537 this.resizeEl.setStyle("overflow", "auto");
36539 // fix randome scrolling
36540 //this.el.on('scroll', function() {
36541 // Roo.log('fix random scolling');
36542 // this.scrollTo('top',0);
36545 content = content || this.content;
36547 this.setContent(content);
36549 if(config && config.url){
36550 this.setUrl(this.url, this.params, this.loadOnce);
36555 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36557 if (this.view && typeof(this.view.xtype) != 'undefined') {
36558 this.view.el = this.el.appendChild(document.createElement("div"));
36559 this.view = Roo.factory(this.view);
36560 this.view.render && this.view.render(false, '');
36564 this.fireEvent('render', this);
36567 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36571 setRegion : function(region){
36572 this.region = region;
36573 this.setActiveClass(region && !this.background);
36577 setActiveClass: function(state)
36580 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36581 this.el.setStyle('position','relative');
36583 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36584 this.el.setStyle('position', 'absolute');
36589 * Returns the toolbar for this Panel if one was configured.
36590 * @return {Roo.Toolbar}
36592 getToolbar : function(){
36593 return this.toolbar;
36596 setActiveState : function(active)
36598 this.active = active;
36599 this.setActiveClass(active);
36601 if(this.fireEvent("deactivate", this) === false){
36606 this.fireEvent("activate", this);
36610 * Updates this panel's element
36611 * @param {String} content The new content
36612 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36614 setContent : function(content, loadScripts){
36615 this.el.update(content, loadScripts);
36618 ignoreResize : function(w, h){
36619 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36622 this.lastSize = {width: w, height: h};
36627 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36628 * @return {Roo.UpdateManager} The UpdateManager
36630 getUpdateManager : function(){
36631 return this.el.getUpdateManager();
36634 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36635 * @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:
36638 url: "your-url.php",
36639 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36640 callback: yourFunction,
36641 scope: yourObject, //(optional scope)
36644 text: "Loading...",
36649 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36650 * 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.
36651 * @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}
36652 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36653 * @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.
36654 * @return {Roo.ContentPanel} this
36657 var um = this.el.getUpdateManager();
36658 um.update.apply(um, arguments);
36664 * 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.
36665 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36666 * @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)
36667 * @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)
36668 * @return {Roo.UpdateManager} The UpdateManager
36670 setUrl : function(url, params, loadOnce){
36671 if(this.refreshDelegate){
36672 this.removeListener("activate", this.refreshDelegate);
36674 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36675 this.on("activate", this.refreshDelegate);
36676 return this.el.getUpdateManager();
36679 _handleRefresh : function(url, params, loadOnce){
36680 if(!loadOnce || !this.loaded){
36681 var updater = this.el.getUpdateManager();
36682 updater.update(url, params, this._setLoaded.createDelegate(this));
36686 _setLoaded : function(){
36687 this.loaded = true;
36691 * Returns this panel's id
36694 getId : function(){
36699 * Returns this panel's element - used by regiosn to add.
36700 * @return {Roo.Element}
36702 getEl : function(){
36703 return this.wrapEl || this.el;
36708 adjustForComponents : function(width, height)
36710 //Roo.log('adjustForComponents ');
36711 if(this.resizeEl != this.el){
36712 width -= this.el.getFrameWidth('lr');
36713 height -= this.el.getFrameWidth('tb');
36716 var te = this.toolbar.getEl();
36717 te.setWidth(width);
36718 height -= te.getHeight();
36721 var te = this.footer.getEl();
36722 te.setWidth(width);
36723 height -= te.getHeight();
36727 if(this.adjustments){
36728 width += this.adjustments[0];
36729 height += this.adjustments[1];
36731 return {"width": width, "height": height};
36734 setSize : function(width, height){
36735 if(this.fitToFrame && !this.ignoreResize(width, height)){
36736 if(this.fitContainer && this.resizeEl != this.el){
36737 this.el.setSize(width, height);
36739 var size = this.adjustForComponents(width, height);
36740 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36741 this.fireEvent('resize', this, size.width, size.height);
36746 * Returns this panel's title
36749 getTitle : function(){
36751 if (typeof(this.title) != 'object') {
36756 for (var k in this.title) {
36757 if (!this.title.hasOwnProperty(k)) {
36761 if (k.indexOf('-') >= 0) {
36762 var s = k.split('-');
36763 for (var i = 0; i<s.length; i++) {
36764 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36767 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36774 * Set this panel's title
36775 * @param {String} title
36777 setTitle : function(title){
36778 this.title = title;
36780 this.region.updatePanelTitle(this, title);
36785 * Returns true is this panel was configured to be closable
36786 * @return {Boolean}
36788 isClosable : function(){
36789 return this.closable;
36792 beforeSlide : function(){
36794 this.resizeEl.clip();
36797 afterSlide : function(){
36799 this.resizeEl.unclip();
36803 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36804 * Will fail silently if the {@link #setUrl} method has not been called.
36805 * This does not activate the panel, just updates its content.
36807 refresh : function(){
36808 if(this.refreshDelegate){
36809 this.loaded = false;
36810 this.refreshDelegate();
36815 * Destroys this panel
36817 destroy : function(){
36818 this.el.removeAllListeners();
36819 var tempEl = document.createElement("span");
36820 tempEl.appendChild(this.el.dom);
36821 tempEl.innerHTML = "";
36827 * form - if the content panel contains a form - this is a reference to it.
36828 * @type {Roo.form.Form}
36832 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36833 * This contains a reference to it.
36839 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36849 * @param {Object} cfg Xtype definition of item to add.
36853 getChildContainer: function () {
36854 return this.getEl();
36859 var ret = new Roo.factory(cfg);
36864 if (cfg.xtype.match(/^Form$/)) {
36867 //if (this.footer) {
36868 // el = this.footer.container.insertSibling(false, 'before');
36870 el = this.el.createChild();
36873 this.form = new Roo.form.Form(cfg);
36876 if ( this.form.allItems.length) {
36877 this.form.render(el.dom);
36881 // should only have one of theses..
36882 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36883 // views.. should not be just added - used named prop 'view''
36885 cfg.el = this.el.appendChild(document.createElement("div"));
36888 var ret = new Roo.factory(cfg);
36890 ret.render && ret.render(false, ''); // render blank..
36900 * @class Roo.bootstrap.panel.Grid
36901 * @extends Roo.bootstrap.panel.Content
36903 * Create a new GridPanel.
36904 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
36905 * @param {Object} config A the config object
36911 Roo.bootstrap.panel.Grid = function(config)
36915 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
36916 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
36918 config.el = this.wrapper;
36919 //this.el = this.wrapper;
36921 if (config.container) {
36922 // ctor'ed from a Border/panel.grid
36925 this.wrapper.setStyle("overflow", "hidden");
36926 this.wrapper.addClass('roo-grid-container');
36931 if(config.toolbar){
36932 var tool_el = this.wrapper.createChild();
36933 this.toolbar = Roo.factory(config.toolbar);
36935 if (config.toolbar.items) {
36936 ti = config.toolbar.items ;
36937 delete config.toolbar.items ;
36941 this.toolbar.render(tool_el);
36942 for(var i =0;i < ti.length;i++) {
36943 // Roo.log(['add child', items[i]]);
36944 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36946 this.toolbar.items = nitems;
36948 delete config.toolbar;
36951 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
36952 config.grid.scrollBody = true;;
36953 config.grid.monitorWindowResize = false; // turn off autosizing
36954 config.grid.autoHeight = false;
36955 config.grid.autoWidth = false;
36957 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
36959 if (config.background) {
36960 // render grid on panel activation (if panel background)
36961 this.on('activate', function(gp) {
36962 if (!gp.grid.rendered) {
36963 gp.grid.render(this.wrapper);
36964 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36969 this.grid.render(this.wrapper);
36970 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36973 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
36974 // ??? needed ??? config.el = this.wrapper;
36979 // xtype created footer. - not sure if will work as we normally have to render first..
36980 if (this.footer && !this.footer.el && this.footer.xtype) {
36982 var ctr = this.grid.getView().getFooterPanel(true);
36983 this.footer.dataSource = this.grid.dataSource;
36984 this.footer = Roo.factory(this.footer, Roo);
36985 this.footer.render(ctr);
36995 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
36996 getId : function(){
36997 return this.grid.id;
37001 * Returns the grid for this panel
37002 * @return {Roo.bootstrap.Table}
37004 getGrid : function(){
37008 setSize : function(width, height){
37009 if(!this.ignoreResize(width, height)){
37010 var grid = this.grid;
37011 var size = this.adjustForComponents(width, height);
37012 var gridel = grid.getGridEl();
37013 gridel.setSize(size.width, size.height);
37015 var thd = grid.getGridEl().select('thead',true).first();
37016 var tbd = grid.getGridEl().select('tbody', true).first();
37018 tbd.setSize(width, height - thd.getHeight());
37027 beforeSlide : function(){
37028 this.grid.getView().scroller.clip();
37031 afterSlide : function(){
37032 this.grid.getView().scroller.unclip();
37035 destroy : function(){
37036 this.grid.destroy();
37038 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37043 * @class Roo.bootstrap.panel.Nest
37044 * @extends Roo.bootstrap.panel.Content
37046 * Create a new Panel, that can contain a layout.Border.
37049 * @param {Roo.BorderLayout} layout The layout for this panel
37050 * @param {String/Object} config A string to set only the title or a config object
37052 Roo.bootstrap.panel.Nest = function(config)
37054 // construct with only one argument..
37055 /* FIXME - implement nicer consturctors
37056 if (layout.layout) {
37058 layout = config.layout;
37059 delete config.layout;
37061 if (layout.xtype && !layout.getEl) {
37062 // then layout needs constructing..
37063 layout = Roo.factory(layout, Roo);
37067 config.el = config.layout.getEl();
37069 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37071 config.layout.monitorWindowResize = false; // turn off autosizing
37072 this.layout = config.layout;
37073 this.layout.getEl().addClass("roo-layout-nested-layout");
37080 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37082 setSize : function(width, height){
37083 if(!this.ignoreResize(width, height)){
37084 var size = this.adjustForComponents(width, height);
37085 var el = this.layout.getEl();
37086 if (size.height < 1) {
37087 el.setWidth(size.width);
37089 el.setSize(size.width, size.height);
37091 var touch = el.dom.offsetWidth;
37092 this.layout.layout();
37093 // ie requires a double layout on the first pass
37094 if(Roo.isIE && !this.initialized){
37095 this.initialized = true;
37096 this.layout.layout();
37101 // activate all subpanels if not currently active..
37103 setActiveState : function(active){
37104 this.active = active;
37105 this.setActiveClass(active);
37108 this.fireEvent("deactivate", this);
37112 this.fireEvent("activate", this);
37113 // not sure if this should happen before or after..
37114 if (!this.layout) {
37115 return; // should not happen..
37118 for (var r in this.layout.regions) {
37119 reg = this.layout.getRegion(r);
37120 if (reg.getActivePanel()) {
37121 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37122 reg.setActivePanel(reg.getActivePanel());
37125 if (!reg.panels.length) {
37128 reg.showPanel(reg.getPanel(0));
37137 * Returns the nested BorderLayout for this panel
37138 * @return {Roo.BorderLayout}
37140 getLayout : function(){
37141 return this.layout;
37145 * Adds a xtype elements to the layout of the nested panel
37149 xtype : 'ContentPanel',
37156 xtype : 'NestedLayoutPanel',
37162 items : [ ... list of content panels or nested layout panels.. ]
37166 * @param {Object} cfg Xtype definition of item to add.
37168 addxtype : function(cfg) {
37169 return this.layout.addxtype(cfg);
37174 * Ext JS Library 1.1.1
37175 * Copyright(c) 2006-2007, Ext JS, LLC.
37177 * Originally Released Under LGPL - original licence link has changed is not relivant.
37180 * <script type="text/javascript">
37183 * @class Roo.TabPanel
37184 * @extends Roo.util.Observable
37185 * A lightweight tab container.
37189 // basic tabs 1, built from existing content
37190 var tabs = new Roo.TabPanel("tabs1");
37191 tabs.addTab("script", "View Script");
37192 tabs.addTab("markup", "View Markup");
37193 tabs.activate("script");
37195 // more advanced tabs, built from javascript
37196 var jtabs = new Roo.TabPanel("jtabs");
37197 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37199 // set up the UpdateManager
37200 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37201 var updater = tab2.getUpdateManager();
37202 updater.setDefaultUrl("ajax1.htm");
37203 tab2.on('activate', updater.refresh, updater, true);
37205 // Use setUrl for Ajax loading
37206 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37207 tab3.setUrl("ajax2.htm", null, true);
37210 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37213 jtabs.activate("jtabs-1");
37216 * Create a new TabPanel.
37217 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37218 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37220 Roo.bootstrap.panel.Tabs = function(config){
37222 * The container element for this TabPanel.
37223 * @type Roo.Element
37225 this.el = Roo.get(config.el);
37228 if(typeof config == "boolean"){
37229 this.tabPosition = config ? "bottom" : "top";
37231 Roo.apply(this, config);
37235 if(this.tabPosition == "bottom"){
37236 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37237 this.el.addClass("roo-tabs-bottom");
37239 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37240 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37241 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37243 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37245 if(this.tabPosition != "bottom"){
37246 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37247 * @type Roo.Element
37249 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37250 this.el.addClass("roo-tabs-top");
37254 this.bodyEl.setStyle("position", "relative");
37256 this.active = null;
37257 this.activateDelegate = this.activate.createDelegate(this);
37262 * Fires when the active tab changes
37263 * @param {Roo.TabPanel} this
37264 * @param {Roo.TabPanelItem} activePanel The new active tab
37268 * @event beforetabchange
37269 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37270 * @param {Roo.TabPanel} this
37271 * @param {Object} e Set cancel to true on this object to cancel the tab change
37272 * @param {Roo.TabPanelItem} tab The tab being changed to
37274 "beforetabchange" : true
37277 Roo.EventManager.onWindowResize(this.onResize, this);
37278 this.cpad = this.el.getPadding("lr");
37279 this.hiddenCount = 0;
37282 // toolbar on the tabbar support...
37283 if (this.toolbar) {
37284 alert("no toolbar support yet");
37285 this.toolbar = false;
37287 var tcfg = this.toolbar;
37288 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37289 this.toolbar = new Roo.Toolbar(tcfg);
37290 if (Roo.isSafari) {
37291 var tbl = tcfg.container.child('table', true);
37292 tbl.setAttribute('width', '100%');
37300 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37303 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37305 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37307 tabPosition : "top",
37309 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37311 currentTabWidth : 0,
37313 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37317 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37321 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37323 preferredTabWidth : 175,
37325 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37327 resizeTabs : false,
37329 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37331 monitorResize : true,
37333 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37338 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37339 * @param {String} id The id of the div to use <b>or create</b>
37340 * @param {String} text The text for the tab
37341 * @param {String} content (optional) Content to put in the TabPanelItem body
37342 * @param {Boolean} closable (optional) True to create a close icon on the tab
37343 * @return {Roo.TabPanelItem} The created TabPanelItem
37345 addTab : function(id, text, content, closable, tpl)
37347 var item = new Roo.bootstrap.panel.TabItem({
37351 closable : closable,
37354 this.addTabItem(item);
37356 item.setContent(content);
37362 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37363 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37364 * @return {Roo.TabPanelItem}
37366 getTab : function(id){
37367 return this.items[id];
37371 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37372 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37374 hideTab : function(id){
37375 var t = this.items[id];
37378 this.hiddenCount++;
37379 this.autoSizeTabs();
37384 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37385 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37387 unhideTab : function(id){
37388 var t = this.items[id];
37390 t.setHidden(false);
37391 this.hiddenCount--;
37392 this.autoSizeTabs();
37397 * Adds an existing {@link Roo.TabPanelItem}.
37398 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37400 addTabItem : function(item){
37401 this.items[item.id] = item;
37402 this.items.push(item);
37403 // if(this.resizeTabs){
37404 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37405 // this.autoSizeTabs();
37407 // item.autoSize();
37412 * Removes a {@link Roo.TabPanelItem}.
37413 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37415 removeTab : function(id){
37416 var items = this.items;
37417 var tab = items[id];
37418 if(!tab) { return; }
37419 var index = items.indexOf(tab);
37420 if(this.active == tab && items.length > 1){
37421 var newTab = this.getNextAvailable(index);
37426 this.stripEl.dom.removeChild(tab.pnode.dom);
37427 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37428 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37430 items.splice(index, 1);
37431 delete this.items[tab.id];
37432 tab.fireEvent("close", tab);
37433 tab.purgeListeners();
37434 this.autoSizeTabs();
37437 getNextAvailable : function(start){
37438 var items = this.items;
37440 // look for a next tab that will slide over to
37441 // replace the one being removed
37442 while(index < items.length){
37443 var item = items[++index];
37444 if(item && !item.isHidden()){
37448 // if one isn't found select the previous tab (on the left)
37451 var item = items[--index];
37452 if(item && !item.isHidden()){
37460 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37461 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37463 disableTab : function(id){
37464 var tab = this.items[id];
37465 if(tab && this.active != tab){
37471 * Enables a {@link Roo.TabPanelItem} that is disabled.
37472 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37474 enableTab : function(id){
37475 var tab = this.items[id];
37480 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37481 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37482 * @return {Roo.TabPanelItem} The TabPanelItem.
37484 activate : function(id){
37485 var tab = this.items[id];
37489 if(tab == this.active || tab.disabled){
37493 this.fireEvent("beforetabchange", this, e, tab);
37494 if(e.cancel !== true && !tab.disabled){
37496 this.active.hide();
37498 this.active = this.items[id];
37499 this.active.show();
37500 this.fireEvent("tabchange", this, this.active);
37506 * Gets the active {@link Roo.TabPanelItem}.
37507 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37509 getActiveTab : function(){
37510 return this.active;
37514 * Updates the tab body element to fit the height of the container element
37515 * for overflow scrolling
37516 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37518 syncHeight : function(targetHeight){
37519 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37520 var bm = this.bodyEl.getMargins();
37521 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37522 this.bodyEl.setHeight(newHeight);
37526 onResize : function(){
37527 if(this.monitorResize){
37528 this.autoSizeTabs();
37533 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37535 beginUpdate : function(){
37536 this.updating = true;
37540 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37542 endUpdate : function(){
37543 this.updating = false;
37544 this.autoSizeTabs();
37548 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37550 autoSizeTabs : function(){
37551 var count = this.items.length;
37552 var vcount = count - this.hiddenCount;
37553 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37556 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37557 var availWidth = Math.floor(w / vcount);
37558 var b = this.stripBody;
37559 if(b.getWidth() > w){
37560 var tabs = this.items;
37561 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37562 if(availWidth < this.minTabWidth){
37563 /*if(!this.sleft){ // incomplete scrolling code
37564 this.createScrollButtons();
37567 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37570 if(this.currentTabWidth < this.preferredTabWidth){
37571 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37577 * Returns the number of tabs in this TabPanel.
37580 getCount : function(){
37581 return this.items.length;
37585 * Resizes all the tabs to the passed width
37586 * @param {Number} The new width
37588 setTabWidth : function(width){
37589 this.currentTabWidth = width;
37590 for(var i = 0, len = this.items.length; i < len; i++) {
37591 if(!this.items[i].isHidden()) {
37592 this.items[i].setWidth(width);
37598 * Destroys this TabPanel
37599 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37601 destroy : function(removeEl){
37602 Roo.EventManager.removeResizeListener(this.onResize, this);
37603 for(var i = 0, len = this.items.length; i < len; i++){
37604 this.items[i].purgeListeners();
37606 if(removeEl === true){
37607 this.el.update("");
37612 createStrip : function(container)
37614 var strip = document.createElement("nav");
37615 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37616 container.appendChild(strip);
37620 createStripList : function(strip)
37622 // div wrapper for retard IE
37623 // returns the "tr" element.
37624 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37625 //'<div class="x-tabs-strip-wrap">'+
37626 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37627 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37628 return strip.firstChild; //.firstChild.firstChild.firstChild;
37630 createBody : function(container)
37632 var body = document.createElement("div");
37633 Roo.id(body, "tab-body");
37634 //Roo.fly(body).addClass("x-tabs-body");
37635 Roo.fly(body).addClass("tab-content");
37636 container.appendChild(body);
37639 createItemBody :function(bodyEl, id){
37640 var body = Roo.getDom(id);
37642 body = document.createElement("div");
37645 //Roo.fly(body).addClass("x-tabs-item-body");
37646 Roo.fly(body).addClass("tab-pane");
37647 bodyEl.insertBefore(body, bodyEl.firstChild);
37651 createStripElements : function(stripEl, text, closable, tpl)
37653 var td = document.createElement("li"); // was td..
37656 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37659 stripEl.appendChild(td);
37661 td.className = "x-tabs-closable";
37662 if(!this.closeTpl){
37663 this.closeTpl = new Roo.Template(
37664 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37665 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37666 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37669 var el = this.closeTpl.overwrite(td, {"text": text});
37670 var close = el.getElementsByTagName("div")[0];
37671 var inner = el.getElementsByTagName("em")[0];
37672 return {"el": el, "close": close, "inner": inner};
37675 // not sure what this is..
37676 // if(!this.tabTpl){
37677 //this.tabTpl = new Roo.Template(
37678 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37679 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37681 // this.tabTpl = new Roo.Template(
37682 // '<a href="#">' +
37683 // '<span unselectable="on"' +
37684 // (this.disableTooltips ? '' : ' title="{text}"') +
37685 // ' >{text}</span></a>'
37691 var template = tpl || this.tabTpl || false;
37695 template = new Roo.Template(
37697 '<span unselectable="on"' +
37698 (this.disableTooltips ? '' : ' title="{text}"') +
37699 ' >{text}</span></a>'
37703 switch (typeof(template)) {
37707 template = new Roo.Template(template);
37713 var el = template.overwrite(td, {"text": text});
37715 var inner = el.getElementsByTagName("span")[0];
37717 return {"el": el, "inner": inner};
37725 * @class Roo.TabPanelItem
37726 * @extends Roo.util.Observable
37727 * Represents an individual item (tab plus body) in a TabPanel.
37728 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37729 * @param {String} id The id of this TabPanelItem
37730 * @param {String} text The text for the tab of this TabPanelItem
37731 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37733 Roo.bootstrap.panel.TabItem = function(config){
37735 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37736 * @type Roo.TabPanel
37738 this.tabPanel = config.panel;
37740 * The id for this TabPanelItem
37743 this.id = config.id;
37745 this.disabled = false;
37747 this.text = config.text;
37749 this.loaded = false;
37750 this.closable = config.closable;
37753 * The body element for this TabPanelItem.
37754 * @type Roo.Element
37756 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37757 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37758 this.bodyEl.setStyle("display", "block");
37759 this.bodyEl.setStyle("zoom", "1");
37760 //this.hideAction();
37762 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37764 this.el = Roo.get(els.el);
37765 this.inner = Roo.get(els.inner, true);
37766 this.textEl = Roo.get(this.el.dom.firstChild, true);
37767 this.pnode = Roo.get(els.el.parentNode, true);
37768 // this.el.on("mousedown", this.onTabMouseDown, this);
37769 this.el.on("click", this.onTabClick, this);
37771 if(config.closable){
37772 var c = Roo.get(els.close, true);
37773 c.dom.title = this.closeText;
37774 c.addClassOnOver("close-over");
37775 c.on("click", this.closeClick, this);
37781 * Fires when this tab becomes the active tab.
37782 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37783 * @param {Roo.TabPanelItem} this
37787 * @event beforeclose
37788 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37789 * @param {Roo.TabPanelItem} this
37790 * @param {Object} e Set cancel to true on this object to cancel the close.
37792 "beforeclose": true,
37795 * Fires when this tab is closed.
37796 * @param {Roo.TabPanelItem} this
37800 * @event deactivate
37801 * Fires when this tab is no longer the active tab.
37802 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37803 * @param {Roo.TabPanelItem} this
37805 "deactivate" : true
37807 this.hidden = false;
37809 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37812 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37814 purgeListeners : function(){
37815 Roo.util.Observable.prototype.purgeListeners.call(this);
37816 this.el.removeAllListeners();
37819 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37822 this.pnode.addClass("active");
37825 this.tabPanel.stripWrap.repaint();
37827 this.fireEvent("activate", this.tabPanel, this);
37831 * Returns true if this tab is the active tab.
37832 * @return {Boolean}
37834 isActive : function(){
37835 return this.tabPanel.getActiveTab() == this;
37839 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37842 this.pnode.removeClass("active");
37844 this.fireEvent("deactivate", this.tabPanel, this);
37847 hideAction : function(){
37848 this.bodyEl.hide();
37849 this.bodyEl.setStyle("position", "absolute");
37850 this.bodyEl.setLeft("-20000px");
37851 this.bodyEl.setTop("-20000px");
37854 showAction : function(){
37855 this.bodyEl.setStyle("position", "relative");
37856 this.bodyEl.setTop("");
37857 this.bodyEl.setLeft("");
37858 this.bodyEl.show();
37862 * Set the tooltip for the tab.
37863 * @param {String} tooltip The tab's tooltip
37865 setTooltip : function(text){
37866 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37867 this.textEl.dom.qtip = text;
37868 this.textEl.dom.removeAttribute('title');
37870 this.textEl.dom.title = text;
37874 onTabClick : function(e){
37875 e.preventDefault();
37876 this.tabPanel.activate(this.id);
37879 onTabMouseDown : function(e){
37880 e.preventDefault();
37881 this.tabPanel.activate(this.id);
37884 getWidth : function(){
37885 return this.inner.getWidth();
37888 setWidth : function(width){
37889 var iwidth = width - this.pnode.getPadding("lr");
37890 this.inner.setWidth(iwidth);
37891 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
37892 this.pnode.setWidth(width);
37896 * Show or hide the tab
37897 * @param {Boolean} hidden True to hide or false to show.
37899 setHidden : function(hidden){
37900 this.hidden = hidden;
37901 this.pnode.setStyle("display", hidden ? "none" : "");
37905 * Returns true if this tab is "hidden"
37906 * @return {Boolean}
37908 isHidden : function(){
37909 return this.hidden;
37913 * Returns the text for this tab
37916 getText : function(){
37920 autoSize : function(){
37921 //this.el.beginMeasure();
37922 this.textEl.setWidth(1);
37924 * #2804 [new] Tabs in Roojs
37925 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
37927 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
37928 //this.el.endMeasure();
37932 * Sets the text for the tab (Note: this also sets the tooltip text)
37933 * @param {String} text The tab's text and tooltip
37935 setText : function(text){
37937 this.textEl.update(text);
37938 this.setTooltip(text);
37939 //if(!this.tabPanel.resizeTabs){
37940 // this.autoSize();
37944 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
37946 activate : function(){
37947 this.tabPanel.activate(this.id);
37951 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
37953 disable : function(){
37954 if(this.tabPanel.active != this){
37955 this.disabled = true;
37956 this.pnode.addClass("disabled");
37961 * Enables this TabPanelItem if it was previously disabled.
37963 enable : function(){
37964 this.disabled = false;
37965 this.pnode.removeClass("disabled");
37969 * Sets the content for this TabPanelItem.
37970 * @param {String} content The content
37971 * @param {Boolean} loadScripts true to look for and load scripts
37973 setContent : function(content, loadScripts){
37974 this.bodyEl.update(content, loadScripts);
37978 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
37979 * @return {Roo.UpdateManager} The UpdateManager
37981 getUpdateManager : function(){
37982 return this.bodyEl.getUpdateManager();
37986 * Set a URL to be used to load the content for this TabPanelItem.
37987 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
37988 * @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)
37989 * @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)
37990 * @return {Roo.UpdateManager} The UpdateManager
37992 setUrl : function(url, params, loadOnce){
37993 if(this.refreshDelegate){
37994 this.un('activate', this.refreshDelegate);
37996 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37997 this.on("activate", this.refreshDelegate);
37998 return this.bodyEl.getUpdateManager();
38002 _handleRefresh : function(url, params, loadOnce){
38003 if(!loadOnce || !this.loaded){
38004 var updater = this.bodyEl.getUpdateManager();
38005 updater.update(url, params, this._setLoaded.createDelegate(this));
38010 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38011 * Will fail silently if the setUrl method has not been called.
38012 * This does not activate the panel, just updates its content.
38014 refresh : function(){
38015 if(this.refreshDelegate){
38016 this.loaded = false;
38017 this.refreshDelegate();
38022 _setLoaded : function(){
38023 this.loaded = true;
38027 closeClick : function(e){
38030 this.fireEvent("beforeclose", this, o);
38031 if(o.cancel !== true){
38032 this.tabPanel.removeTab(this.id);
38036 * The text displayed in the tooltip for the close icon.
38039 closeText : "Close this tab"
38042 * This script refer to:
38043 * Title: International Telephone Input
38044 * Author: Jack O'Connor
38045 * Code version: v12.1.12
38046 * Availability: https://github.com/jackocnr/intl-tel-input.git
38049 Roo.bootstrap.PhoneInputData = function() {
38052 "Afghanistan (افغانستان)",
38057 "Albania (Shqipëri)",
38062 "Algeria (الجزائر)",
38087 "Antigua and Barbuda",
38097 "Armenia (Հայաստան)",
38113 "Austria (Österreich)",
38118 "Azerbaijan (Azərbaycan)",
38128 "Bahrain (البحرين)",
38133 "Bangladesh (বাংলাদেশ)",
38143 "Belarus (Беларусь)",
38148 "Belgium (België)",
38178 "Bosnia and Herzegovina (Босна и Херцеговина)",
38193 "British Indian Ocean Territory",
38198 "British Virgin Islands",
38208 "Bulgaria (България)",
38218 "Burundi (Uburundi)",
38223 "Cambodia (កម្ពុជា)",
38228 "Cameroon (Cameroun)",
38237 ["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"]
38240 "Cape Verde (Kabu Verdi)",
38245 "Caribbean Netherlands",
38256 "Central African Republic (République centrafricaine)",
38276 "Christmas Island",
38282 "Cocos (Keeling) Islands",
38293 "Comoros (جزر القمر)",
38298 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38303 "Congo (Republic) (Congo-Brazzaville)",
38323 "Croatia (Hrvatska)",
38344 "Czech Republic (Česká republika)",
38349 "Denmark (Danmark)",
38364 "Dominican Republic (República Dominicana)",
38368 ["809", "829", "849"]
38386 "Equatorial Guinea (Guinea Ecuatorial)",
38406 "Falkland Islands (Islas Malvinas)",
38411 "Faroe Islands (Føroyar)",
38432 "French Guiana (Guyane française)",
38437 "French Polynesia (Polynésie française)",
38452 "Georgia (საქართველო)",
38457 "Germany (Deutschland)",
38477 "Greenland (Kalaallit Nunaat)",
38514 "Guinea-Bissau (Guiné Bissau)",
38539 "Hungary (Magyarország)",
38544 "Iceland (Ísland)",
38564 "Iraq (العراق)",
38580 "Israel (ישראל)",
38607 "Jordan (الأردن)",
38612 "Kazakhstan (Казахстан)",
38633 "Kuwait (الكويت)",
38638 "Kyrgyzstan (Кыргызстан)",
38648 "Latvia (Latvija)",
38653 "Lebanon (لبنان)",
38668 "Libya (ليبيا)",
38678 "Lithuania (Lietuva)",
38693 "Macedonia (FYROM) (Македонија)",
38698 "Madagascar (Madagasikara)",
38728 "Marshall Islands",
38738 "Mauritania (موريتانيا)",
38743 "Mauritius (Moris)",
38764 "Moldova (Republica Moldova)",
38774 "Mongolia (Монгол)",
38779 "Montenegro (Crna Gora)",
38789 "Morocco (المغرب)",
38795 "Mozambique (Moçambique)",
38800 "Myanmar (Burma) (မြန်မာ)",
38805 "Namibia (Namibië)",
38820 "Netherlands (Nederland)",
38825 "New Caledonia (Nouvelle-Calédonie)",
38860 "North Korea (조선 민주주의 인민 공화국)",
38865 "Northern Mariana Islands",
38881 "Pakistan (پاکستان)",
38891 "Palestine (فلسطين)",
38901 "Papua New Guinea",
38943 "Réunion (La Réunion)",
38949 "Romania (România)",
38965 "Saint Barthélemy",
38976 "Saint Kitts and Nevis",
38986 "Saint Martin (Saint-Martin (partie française))",
38992 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
38997 "Saint Vincent and the Grenadines",
39012 "São Tomé and Príncipe (São Tomé e Príncipe)",
39017 "Saudi Arabia (المملكة العربية السعودية)",
39022 "Senegal (Sénégal)",
39052 "Slovakia (Slovensko)",
39057 "Slovenia (Slovenija)",
39067 "Somalia (Soomaaliya)",
39077 "South Korea (대한민국)",
39082 "South Sudan (جنوب السودان)",
39092 "Sri Lanka (ශ්රී ලංකාව)",
39097 "Sudan (السودان)",
39107 "Svalbard and Jan Mayen",
39118 "Sweden (Sverige)",
39123 "Switzerland (Schweiz)",
39128 "Syria (سوريا)",
39173 "Trinidad and Tobago",
39178 "Tunisia (تونس)",
39183 "Turkey (Türkiye)",
39193 "Turks and Caicos Islands",
39203 "U.S. Virgin Islands",
39213 "Ukraine (Україна)",
39218 "United Arab Emirates (الإمارات العربية المتحدة)",
39240 "Uzbekistan (Oʻzbekiston)",
39250 "Vatican City (Città del Vaticano)",
39261 "Vietnam (Việt Nam)",
39266 "Wallis and Futuna (Wallis-et-Futuna)",
39271 "Western Sahara (الصحراء الغربية)",
39277 "Yemen (اليمن)",
39301 * This script refer to:
39302 * Title: International Telephone Input
39303 * Author: Jack O'Connor
39304 * Code version: v12.1.12
39305 * Availability: https://github.com/jackocnr/intl-tel-input.git
39309 * @class Roo.bootstrap.PhoneInput
39310 * @extends Roo.bootstrap.TriggerField
39311 * An input with International dial-code selection
39313 * @cfg {String} defaultDialCode default '+852'
39314 * @cfg {Array} preferedCountries default []
39317 * Create a new PhoneInput.
39318 * @param {Object} config Configuration options
39321 Roo.bootstrap.PhoneInput = function(config) {
39322 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39325 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39327 listWidth: undefined,
39329 selectedClass: 'active',
39331 invalidClass : "has-warning",
39333 validClass: 'has-success',
39335 allowed: '0123456789',
39338 * @cfg {String} defaultDialCode The default dial code when initializing the input
39340 defaultDialCode: '+852',
39343 * @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
39345 preferedCountries: false,
39347 getAutoCreate : function()
39349 var data = Roo.bootstrap.PhoneInputData();
39350 var align = this.labelAlign || this.parentLabelAlign();
39353 this.allCountries = [];
39354 this.dialCodeMapping = [];
39356 for (var i = 0; i < data.length; i++) {
39358 this.allCountries[i] = {
39362 priority: c[3] || 0,
39363 areaCodes: c[4] || null
39365 this.dialCodeMapping[c[2]] = {
39368 priority: c[3] || 0,
39369 areaCodes: c[4] || null
39381 cls : 'form-control tel-input',
39382 autocomplete: 'new-password'
39385 var hiddenInput = {
39388 cls: 'hidden-tel-input'
39392 hiddenInput.name = this.name;
39395 if (this.disabled) {
39396 input.disabled = true;
39399 var flag_container = {
39416 cls: this.hasFeedback ? 'has-feedback' : '',
39422 cls: 'dial-code-holder',
39429 cls: 'roo-select2-container input-group',
39436 if (this.fieldLabel.length) {
39439 tooltip: 'This field is required'
39445 cls: 'control-label',
39451 html: this.fieldLabel
39454 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39460 if(this.indicatorpos == 'right') {
39461 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39468 if(align == 'left') {
39476 if(this.labelWidth > 12){
39477 label.style = "width: " + this.labelWidth + 'px';
39479 if(this.labelWidth < 13 && this.labelmd == 0){
39480 this.labelmd = this.labelWidth;
39482 if(this.labellg > 0){
39483 label.cls += ' col-lg-' + this.labellg;
39484 input.cls += ' col-lg-' + (12 - this.labellg);
39486 if(this.labelmd > 0){
39487 label.cls += ' col-md-' + this.labelmd;
39488 container.cls += ' col-md-' + (12 - this.labelmd);
39490 if(this.labelsm > 0){
39491 label.cls += ' col-sm-' + this.labelsm;
39492 container.cls += ' col-sm-' + (12 - this.labelsm);
39494 if(this.labelxs > 0){
39495 label.cls += ' col-xs-' + this.labelxs;
39496 container.cls += ' col-xs-' + (12 - this.labelxs);
39506 var settings = this;
39508 ['xs','sm','md','lg'].map(function(size){
39509 if (settings[size]) {
39510 cfg.cls += ' col-' + size + '-' + settings[size];
39514 this.store = new Roo.data.Store({
39515 proxy : new Roo.data.MemoryProxy({}),
39516 reader : new Roo.data.JsonReader({
39527 'name' : 'dialCode',
39531 'name' : 'priority',
39535 'name' : 'areaCodes',
39542 if(!this.preferedCountries) {
39543 this.preferedCountries = [
39550 var p = this.preferedCountries.reverse();
39553 for (var i = 0; i < p.length; i++) {
39554 for (var j = 0; j < this.allCountries.length; j++) {
39555 if(this.allCountries[j].iso2 == p[i]) {
39556 var t = this.allCountries[j];
39557 this.allCountries.splice(j,1);
39558 this.allCountries.unshift(t);
39564 this.store.proxy.data = {
39566 data: this.allCountries
39572 initEvents : function()
39575 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39577 this.indicator = this.indicatorEl();
39578 this.flag = this.flagEl();
39579 this.dialCodeHolder = this.dialCodeHolderEl();
39581 this.trigger = this.el.select('div.flag-box',true).first();
39582 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39587 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39588 _this.list.setWidth(lw);
39591 this.list.on('mouseover', this.onViewOver, this);
39592 this.list.on('mousemove', this.onViewMove, this);
39593 this.inputEl().on("keyup", this.onKeyUp, this);
39595 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39597 this.view = new Roo.View(this.list, this.tpl, {
39598 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39601 this.view.on('click', this.onViewClick, this);
39602 this.setValue(this.defaultDialCode);
39605 onTriggerClick : function(e)
39607 Roo.log('trigger click');
39612 if(this.isExpanded()){
39614 this.hasFocus = false;
39616 this.store.load({});
39617 this.hasFocus = true;
39622 isExpanded : function()
39624 return this.list.isVisible();
39627 collapse : function()
39629 if(!this.isExpanded()){
39633 Roo.get(document).un('mousedown', this.collapseIf, this);
39634 Roo.get(document).un('mousewheel', this.collapseIf, this);
39635 this.fireEvent('collapse', this);
39639 expand : function()
39643 if(this.isExpanded() || !this.hasFocus){
39647 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39648 this.list.setWidth(lw);
39651 this.restrictHeight();
39653 Roo.get(document).on('mousedown', this.collapseIf, this);
39654 Roo.get(document).on('mousewheel', this.collapseIf, this);
39656 this.fireEvent('expand', this);
39659 restrictHeight : function()
39661 this.list.alignTo(this.inputEl(), this.listAlign);
39662 this.list.alignTo(this.inputEl(), this.listAlign);
39665 onViewOver : function(e, t)
39667 if(this.inKeyMode){
39670 var item = this.view.findItemFromChild(t);
39673 var index = this.view.indexOf(item);
39674 this.select(index, false);
39679 onViewClick : function(view, doFocus, el, e)
39681 var index = this.view.getSelectedIndexes()[0];
39683 var r = this.store.getAt(index);
39686 this.onSelect(r, index);
39688 if(doFocus !== false && !this.blockFocus){
39689 this.inputEl().focus();
39693 onViewMove : function(e, t)
39695 this.inKeyMode = false;
39698 select : function(index, scrollIntoView)
39700 this.selectedIndex = index;
39701 this.view.select(index);
39702 if(scrollIntoView !== false){
39703 var el = this.view.getNode(index);
39705 this.list.scrollChildIntoView(el, false);
39710 createList : function()
39712 this.list = Roo.get(document.body).createChild({
39714 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39715 style: 'display:none'
39717 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39720 collapseIf : function(e)
39722 var in_combo = e.within(this.el);
39723 var in_list = e.within(this.list);
39724 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39726 if (in_combo || in_list || is_list) {
39732 onSelect : function(record, index)
39734 if(this.fireEvent('beforeselect', this, record, index) !== false){
39736 this.setFlagClass(record.data.iso2);
39737 this.setDialCode(record.data.dialCode);
39738 this.hasFocus = false;
39740 this.fireEvent('select', this, record, index);
39744 flagEl : function()
39746 var flag = this.el.select('div.flag',true).first();
39753 dialCodeHolderEl : function()
39755 var d = this.el.select('input.dial-code-holder',true).first();
39762 setDialCode : function(v)
39764 this.dialCodeHolder.dom.value = '+'+v;
39767 setFlagClass : function(n)
39769 this.flag.dom.className = 'flag '+n;
39772 getValue : function()
39774 var v = this.inputEl().getValue();
39775 if(this.dialCodeHolder) {
39776 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
39781 setValue : function(v)
39783 var d = this.getDialCode(v);
39785 //invalid dial code
39786 if(v.length == 0 || !d || d.length == 0) {
39788 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
39789 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39795 this.setFlagClass(this.dialCodeMapping[d].iso2);
39796 this.setDialCode(d);
39797 this.inputEl().dom.value = v.replace('+'+d,'');
39798 this.hiddenEl().dom.value = this.getValue();
39803 getDialCode : function(v = '')
39805 if (v.length == 0) {
39806 return this.dialCodeHolder.dom.value;
39810 if (v.charAt(0) != "+") {
39813 var numericChars = "";
39814 for (var i = 1; i < v.length; i++) {
39815 var c = v.charAt(i);
39818 if (this.dialCodeMapping[numericChars]) {
39819 dialCode = v.substr(1, i);
39821 if (numericChars.length == 4) {
39831 this.setValue(this.defaultDialCode);
39835 hiddenEl : function()
39837 return this.el.select('input.hidden-tel-input',true).first();
39840 onKeyUp : function(e){
39842 var k = e.getKey();
39843 var c = e.getCharCode();
39846 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39847 this.allowed.indexOf(String.fromCharCode(c)) === -1
39852 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39855 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
39859 this.setValue(this.getValue());
39864 * @class Roo.bootstrap.MoneyField
39865 * @extends Roo.bootstrap.ComboBox
39866 * Bootstrap MoneyField class
39869 * Create a new MoneyField.
39870 * @param {Object} config Configuration options
39873 Roo.bootstrap.MoneyField = function(config) {
39875 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
39879 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
39882 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
39884 allowDecimals : true,
39886 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
39888 decimalSeparator : ".",
39890 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
39892 decimalPrecision : 2,
39894 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
39896 allowNegative : true,
39898 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
39900 minValue : Number.NEGATIVE_INFINITY,
39902 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
39904 maxValue : Number.MAX_VALUE,
39906 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
39908 minText : "The minimum value for this field is {0}",
39910 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
39912 maxText : "The maximum value for this field is {0}",
39914 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
39915 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
39917 nanText : "{0} is not a valid number",
39919 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
39930 getAutoCreate : function()
39932 var align = this.labelAlign || this.parentLabelAlign();
39944 cls : 'form-control roo-money-amount-input',
39945 autocomplete: 'new-password'
39949 input.name = this.name;
39952 if (this.disabled) {
39953 input.disabled = true;
39956 var clg = 12 - this.inputlg;
39957 var cmd = 12 - this.inputmd;
39958 var csm = 12 - this.inputsm;
39959 var cxs = 12 - this.inputxs;
39963 cls : 'row roo-money-field',
39967 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
39971 cls: 'roo-select2-container input-group',
39975 cls : 'form-control roo-money-currency-input',
39976 autocomplete: 'new-password',
39978 name : this.currencyName
39982 cls : 'input-group-addon',
39996 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40000 cls: this.hasFeedback ? 'has-feedback' : '',
40011 if (this.fieldLabel.length) {
40014 tooltip: 'This field is required'
40020 cls: 'control-label',
40026 html: this.fieldLabel
40029 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40035 if(this.indicatorpos == 'right') {
40036 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40043 if(align == 'left') {
40051 if(this.labelWidth > 12){
40052 label.style = "width: " + this.labelWidth + 'px';
40054 if(this.labelWidth < 13 && this.labelmd == 0){
40055 this.labelmd = this.labelWidth;
40057 if(this.labellg > 0){
40058 label.cls += ' col-lg-' + this.labellg;
40059 input.cls += ' col-lg-' + (12 - this.labellg);
40061 if(this.labelmd > 0){
40062 label.cls += ' col-md-' + this.labelmd;
40063 container.cls += ' col-md-' + (12 - this.labelmd);
40065 if(this.labelsm > 0){
40066 label.cls += ' col-sm-' + this.labelsm;
40067 container.cls += ' col-sm-' + (12 - this.labelsm);
40069 if(this.labelxs > 0){
40070 label.cls += ' col-xs-' + this.labelxs;
40071 container.cls += ' col-xs-' + (12 - this.labelxs);
40081 var settings = this;
40083 ['xs','sm','md','lg'].map(function(size){
40084 if (settings[size]) {
40085 cfg.cls += ' col-' + size + '-' + settings[size];
40093 initEvents : function()
40095 this.indicator = this.indicatorEl();
40097 this.initCurrencyEvent();
40099 this.initNumberEvent();
40103 initCurrencyEvent : function()
40106 throw "can not find store for combo";
40109 this.store = Roo.factory(this.store, Roo.data);
40110 this.store.parent = this;
40114 this.triggerEl = this.el.select('.input-group-addon', true).first();
40116 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40121 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40122 _this.list.setWidth(lw);
40125 this.list.on('mouseover', this.onViewOver, this);
40126 this.list.on('mousemove', this.onViewMove, this);
40127 this.list.on('scroll', this.onViewScroll, this);
40130 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40133 this.view = new Roo.View(this.list, this.tpl, {
40134 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40137 this.view.on('click', this.onViewClick, this);
40139 this.store.on('beforeload', this.onBeforeLoad, this);
40140 this.store.on('load', this.onLoad, this);
40141 this.store.on('loadexception', this.onLoadException, this);
40143 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40144 "up" : function(e){
40145 this.inKeyMode = true;
40149 "down" : function(e){
40150 if(!this.isExpanded()){
40151 this.onTriggerClick();
40153 this.inKeyMode = true;
40158 "enter" : function(e){
40161 if(this.fireEvent("specialkey", this, e)){
40162 this.onViewClick(false);
40168 "esc" : function(e){
40172 "tab" : function(e){
40175 if(this.fireEvent("specialkey", this, e)){
40176 this.onViewClick(false);
40184 doRelay : function(foo, bar, hname){
40185 if(hname == 'down' || this.scope.isExpanded()){
40186 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40194 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40198 initNumberEvent : function(e)
40200 this.inputEl().on("keydown" , this.fireKey, this);
40201 this.inputEl().on("focus", this.onFocus, this);
40202 this.inputEl().on("blur", this.onBlur, this);
40204 this.inputEl().relayEvent('keyup', this);
40206 if(this.indicator){
40207 this.indicator.addClass('invisible');
40210 this.originalValue = this.getValue();
40212 if(this.validationEvent == 'keyup'){
40213 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40214 this.inputEl().on('keyup', this.filterValidation, this);
40216 else if(this.validationEvent !== false){
40217 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40220 if(this.selectOnFocus){
40221 this.on("focus", this.preFocus, this);
40224 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40225 this.inputEl().on("keypress", this.filterKeys, this);
40227 this.inputEl().relayEvent('keypress', this);
40230 var allowed = "0123456789";
40232 if(this.allowDecimals){
40233 allowed += this.decimalSeparator;
40236 if(this.allowNegative){
40240 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40242 var keyPress = function(e){
40244 var k = e.getKey();
40246 var c = e.getCharCode();
40249 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40250 allowed.indexOf(String.fromCharCode(c)) === -1
40256 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40260 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40265 this.inputEl().on("keypress", keyPress, this);
40269 onTriggerClick : function(e)
40276 this.loadNext = false;
40278 if(this.isExpanded()){
40283 this.hasFocus = true;
40285 if(this.triggerAction == 'all') {
40286 this.doQuery(this.allQuery, true);
40290 this.doQuery(this.getRawValue());
40293 getCurrency : function()
40295 var v = this.currencyEl().getValue();
40300 restrictHeight : function()
40302 this.list.alignTo(this.currencyEl(), this.listAlign);
40303 this.list.alignTo(this.currencyEl(), this.listAlign);
40306 onViewClick : function(view, doFocus, el, e)
40308 var index = this.view.getSelectedIndexes()[0];
40310 var r = this.store.getAt(index);
40313 this.onSelect(r, index);
40317 onSelect : function(record, index){
40319 if(this.fireEvent('beforeselect', this, record, index) !== false){
40321 this.setFromCurrencyData(index > -1 ? record.data : false);
40325 this.fireEvent('select', this, record, index);
40329 setFromCurrencyData : function(o)
40333 this.lastCurrency = o;
40335 if (this.currencyField) {
40336 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40338 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40341 this.lastSelectionText = currency;
40343 this.setCurrency(currency);
40346 setFromData : function(o)
40350 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40352 this.setFromCurrencyData(c);
40357 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40359 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40362 this.setValue(value);
40366 setCurrency : function(v)
40368 this.currencyValue = v;
40371 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40376 setValue : function(v)
40378 v = this.fixPrecision(v);
40380 v = String(v).replace(".", this.decimalSeparator);
40385 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40390 getRawValue : function()
40392 var v = this.inputEl().getValue();
40397 getValue : function()
40399 return this.fixPrecision(this.parseValue(this.getRawValue()));
40402 parseValue : function(value)
40404 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40405 return isNaN(value) ? '' : value;
40408 fixPrecision : function(value)
40410 var nan = isNaN(value);
40412 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40413 return nan ? '' : value;
40416 return parseFloat(value).toFixed(this.decimalPrecision);
40419 decimalPrecisionFcn : function(v)
40421 return Math.floor(v);
40424 validateValue : function(value)
40426 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40430 var num = this.parseValue(value);
40433 this.markInvalid(String.format(this.nanText, value));
40437 if(num < this.minValue){
40438 this.markInvalid(String.format(this.minText, this.minValue));
40442 if(num > this.maxValue){
40443 this.markInvalid(String.format(this.maxText, this.maxValue));
40450 validate : function()
40452 if(this.disabled || this.allowBlank){
40457 var currency = this.getCurrency();
40459 if(this.validateValue(this.getRawValue()) && currency.length){
40464 this.markInvalid();
40468 getName: function()
40473 beforeBlur : function()
40479 var v = this.parseValue(this.getRawValue());
40486 onBlur : function()
40490 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40491 //this.el.removeClass(this.focusClass);
40494 this.hasFocus = false;
40496 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40500 var v = this.getValue();
40502 if(String(v) !== String(this.startValue)){
40503 this.fireEvent('change', this, v, this.startValue);
40506 this.fireEvent("blur", this);
40509 inputEl : function()
40511 return this.el.select('.roo-money-amount-input', true).first();
40514 currencyEl : function()
40516 return this.el.select('.roo-money-currency-input', true).first();