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 (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.getHeight() + (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) {
8041 getItems : function()
8043 var r=new Roo.util.MixedCollection(false, function(o){
8044 return o.id || (o.id = Roo.id());
8046 var iter = function(el) {
8053 Roo.each(el.items,function(e) {
8070 Roo.apply(Roo.bootstrap.Form, {
8097 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8098 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8099 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8100 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8103 this.maskEl.top.enableDisplayMode("block");
8104 this.maskEl.left.enableDisplayMode("block");
8105 this.maskEl.bottom.enableDisplayMode("block");
8106 this.maskEl.right.enableDisplayMode("block");
8108 this.toolTip = new Roo.bootstrap.Tooltip({
8109 cls : 'roo-form-error-popover',
8111 'left' : ['r-l', [-2,0], 'right'],
8112 'right' : ['l-r', [2,0], 'left'],
8113 'bottom' : ['tl-bl', [0,2], 'top'],
8114 'top' : [ 'bl-tl', [0,-2], 'bottom']
8118 this.toolTip.render(Roo.get(document.body));
8120 this.toolTip.el.enableDisplayMode("block");
8122 Roo.get(document.body).on('click', function(){
8126 Roo.get(document.body).on('touchstart', function(){
8130 this.isApplied = true
8133 mask : function(form, target)
8137 this.target = target;
8139 if(!this.form.errorMask || !target.el){
8143 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8145 Roo.log(scrollable);
8147 var ot = this.target.el.calcOffsetsTo(scrollable);
8149 var scrollTo = ot[1] - this.form.maskOffset;
8151 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8153 scrollable.scrollTo('top', scrollTo);
8155 var box = this.target.el.getBox();
8157 var zIndex = Roo.bootstrap.Modal.zIndex++;
8160 this.maskEl.top.setStyle('position', 'absolute');
8161 this.maskEl.top.setStyle('z-index', zIndex);
8162 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8163 this.maskEl.top.setLeft(0);
8164 this.maskEl.top.setTop(0);
8165 this.maskEl.top.show();
8167 this.maskEl.left.setStyle('position', 'absolute');
8168 this.maskEl.left.setStyle('z-index', zIndex);
8169 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8170 this.maskEl.left.setLeft(0);
8171 this.maskEl.left.setTop(box.y - this.padding);
8172 this.maskEl.left.show();
8174 this.maskEl.bottom.setStyle('position', 'absolute');
8175 this.maskEl.bottom.setStyle('z-index', zIndex);
8176 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8177 this.maskEl.bottom.setLeft(0);
8178 this.maskEl.bottom.setTop(box.bottom + this.padding);
8179 this.maskEl.bottom.show();
8181 this.maskEl.right.setStyle('position', 'absolute');
8182 this.maskEl.right.setStyle('z-index', zIndex);
8183 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8184 this.maskEl.right.setLeft(box.right + this.padding);
8185 this.maskEl.right.setTop(box.y - this.padding);
8186 this.maskEl.right.show();
8188 this.toolTip.bindEl = this.target.el;
8190 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8192 var tip = this.target.blankText;
8194 if(this.target.getValue() !== '' ) {
8196 if (this.target.invalidText.length) {
8197 tip = this.target.invalidText;
8198 } else if (this.target.regexText.length){
8199 tip = this.target.regexText;
8203 this.toolTip.show(tip);
8205 this.intervalID = window.setInterval(function() {
8206 Roo.bootstrap.Form.popover.unmask();
8209 window.onwheel = function(){ return false;};
8211 (function(){ this.isMasked = true; }).defer(500, this);
8217 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8221 this.maskEl.top.setStyle('position', 'absolute');
8222 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8223 this.maskEl.top.hide();
8225 this.maskEl.left.setStyle('position', 'absolute');
8226 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8227 this.maskEl.left.hide();
8229 this.maskEl.bottom.setStyle('position', 'absolute');
8230 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8231 this.maskEl.bottom.hide();
8233 this.maskEl.right.setStyle('position', 'absolute');
8234 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8235 this.maskEl.right.hide();
8237 this.toolTip.hide();
8239 this.toolTip.el.hide();
8241 window.onwheel = function(){ return true;};
8243 if(this.intervalID){
8244 window.clearInterval(this.intervalID);
8245 this.intervalID = false;
8248 this.isMasked = false;
8258 * Ext JS Library 1.1.1
8259 * Copyright(c) 2006-2007, Ext JS, LLC.
8261 * Originally Released Under LGPL - original licence link has changed is not relivant.
8264 * <script type="text/javascript">
8267 * @class Roo.form.VTypes
8268 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8271 Roo.form.VTypes = function(){
8272 // closure these in so they are only created once.
8273 var alpha = /^[a-zA-Z_]+$/;
8274 var alphanum = /^[a-zA-Z0-9_]+$/;
8275 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8276 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8278 // All these messages and functions are configurable
8281 * The function used to validate email addresses
8282 * @param {String} value The email address
8284 'email' : function(v){
8285 return email.test(v);
8288 * The error text to display when the email validation function returns false
8291 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8293 * The keystroke filter mask to be applied on email input
8296 'emailMask' : /[a-z0-9_\.\-@]/i,
8299 * The function used to validate URLs
8300 * @param {String} value The URL
8302 'url' : function(v){
8306 * The error text to display when the url validation function returns false
8309 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8312 * The function used to validate alpha values
8313 * @param {String} value The value
8315 'alpha' : function(v){
8316 return alpha.test(v);
8319 * The error text to display when the alpha validation function returns false
8322 'alphaText' : 'This field should only contain letters and _',
8324 * The keystroke filter mask to be applied on alpha input
8327 'alphaMask' : /[a-z_]/i,
8330 * The function used to validate alphanumeric values
8331 * @param {String} value The value
8333 'alphanum' : function(v){
8334 return alphanum.test(v);
8337 * The error text to display when the alphanumeric validation function returns false
8340 'alphanumText' : 'This field should only contain letters, numbers and _',
8342 * The keystroke filter mask to be applied on alphanumeric input
8345 'alphanumMask' : /[a-z0-9_]/i
8355 * @class Roo.bootstrap.Input
8356 * @extends Roo.bootstrap.Component
8357 * Bootstrap Input class
8358 * @cfg {Boolean} disabled is it disabled
8359 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8360 * @cfg {String} name name of the input
8361 * @cfg {string} fieldLabel - the label associated
8362 * @cfg {string} placeholder - placeholder to put in text.
8363 * @cfg {string} before - input group add on before
8364 * @cfg {string} after - input group add on after
8365 * @cfg {string} size - (lg|sm) or leave empty..
8366 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8367 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8368 * @cfg {Number} md colspan out of 12 for computer-sized screens
8369 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8370 * @cfg {string} value default value of the input
8371 * @cfg {Number} labelWidth set the width of label
8372 * @cfg {Number} labellg set the width of label (1-12)
8373 * @cfg {Number} labelmd set the width of label (1-12)
8374 * @cfg {Number} labelsm set the width of label (1-12)
8375 * @cfg {Number} labelxs set the width of label (1-12)
8376 * @cfg {String} labelAlign (top|left)
8377 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8378 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8379 * @cfg {String} indicatorpos (left|right) default left
8381 * @cfg {String} align (left|center|right) Default left
8382 * @cfg {Boolean} forceFeedback (true|false) Default false
8388 * Create a new Input
8389 * @param {Object} config The config object
8392 Roo.bootstrap.Input = function(config){
8394 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8399 * Fires when this field receives input focus.
8400 * @param {Roo.form.Field} this
8405 * Fires when this field loses input focus.
8406 * @param {Roo.form.Field} this
8411 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8412 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8413 * @param {Roo.form.Field} this
8414 * @param {Roo.EventObject} e The event object
8419 * Fires just before the field blurs if the field value has changed.
8420 * @param {Roo.form.Field} this
8421 * @param {Mixed} newValue The new value
8422 * @param {Mixed} oldValue The original value
8427 * Fires after the field has been marked as invalid.
8428 * @param {Roo.form.Field} this
8429 * @param {String} msg The validation message
8434 * Fires after the field has been validated with no errors.
8435 * @param {Roo.form.Field} this
8440 * Fires after the key up
8441 * @param {Roo.form.Field} this
8442 * @param {Roo.EventObject} e The event Object
8448 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8450 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8451 automatic validation (defaults to "keyup").
8453 validationEvent : "keyup",
8455 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8457 validateOnBlur : true,
8459 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8461 validationDelay : 250,
8463 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8465 focusClass : "x-form-focus", // not needed???
8469 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8471 invalidClass : "has-warning",
8474 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8476 validClass : "has-success",
8479 * @cfg {Boolean} hasFeedback (true|false) default true
8484 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8486 invalidFeedbackClass : "glyphicon-warning-sign",
8489 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8491 validFeedbackClass : "glyphicon-ok",
8494 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8496 selectOnFocus : false,
8499 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8503 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8508 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8510 disableKeyFilter : false,
8513 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8517 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8521 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8523 blankText : "Please complete this mandatory field",
8526 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8530 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8532 maxLength : Number.MAX_VALUE,
8534 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8536 minLengthText : "The minimum length for this field is {0}",
8538 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8540 maxLengthText : "The maximum length for this field is {0}",
8544 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8545 * If available, this function will be called only after the basic validators all return true, and will be passed the
8546 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8550 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8551 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8552 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8556 * @cfg {String} regexText -- Depricated - use Invalid Text
8561 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8567 autocomplete: false,
8586 formatedValue : false,
8587 forceFeedback : false,
8589 indicatorpos : 'left',
8596 parentLabelAlign : function()
8599 while (parent.parent()) {
8600 parent = parent.parent();
8601 if (typeof(parent.labelAlign) !='undefined') {
8602 return parent.labelAlign;
8609 getAutoCreate : function()
8611 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8617 if(this.inputType != 'hidden'){
8618 cfg.cls = 'form-group' //input-group
8624 type : this.inputType,
8626 cls : 'form-control',
8627 placeholder : this.placeholder || '',
8628 autocomplete : this.autocomplete || 'new-password'
8632 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8635 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8636 input.maxLength = this.maxLength;
8639 if (this.disabled) {
8640 input.disabled=true;
8643 if (this.readOnly) {
8644 input.readonly=true;
8648 input.name = this.name;
8652 input.cls += ' input-' + this.size;
8656 ['xs','sm','md','lg'].map(function(size){
8657 if (settings[size]) {
8658 cfg.cls += ' col-' + size + '-' + settings[size];
8662 var inputblock = input;
8666 cls: 'glyphicon form-control-feedback'
8669 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8672 cls : 'has-feedback',
8680 if (this.before || this.after) {
8683 cls : 'input-group',
8687 if (this.before && typeof(this.before) == 'string') {
8689 inputblock.cn.push({
8691 cls : 'roo-input-before input-group-addon',
8695 if (this.before && typeof(this.before) == 'object') {
8696 this.before = Roo.factory(this.before);
8698 inputblock.cn.push({
8700 cls : 'roo-input-before input-group-' +
8701 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8705 inputblock.cn.push(input);
8707 if (this.after && typeof(this.after) == 'string') {
8708 inputblock.cn.push({
8710 cls : 'roo-input-after input-group-addon',
8714 if (this.after && typeof(this.after) == 'object') {
8715 this.after = Roo.factory(this.after);
8717 inputblock.cn.push({
8719 cls : 'roo-input-after input-group-' +
8720 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8724 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8725 inputblock.cls += ' has-feedback';
8726 inputblock.cn.push(feedback);
8730 if (align ==='left' && this.fieldLabel.length) {
8732 cfg.cls += ' roo-form-group-label-left';
8737 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8738 tooltip : 'This field is required'
8743 cls : 'control-label',
8744 html : this.fieldLabel
8755 var labelCfg = cfg.cn[1];
8756 var contentCfg = cfg.cn[2];
8758 if(this.indicatorpos == 'right'){
8763 cls : 'control-label',
8767 html : this.fieldLabel
8771 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8772 tooltip : 'This field is required'
8785 labelCfg = cfg.cn[0];
8786 contentCfg = cfg.cn[1];
8790 if(this.labelWidth > 12){
8791 labelCfg.style = "width: " + this.labelWidth + 'px';
8794 if(this.labelWidth < 13 && this.labelmd == 0){
8795 this.labelmd = this.labelWidth;
8798 if(this.labellg > 0){
8799 labelCfg.cls += ' col-lg-' + this.labellg;
8800 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8803 if(this.labelmd > 0){
8804 labelCfg.cls += ' col-md-' + this.labelmd;
8805 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8808 if(this.labelsm > 0){
8809 labelCfg.cls += ' col-sm-' + this.labelsm;
8810 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8813 if(this.labelxs > 0){
8814 labelCfg.cls += ' col-xs-' + this.labelxs;
8815 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8819 } else if ( this.fieldLabel.length) {
8824 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8825 tooltip : 'This field is required'
8829 //cls : 'input-group-addon',
8830 html : this.fieldLabel
8838 if(this.indicatorpos == 'right'){
8843 //cls : 'input-group-addon',
8844 html : this.fieldLabel
8849 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8850 tooltip : 'This field is required'
8870 if (this.parentType === 'Navbar' && this.parent().bar) {
8871 cfg.cls += ' navbar-form';
8874 if (this.parentType === 'NavGroup') {
8875 cfg.cls += ' navbar-form';
8883 * return the real input element.
8885 inputEl: function ()
8887 return this.el.select('input.form-control',true).first();
8890 tooltipEl : function()
8892 return this.inputEl();
8895 indicatorEl : function()
8897 var indicator = this.el.select('i.roo-required-indicator',true).first();
8907 setDisabled : function(v)
8909 var i = this.inputEl().dom;
8911 i.removeAttribute('disabled');
8915 i.setAttribute('disabled','true');
8917 initEvents : function()
8920 this.inputEl().on("keydown" , this.fireKey, this);
8921 this.inputEl().on("focus", this.onFocus, this);
8922 this.inputEl().on("blur", this.onBlur, this);
8924 this.inputEl().relayEvent('keyup', this);
8926 this.indicator = this.indicatorEl();
8929 this.indicator.addClass('invisible');
8933 // reference to original value for reset
8934 this.originalValue = this.getValue();
8935 //Roo.form.TextField.superclass.initEvents.call(this);
8936 if(this.validationEvent == 'keyup'){
8937 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8938 this.inputEl().on('keyup', this.filterValidation, this);
8940 else if(this.validationEvent !== false){
8941 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8944 if(this.selectOnFocus){
8945 this.on("focus", this.preFocus, this);
8948 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8949 this.inputEl().on("keypress", this.filterKeys, this);
8951 this.inputEl().relayEvent('keypress', this);
8954 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8955 this.el.on("click", this.autoSize, this);
8958 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
8959 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
8962 if (typeof(this.before) == 'object') {
8963 this.before.render(this.el.select('.roo-input-before',true).first());
8965 if (typeof(this.after) == 'object') {
8966 this.after.render(this.el.select('.roo-input-after',true).first());
8971 filterValidation : function(e){
8972 if(!e.isNavKeyPress()){
8973 this.validationTask.delay(this.validationDelay);
8977 * Validates the field value
8978 * @return {Boolean} True if the value is valid, else false
8980 validate : function(){
8981 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
8982 if(this.disabled || this.validateValue(this.getRawValue())){
8993 * Validates a value according to the field's validation rules and marks the field as invalid
8994 * if the validation fails
8995 * @param {Mixed} value The value to validate
8996 * @return {Boolean} True if the value is valid, else false
8998 validateValue : function(value){
8999 if(value.length < 1) { // if it's blank
9000 if(this.allowBlank){
9003 return this.inputEl().hasClass('hide') ? true : false;
9006 if(value.length < this.minLength){
9009 if(value.length > this.maxLength){
9013 var vt = Roo.form.VTypes;
9014 if(!vt[this.vtype](value, this)){
9018 if(typeof this.validator == "function"){
9019 var msg = this.validator(value);
9023 if (typeof(msg) == 'string') {
9024 this.invalidText = msg;
9028 if(this.regex && !this.regex.test(value)){
9038 fireKey : function(e){
9039 //Roo.log('field ' + e.getKey());
9040 if(e.isNavKeyPress()){
9041 this.fireEvent("specialkey", this, e);
9044 focus : function (selectText){
9046 this.inputEl().focus();
9047 if(selectText === true){
9048 this.inputEl().dom.select();
9054 onFocus : function(){
9055 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9056 // this.el.addClass(this.focusClass);
9059 this.hasFocus = true;
9060 this.startValue = this.getValue();
9061 this.fireEvent("focus", this);
9065 beforeBlur : Roo.emptyFn,
9069 onBlur : function(){
9071 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9072 //this.el.removeClass(this.focusClass);
9074 this.hasFocus = false;
9075 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9078 var v = this.getValue();
9079 if(String(v) !== String(this.startValue)){
9080 this.fireEvent('change', this, v, this.startValue);
9082 this.fireEvent("blur", this);
9086 * Resets the current field value to the originally loaded value and clears any validation messages
9089 this.setValue(this.originalValue);
9093 * Returns the name of the field
9094 * @return {Mixed} name The name field
9096 getName: function(){
9100 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9101 * @return {Mixed} value The field value
9103 getValue : function(){
9105 var v = this.inputEl().getValue();
9110 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9111 * @return {Mixed} value The field value
9113 getRawValue : function(){
9114 var v = this.inputEl().getValue();
9120 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9121 * @param {Mixed} value The value to set
9123 setRawValue : function(v){
9124 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9127 selectText : function(start, end){
9128 var v = this.getRawValue();
9130 start = start === undefined ? 0 : start;
9131 end = end === undefined ? v.length : end;
9132 var d = this.inputEl().dom;
9133 if(d.setSelectionRange){
9134 d.setSelectionRange(start, end);
9135 }else if(d.createTextRange){
9136 var range = d.createTextRange();
9137 range.moveStart("character", start);
9138 range.moveEnd("character", v.length-end);
9145 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9146 * @param {Mixed} value The value to set
9148 setValue : function(v){
9151 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9157 processValue : function(value){
9158 if(this.stripCharsRe){
9159 var newValue = value.replace(this.stripCharsRe, '');
9160 if(newValue !== value){
9161 this.setRawValue(newValue);
9168 preFocus : function(){
9170 if(this.selectOnFocus){
9171 this.inputEl().dom.select();
9174 filterKeys : function(e){
9176 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9179 var c = e.getCharCode(), cc = String.fromCharCode(c);
9180 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9183 if(!this.maskRe.test(cc)){
9188 * Clear any invalid styles/messages for this field
9190 clearInvalid : function(){
9192 if(!this.el || this.preventMark){ // not rendered
9197 this.el.removeClass(this.invalidClass);
9199 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9201 var feedback = this.el.select('.form-control-feedback', true).first();
9204 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9209 this.fireEvent('valid', this);
9213 * Mark this field as valid
9215 markValid : function()
9217 if(!this.el || this.preventMark){ // not rendered...
9221 this.el.removeClass([this.invalidClass, this.validClass]);
9223 var feedback = this.el.select('.form-control-feedback', true).first();
9226 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9233 if(this.allowBlank && !this.getRawValue().length){
9238 this.indicator.removeClass('visible');
9239 this.indicator.addClass('invisible');
9242 this.el.addClass(this.validClass);
9244 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9246 var feedback = this.el.select('.form-control-feedback', true).first();
9249 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9250 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9255 this.fireEvent('valid', this);
9259 * Mark this field as invalid
9260 * @param {String} msg The validation message
9262 markInvalid : function(msg)
9264 if(!this.el || this.preventMark){ // not rendered
9268 this.el.removeClass([this.invalidClass, this.validClass]);
9270 var feedback = this.el.select('.form-control-feedback', true).first();
9273 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9280 if(this.allowBlank && !this.getRawValue().length){
9285 this.indicator.removeClass('invisible');
9286 this.indicator.addClass('visible');
9289 this.el.addClass(this.invalidClass);
9291 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9293 var feedback = this.el.select('.form-control-feedback', true).first();
9296 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9298 if(this.getValue().length || this.forceFeedback){
9299 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9306 this.fireEvent('invalid', this, msg);
9309 SafariOnKeyDown : function(event)
9311 // this is a workaround for a password hang bug on chrome/ webkit.
9312 if (this.inputEl().dom.type != 'password') {
9316 var isSelectAll = false;
9318 if(this.inputEl().dom.selectionEnd > 0){
9319 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9321 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9322 event.preventDefault();
9327 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9329 event.preventDefault();
9330 // this is very hacky as keydown always get's upper case.
9332 var cc = String.fromCharCode(event.getCharCode());
9333 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9337 adjustWidth : function(tag, w){
9338 tag = tag.toLowerCase();
9339 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9340 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9344 if(tag == 'textarea'){
9347 }else if(Roo.isOpera){
9351 if(tag == 'textarea'){
9359 setFieldLabel : function(v)
9361 this.fieldLabel = v;
9364 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9378 * @class Roo.bootstrap.TextArea
9379 * @extends Roo.bootstrap.Input
9380 * Bootstrap TextArea class
9381 * @cfg {Number} cols Specifies the visible width of a text area
9382 * @cfg {Number} rows Specifies the visible number of lines in a text area
9383 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9384 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9385 * @cfg {string} html text
9388 * Create a new TextArea
9389 * @param {Object} config The config object
9392 Roo.bootstrap.TextArea = function(config){
9393 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9397 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9407 getAutoCreate : function(){
9409 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9415 if(this.inputType != 'hidden'){
9416 cfg.cls = 'form-group' //input-group
9424 value : this.value || '',
9425 html: this.html || '',
9426 cls : 'form-control',
9427 placeholder : this.placeholder || ''
9431 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9432 input.maxLength = this.maxLength;
9436 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9440 input.cols = this.cols;
9443 if (this.readOnly) {
9444 input.readonly = true;
9448 input.name = this.name;
9452 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9456 ['xs','sm','md','lg'].map(function(size){
9457 if (settings[size]) {
9458 cfg.cls += ' col-' + size + '-' + settings[size];
9462 var inputblock = input;
9464 if(this.hasFeedback && !this.allowBlank){
9468 cls: 'glyphicon form-control-feedback'
9472 cls : 'has-feedback',
9481 if (this.before || this.after) {
9484 cls : 'input-group',
9488 inputblock.cn.push({
9490 cls : 'input-group-addon',
9495 inputblock.cn.push(input);
9497 if(this.hasFeedback && !this.allowBlank){
9498 inputblock.cls += ' has-feedback';
9499 inputblock.cn.push(feedback);
9503 inputblock.cn.push({
9505 cls : 'input-group-addon',
9512 if (align ==='left' && this.fieldLabel.length) {
9517 cls : 'control-label',
9518 html : this.fieldLabel
9529 if(this.labelWidth > 12){
9530 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9533 if(this.labelWidth < 13 && this.labelmd == 0){
9534 this.labelmd = this.labelWidth;
9537 if(this.labellg > 0){
9538 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9539 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9542 if(this.labelmd > 0){
9543 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9544 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9547 if(this.labelsm > 0){
9548 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9549 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9552 if(this.labelxs > 0){
9553 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9554 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9557 } else if ( this.fieldLabel.length) {
9562 //cls : 'input-group-addon',
9563 html : this.fieldLabel
9581 if (this.disabled) {
9582 input.disabled=true;
9589 * return the real textarea element.
9591 inputEl: function ()
9593 return this.el.select('textarea.form-control',true).first();
9597 * Clear any invalid styles/messages for this field
9599 clearInvalid : function()
9602 if(!this.el || this.preventMark){ // not rendered
9606 var label = this.el.select('label', true).first();
9607 var icon = this.el.select('i.fa-star', true).first();
9613 this.el.removeClass(this.invalidClass);
9615 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9617 var feedback = this.el.select('.form-control-feedback', true).first();
9620 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9625 this.fireEvent('valid', this);
9629 * Mark this field as valid
9631 markValid : function()
9633 if(!this.el || this.preventMark){ // not rendered
9637 this.el.removeClass([this.invalidClass, this.validClass]);
9639 var feedback = this.el.select('.form-control-feedback', true).first();
9642 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9645 if(this.disabled || this.allowBlank){
9649 var label = this.el.select('label', true).first();
9650 var icon = this.el.select('i.fa-star', true).first();
9656 this.el.addClass(this.validClass);
9658 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9660 var feedback = this.el.select('.form-control-feedback', true).first();
9663 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9664 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9669 this.fireEvent('valid', this);
9673 * Mark this field as invalid
9674 * @param {String} msg The validation message
9676 markInvalid : function(msg)
9678 if(!this.el || this.preventMark){ // not rendered
9682 this.el.removeClass([this.invalidClass, this.validClass]);
9684 var feedback = this.el.select('.form-control-feedback', true).first();
9687 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9690 if(this.disabled || this.allowBlank){
9694 var label = this.el.select('label', true).first();
9695 var icon = this.el.select('i.fa-star', true).first();
9697 if(!this.getValue().length && label && !icon){
9698 this.el.createChild({
9700 cls : 'text-danger fa fa-lg fa-star',
9701 tooltip : 'This field is required',
9702 style : 'margin-right:5px;'
9706 this.el.addClass(this.invalidClass);
9708 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9710 var feedback = this.el.select('.form-control-feedback', true).first();
9713 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9715 if(this.getValue().length || this.forceFeedback){
9716 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9723 this.fireEvent('invalid', this, msg);
9731 * trigger field - base class for combo..
9736 * @class Roo.bootstrap.TriggerField
9737 * @extends Roo.bootstrap.Input
9738 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9739 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9740 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9741 * for which you can provide a custom implementation. For example:
9743 var trigger = new Roo.bootstrap.TriggerField();
9744 trigger.onTriggerClick = myTriggerFn;
9745 trigger.applyTo('my-field');
9748 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9749 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9750 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9751 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9752 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9755 * Create a new TriggerField.
9756 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9757 * to the base TextField)
9759 Roo.bootstrap.TriggerField = function(config){
9760 this.mimicing = false;
9761 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9764 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9766 * @cfg {String} triggerClass A CSS class to apply to the trigger
9769 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9774 * @cfg {Boolean} removable (true|false) special filter default false
9778 /** @cfg {Boolean} grow @hide */
9779 /** @cfg {Number} growMin @hide */
9780 /** @cfg {Number} growMax @hide */
9786 autoSize: Roo.emptyFn,
9793 actionMode : 'wrap',
9798 getAutoCreate : function(){
9800 var align = this.labelAlign || this.parentLabelAlign();
9805 cls: 'form-group' //input-group
9812 type : this.inputType,
9813 cls : 'form-control',
9814 autocomplete: 'new-password',
9815 placeholder : this.placeholder || ''
9819 input.name = this.name;
9822 input.cls += ' input-' + this.size;
9825 if (this.disabled) {
9826 input.disabled=true;
9829 var inputblock = input;
9831 if(this.hasFeedback && !this.allowBlank){
9835 cls: 'glyphicon form-control-feedback'
9838 if(this.removable && !this.editable && !this.tickable){
9840 cls : 'has-feedback',
9846 cls : 'roo-combo-removable-btn close'
9853 cls : 'has-feedback',
9862 if(this.removable && !this.editable && !this.tickable){
9864 cls : 'roo-removable',
9870 cls : 'roo-combo-removable-btn close'
9877 if (this.before || this.after) {
9880 cls : 'input-group',
9884 inputblock.cn.push({
9886 cls : 'input-group-addon',
9891 inputblock.cn.push(input);
9893 if(this.hasFeedback && !this.allowBlank){
9894 inputblock.cls += ' has-feedback';
9895 inputblock.cn.push(feedback);
9899 inputblock.cn.push({
9901 cls : 'input-group-addon',
9914 cls: 'form-hidden-field'
9928 cls: 'form-hidden-field'
9932 cls: 'roo-select2-choices',
9936 cls: 'roo-select2-search-field',
9949 cls: 'roo-select2-container input-group',
9954 // cls: 'typeahead typeahead-long dropdown-menu',
9955 // style: 'display:none'
9960 if(!this.multiple && this.showToggleBtn){
9966 if (this.caret != false) {
9969 cls: 'fa fa-' + this.caret
9976 cls : 'input-group-addon btn dropdown-toggle',
9981 cls: 'combobox-clear',
9995 combobox.cls += ' roo-select2-container-multi';
9998 if (align ==='left' && this.fieldLabel.length) {
10000 cfg.cls += ' roo-form-group-label-left';
10005 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10006 tooltip : 'This field is required'
10011 cls : 'control-label',
10012 html : this.fieldLabel
10024 var labelCfg = cfg.cn[1];
10025 var contentCfg = cfg.cn[2];
10027 if(this.indicatorpos == 'right'){
10032 cls : 'control-label',
10036 html : this.fieldLabel
10040 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10041 tooltip : 'This field is required'
10054 labelCfg = cfg.cn[0];
10055 contentCfg = cfg.cn[1];
10058 if(this.labelWidth > 12){
10059 labelCfg.style = "width: " + this.labelWidth + 'px';
10062 if(this.labelWidth < 13 && this.labelmd == 0){
10063 this.labelmd = this.labelWidth;
10066 if(this.labellg > 0){
10067 labelCfg.cls += ' col-lg-' + this.labellg;
10068 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10071 if(this.labelmd > 0){
10072 labelCfg.cls += ' col-md-' + this.labelmd;
10073 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10076 if(this.labelsm > 0){
10077 labelCfg.cls += ' col-sm-' + this.labelsm;
10078 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10081 if(this.labelxs > 0){
10082 labelCfg.cls += ' col-xs-' + this.labelxs;
10083 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10086 } else if ( this.fieldLabel.length) {
10087 // Roo.log(" label");
10091 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10092 tooltip : 'This field is required'
10096 //cls : 'input-group-addon',
10097 html : this.fieldLabel
10105 if(this.indicatorpos == 'right'){
10113 html : this.fieldLabel
10117 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10118 tooltip : 'This field is required'
10131 // Roo.log(" no label && no align");
10138 ['xs','sm','md','lg'].map(function(size){
10139 if (settings[size]) {
10140 cfg.cls += ' col-' + size + '-' + settings[size];
10151 onResize : function(w, h){
10152 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10153 // if(typeof w == 'number'){
10154 // var x = w - this.trigger.getWidth();
10155 // this.inputEl().setWidth(this.adjustWidth('input', x));
10156 // this.trigger.setStyle('left', x+'px');
10161 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10164 getResizeEl : function(){
10165 return this.inputEl();
10169 getPositionEl : function(){
10170 return this.inputEl();
10174 alignErrorIcon : function(){
10175 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10179 initEvents : function(){
10183 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10184 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10185 if(!this.multiple && this.showToggleBtn){
10186 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10187 if(this.hideTrigger){
10188 this.trigger.setDisplayed(false);
10190 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10194 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10197 if(this.removable && !this.editable && !this.tickable){
10198 var close = this.closeTriggerEl();
10201 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10202 close.on('click', this.removeBtnClick, this, close);
10206 //this.trigger.addClassOnOver('x-form-trigger-over');
10207 //this.trigger.addClassOnClick('x-form-trigger-click');
10210 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10214 closeTriggerEl : function()
10216 var close = this.el.select('.roo-combo-removable-btn', true).first();
10217 return close ? close : false;
10220 removeBtnClick : function(e, h, el)
10222 e.preventDefault();
10224 if(this.fireEvent("remove", this) !== false){
10226 this.fireEvent("afterremove", this)
10230 createList : function()
10232 this.list = Roo.get(document.body).createChild({
10234 cls: 'typeahead typeahead-long dropdown-menu',
10235 style: 'display:none'
10238 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10243 initTrigger : function(){
10248 onDestroy : function(){
10250 this.trigger.removeAllListeners();
10251 // this.trigger.remove();
10254 // this.wrap.remove();
10256 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10260 onFocus : function(){
10261 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10263 if(!this.mimicing){
10264 this.wrap.addClass('x-trigger-wrap-focus');
10265 this.mimicing = true;
10266 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10267 if(this.monitorTab){
10268 this.el.on("keydown", this.checkTab, this);
10275 checkTab : function(e){
10276 if(e.getKey() == e.TAB){
10277 this.triggerBlur();
10282 onBlur : function(){
10287 mimicBlur : function(e, t){
10289 if(!this.wrap.contains(t) && this.validateBlur()){
10290 this.triggerBlur();
10296 triggerBlur : function(){
10297 this.mimicing = false;
10298 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10299 if(this.monitorTab){
10300 this.el.un("keydown", this.checkTab, this);
10302 //this.wrap.removeClass('x-trigger-wrap-focus');
10303 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10307 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10308 validateBlur : function(e, t){
10313 onDisable : function(){
10314 this.inputEl().dom.disabled = true;
10315 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10317 // this.wrap.addClass('x-item-disabled');
10322 onEnable : function(){
10323 this.inputEl().dom.disabled = false;
10324 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10326 // this.el.removeClass('x-item-disabled');
10331 onShow : function(){
10332 var ae = this.getActionEl();
10335 ae.dom.style.display = '';
10336 ae.dom.style.visibility = 'visible';
10342 onHide : function(){
10343 var ae = this.getActionEl();
10344 ae.dom.style.display = 'none';
10348 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10349 * by an implementing function.
10351 * @param {EventObject} e
10353 onTriggerClick : Roo.emptyFn
10357 * Ext JS Library 1.1.1
10358 * Copyright(c) 2006-2007, Ext JS, LLC.
10360 * Originally Released Under LGPL - original licence link has changed is not relivant.
10363 * <script type="text/javascript">
10368 * @class Roo.data.SortTypes
10370 * Defines the default sorting (casting?) comparison functions used when sorting data.
10372 Roo.data.SortTypes = {
10374 * Default sort that does nothing
10375 * @param {Mixed} s The value being converted
10376 * @return {Mixed} The comparison value
10378 none : function(s){
10383 * The regular expression used to strip tags
10387 stripTagsRE : /<\/?[^>]+>/gi,
10390 * Strips all HTML tags to sort on text only
10391 * @param {Mixed} s The value being converted
10392 * @return {String} The comparison value
10394 asText : function(s){
10395 return String(s).replace(this.stripTagsRE, "");
10399 * Strips all HTML tags to sort on text only - Case insensitive
10400 * @param {Mixed} s The value being converted
10401 * @return {String} The comparison value
10403 asUCText : function(s){
10404 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10408 * Case insensitive string
10409 * @param {Mixed} s The value being converted
10410 * @return {String} The comparison value
10412 asUCString : function(s) {
10413 return String(s).toUpperCase();
10418 * @param {Mixed} s The value being converted
10419 * @return {Number} The comparison value
10421 asDate : function(s) {
10425 if(s instanceof Date){
10426 return s.getTime();
10428 return Date.parse(String(s));
10433 * @param {Mixed} s The value being converted
10434 * @return {Float} The comparison value
10436 asFloat : function(s) {
10437 var val = parseFloat(String(s).replace(/,/g, ""));
10446 * @param {Mixed} s The value being converted
10447 * @return {Number} The comparison value
10449 asInt : function(s) {
10450 var val = parseInt(String(s).replace(/,/g, ""));
10458 * Ext JS Library 1.1.1
10459 * Copyright(c) 2006-2007, Ext JS, LLC.
10461 * Originally Released Under LGPL - original licence link has changed is not relivant.
10464 * <script type="text/javascript">
10468 * @class Roo.data.Record
10469 * Instances of this class encapsulate both record <em>definition</em> information, and record
10470 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10471 * to access Records cached in an {@link Roo.data.Store} object.<br>
10473 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10474 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10477 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10479 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10480 * {@link #create}. The parameters are the same.
10481 * @param {Array} data An associative Array of data values keyed by the field name.
10482 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10483 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10484 * not specified an integer id is generated.
10486 Roo.data.Record = function(data, id){
10487 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10492 * Generate a constructor for a specific record layout.
10493 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10494 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10495 * Each field definition object may contain the following properties: <ul>
10496 * <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,
10497 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10498 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10499 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10500 * is being used, then this is a string containing the javascript expression to reference the data relative to
10501 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10502 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10503 * this may be omitted.</p></li>
10504 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10505 * <ul><li>auto (Default, implies no conversion)</li>
10510 * <li>date</li></ul></p></li>
10511 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10512 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10513 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10514 * by the Reader into an object that will be stored in the Record. It is passed the
10515 * following parameters:<ul>
10516 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10518 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10520 * <br>usage:<br><pre><code>
10521 var TopicRecord = Roo.data.Record.create(
10522 {name: 'title', mapping: 'topic_title'},
10523 {name: 'author', mapping: 'username'},
10524 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10525 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10526 {name: 'lastPoster', mapping: 'user2'},
10527 {name: 'excerpt', mapping: 'post_text'}
10530 var myNewRecord = new TopicRecord({
10531 title: 'Do my job please',
10534 lastPost: new Date(),
10535 lastPoster: 'Animal',
10536 excerpt: 'No way dude!'
10538 myStore.add(myNewRecord);
10543 Roo.data.Record.create = function(o){
10544 var f = function(){
10545 f.superclass.constructor.apply(this, arguments);
10547 Roo.extend(f, Roo.data.Record);
10548 var p = f.prototype;
10549 p.fields = new Roo.util.MixedCollection(false, function(field){
10552 for(var i = 0, len = o.length; i < len; i++){
10553 p.fields.add(new Roo.data.Field(o[i]));
10555 f.getField = function(name){
10556 return p.fields.get(name);
10561 Roo.data.Record.AUTO_ID = 1000;
10562 Roo.data.Record.EDIT = 'edit';
10563 Roo.data.Record.REJECT = 'reject';
10564 Roo.data.Record.COMMIT = 'commit';
10566 Roo.data.Record.prototype = {
10568 * Readonly flag - true if this record has been modified.
10577 join : function(store){
10578 this.store = store;
10582 * Set the named field to the specified value.
10583 * @param {String} name The name of the field to set.
10584 * @param {Object} value The value to set the field to.
10586 set : function(name, value){
10587 if(this.data[name] == value){
10591 if(!this.modified){
10592 this.modified = {};
10594 if(typeof this.modified[name] == 'undefined'){
10595 this.modified[name] = this.data[name];
10597 this.data[name] = value;
10598 if(!this.editing && this.store){
10599 this.store.afterEdit(this);
10604 * Get the value of the named field.
10605 * @param {String} name The name of the field to get the value of.
10606 * @return {Object} The value of the field.
10608 get : function(name){
10609 return this.data[name];
10613 beginEdit : function(){
10614 this.editing = true;
10615 this.modified = {};
10619 cancelEdit : function(){
10620 this.editing = false;
10621 delete this.modified;
10625 endEdit : function(){
10626 this.editing = false;
10627 if(this.dirty && this.store){
10628 this.store.afterEdit(this);
10633 * Usually called by the {@link Roo.data.Store} which owns the Record.
10634 * Rejects all changes made to the Record since either creation, or the last commit operation.
10635 * Modified fields are reverted to their original values.
10637 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10638 * of reject operations.
10640 reject : function(){
10641 var m = this.modified;
10643 if(typeof m[n] != "function"){
10644 this.data[n] = m[n];
10647 this.dirty = false;
10648 delete this.modified;
10649 this.editing = false;
10651 this.store.afterReject(this);
10656 * Usually called by the {@link Roo.data.Store} which owns the Record.
10657 * Commits all changes made to the Record since either creation, or the last commit operation.
10659 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10660 * of commit operations.
10662 commit : function(){
10663 this.dirty = false;
10664 delete this.modified;
10665 this.editing = false;
10667 this.store.afterCommit(this);
10672 hasError : function(){
10673 return this.error != null;
10677 clearError : function(){
10682 * Creates a copy of this record.
10683 * @param {String} id (optional) A new record id if you don't want to use this record's id
10686 copy : function(newId) {
10687 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10691 * Ext JS Library 1.1.1
10692 * Copyright(c) 2006-2007, Ext JS, LLC.
10694 * Originally Released Under LGPL - original licence link has changed is not relivant.
10697 * <script type="text/javascript">
10703 * @class Roo.data.Store
10704 * @extends Roo.util.Observable
10705 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10706 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10708 * 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
10709 * has no knowledge of the format of the data returned by the Proxy.<br>
10711 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10712 * instances from the data object. These records are cached and made available through accessor functions.
10714 * Creates a new Store.
10715 * @param {Object} config A config object containing the objects needed for the Store to access data,
10716 * and read the data into Records.
10718 Roo.data.Store = function(config){
10719 this.data = new Roo.util.MixedCollection(false);
10720 this.data.getKey = function(o){
10723 this.baseParams = {};
10725 this.paramNames = {
10730 "multisort" : "_multisort"
10733 if(config && config.data){
10734 this.inlineData = config.data;
10735 delete config.data;
10738 Roo.apply(this, config);
10740 if(this.reader){ // reader passed
10741 this.reader = Roo.factory(this.reader, Roo.data);
10742 this.reader.xmodule = this.xmodule || false;
10743 if(!this.recordType){
10744 this.recordType = this.reader.recordType;
10746 if(this.reader.onMetaChange){
10747 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10751 if(this.recordType){
10752 this.fields = this.recordType.prototype.fields;
10754 this.modified = [];
10758 * @event datachanged
10759 * Fires when the data cache has changed, and a widget which is using this Store
10760 * as a Record cache should refresh its view.
10761 * @param {Store} this
10763 datachanged : true,
10765 * @event metachange
10766 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10767 * @param {Store} this
10768 * @param {Object} meta The JSON metadata
10773 * Fires when Records have been added to the Store
10774 * @param {Store} this
10775 * @param {Roo.data.Record[]} records The array of Records added
10776 * @param {Number} index The index at which the record(s) were added
10781 * Fires when a Record has been removed from the Store
10782 * @param {Store} this
10783 * @param {Roo.data.Record} record The Record that was removed
10784 * @param {Number} index The index at which the record was removed
10789 * Fires when a Record has been updated
10790 * @param {Store} this
10791 * @param {Roo.data.Record} record The Record that was updated
10792 * @param {String} operation The update operation being performed. Value may be one of:
10794 Roo.data.Record.EDIT
10795 Roo.data.Record.REJECT
10796 Roo.data.Record.COMMIT
10802 * Fires when the data cache has been cleared.
10803 * @param {Store} this
10807 * @event beforeload
10808 * Fires before a request is made for a new data object. If the beforeload handler returns false
10809 * the load action will be canceled.
10810 * @param {Store} this
10811 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10815 * @event beforeloadadd
10816 * Fires after a new set of Records has been loaded.
10817 * @param {Store} this
10818 * @param {Roo.data.Record[]} records The Records that were loaded
10819 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10821 beforeloadadd : true,
10824 * Fires after a new set of Records has been loaded, before they are added to the store.
10825 * @param {Store} this
10826 * @param {Roo.data.Record[]} records The Records that were loaded
10827 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10828 * @params {Object} return from reader
10832 * @event loadexception
10833 * Fires if an exception occurs in the Proxy during loading.
10834 * Called with the signature of the Proxy's "loadexception" event.
10835 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10838 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10839 * @param {Object} load options
10840 * @param {Object} jsonData from your request (normally this contains the Exception)
10842 loadexception : true
10846 this.proxy = Roo.factory(this.proxy, Roo.data);
10847 this.proxy.xmodule = this.xmodule || false;
10848 this.relayEvents(this.proxy, ["loadexception"]);
10850 this.sortToggle = {};
10851 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10853 Roo.data.Store.superclass.constructor.call(this);
10855 if(this.inlineData){
10856 this.loadData(this.inlineData);
10857 delete this.inlineData;
10861 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10863 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10864 * without a remote query - used by combo/forms at present.
10868 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10871 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10874 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10875 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10878 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10879 * on any HTTP request
10882 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10885 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10889 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10890 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10892 remoteSort : false,
10895 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10896 * loaded or when a record is removed. (defaults to false).
10898 pruneModifiedRecords : false,
10901 lastOptions : null,
10904 * Add Records to the Store and fires the add event.
10905 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10907 add : function(records){
10908 records = [].concat(records);
10909 for(var i = 0, len = records.length; i < len; i++){
10910 records[i].join(this);
10912 var index = this.data.length;
10913 this.data.addAll(records);
10914 this.fireEvent("add", this, records, index);
10918 * Remove a Record from the Store and fires the remove event.
10919 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10921 remove : function(record){
10922 var index = this.data.indexOf(record);
10923 this.data.removeAt(index);
10924 if(this.pruneModifiedRecords){
10925 this.modified.remove(record);
10927 this.fireEvent("remove", this, record, index);
10931 * Remove all Records from the Store and fires the clear event.
10933 removeAll : function(){
10935 if(this.pruneModifiedRecords){
10936 this.modified = [];
10938 this.fireEvent("clear", this);
10942 * Inserts Records to the Store at the given index and fires the add event.
10943 * @param {Number} index The start index at which to insert the passed Records.
10944 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10946 insert : function(index, records){
10947 records = [].concat(records);
10948 for(var i = 0, len = records.length; i < len; i++){
10949 this.data.insert(index, records[i]);
10950 records[i].join(this);
10952 this.fireEvent("add", this, records, index);
10956 * Get the index within the cache of the passed Record.
10957 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
10958 * @return {Number} The index of the passed Record. Returns -1 if not found.
10960 indexOf : function(record){
10961 return this.data.indexOf(record);
10965 * Get the index within the cache of the Record with the passed id.
10966 * @param {String} id The id of the Record to find.
10967 * @return {Number} The index of the Record. Returns -1 if not found.
10969 indexOfId : function(id){
10970 return this.data.indexOfKey(id);
10974 * Get the Record with the specified id.
10975 * @param {String} id The id of the Record to find.
10976 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
10978 getById : function(id){
10979 return this.data.key(id);
10983 * Get the Record at the specified index.
10984 * @param {Number} index The index of the Record to find.
10985 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
10987 getAt : function(index){
10988 return this.data.itemAt(index);
10992 * Returns a range of Records between specified indices.
10993 * @param {Number} startIndex (optional) The starting index (defaults to 0)
10994 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
10995 * @return {Roo.data.Record[]} An array of Records
10997 getRange : function(start, end){
10998 return this.data.getRange(start, end);
11002 storeOptions : function(o){
11003 o = Roo.apply({}, o);
11006 this.lastOptions = o;
11010 * Loads the Record cache from the configured Proxy using the configured Reader.
11012 * If using remote paging, then the first load call must specify the <em>start</em>
11013 * and <em>limit</em> properties in the options.params property to establish the initial
11014 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11016 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11017 * and this call will return before the new data has been loaded. Perform any post-processing
11018 * in a callback function, or in a "load" event handler.</strong>
11020 * @param {Object} options An object containing properties which control loading options:<ul>
11021 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11022 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11023 * passed the following arguments:<ul>
11024 * <li>r : Roo.data.Record[]</li>
11025 * <li>options: Options object from the load call</li>
11026 * <li>success: Boolean success indicator</li></ul></li>
11027 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11028 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11031 load : function(options){
11032 options = options || {};
11033 if(this.fireEvent("beforeload", this, options) !== false){
11034 this.storeOptions(options);
11035 var p = Roo.apply(options.params || {}, this.baseParams);
11036 // if meta was not loaded from remote source.. try requesting it.
11037 if (!this.reader.metaFromRemote) {
11038 p._requestMeta = 1;
11040 if(this.sortInfo && this.remoteSort){
11041 var pn = this.paramNames;
11042 p[pn["sort"]] = this.sortInfo.field;
11043 p[pn["dir"]] = this.sortInfo.direction;
11045 if (this.multiSort) {
11046 var pn = this.paramNames;
11047 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11050 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11055 * Reloads the Record cache from the configured Proxy using the configured Reader and
11056 * the options from the last load operation performed.
11057 * @param {Object} options (optional) An object containing properties which may override the options
11058 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11059 * the most recently used options are reused).
11061 reload : function(options){
11062 this.load(Roo.applyIf(options||{}, this.lastOptions));
11066 // Called as a callback by the Reader during a load operation.
11067 loadRecords : function(o, options, success){
11068 if(!o || success === false){
11069 if(success !== false){
11070 this.fireEvent("load", this, [], options, o);
11072 if(options.callback){
11073 options.callback.call(options.scope || this, [], options, false);
11077 // if data returned failure - throw an exception.
11078 if (o.success === false) {
11079 // show a message if no listener is registered.
11080 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11081 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11083 // loadmask wil be hooked into this..
11084 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11087 var r = o.records, t = o.totalRecords || r.length;
11089 this.fireEvent("beforeloadadd", this, r, options, o);
11091 if(!options || options.add !== true){
11092 if(this.pruneModifiedRecords){
11093 this.modified = [];
11095 for(var i = 0, len = r.length; i < len; i++){
11099 this.data = this.snapshot;
11100 delete this.snapshot;
11103 this.data.addAll(r);
11104 this.totalLength = t;
11106 this.fireEvent("datachanged", this);
11108 this.totalLength = Math.max(t, this.data.length+r.length);
11112 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11114 var e = new Roo.data.Record({});
11116 e.set(this.parent.displayField, this.parent.emptyTitle);
11117 e.set(this.parent.valueField, '');
11122 this.fireEvent("load", this, r, options, o);
11123 if(options.callback){
11124 options.callback.call(options.scope || this, r, options, true);
11130 * Loads data from a passed data block. A Reader which understands the format of the data
11131 * must have been configured in the constructor.
11132 * @param {Object} data The data block from which to read the Records. The format of the data expected
11133 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11134 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11136 loadData : function(o, append){
11137 var r = this.reader.readRecords(o);
11138 this.loadRecords(r, {add: append}, true);
11142 * Gets the number of cached records.
11144 * <em>If using paging, this may not be the total size of the dataset. If the data object
11145 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11146 * the data set size</em>
11148 getCount : function(){
11149 return this.data.length || 0;
11153 * Gets the total number of records in the dataset as returned by the server.
11155 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11156 * the dataset size</em>
11158 getTotalCount : function(){
11159 return this.totalLength || 0;
11163 * Returns the sort state of the Store as an object with two properties:
11165 field {String} The name of the field by which the Records are sorted
11166 direction {String} The sort order, "ASC" or "DESC"
11169 getSortState : function(){
11170 return this.sortInfo;
11174 applySort : function(){
11175 if(this.sortInfo && !this.remoteSort){
11176 var s = this.sortInfo, f = s.field;
11177 var st = this.fields.get(f).sortType;
11178 var fn = function(r1, r2){
11179 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11180 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11182 this.data.sort(s.direction, fn);
11183 if(this.snapshot && this.snapshot != this.data){
11184 this.snapshot.sort(s.direction, fn);
11190 * Sets the default sort column and order to be used by the next load operation.
11191 * @param {String} fieldName The name of the field to sort by.
11192 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11194 setDefaultSort : function(field, dir){
11195 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11199 * Sort the Records.
11200 * If remote sorting is used, the sort is performed on the server, and the cache is
11201 * reloaded. If local sorting is used, the cache is sorted internally.
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 sort : function(fieldName, dir){
11206 var f = this.fields.get(fieldName);
11208 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11210 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11211 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11216 this.sortToggle[f.name] = dir;
11217 this.sortInfo = {field: f.name, direction: dir};
11218 if(!this.remoteSort){
11220 this.fireEvent("datachanged", this);
11222 this.load(this.lastOptions);
11227 * Calls the specified function for each of the Records in the cache.
11228 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11229 * Returning <em>false</em> aborts and exits the iteration.
11230 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11232 each : function(fn, scope){
11233 this.data.each(fn, scope);
11237 * Gets all records modified since the last commit. Modified records are persisted across load operations
11238 * (e.g., during paging).
11239 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11241 getModifiedRecords : function(){
11242 return this.modified;
11246 createFilterFn : function(property, value, anyMatch){
11247 if(!value.exec){ // not a regex
11248 value = String(value);
11249 if(value.length == 0){
11252 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11254 return function(r){
11255 return value.test(r.data[property]);
11260 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11261 * @param {String} property A field on your records
11262 * @param {Number} start The record index to start at (defaults to 0)
11263 * @param {Number} end The last record index to include (defaults to length - 1)
11264 * @return {Number} The sum
11266 sum : function(property, start, end){
11267 var rs = this.data.items, v = 0;
11268 start = start || 0;
11269 end = (end || end === 0) ? end : rs.length-1;
11271 for(var i = start; i <= end; i++){
11272 v += (rs[i].data[property] || 0);
11278 * Filter the records by a specified property.
11279 * @param {String} field A field on your records
11280 * @param {String/RegExp} value Either a string that the field
11281 * should start with or a RegExp to test against the field
11282 * @param {Boolean} anyMatch True to match any part not just the beginning
11284 filter : function(property, value, anyMatch){
11285 var fn = this.createFilterFn(property, value, anyMatch);
11286 return fn ? this.filterBy(fn) : this.clearFilter();
11290 * Filter by a function. The specified function will be called with each
11291 * record in this data source. If the function returns true the record is included,
11292 * otherwise it is filtered.
11293 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11294 * @param {Object} scope (optional) The scope of the function (defaults to this)
11296 filterBy : function(fn, scope){
11297 this.snapshot = this.snapshot || this.data;
11298 this.data = this.queryBy(fn, scope||this);
11299 this.fireEvent("datachanged", this);
11303 * Query the records by a specified property.
11304 * @param {String} field A field on your records
11305 * @param {String/RegExp} value Either a string that the field
11306 * should start with or a RegExp to test against the field
11307 * @param {Boolean} anyMatch True to match any part not just the beginning
11308 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11310 query : function(property, value, anyMatch){
11311 var fn = this.createFilterFn(property, value, anyMatch);
11312 return fn ? this.queryBy(fn) : this.data.clone();
11316 * Query by a function. The specified function will be called with each
11317 * record in this data source. If the function returns true the record is included
11319 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11320 * @param {Object} scope (optional) The scope of the function (defaults to this)
11321 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11323 queryBy : function(fn, scope){
11324 var data = this.snapshot || this.data;
11325 return data.filterBy(fn, scope||this);
11329 * Collects unique values for a particular dataIndex from this store.
11330 * @param {String} dataIndex The property to collect
11331 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11332 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11333 * @return {Array} An array of the unique values
11335 collect : function(dataIndex, allowNull, bypassFilter){
11336 var d = (bypassFilter === true && this.snapshot) ?
11337 this.snapshot.items : this.data.items;
11338 var v, sv, r = [], l = {};
11339 for(var i = 0, len = d.length; i < len; i++){
11340 v = d[i].data[dataIndex];
11342 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11351 * Revert to a view of the Record cache with no filtering applied.
11352 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11354 clearFilter : function(suppressEvent){
11355 if(this.snapshot && this.snapshot != this.data){
11356 this.data = this.snapshot;
11357 delete this.snapshot;
11358 if(suppressEvent !== true){
11359 this.fireEvent("datachanged", this);
11365 afterEdit : function(record){
11366 if(this.modified.indexOf(record) == -1){
11367 this.modified.push(record);
11369 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11373 afterReject : function(record){
11374 this.modified.remove(record);
11375 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11379 afterCommit : function(record){
11380 this.modified.remove(record);
11381 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11385 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11386 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11388 commitChanges : function(){
11389 var m = this.modified.slice(0);
11390 this.modified = [];
11391 for(var i = 0, len = m.length; i < len; i++){
11397 * Cancel outstanding changes on all changed records.
11399 rejectChanges : function(){
11400 var m = this.modified.slice(0);
11401 this.modified = [];
11402 for(var i = 0, len = m.length; i < len; i++){
11407 onMetaChange : function(meta, rtype, o){
11408 this.recordType = rtype;
11409 this.fields = rtype.prototype.fields;
11410 delete this.snapshot;
11411 this.sortInfo = meta.sortInfo || this.sortInfo;
11412 this.modified = [];
11413 this.fireEvent('metachange', this, this.reader.meta);
11416 moveIndex : function(data, type)
11418 var index = this.indexOf(data);
11420 var newIndex = index + type;
11424 this.insert(newIndex, data);
11429 * Ext JS Library 1.1.1
11430 * Copyright(c) 2006-2007, Ext JS, LLC.
11432 * Originally Released Under LGPL - original licence link has changed is not relivant.
11435 * <script type="text/javascript">
11439 * @class Roo.data.SimpleStore
11440 * @extends Roo.data.Store
11441 * Small helper class to make creating Stores from Array data easier.
11442 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11443 * @cfg {Array} fields An array of field definition objects, or field name strings.
11444 * @cfg {Array} data The multi-dimensional array of data
11446 * @param {Object} config
11448 Roo.data.SimpleStore = function(config){
11449 Roo.data.SimpleStore.superclass.constructor.call(this, {
11451 reader: new Roo.data.ArrayReader({
11454 Roo.data.Record.create(config.fields)
11456 proxy : new Roo.data.MemoryProxy(config.data)
11460 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11462 * Ext JS Library 1.1.1
11463 * Copyright(c) 2006-2007, Ext JS, LLC.
11465 * Originally Released Under LGPL - original licence link has changed is not relivant.
11468 * <script type="text/javascript">
11473 * @extends Roo.data.Store
11474 * @class Roo.data.JsonStore
11475 * Small helper class to make creating Stores for JSON data easier. <br/>
11477 var store = new Roo.data.JsonStore({
11478 url: 'get-images.php',
11480 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11483 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11484 * JsonReader and HttpProxy (unless inline data is provided).</b>
11485 * @cfg {Array} fields An array of field definition objects, or field name strings.
11487 * @param {Object} config
11489 Roo.data.JsonStore = function(c){
11490 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11491 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11492 reader: new Roo.data.JsonReader(c, c.fields)
11495 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11497 * Ext JS Library 1.1.1
11498 * Copyright(c) 2006-2007, Ext JS, LLC.
11500 * Originally Released Under LGPL - original licence link has changed is not relivant.
11503 * <script type="text/javascript">
11507 Roo.data.Field = function(config){
11508 if(typeof config == "string"){
11509 config = {name: config};
11511 Roo.apply(this, config);
11514 this.type = "auto";
11517 var st = Roo.data.SortTypes;
11518 // named sortTypes are supported, here we look them up
11519 if(typeof this.sortType == "string"){
11520 this.sortType = st[this.sortType];
11523 // set default sortType for strings and dates
11524 if(!this.sortType){
11527 this.sortType = st.asUCString;
11530 this.sortType = st.asDate;
11533 this.sortType = st.none;
11538 var stripRe = /[\$,%]/g;
11540 // prebuilt conversion function for this field, instead of
11541 // switching every time we're reading a value
11543 var cv, dateFormat = this.dateFormat;
11548 cv = function(v){ return v; };
11551 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11555 return v !== undefined && v !== null && v !== '' ?
11556 parseInt(String(v).replace(stripRe, ""), 10) : '';
11561 return v !== undefined && v !== null && v !== '' ?
11562 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11567 cv = function(v){ return v === true || v === "true" || v == 1; };
11574 if(v instanceof Date){
11578 if(dateFormat == "timestamp"){
11579 return new Date(v*1000);
11581 return Date.parseDate(v, dateFormat);
11583 var parsed = Date.parse(v);
11584 return parsed ? new Date(parsed) : null;
11593 Roo.data.Field.prototype = {
11601 * Ext JS Library 1.1.1
11602 * Copyright(c) 2006-2007, Ext JS, LLC.
11604 * Originally Released Under LGPL - original licence link has changed is not relivant.
11607 * <script type="text/javascript">
11610 // Base class for reading structured data from a data source. This class is intended to be
11611 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11614 * @class Roo.data.DataReader
11615 * Base class for reading structured data from a data source. This class is intended to be
11616 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11619 Roo.data.DataReader = function(meta, recordType){
11623 this.recordType = recordType instanceof Array ?
11624 Roo.data.Record.create(recordType) : recordType;
11627 Roo.data.DataReader.prototype = {
11629 * Create an empty record
11630 * @param {Object} data (optional) - overlay some values
11631 * @return {Roo.data.Record} record created.
11633 newRow : function(d) {
11635 this.recordType.prototype.fields.each(function(c) {
11637 case 'int' : da[c.name] = 0; break;
11638 case 'date' : da[c.name] = new Date(); break;
11639 case 'float' : da[c.name] = 0.0; break;
11640 case 'boolean' : da[c.name] = false; break;
11641 default : da[c.name] = ""; break;
11645 return new this.recordType(Roo.apply(da, d));
11650 * Ext JS Library 1.1.1
11651 * Copyright(c) 2006-2007, Ext JS, LLC.
11653 * Originally Released Under LGPL - original licence link has changed is not relivant.
11656 * <script type="text/javascript">
11660 * @class Roo.data.DataProxy
11661 * @extends Roo.data.Observable
11662 * This class is an abstract base class for implementations which provide retrieval of
11663 * unformatted data objects.<br>
11665 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11666 * (of the appropriate type which knows how to parse the data object) to provide a block of
11667 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11669 * Custom implementations must implement the load method as described in
11670 * {@link Roo.data.HttpProxy#load}.
11672 Roo.data.DataProxy = function(){
11675 * @event beforeload
11676 * Fires before a network request is made to retrieve a data object.
11677 * @param {Object} This DataProxy object.
11678 * @param {Object} params The params parameter to the load function.
11683 * Fires before the load method's callback is called.
11684 * @param {Object} This DataProxy object.
11685 * @param {Object} o The data object.
11686 * @param {Object} arg The callback argument object passed to the load function.
11690 * @event loadexception
11691 * Fires if an Exception occurs during data retrieval.
11692 * @param {Object} This DataProxy object.
11693 * @param {Object} o The data object.
11694 * @param {Object} arg The callback argument object passed to the load function.
11695 * @param {Object} e The Exception.
11697 loadexception : true
11699 Roo.data.DataProxy.superclass.constructor.call(this);
11702 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11705 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11709 * Ext JS Library 1.1.1
11710 * Copyright(c) 2006-2007, Ext JS, LLC.
11712 * Originally Released Under LGPL - original licence link has changed is not relivant.
11715 * <script type="text/javascript">
11718 * @class Roo.data.MemoryProxy
11719 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11720 * to the Reader when its load method is called.
11722 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11724 Roo.data.MemoryProxy = function(data){
11728 Roo.data.MemoryProxy.superclass.constructor.call(this);
11732 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11735 * Load data from the requested source (in this case an in-memory
11736 * data object passed to the constructor), read the data object into
11737 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11738 * process that block using the passed callback.
11739 * @param {Object} params This parameter is not used by the MemoryProxy class.
11740 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11741 * object into a block of Roo.data.Records.
11742 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11743 * The function must be passed <ul>
11744 * <li>The Record block object</li>
11745 * <li>The "arg" argument from the load function</li>
11746 * <li>A boolean success indicator</li>
11748 * @param {Object} scope The scope in which to call the callback
11749 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11751 load : function(params, reader, callback, scope, arg){
11752 params = params || {};
11755 result = reader.readRecords(this.data);
11757 this.fireEvent("loadexception", this, arg, null, e);
11758 callback.call(scope, null, arg, false);
11761 callback.call(scope, result, arg, true);
11765 update : function(params, records){
11770 * Ext JS Library 1.1.1
11771 * Copyright(c) 2006-2007, Ext JS, LLC.
11773 * Originally Released Under LGPL - original licence link has changed is not relivant.
11776 * <script type="text/javascript">
11779 * @class Roo.data.HttpProxy
11780 * @extends Roo.data.DataProxy
11781 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11782 * configured to reference a certain URL.<br><br>
11784 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11785 * from which the running page was served.<br><br>
11787 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11789 * Be aware that to enable the browser to parse an XML document, the server must set
11790 * the Content-Type header in the HTTP response to "text/xml".
11792 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11793 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11794 * will be used to make the request.
11796 Roo.data.HttpProxy = function(conn){
11797 Roo.data.HttpProxy.superclass.constructor.call(this);
11798 // is conn a conn config or a real conn?
11800 this.useAjax = !conn || !conn.events;
11804 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11805 // thse are take from connection...
11808 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11811 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11812 * extra parameters to each request made by this object. (defaults to undefined)
11815 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11816 * to each request made by this object. (defaults to undefined)
11819 * @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)
11822 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11825 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11831 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11835 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11836 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11837 * a finer-grained basis than the DataProxy events.
11839 getConnection : function(){
11840 return this.useAjax ? Roo.Ajax : this.conn;
11844 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11845 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11846 * process that block using the passed callback.
11847 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11848 * for the request to the remote server.
11849 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11850 * object into a block of Roo.data.Records.
11851 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11852 * The function must be passed <ul>
11853 * <li>The Record block object</li>
11854 * <li>The "arg" argument from the load function</li>
11855 * <li>A boolean success indicator</li>
11857 * @param {Object} scope The scope in which to call the callback
11858 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11860 load : function(params, reader, callback, scope, arg){
11861 if(this.fireEvent("beforeload", this, params) !== false){
11863 params : params || {},
11865 callback : callback,
11870 callback : this.loadResponse,
11874 Roo.applyIf(o, this.conn);
11875 if(this.activeRequest){
11876 Roo.Ajax.abort(this.activeRequest);
11878 this.activeRequest = Roo.Ajax.request(o);
11880 this.conn.request(o);
11883 callback.call(scope||this, null, arg, false);
11888 loadResponse : function(o, success, response){
11889 delete this.activeRequest;
11891 this.fireEvent("loadexception", this, o, response);
11892 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11897 result = o.reader.read(response);
11899 this.fireEvent("loadexception", this, o, response, e);
11900 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11904 this.fireEvent("load", this, o, o.request.arg);
11905 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11909 update : function(dataSet){
11914 updateResponse : function(dataSet){
11919 * Ext JS Library 1.1.1
11920 * Copyright(c) 2006-2007, Ext JS, LLC.
11922 * Originally Released Under LGPL - original licence link has changed is not relivant.
11925 * <script type="text/javascript">
11929 * @class Roo.data.ScriptTagProxy
11930 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11931 * other than the originating domain of the running page.<br><br>
11933 * <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
11934 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
11936 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
11937 * source code that is used as the source inside a <script> tag.<br><br>
11939 * In order for the browser to process the returned data, the server must wrap the data object
11940 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
11941 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
11942 * depending on whether the callback name was passed:
11945 boolean scriptTag = false;
11946 String cb = request.getParameter("callback");
11949 response.setContentType("text/javascript");
11951 response.setContentType("application/x-json");
11953 Writer out = response.getWriter();
11955 out.write(cb + "(");
11957 out.print(dataBlock.toJsonString());
11964 * @param {Object} config A configuration object.
11966 Roo.data.ScriptTagProxy = function(config){
11967 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
11968 Roo.apply(this, config);
11969 this.head = document.getElementsByTagName("head")[0];
11972 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
11974 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
11976 * @cfg {String} url The URL from which to request the data object.
11979 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
11983 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
11984 * the server the name of the callback function set up by the load call to process the returned data object.
11985 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
11986 * javascript output which calls this named function passing the data object as its only parameter.
11988 callbackParam : "callback",
11990 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
11991 * name to the request.
11996 * Load data from the configured URL, read the data object into
11997 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11998 * process that block using the passed callback.
11999 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12000 * for the request to the remote server.
12001 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12002 * object into a block of Roo.data.Records.
12003 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12004 * The function must be passed <ul>
12005 * <li>The Record block object</li>
12006 * <li>The "arg" argument from the load function</li>
12007 * <li>A boolean success indicator</li>
12009 * @param {Object} scope The scope in which to call the callback
12010 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12012 load : function(params, reader, callback, scope, arg){
12013 if(this.fireEvent("beforeload", this, params) !== false){
12015 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12017 var url = this.url;
12018 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12020 url += "&_dc=" + (new Date().getTime());
12022 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12025 cb : "stcCallback"+transId,
12026 scriptId : "stcScript"+transId,
12030 callback : callback,
12036 window[trans.cb] = function(o){
12037 conn.handleResponse(o, trans);
12040 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12042 if(this.autoAbort !== false){
12046 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12048 var script = document.createElement("script");
12049 script.setAttribute("src", url);
12050 script.setAttribute("type", "text/javascript");
12051 script.setAttribute("id", trans.scriptId);
12052 this.head.appendChild(script);
12054 this.trans = trans;
12056 callback.call(scope||this, null, arg, false);
12061 isLoading : function(){
12062 return this.trans ? true : false;
12066 * Abort the current server request.
12068 abort : function(){
12069 if(this.isLoading()){
12070 this.destroyTrans(this.trans);
12075 destroyTrans : function(trans, isLoaded){
12076 this.head.removeChild(document.getElementById(trans.scriptId));
12077 clearTimeout(trans.timeoutId);
12079 window[trans.cb] = undefined;
12081 delete window[trans.cb];
12084 // if hasn't been loaded, wait for load to remove it to prevent script error
12085 window[trans.cb] = function(){
12086 window[trans.cb] = undefined;
12088 delete window[trans.cb];
12095 handleResponse : function(o, trans){
12096 this.trans = false;
12097 this.destroyTrans(trans, true);
12100 result = trans.reader.readRecords(o);
12102 this.fireEvent("loadexception", this, o, trans.arg, e);
12103 trans.callback.call(trans.scope||window, null, trans.arg, false);
12106 this.fireEvent("load", this, o, trans.arg);
12107 trans.callback.call(trans.scope||window, result, trans.arg, true);
12111 handleFailure : function(trans){
12112 this.trans = false;
12113 this.destroyTrans(trans, false);
12114 this.fireEvent("loadexception", this, null, trans.arg);
12115 trans.callback.call(trans.scope||window, null, trans.arg, false);
12119 * Ext JS Library 1.1.1
12120 * Copyright(c) 2006-2007, Ext JS, LLC.
12122 * Originally Released Under LGPL - original licence link has changed is not relivant.
12125 * <script type="text/javascript">
12129 * @class Roo.data.JsonReader
12130 * @extends Roo.data.DataReader
12131 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12132 * based on mappings in a provided Roo.data.Record constructor.
12134 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12135 * in the reply previously.
12140 var RecordDef = Roo.data.Record.create([
12141 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12142 {name: 'occupation'} // This field will use "occupation" as the mapping.
12144 var myReader = new Roo.data.JsonReader({
12145 totalProperty: "results", // The property which contains the total dataset size (optional)
12146 root: "rows", // The property which contains an Array of row objects
12147 id: "id" // The property within each row object that provides an ID for the record (optional)
12151 * This would consume a JSON file like this:
12153 { 'results': 2, 'rows': [
12154 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12155 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12158 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12159 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12160 * paged from the remote server.
12161 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12162 * @cfg {String} root name of the property which contains the Array of row objects.
12163 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12164 * @cfg {Array} fields Array of field definition objects
12166 * Create a new JsonReader
12167 * @param {Object} meta Metadata configuration options
12168 * @param {Object} recordType Either an Array of field definition objects,
12169 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12171 Roo.data.JsonReader = function(meta, recordType){
12174 // set some defaults:
12175 Roo.applyIf(meta, {
12176 totalProperty: 'total',
12177 successProperty : 'success',
12182 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12184 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12187 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12188 * Used by Store query builder to append _requestMeta to params.
12191 metaFromRemote : false,
12193 * This method is only used by a DataProxy which has retrieved data from a remote server.
12194 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12195 * @return {Object} data A data block which is used by an Roo.data.Store object as
12196 * a cache of Roo.data.Records.
12198 read : function(response){
12199 var json = response.responseText;
12201 var o = /* eval:var:o */ eval("("+json+")");
12203 throw {message: "JsonReader.read: Json object not found"};
12209 this.metaFromRemote = true;
12210 this.meta = o.metaData;
12211 this.recordType = Roo.data.Record.create(o.metaData.fields);
12212 this.onMetaChange(this.meta, this.recordType, o);
12214 return this.readRecords(o);
12217 // private function a store will implement
12218 onMetaChange : function(meta, recordType, o){
12225 simpleAccess: function(obj, subsc) {
12232 getJsonAccessor: function(){
12234 return function(expr) {
12236 return(re.test(expr))
12237 ? new Function("obj", "return obj." + expr)
12242 return Roo.emptyFn;
12247 * Create a data block containing Roo.data.Records from an XML document.
12248 * @param {Object} o An object which contains an Array of row objects in the property specified
12249 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12250 * which contains the total size of the dataset.
12251 * @return {Object} data A data block which is used by an Roo.data.Store object as
12252 * a cache of Roo.data.Records.
12254 readRecords : function(o){
12256 * After any data loads, the raw JSON data is available for further custom processing.
12260 var s = this.meta, Record = this.recordType,
12261 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12263 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12265 if(s.totalProperty) {
12266 this.getTotal = this.getJsonAccessor(s.totalProperty);
12268 if(s.successProperty) {
12269 this.getSuccess = this.getJsonAccessor(s.successProperty);
12271 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12273 var g = this.getJsonAccessor(s.id);
12274 this.getId = function(rec) {
12276 return (r === undefined || r === "") ? null : r;
12279 this.getId = function(){return null;};
12282 for(var jj = 0; jj < fl; jj++){
12284 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12285 this.ef[jj] = this.getJsonAccessor(map);
12289 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12290 if(s.totalProperty){
12291 var vt = parseInt(this.getTotal(o), 10);
12296 if(s.successProperty){
12297 var vs = this.getSuccess(o);
12298 if(vs === false || vs === 'false'){
12303 for(var i = 0; i < c; i++){
12306 var id = this.getId(n);
12307 for(var j = 0; j < fl; j++){
12309 var v = this.ef[j](n);
12311 Roo.log('missing convert for ' + f.name);
12315 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12317 var record = new Record(values, id);
12319 records[i] = record;
12325 totalRecords : totalRecords
12330 * Ext JS Library 1.1.1
12331 * Copyright(c) 2006-2007, Ext JS, LLC.
12333 * Originally Released Under LGPL - original licence link has changed is not relivant.
12336 * <script type="text/javascript">
12340 * @class Roo.data.ArrayReader
12341 * @extends Roo.data.DataReader
12342 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12343 * Each element of that Array represents a row of data fields. The
12344 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12345 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12349 var RecordDef = Roo.data.Record.create([
12350 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12351 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12353 var myReader = new Roo.data.ArrayReader({
12354 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12358 * This would consume an Array like this:
12360 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12362 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12364 * Create a new JsonReader
12365 * @param {Object} meta Metadata configuration options.
12366 * @param {Object} recordType Either an Array of field definition objects
12367 * as specified to {@link Roo.data.Record#create},
12368 * or an {@link Roo.data.Record} object
12369 * created using {@link Roo.data.Record#create}.
12371 Roo.data.ArrayReader = function(meta, recordType){
12372 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12375 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12377 * Create a data block containing Roo.data.Records from an XML document.
12378 * @param {Object} o An Array of row objects which represents the dataset.
12379 * @return {Object} data A data block which is used by an Roo.data.Store object as
12380 * a cache of Roo.data.Records.
12382 readRecords : function(o){
12383 var sid = this.meta ? this.meta.id : null;
12384 var recordType = this.recordType, fields = recordType.prototype.fields;
12387 for(var i = 0; i < root.length; i++){
12390 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12391 for(var j = 0, jlen = fields.length; j < jlen; j++){
12392 var f = fields.items[j];
12393 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12394 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12396 values[f.name] = v;
12398 var record = new recordType(values, id);
12400 records[records.length] = record;
12404 totalRecords : records.length
12413 * @class Roo.bootstrap.ComboBox
12414 * @extends Roo.bootstrap.TriggerField
12415 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12416 * @cfg {Boolean} append (true|false) default false
12417 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12418 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12419 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12420 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12421 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12422 * @cfg {Boolean} animate default true
12423 * @cfg {Boolean} emptyResultText only for touch device
12424 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12425 * @cfg {String} emptyTitle default ''
12427 * Create a new ComboBox.
12428 * @param {Object} config Configuration options
12430 Roo.bootstrap.ComboBox = function(config){
12431 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12435 * Fires when the dropdown list is expanded
12436 * @param {Roo.bootstrap.ComboBox} combo This combo box
12441 * Fires when the dropdown list is collapsed
12442 * @param {Roo.bootstrap.ComboBox} combo This combo box
12446 * @event beforeselect
12447 * Fires before a list item is selected. Return false to cancel the selection.
12448 * @param {Roo.bootstrap.ComboBox} combo This combo box
12449 * @param {Roo.data.Record} record The data record returned from the underlying store
12450 * @param {Number} index The index of the selected item in the dropdown list
12452 'beforeselect' : true,
12455 * Fires when a list item is selected
12456 * @param {Roo.bootstrap.ComboBox} combo This combo box
12457 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12458 * @param {Number} index The index of the selected item in the dropdown list
12462 * @event beforequery
12463 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12464 * The event object passed has these properties:
12465 * @param {Roo.bootstrap.ComboBox} combo This combo box
12466 * @param {String} query The query
12467 * @param {Boolean} forceAll true to force "all" query
12468 * @param {Boolean} cancel true to cancel the query
12469 * @param {Object} e The query event object
12471 'beforequery': true,
12474 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12475 * @param {Roo.bootstrap.ComboBox} combo This combo box
12480 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12481 * @param {Roo.bootstrap.ComboBox} combo This combo box
12482 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12487 * Fires when the remove value from the combobox array
12488 * @param {Roo.bootstrap.ComboBox} combo This combo box
12492 * @event afterremove
12493 * Fires when the remove value from the combobox array
12494 * @param {Roo.bootstrap.ComboBox} combo This combo box
12496 'afterremove' : true,
12498 * @event specialfilter
12499 * Fires when specialfilter
12500 * @param {Roo.bootstrap.ComboBox} combo This combo box
12502 'specialfilter' : true,
12505 * Fires when tick the element
12506 * @param {Roo.bootstrap.ComboBox} combo This combo box
12510 * @event touchviewdisplay
12511 * Fires when touch view require special display (default is using displayField)
12512 * @param {Roo.bootstrap.ComboBox} combo This combo box
12513 * @param {Object} cfg set html .
12515 'touchviewdisplay' : true
12520 this.tickItems = [];
12522 this.selectedIndex = -1;
12523 if(this.mode == 'local'){
12524 if(config.queryDelay === undefined){
12525 this.queryDelay = 10;
12527 if(config.minChars === undefined){
12533 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12536 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12537 * rendering into an Roo.Editor, defaults to false)
12540 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12541 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12544 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12547 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12548 * the dropdown list (defaults to undefined, with no header element)
12552 * @cfg {String/Roo.Template} tpl The template to use to render the output
12556 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12558 listWidth: undefined,
12560 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12561 * mode = 'remote' or 'text' if mode = 'local')
12563 displayField: undefined,
12566 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12567 * mode = 'remote' or 'value' if mode = 'local').
12568 * Note: use of a valueField requires the user make a selection
12569 * in order for a value to be mapped.
12571 valueField: undefined,
12573 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12578 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12579 * field's data value (defaults to the underlying DOM element's name)
12581 hiddenName: undefined,
12583 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12587 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12589 selectedClass: 'active',
12592 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12596 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12597 * anchor positions (defaults to 'tl-bl')
12599 listAlign: 'tl-bl?',
12601 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12605 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12606 * query specified by the allQuery config option (defaults to 'query')
12608 triggerAction: 'query',
12610 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12611 * (defaults to 4, does not apply if editable = false)
12615 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12616 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12620 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12621 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12625 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12626 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12630 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12631 * when editable = true (defaults to false)
12633 selectOnFocus:false,
12635 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12637 queryParam: 'query',
12639 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12640 * when mode = 'remote' (defaults to 'Loading...')
12642 loadingText: 'Loading...',
12644 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12648 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12652 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12653 * traditional select (defaults to true)
12657 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12661 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12665 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12666 * listWidth has a higher value)
12670 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12671 * allow the user to set arbitrary text into the field (defaults to false)
12673 forceSelection:false,
12675 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12676 * if typeAhead = true (defaults to 250)
12678 typeAheadDelay : 250,
12680 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12681 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12683 valueNotFoundText : undefined,
12685 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12687 blockFocus : false,
12690 * @cfg {Boolean} disableClear Disable showing of clear button.
12692 disableClear : false,
12694 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12696 alwaysQuery : false,
12699 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12704 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12706 invalidClass : "has-warning",
12709 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12711 validClass : "has-success",
12714 * @cfg {Boolean} specialFilter (true|false) special filter default false
12716 specialFilter : false,
12719 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12721 mobileTouchView : true,
12724 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12726 useNativeIOS : false,
12728 ios_options : false,
12740 btnPosition : 'right',
12741 triggerList : true,
12742 showToggleBtn : true,
12744 emptyResultText: 'Empty',
12745 triggerText : 'Select',
12748 // element that contains real text value.. (when hidden is used..)
12750 getAutoCreate : function()
12755 * Render classic select for iso
12758 if(Roo.isIOS && this.useNativeIOS){
12759 cfg = this.getAutoCreateNativeIOS();
12767 if(Roo.isTouch && this.mobileTouchView){
12768 cfg = this.getAutoCreateTouchView();
12775 if(!this.tickable){
12776 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12781 * ComboBox with tickable selections
12784 var align = this.labelAlign || this.parentLabelAlign();
12787 cls : 'form-group roo-combobox-tickable' //input-group
12790 var btn_text_select = '';
12791 var btn_text_done = '';
12792 var btn_text_cancel = '';
12794 if (this.btn_text_show) {
12795 btn_text_select = 'Select';
12796 btn_text_done = 'Done';
12797 btn_text_cancel = 'Cancel';
12802 cls : 'tickable-buttons',
12807 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12808 //html : this.triggerText
12809 html: btn_text_select
12815 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12817 html: btn_text_done
12823 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12825 html: btn_text_cancel
12831 buttons.cn.unshift({
12833 cls: 'roo-select2-search-field-input'
12839 Roo.each(buttons.cn, function(c){
12841 c.cls += ' btn-' + _this.size;
12844 if (_this.disabled) {
12855 cls: 'form-hidden-field'
12859 cls: 'roo-select2-choices',
12863 cls: 'roo-select2-search-field',
12874 cls: 'roo-select2-container input-group roo-select2-container-multi',
12879 // cls: 'typeahead typeahead-long dropdown-menu',
12880 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12885 if(this.hasFeedback && !this.allowBlank){
12889 cls: 'glyphicon form-control-feedback'
12892 combobox.cn.push(feedback);
12896 if (align ==='left' && this.fieldLabel.length) {
12898 cfg.cls += ' roo-form-group-label-left';
12903 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12904 tooltip : 'This field is required'
12909 cls : 'control-label',
12910 html : this.fieldLabel
12922 var labelCfg = cfg.cn[1];
12923 var contentCfg = cfg.cn[2];
12926 if(this.indicatorpos == 'right'){
12932 cls : 'control-label',
12936 html : this.fieldLabel
12940 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12941 tooltip : 'This field is required'
12956 labelCfg = cfg.cn[0];
12957 contentCfg = cfg.cn[1];
12961 if(this.labelWidth > 12){
12962 labelCfg.style = "width: " + this.labelWidth + 'px';
12965 if(this.labelWidth < 13 && this.labelmd == 0){
12966 this.labelmd = this.labelWidth;
12969 if(this.labellg > 0){
12970 labelCfg.cls += ' col-lg-' + this.labellg;
12971 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12974 if(this.labelmd > 0){
12975 labelCfg.cls += ' col-md-' + this.labelmd;
12976 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12979 if(this.labelsm > 0){
12980 labelCfg.cls += ' col-sm-' + this.labelsm;
12981 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12984 if(this.labelxs > 0){
12985 labelCfg.cls += ' col-xs-' + this.labelxs;
12986 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12990 } else if ( this.fieldLabel.length) {
12991 // Roo.log(" label");
12995 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12996 tooltip : 'This field is required'
13000 //cls : 'input-group-addon',
13001 html : this.fieldLabel
13006 if(this.indicatorpos == 'right'){
13010 //cls : 'input-group-addon',
13011 html : this.fieldLabel
13015 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13016 tooltip : 'This field is required'
13025 // Roo.log(" no label && no align");
13032 ['xs','sm','md','lg'].map(function(size){
13033 if (settings[size]) {
13034 cfg.cls += ' col-' + size + '-' + settings[size];
13042 _initEventsCalled : false,
13045 initEvents: function()
13047 if (this._initEventsCalled) { // as we call render... prevent looping...
13050 this._initEventsCalled = true;
13053 throw "can not find store for combo";
13056 this.indicator = this.indicatorEl();
13058 this.store = Roo.factory(this.store, Roo.data);
13059 this.store.parent = this;
13061 // if we are building from html. then this element is so complex, that we can not really
13062 // use the rendered HTML.
13063 // so we have to trash and replace the previous code.
13064 if (Roo.XComponent.build_from_html) {
13065 // remove this element....
13066 var e = this.el.dom, k=0;
13067 while (e ) { e = e.previousSibling; ++k;}
13072 this.rendered = false;
13074 this.render(this.parent().getChildContainer(true), k);
13077 if(Roo.isIOS && this.useNativeIOS){
13078 this.initIOSView();
13086 if(Roo.isTouch && this.mobileTouchView){
13087 this.initTouchView();
13092 this.initTickableEvents();
13096 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13098 if(this.hiddenName){
13100 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13102 this.hiddenField.dom.value =
13103 this.hiddenValue !== undefined ? this.hiddenValue :
13104 this.value !== undefined ? this.value : '';
13106 // prevent input submission
13107 this.el.dom.removeAttribute('name');
13108 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13113 // this.el.dom.setAttribute('autocomplete', 'off');
13116 var cls = 'x-combo-list';
13118 //this.list = new Roo.Layer({
13119 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13125 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13126 _this.list.setWidth(lw);
13129 this.list.on('mouseover', this.onViewOver, this);
13130 this.list.on('mousemove', this.onViewMove, this);
13131 this.list.on('scroll', this.onViewScroll, this);
13134 this.list.swallowEvent('mousewheel');
13135 this.assetHeight = 0;
13138 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13139 this.assetHeight += this.header.getHeight();
13142 this.innerList = this.list.createChild({cls:cls+'-inner'});
13143 this.innerList.on('mouseover', this.onViewOver, this);
13144 this.innerList.on('mousemove', this.onViewMove, this);
13145 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13147 if(this.allowBlank && !this.pageSize && !this.disableClear){
13148 this.footer = this.list.createChild({cls:cls+'-ft'});
13149 this.pageTb = new Roo.Toolbar(this.footer);
13153 this.footer = this.list.createChild({cls:cls+'-ft'});
13154 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13155 {pageSize: this.pageSize});
13159 if (this.pageTb && this.allowBlank && !this.disableClear) {
13161 this.pageTb.add(new Roo.Toolbar.Fill(), {
13162 cls: 'x-btn-icon x-btn-clear',
13164 handler: function()
13167 _this.clearValue();
13168 _this.onSelect(false, -1);
13173 this.assetHeight += this.footer.getHeight();
13178 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13181 this.view = new Roo.View(this.list, this.tpl, {
13182 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13184 //this.view.wrapEl.setDisplayed(false);
13185 this.view.on('click', this.onViewClick, this);
13188 this.store.on('beforeload', this.onBeforeLoad, this);
13189 this.store.on('load', this.onLoad, this);
13190 this.store.on('loadexception', this.onLoadException, this);
13192 if(this.resizable){
13193 this.resizer = new Roo.Resizable(this.list, {
13194 pinned:true, handles:'se'
13196 this.resizer.on('resize', function(r, w, h){
13197 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13198 this.listWidth = w;
13199 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13200 this.restrictHeight();
13202 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13205 if(!this.editable){
13206 this.editable = true;
13207 this.setEditable(false);
13212 if (typeof(this.events.add.listeners) != 'undefined') {
13214 this.addicon = this.wrap.createChild(
13215 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13217 this.addicon.on('click', function(e) {
13218 this.fireEvent('add', this);
13221 if (typeof(this.events.edit.listeners) != 'undefined') {
13223 this.editicon = this.wrap.createChild(
13224 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13225 if (this.addicon) {
13226 this.editicon.setStyle('margin-left', '40px');
13228 this.editicon.on('click', function(e) {
13230 // we fire even if inothing is selected..
13231 this.fireEvent('edit', this, this.lastData );
13237 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13238 "up" : function(e){
13239 this.inKeyMode = true;
13243 "down" : function(e){
13244 if(!this.isExpanded()){
13245 this.onTriggerClick();
13247 this.inKeyMode = true;
13252 "enter" : function(e){
13253 // this.onViewClick();
13257 if(this.fireEvent("specialkey", this, e)){
13258 this.onViewClick(false);
13264 "esc" : function(e){
13268 "tab" : function(e){
13271 if(this.fireEvent("specialkey", this, e)){
13272 this.onViewClick(false);
13280 doRelay : function(foo, bar, hname){
13281 if(hname == 'down' || this.scope.isExpanded()){
13282 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13291 this.queryDelay = Math.max(this.queryDelay || 10,
13292 this.mode == 'local' ? 10 : 250);
13295 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13297 if(this.typeAhead){
13298 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13300 if(this.editable !== false){
13301 this.inputEl().on("keyup", this.onKeyUp, this);
13303 if(this.forceSelection){
13304 this.inputEl().on('blur', this.doForce, this);
13308 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13309 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13313 initTickableEvents: function()
13317 if(this.hiddenName){
13319 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13321 this.hiddenField.dom.value =
13322 this.hiddenValue !== undefined ? this.hiddenValue :
13323 this.value !== undefined ? this.value : '';
13325 // prevent input submission
13326 this.el.dom.removeAttribute('name');
13327 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13332 // this.list = this.el.select('ul.dropdown-menu',true).first();
13334 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13335 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13336 if(this.triggerList){
13337 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13340 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13341 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13343 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13344 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13346 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13347 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13349 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13350 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13351 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13354 this.cancelBtn.hide();
13359 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13360 _this.list.setWidth(lw);
13363 this.list.on('mouseover', this.onViewOver, this);
13364 this.list.on('mousemove', this.onViewMove, this);
13366 this.list.on('scroll', this.onViewScroll, this);
13369 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>';
13372 this.view = new Roo.View(this.list, this.tpl, {
13373 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13376 //this.view.wrapEl.setDisplayed(false);
13377 this.view.on('click', this.onViewClick, this);
13381 this.store.on('beforeload', this.onBeforeLoad, this);
13382 this.store.on('load', this.onLoad, this);
13383 this.store.on('loadexception', this.onLoadException, this);
13386 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13387 "up" : function(e){
13388 this.inKeyMode = true;
13392 "down" : function(e){
13393 this.inKeyMode = true;
13397 "enter" : function(e){
13398 if(this.fireEvent("specialkey", this, e)){
13399 this.onViewClick(false);
13405 "esc" : function(e){
13406 this.onTickableFooterButtonClick(e, false, false);
13409 "tab" : function(e){
13410 this.fireEvent("specialkey", this, e);
13412 this.onTickableFooterButtonClick(e, false, false);
13419 doRelay : function(e, fn, key){
13420 if(this.scope.isExpanded()){
13421 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13430 this.queryDelay = Math.max(this.queryDelay || 10,
13431 this.mode == 'local' ? 10 : 250);
13434 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13436 if(this.typeAhead){
13437 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13440 if(this.editable !== false){
13441 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13444 this.indicator = this.indicatorEl();
13446 if(this.indicator){
13447 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13448 this.indicator.hide();
13453 onDestroy : function(){
13455 this.view.setStore(null);
13456 this.view.el.removeAllListeners();
13457 this.view.el.remove();
13458 this.view.purgeListeners();
13461 this.list.dom.innerHTML = '';
13465 this.store.un('beforeload', this.onBeforeLoad, this);
13466 this.store.un('load', this.onLoad, this);
13467 this.store.un('loadexception', this.onLoadException, this);
13469 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13473 fireKey : function(e){
13474 if(e.isNavKeyPress() && !this.list.isVisible()){
13475 this.fireEvent("specialkey", this, e);
13480 onResize: function(w, h){
13481 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13483 // if(typeof w != 'number'){
13484 // // we do not handle it!?!?
13487 // var tw = this.trigger.getWidth();
13488 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13489 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13491 // this.inputEl().setWidth( this.adjustWidth('input', x));
13493 // //this.trigger.setStyle('left', x+'px');
13495 // if(this.list && this.listWidth === undefined){
13496 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13497 // this.list.setWidth(lw);
13498 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13506 * Allow or prevent the user from directly editing the field text. If false is passed,
13507 * the user will only be able to select from the items defined in the dropdown list. This method
13508 * is the runtime equivalent of setting the 'editable' config option at config time.
13509 * @param {Boolean} value True to allow the user to directly edit the field text
13511 setEditable : function(value){
13512 if(value == this.editable){
13515 this.editable = value;
13517 this.inputEl().dom.setAttribute('readOnly', true);
13518 this.inputEl().on('mousedown', this.onTriggerClick, this);
13519 this.inputEl().addClass('x-combo-noedit');
13521 this.inputEl().dom.setAttribute('readOnly', false);
13522 this.inputEl().un('mousedown', this.onTriggerClick, this);
13523 this.inputEl().removeClass('x-combo-noedit');
13529 onBeforeLoad : function(combo,opts){
13530 if(!this.hasFocus){
13534 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13536 this.restrictHeight();
13537 this.selectedIndex = -1;
13541 onLoad : function(){
13543 this.hasQuery = false;
13545 if(!this.hasFocus){
13549 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13550 this.loading.hide();
13553 if(this.store.getCount() > 0){
13556 this.restrictHeight();
13557 if(this.lastQuery == this.allQuery){
13558 if(this.editable && !this.tickable){
13559 this.inputEl().dom.select();
13563 !this.selectByValue(this.value, true) &&
13566 !this.store.lastOptions ||
13567 typeof(this.store.lastOptions.add) == 'undefined' ||
13568 this.store.lastOptions.add != true
13571 this.select(0, true);
13574 if(this.autoFocus){
13577 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13578 this.taTask.delay(this.typeAheadDelay);
13582 this.onEmptyResults();
13588 onLoadException : function()
13590 this.hasQuery = false;
13592 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13593 this.loading.hide();
13596 if(this.tickable && this.editable){
13601 // only causes errors at present
13602 //Roo.log(this.store.reader.jsonData);
13603 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13605 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13611 onTypeAhead : function(){
13612 if(this.store.getCount() > 0){
13613 var r = this.store.getAt(0);
13614 var newValue = r.data[this.displayField];
13615 var len = newValue.length;
13616 var selStart = this.getRawValue().length;
13618 if(selStart != len){
13619 this.setRawValue(newValue);
13620 this.selectText(selStart, newValue.length);
13626 onSelect : function(record, index){
13628 if(this.fireEvent('beforeselect', this, record, index) !== false){
13630 this.setFromData(index > -1 ? record.data : false);
13633 this.fireEvent('select', this, record, index);
13638 * Returns the currently selected field value or empty string if no value is set.
13639 * @return {String} value The selected value
13641 getValue : function()
13643 if(Roo.isIOS && this.useNativeIOS){
13644 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13648 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13651 if(this.valueField){
13652 return typeof this.value != 'undefined' ? this.value : '';
13654 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13658 getRawValue : function()
13660 if(Roo.isIOS && this.useNativeIOS){
13661 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13664 var v = this.inputEl().getValue();
13670 * Clears any text/value currently set in the field
13672 clearValue : function(){
13674 if(this.hiddenField){
13675 this.hiddenField.dom.value = '';
13678 this.setRawValue('');
13679 this.lastSelectionText = '';
13680 this.lastData = false;
13682 var close = this.closeTriggerEl();
13693 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13694 * will be displayed in the field. If the value does not match the data value of an existing item,
13695 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13696 * Otherwise the field will be blank (although the value will still be set).
13697 * @param {String} value The value to match
13699 setValue : function(v)
13701 if(Roo.isIOS && this.useNativeIOS){
13702 this.setIOSValue(v);
13712 if(this.valueField){
13713 var r = this.findRecord(this.valueField, v);
13715 text = r.data[this.displayField];
13716 }else if(this.valueNotFoundText !== undefined){
13717 text = this.valueNotFoundText;
13720 this.lastSelectionText = text;
13721 if(this.hiddenField){
13722 this.hiddenField.dom.value = v;
13724 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13727 var close = this.closeTriggerEl();
13730 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13736 * @property {Object} the last set data for the element
13741 * Sets the value of the field based on a object which is related to the record format for the store.
13742 * @param {Object} value the value to set as. or false on reset?
13744 setFromData : function(o){
13751 var dv = ''; // display value
13752 var vv = ''; // value value..
13754 if (this.displayField) {
13755 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13757 // this is an error condition!!!
13758 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13761 if(this.valueField){
13762 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13765 var close = this.closeTriggerEl();
13768 if(dv.length || vv * 1 > 0){
13770 this.blockFocus=true;
13776 if(this.hiddenField){
13777 this.hiddenField.dom.value = vv;
13779 this.lastSelectionText = dv;
13780 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13784 // no hidden field.. - we store the value in 'value', but still display
13785 // display field!!!!
13786 this.lastSelectionText = dv;
13787 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13794 reset : function(){
13795 // overridden so that last data is reset..
13802 this.setValue(this.originalValue);
13803 //this.clearInvalid();
13804 this.lastData = false;
13806 this.view.clearSelections();
13812 findRecord : function(prop, value){
13814 if(this.store.getCount() > 0){
13815 this.store.each(function(r){
13816 if(r.data[prop] == value){
13826 getName: function()
13828 // returns hidden if it's set..
13829 if (!this.rendered) {return ''};
13830 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13834 onViewMove : function(e, t){
13835 this.inKeyMode = false;
13839 onViewOver : function(e, t){
13840 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13843 var item = this.view.findItemFromChild(t);
13846 var index = this.view.indexOf(item);
13847 this.select(index, false);
13852 onViewClick : function(view, doFocus, el, e)
13854 var index = this.view.getSelectedIndexes()[0];
13856 var r = this.store.getAt(index);
13860 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13867 Roo.each(this.tickItems, function(v,k){
13869 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13871 _this.tickItems.splice(k, 1);
13873 if(typeof(e) == 'undefined' && view == false){
13874 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13886 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13887 this.tickItems.push(r.data);
13890 if(typeof(e) == 'undefined' && view == false){
13891 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13898 this.onSelect(r, index);
13900 if(doFocus !== false && !this.blockFocus){
13901 this.inputEl().focus();
13906 restrictHeight : function(){
13907 //this.innerList.dom.style.height = '';
13908 //var inner = this.innerList.dom;
13909 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13910 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13911 //this.list.beginUpdate();
13912 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13913 this.list.alignTo(this.inputEl(), this.listAlign);
13914 this.list.alignTo(this.inputEl(), this.listAlign);
13915 //this.list.endUpdate();
13919 onEmptyResults : function(){
13921 if(this.tickable && this.editable){
13922 this.restrictHeight();
13930 * Returns true if the dropdown list is expanded, else false.
13932 isExpanded : function(){
13933 return this.list.isVisible();
13937 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
13938 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13939 * @param {String} value The data value of the item to select
13940 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13941 * selected item if it is not currently in view (defaults to true)
13942 * @return {Boolean} True if the value matched an item in the list, else false
13944 selectByValue : function(v, scrollIntoView){
13945 if(v !== undefined && v !== null){
13946 var r = this.findRecord(this.valueField || this.displayField, v);
13948 this.select(this.store.indexOf(r), scrollIntoView);
13956 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
13957 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13958 * @param {Number} index The zero-based index of the list item to select
13959 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13960 * selected item if it is not currently in view (defaults to true)
13962 select : function(index, scrollIntoView){
13963 this.selectedIndex = index;
13964 this.view.select(index);
13965 if(scrollIntoView !== false){
13966 var el = this.view.getNode(index);
13968 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
13971 this.list.scrollChildIntoView(el, false);
13977 selectNext : function(){
13978 var ct = this.store.getCount();
13980 if(this.selectedIndex == -1){
13982 }else if(this.selectedIndex < ct-1){
13983 this.select(this.selectedIndex+1);
13989 selectPrev : function(){
13990 var ct = this.store.getCount();
13992 if(this.selectedIndex == -1){
13994 }else if(this.selectedIndex != 0){
13995 this.select(this.selectedIndex-1);
14001 onKeyUp : function(e){
14002 if(this.editable !== false && !e.isSpecialKey()){
14003 this.lastKey = e.getKey();
14004 this.dqTask.delay(this.queryDelay);
14009 validateBlur : function(){
14010 return !this.list || !this.list.isVisible();
14014 initQuery : function(){
14016 var v = this.getRawValue();
14018 if(this.tickable && this.editable){
14019 v = this.tickableInputEl().getValue();
14026 doForce : function(){
14027 if(this.inputEl().dom.value.length > 0){
14028 this.inputEl().dom.value =
14029 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14035 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14036 * query allowing the query action to be canceled if needed.
14037 * @param {String} query The SQL query to execute
14038 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14039 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14040 * saved in the current store (defaults to false)
14042 doQuery : function(q, forceAll){
14044 if(q === undefined || q === null){
14049 forceAll: forceAll,
14053 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14061 forceAll = qe.forceAll;
14062 if(forceAll === true || (q.length >= this.minChars)){
14064 this.hasQuery = true;
14066 if(this.lastQuery != q || this.alwaysQuery){
14067 this.lastQuery = q;
14068 if(this.mode == 'local'){
14069 this.selectedIndex = -1;
14071 this.store.clearFilter();
14074 if(this.specialFilter){
14075 this.fireEvent('specialfilter', this);
14080 this.store.filter(this.displayField, q);
14083 this.store.fireEvent("datachanged", this.store);
14087 Roo.log('onload???');
14091 this.store.baseParams[this.queryParam] = q;
14093 var options = {params : this.getParams(q)};
14096 options.add = true;
14097 options.params.start = this.page * this.pageSize;
14100 this.store.load(options);
14103 * this code will make the page width larger, at the beginning, the list not align correctly,
14104 * we should expand the list on onLoad
14105 * so command out it
14111 this.selectedIndex = -1;
14116 this.loadNext = false;
14120 getParams : function(q){
14122 //p[this.queryParam] = q;
14126 p.limit = this.pageSize;
14132 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14134 collapse : function(){
14135 if(!this.isExpanded()){
14141 this.hasFocus = false;
14145 this.cancelBtn.hide();
14146 this.trigger.show();
14149 this.tickableInputEl().dom.value = '';
14150 this.tickableInputEl().blur();
14155 Roo.get(document).un('mousedown', this.collapseIf, this);
14156 Roo.get(document).un('mousewheel', this.collapseIf, this);
14157 if (!this.editable) {
14158 Roo.get(document).un('keydown', this.listKeyPress, this);
14160 this.fireEvent('collapse', this);
14166 collapseIf : function(e){
14167 var in_combo = e.within(this.el);
14168 var in_list = e.within(this.list);
14169 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14171 if (in_combo || in_list || is_list) {
14172 //e.stopPropagation();
14177 this.onTickableFooterButtonClick(e, false, false);
14185 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14187 expand : function(){
14189 if(this.isExpanded() || !this.hasFocus){
14193 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14194 this.list.setWidth(lw);
14200 this.restrictHeight();
14204 this.tickItems = Roo.apply([], this.item);
14207 this.cancelBtn.show();
14208 this.trigger.hide();
14211 this.tickableInputEl().focus();
14216 Roo.get(document).on('mousedown', this.collapseIf, this);
14217 Roo.get(document).on('mousewheel', this.collapseIf, this);
14218 if (!this.editable) {
14219 Roo.get(document).on('keydown', this.listKeyPress, this);
14222 this.fireEvent('expand', this);
14226 // Implements the default empty TriggerField.onTriggerClick function
14227 onTriggerClick : function(e)
14229 Roo.log('trigger click');
14231 if(this.disabled || !this.triggerList){
14236 this.loadNext = false;
14238 if(this.isExpanded()){
14240 if (!this.blockFocus) {
14241 this.inputEl().focus();
14245 this.hasFocus = true;
14246 if(this.triggerAction == 'all') {
14247 this.doQuery(this.allQuery, true);
14249 this.doQuery(this.getRawValue());
14251 if (!this.blockFocus) {
14252 this.inputEl().focus();
14257 onTickableTriggerClick : function(e)
14264 this.loadNext = false;
14265 this.hasFocus = true;
14267 if(this.triggerAction == 'all') {
14268 this.doQuery(this.allQuery, true);
14270 this.doQuery(this.getRawValue());
14274 onSearchFieldClick : function(e)
14276 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14277 this.onTickableFooterButtonClick(e, false, false);
14281 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14286 this.loadNext = false;
14287 this.hasFocus = true;
14289 if(this.triggerAction == 'all') {
14290 this.doQuery(this.allQuery, true);
14292 this.doQuery(this.getRawValue());
14296 listKeyPress : function(e)
14298 //Roo.log('listkeypress');
14299 // scroll to first matching element based on key pres..
14300 if (e.isSpecialKey()) {
14303 var k = String.fromCharCode(e.getKey()).toUpperCase();
14306 var csel = this.view.getSelectedNodes();
14307 var cselitem = false;
14309 var ix = this.view.indexOf(csel[0]);
14310 cselitem = this.store.getAt(ix);
14311 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14317 this.store.each(function(v) {
14319 // start at existing selection.
14320 if (cselitem.id == v.id) {
14326 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14327 match = this.store.indexOf(v);
14333 if (match === false) {
14334 return true; // no more action?
14337 this.view.select(match);
14338 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14339 sn.scrollIntoView(sn.dom.parentNode, false);
14342 onViewScroll : function(e, t){
14344 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){
14348 this.hasQuery = true;
14350 this.loading = this.list.select('.loading', true).first();
14352 if(this.loading === null){
14353 this.list.createChild({
14355 cls: 'loading roo-select2-more-results roo-select2-active',
14356 html: 'Loading more results...'
14359 this.loading = this.list.select('.loading', true).first();
14361 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14363 this.loading.hide();
14366 this.loading.show();
14371 this.loadNext = true;
14373 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14378 addItem : function(o)
14380 var dv = ''; // display value
14382 if (this.displayField) {
14383 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14385 // this is an error condition!!!
14386 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14393 var choice = this.choices.createChild({
14395 cls: 'roo-select2-search-choice',
14404 cls: 'roo-select2-search-choice-close fa fa-times',
14409 }, this.searchField);
14411 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14413 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14421 this.inputEl().dom.value = '';
14426 onRemoveItem : function(e, _self, o)
14428 e.preventDefault();
14430 this.lastItem = Roo.apply([], this.item);
14432 var index = this.item.indexOf(o.data) * 1;
14435 Roo.log('not this item?!');
14439 this.item.splice(index, 1);
14444 this.fireEvent('remove', this, e);
14450 syncValue : function()
14452 if(!this.item.length){
14459 Roo.each(this.item, function(i){
14460 if(_this.valueField){
14461 value.push(i[_this.valueField]);
14468 this.value = value.join(',');
14470 if(this.hiddenField){
14471 this.hiddenField.dom.value = this.value;
14474 this.store.fireEvent("datachanged", this.store);
14479 clearItem : function()
14481 if(!this.multiple){
14487 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14495 if(this.tickable && !Roo.isTouch){
14496 this.view.refresh();
14500 inputEl: function ()
14502 if(Roo.isIOS && this.useNativeIOS){
14503 return this.el.select('select.roo-ios-select', true).first();
14506 if(Roo.isTouch && this.mobileTouchView){
14507 return this.el.select('input.form-control',true).first();
14511 return this.searchField;
14514 return this.el.select('input.form-control',true).first();
14517 onTickableFooterButtonClick : function(e, btn, el)
14519 e.preventDefault();
14521 this.lastItem = Roo.apply([], this.item);
14523 if(btn && btn.name == 'cancel'){
14524 this.tickItems = Roo.apply([], this.item);
14533 Roo.each(this.tickItems, function(o){
14541 validate : function()
14543 var v = this.getRawValue();
14546 v = this.getValue();
14549 if(this.disabled || this.allowBlank || v.length){
14554 this.markInvalid();
14558 tickableInputEl : function()
14560 if(!this.tickable || !this.editable){
14561 return this.inputEl();
14564 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14568 getAutoCreateTouchView : function()
14573 cls: 'form-group' //input-group
14579 type : this.inputType,
14580 cls : 'form-control x-combo-noedit',
14581 autocomplete: 'new-password',
14582 placeholder : this.placeholder || '',
14587 input.name = this.name;
14591 input.cls += ' input-' + this.size;
14594 if (this.disabled) {
14595 input.disabled = true;
14606 inputblock.cls += ' input-group';
14608 inputblock.cn.unshift({
14610 cls : 'input-group-addon',
14615 if(this.removable && !this.multiple){
14616 inputblock.cls += ' roo-removable';
14618 inputblock.cn.push({
14621 cls : 'roo-combo-removable-btn close'
14625 if(this.hasFeedback && !this.allowBlank){
14627 inputblock.cls += ' has-feedback';
14629 inputblock.cn.push({
14631 cls: 'glyphicon form-control-feedback'
14638 inputblock.cls += (this.before) ? '' : ' input-group';
14640 inputblock.cn.push({
14642 cls : 'input-group-addon',
14653 cls: 'form-hidden-field'
14667 cls: 'form-hidden-field'
14671 cls: 'roo-select2-choices',
14675 cls: 'roo-select2-search-field',
14688 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14694 if(!this.multiple && this.showToggleBtn){
14701 if (this.caret != false) {
14704 cls: 'fa fa-' + this.caret
14711 cls : 'input-group-addon btn dropdown-toggle',
14716 cls: 'combobox-clear',
14730 combobox.cls += ' roo-select2-container-multi';
14733 var align = this.labelAlign || this.parentLabelAlign();
14735 if (align ==='left' && this.fieldLabel.length) {
14740 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14741 tooltip : 'This field is required'
14745 cls : 'control-label',
14746 html : this.fieldLabel
14757 var labelCfg = cfg.cn[1];
14758 var contentCfg = cfg.cn[2];
14761 if(this.indicatorpos == 'right'){
14766 cls : 'control-label',
14770 html : this.fieldLabel
14774 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14775 tooltip : 'This field is required'
14788 labelCfg = cfg.cn[0];
14789 contentCfg = cfg.cn[1];
14794 if(this.labelWidth > 12){
14795 labelCfg.style = "width: " + this.labelWidth + 'px';
14798 if(this.labelWidth < 13 && this.labelmd == 0){
14799 this.labelmd = this.labelWidth;
14802 if(this.labellg > 0){
14803 labelCfg.cls += ' col-lg-' + this.labellg;
14804 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14807 if(this.labelmd > 0){
14808 labelCfg.cls += ' col-md-' + this.labelmd;
14809 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14812 if(this.labelsm > 0){
14813 labelCfg.cls += ' col-sm-' + this.labelsm;
14814 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14817 if(this.labelxs > 0){
14818 labelCfg.cls += ' col-xs-' + this.labelxs;
14819 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14823 } else if ( this.fieldLabel.length) {
14827 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14828 tooltip : 'This field is required'
14832 cls : 'control-label',
14833 html : this.fieldLabel
14844 if(this.indicatorpos == 'right'){
14848 cls : 'control-label',
14849 html : this.fieldLabel,
14853 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14854 tooltip : 'This field is required'
14871 var settings = this;
14873 ['xs','sm','md','lg'].map(function(size){
14874 if (settings[size]) {
14875 cfg.cls += ' col-' + size + '-' + settings[size];
14882 initTouchView : function()
14884 this.renderTouchView();
14886 this.touchViewEl.on('scroll', function(){
14887 this.el.dom.scrollTop = 0;
14890 this.originalValue = this.getValue();
14892 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14894 this.inputEl().on("click", this.showTouchView, this);
14895 if (this.triggerEl) {
14896 this.triggerEl.on("click", this.showTouchView, this);
14900 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14901 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14903 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14905 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14906 this.store.on('load', this.onTouchViewLoad, this);
14907 this.store.on('loadexception', this.onTouchViewLoadException, this);
14909 if(this.hiddenName){
14911 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14913 this.hiddenField.dom.value =
14914 this.hiddenValue !== undefined ? this.hiddenValue :
14915 this.value !== undefined ? this.value : '';
14917 this.el.dom.removeAttribute('name');
14918 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14922 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14923 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14926 if(this.removable && !this.multiple){
14927 var close = this.closeTriggerEl();
14929 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14930 close.on('click', this.removeBtnClick, this, close);
14934 * fix the bug in Safari iOS8
14936 this.inputEl().on("focus", function(e){
14937 document.activeElement.blur();
14945 renderTouchView : function()
14947 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
14948 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14950 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
14951 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14953 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
14954 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14955 this.touchViewBodyEl.setStyle('overflow', 'auto');
14957 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
14958 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14960 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
14961 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14965 showTouchView : function()
14971 this.touchViewHeaderEl.hide();
14973 if(this.modalTitle.length){
14974 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
14975 this.touchViewHeaderEl.show();
14978 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
14979 this.touchViewEl.show();
14981 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
14983 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
14984 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
14986 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
14988 if(this.modalTitle.length){
14989 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
14992 this.touchViewBodyEl.setHeight(bodyHeight);
14996 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
14998 this.touchViewEl.addClass('in');
15001 this.doTouchViewQuery();
15005 hideTouchView : function()
15007 this.touchViewEl.removeClass('in');
15011 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15013 this.touchViewEl.setStyle('display', 'none');
15018 setTouchViewValue : function()
15025 Roo.each(this.tickItems, function(o){
15030 this.hideTouchView();
15033 doTouchViewQuery : function()
15042 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15046 if(!this.alwaysQuery || this.mode == 'local'){
15047 this.onTouchViewLoad();
15054 onTouchViewBeforeLoad : function(combo,opts)
15060 onTouchViewLoad : function()
15062 if(this.store.getCount() < 1){
15063 this.onTouchViewEmptyResults();
15067 this.clearTouchView();
15069 var rawValue = this.getRawValue();
15071 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15073 this.tickItems = [];
15075 this.store.data.each(function(d, rowIndex){
15076 var row = this.touchViewListGroup.createChild(template);
15078 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15079 row.addClass(d.data.cls);
15082 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15085 html : d.data[this.displayField]
15088 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15089 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15092 row.removeClass('selected');
15093 if(!this.multiple && this.valueField &&
15094 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15097 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15098 row.addClass('selected');
15101 if(this.multiple && this.valueField &&
15102 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15106 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15107 this.tickItems.push(d.data);
15110 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15114 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15116 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15118 if(this.modalTitle.length){
15119 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15122 var listHeight = this.touchViewListGroup.getHeight();
15126 if(firstChecked && listHeight > bodyHeight){
15127 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15132 onTouchViewLoadException : function()
15134 this.hideTouchView();
15137 onTouchViewEmptyResults : function()
15139 this.clearTouchView();
15141 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15143 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15147 clearTouchView : function()
15149 this.touchViewListGroup.dom.innerHTML = '';
15152 onTouchViewClick : function(e, el, o)
15154 e.preventDefault();
15157 var rowIndex = o.rowIndex;
15159 var r = this.store.getAt(rowIndex);
15161 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15163 if(!this.multiple){
15164 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15165 c.dom.removeAttribute('checked');
15168 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15170 this.setFromData(r.data);
15172 var close = this.closeTriggerEl();
15178 this.hideTouchView();
15180 this.fireEvent('select', this, r, rowIndex);
15185 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15186 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15187 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15191 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15192 this.addItem(r.data);
15193 this.tickItems.push(r.data);
15197 getAutoCreateNativeIOS : function()
15200 cls: 'form-group' //input-group,
15205 cls : 'roo-ios-select'
15209 combobox.name = this.name;
15212 if (this.disabled) {
15213 combobox.disabled = true;
15216 var settings = this;
15218 ['xs','sm','md','lg'].map(function(size){
15219 if (settings[size]) {
15220 cfg.cls += ' col-' + size + '-' + settings[size];
15230 initIOSView : function()
15232 this.store.on('load', this.onIOSViewLoad, this);
15237 onIOSViewLoad : function()
15239 if(this.store.getCount() < 1){
15243 this.clearIOSView();
15245 if(this.allowBlank) {
15247 var default_text = '-- SELECT --';
15249 if(this.placeholder.length){
15250 default_text = this.placeholder;
15253 if(this.emptyTitle.length){
15254 default_text += ' - ' + this.emptyTitle + ' -';
15257 var opt = this.inputEl().createChild({
15260 html : default_text
15264 o[this.valueField] = 0;
15265 o[this.displayField] = default_text;
15267 this.ios_options.push({
15274 this.store.data.each(function(d, rowIndex){
15278 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15279 html = d.data[this.displayField];
15284 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15285 value = d.data[this.valueField];
15294 if(this.value == d.data[this.valueField]){
15295 option['selected'] = true;
15298 var opt = this.inputEl().createChild(option);
15300 this.ios_options.push({
15307 this.inputEl().on('change', function(){
15308 this.fireEvent('select', this);
15313 clearIOSView: function()
15315 this.inputEl().dom.innerHTML = '';
15317 this.ios_options = [];
15320 setIOSValue: function(v)
15324 if(!this.ios_options){
15328 Roo.each(this.ios_options, function(opts){
15330 opts.el.dom.removeAttribute('selected');
15332 if(opts.data[this.valueField] != v){
15336 opts.el.dom.setAttribute('selected', true);
15342 * @cfg {Boolean} grow
15346 * @cfg {Number} growMin
15350 * @cfg {Number} growMax
15359 Roo.apply(Roo.bootstrap.ComboBox, {
15363 cls: 'modal-header',
15385 cls: 'list-group-item',
15389 cls: 'roo-combobox-list-group-item-value'
15393 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15407 listItemCheckbox : {
15409 cls: 'list-group-item',
15413 cls: 'roo-combobox-list-group-item-value'
15417 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15433 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15438 cls: 'modal-footer',
15446 cls: 'col-xs-6 text-left',
15449 cls: 'btn btn-danger roo-touch-view-cancel',
15455 cls: 'col-xs-6 text-right',
15458 cls: 'btn btn-success roo-touch-view-ok',
15469 Roo.apply(Roo.bootstrap.ComboBox, {
15471 touchViewTemplate : {
15473 cls: 'modal fade roo-combobox-touch-view',
15477 cls: 'modal-dialog',
15478 style : 'position:fixed', // we have to fix position....
15482 cls: 'modal-content',
15484 Roo.bootstrap.ComboBox.header,
15485 Roo.bootstrap.ComboBox.body,
15486 Roo.bootstrap.ComboBox.footer
15495 * Ext JS Library 1.1.1
15496 * Copyright(c) 2006-2007, Ext JS, LLC.
15498 * Originally Released Under LGPL - original licence link has changed is not relivant.
15501 * <script type="text/javascript">
15506 * @extends Roo.util.Observable
15507 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15508 * This class also supports single and multi selection modes. <br>
15509 * Create a data model bound view:
15511 var store = new Roo.data.Store(...);
15513 var view = new Roo.View({
15515 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15517 singleSelect: true,
15518 selectedClass: "ydataview-selected",
15522 // listen for node click?
15523 view.on("click", function(vw, index, node, e){
15524 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15528 dataModel.load("foobar.xml");
15530 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15532 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15533 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15535 * Note: old style constructor is still suported (container, template, config)
15538 * Create a new View
15539 * @param {Object} config The config object
15542 Roo.View = function(config, depreciated_tpl, depreciated_config){
15544 this.parent = false;
15546 if (typeof(depreciated_tpl) == 'undefined') {
15547 // new way.. - universal constructor.
15548 Roo.apply(this, config);
15549 this.el = Roo.get(this.el);
15552 this.el = Roo.get(config);
15553 this.tpl = depreciated_tpl;
15554 Roo.apply(this, depreciated_config);
15556 this.wrapEl = this.el.wrap().wrap();
15557 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15560 if(typeof(this.tpl) == "string"){
15561 this.tpl = new Roo.Template(this.tpl);
15563 // support xtype ctors..
15564 this.tpl = new Roo.factory(this.tpl, Roo);
15568 this.tpl.compile();
15573 * @event beforeclick
15574 * Fires before a click is processed. Returns false to cancel the default action.
15575 * @param {Roo.View} this
15576 * @param {Number} index The index of the target node
15577 * @param {HTMLElement} node The target node
15578 * @param {Roo.EventObject} e The raw event object
15580 "beforeclick" : true,
15583 * Fires when a template node is clicked.
15584 * @param {Roo.View} this
15585 * @param {Number} index The index of the target node
15586 * @param {HTMLElement} node The target node
15587 * @param {Roo.EventObject} e The raw event object
15592 * Fires when a template node is double clicked.
15593 * @param {Roo.View} this
15594 * @param {Number} index The index of the target node
15595 * @param {HTMLElement} node The target node
15596 * @param {Roo.EventObject} e The raw event object
15600 * @event contextmenu
15601 * Fires when a template node is right clicked.
15602 * @param {Roo.View} this
15603 * @param {Number} index The index of the target node
15604 * @param {HTMLElement} node The target node
15605 * @param {Roo.EventObject} e The raw event object
15607 "contextmenu" : true,
15609 * @event selectionchange
15610 * Fires when the selected nodes change.
15611 * @param {Roo.View} this
15612 * @param {Array} selections Array of the selected nodes
15614 "selectionchange" : true,
15617 * @event beforeselect
15618 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15619 * @param {Roo.View} this
15620 * @param {HTMLElement} node The node to be selected
15621 * @param {Array} selections Array of currently selected nodes
15623 "beforeselect" : true,
15625 * @event preparedata
15626 * Fires on every row to render, to allow you to change the data.
15627 * @param {Roo.View} this
15628 * @param {Object} data to be rendered (change this)
15630 "preparedata" : true
15638 "click": this.onClick,
15639 "dblclick": this.onDblClick,
15640 "contextmenu": this.onContextMenu,
15644 this.selections = [];
15646 this.cmp = new Roo.CompositeElementLite([]);
15648 this.store = Roo.factory(this.store, Roo.data);
15649 this.setStore(this.store, true);
15652 if ( this.footer && this.footer.xtype) {
15654 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15656 this.footer.dataSource = this.store;
15657 this.footer.container = fctr;
15658 this.footer = Roo.factory(this.footer, Roo);
15659 fctr.insertFirst(this.el);
15661 // this is a bit insane - as the paging toolbar seems to detach the el..
15662 // dom.parentNode.parentNode.parentNode
15663 // they get detached?
15667 Roo.View.superclass.constructor.call(this);
15672 Roo.extend(Roo.View, Roo.util.Observable, {
15675 * @cfg {Roo.data.Store} store Data store to load data from.
15680 * @cfg {String|Roo.Element} el The container element.
15685 * @cfg {String|Roo.Template} tpl The template used by this View
15689 * @cfg {String} dataName the named area of the template to use as the data area
15690 * Works with domtemplates roo-name="name"
15694 * @cfg {String} selectedClass The css class to add to selected nodes
15696 selectedClass : "x-view-selected",
15698 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15703 * @cfg {String} text to display on mask (default Loading)
15707 * @cfg {Boolean} multiSelect Allow multiple selection
15709 multiSelect : false,
15711 * @cfg {Boolean} singleSelect Allow single selection
15713 singleSelect: false,
15716 * @cfg {Boolean} toggleSelect - selecting
15718 toggleSelect : false,
15721 * @cfg {Boolean} tickable - selecting
15726 * Returns the element this view is bound to.
15727 * @return {Roo.Element}
15729 getEl : function(){
15730 return this.wrapEl;
15736 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15738 refresh : function(){
15739 //Roo.log('refresh');
15742 // if we are using something like 'domtemplate', then
15743 // the what gets used is:
15744 // t.applySubtemplate(NAME, data, wrapping data..)
15745 // the outer template then get' applied with
15746 // the store 'extra data'
15747 // and the body get's added to the
15748 // roo-name="data" node?
15749 // <span class='roo-tpl-{name}'></span> ?????
15753 this.clearSelections();
15754 this.el.update("");
15756 var records = this.store.getRange();
15757 if(records.length < 1) {
15759 // is this valid?? = should it render a template??
15761 this.el.update(this.emptyText);
15765 if (this.dataName) {
15766 this.el.update(t.apply(this.store.meta)); //????
15767 el = this.el.child('.roo-tpl-' + this.dataName);
15770 for(var i = 0, len = records.length; i < len; i++){
15771 var data = this.prepareData(records[i].data, i, records[i]);
15772 this.fireEvent("preparedata", this, data, i, records[i]);
15774 var d = Roo.apply({}, data);
15777 Roo.apply(d, {'roo-id' : Roo.id()});
15781 Roo.each(this.parent.item, function(item){
15782 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15785 Roo.apply(d, {'roo-data-checked' : 'checked'});
15789 html[html.length] = Roo.util.Format.trim(
15791 t.applySubtemplate(this.dataName, d, this.store.meta) :
15798 el.update(html.join(""));
15799 this.nodes = el.dom.childNodes;
15800 this.updateIndexes(0);
15805 * Function to override to reformat the data that is sent to
15806 * the template for each node.
15807 * DEPRICATED - use the preparedata event handler.
15808 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15809 * a JSON object for an UpdateManager bound view).
15811 prepareData : function(data, index, record)
15813 this.fireEvent("preparedata", this, data, index, record);
15817 onUpdate : function(ds, record){
15818 // Roo.log('on update');
15819 this.clearSelections();
15820 var index = this.store.indexOf(record);
15821 var n = this.nodes[index];
15822 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15823 n.parentNode.removeChild(n);
15824 this.updateIndexes(index, index);
15830 onAdd : function(ds, records, index)
15832 //Roo.log(['on Add', ds, records, index] );
15833 this.clearSelections();
15834 if(this.nodes.length == 0){
15838 var n = this.nodes[index];
15839 for(var i = 0, len = records.length; i < len; i++){
15840 var d = this.prepareData(records[i].data, i, records[i]);
15842 this.tpl.insertBefore(n, d);
15845 this.tpl.append(this.el, d);
15848 this.updateIndexes(index);
15851 onRemove : function(ds, record, index){
15852 // Roo.log('onRemove');
15853 this.clearSelections();
15854 var el = this.dataName ?
15855 this.el.child('.roo-tpl-' + this.dataName) :
15858 el.dom.removeChild(this.nodes[index]);
15859 this.updateIndexes(index);
15863 * Refresh an individual node.
15864 * @param {Number} index
15866 refreshNode : function(index){
15867 this.onUpdate(this.store, this.store.getAt(index));
15870 updateIndexes : function(startIndex, endIndex){
15871 var ns = this.nodes;
15872 startIndex = startIndex || 0;
15873 endIndex = endIndex || ns.length - 1;
15874 for(var i = startIndex; i <= endIndex; i++){
15875 ns[i].nodeIndex = i;
15880 * Changes the data store this view uses and refresh the view.
15881 * @param {Store} store
15883 setStore : function(store, initial){
15884 if(!initial && this.store){
15885 this.store.un("datachanged", this.refresh);
15886 this.store.un("add", this.onAdd);
15887 this.store.un("remove", this.onRemove);
15888 this.store.un("update", this.onUpdate);
15889 this.store.un("clear", this.refresh);
15890 this.store.un("beforeload", this.onBeforeLoad);
15891 this.store.un("load", this.onLoad);
15892 this.store.un("loadexception", this.onLoad);
15896 store.on("datachanged", this.refresh, this);
15897 store.on("add", this.onAdd, this);
15898 store.on("remove", this.onRemove, this);
15899 store.on("update", this.onUpdate, this);
15900 store.on("clear", this.refresh, this);
15901 store.on("beforeload", this.onBeforeLoad, this);
15902 store.on("load", this.onLoad, this);
15903 store.on("loadexception", this.onLoad, this);
15911 * onbeforeLoad - masks the loading area.
15914 onBeforeLoad : function(store,opts)
15916 //Roo.log('onBeforeLoad');
15918 this.el.update("");
15920 this.el.mask(this.mask ? this.mask : "Loading" );
15922 onLoad : function ()
15929 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15930 * @param {HTMLElement} node
15931 * @return {HTMLElement} The template node
15933 findItemFromChild : function(node){
15934 var el = this.dataName ?
15935 this.el.child('.roo-tpl-' + this.dataName,true) :
15938 if(!node || node.parentNode == el){
15941 var p = node.parentNode;
15942 while(p && p != el){
15943 if(p.parentNode == el){
15952 onClick : function(e){
15953 var item = this.findItemFromChild(e.getTarget());
15955 var index = this.indexOf(item);
15956 if(this.onItemClick(item, index, e) !== false){
15957 this.fireEvent("click", this, index, item, e);
15960 this.clearSelections();
15965 onContextMenu : function(e){
15966 var item = this.findItemFromChild(e.getTarget());
15968 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
15973 onDblClick : function(e){
15974 var item = this.findItemFromChild(e.getTarget());
15976 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
15980 onItemClick : function(item, index, e)
15982 if(this.fireEvent("beforeclick", this, index, item, e) === false){
15985 if (this.toggleSelect) {
15986 var m = this.isSelected(item) ? 'unselect' : 'select';
15989 _t[m](item, true, false);
15992 if(this.multiSelect || this.singleSelect){
15993 if(this.multiSelect && e.shiftKey && this.lastSelection){
15994 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
15996 this.select(item, this.multiSelect && e.ctrlKey);
15997 this.lastSelection = item;
16000 if(!this.tickable){
16001 e.preventDefault();
16009 * Get the number of selected nodes.
16012 getSelectionCount : function(){
16013 return this.selections.length;
16017 * Get the currently selected nodes.
16018 * @return {Array} An array of HTMLElements
16020 getSelectedNodes : function(){
16021 return this.selections;
16025 * Get the indexes of the selected nodes.
16028 getSelectedIndexes : function(){
16029 var indexes = [], s = this.selections;
16030 for(var i = 0, len = s.length; i < len; i++){
16031 indexes.push(s[i].nodeIndex);
16037 * Clear all selections
16038 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16040 clearSelections : function(suppressEvent){
16041 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16042 this.cmp.elements = this.selections;
16043 this.cmp.removeClass(this.selectedClass);
16044 this.selections = [];
16045 if(!suppressEvent){
16046 this.fireEvent("selectionchange", this, this.selections);
16052 * Returns true if the passed node is selected
16053 * @param {HTMLElement/Number} node The node or node index
16054 * @return {Boolean}
16056 isSelected : function(node){
16057 var s = this.selections;
16061 node = this.getNode(node);
16062 return s.indexOf(node) !== -1;
16067 * @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
16068 * @param {Boolean} keepExisting (optional) true to keep existing selections
16069 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16071 select : function(nodeInfo, keepExisting, suppressEvent){
16072 if(nodeInfo instanceof Array){
16074 this.clearSelections(true);
16076 for(var i = 0, len = nodeInfo.length; i < len; i++){
16077 this.select(nodeInfo[i], true, true);
16081 var node = this.getNode(nodeInfo);
16082 if(!node || this.isSelected(node)){
16083 return; // already selected.
16086 this.clearSelections(true);
16089 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16090 Roo.fly(node).addClass(this.selectedClass);
16091 this.selections.push(node);
16092 if(!suppressEvent){
16093 this.fireEvent("selectionchange", this, this.selections);
16101 * @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
16102 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16103 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16105 unselect : function(nodeInfo, keepExisting, suppressEvent)
16107 if(nodeInfo instanceof Array){
16108 Roo.each(this.selections, function(s) {
16109 this.unselect(s, nodeInfo);
16113 var node = this.getNode(nodeInfo);
16114 if(!node || !this.isSelected(node)){
16115 //Roo.log("not selected");
16116 return; // not selected.
16120 Roo.each(this.selections, function(s) {
16122 Roo.fly(node).removeClass(this.selectedClass);
16129 this.selections= ns;
16130 this.fireEvent("selectionchange", this, this.selections);
16134 * Gets a template node.
16135 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16136 * @return {HTMLElement} The node or null if it wasn't found
16138 getNode : function(nodeInfo){
16139 if(typeof nodeInfo == "string"){
16140 return document.getElementById(nodeInfo);
16141 }else if(typeof nodeInfo == "number"){
16142 return this.nodes[nodeInfo];
16148 * Gets a range template nodes.
16149 * @param {Number} startIndex
16150 * @param {Number} endIndex
16151 * @return {Array} An array of nodes
16153 getNodes : function(start, end){
16154 var ns = this.nodes;
16155 start = start || 0;
16156 end = typeof end == "undefined" ? ns.length - 1 : end;
16159 for(var i = start; i <= end; i++){
16163 for(var i = start; i >= end; i--){
16171 * Finds the index of the passed node
16172 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16173 * @return {Number} The index of the node or -1
16175 indexOf : function(node){
16176 node = this.getNode(node);
16177 if(typeof node.nodeIndex == "number"){
16178 return node.nodeIndex;
16180 var ns = this.nodes;
16181 for(var i = 0, len = ns.length; i < len; i++){
16192 * based on jquery fullcalendar
16196 Roo.bootstrap = Roo.bootstrap || {};
16198 * @class Roo.bootstrap.Calendar
16199 * @extends Roo.bootstrap.Component
16200 * Bootstrap Calendar class
16201 * @cfg {Boolean} loadMask (true|false) default false
16202 * @cfg {Object} header generate the user specific header of the calendar, default false
16205 * Create a new Container
16206 * @param {Object} config The config object
16211 Roo.bootstrap.Calendar = function(config){
16212 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16216 * Fires when a date is selected
16217 * @param {DatePicker} this
16218 * @param {Date} date The selected date
16222 * @event monthchange
16223 * Fires when the displayed month changes
16224 * @param {DatePicker} this
16225 * @param {Date} date The selected month
16227 'monthchange': true,
16229 * @event evententer
16230 * Fires when mouse over an event
16231 * @param {Calendar} this
16232 * @param {event} Event
16234 'evententer': true,
16236 * @event eventleave
16237 * Fires when the mouse leaves an
16238 * @param {Calendar} this
16241 'eventleave': true,
16243 * @event eventclick
16244 * Fires when the mouse click an
16245 * @param {Calendar} this
16254 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16257 * @cfg {Number} startDay
16258 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16266 getAutoCreate : function(){
16269 var fc_button = function(name, corner, style, content ) {
16270 return Roo.apply({},{
16272 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16274 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16277 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16288 style : 'width:100%',
16295 cls : 'fc-header-left',
16297 fc_button('prev', 'left', 'arrow', '‹' ),
16298 fc_button('next', 'right', 'arrow', '›' ),
16299 { tag: 'span', cls: 'fc-header-space' },
16300 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16308 cls : 'fc-header-center',
16312 cls: 'fc-header-title',
16315 html : 'month / year'
16323 cls : 'fc-header-right',
16325 /* fc_button('month', 'left', '', 'month' ),
16326 fc_button('week', '', '', 'week' ),
16327 fc_button('day', 'right', '', 'day' )
16339 header = this.header;
16342 var cal_heads = function() {
16344 // fixme - handle this.
16346 for (var i =0; i < Date.dayNames.length; i++) {
16347 var d = Date.dayNames[i];
16350 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16351 html : d.substring(0,3)
16355 ret[0].cls += ' fc-first';
16356 ret[6].cls += ' fc-last';
16359 var cal_cell = function(n) {
16362 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16367 cls: 'fc-day-number',
16371 cls: 'fc-day-content',
16375 style: 'position: relative;' // height: 17px;
16387 var cal_rows = function() {
16390 for (var r = 0; r < 6; r++) {
16397 for (var i =0; i < Date.dayNames.length; i++) {
16398 var d = Date.dayNames[i];
16399 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16402 row.cn[0].cls+=' fc-first';
16403 row.cn[0].cn[0].style = 'min-height:90px';
16404 row.cn[6].cls+=' fc-last';
16408 ret[0].cls += ' fc-first';
16409 ret[4].cls += ' fc-prev-last';
16410 ret[5].cls += ' fc-last';
16417 cls: 'fc-border-separate',
16418 style : 'width:100%',
16426 cls : 'fc-first fc-last',
16444 cls : 'fc-content',
16445 style : "position: relative;",
16448 cls : 'fc-view fc-view-month fc-grid',
16449 style : 'position: relative',
16450 unselectable : 'on',
16453 cls : 'fc-event-container',
16454 style : 'position:absolute;z-index:8;top:0;left:0;'
16472 initEvents : function()
16475 throw "can not find store for calendar";
16481 style: "text-align:center",
16485 style: "background-color:white;width:50%;margin:250 auto",
16489 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16500 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16502 var size = this.el.select('.fc-content', true).first().getSize();
16503 this.maskEl.setSize(size.width, size.height);
16504 this.maskEl.enableDisplayMode("block");
16505 if(!this.loadMask){
16506 this.maskEl.hide();
16509 this.store = Roo.factory(this.store, Roo.data);
16510 this.store.on('load', this.onLoad, this);
16511 this.store.on('beforeload', this.onBeforeLoad, this);
16515 this.cells = this.el.select('.fc-day',true);
16516 //Roo.log(this.cells);
16517 this.textNodes = this.el.query('.fc-day-number');
16518 this.cells.addClassOnOver('fc-state-hover');
16520 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16521 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16522 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16523 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16525 this.on('monthchange', this.onMonthChange, this);
16527 this.update(new Date().clearTime());
16530 resize : function() {
16531 var sz = this.el.getSize();
16533 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16534 this.el.select('.fc-day-content div',true).setHeight(34);
16539 showPrevMonth : function(e){
16540 this.update(this.activeDate.add("mo", -1));
16542 showToday : function(e){
16543 this.update(new Date().clearTime());
16546 showNextMonth : function(e){
16547 this.update(this.activeDate.add("mo", 1));
16551 showPrevYear : function(){
16552 this.update(this.activeDate.add("y", -1));
16556 showNextYear : function(){
16557 this.update(this.activeDate.add("y", 1));
16562 update : function(date)
16564 var vd = this.activeDate;
16565 this.activeDate = date;
16566 // if(vd && this.el){
16567 // var t = date.getTime();
16568 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16569 // Roo.log('using add remove');
16571 // this.fireEvent('monthchange', this, date);
16573 // this.cells.removeClass("fc-state-highlight");
16574 // this.cells.each(function(c){
16575 // if(c.dateValue == t){
16576 // c.addClass("fc-state-highlight");
16577 // setTimeout(function(){
16578 // try{c.dom.firstChild.focus();}catch(e){}
16588 var days = date.getDaysInMonth();
16590 var firstOfMonth = date.getFirstDateOfMonth();
16591 var startingPos = firstOfMonth.getDay()-this.startDay;
16593 if(startingPos < this.startDay){
16597 var pm = date.add(Date.MONTH, -1);
16598 var prevStart = pm.getDaysInMonth()-startingPos;
16600 this.cells = this.el.select('.fc-day',true);
16601 this.textNodes = this.el.query('.fc-day-number');
16602 this.cells.addClassOnOver('fc-state-hover');
16604 var cells = this.cells.elements;
16605 var textEls = this.textNodes;
16607 Roo.each(cells, function(cell){
16608 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16611 days += startingPos;
16613 // convert everything to numbers so it's fast
16614 var day = 86400000;
16615 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16618 //Roo.log(prevStart);
16620 var today = new Date().clearTime().getTime();
16621 var sel = date.clearTime().getTime();
16622 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16623 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16624 var ddMatch = this.disabledDatesRE;
16625 var ddText = this.disabledDatesText;
16626 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16627 var ddaysText = this.disabledDaysText;
16628 var format = this.format;
16630 var setCellClass = function(cal, cell){
16634 //Roo.log('set Cell Class');
16636 var t = d.getTime();
16640 cell.dateValue = t;
16642 cell.className += " fc-today";
16643 cell.className += " fc-state-highlight";
16644 cell.title = cal.todayText;
16647 // disable highlight in other month..
16648 //cell.className += " fc-state-highlight";
16653 cell.className = " fc-state-disabled";
16654 cell.title = cal.minText;
16658 cell.className = " fc-state-disabled";
16659 cell.title = cal.maxText;
16663 if(ddays.indexOf(d.getDay()) != -1){
16664 cell.title = ddaysText;
16665 cell.className = " fc-state-disabled";
16668 if(ddMatch && format){
16669 var fvalue = d.dateFormat(format);
16670 if(ddMatch.test(fvalue)){
16671 cell.title = ddText.replace("%0", fvalue);
16672 cell.className = " fc-state-disabled";
16676 if (!cell.initialClassName) {
16677 cell.initialClassName = cell.dom.className;
16680 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16685 for(; i < startingPos; i++) {
16686 textEls[i].innerHTML = (++prevStart);
16687 d.setDate(d.getDate()+1);
16689 cells[i].className = "fc-past fc-other-month";
16690 setCellClass(this, cells[i]);
16695 for(; i < days; i++){
16696 intDay = i - startingPos + 1;
16697 textEls[i].innerHTML = (intDay);
16698 d.setDate(d.getDate()+1);
16700 cells[i].className = ''; // "x-date-active";
16701 setCellClass(this, cells[i]);
16705 for(; i < 42; i++) {
16706 textEls[i].innerHTML = (++extraDays);
16707 d.setDate(d.getDate()+1);
16709 cells[i].className = "fc-future fc-other-month";
16710 setCellClass(this, cells[i]);
16713 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16715 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16717 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16718 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16720 if(totalRows != 6){
16721 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16722 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16725 this.fireEvent('monthchange', this, date);
16729 if(!this.internalRender){
16730 var main = this.el.dom.firstChild;
16731 var w = main.offsetWidth;
16732 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16733 Roo.fly(main).setWidth(w);
16734 this.internalRender = true;
16735 // opera does not respect the auto grow header center column
16736 // then, after it gets a width opera refuses to recalculate
16737 // without a second pass
16738 if(Roo.isOpera && !this.secondPass){
16739 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16740 this.secondPass = true;
16741 this.update.defer(10, this, [date]);
16748 findCell : function(dt) {
16749 dt = dt.clearTime().getTime();
16751 this.cells.each(function(c){
16752 //Roo.log("check " +c.dateValue + '?=' + dt);
16753 if(c.dateValue == dt){
16763 findCells : function(ev) {
16764 var s = ev.start.clone().clearTime().getTime();
16766 var e= ev.end.clone().clearTime().getTime();
16769 this.cells.each(function(c){
16770 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16772 if(c.dateValue > e){
16775 if(c.dateValue < s){
16784 // findBestRow: function(cells)
16788 // for (var i =0 ; i < cells.length;i++) {
16789 // ret = Math.max(cells[i].rows || 0,ret);
16796 addItem : function(ev)
16798 // look for vertical location slot in
16799 var cells = this.findCells(ev);
16801 // ev.row = this.findBestRow(cells);
16803 // work out the location.
16807 for(var i =0; i < cells.length; i++) {
16809 cells[i].row = cells[0].row;
16812 cells[i].row = cells[i].row + 1;
16822 if (crow.start.getY() == cells[i].getY()) {
16824 crow.end = cells[i];
16841 cells[0].events.push(ev);
16843 this.calevents.push(ev);
16846 clearEvents: function() {
16848 if(!this.calevents){
16852 Roo.each(this.cells.elements, function(c){
16858 Roo.each(this.calevents, function(e) {
16859 Roo.each(e.els, function(el) {
16860 el.un('mouseenter' ,this.onEventEnter, this);
16861 el.un('mouseleave' ,this.onEventLeave, this);
16866 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16872 renderEvents: function()
16876 this.cells.each(function(c) {
16885 if(c.row != c.events.length){
16886 r = 4 - (4 - (c.row - c.events.length));
16889 c.events = ev.slice(0, r);
16890 c.more = ev.slice(r);
16892 if(c.more.length && c.more.length == 1){
16893 c.events.push(c.more.pop());
16896 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16900 this.cells.each(function(c) {
16902 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16905 for (var e = 0; e < c.events.length; e++){
16906 var ev = c.events[e];
16907 var rows = ev.rows;
16909 for(var i = 0; i < rows.length; i++) {
16911 // how many rows should it span..
16914 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16915 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16917 unselectable : "on",
16920 cls: 'fc-event-inner',
16924 // cls: 'fc-event-time',
16925 // html : cells.length > 1 ? '' : ev.time
16929 cls: 'fc-event-title',
16930 html : String.format('{0}', ev.title)
16937 cls: 'ui-resizable-handle ui-resizable-e',
16938 html : '  '
16945 cfg.cls += ' fc-event-start';
16947 if ((i+1) == rows.length) {
16948 cfg.cls += ' fc-event-end';
16951 var ctr = _this.el.select('.fc-event-container',true).first();
16952 var cg = ctr.createChild(cfg);
16954 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
16955 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
16957 var r = (c.more.length) ? 1 : 0;
16958 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
16959 cg.setWidth(ebox.right - sbox.x -2);
16961 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
16962 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
16963 cg.on('click', _this.onEventClick, _this, ev);
16974 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
16975 style : 'position: absolute',
16976 unselectable : "on",
16979 cls: 'fc-event-inner',
16983 cls: 'fc-event-title',
16991 cls: 'ui-resizable-handle ui-resizable-e',
16992 html : '  '
16998 var ctr = _this.el.select('.fc-event-container',true).first();
16999 var cg = ctr.createChild(cfg);
17001 var sbox = c.select('.fc-day-content',true).first().getBox();
17002 var ebox = c.select('.fc-day-content',true).first().getBox();
17004 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17005 cg.setWidth(ebox.right - sbox.x -2);
17007 cg.on('click', _this.onMoreEventClick, _this, c.more);
17017 onEventEnter: function (e, el,event,d) {
17018 this.fireEvent('evententer', this, el, event);
17021 onEventLeave: function (e, el,event,d) {
17022 this.fireEvent('eventleave', this, el, event);
17025 onEventClick: function (e, el,event,d) {
17026 this.fireEvent('eventclick', this, el, event);
17029 onMonthChange: function () {
17033 onMoreEventClick: function(e, el, more)
17037 this.calpopover.placement = 'right';
17038 this.calpopover.setTitle('More');
17040 this.calpopover.setContent('');
17042 var ctr = this.calpopover.el.select('.popover-content', true).first();
17044 Roo.each(more, function(m){
17046 cls : 'fc-event-hori fc-event-draggable',
17049 var cg = ctr.createChild(cfg);
17051 cg.on('click', _this.onEventClick, _this, m);
17054 this.calpopover.show(el);
17059 onLoad: function ()
17061 this.calevents = [];
17064 if(this.store.getCount() > 0){
17065 this.store.data.each(function(d){
17068 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17069 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17070 time : d.data.start_time,
17071 title : d.data.title,
17072 description : d.data.description,
17073 venue : d.data.venue
17078 this.renderEvents();
17080 if(this.calevents.length && this.loadMask){
17081 this.maskEl.hide();
17085 onBeforeLoad: function()
17087 this.clearEvents();
17089 this.maskEl.show();
17103 * @class Roo.bootstrap.Popover
17104 * @extends Roo.bootstrap.Component
17105 * Bootstrap Popover class
17106 * @cfg {String} html contents of the popover (or false to use children..)
17107 * @cfg {String} title of popover (or false to hide)
17108 * @cfg {String} placement how it is placed
17109 * @cfg {String} trigger click || hover (or false to trigger manually)
17110 * @cfg {String} over what (parent or false to trigger manually.)
17111 * @cfg {Number} delay - delay before showing
17114 * Create a new Popover
17115 * @param {Object} config The config object
17118 Roo.bootstrap.Popover = function(config){
17119 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17125 * After the popover show
17127 * @param {Roo.bootstrap.Popover} this
17132 * After the popover hide
17134 * @param {Roo.bootstrap.Popover} this
17140 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17142 title: 'Fill in a title',
17145 placement : 'right',
17146 trigger : 'hover', // hover
17152 can_build_overlaid : false,
17154 getChildContainer : function()
17156 return this.el.select('.popover-content',true).first();
17159 getAutoCreate : function(){
17162 cls : 'popover roo-dynamic',
17163 style: 'display:block',
17169 cls : 'popover-inner',
17173 cls: 'popover-title',
17177 cls : 'popover-content',
17188 setTitle: function(str)
17191 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17193 setContent: function(str)
17196 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17198 // as it get's added to the bottom of the page.
17199 onRender : function(ct, position)
17201 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17203 var cfg = Roo.apply({}, this.getAutoCreate());
17207 cfg.cls += ' ' + this.cls;
17210 cfg.style = this.style;
17212 //Roo.log("adding to ");
17213 this.el = Roo.get(document.body).createChild(cfg, position);
17214 // Roo.log(this.el);
17219 initEvents : function()
17221 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17222 this.el.enableDisplayMode('block');
17224 if (this.over === false) {
17227 if (this.triggers === false) {
17230 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17231 var triggers = this.trigger ? this.trigger.split(' ') : [];
17232 Roo.each(triggers, function(trigger) {
17234 if (trigger == 'click') {
17235 on_el.on('click', this.toggle, this);
17236 } else if (trigger != 'manual') {
17237 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17238 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17240 on_el.on(eventIn ,this.enter, this);
17241 on_el.on(eventOut, this.leave, this);
17252 toggle : function () {
17253 this.hoverState == 'in' ? this.leave() : this.enter();
17256 enter : function () {
17258 clearTimeout(this.timeout);
17260 this.hoverState = 'in';
17262 if (!this.delay || !this.delay.show) {
17267 this.timeout = setTimeout(function () {
17268 if (_t.hoverState == 'in') {
17271 }, this.delay.show)
17274 leave : function() {
17275 clearTimeout(this.timeout);
17277 this.hoverState = 'out';
17279 if (!this.delay || !this.delay.hide) {
17284 this.timeout = setTimeout(function () {
17285 if (_t.hoverState == 'out') {
17288 }, this.delay.hide)
17291 show : function (on_el)
17294 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17298 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17299 if (this.html !== false) {
17300 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17302 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17303 if (!this.title.length) {
17304 this.el.select('.popover-title',true).hide();
17307 var placement = typeof this.placement == 'function' ?
17308 this.placement.call(this, this.el, on_el) :
17311 var autoToken = /\s?auto?\s?/i;
17312 var autoPlace = autoToken.test(placement);
17314 placement = placement.replace(autoToken, '') || 'top';
17318 //this.el.setXY([0,0]);
17320 this.el.dom.style.display='block';
17321 this.el.addClass(placement);
17323 //this.el.appendTo(on_el);
17325 var p = this.getPosition();
17326 var box = this.el.getBox();
17331 var align = Roo.bootstrap.Popover.alignment[placement];
17332 this.el.alignTo(on_el, align[0],align[1]);
17333 //var arrow = this.el.select('.arrow',true).first();
17334 //arrow.set(align[2],
17336 this.el.addClass('in');
17339 if (this.el.hasClass('fade')) {
17343 this.hoverState = 'in';
17345 this.fireEvent('show', this);
17350 this.el.setXY([0,0]);
17351 this.el.removeClass('in');
17353 this.hoverState = null;
17355 this.fireEvent('hide', this);
17360 Roo.bootstrap.Popover.alignment = {
17361 'left' : ['r-l', [-10,0], 'right'],
17362 'right' : ['l-r', [10,0], 'left'],
17363 'bottom' : ['t-b', [0,10], 'top'],
17364 'top' : [ 'b-t', [0,-10], 'bottom']
17375 * @class Roo.bootstrap.Progress
17376 * @extends Roo.bootstrap.Component
17377 * Bootstrap Progress class
17378 * @cfg {Boolean} striped striped of the progress bar
17379 * @cfg {Boolean} active animated of the progress bar
17383 * Create a new Progress
17384 * @param {Object} config The config object
17387 Roo.bootstrap.Progress = function(config){
17388 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17391 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17396 getAutoCreate : function(){
17404 cfg.cls += ' progress-striped';
17408 cfg.cls += ' active';
17427 * @class Roo.bootstrap.ProgressBar
17428 * @extends Roo.bootstrap.Component
17429 * Bootstrap ProgressBar class
17430 * @cfg {Number} aria_valuenow aria-value now
17431 * @cfg {Number} aria_valuemin aria-value min
17432 * @cfg {Number} aria_valuemax aria-value max
17433 * @cfg {String} label label for the progress bar
17434 * @cfg {String} panel (success | info | warning | danger )
17435 * @cfg {String} role role of the progress bar
17436 * @cfg {String} sr_only text
17440 * Create a new ProgressBar
17441 * @param {Object} config The config object
17444 Roo.bootstrap.ProgressBar = function(config){
17445 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17448 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17452 aria_valuemax : 100,
17458 getAutoCreate : function()
17463 cls: 'progress-bar',
17464 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17476 cfg.role = this.role;
17479 if(this.aria_valuenow){
17480 cfg['aria-valuenow'] = this.aria_valuenow;
17483 if(this.aria_valuemin){
17484 cfg['aria-valuemin'] = this.aria_valuemin;
17487 if(this.aria_valuemax){
17488 cfg['aria-valuemax'] = this.aria_valuemax;
17491 if(this.label && !this.sr_only){
17492 cfg.html = this.label;
17496 cfg.cls += ' progress-bar-' + this.panel;
17502 update : function(aria_valuenow)
17504 this.aria_valuenow = aria_valuenow;
17506 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17521 * @class Roo.bootstrap.TabGroup
17522 * @extends Roo.bootstrap.Column
17523 * Bootstrap Column class
17524 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17525 * @cfg {Boolean} carousel true to make the group behave like a carousel
17526 * @cfg {Boolean} bullets show bullets for the panels
17527 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17528 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17529 * @cfg {Boolean} showarrow (true|false) show arrow default true
17532 * Create a new TabGroup
17533 * @param {Object} config The config object
17536 Roo.bootstrap.TabGroup = function(config){
17537 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17539 this.navId = Roo.id();
17542 Roo.bootstrap.TabGroup.register(this);
17546 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17549 transition : false,
17554 slideOnTouch : false,
17557 getAutoCreate : function()
17559 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17561 cfg.cls += ' tab-content';
17563 if (this.carousel) {
17564 cfg.cls += ' carousel slide';
17567 cls : 'carousel-inner',
17571 if(this.bullets && !Roo.isTouch){
17574 cls : 'carousel-bullets',
17578 if(this.bullets_cls){
17579 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17586 cfg.cn[0].cn.push(bullets);
17589 if(this.showarrow){
17590 cfg.cn[0].cn.push({
17592 class : 'carousel-arrow',
17596 class : 'carousel-prev',
17600 class : 'fa fa-chevron-left'
17606 class : 'carousel-next',
17610 class : 'fa fa-chevron-right'
17623 initEvents: function()
17625 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17626 // this.el.on("touchstart", this.onTouchStart, this);
17629 if(this.autoslide){
17632 this.slideFn = window.setInterval(function() {
17633 _this.showPanelNext();
17637 if(this.showarrow){
17638 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17639 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17645 // onTouchStart : function(e, el, o)
17647 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17651 // this.showPanelNext();
17655 getChildContainer : function()
17657 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17661 * register a Navigation item
17662 * @param {Roo.bootstrap.NavItem} the navitem to add
17664 register : function(item)
17666 this.tabs.push( item);
17667 item.navId = this.navId; // not really needed..
17672 getActivePanel : function()
17675 Roo.each(this.tabs, function(t) {
17685 getPanelByName : function(n)
17688 Roo.each(this.tabs, function(t) {
17689 if (t.tabId == n) {
17697 indexOfPanel : function(p)
17700 Roo.each(this.tabs, function(t,i) {
17701 if (t.tabId == p.tabId) {
17710 * show a specific panel
17711 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17712 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17714 showPanel : function (pan)
17716 if(this.transition || typeof(pan) == 'undefined'){
17717 Roo.log("waiting for the transitionend");
17721 if (typeof(pan) == 'number') {
17722 pan = this.tabs[pan];
17725 if (typeof(pan) == 'string') {
17726 pan = this.getPanelByName(pan);
17729 var cur = this.getActivePanel();
17732 Roo.log('pan or acitve pan is undefined');
17736 if (pan.tabId == this.getActivePanel().tabId) {
17740 if (false === cur.fireEvent('beforedeactivate')) {
17744 if(this.bullets > 0 && !Roo.isTouch){
17745 this.setActiveBullet(this.indexOfPanel(pan));
17748 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17750 this.transition = true;
17751 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17752 var lr = dir == 'next' ? 'left' : 'right';
17753 pan.el.addClass(dir); // or prev
17754 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17755 cur.el.addClass(lr); // or right
17756 pan.el.addClass(lr);
17759 cur.el.on('transitionend', function() {
17760 Roo.log("trans end?");
17762 pan.el.removeClass([lr,dir]);
17763 pan.setActive(true);
17765 cur.el.removeClass([lr]);
17766 cur.setActive(false);
17768 _this.transition = false;
17770 }, this, { single: true } );
17775 cur.setActive(false);
17776 pan.setActive(true);
17781 showPanelNext : function()
17783 var i = this.indexOfPanel(this.getActivePanel());
17785 if (i >= this.tabs.length - 1 && !this.autoslide) {
17789 if (i >= this.tabs.length - 1 && this.autoslide) {
17793 this.showPanel(this.tabs[i+1]);
17796 showPanelPrev : function()
17798 var i = this.indexOfPanel(this.getActivePanel());
17800 if (i < 1 && !this.autoslide) {
17804 if (i < 1 && this.autoslide) {
17805 i = this.tabs.length;
17808 this.showPanel(this.tabs[i-1]);
17812 addBullet: function()
17814 if(!this.bullets || Roo.isTouch){
17817 var ctr = this.el.select('.carousel-bullets',true).first();
17818 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17819 var bullet = ctr.createChild({
17820 cls : 'bullet bullet-' + i
17821 },ctr.dom.lastChild);
17826 bullet.on('click', (function(e, el, o, ii, t){
17828 e.preventDefault();
17830 this.showPanel(ii);
17832 if(this.autoslide && this.slideFn){
17833 clearInterval(this.slideFn);
17834 this.slideFn = window.setInterval(function() {
17835 _this.showPanelNext();
17839 }).createDelegate(this, [i, bullet], true));
17844 setActiveBullet : function(i)
17850 Roo.each(this.el.select('.bullet', true).elements, function(el){
17851 el.removeClass('selected');
17854 var bullet = this.el.select('.bullet-' + i, true).first();
17860 bullet.addClass('selected');
17871 Roo.apply(Roo.bootstrap.TabGroup, {
17875 * register a Navigation Group
17876 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17878 register : function(navgrp)
17880 this.groups[navgrp.navId] = navgrp;
17884 * fetch a Navigation Group based on the navigation ID
17885 * if one does not exist , it will get created.
17886 * @param {string} the navgroup to add
17887 * @returns {Roo.bootstrap.NavGroup} the navgroup
17889 get: function(navId) {
17890 if (typeof(this.groups[navId]) == 'undefined') {
17891 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17893 return this.groups[navId] ;
17908 * @class Roo.bootstrap.TabPanel
17909 * @extends Roo.bootstrap.Component
17910 * Bootstrap TabPanel class
17911 * @cfg {Boolean} active panel active
17912 * @cfg {String} html panel content
17913 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17914 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17915 * @cfg {String} href click to link..
17919 * Create a new TabPanel
17920 * @param {Object} config The config object
17923 Roo.bootstrap.TabPanel = function(config){
17924 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17928 * Fires when the active status changes
17929 * @param {Roo.bootstrap.TabPanel} this
17930 * @param {Boolean} state the new state
17935 * @event beforedeactivate
17936 * Fires before a tab is de-activated - can be used to do validation on a form.
17937 * @param {Roo.bootstrap.TabPanel} this
17938 * @return {Boolean} false if there is an error
17941 'beforedeactivate': true
17944 this.tabId = this.tabId || Roo.id();
17948 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
17956 getAutoCreate : function(){
17959 // item is needed for carousel - not sure if it has any effect otherwise
17960 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
17961 html: this.html || ''
17965 cfg.cls += ' active';
17969 cfg.tabId = this.tabId;
17976 initEvents: function()
17978 var p = this.parent();
17980 this.navId = this.navId || p.navId;
17982 if (typeof(this.navId) != 'undefined') {
17983 // not really needed.. but just in case.. parent should be a NavGroup.
17984 var tg = Roo.bootstrap.TabGroup.get(this.navId);
17988 var i = tg.tabs.length - 1;
17990 if(this.active && tg.bullets > 0 && i < tg.bullets){
17991 tg.setActiveBullet(i);
17995 this.el.on('click', this.onClick, this);
17998 this.el.on("touchstart", this.onTouchStart, this);
17999 this.el.on("touchmove", this.onTouchMove, this);
18000 this.el.on("touchend", this.onTouchEnd, this);
18005 onRender : function(ct, position)
18007 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18010 setActive : function(state)
18012 Roo.log("panel - set active " + this.tabId + "=" + state);
18014 this.active = state;
18016 this.el.removeClass('active');
18018 } else if (!this.el.hasClass('active')) {
18019 this.el.addClass('active');
18022 this.fireEvent('changed', this, state);
18025 onClick : function(e)
18027 e.preventDefault();
18029 if(!this.href.length){
18033 window.location.href = this.href;
18042 onTouchStart : function(e)
18044 this.swiping = false;
18046 this.startX = e.browserEvent.touches[0].clientX;
18047 this.startY = e.browserEvent.touches[0].clientY;
18050 onTouchMove : function(e)
18052 this.swiping = true;
18054 this.endX = e.browserEvent.touches[0].clientX;
18055 this.endY = e.browserEvent.touches[0].clientY;
18058 onTouchEnd : function(e)
18065 var tabGroup = this.parent();
18067 if(this.endX > this.startX){ // swiping right
18068 tabGroup.showPanelPrev();
18072 if(this.startX > this.endX){ // swiping left
18073 tabGroup.showPanelNext();
18092 * @class Roo.bootstrap.DateField
18093 * @extends Roo.bootstrap.Input
18094 * Bootstrap DateField class
18095 * @cfg {Number} weekStart default 0
18096 * @cfg {String} viewMode default empty, (months|years)
18097 * @cfg {String} minViewMode default empty, (months|years)
18098 * @cfg {Number} startDate default -Infinity
18099 * @cfg {Number} endDate default Infinity
18100 * @cfg {Boolean} todayHighlight default false
18101 * @cfg {Boolean} todayBtn default false
18102 * @cfg {Boolean} calendarWeeks default false
18103 * @cfg {Object} daysOfWeekDisabled default empty
18104 * @cfg {Boolean} singleMode default false (true | false)
18106 * @cfg {Boolean} keyboardNavigation default true
18107 * @cfg {String} language default en
18110 * Create a new DateField
18111 * @param {Object} config The config object
18114 Roo.bootstrap.DateField = function(config){
18115 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18119 * Fires when this field show.
18120 * @param {Roo.bootstrap.DateField} this
18121 * @param {Mixed} date The date value
18126 * Fires when this field hide.
18127 * @param {Roo.bootstrap.DateField} this
18128 * @param {Mixed} date The date value
18133 * Fires when select a date.
18134 * @param {Roo.bootstrap.DateField} this
18135 * @param {Mixed} date The date value
18139 * @event beforeselect
18140 * Fires when before select a date.
18141 * @param {Roo.bootstrap.DateField} this
18142 * @param {Mixed} date The date value
18144 beforeselect : true
18148 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18151 * @cfg {String} format
18152 * The default date format string which can be overriden for localization support. The format must be
18153 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18157 * @cfg {String} altFormats
18158 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18159 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18161 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18169 todayHighlight : false,
18175 keyboardNavigation: true,
18177 calendarWeeks: false,
18179 startDate: -Infinity,
18183 daysOfWeekDisabled: [],
18187 singleMode : false,
18189 UTCDate: function()
18191 return new Date(Date.UTC.apply(Date, arguments));
18194 UTCToday: function()
18196 var today = new Date();
18197 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18200 getDate: function() {
18201 var d = this.getUTCDate();
18202 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18205 getUTCDate: function() {
18209 setDate: function(d) {
18210 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18213 setUTCDate: function(d) {
18215 this.setValue(this.formatDate(this.date));
18218 onRender: function(ct, position)
18221 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18223 this.language = this.language || 'en';
18224 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18225 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18227 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18228 this.format = this.format || 'm/d/y';
18229 this.isInline = false;
18230 this.isInput = true;
18231 this.component = this.el.select('.add-on', true).first() || false;
18232 this.component = (this.component && this.component.length === 0) ? false : this.component;
18233 this.hasInput = this.component && this.inputEl().length;
18235 if (typeof(this.minViewMode === 'string')) {
18236 switch (this.minViewMode) {
18238 this.minViewMode = 1;
18241 this.minViewMode = 2;
18244 this.minViewMode = 0;
18249 if (typeof(this.viewMode === 'string')) {
18250 switch (this.viewMode) {
18263 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18265 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18267 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18269 this.picker().on('mousedown', this.onMousedown, this);
18270 this.picker().on('click', this.onClick, this);
18272 this.picker().addClass('datepicker-dropdown');
18274 this.startViewMode = this.viewMode;
18276 if(this.singleMode){
18277 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18278 v.setVisibilityMode(Roo.Element.DISPLAY);
18282 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18283 v.setStyle('width', '189px');
18287 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18288 if(!this.calendarWeeks){
18293 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18294 v.attr('colspan', function(i, val){
18295 return parseInt(val) + 1;
18300 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18302 this.setStartDate(this.startDate);
18303 this.setEndDate(this.endDate);
18305 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18312 if(this.isInline) {
18317 picker : function()
18319 return this.pickerEl;
18320 // return this.el.select('.datepicker', true).first();
18323 fillDow: function()
18325 var dowCnt = this.weekStart;
18334 if(this.calendarWeeks){
18342 while (dowCnt < this.weekStart + 7) {
18346 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18350 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18353 fillMonths: function()
18356 var months = this.picker().select('>.datepicker-months td', true).first();
18358 months.dom.innerHTML = '';
18364 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18367 months.createChild(month);
18374 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;
18376 if (this.date < this.startDate) {
18377 this.viewDate = new Date(this.startDate);
18378 } else if (this.date > this.endDate) {
18379 this.viewDate = new Date(this.endDate);
18381 this.viewDate = new Date(this.date);
18389 var d = new Date(this.viewDate),
18390 year = d.getUTCFullYear(),
18391 month = d.getUTCMonth(),
18392 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18393 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18394 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18395 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18396 currentDate = this.date && this.date.valueOf(),
18397 today = this.UTCToday();
18399 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18401 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18403 // this.picker.select('>tfoot th.today').
18404 // .text(dates[this.language].today)
18405 // .toggle(this.todayBtn !== false);
18407 this.updateNavArrows();
18410 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18412 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18414 prevMonth.setUTCDate(day);
18416 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18418 var nextMonth = new Date(prevMonth);
18420 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18422 nextMonth = nextMonth.valueOf();
18424 var fillMonths = false;
18426 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18428 while(prevMonth.valueOf() < nextMonth) {
18431 if (prevMonth.getUTCDay() === this.weekStart) {
18433 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18441 if(this.calendarWeeks){
18442 // ISO 8601: First week contains first thursday.
18443 // ISO also states week starts on Monday, but we can be more abstract here.
18445 // Start of current week: based on weekstart/current date
18446 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18447 // Thursday of this week
18448 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18449 // First Thursday of year, year from thursday
18450 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18451 // Calendar week: ms between thursdays, div ms per day, div 7 days
18452 calWeek = (th - yth) / 864e5 / 7 + 1;
18454 fillMonths.cn.push({
18462 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18464 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18467 if (this.todayHighlight &&
18468 prevMonth.getUTCFullYear() == today.getFullYear() &&
18469 prevMonth.getUTCMonth() == today.getMonth() &&
18470 prevMonth.getUTCDate() == today.getDate()) {
18471 clsName += ' today';
18474 if (currentDate && prevMonth.valueOf() === currentDate) {
18475 clsName += ' active';
18478 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18479 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18480 clsName += ' disabled';
18483 fillMonths.cn.push({
18485 cls: 'day ' + clsName,
18486 html: prevMonth.getDate()
18489 prevMonth.setDate(prevMonth.getDate()+1);
18492 var currentYear = this.date && this.date.getUTCFullYear();
18493 var currentMonth = this.date && this.date.getUTCMonth();
18495 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18497 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18498 v.removeClass('active');
18500 if(currentYear === year && k === currentMonth){
18501 v.addClass('active');
18504 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18505 v.addClass('disabled');
18511 year = parseInt(year/10, 10) * 10;
18513 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18515 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18518 for (var i = -1; i < 11; i++) {
18519 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18521 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18529 showMode: function(dir)
18532 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18535 Roo.each(this.picker().select('>div',true).elements, function(v){
18536 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18539 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18544 if(this.isInline) {
18548 this.picker().removeClass(['bottom', 'top']);
18550 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18552 * place to the top of element!
18556 this.picker().addClass('top');
18557 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18562 this.picker().addClass('bottom');
18564 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18567 parseDate : function(value)
18569 if(!value || value instanceof Date){
18572 var v = Date.parseDate(value, this.format);
18573 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18574 v = Date.parseDate(value, 'Y-m-d');
18576 if(!v && this.altFormats){
18577 if(!this.altFormatsArray){
18578 this.altFormatsArray = this.altFormats.split("|");
18580 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18581 v = Date.parseDate(value, this.altFormatsArray[i]);
18587 formatDate : function(date, fmt)
18589 return (!date || !(date instanceof Date)) ?
18590 date : date.dateFormat(fmt || this.format);
18593 onFocus : function()
18595 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18599 onBlur : function()
18601 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18603 var d = this.inputEl().getValue();
18612 this.picker().show();
18616 this.fireEvent('show', this, this.date);
18621 if(this.isInline) {
18624 this.picker().hide();
18625 this.viewMode = this.startViewMode;
18628 this.fireEvent('hide', this, this.date);
18632 onMousedown: function(e)
18634 e.stopPropagation();
18635 e.preventDefault();
18640 Roo.bootstrap.DateField.superclass.keyup.call(this);
18644 setValue: function(v)
18646 if(this.fireEvent('beforeselect', this, v) !== false){
18647 var d = new Date(this.parseDate(v) ).clearTime();
18649 if(isNaN(d.getTime())){
18650 this.date = this.viewDate = '';
18651 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18655 v = this.formatDate(d);
18657 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18659 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18663 this.fireEvent('select', this, this.date);
18667 getValue: function()
18669 return this.formatDate(this.date);
18672 fireKey: function(e)
18674 if (!this.picker().isVisible()){
18675 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18681 var dateChanged = false,
18683 newDate, newViewDate;
18688 e.preventDefault();
18692 if (!this.keyboardNavigation) {
18695 dir = e.keyCode == 37 ? -1 : 1;
18698 newDate = this.moveYear(this.date, dir);
18699 newViewDate = this.moveYear(this.viewDate, dir);
18700 } else if (e.shiftKey){
18701 newDate = this.moveMonth(this.date, dir);
18702 newViewDate = this.moveMonth(this.viewDate, dir);
18704 newDate = new Date(this.date);
18705 newDate.setUTCDate(this.date.getUTCDate() + dir);
18706 newViewDate = new Date(this.viewDate);
18707 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18709 if (this.dateWithinRange(newDate)){
18710 this.date = newDate;
18711 this.viewDate = newViewDate;
18712 this.setValue(this.formatDate(this.date));
18714 e.preventDefault();
18715 dateChanged = true;
18720 if (!this.keyboardNavigation) {
18723 dir = e.keyCode == 38 ? -1 : 1;
18725 newDate = this.moveYear(this.date, dir);
18726 newViewDate = this.moveYear(this.viewDate, dir);
18727 } else if (e.shiftKey){
18728 newDate = this.moveMonth(this.date, dir);
18729 newViewDate = this.moveMonth(this.viewDate, dir);
18731 newDate = new Date(this.date);
18732 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18733 newViewDate = new Date(this.viewDate);
18734 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18736 if (this.dateWithinRange(newDate)){
18737 this.date = newDate;
18738 this.viewDate = newViewDate;
18739 this.setValue(this.formatDate(this.date));
18741 e.preventDefault();
18742 dateChanged = true;
18746 this.setValue(this.formatDate(this.date));
18748 e.preventDefault();
18751 this.setValue(this.formatDate(this.date));
18765 onClick: function(e)
18767 e.stopPropagation();
18768 e.preventDefault();
18770 var target = e.getTarget();
18772 if(target.nodeName.toLowerCase() === 'i'){
18773 target = Roo.get(target).dom.parentNode;
18776 var nodeName = target.nodeName;
18777 var className = target.className;
18778 var html = target.innerHTML;
18779 //Roo.log(nodeName);
18781 switch(nodeName.toLowerCase()) {
18783 switch(className) {
18789 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18790 switch(this.viewMode){
18792 this.viewDate = this.moveMonth(this.viewDate, dir);
18796 this.viewDate = this.moveYear(this.viewDate, dir);
18802 var date = new Date();
18803 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18805 this.setValue(this.formatDate(this.date));
18812 if (className.indexOf('disabled') < 0) {
18813 this.viewDate.setUTCDate(1);
18814 if (className.indexOf('month') > -1) {
18815 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18817 var year = parseInt(html, 10) || 0;
18818 this.viewDate.setUTCFullYear(year);
18822 if(this.singleMode){
18823 this.setValue(this.formatDate(this.viewDate));
18834 //Roo.log(className);
18835 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18836 var day = parseInt(html, 10) || 1;
18837 var year = this.viewDate.getUTCFullYear(),
18838 month = this.viewDate.getUTCMonth();
18840 if (className.indexOf('old') > -1) {
18847 } else if (className.indexOf('new') > -1) {
18855 //Roo.log([year,month,day]);
18856 this.date = this.UTCDate(year, month, day,0,0,0,0);
18857 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18859 //Roo.log(this.formatDate(this.date));
18860 this.setValue(this.formatDate(this.date));
18867 setStartDate: function(startDate)
18869 this.startDate = startDate || -Infinity;
18870 if (this.startDate !== -Infinity) {
18871 this.startDate = this.parseDate(this.startDate);
18874 this.updateNavArrows();
18877 setEndDate: function(endDate)
18879 this.endDate = endDate || Infinity;
18880 if (this.endDate !== Infinity) {
18881 this.endDate = this.parseDate(this.endDate);
18884 this.updateNavArrows();
18887 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18889 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18890 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18891 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18893 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18894 return parseInt(d, 10);
18897 this.updateNavArrows();
18900 updateNavArrows: function()
18902 if(this.singleMode){
18906 var d = new Date(this.viewDate),
18907 year = d.getUTCFullYear(),
18908 month = d.getUTCMonth();
18910 Roo.each(this.picker().select('.prev', true).elements, function(v){
18912 switch (this.viewMode) {
18915 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18921 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18928 Roo.each(this.picker().select('.next', true).elements, function(v){
18930 switch (this.viewMode) {
18933 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
18939 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
18947 moveMonth: function(date, dir)
18952 var new_date = new Date(date.valueOf()),
18953 day = new_date.getUTCDate(),
18954 month = new_date.getUTCMonth(),
18955 mag = Math.abs(dir),
18957 dir = dir > 0 ? 1 : -1;
18960 // If going back one month, make sure month is not current month
18961 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
18963 return new_date.getUTCMonth() == month;
18965 // If going forward one month, make sure month is as expected
18966 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
18968 return new_date.getUTCMonth() != new_month;
18970 new_month = month + dir;
18971 new_date.setUTCMonth(new_month);
18972 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
18973 if (new_month < 0 || new_month > 11) {
18974 new_month = (new_month + 12) % 12;
18977 // For magnitudes >1, move one month at a time...
18978 for (var i=0; i<mag; i++) {
18979 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
18980 new_date = this.moveMonth(new_date, dir);
18982 // ...then reset the day, keeping it in the new month
18983 new_month = new_date.getUTCMonth();
18984 new_date.setUTCDate(day);
18986 return new_month != new_date.getUTCMonth();
18989 // Common date-resetting loop -- if date is beyond end of month, make it
18992 new_date.setUTCDate(--day);
18993 new_date.setUTCMonth(new_month);
18998 moveYear: function(date, dir)
19000 return this.moveMonth(date, dir*12);
19003 dateWithinRange: function(date)
19005 return date >= this.startDate && date <= this.endDate;
19011 this.picker().remove();
19014 validateValue : function(value)
19016 if(value.length < 1) {
19017 if(this.allowBlank){
19023 if(value.length < this.minLength){
19026 if(value.length > this.maxLength){
19030 var vt = Roo.form.VTypes;
19031 if(!vt[this.vtype](value, this)){
19035 if(typeof this.validator == "function"){
19036 var msg = this.validator(value);
19042 if(this.regex && !this.regex.test(value)){
19046 if(typeof(this.parseDate(value)) == 'undefined'){
19050 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19054 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19064 Roo.apply(Roo.bootstrap.DateField, {
19075 html: '<i class="fa fa-arrow-left"/>'
19085 html: '<i class="fa fa-arrow-right"/>'
19127 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19128 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19129 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19130 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19131 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19144 navFnc: 'FullYear',
19149 navFnc: 'FullYear',
19154 Roo.apply(Roo.bootstrap.DateField, {
19158 cls: 'datepicker dropdown-menu roo-dynamic',
19162 cls: 'datepicker-days',
19166 cls: 'table-condensed',
19168 Roo.bootstrap.DateField.head,
19172 Roo.bootstrap.DateField.footer
19179 cls: 'datepicker-months',
19183 cls: 'table-condensed',
19185 Roo.bootstrap.DateField.head,
19186 Roo.bootstrap.DateField.content,
19187 Roo.bootstrap.DateField.footer
19194 cls: 'datepicker-years',
19198 cls: 'table-condensed',
19200 Roo.bootstrap.DateField.head,
19201 Roo.bootstrap.DateField.content,
19202 Roo.bootstrap.DateField.footer
19221 * @class Roo.bootstrap.TimeField
19222 * @extends Roo.bootstrap.Input
19223 * Bootstrap DateField class
19227 * Create a new TimeField
19228 * @param {Object} config The config object
19231 Roo.bootstrap.TimeField = function(config){
19232 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19236 * Fires when this field show.
19237 * @param {Roo.bootstrap.DateField} thisthis
19238 * @param {Mixed} date The date value
19243 * Fires when this field hide.
19244 * @param {Roo.bootstrap.DateField} this
19245 * @param {Mixed} date The date value
19250 * Fires when select a date.
19251 * @param {Roo.bootstrap.DateField} this
19252 * @param {Mixed} date The date value
19258 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19261 * @cfg {String} format
19262 * The default time format string which can be overriden for localization support. The format must be
19263 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19267 onRender: function(ct, position)
19270 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19272 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19274 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19276 this.pop = this.picker().select('>.datepicker-time',true).first();
19277 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19279 this.picker().on('mousedown', this.onMousedown, this);
19280 this.picker().on('click', this.onClick, this);
19282 this.picker().addClass('datepicker-dropdown');
19287 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19288 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19289 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19290 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19291 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19292 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19296 fireKey: function(e){
19297 if (!this.picker().isVisible()){
19298 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19304 e.preventDefault();
19312 this.onTogglePeriod();
19315 this.onIncrementMinutes();
19318 this.onDecrementMinutes();
19327 onClick: function(e) {
19328 e.stopPropagation();
19329 e.preventDefault();
19332 picker : function()
19334 return this.el.select('.datepicker', true).first();
19337 fillTime: function()
19339 var time = this.pop.select('tbody', true).first();
19341 time.dom.innerHTML = '';
19356 cls: 'hours-up glyphicon glyphicon-chevron-up'
19376 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19397 cls: 'timepicker-hour',
19412 cls: 'timepicker-minute',
19427 cls: 'btn btn-primary period',
19449 cls: 'hours-down glyphicon glyphicon-chevron-down'
19469 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19487 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19494 var hours = this.time.getHours();
19495 var minutes = this.time.getMinutes();
19508 hours = hours - 12;
19512 hours = '0' + hours;
19516 minutes = '0' + minutes;
19519 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19520 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19521 this.pop.select('button', true).first().dom.innerHTML = period;
19527 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19529 var cls = ['bottom'];
19531 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19538 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19543 this.picker().addClass(cls.join('-'));
19547 Roo.each(cls, function(c){
19549 _this.picker().setTop(_this.inputEl().getHeight());
19553 _this.picker().setTop(0 - _this.picker().getHeight());
19558 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19562 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19569 onFocus : function()
19571 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19575 onBlur : function()
19577 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19583 this.picker().show();
19588 this.fireEvent('show', this, this.date);
19593 this.picker().hide();
19596 this.fireEvent('hide', this, this.date);
19599 setTime : function()
19602 this.setValue(this.time.format(this.format));
19604 this.fireEvent('select', this, this.date);
19609 onMousedown: function(e){
19610 e.stopPropagation();
19611 e.preventDefault();
19614 onIncrementHours: function()
19616 Roo.log('onIncrementHours');
19617 this.time = this.time.add(Date.HOUR, 1);
19622 onDecrementHours: function()
19624 Roo.log('onDecrementHours');
19625 this.time = this.time.add(Date.HOUR, -1);
19629 onIncrementMinutes: function()
19631 Roo.log('onIncrementMinutes');
19632 this.time = this.time.add(Date.MINUTE, 1);
19636 onDecrementMinutes: function()
19638 Roo.log('onDecrementMinutes');
19639 this.time = this.time.add(Date.MINUTE, -1);
19643 onTogglePeriod: function()
19645 Roo.log('onTogglePeriod');
19646 this.time = this.time.add(Date.HOUR, 12);
19653 Roo.apply(Roo.bootstrap.TimeField, {
19683 cls: 'btn btn-info ok',
19695 Roo.apply(Roo.bootstrap.TimeField, {
19699 cls: 'datepicker dropdown-menu',
19703 cls: 'datepicker-time',
19707 cls: 'table-condensed',
19709 Roo.bootstrap.TimeField.content,
19710 Roo.bootstrap.TimeField.footer
19729 * @class Roo.bootstrap.MonthField
19730 * @extends Roo.bootstrap.Input
19731 * Bootstrap MonthField class
19733 * @cfg {String} language default en
19736 * Create a new MonthField
19737 * @param {Object} config The config object
19740 Roo.bootstrap.MonthField = function(config){
19741 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19746 * Fires when this field show.
19747 * @param {Roo.bootstrap.MonthField} this
19748 * @param {Mixed} date The date value
19753 * Fires when this field hide.
19754 * @param {Roo.bootstrap.MonthField} this
19755 * @param {Mixed} date The date value
19760 * Fires when select a date.
19761 * @param {Roo.bootstrap.MonthField} this
19762 * @param {String} oldvalue The old value
19763 * @param {String} newvalue The new value
19769 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19771 onRender: function(ct, position)
19774 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19776 this.language = this.language || 'en';
19777 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19778 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19780 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19781 this.isInline = false;
19782 this.isInput = true;
19783 this.component = this.el.select('.add-on', true).first() || false;
19784 this.component = (this.component && this.component.length === 0) ? false : this.component;
19785 this.hasInput = this.component && this.inputEL().length;
19787 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19789 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19791 this.picker().on('mousedown', this.onMousedown, this);
19792 this.picker().on('click', this.onClick, this);
19794 this.picker().addClass('datepicker-dropdown');
19796 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19797 v.setStyle('width', '189px');
19804 if(this.isInline) {
19810 setValue: function(v, suppressEvent)
19812 var o = this.getValue();
19814 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19818 if(suppressEvent !== true){
19819 this.fireEvent('select', this, o, v);
19824 getValue: function()
19829 onClick: function(e)
19831 e.stopPropagation();
19832 e.preventDefault();
19834 var target = e.getTarget();
19836 if(target.nodeName.toLowerCase() === 'i'){
19837 target = Roo.get(target).dom.parentNode;
19840 var nodeName = target.nodeName;
19841 var className = target.className;
19842 var html = target.innerHTML;
19844 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19848 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19850 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19856 picker : function()
19858 return this.pickerEl;
19861 fillMonths: function()
19864 var months = this.picker().select('>.datepicker-months td', true).first();
19866 months.dom.innerHTML = '';
19872 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19875 months.createChild(month);
19884 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19885 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19888 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19889 e.removeClass('active');
19891 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19892 e.addClass('active');
19899 if(this.isInline) {
19903 this.picker().removeClass(['bottom', 'top']);
19905 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19907 * place to the top of element!
19911 this.picker().addClass('top');
19912 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19917 this.picker().addClass('bottom');
19919 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19922 onFocus : function()
19924 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19928 onBlur : function()
19930 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19932 var d = this.inputEl().getValue();
19941 this.picker().show();
19942 this.picker().select('>.datepicker-months', true).first().show();
19946 this.fireEvent('show', this, this.date);
19951 if(this.isInline) {
19954 this.picker().hide();
19955 this.fireEvent('hide', this, this.date);
19959 onMousedown: function(e)
19961 e.stopPropagation();
19962 e.preventDefault();
19967 Roo.bootstrap.MonthField.superclass.keyup.call(this);
19971 fireKey: function(e)
19973 if (!this.picker().isVisible()){
19974 if (e.keyCode == 27) {// allow escape to hide and re-show picker
19985 e.preventDefault();
19989 dir = e.keyCode == 37 ? -1 : 1;
19991 this.vIndex = this.vIndex + dir;
19993 if(this.vIndex < 0){
19997 if(this.vIndex > 11){
20001 if(isNaN(this.vIndex)){
20005 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20011 dir = e.keyCode == 38 ? -1 : 1;
20013 this.vIndex = this.vIndex + dir * 4;
20015 if(this.vIndex < 0){
20019 if(this.vIndex > 11){
20023 if(isNaN(this.vIndex)){
20027 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20032 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20033 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20037 e.preventDefault();
20040 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20041 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20057 this.picker().remove();
20062 Roo.apply(Roo.bootstrap.MonthField, {
20081 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20082 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20087 Roo.apply(Roo.bootstrap.MonthField, {
20091 cls: 'datepicker dropdown-menu roo-dynamic',
20095 cls: 'datepicker-months',
20099 cls: 'table-condensed',
20101 Roo.bootstrap.DateField.content
20121 * @class Roo.bootstrap.CheckBox
20122 * @extends Roo.bootstrap.Input
20123 * Bootstrap CheckBox class
20125 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20126 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20127 * @cfg {String} boxLabel The text that appears beside the checkbox
20128 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20129 * @cfg {Boolean} checked initnal the element
20130 * @cfg {Boolean} inline inline the element (default false)
20131 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20134 * Create a new CheckBox
20135 * @param {Object} config The config object
20138 Roo.bootstrap.CheckBox = function(config){
20139 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20144 * Fires when the element is checked or unchecked.
20145 * @param {Roo.bootstrap.CheckBox} this This input
20146 * @param {Boolean} checked The new checked value
20153 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20155 inputType: 'checkbox',
20163 getAutoCreate : function()
20165 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20171 cfg.cls = 'form-group ' + this.inputType; //input-group
20174 cfg.cls += ' ' + this.inputType + '-inline';
20180 type : this.inputType,
20181 value : this.inputValue,
20182 cls : 'roo-' + this.inputType, //'form-box',
20183 placeholder : this.placeholder || ''
20187 if(this.inputType != 'radio'){
20191 cls : 'roo-hidden-value',
20192 value : this.checked ? this.valueOff : this.inputValue
20197 if (this.weight) { // Validity check?
20198 cfg.cls += " " + this.inputType + "-" + this.weight;
20201 if (this.disabled) {
20202 input.disabled=true;
20206 input.checked = this.checked;
20213 input.name = this.name;
20215 if(this.inputType != 'radio'){
20216 hidden.name = this.name;
20217 input.name = '_hidden_' + this.name;
20222 input.cls += ' input-' + this.size;
20227 ['xs','sm','md','lg'].map(function(size){
20228 if (settings[size]) {
20229 cfg.cls += ' col-' + size + '-' + settings[size];
20233 var inputblock = input;
20235 if (this.before || this.after) {
20238 cls : 'input-group',
20243 inputblock.cn.push({
20245 cls : 'input-group-addon',
20250 inputblock.cn.push(input);
20252 if(this.inputType != 'radio'){
20253 inputblock.cn.push(hidden);
20257 inputblock.cn.push({
20259 cls : 'input-group-addon',
20266 if (align ==='left' && this.fieldLabel.length) {
20267 // Roo.log("left and has label");
20272 cls : 'control-label',
20273 html : this.fieldLabel
20284 if(this.labelWidth > 12){
20285 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20288 if(this.labelWidth < 13 && this.labelmd == 0){
20289 this.labelmd = this.labelWidth;
20292 if(this.labellg > 0){
20293 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20294 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20297 if(this.labelmd > 0){
20298 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20299 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20302 if(this.labelsm > 0){
20303 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20304 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20307 if(this.labelxs > 0){
20308 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20309 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20312 } else if ( this.fieldLabel.length) {
20313 // Roo.log(" label");
20317 tag: this.boxLabel ? 'span' : 'label',
20319 cls: 'control-label box-input-label',
20320 //cls : 'input-group-addon',
20321 html : this.fieldLabel
20331 // Roo.log(" no label && no align");
20332 cfg.cn = [ inputblock ] ;
20338 var boxLabelCfg = {
20340 //'for': id, // box label is handled by onclick - so no for...
20342 html: this.boxLabel
20346 boxLabelCfg.tooltip = this.tooltip;
20349 cfg.cn.push(boxLabelCfg);
20352 if(this.inputType != 'radio'){
20353 cfg.cn.push(hidden);
20361 * return the real input element.
20363 inputEl: function ()
20365 return this.el.select('input.roo-' + this.inputType,true).first();
20367 hiddenEl: function ()
20369 return this.el.select('input.roo-hidden-value',true).first();
20372 labelEl: function()
20374 return this.el.select('label.control-label',true).first();
20376 /* depricated... */
20380 return this.labelEl();
20383 boxLabelEl: function()
20385 return this.el.select('label.box-label',true).first();
20388 initEvents : function()
20390 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20392 this.inputEl().on('click', this.onClick, this);
20394 if (this.boxLabel) {
20395 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20398 this.startValue = this.getValue();
20401 Roo.bootstrap.CheckBox.register(this);
20405 onClick : function()
20407 this.setChecked(!this.checked);
20410 setChecked : function(state,suppressEvent)
20412 this.startValue = this.getValue();
20414 if(this.inputType == 'radio'){
20416 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20417 e.dom.checked = false;
20420 this.inputEl().dom.checked = true;
20422 this.inputEl().dom.value = this.inputValue;
20424 if(suppressEvent !== true){
20425 this.fireEvent('check', this, true);
20433 this.checked = state;
20435 this.inputEl().dom.checked = state;
20438 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20440 if(suppressEvent !== true){
20441 this.fireEvent('check', this, state);
20447 getValue : function()
20449 if(this.inputType == 'radio'){
20450 return this.getGroupValue();
20453 return this.hiddenEl().dom.value;
20457 getGroupValue : function()
20459 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20463 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20466 setValue : function(v,suppressEvent)
20468 if(this.inputType == 'radio'){
20469 this.setGroupValue(v, suppressEvent);
20473 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20478 setGroupValue : function(v, suppressEvent)
20480 this.startValue = this.getValue();
20482 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20483 e.dom.checked = false;
20485 if(e.dom.value == v){
20486 e.dom.checked = true;
20490 if(suppressEvent !== true){
20491 this.fireEvent('check', this, true);
20499 validate : function()
20503 (this.inputType == 'radio' && this.validateRadio()) ||
20504 (this.inputType == 'checkbox' && this.validateCheckbox())
20510 this.markInvalid();
20514 validateRadio : function()
20516 if(this.allowBlank){
20522 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20523 if(!e.dom.checked){
20535 validateCheckbox : function()
20538 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20539 //return (this.getValue() == this.inputValue) ? true : false;
20542 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20550 for(var i in group){
20555 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20562 * Mark this field as valid
20564 markValid : function()
20568 this.fireEvent('valid', this);
20570 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20573 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20580 if(this.inputType == 'radio'){
20581 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20582 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20583 e.findParent('.form-group', false, true).addClass(_this.validClass);
20590 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20591 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20595 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20601 for(var i in group){
20602 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20603 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20608 * Mark this field as invalid
20609 * @param {String} msg The validation message
20611 markInvalid : function(msg)
20613 if(this.allowBlank){
20619 this.fireEvent('invalid', this, msg);
20621 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20624 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20628 label.markInvalid();
20631 if(this.inputType == 'radio'){
20632 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20633 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20634 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20641 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20642 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20646 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20652 for(var i in group){
20653 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20654 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20659 clearInvalid : function()
20661 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20663 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20665 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20668 label.iconEl.removeClass(label.validClass);
20669 label.iconEl.removeClass(label.invalidClass);
20673 disable : function()
20675 if(this.inputType != 'radio'){
20676 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20683 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20684 _this.getActionEl().addClass(this.disabledClass);
20685 e.dom.disabled = true;
20689 this.disabled = true;
20690 this.fireEvent("disable", this);
20694 enable : function()
20696 if(this.inputType != 'radio'){
20697 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20704 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20705 _this.getActionEl().removeClass(this.disabledClass);
20706 e.dom.disabled = false;
20710 this.disabled = false;
20711 this.fireEvent("enable", this);
20717 Roo.apply(Roo.bootstrap.CheckBox, {
20722 * register a CheckBox Group
20723 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20725 register : function(checkbox)
20727 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20728 this.groups[checkbox.groupId] = {};
20731 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20735 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20739 * fetch a CheckBox Group based on the group ID
20740 * @param {string} the group ID
20741 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20743 get: function(groupId) {
20744 if (typeof(this.groups[groupId]) == 'undefined') {
20748 return this.groups[groupId] ;
20761 * @class Roo.bootstrap.Radio
20762 * @extends Roo.bootstrap.Component
20763 * Bootstrap Radio class
20764 * @cfg {String} boxLabel - the label associated
20765 * @cfg {String} value - the value of radio
20768 * Create a new Radio
20769 * @param {Object} config The config object
20771 Roo.bootstrap.Radio = function(config){
20772 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20776 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20782 getAutoCreate : function()
20786 cls : 'form-group radio',
20791 html : this.boxLabel
20799 initEvents : function()
20801 this.parent().register(this);
20803 this.el.on('click', this.onClick, this);
20807 onClick : function()
20809 this.setChecked(true);
20812 setChecked : function(state, suppressEvent)
20814 this.parent().setValue(this.value, suppressEvent);
20818 setBoxLabel : function(v)
20823 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20838 * @class Roo.bootstrap.SecurePass
20839 * @extends Roo.bootstrap.Input
20840 * Bootstrap SecurePass class
20844 * Create a new SecurePass
20845 * @param {Object} config The config object
20848 Roo.bootstrap.SecurePass = function (config) {
20849 // these go here, so the translation tool can replace them..
20851 PwdEmpty: "Please type a password, and then retype it to confirm.",
20852 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20853 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20854 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20855 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20856 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20857 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20858 TooWeak: "Your password is Too Weak."
20860 this.meterLabel = "Password strength:";
20861 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20862 this.meterClass = [
20863 "roo-password-meter-tooweak",
20864 "roo-password-meter-weak",
20865 "roo-password-meter-medium",
20866 "roo-password-meter-strong",
20867 "roo-password-meter-grey"
20872 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20875 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20877 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20879 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20880 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20881 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20882 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20883 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20884 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20885 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20895 * @cfg {String/Object} Label for the strength meter (defaults to
20896 * 'Password strength:')
20901 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20902 * ['Weak', 'Medium', 'Strong'])
20905 pwdStrengths: false,
20918 initEvents: function ()
20920 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
20922 if (this.el.is('input[type=password]') && Roo.isSafari) {
20923 this.el.on('keydown', this.SafariOnKeyDown, this);
20926 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
20929 onRender: function (ct, position)
20931 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
20932 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
20933 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
20935 this.trigger.createChild({
20940 cls: 'roo-password-meter-grey col-xs-12',
20943 //width: this.meterWidth + 'px'
20947 cls: 'roo-password-meter-text'
20953 if (this.hideTrigger) {
20954 this.trigger.setDisplayed(false);
20956 this.setSize(this.width || '', this.height || '');
20959 onDestroy: function ()
20961 if (this.trigger) {
20962 this.trigger.removeAllListeners();
20963 this.trigger.remove();
20966 this.wrap.remove();
20968 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
20971 checkStrength: function ()
20973 var pwd = this.inputEl().getValue();
20974 if (pwd == this._lastPwd) {
20979 if (this.ClientSideStrongPassword(pwd)) {
20981 } else if (this.ClientSideMediumPassword(pwd)) {
20983 } else if (this.ClientSideWeakPassword(pwd)) {
20989 Roo.log('strength1: ' + strength);
20991 //var pm = this.trigger.child('div/div/div').dom;
20992 var pm = this.trigger.child('div/div');
20993 pm.removeClass(this.meterClass);
20994 pm.addClass(this.meterClass[strength]);
20997 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
20999 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21001 this._lastPwd = pwd;
21005 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21007 this._lastPwd = '';
21009 var pm = this.trigger.child('div/div');
21010 pm.removeClass(this.meterClass);
21011 pm.addClass('roo-password-meter-grey');
21014 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21017 this.inputEl().dom.type='password';
21020 validateValue: function (value)
21023 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21026 if (value.length == 0) {
21027 if (this.allowBlank) {
21028 this.clearInvalid();
21032 this.markInvalid(this.errors.PwdEmpty);
21033 this.errorMsg = this.errors.PwdEmpty;
21041 if ('[\x21-\x7e]*'.match(value)) {
21042 this.markInvalid(this.errors.PwdBadChar);
21043 this.errorMsg = this.errors.PwdBadChar;
21046 if (value.length < 6) {
21047 this.markInvalid(this.errors.PwdShort);
21048 this.errorMsg = this.errors.PwdShort;
21051 if (value.length > 16) {
21052 this.markInvalid(this.errors.PwdLong);
21053 this.errorMsg = this.errors.PwdLong;
21057 if (this.ClientSideStrongPassword(value)) {
21059 } else if (this.ClientSideMediumPassword(value)) {
21061 } else if (this.ClientSideWeakPassword(value)) {
21068 if (strength < 2) {
21069 //this.markInvalid(this.errors.TooWeak);
21070 this.errorMsg = this.errors.TooWeak;
21075 console.log('strength2: ' + strength);
21077 //var pm = this.trigger.child('div/div/div').dom;
21079 var pm = this.trigger.child('div/div');
21080 pm.removeClass(this.meterClass);
21081 pm.addClass(this.meterClass[strength]);
21083 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21085 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21087 this.errorMsg = '';
21091 CharacterSetChecks: function (type)
21094 this.fResult = false;
21097 isctype: function (character, type)
21100 case this.kCapitalLetter:
21101 if (character >= 'A' && character <= 'Z') {
21106 case this.kSmallLetter:
21107 if (character >= 'a' && character <= 'z') {
21113 if (character >= '0' && character <= '9') {
21118 case this.kPunctuation:
21119 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21130 IsLongEnough: function (pwd, size)
21132 return !(pwd == null || isNaN(size) || pwd.length < size);
21135 SpansEnoughCharacterSets: function (word, nb)
21137 if (!this.IsLongEnough(word, nb))
21142 var characterSetChecks = new Array(
21143 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21144 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21147 for (var index = 0; index < word.length; ++index) {
21148 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21149 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21150 characterSetChecks[nCharSet].fResult = true;
21157 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21158 if (characterSetChecks[nCharSet].fResult) {
21163 if (nCharSets < nb) {
21169 ClientSideStrongPassword: function (pwd)
21171 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21174 ClientSideMediumPassword: function (pwd)
21176 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21179 ClientSideWeakPassword: function (pwd)
21181 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21184 })//<script type="text/javascript">
21187 * Based Ext JS Library 1.1.1
21188 * Copyright(c) 2006-2007, Ext JS, LLC.
21194 * @class Roo.HtmlEditorCore
21195 * @extends Roo.Component
21196 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21198 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21201 Roo.HtmlEditorCore = function(config){
21204 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21209 * @event initialize
21210 * Fires when the editor is fully initialized (including the iframe)
21211 * @param {Roo.HtmlEditorCore} this
21216 * Fires when the editor is first receives the focus. Any insertion must wait
21217 * until after this event.
21218 * @param {Roo.HtmlEditorCore} this
21222 * @event beforesync
21223 * Fires before the textarea is updated with content from the editor iframe. Return false
21224 * to cancel the sync.
21225 * @param {Roo.HtmlEditorCore} this
21226 * @param {String} html
21230 * @event beforepush
21231 * Fires before the iframe editor is updated with content from the textarea. Return false
21232 * to cancel the push.
21233 * @param {Roo.HtmlEditorCore} this
21234 * @param {String} html
21239 * Fires when the textarea is updated with content from the editor iframe.
21240 * @param {Roo.HtmlEditorCore} this
21241 * @param {String} html
21246 * Fires when the iframe editor is updated with content from the textarea.
21247 * @param {Roo.HtmlEditorCore} this
21248 * @param {String} html
21253 * @event editorevent
21254 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21255 * @param {Roo.HtmlEditorCore} this
21261 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21263 // defaults : white / black...
21264 this.applyBlacklists();
21271 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21275 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21281 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21286 * @cfg {Number} height (in pixels)
21290 * @cfg {Number} width (in pixels)
21295 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21298 stylesheets: false,
21303 // private properties
21304 validationEvent : false,
21306 initialized : false,
21308 sourceEditMode : false,
21309 onFocus : Roo.emptyFn,
21311 hideMode:'offsets',
21315 // blacklist + whitelisted elements..
21322 * Protected method that will not generally be called directly. It
21323 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21324 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21326 getDocMarkup : function(){
21330 // inherit styels from page...??
21331 if (this.stylesheets === false) {
21333 Roo.get(document.head).select('style').each(function(node) {
21334 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21337 Roo.get(document.head).select('link').each(function(node) {
21338 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21341 } else if (!this.stylesheets.length) {
21343 st = '<style type="text/css">' +
21344 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21347 st = '<style type="text/css">' +
21352 st += '<style type="text/css">' +
21353 'IMG { cursor: pointer } ' +
21356 var cls = 'roo-htmleditor-body';
21358 if(this.bodyCls.length){
21359 cls += ' ' + this.bodyCls;
21362 return '<html><head>' + st +
21363 //<style type="text/css">' +
21364 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21366 ' </head><body class="' + cls + '"></body></html>';
21370 onRender : function(ct, position)
21373 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21374 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21377 this.el.dom.style.border = '0 none';
21378 this.el.dom.setAttribute('tabIndex', -1);
21379 this.el.addClass('x-hidden hide');
21383 if(Roo.isIE){ // fix IE 1px bogus margin
21384 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21388 this.frameId = Roo.id();
21392 var iframe = this.owner.wrap.createChild({
21394 cls: 'form-control', // bootstrap..
21396 name: this.frameId,
21397 frameBorder : 'no',
21398 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21403 this.iframe = iframe.dom;
21405 this.assignDocWin();
21407 this.doc.designMode = 'on';
21410 this.doc.write(this.getDocMarkup());
21414 var task = { // must defer to wait for browser to be ready
21416 //console.log("run task?" + this.doc.readyState);
21417 this.assignDocWin();
21418 if(this.doc.body || this.doc.readyState == 'complete'){
21420 this.doc.designMode="on";
21424 Roo.TaskMgr.stop(task);
21425 this.initEditor.defer(10, this);
21432 Roo.TaskMgr.start(task);
21437 onResize : function(w, h)
21439 Roo.log('resize: ' +w + ',' + h );
21440 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21444 if(typeof w == 'number'){
21446 this.iframe.style.width = w + 'px';
21448 if(typeof h == 'number'){
21450 this.iframe.style.height = h + 'px';
21452 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21459 * Toggles the editor between standard and source edit mode.
21460 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21462 toggleSourceEdit : function(sourceEditMode){
21464 this.sourceEditMode = sourceEditMode === true;
21466 if(this.sourceEditMode){
21468 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21471 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21472 //this.iframe.className = '';
21475 //this.setSize(this.owner.wrap.getSize());
21476 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21483 * Protected method that will not generally be called directly. If you need/want
21484 * custom HTML cleanup, this is the method you should override.
21485 * @param {String} html The HTML to be cleaned
21486 * return {String} The cleaned HTML
21488 cleanHtml : function(html){
21489 html = String(html);
21490 if(html.length > 5){
21491 if(Roo.isSafari){ // strip safari nonsense
21492 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21495 if(html == ' '){
21502 * HTML Editor -> Textarea
21503 * Protected method that will not generally be called directly. Syncs the contents
21504 * of the editor iframe with the textarea.
21506 syncValue : function(){
21507 if(this.initialized){
21508 var bd = (this.doc.body || this.doc.documentElement);
21509 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21510 var html = bd.innerHTML;
21512 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21513 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21515 html = '<div style="'+m[0]+'">' + html + '</div>';
21518 html = this.cleanHtml(html);
21519 // fix up the special chars.. normaly like back quotes in word...
21520 // however we do not want to do this with chinese..
21521 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21522 var cc = b.charCodeAt();
21524 (cc >= 0x4E00 && cc < 0xA000 ) ||
21525 (cc >= 0x3400 && cc < 0x4E00 ) ||
21526 (cc >= 0xf900 && cc < 0xfb00 )
21532 if(this.owner.fireEvent('beforesync', this, html) !== false){
21533 this.el.dom.value = html;
21534 this.owner.fireEvent('sync', this, html);
21540 * Protected method that will not generally be called directly. Pushes the value of the textarea
21541 * into the iframe editor.
21543 pushValue : function(){
21544 if(this.initialized){
21545 var v = this.el.dom.value.trim();
21547 // if(v.length < 1){
21551 if(this.owner.fireEvent('beforepush', this, v) !== false){
21552 var d = (this.doc.body || this.doc.documentElement);
21554 this.cleanUpPaste();
21555 this.el.dom.value = d.innerHTML;
21556 this.owner.fireEvent('push', this, v);
21562 deferFocus : function(){
21563 this.focus.defer(10, this);
21567 focus : function(){
21568 if(this.win && !this.sourceEditMode){
21575 assignDocWin: function()
21577 var iframe = this.iframe;
21580 this.doc = iframe.contentWindow.document;
21581 this.win = iframe.contentWindow;
21583 // if (!Roo.get(this.frameId)) {
21586 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21587 // this.win = Roo.get(this.frameId).dom.contentWindow;
21589 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21593 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21594 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21599 initEditor : function(){
21600 //console.log("INIT EDITOR");
21601 this.assignDocWin();
21605 this.doc.designMode="on";
21607 this.doc.write(this.getDocMarkup());
21610 var dbody = (this.doc.body || this.doc.documentElement);
21611 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21612 // this copies styles from the containing element into thsi one..
21613 // not sure why we need all of this..
21614 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21616 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21617 //ss['background-attachment'] = 'fixed'; // w3c
21618 dbody.bgProperties = 'fixed'; // ie
21619 //Roo.DomHelper.applyStyles(dbody, ss);
21620 Roo.EventManager.on(this.doc, {
21621 //'mousedown': this.onEditorEvent,
21622 'mouseup': this.onEditorEvent,
21623 'dblclick': this.onEditorEvent,
21624 'click': this.onEditorEvent,
21625 'keyup': this.onEditorEvent,
21630 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21632 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21633 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21635 this.initialized = true;
21637 this.owner.fireEvent('initialize', this);
21642 onDestroy : function(){
21648 //for (var i =0; i < this.toolbars.length;i++) {
21649 // // fixme - ask toolbars for heights?
21650 // this.toolbars[i].onDestroy();
21653 //this.wrap.dom.innerHTML = '';
21654 //this.wrap.remove();
21659 onFirstFocus : function(){
21661 this.assignDocWin();
21664 this.activated = true;
21667 if(Roo.isGecko){ // prevent silly gecko errors
21669 var s = this.win.getSelection();
21670 if(!s.focusNode || s.focusNode.nodeType != 3){
21671 var r = s.getRangeAt(0);
21672 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21677 this.execCmd('useCSS', true);
21678 this.execCmd('styleWithCSS', false);
21681 this.owner.fireEvent('activate', this);
21685 adjustFont: function(btn){
21686 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21687 //if(Roo.isSafari){ // safari
21690 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21691 if(Roo.isSafari){ // safari
21692 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21693 v = (v < 10) ? 10 : v;
21694 v = (v > 48) ? 48 : v;
21695 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21700 v = Math.max(1, v+adjust);
21702 this.execCmd('FontSize', v );
21705 onEditorEvent : function(e)
21707 this.owner.fireEvent('editorevent', this, e);
21708 // this.updateToolbar();
21709 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21712 insertTag : function(tg)
21714 // could be a bit smarter... -> wrap the current selected tRoo..
21715 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21717 range = this.createRange(this.getSelection());
21718 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21719 wrappingNode.appendChild(range.extractContents());
21720 range.insertNode(wrappingNode);
21727 this.execCmd("formatblock", tg);
21731 insertText : function(txt)
21735 var range = this.createRange();
21736 range.deleteContents();
21737 //alert(Sender.getAttribute('label'));
21739 range.insertNode(this.doc.createTextNode(txt));
21745 * Executes a Midas editor command on the editor document and performs necessary focus and
21746 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21747 * @param {String} cmd The Midas command
21748 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21750 relayCmd : function(cmd, value){
21752 this.execCmd(cmd, value);
21753 this.owner.fireEvent('editorevent', this);
21754 //this.updateToolbar();
21755 this.owner.deferFocus();
21759 * Executes a Midas editor command directly on the editor document.
21760 * For visual commands, you should use {@link #relayCmd} instead.
21761 * <b>This should only be called after the editor is initialized.</b>
21762 * @param {String} cmd The Midas command
21763 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21765 execCmd : function(cmd, value){
21766 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21773 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21775 * @param {String} text | dom node..
21777 insertAtCursor : function(text)
21780 if(!this.activated){
21786 var r = this.doc.selection.createRange();
21797 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21801 // from jquery ui (MIT licenced)
21803 var win = this.win;
21805 if (win.getSelection && win.getSelection().getRangeAt) {
21806 range = win.getSelection().getRangeAt(0);
21807 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21808 range.insertNode(node);
21809 } else if (win.document.selection && win.document.selection.createRange) {
21810 // no firefox support
21811 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21812 win.document.selection.createRange().pasteHTML(txt);
21814 // no firefox support
21815 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21816 this.execCmd('InsertHTML', txt);
21825 mozKeyPress : function(e){
21827 var c = e.getCharCode(), cmd;
21830 c = String.fromCharCode(c).toLowerCase();
21844 this.cleanUpPaste.defer(100, this);
21852 e.preventDefault();
21860 fixKeys : function(){ // load time branching for fastest keydown performance
21862 return function(e){
21863 var k = e.getKey(), r;
21866 r = this.doc.selection.createRange();
21869 r.pasteHTML('    ');
21876 r = this.doc.selection.createRange();
21878 var target = r.parentElement();
21879 if(!target || target.tagName.toLowerCase() != 'li'){
21881 r.pasteHTML('<br />');
21887 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21888 this.cleanUpPaste.defer(100, this);
21894 }else if(Roo.isOpera){
21895 return function(e){
21896 var k = e.getKey();
21900 this.execCmd('InsertHTML','    ');
21903 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21904 this.cleanUpPaste.defer(100, this);
21909 }else if(Roo.isSafari){
21910 return function(e){
21911 var k = e.getKey();
21915 this.execCmd('InsertText','\t');
21919 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21920 this.cleanUpPaste.defer(100, this);
21928 getAllAncestors: function()
21930 var p = this.getSelectedNode();
21933 a.push(p); // push blank onto stack..
21934 p = this.getParentElement();
21938 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
21942 a.push(this.doc.body);
21946 lastSelNode : false,
21949 getSelection : function()
21951 this.assignDocWin();
21952 return Roo.isIE ? this.doc.selection : this.win.getSelection();
21955 getSelectedNode: function()
21957 // this may only work on Gecko!!!
21959 // should we cache this!!!!
21964 var range = this.createRange(this.getSelection()).cloneRange();
21967 var parent = range.parentElement();
21969 var testRange = range.duplicate();
21970 testRange.moveToElementText(parent);
21971 if (testRange.inRange(range)) {
21974 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
21977 parent = parent.parentElement;
21982 // is ancestor a text element.
21983 var ac = range.commonAncestorContainer;
21984 if (ac.nodeType == 3) {
21985 ac = ac.parentNode;
21988 var ar = ac.childNodes;
21991 var other_nodes = [];
21992 var has_other_nodes = false;
21993 for (var i=0;i<ar.length;i++) {
21994 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
21997 // fullly contained node.
21999 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22004 // probably selected..
22005 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22006 other_nodes.push(ar[i]);
22010 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22015 has_other_nodes = true;
22017 if (!nodes.length && other_nodes.length) {
22018 nodes= other_nodes;
22020 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22026 createRange: function(sel)
22028 // this has strange effects when using with
22029 // top toolbar - not sure if it's a great idea.
22030 //this.editor.contentWindow.focus();
22031 if (typeof sel != "undefined") {
22033 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22035 return this.doc.createRange();
22038 return this.doc.createRange();
22041 getParentElement: function()
22044 this.assignDocWin();
22045 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22047 var range = this.createRange(sel);
22050 var p = range.commonAncestorContainer;
22051 while (p.nodeType == 3) { // text node
22062 * Range intersection.. the hard stuff...
22066 * [ -- selected range --- ]
22070 * if end is before start or hits it. fail.
22071 * if start is after end or hits it fail.
22073 * if either hits (but other is outside. - then it's not
22079 // @see http://www.thismuchiknow.co.uk/?p=64.
22080 rangeIntersectsNode : function(range, node)
22082 var nodeRange = node.ownerDocument.createRange();
22084 nodeRange.selectNode(node);
22086 nodeRange.selectNodeContents(node);
22089 var rangeStartRange = range.cloneRange();
22090 rangeStartRange.collapse(true);
22092 var rangeEndRange = range.cloneRange();
22093 rangeEndRange.collapse(false);
22095 var nodeStartRange = nodeRange.cloneRange();
22096 nodeStartRange.collapse(true);
22098 var nodeEndRange = nodeRange.cloneRange();
22099 nodeEndRange.collapse(false);
22101 return rangeStartRange.compareBoundaryPoints(
22102 Range.START_TO_START, nodeEndRange) == -1 &&
22103 rangeEndRange.compareBoundaryPoints(
22104 Range.START_TO_START, nodeStartRange) == 1;
22108 rangeCompareNode : function(range, node)
22110 var nodeRange = node.ownerDocument.createRange();
22112 nodeRange.selectNode(node);
22114 nodeRange.selectNodeContents(node);
22118 range.collapse(true);
22120 nodeRange.collapse(true);
22122 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22123 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22125 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22127 var nodeIsBefore = ss == 1;
22128 var nodeIsAfter = ee == -1;
22130 if (nodeIsBefore && nodeIsAfter) {
22133 if (!nodeIsBefore && nodeIsAfter) {
22134 return 1; //right trailed.
22137 if (nodeIsBefore && !nodeIsAfter) {
22138 return 2; // left trailed.
22144 // private? - in a new class?
22145 cleanUpPaste : function()
22147 // cleans up the whole document..
22148 Roo.log('cleanuppaste');
22150 this.cleanUpChildren(this.doc.body);
22151 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22152 if (clean != this.doc.body.innerHTML) {
22153 this.doc.body.innerHTML = clean;
22158 cleanWordChars : function(input) {// change the chars to hex code
22159 var he = Roo.HtmlEditorCore;
22161 var output = input;
22162 Roo.each(he.swapCodes, function(sw) {
22163 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22165 output = output.replace(swapper, sw[1]);
22172 cleanUpChildren : function (n)
22174 if (!n.childNodes.length) {
22177 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22178 this.cleanUpChild(n.childNodes[i]);
22185 cleanUpChild : function (node)
22188 //console.log(node);
22189 if (node.nodeName == "#text") {
22190 // clean up silly Windows -- stuff?
22193 if (node.nodeName == "#comment") {
22194 node.parentNode.removeChild(node);
22195 // clean up silly Windows -- stuff?
22198 var lcname = node.tagName.toLowerCase();
22199 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22200 // whitelist of tags..
22202 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22204 node.parentNode.removeChild(node);
22209 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22211 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22212 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22214 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22215 // remove_keep_children = true;
22218 if (remove_keep_children) {
22219 this.cleanUpChildren(node);
22220 // inserts everything just before this node...
22221 while (node.childNodes.length) {
22222 var cn = node.childNodes[0];
22223 node.removeChild(cn);
22224 node.parentNode.insertBefore(cn, node);
22226 node.parentNode.removeChild(node);
22230 if (!node.attributes || !node.attributes.length) {
22231 this.cleanUpChildren(node);
22235 function cleanAttr(n,v)
22238 if (v.match(/^\./) || v.match(/^\//)) {
22241 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22244 if (v.match(/^#/)) {
22247 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22248 node.removeAttribute(n);
22252 var cwhite = this.cwhite;
22253 var cblack = this.cblack;
22255 function cleanStyle(n,v)
22257 if (v.match(/expression/)) { //XSS?? should we even bother..
22258 node.removeAttribute(n);
22262 var parts = v.split(/;/);
22265 Roo.each(parts, function(p) {
22266 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22270 var l = p.split(':').shift().replace(/\s+/g,'');
22271 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22273 if ( cwhite.length && cblack.indexOf(l) > -1) {
22274 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22275 //node.removeAttribute(n);
22279 // only allow 'c whitelisted system attributes'
22280 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22281 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22282 //node.removeAttribute(n);
22292 if (clean.length) {
22293 node.setAttribute(n, clean.join(';'));
22295 node.removeAttribute(n);
22301 for (var i = node.attributes.length-1; i > -1 ; i--) {
22302 var a = node.attributes[i];
22305 if (a.name.toLowerCase().substr(0,2)=='on') {
22306 node.removeAttribute(a.name);
22309 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22310 node.removeAttribute(a.name);
22313 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22314 cleanAttr(a.name,a.value); // fixme..
22317 if (a.name == 'style') {
22318 cleanStyle(a.name,a.value);
22321 /// clean up MS crap..
22322 // tecnically this should be a list of valid class'es..
22325 if (a.name == 'class') {
22326 if (a.value.match(/^Mso/)) {
22327 node.className = '';
22330 if (a.value.match(/^body$/)) {
22331 node.className = '';
22342 this.cleanUpChildren(node);
22348 * Clean up MS wordisms...
22350 cleanWord : function(node)
22355 this.cleanWord(this.doc.body);
22358 if (node.nodeName == "#text") {
22359 // clean up silly Windows -- stuff?
22362 if (node.nodeName == "#comment") {
22363 node.parentNode.removeChild(node);
22364 // clean up silly Windows -- stuff?
22368 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22369 node.parentNode.removeChild(node);
22373 // remove - but keep children..
22374 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22375 while (node.childNodes.length) {
22376 var cn = node.childNodes[0];
22377 node.removeChild(cn);
22378 node.parentNode.insertBefore(cn, node);
22380 node.parentNode.removeChild(node);
22381 this.iterateChildren(node, this.cleanWord);
22385 if (node.className.length) {
22387 var cn = node.className.split(/\W+/);
22389 Roo.each(cn, function(cls) {
22390 if (cls.match(/Mso[a-zA-Z]+/)) {
22395 node.className = cna.length ? cna.join(' ') : '';
22397 node.removeAttribute("class");
22401 if (node.hasAttribute("lang")) {
22402 node.removeAttribute("lang");
22405 if (node.hasAttribute("style")) {
22407 var styles = node.getAttribute("style").split(";");
22409 Roo.each(styles, function(s) {
22410 if (!s.match(/:/)) {
22413 var kv = s.split(":");
22414 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22417 // what ever is left... we allow.
22420 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22421 if (!nstyle.length) {
22422 node.removeAttribute('style');
22425 this.iterateChildren(node, this.cleanWord);
22431 * iterateChildren of a Node, calling fn each time, using this as the scole..
22432 * @param {DomNode} node node to iterate children of.
22433 * @param {Function} fn method of this class to call on each item.
22435 iterateChildren : function(node, fn)
22437 if (!node.childNodes.length) {
22440 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22441 fn.call(this, node.childNodes[i])
22447 * cleanTableWidths.
22449 * Quite often pasting from word etc.. results in tables with column and widths.
22450 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22453 cleanTableWidths : function(node)
22458 this.cleanTableWidths(this.doc.body);
22463 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22466 Roo.log(node.tagName);
22467 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22468 this.iterateChildren(node, this.cleanTableWidths);
22471 if (node.hasAttribute('width')) {
22472 node.removeAttribute('width');
22476 if (node.hasAttribute("style")) {
22479 var styles = node.getAttribute("style").split(";");
22481 Roo.each(styles, function(s) {
22482 if (!s.match(/:/)) {
22485 var kv = s.split(":");
22486 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22489 // what ever is left... we allow.
22492 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22493 if (!nstyle.length) {
22494 node.removeAttribute('style');
22498 this.iterateChildren(node, this.cleanTableWidths);
22506 domToHTML : function(currentElement, depth, nopadtext) {
22508 depth = depth || 0;
22509 nopadtext = nopadtext || false;
22511 if (!currentElement) {
22512 return this.domToHTML(this.doc.body);
22515 //Roo.log(currentElement);
22517 var allText = false;
22518 var nodeName = currentElement.nodeName;
22519 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22521 if (nodeName == '#text') {
22523 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22528 if (nodeName != 'BODY') {
22531 // Prints the node tagName, such as <A>, <IMG>, etc
22534 for(i = 0; i < currentElement.attributes.length;i++) {
22536 var aname = currentElement.attributes.item(i).name;
22537 if (!currentElement.attributes.item(i).value.length) {
22540 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22543 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22552 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22555 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22560 // Traverse the tree
22562 var currentElementChild = currentElement.childNodes.item(i);
22563 var allText = true;
22564 var innerHTML = '';
22566 while (currentElementChild) {
22567 // Formatting code (indent the tree so it looks nice on the screen)
22568 var nopad = nopadtext;
22569 if (lastnode == 'SPAN') {
22573 if (currentElementChild.nodeName == '#text') {
22574 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22575 toadd = nopadtext ? toadd : toadd.trim();
22576 if (!nopad && toadd.length > 80) {
22577 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22579 innerHTML += toadd;
22582 currentElementChild = currentElement.childNodes.item(i);
22588 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22590 // Recursively traverse the tree structure of the child node
22591 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22592 lastnode = currentElementChild.nodeName;
22594 currentElementChild=currentElement.childNodes.item(i);
22600 // The remaining code is mostly for formatting the tree
22601 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22606 ret+= "</"+tagName+">";
22612 applyBlacklists : function()
22614 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22615 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22619 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22620 if (b.indexOf(tag) > -1) {
22623 this.white.push(tag);
22627 Roo.each(w, function(tag) {
22628 if (b.indexOf(tag) > -1) {
22631 if (this.white.indexOf(tag) > -1) {
22634 this.white.push(tag);
22639 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22640 if (w.indexOf(tag) > -1) {
22643 this.black.push(tag);
22647 Roo.each(b, function(tag) {
22648 if (w.indexOf(tag) > -1) {
22651 if (this.black.indexOf(tag) > -1) {
22654 this.black.push(tag);
22659 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22660 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22664 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22665 if (b.indexOf(tag) > -1) {
22668 this.cwhite.push(tag);
22672 Roo.each(w, function(tag) {
22673 if (b.indexOf(tag) > -1) {
22676 if (this.cwhite.indexOf(tag) > -1) {
22679 this.cwhite.push(tag);
22684 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22685 if (w.indexOf(tag) > -1) {
22688 this.cblack.push(tag);
22692 Roo.each(b, function(tag) {
22693 if (w.indexOf(tag) > -1) {
22696 if (this.cblack.indexOf(tag) > -1) {
22699 this.cblack.push(tag);
22704 setStylesheets : function(stylesheets)
22706 if(typeof(stylesheets) == 'string'){
22707 Roo.get(this.iframe.contentDocument.head).createChild({
22709 rel : 'stylesheet',
22718 Roo.each(stylesheets, function(s) {
22723 Roo.get(_this.iframe.contentDocument.head).createChild({
22725 rel : 'stylesheet',
22734 removeStylesheets : function()
22738 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22743 setStyle : function(style)
22745 Roo.get(this.iframe.contentDocument.head).createChild({
22754 // hide stuff that is not compatible
22768 * @event specialkey
22772 * @cfg {String} fieldClass @hide
22775 * @cfg {String} focusClass @hide
22778 * @cfg {String} autoCreate @hide
22781 * @cfg {String} inputType @hide
22784 * @cfg {String} invalidClass @hide
22787 * @cfg {String} invalidText @hide
22790 * @cfg {String} msgFx @hide
22793 * @cfg {String} validateOnBlur @hide
22797 Roo.HtmlEditorCore.white = [
22798 'area', 'br', 'img', 'input', 'hr', 'wbr',
22800 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22801 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22802 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22803 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22804 'table', 'ul', 'xmp',
22806 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22809 'dir', 'menu', 'ol', 'ul', 'dl',
22815 Roo.HtmlEditorCore.black = [
22816 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22818 'base', 'basefont', 'bgsound', 'blink', 'body',
22819 'frame', 'frameset', 'head', 'html', 'ilayer',
22820 'iframe', 'layer', 'link', 'meta', 'object',
22821 'script', 'style' ,'title', 'xml' // clean later..
22823 Roo.HtmlEditorCore.clean = [
22824 'script', 'style', 'title', 'xml'
22826 Roo.HtmlEditorCore.remove = [
22831 Roo.HtmlEditorCore.ablack = [
22835 Roo.HtmlEditorCore.aclean = [
22836 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22840 Roo.HtmlEditorCore.pwhite= [
22841 'http', 'https', 'mailto'
22844 // white listed style attributes.
22845 Roo.HtmlEditorCore.cwhite= [
22846 // 'text-align', /// default is to allow most things..
22852 // black listed style attributes.
22853 Roo.HtmlEditorCore.cblack= [
22854 // 'font-size' -- this can be set by the project
22858 Roo.HtmlEditorCore.swapCodes =[
22877 * @class Roo.bootstrap.HtmlEditor
22878 * @extends Roo.bootstrap.TextArea
22879 * Bootstrap HtmlEditor class
22882 * Create a new HtmlEditor
22883 * @param {Object} config The config object
22886 Roo.bootstrap.HtmlEditor = function(config){
22887 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22888 if (!this.toolbars) {
22889 this.toolbars = [];
22892 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22895 * @event initialize
22896 * Fires when the editor is fully initialized (including the iframe)
22897 * @param {HtmlEditor} this
22902 * Fires when the editor is first receives the focus. Any insertion must wait
22903 * until after this event.
22904 * @param {HtmlEditor} this
22908 * @event beforesync
22909 * Fires before the textarea is updated with content from the editor iframe. Return false
22910 * to cancel the sync.
22911 * @param {HtmlEditor} this
22912 * @param {String} html
22916 * @event beforepush
22917 * Fires before the iframe editor is updated with content from the textarea. Return false
22918 * to cancel the push.
22919 * @param {HtmlEditor} this
22920 * @param {String} html
22925 * Fires when the textarea is updated with content from the editor iframe.
22926 * @param {HtmlEditor} this
22927 * @param {String} html
22932 * Fires when the iframe editor is updated with content from the textarea.
22933 * @param {HtmlEditor} this
22934 * @param {String} html
22938 * @event editmodechange
22939 * Fires when the editor switches edit modes
22940 * @param {HtmlEditor} this
22941 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
22943 editmodechange: true,
22945 * @event editorevent
22946 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22947 * @param {HtmlEditor} this
22951 * @event firstfocus
22952 * Fires when on first focus - needed by toolbars..
22953 * @param {HtmlEditor} this
22958 * Auto save the htmlEditor value as a file into Events
22959 * @param {HtmlEditor} this
22963 * @event savedpreview
22964 * preview the saved version of htmlEditor
22965 * @param {HtmlEditor} this
22972 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
22976 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
22981 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
22986 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22991 * @cfg {Number} height (in pixels)
22995 * @cfg {Number} width (in pixels)
23000 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23003 stylesheets: false,
23008 // private properties
23009 validationEvent : false,
23011 initialized : false,
23014 onFocus : Roo.emptyFn,
23016 hideMode:'offsets',
23018 tbContainer : false,
23022 toolbarContainer :function() {
23023 return this.wrap.select('.x-html-editor-tb',true).first();
23027 * Protected method that will not generally be called directly. It
23028 * is called when the editor creates its toolbar. Override this method if you need to
23029 * add custom toolbar buttons.
23030 * @param {HtmlEditor} editor
23032 createToolbar : function(){
23033 Roo.log('renewing');
23034 Roo.log("create toolbars");
23036 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23037 this.toolbars[0].render(this.toolbarContainer());
23041 // if (!editor.toolbars || !editor.toolbars.length) {
23042 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23045 // for (var i =0 ; i < editor.toolbars.length;i++) {
23046 // editor.toolbars[i] = Roo.factory(
23047 // typeof(editor.toolbars[i]) == 'string' ?
23048 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23049 // Roo.bootstrap.HtmlEditor);
23050 // editor.toolbars[i].init(editor);
23056 onRender : function(ct, position)
23058 // Roo.log("Call onRender: " + this.xtype);
23060 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23062 this.wrap = this.inputEl().wrap({
23063 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23066 this.editorcore.onRender(ct, position);
23068 if (this.resizable) {
23069 this.resizeEl = new Roo.Resizable(this.wrap, {
23073 minHeight : this.height,
23074 height: this.height,
23075 handles : this.resizable,
23078 resize : function(r, w, h) {
23079 _t.onResize(w,h); // -something
23085 this.createToolbar(this);
23088 if(!this.width && this.resizable){
23089 this.setSize(this.wrap.getSize());
23091 if (this.resizeEl) {
23092 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23093 // should trigger onReize..
23099 onResize : function(w, h)
23101 Roo.log('resize: ' +w + ',' + h );
23102 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23106 if(this.inputEl() ){
23107 if(typeof w == 'number'){
23108 var aw = w - this.wrap.getFrameWidth('lr');
23109 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23112 if(typeof h == 'number'){
23113 var tbh = -11; // fixme it needs to tool bar size!
23114 for (var i =0; i < this.toolbars.length;i++) {
23115 // fixme - ask toolbars for heights?
23116 tbh += this.toolbars[i].el.getHeight();
23117 //if (this.toolbars[i].footer) {
23118 // tbh += this.toolbars[i].footer.el.getHeight();
23126 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23127 ah -= 5; // knock a few pixes off for look..
23128 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23132 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23133 this.editorcore.onResize(ew,eh);
23138 * Toggles the editor between standard and source edit mode.
23139 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23141 toggleSourceEdit : function(sourceEditMode)
23143 this.editorcore.toggleSourceEdit(sourceEditMode);
23145 if(this.editorcore.sourceEditMode){
23146 Roo.log('editor - showing textarea');
23149 // Roo.log(this.syncValue());
23151 this.inputEl().removeClass(['hide', 'x-hidden']);
23152 this.inputEl().dom.removeAttribute('tabIndex');
23153 this.inputEl().focus();
23155 Roo.log('editor - hiding textarea');
23157 // Roo.log(this.pushValue());
23160 this.inputEl().addClass(['hide', 'x-hidden']);
23161 this.inputEl().dom.setAttribute('tabIndex', -1);
23162 //this.deferFocus();
23165 if(this.resizable){
23166 this.setSize(this.wrap.getSize());
23169 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23172 // private (for BoxComponent)
23173 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23175 // private (for BoxComponent)
23176 getResizeEl : function(){
23180 // private (for BoxComponent)
23181 getPositionEl : function(){
23186 initEvents : function(){
23187 this.originalValue = this.getValue();
23191 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23194 // markInvalid : Roo.emptyFn,
23196 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23199 // clearInvalid : Roo.emptyFn,
23201 setValue : function(v){
23202 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23203 this.editorcore.pushValue();
23208 deferFocus : function(){
23209 this.focus.defer(10, this);
23213 focus : function(){
23214 this.editorcore.focus();
23220 onDestroy : function(){
23226 for (var i =0; i < this.toolbars.length;i++) {
23227 // fixme - ask toolbars for heights?
23228 this.toolbars[i].onDestroy();
23231 this.wrap.dom.innerHTML = '';
23232 this.wrap.remove();
23237 onFirstFocus : function(){
23238 //Roo.log("onFirstFocus");
23239 this.editorcore.onFirstFocus();
23240 for (var i =0; i < this.toolbars.length;i++) {
23241 this.toolbars[i].onFirstFocus();
23247 syncValue : function()
23249 this.editorcore.syncValue();
23252 pushValue : function()
23254 this.editorcore.pushValue();
23258 // hide stuff that is not compatible
23272 * @event specialkey
23276 * @cfg {String} fieldClass @hide
23279 * @cfg {String} focusClass @hide
23282 * @cfg {String} autoCreate @hide
23285 * @cfg {String} inputType @hide
23288 * @cfg {String} invalidClass @hide
23291 * @cfg {String} invalidText @hide
23294 * @cfg {String} msgFx @hide
23297 * @cfg {String} validateOnBlur @hide
23306 Roo.namespace('Roo.bootstrap.htmleditor');
23308 * @class Roo.bootstrap.HtmlEditorToolbar1
23313 new Roo.bootstrap.HtmlEditor({
23316 new Roo.bootstrap.HtmlEditorToolbar1({
23317 disable : { fonts: 1 , format: 1, ..., ... , ...],
23323 * @cfg {Object} disable List of elements to disable..
23324 * @cfg {Array} btns List of additional buttons.
23328 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23331 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23334 Roo.apply(this, config);
23336 // default disabled, based on 'good practice'..
23337 this.disable = this.disable || {};
23338 Roo.applyIf(this.disable, {
23341 specialElements : true
23343 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23345 this.editor = config.editor;
23346 this.editorcore = config.editor.editorcore;
23348 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23350 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23351 // dont call parent... till later.
23353 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23358 editorcore : false,
23363 "h1","h2","h3","h4","h5","h6",
23365 "abbr", "acronym", "address", "cite", "samp", "var",
23369 onRender : function(ct, position)
23371 // Roo.log("Call onRender: " + this.xtype);
23373 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23375 this.el.dom.style.marginBottom = '0';
23377 var editorcore = this.editorcore;
23378 var editor= this.editor;
23381 var btn = function(id,cmd , toggle, handler, html){
23383 var event = toggle ? 'toggle' : 'click';
23388 xns: Roo.bootstrap,
23391 enableToggle:toggle !== false,
23393 pressed : toggle ? false : null,
23396 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23397 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23403 // var cb_box = function...
23408 xns: Roo.bootstrap,
23409 glyphicon : 'font',
23413 xns: Roo.bootstrap,
23417 Roo.each(this.formats, function(f) {
23418 style.menu.items.push({
23420 xns: Roo.bootstrap,
23421 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23426 editorcore.insertTag(this.tagname);
23433 children.push(style);
23435 btn('bold',false,true);
23436 btn('italic',false,true);
23437 btn('align-left', 'justifyleft',true);
23438 btn('align-center', 'justifycenter',true);
23439 btn('align-right' , 'justifyright',true);
23440 btn('link', false, false, function(btn) {
23441 //Roo.log("create link?");
23442 var url = prompt(this.createLinkText, this.defaultLinkValue);
23443 if(url && url != 'http:/'+'/'){
23444 this.editorcore.relayCmd('createlink', url);
23447 btn('list','insertunorderedlist',true);
23448 btn('pencil', false,true, function(btn){
23450 this.toggleSourceEdit(btn.pressed);
23453 if (this.editor.btns.length > 0) {
23454 for (var i = 0; i<this.editor.btns.length; i++) {
23455 children.push(this.editor.btns[i]);
23463 xns: Roo.bootstrap,
23468 xns: Roo.bootstrap,
23473 cog.menu.items.push({
23475 xns: Roo.bootstrap,
23476 html : Clean styles,
23481 editorcore.insertTag(this.tagname);
23490 this.xtype = 'NavSimplebar';
23492 for(var i=0;i< children.length;i++) {
23494 this.buttons.add(this.addxtypeChild(children[i]));
23498 editor.on('editorevent', this.updateToolbar, this);
23500 onBtnClick : function(id)
23502 this.editorcore.relayCmd(id);
23503 this.editorcore.focus();
23507 * Protected method that will not generally be called directly. It triggers
23508 * a toolbar update by reading the markup state of the current selection in the editor.
23510 updateToolbar: function(){
23512 if(!this.editorcore.activated){
23513 this.editor.onFirstFocus(); // is this neeed?
23517 var btns = this.buttons;
23518 var doc = this.editorcore.doc;
23519 btns.get('bold').setActive(doc.queryCommandState('bold'));
23520 btns.get('italic').setActive(doc.queryCommandState('italic'));
23521 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23523 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23524 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23525 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23527 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23528 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23531 var ans = this.editorcore.getAllAncestors();
23532 if (this.formatCombo) {
23535 var store = this.formatCombo.store;
23536 this.formatCombo.setValue("");
23537 for (var i =0; i < ans.length;i++) {
23538 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23540 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23548 // hides menus... - so this cant be on a menu...
23549 Roo.bootstrap.MenuMgr.hideAll();
23551 Roo.bootstrap.MenuMgr.hideAll();
23552 //this.editorsyncValue();
23554 onFirstFocus: function() {
23555 this.buttons.each(function(item){
23559 toggleSourceEdit : function(sourceEditMode){
23562 if(sourceEditMode){
23563 Roo.log("disabling buttons");
23564 this.buttons.each( function(item){
23565 if(item.cmd != 'pencil'){
23571 Roo.log("enabling buttons");
23572 if(this.editorcore.initialized){
23573 this.buttons.each( function(item){
23579 Roo.log("calling toggole on editor");
23580 // tell the editor that it's been pressed..
23581 this.editor.toggleSourceEdit(sourceEditMode);
23591 * @class Roo.bootstrap.Table.AbstractSelectionModel
23592 * @extends Roo.util.Observable
23593 * Abstract base class for grid SelectionModels. It provides the interface that should be
23594 * implemented by descendant classes. This class should not be directly instantiated.
23597 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23598 this.locked = false;
23599 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23603 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23604 /** @ignore Called by the grid automatically. Do not call directly. */
23605 init : function(grid){
23611 * Locks the selections.
23614 this.locked = true;
23618 * Unlocks the selections.
23620 unlock : function(){
23621 this.locked = false;
23625 * Returns true if the selections are locked.
23626 * @return {Boolean}
23628 isLocked : function(){
23629 return this.locked;
23633 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23634 * @class Roo.bootstrap.Table.RowSelectionModel
23635 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23636 * It supports multiple selections and keyboard selection/navigation.
23638 * @param {Object} config
23641 Roo.bootstrap.Table.RowSelectionModel = function(config){
23642 Roo.apply(this, config);
23643 this.selections = new Roo.util.MixedCollection(false, function(o){
23648 this.lastActive = false;
23652 * @event selectionchange
23653 * Fires when the selection changes
23654 * @param {SelectionModel} this
23656 "selectionchange" : true,
23658 * @event afterselectionchange
23659 * Fires after the selection changes (eg. by key press or clicking)
23660 * @param {SelectionModel} this
23662 "afterselectionchange" : true,
23664 * @event beforerowselect
23665 * Fires when a row is selected being selected, return false to cancel.
23666 * @param {SelectionModel} this
23667 * @param {Number} rowIndex The selected index
23668 * @param {Boolean} keepExisting False if other selections will be cleared
23670 "beforerowselect" : true,
23673 * Fires when a row is selected.
23674 * @param {SelectionModel} this
23675 * @param {Number} rowIndex The selected index
23676 * @param {Roo.data.Record} r The record
23678 "rowselect" : true,
23680 * @event rowdeselect
23681 * Fires when a row is deselected.
23682 * @param {SelectionModel} this
23683 * @param {Number} rowIndex The selected index
23685 "rowdeselect" : true
23687 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23688 this.locked = false;
23691 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23693 * @cfg {Boolean} singleSelect
23694 * True to allow selection of only one row at a time (defaults to false)
23696 singleSelect : false,
23699 initEvents : function()
23702 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23703 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23704 //}else{ // allow click to work like normal
23705 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23707 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23708 this.grid.on("rowclick", this.handleMouseDown, this);
23710 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23711 "up" : function(e){
23713 this.selectPrevious(e.shiftKey);
23714 }else if(this.last !== false && this.lastActive !== false){
23715 var last = this.last;
23716 this.selectRange(this.last, this.lastActive-1);
23717 this.grid.getView().focusRow(this.lastActive);
23718 if(last !== false){
23722 this.selectFirstRow();
23724 this.fireEvent("afterselectionchange", this);
23726 "down" : function(e){
23728 this.selectNext(e.shiftKey);
23729 }else if(this.last !== false && this.lastActive !== false){
23730 var last = this.last;
23731 this.selectRange(this.last, this.lastActive+1);
23732 this.grid.getView().focusRow(this.lastActive);
23733 if(last !== false){
23737 this.selectFirstRow();
23739 this.fireEvent("afterselectionchange", this);
23743 this.grid.store.on('load', function(){
23744 this.selections.clear();
23747 var view = this.grid.view;
23748 view.on("refresh", this.onRefresh, this);
23749 view.on("rowupdated", this.onRowUpdated, this);
23750 view.on("rowremoved", this.onRemove, this);
23755 onRefresh : function()
23757 var ds = this.grid.store, i, v = this.grid.view;
23758 var s = this.selections;
23759 s.each(function(r){
23760 if((i = ds.indexOfId(r.id)) != -1){
23769 onRemove : function(v, index, r){
23770 this.selections.remove(r);
23774 onRowUpdated : function(v, index, r){
23775 if(this.isSelected(r)){
23776 v.onRowSelect(index);
23782 * @param {Array} records The records to select
23783 * @param {Boolean} keepExisting (optional) True to keep existing selections
23785 selectRecords : function(records, keepExisting)
23788 this.clearSelections();
23790 var ds = this.grid.store;
23791 for(var i = 0, len = records.length; i < len; i++){
23792 this.selectRow(ds.indexOf(records[i]), true);
23797 * Gets the number of selected rows.
23800 getCount : function(){
23801 return this.selections.length;
23805 * Selects the first row in the grid.
23807 selectFirstRow : function(){
23812 * Select the last row.
23813 * @param {Boolean} keepExisting (optional) True to keep existing selections
23815 selectLastRow : function(keepExisting){
23816 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23817 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23821 * Selects the row immediately following the last selected row.
23822 * @param {Boolean} keepExisting (optional) True to keep existing selections
23824 selectNext : function(keepExisting)
23826 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23827 this.selectRow(this.last+1, keepExisting);
23828 this.grid.getView().focusRow(this.last);
23833 * Selects the row that precedes the last selected row.
23834 * @param {Boolean} keepExisting (optional) True to keep existing selections
23836 selectPrevious : function(keepExisting){
23838 this.selectRow(this.last-1, keepExisting);
23839 this.grid.getView().focusRow(this.last);
23844 * Returns the selected records
23845 * @return {Array} Array of selected records
23847 getSelections : function(){
23848 return [].concat(this.selections.items);
23852 * Returns the first selected record.
23855 getSelected : function(){
23856 return this.selections.itemAt(0);
23861 * Clears all selections.
23863 clearSelections : function(fast)
23869 var ds = this.grid.store;
23870 var s = this.selections;
23871 s.each(function(r){
23872 this.deselectRow(ds.indexOfId(r.id));
23876 this.selections.clear();
23883 * Selects all rows.
23885 selectAll : function(){
23889 this.selections.clear();
23890 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23891 this.selectRow(i, true);
23896 * Returns True if there is a selection.
23897 * @return {Boolean}
23899 hasSelection : function(){
23900 return this.selections.length > 0;
23904 * Returns True if the specified row is selected.
23905 * @param {Number/Record} record The record or index of the record to check
23906 * @return {Boolean}
23908 isSelected : function(index){
23909 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
23910 return (r && this.selections.key(r.id) ? true : false);
23914 * Returns True if the specified record id is selected.
23915 * @param {String} id The id of record to check
23916 * @return {Boolean}
23918 isIdSelected : function(id){
23919 return (this.selections.key(id) ? true : false);
23924 handleMouseDBClick : function(e, t){
23928 handleMouseDown : function(e, t)
23930 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
23931 if(this.isLocked() || rowIndex < 0 ){
23934 if(e.shiftKey && this.last !== false){
23935 var last = this.last;
23936 this.selectRange(last, rowIndex, e.ctrlKey);
23937 this.last = last; // reset the last
23941 var isSelected = this.isSelected(rowIndex);
23942 //Roo.log("select row:" + rowIndex);
23944 this.deselectRow(rowIndex);
23946 this.selectRow(rowIndex, true);
23950 if(e.button !== 0 && isSelected){
23951 alert('rowIndex 2: ' + rowIndex);
23952 view.focusRow(rowIndex);
23953 }else if(e.ctrlKey && isSelected){
23954 this.deselectRow(rowIndex);
23955 }else if(!isSelected){
23956 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
23957 view.focusRow(rowIndex);
23961 this.fireEvent("afterselectionchange", this);
23964 handleDragableRowClick : function(grid, rowIndex, e)
23966 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
23967 this.selectRow(rowIndex, false);
23968 grid.view.focusRow(rowIndex);
23969 this.fireEvent("afterselectionchange", this);
23974 * Selects multiple rows.
23975 * @param {Array} rows Array of the indexes of the row to select
23976 * @param {Boolean} keepExisting (optional) True to keep existing selections
23978 selectRows : function(rows, keepExisting){
23980 this.clearSelections();
23982 for(var i = 0, len = rows.length; i < len; i++){
23983 this.selectRow(rows[i], true);
23988 * Selects a range of rows. All rows in between startRow and endRow are also selected.
23989 * @param {Number} startRow The index of the first row in the range
23990 * @param {Number} endRow The index of the last row in the range
23991 * @param {Boolean} keepExisting (optional) True to retain existing selections
23993 selectRange : function(startRow, endRow, keepExisting){
23998 this.clearSelections();
24000 if(startRow <= endRow){
24001 for(var i = startRow; i <= endRow; i++){
24002 this.selectRow(i, true);
24005 for(var i = startRow; i >= endRow; i--){
24006 this.selectRow(i, true);
24012 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
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
24016 deselectRange : function(startRow, endRow, preventViewNotify){
24020 for(var i = startRow; i <= endRow; i++){
24021 this.deselectRow(i, preventViewNotify);
24027 * @param {Number} row The index of the row to select
24028 * @param {Boolean} keepExisting (optional) True to keep existing selections
24030 selectRow : function(index, keepExisting, preventViewNotify)
24032 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24035 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24036 if(!keepExisting || this.singleSelect){
24037 this.clearSelections();
24040 var r = this.grid.store.getAt(index);
24041 //console.log('selectRow - record id :' + r.id);
24043 this.selections.add(r);
24044 this.last = this.lastActive = index;
24045 if(!preventViewNotify){
24046 var proxy = new Roo.Element(
24047 this.grid.getRowDom(index)
24049 proxy.addClass('bg-info info');
24051 this.fireEvent("rowselect", this, index, r);
24052 this.fireEvent("selectionchange", this);
24058 * @param {Number} row The index of the row to deselect
24060 deselectRow : function(index, preventViewNotify)
24065 if(this.last == index){
24068 if(this.lastActive == index){
24069 this.lastActive = false;
24072 var r = this.grid.store.getAt(index);
24077 this.selections.remove(r);
24078 //.console.log('deselectRow - record id :' + r.id);
24079 if(!preventViewNotify){
24081 var proxy = new Roo.Element(
24082 this.grid.getRowDom(index)
24084 proxy.removeClass('bg-info info');
24086 this.fireEvent("rowdeselect", this, index);
24087 this.fireEvent("selectionchange", this);
24091 restoreLast : function(){
24093 this.last = this._last;
24098 acceptsNav : function(row, col, cm){
24099 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24103 onEditorKey : function(field, e){
24104 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24109 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24111 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24113 }else if(k == e.ENTER && !e.ctrlKey){
24117 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24119 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24121 }else if(k == e.ESC){
24125 g.startEditing(newCell[0], newCell[1]);
24131 * Ext JS Library 1.1.1
24132 * Copyright(c) 2006-2007, Ext JS, LLC.
24134 * Originally Released Under LGPL - original licence link has changed is not relivant.
24137 * <script type="text/javascript">
24141 * @class Roo.bootstrap.PagingToolbar
24142 * @extends Roo.bootstrap.NavSimplebar
24143 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24145 * Create a new PagingToolbar
24146 * @param {Object} config The config object
24147 * @param {Roo.data.Store} store
24149 Roo.bootstrap.PagingToolbar = function(config)
24151 // old args format still supported... - xtype is prefered..
24152 // created from xtype...
24154 this.ds = config.dataSource;
24156 if (config.store && !this.ds) {
24157 this.store= Roo.factory(config.store, Roo.data);
24158 this.ds = this.store;
24159 this.ds.xmodule = this.xmodule || false;
24162 this.toolbarItems = [];
24163 if (config.items) {
24164 this.toolbarItems = config.items;
24167 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24172 this.bind(this.ds);
24175 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24179 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24181 * @cfg {Roo.data.Store} dataSource
24182 * The underlying data store providing the paged data
24185 * @cfg {String/HTMLElement/Element} container
24186 * container The id or element that will contain the toolbar
24189 * @cfg {Boolean} displayInfo
24190 * True to display the displayMsg (defaults to false)
24193 * @cfg {Number} pageSize
24194 * The number of records to display per page (defaults to 20)
24198 * @cfg {String} displayMsg
24199 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24201 displayMsg : 'Displaying {0} - {1} of {2}',
24203 * @cfg {String} emptyMsg
24204 * The message to display when no records are found (defaults to "No data to display")
24206 emptyMsg : 'No data to display',
24208 * Customizable piece of the default paging text (defaults to "Page")
24211 beforePageText : "Page",
24213 * Customizable piece of the default paging text (defaults to "of %0")
24216 afterPageText : "of {0}",
24218 * Customizable piece of the default paging text (defaults to "First Page")
24221 firstText : "First Page",
24223 * Customizable piece of the default paging text (defaults to "Previous Page")
24226 prevText : "Previous Page",
24228 * Customizable piece of the default paging text (defaults to "Next Page")
24231 nextText : "Next Page",
24233 * Customizable piece of the default paging text (defaults to "Last Page")
24236 lastText : "Last Page",
24238 * Customizable piece of the default paging text (defaults to "Refresh")
24241 refreshText : "Refresh",
24245 onRender : function(ct, position)
24247 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24248 this.navgroup.parentId = this.id;
24249 this.navgroup.onRender(this.el, null);
24250 // add the buttons to the navgroup
24252 if(this.displayInfo){
24253 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24254 this.displayEl = this.el.select('.x-paging-info', true).first();
24255 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24256 // this.displayEl = navel.el.select('span',true).first();
24262 Roo.each(_this.buttons, function(e){ // this might need to use render????
24263 Roo.factory(e).onRender(_this.el, null);
24267 Roo.each(_this.toolbarItems, function(e) {
24268 _this.navgroup.addItem(e);
24272 this.first = this.navgroup.addItem({
24273 tooltip: this.firstText,
24275 icon : 'fa fa-backward',
24277 preventDefault: true,
24278 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24281 this.prev = this.navgroup.addItem({
24282 tooltip: this.prevText,
24284 icon : 'fa fa-step-backward',
24286 preventDefault: true,
24287 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24289 //this.addSeparator();
24292 var field = this.navgroup.addItem( {
24294 cls : 'x-paging-position',
24296 html : this.beforePageText +
24297 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24298 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24301 this.field = field.el.select('input', true).first();
24302 this.field.on("keydown", this.onPagingKeydown, this);
24303 this.field.on("focus", function(){this.dom.select();});
24306 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24307 //this.field.setHeight(18);
24308 //this.addSeparator();
24309 this.next = this.navgroup.addItem({
24310 tooltip: this.nextText,
24312 html : ' <i class="fa fa-step-forward">',
24314 preventDefault: true,
24315 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24317 this.last = this.navgroup.addItem({
24318 tooltip: this.lastText,
24319 icon : 'fa fa-forward',
24322 preventDefault: true,
24323 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24325 //this.addSeparator();
24326 this.loading = this.navgroup.addItem({
24327 tooltip: this.refreshText,
24328 icon: 'fa fa-refresh',
24329 preventDefault: true,
24330 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24336 updateInfo : function(){
24337 if(this.displayEl){
24338 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24339 var msg = count == 0 ?
24343 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24345 this.displayEl.update(msg);
24350 onLoad : function(ds, r, o)
24352 this.cursor = o.params ? o.params.start : 0;
24353 var d = this.getPageData(),
24358 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24359 this.field.dom.value = ap;
24360 this.first.setDisabled(ap == 1);
24361 this.prev.setDisabled(ap == 1);
24362 this.next.setDisabled(ap == ps);
24363 this.last.setDisabled(ap == ps);
24364 this.loading.enable();
24369 getPageData : function(){
24370 var total = this.ds.getTotalCount();
24373 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24374 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24379 onLoadError : function(){
24380 this.loading.enable();
24384 onPagingKeydown : function(e){
24385 var k = e.getKey();
24386 var d = this.getPageData();
24388 var v = this.field.dom.value, pageNum;
24389 if(!v || isNaN(pageNum = parseInt(v, 10))){
24390 this.field.dom.value = d.activePage;
24393 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24394 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24397 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))
24399 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24400 this.field.dom.value = pageNum;
24401 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24404 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24406 var v = this.field.dom.value, pageNum;
24407 var increment = (e.shiftKey) ? 10 : 1;
24408 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24411 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24412 this.field.dom.value = d.activePage;
24415 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24417 this.field.dom.value = parseInt(v, 10) + increment;
24418 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24419 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24426 beforeLoad : function(){
24428 this.loading.disable();
24433 onClick : function(which){
24442 ds.load({params:{start: 0, limit: this.pageSize}});
24445 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24448 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24451 var total = ds.getTotalCount();
24452 var extra = total % this.pageSize;
24453 var lastStart = extra ? (total - extra) : total-this.pageSize;
24454 ds.load({params:{start: lastStart, limit: this.pageSize}});
24457 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24463 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24464 * @param {Roo.data.Store} store The data store to unbind
24466 unbind : function(ds){
24467 ds.un("beforeload", this.beforeLoad, this);
24468 ds.un("load", this.onLoad, this);
24469 ds.un("loadexception", this.onLoadError, this);
24470 ds.un("remove", this.updateInfo, this);
24471 ds.un("add", this.updateInfo, this);
24472 this.ds = undefined;
24476 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24477 * @param {Roo.data.Store} store The data store to bind
24479 bind : function(ds){
24480 ds.on("beforeload", this.beforeLoad, this);
24481 ds.on("load", this.onLoad, this);
24482 ds.on("loadexception", this.onLoadError, this);
24483 ds.on("remove", this.updateInfo, this);
24484 ds.on("add", this.updateInfo, this);
24495 * @class Roo.bootstrap.MessageBar
24496 * @extends Roo.bootstrap.Component
24497 * Bootstrap MessageBar class
24498 * @cfg {String} html contents of the MessageBar
24499 * @cfg {String} weight (info | success | warning | danger) default info
24500 * @cfg {String} beforeClass insert the bar before the given class
24501 * @cfg {Boolean} closable (true | false) default false
24502 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24505 * Create a new Element
24506 * @param {Object} config The config object
24509 Roo.bootstrap.MessageBar = function(config){
24510 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24513 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24519 beforeClass: 'bootstrap-sticky-wrap',
24521 getAutoCreate : function(){
24525 cls: 'alert alert-dismissable alert-' + this.weight,
24530 html: this.html || ''
24536 cfg.cls += ' alert-messages-fixed';
24550 onRender : function(ct, position)
24552 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24555 var cfg = Roo.apply({}, this.getAutoCreate());
24559 cfg.cls += ' ' + this.cls;
24562 cfg.style = this.style;
24564 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24566 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24569 this.el.select('>button.close').on('click', this.hide, this);
24575 if (!this.rendered) {
24581 this.fireEvent('show', this);
24587 if (!this.rendered) {
24593 this.fireEvent('hide', this);
24596 update : function()
24598 // var e = this.el.dom.firstChild;
24600 // if(this.closable){
24601 // e = e.nextSibling;
24604 // e.data = this.html || '';
24606 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24622 * @class Roo.bootstrap.Graph
24623 * @extends Roo.bootstrap.Component
24624 * Bootstrap Graph class
24628 @cfg {String} graphtype bar | vbar | pie
24629 @cfg {number} g_x coodinator | centre x (pie)
24630 @cfg {number} g_y coodinator | centre y (pie)
24631 @cfg {number} g_r radius (pie)
24632 @cfg {number} g_height height of the chart (respected by all elements in the set)
24633 @cfg {number} g_width width of the chart (respected by all elements in the set)
24634 @cfg {Object} title The title of the chart
24637 -opts (object) options for the chart
24639 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24640 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24642 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.
24643 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24645 o stretch (boolean)
24647 -opts (object) options for the pie
24650 o startAngle (number)
24651 o endAngle (number)
24655 * Create a new Input
24656 * @param {Object} config The config object
24659 Roo.bootstrap.Graph = function(config){
24660 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24666 * The img click event for the img.
24667 * @param {Roo.EventObject} e
24673 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24684 //g_colors: this.colors,
24691 getAutoCreate : function(){
24702 onRender : function(ct,position){
24705 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24707 if (typeof(Raphael) == 'undefined') {
24708 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24712 this.raphael = Raphael(this.el.dom);
24714 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24715 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24716 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24717 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24719 r.text(160, 10, "Single Series Chart").attr(txtattr);
24720 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24721 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24722 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24724 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24725 r.barchart(330, 10, 300, 220, data1);
24726 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24727 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24730 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24731 // r.barchart(30, 30, 560, 250, xdata, {
24732 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24733 // axis : "0 0 1 1",
24734 // axisxlabels : xdata
24735 // //yvalues : cols,
24738 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24740 // this.load(null,xdata,{
24741 // axis : "0 0 1 1",
24742 // axisxlabels : xdata
24747 load : function(graphtype,xdata,opts)
24749 this.raphael.clear();
24751 graphtype = this.graphtype;
24756 var r = this.raphael,
24757 fin = function () {
24758 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24760 fout = function () {
24761 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24763 pfin = function() {
24764 this.sector.stop();
24765 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24768 this.label[0].stop();
24769 this.label[0].attr({ r: 7.5 });
24770 this.label[1].attr({ "font-weight": 800 });
24773 pfout = function() {
24774 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24777 this.label[0].animate({ r: 5 }, 500, "bounce");
24778 this.label[1].attr({ "font-weight": 400 });
24784 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24787 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24790 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24791 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24793 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24800 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24805 setTitle: function(o)
24810 initEvents: function() {
24813 this.el.on('click', this.onClick, this);
24817 onClick : function(e)
24819 Roo.log('img onclick');
24820 this.fireEvent('click', this, e);
24832 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24835 * @class Roo.bootstrap.dash.NumberBox
24836 * @extends Roo.bootstrap.Component
24837 * Bootstrap NumberBox class
24838 * @cfg {String} headline Box headline
24839 * @cfg {String} content Box content
24840 * @cfg {String} icon Box icon
24841 * @cfg {String} footer Footer text
24842 * @cfg {String} fhref Footer href
24845 * Create a new NumberBox
24846 * @param {Object} config The config object
24850 Roo.bootstrap.dash.NumberBox = function(config){
24851 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24855 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24864 getAutoCreate : function(){
24868 cls : 'small-box ',
24876 cls : 'roo-headline',
24877 html : this.headline
24881 cls : 'roo-content',
24882 html : this.content
24896 cls : 'ion ' + this.icon
24905 cls : 'small-box-footer',
24906 href : this.fhref || '#',
24910 cfg.cn.push(footer);
24917 onRender : function(ct,position){
24918 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
24925 setHeadline: function (value)
24927 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
24930 setFooter: function (value, href)
24932 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
24935 this.el.select('a.small-box-footer',true).first().attr('href', href);
24940 setContent: function (value)
24942 this.el.select('.roo-content',true).first().dom.innerHTML = value;
24945 initEvents: function()
24959 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24962 * @class Roo.bootstrap.dash.TabBox
24963 * @extends Roo.bootstrap.Component
24964 * Bootstrap TabBox class
24965 * @cfg {String} title Title of the TabBox
24966 * @cfg {String} icon Icon of the TabBox
24967 * @cfg {Boolean} showtabs (true|false) show the tabs default true
24968 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
24971 * Create a new TabBox
24972 * @param {Object} config The config object
24976 Roo.bootstrap.dash.TabBox = function(config){
24977 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
24982 * When a pane is added
24983 * @param {Roo.bootstrap.dash.TabPane} pane
24987 * @event activatepane
24988 * When a pane is activated
24989 * @param {Roo.bootstrap.dash.TabPane} pane
24991 "activatepane" : true
24999 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25004 tabScrollable : false,
25006 getChildContainer : function()
25008 return this.el.select('.tab-content', true).first();
25011 getAutoCreate : function(){
25015 cls: 'pull-left header',
25023 cls: 'fa ' + this.icon
25029 cls: 'nav nav-tabs pull-right',
25035 if(this.tabScrollable){
25042 cls: 'nav nav-tabs pull-right',
25053 cls: 'nav-tabs-custom',
25058 cls: 'tab-content no-padding',
25066 initEvents : function()
25068 //Roo.log('add add pane handler');
25069 this.on('addpane', this.onAddPane, this);
25072 * Updates the box title
25073 * @param {String} html to set the title to.
25075 setTitle : function(value)
25077 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25079 onAddPane : function(pane)
25081 this.panes.push(pane);
25082 //Roo.log('addpane');
25084 // tabs are rendere left to right..
25085 if(!this.showtabs){
25089 var ctr = this.el.select('.nav-tabs', true).first();
25092 var existing = ctr.select('.nav-tab',true);
25093 var qty = existing.getCount();;
25096 var tab = ctr.createChild({
25098 cls : 'nav-tab' + (qty ? '' : ' active'),
25106 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25109 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25111 pane.el.addClass('active');
25116 onTabClick : function(ev,un,ob,pane)
25118 //Roo.log('tab - prev default');
25119 ev.preventDefault();
25122 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25123 pane.tab.addClass('active');
25124 //Roo.log(pane.title);
25125 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25126 // technically we should have a deactivate event.. but maybe add later.
25127 // and it should not de-activate the selected tab...
25128 this.fireEvent('activatepane', pane);
25129 pane.el.addClass('active');
25130 pane.fireEvent('activate');
25135 getActivePane : function()
25138 Roo.each(this.panes, function(p) {
25139 if(p.el.hasClass('active')){
25160 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25162 * @class Roo.bootstrap.TabPane
25163 * @extends Roo.bootstrap.Component
25164 * Bootstrap TabPane class
25165 * @cfg {Boolean} active (false | true) Default false
25166 * @cfg {String} title title of panel
25170 * Create a new TabPane
25171 * @param {Object} config The config object
25174 Roo.bootstrap.dash.TabPane = function(config){
25175 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25181 * When a pane is activated
25182 * @param {Roo.bootstrap.dash.TabPane} pane
25189 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25194 // the tabBox that this is attached to.
25197 getAutoCreate : function()
25205 cfg.cls += ' active';
25210 initEvents : function()
25212 //Roo.log('trigger add pane handler');
25213 this.parent().fireEvent('addpane', this)
25217 * Updates the tab title
25218 * @param {String} html to set the title to.
25220 setTitle: function(str)
25226 this.tab.select('a', true).first().dom.innerHTML = str;
25243 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25246 * @class Roo.bootstrap.menu.Menu
25247 * @extends Roo.bootstrap.Component
25248 * Bootstrap Menu class - container for Menu
25249 * @cfg {String} html Text of the menu
25250 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25251 * @cfg {String} icon Font awesome icon
25252 * @cfg {String} pos Menu align to (top | bottom) default bottom
25256 * Create a new Menu
25257 * @param {Object} config The config object
25261 Roo.bootstrap.menu.Menu = function(config){
25262 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25266 * @event beforeshow
25267 * Fires before this menu is displayed
25268 * @param {Roo.bootstrap.menu.Menu} this
25272 * @event beforehide
25273 * Fires before this menu is hidden
25274 * @param {Roo.bootstrap.menu.Menu} this
25279 * Fires after this menu is displayed
25280 * @param {Roo.bootstrap.menu.Menu} this
25285 * Fires after this menu is hidden
25286 * @param {Roo.bootstrap.menu.Menu} this
25291 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25292 * @param {Roo.bootstrap.menu.Menu} this
25293 * @param {Roo.EventObject} e
25300 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25304 weight : 'default',
25309 getChildContainer : function() {
25310 if(this.isSubMenu){
25314 return this.el.select('ul.dropdown-menu', true).first();
25317 getAutoCreate : function()
25322 cls : 'roo-menu-text',
25330 cls : 'fa ' + this.icon
25341 cls : 'dropdown-button btn btn-' + this.weight,
25346 cls : 'dropdown-toggle btn btn-' + this.weight,
25356 cls : 'dropdown-menu'
25362 if(this.pos == 'top'){
25363 cfg.cls += ' dropup';
25366 if(this.isSubMenu){
25369 cls : 'dropdown-menu'
25376 onRender : function(ct, position)
25378 this.isSubMenu = ct.hasClass('dropdown-submenu');
25380 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25383 initEvents : function()
25385 if(this.isSubMenu){
25389 this.hidden = true;
25391 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25392 this.triggerEl.on('click', this.onTriggerPress, this);
25394 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25395 this.buttonEl.on('click', this.onClick, this);
25401 if(this.isSubMenu){
25405 return this.el.select('ul.dropdown-menu', true).first();
25408 onClick : function(e)
25410 this.fireEvent("click", this, e);
25413 onTriggerPress : function(e)
25415 if (this.isVisible()) {
25422 isVisible : function(){
25423 return !this.hidden;
25428 this.fireEvent("beforeshow", this);
25430 this.hidden = false;
25431 this.el.addClass('open');
25433 Roo.get(document).on("mouseup", this.onMouseUp, this);
25435 this.fireEvent("show", this);
25442 this.fireEvent("beforehide", this);
25444 this.hidden = true;
25445 this.el.removeClass('open');
25447 Roo.get(document).un("mouseup", this.onMouseUp);
25449 this.fireEvent("hide", this);
25452 onMouseUp : function()
25466 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25469 * @class Roo.bootstrap.menu.Item
25470 * @extends Roo.bootstrap.Component
25471 * Bootstrap MenuItem class
25472 * @cfg {Boolean} submenu (true | false) default false
25473 * @cfg {String} html text of the item
25474 * @cfg {String} href the link
25475 * @cfg {Boolean} disable (true | false) default false
25476 * @cfg {Boolean} preventDefault (true | false) default true
25477 * @cfg {String} icon Font awesome icon
25478 * @cfg {String} pos Submenu align to (left | right) default right
25482 * Create a new Item
25483 * @param {Object} config The config object
25487 Roo.bootstrap.menu.Item = function(config){
25488 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25492 * Fires when the mouse is hovering over this menu
25493 * @param {Roo.bootstrap.menu.Item} this
25494 * @param {Roo.EventObject} e
25499 * Fires when the mouse exits this menu
25500 * @param {Roo.bootstrap.menu.Item} this
25501 * @param {Roo.EventObject} e
25507 * The raw click event for the entire grid.
25508 * @param {Roo.EventObject} e
25514 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25519 preventDefault: true,
25524 getAutoCreate : function()
25529 cls : 'roo-menu-item-text',
25537 cls : 'fa ' + this.icon
25546 href : this.href || '#',
25553 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25557 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25559 if(this.pos == 'left'){
25560 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25567 initEvents : function()
25569 this.el.on('mouseover', this.onMouseOver, this);
25570 this.el.on('mouseout', this.onMouseOut, this);
25572 this.el.select('a', true).first().on('click', this.onClick, this);
25576 onClick : function(e)
25578 if(this.preventDefault){
25579 e.preventDefault();
25582 this.fireEvent("click", this, e);
25585 onMouseOver : function(e)
25587 if(this.submenu && this.pos == 'left'){
25588 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25591 this.fireEvent("mouseover", this, e);
25594 onMouseOut : function(e)
25596 this.fireEvent("mouseout", this, e);
25608 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25611 * @class Roo.bootstrap.menu.Separator
25612 * @extends Roo.bootstrap.Component
25613 * Bootstrap Separator class
25616 * Create a new Separator
25617 * @param {Object} config The config object
25621 Roo.bootstrap.menu.Separator = function(config){
25622 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25625 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25627 getAutoCreate : function(){
25648 * @class Roo.bootstrap.Tooltip
25649 * Bootstrap Tooltip class
25650 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25651 * to determine which dom element triggers the tooltip.
25653 * It needs to add support for additional attributes like tooltip-position
25656 * Create a new Toolti
25657 * @param {Object} config The config object
25660 Roo.bootstrap.Tooltip = function(config){
25661 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25663 this.alignment = Roo.bootstrap.Tooltip.alignment;
25665 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25666 this.alignment = config.alignment;
25671 Roo.apply(Roo.bootstrap.Tooltip, {
25673 * @function init initialize tooltip monitoring.
25677 currentTip : false,
25678 currentRegion : false,
25684 Roo.get(document).on('mouseover', this.enter ,this);
25685 Roo.get(document).on('mouseout', this.leave, this);
25688 this.currentTip = new Roo.bootstrap.Tooltip();
25691 enter : function(ev)
25693 var dom = ev.getTarget();
25695 //Roo.log(['enter',dom]);
25696 var el = Roo.fly(dom);
25697 if (this.currentEl) {
25699 //Roo.log(this.currentEl);
25700 //Roo.log(this.currentEl.contains(dom));
25701 if (this.currentEl == el) {
25704 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25710 if (this.currentTip.el) {
25711 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25715 if(!el || el.dom == document){
25721 // you can not look for children, as if el is the body.. then everythign is the child..
25722 if (!el.attr('tooltip')) { //
25723 if (!el.select("[tooltip]").elements.length) {
25726 // is the mouse over this child...?
25727 bindEl = el.select("[tooltip]").first();
25728 var xy = ev.getXY();
25729 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25730 //Roo.log("not in region.");
25733 //Roo.log("child element over..");
25736 this.currentEl = bindEl;
25737 this.currentTip.bind(bindEl);
25738 this.currentRegion = Roo.lib.Region.getRegion(dom);
25739 this.currentTip.enter();
25742 leave : function(ev)
25744 var dom = ev.getTarget();
25745 //Roo.log(['leave',dom]);
25746 if (!this.currentEl) {
25751 if (dom != this.currentEl.dom) {
25754 var xy = ev.getXY();
25755 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25758 // only activate leave if mouse cursor is outside... bounding box..
25763 if (this.currentTip) {
25764 this.currentTip.leave();
25766 //Roo.log('clear currentEl');
25767 this.currentEl = false;
25772 'left' : ['r-l', [-2,0], 'right'],
25773 'right' : ['l-r', [2,0], 'left'],
25774 'bottom' : ['t-b', [0,2], 'top'],
25775 'top' : [ 'b-t', [0,-2], 'bottom']
25781 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25786 delay : null, // can be { show : 300 , hide: 500}
25790 hoverState : null, //???
25792 placement : 'bottom',
25796 getAutoCreate : function(){
25803 cls : 'tooltip-arrow'
25806 cls : 'tooltip-inner'
25813 bind : function(el)
25819 enter : function () {
25821 if (this.timeout != null) {
25822 clearTimeout(this.timeout);
25825 this.hoverState = 'in';
25826 //Roo.log("enter - show");
25827 if (!this.delay || !this.delay.show) {
25832 this.timeout = setTimeout(function () {
25833 if (_t.hoverState == 'in') {
25836 }, this.delay.show);
25840 clearTimeout(this.timeout);
25842 this.hoverState = 'out';
25843 if (!this.delay || !this.delay.hide) {
25849 this.timeout = setTimeout(function () {
25850 //Roo.log("leave - timeout");
25852 if (_t.hoverState == 'out') {
25854 Roo.bootstrap.Tooltip.currentEl = false;
25859 show : function (msg)
25862 this.render(document.body);
25865 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25867 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25869 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25871 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25873 var placement = typeof this.placement == 'function' ?
25874 this.placement.call(this, this.el, on_el) :
25877 var autoToken = /\s?auto?\s?/i;
25878 var autoPlace = autoToken.test(placement);
25880 placement = placement.replace(autoToken, '') || 'top';
25884 //this.el.setXY([0,0]);
25886 //this.el.dom.style.display='block';
25888 //this.el.appendTo(on_el);
25890 var p = this.getPosition();
25891 var box = this.el.getBox();
25897 var align = this.alignment[placement];
25899 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25901 if(placement == 'top' || placement == 'bottom'){
25903 placement = 'right';
25906 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25907 placement = 'left';
25910 var scroll = Roo.select('body', true).first().getScroll();
25912 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
25918 this.el.alignTo(this.bindEl, align[0],align[1]);
25919 //var arrow = this.el.select('.arrow',true).first();
25920 //arrow.set(align[2],
25922 this.el.addClass(placement);
25924 this.el.addClass('in fade');
25926 this.hoverState = null;
25928 if (this.el.hasClass('fade')) {
25939 //this.el.setXY([0,0]);
25940 this.el.removeClass('in');
25956 * @class Roo.bootstrap.LocationPicker
25957 * @extends Roo.bootstrap.Component
25958 * Bootstrap LocationPicker class
25959 * @cfg {Number} latitude Position when init default 0
25960 * @cfg {Number} longitude Position when init default 0
25961 * @cfg {Number} zoom default 15
25962 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
25963 * @cfg {Boolean} mapTypeControl default false
25964 * @cfg {Boolean} disableDoubleClickZoom default false
25965 * @cfg {Boolean} scrollwheel default true
25966 * @cfg {Boolean} streetViewControl default false
25967 * @cfg {Number} radius default 0
25968 * @cfg {String} locationName
25969 * @cfg {Boolean} draggable default true
25970 * @cfg {Boolean} enableAutocomplete default false
25971 * @cfg {Boolean} enableReverseGeocode default true
25972 * @cfg {String} markerTitle
25975 * Create a new LocationPicker
25976 * @param {Object} config The config object
25980 Roo.bootstrap.LocationPicker = function(config){
25982 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
25987 * Fires when the picker initialized.
25988 * @param {Roo.bootstrap.LocationPicker} this
25989 * @param {Google Location} location
25993 * @event positionchanged
25994 * Fires when the picker position changed.
25995 * @param {Roo.bootstrap.LocationPicker} this
25996 * @param {Google Location} location
25998 positionchanged : true,
26001 * Fires when the map resize.
26002 * @param {Roo.bootstrap.LocationPicker} this
26007 * Fires when the map show.
26008 * @param {Roo.bootstrap.LocationPicker} this
26013 * Fires when the map hide.
26014 * @param {Roo.bootstrap.LocationPicker} this
26019 * Fires when click the map.
26020 * @param {Roo.bootstrap.LocationPicker} this
26021 * @param {Map event} e
26025 * @event mapRightClick
26026 * Fires when right click the map.
26027 * @param {Roo.bootstrap.LocationPicker} this
26028 * @param {Map event} e
26030 mapRightClick : true,
26032 * @event markerClick
26033 * Fires when click the marker.
26034 * @param {Roo.bootstrap.LocationPicker} this
26035 * @param {Map event} e
26037 markerClick : true,
26039 * @event markerRightClick
26040 * Fires when right click the marker.
26041 * @param {Roo.bootstrap.LocationPicker} this
26042 * @param {Map event} e
26044 markerRightClick : true,
26046 * @event OverlayViewDraw
26047 * Fires when OverlayView Draw
26048 * @param {Roo.bootstrap.LocationPicker} this
26050 OverlayViewDraw : true,
26052 * @event OverlayViewOnAdd
26053 * Fires when OverlayView Draw
26054 * @param {Roo.bootstrap.LocationPicker} this
26056 OverlayViewOnAdd : true,
26058 * @event OverlayViewOnRemove
26059 * Fires when OverlayView Draw
26060 * @param {Roo.bootstrap.LocationPicker} this
26062 OverlayViewOnRemove : true,
26064 * @event OverlayViewShow
26065 * Fires when OverlayView Draw
26066 * @param {Roo.bootstrap.LocationPicker} this
26067 * @param {Pixel} cpx
26069 OverlayViewShow : true,
26071 * @event OverlayViewHide
26072 * Fires when OverlayView Draw
26073 * @param {Roo.bootstrap.LocationPicker} this
26075 OverlayViewHide : true,
26077 * @event loadexception
26078 * Fires when load google lib failed.
26079 * @param {Roo.bootstrap.LocationPicker} this
26081 loadexception : true
26086 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26088 gMapContext: false,
26094 mapTypeControl: false,
26095 disableDoubleClickZoom: false,
26097 streetViewControl: false,
26101 enableAutocomplete: false,
26102 enableReverseGeocode: true,
26105 getAutoCreate: function()
26110 cls: 'roo-location-picker'
26116 initEvents: function(ct, position)
26118 if(!this.el.getWidth() || this.isApplied()){
26122 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26127 initial: function()
26129 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26130 this.fireEvent('loadexception', this);
26134 if(!this.mapTypeId){
26135 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26138 this.gMapContext = this.GMapContext();
26140 this.initOverlayView();
26142 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26146 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26147 _this.setPosition(_this.gMapContext.marker.position);
26150 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26151 _this.fireEvent('mapClick', this, event);
26155 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26156 _this.fireEvent('mapRightClick', this, event);
26160 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26161 _this.fireEvent('markerClick', this, event);
26165 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26166 _this.fireEvent('markerRightClick', this, event);
26170 this.setPosition(this.gMapContext.location);
26172 this.fireEvent('initial', this, this.gMapContext.location);
26175 initOverlayView: function()
26179 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26183 _this.fireEvent('OverlayViewDraw', _this);
26188 _this.fireEvent('OverlayViewOnAdd', _this);
26191 onRemove: function()
26193 _this.fireEvent('OverlayViewOnRemove', _this);
26196 show: function(cpx)
26198 _this.fireEvent('OverlayViewShow', _this, cpx);
26203 _this.fireEvent('OverlayViewHide', _this);
26209 fromLatLngToContainerPixel: function(event)
26211 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26214 isApplied: function()
26216 return this.getGmapContext() == false ? false : true;
26219 getGmapContext: function()
26221 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26224 GMapContext: function()
26226 var position = new google.maps.LatLng(this.latitude, this.longitude);
26228 var _map = new google.maps.Map(this.el.dom, {
26231 mapTypeId: this.mapTypeId,
26232 mapTypeControl: this.mapTypeControl,
26233 disableDoubleClickZoom: this.disableDoubleClickZoom,
26234 scrollwheel: this.scrollwheel,
26235 streetViewControl: this.streetViewControl,
26236 locationName: this.locationName,
26237 draggable: this.draggable,
26238 enableAutocomplete: this.enableAutocomplete,
26239 enableReverseGeocode: this.enableReverseGeocode
26242 var _marker = new google.maps.Marker({
26243 position: position,
26245 title: this.markerTitle,
26246 draggable: this.draggable
26253 location: position,
26254 radius: this.radius,
26255 locationName: this.locationName,
26256 addressComponents: {
26257 formatted_address: null,
26258 addressLine1: null,
26259 addressLine2: null,
26261 streetNumber: null,
26265 stateOrProvince: null
26268 domContainer: this.el.dom,
26269 geodecoder: new google.maps.Geocoder()
26273 drawCircle: function(center, radius, options)
26275 if (this.gMapContext.circle != null) {
26276 this.gMapContext.circle.setMap(null);
26280 options = Roo.apply({}, options, {
26281 strokeColor: "#0000FF",
26282 strokeOpacity: .35,
26284 fillColor: "#0000FF",
26288 options.map = this.gMapContext.map;
26289 options.radius = radius;
26290 options.center = center;
26291 this.gMapContext.circle = new google.maps.Circle(options);
26292 return this.gMapContext.circle;
26298 setPosition: function(location)
26300 this.gMapContext.location = location;
26301 this.gMapContext.marker.setPosition(location);
26302 this.gMapContext.map.panTo(location);
26303 this.drawCircle(location, this.gMapContext.radius, {});
26307 if (this.gMapContext.settings.enableReverseGeocode) {
26308 this.gMapContext.geodecoder.geocode({
26309 latLng: this.gMapContext.location
26310 }, function(results, status) {
26312 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26313 _this.gMapContext.locationName = results[0].formatted_address;
26314 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26316 _this.fireEvent('positionchanged', this, location);
26323 this.fireEvent('positionchanged', this, location);
26328 google.maps.event.trigger(this.gMapContext.map, "resize");
26330 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26332 this.fireEvent('resize', this);
26335 setPositionByLatLng: function(latitude, longitude)
26337 this.setPosition(new google.maps.LatLng(latitude, longitude));
26340 getCurrentPosition: function()
26343 latitude: this.gMapContext.location.lat(),
26344 longitude: this.gMapContext.location.lng()
26348 getAddressName: function()
26350 return this.gMapContext.locationName;
26353 getAddressComponents: function()
26355 return this.gMapContext.addressComponents;
26358 address_component_from_google_geocode: function(address_components)
26362 for (var i = 0; i < address_components.length; i++) {
26363 var component = address_components[i];
26364 if (component.types.indexOf("postal_code") >= 0) {
26365 result.postalCode = component.short_name;
26366 } else if (component.types.indexOf("street_number") >= 0) {
26367 result.streetNumber = component.short_name;
26368 } else if (component.types.indexOf("route") >= 0) {
26369 result.streetName = component.short_name;
26370 } else if (component.types.indexOf("neighborhood") >= 0) {
26371 result.city = component.short_name;
26372 } else if (component.types.indexOf("locality") >= 0) {
26373 result.city = component.short_name;
26374 } else if (component.types.indexOf("sublocality") >= 0) {
26375 result.district = component.short_name;
26376 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26377 result.stateOrProvince = component.short_name;
26378 } else if (component.types.indexOf("country") >= 0) {
26379 result.country = component.short_name;
26383 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26384 result.addressLine2 = "";
26388 setZoomLevel: function(zoom)
26390 this.gMapContext.map.setZoom(zoom);
26403 this.fireEvent('show', this);
26414 this.fireEvent('hide', this);
26419 Roo.apply(Roo.bootstrap.LocationPicker, {
26421 OverlayView : function(map, options)
26423 options = options || {};
26437 * @class Roo.bootstrap.Alert
26438 * @extends Roo.bootstrap.Component
26439 * Bootstrap Alert class
26440 * @cfg {String} title The title of alert
26441 * @cfg {String} html The content of alert
26442 * @cfg {String} weight ( success | info | warning | danger )
26443 * @cfg {String} faicon font-awesomeicon
26446 * Create a new alert
26447 * @param {Object} config The config object
26451 Roo.bootstrap.Alert = function(config){
26452 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26456 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26463 getAutoCreate : function()
26472 cls : 'roo-alert-icon'
26477 cls : 'roo-alert-title',
26482 cls : 'roo-alert-text',
26489 cfg.cn[0].cls += ' fa ' + this.faicon;
26493 cfg.cls += ' alert-' + this.weight;
26499 initEvents: function()
26501 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26504 setTitle : function(str)
26506 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26509 setText : function(str)
26511 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26514 setWeight : function(weight)
26517 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26520 this.weight = weight;
26522 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26525 setIcon : function(icon)
26528 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26531 this.faicon = icon;
26533 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26554 * @class Roo.bootstrap.UploadCropbox
26555 * @extends Roo.bootstrap.Component
26556 * Bootstrap UploadCropbox class
26557 * @cfg {String} emptyText show when image has been loaded
26558 * @cfg {String} rotateNotify show when image too small to rotate
26559 * @cfg {Number} errorTimeout default 3000
26560 * @cfg {Number} minWidth default 300
26561 * @cfg {Number} minHeight default 300
26562 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26563 * @cfg {Boolean} isDocument (true|false) default false
26564 * @cfg {String} url action url
26565 * @cfg {String} paramName default 'imageUpload'
26566 * @cfg {String} method default POST
26567 * @cfg {Boolean} loadMask (true|false) default true
26568 * @cfg {Boolean} loadingText default 'Loading...'
26571 * Create a new UploadCropbox
26572 * @param {Object} config The config object
26575 Roo.bootstrap.UploadCropbox = function(config){
26576 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26580 * @event beforeselectfile
26581 * Fire before select file
26582 * @param {Roo.bootstrap.UploadCropbox} this
26584 "beforeselectfile" : true,
26587 * Fire after initEvent
26588 * @param {Roo.bootstrap.UploadCropbox} this
26593 * Fire after initEvent
26594 * @param {Roo.bootstrap.UploadCropbox} this
26595 * @param {String} data
26600 * Fire when preparing the file data
26601 * @param {Roo.bootstrap.UploadCropbox} this
26602 * @param {Object} file
26607 * Fire when get exception
26608 * @param {Roo.bootstrap.UploadCropbox} this
26609 * @param {XMLHttpRequest} xhr
26611 "exception" : true,
26613 * @event beforeloadcanvas
26614 * Fire before load the canvas
26615 * @param {Roo.bootstrap.UploadCropbox} this
26616 * @param {String} src
26618 "beforeloadcanvas" : true,
26621 * Fire when trash image
26622 * @param {Roo.bootstrap.UploadCropbox} this
26627 * Fire when download the image
26628 * @param {Roo.bootstrap.UploadCropbox} this
26632 * @event footerbuttonclick
26633 * Fire when footerbuttonclick
26634 * @param {Roo.bootstrap.UploadCropbox} this
26635 * @param {String} type
26637 "footerbuttonclick" : true,
26641 * @param {Roo.bootstrap.UploadCropbox} this
26646 * Fire when rotate the image
26647 * @param {Roo.bootstrap.UploadCropbox} this
26648 * @param {String} pos
26653 * Fire when inspect the file
26654 * @param {Roo.bootstrap.UploadCropbox} this
26655 * @param {Object} file
26660 * Fire when xhr upload the file
26661 * @param {Roo.bootstrap.UploadCropbox} this
26662 * @param {Object} data
26667 * Fire when arrange the file data
26668 * @param {Roo.bootstrap.UploadCropbox} this
26669 * @param {Object} formData
26674 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26677 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26679 emptyText : 'Click to upload image',
26680 rotateNotify : 'Image is too small to rotate',
26681 errorTimeout : 3000,
26695 cropType : 'image/jpeg',
26697 canvasLoaded : false,
26698 isDocument : false,
26700 paramName : 'imageUpload',
26702 loadingText : 'Loading...',
26705 getAutoCreate : function()
26709 cls : 'roo-upload-cropbox',
26713 cls : 'roo-upload-cropbox-selector',
26718 cls : 'roo-upload-cropbox-body',
26719 style : 'cursor:pointer',
26723 cls : 'roo-upload-cropbox-preview'
26727 cls : 'roo-upload-cropbox-thumb'
26731 cls : 'roo-upload-cropbox-empty-notify',
26732 html : this.emptyText
26736 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26737 html : this.rotateNotify
26743 cls : 'roo-upload-cropbox-footer',
26746 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26756 onRender : function(ct, position)
26758 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26760 if (this.buttons.length) {
26762 Roo.each(this.buttons, function(bb) {
26764 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26766 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26772 this.maskEl = this.el;
26776 initEvents : function()
26778 this.urlAPI = (window.createObjectURL && window) ||
26779 (window.URL && URL.revokeObjectURL && URL) ||
26780 (window.webkitURL && webkitURL);
26782 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26783 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26785 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26786 this.selectorEl.hide();
26788 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26789 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26791 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26792 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26793 this.thumbEl.hide();
26795 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26796 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26798 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26799 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26800 this.errorEl.hide();
26802 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26803 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26804 this.footerEl.hide();
26806 this.setThumbBoxSize();
26812 this.fireEvent('initial', this);
26819 window.addEventListener("resize", function() { _this.resize(); } );
26821 this.bodyEl.on('click', this.beforeSelectFile, this);
26824 this.bodyEl.on('touchstart', this.onTouchStart, this);
26825 this.bodyEl.on('touchmove', this.onTouchMove, this);
26826 this.bodyEl.on('touchend', this.onTouchEnd, this);
26830 this.bodyEl.on('mousedown', this.onMouseDown, this);
26831 this.bodyEl.on('mousemove', this.onMouseMove, this);
26832 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26833 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26834 Roo.get(document).on('mouseup', this.onMouseUp, this);
26837 this.selectorEl.on('change', this.onFileSelected, this);
26843 this.baseScale = 1;
26845 this.baseRotate = 1;
26846 this.dragable = false;
26847 this.pinching = false;
26850 this.cropData = false;
26851 this.notifyEl.dom.innerHTML = this.emptyText;
26853 this.selectorEl.dom.value = '';
26857 resize : function()
26859 if(this.fireEvent('resize', this) != false){
26860 this.setThumbBoxPosition();
26861 this.setCanvasPosition();
26865 onFooterButtonClick : function(e, el, o, type)
26868 case 'rotate-left' :
26869 this.onRotateLeft(e);
26871 case 'rotate-right' :
26872 this.onRotateRight(e);
26875 this.beforeSelectFile(e);
26890 this.fireEvent('footerbuttonclick', this, type);
26893 beforeSelectFile : function(e)
26895 e.preventDefault();
26897 if(this.fireEvent('beforeselectfile', this) != false){
26898 this.selectorEl.dom.click();
26902 onFileSelected : function(e)
26904 e.preventDefault();
26906 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
26910 var file = this.selectorEl.dom.files[0];
26912 if(this.fireEvent('inspect', this, file) != false){
26913 this.prepare(file);
26918 trash : function(e)
26920 this.fireEvent('trash', this);
26923 download : function(e)
26925 this.fireEvent('download', this);
26928 loadCanvas : function(src)
26930 if(this.fireEvent('beforeloadcanvas', this, src) != false){
26934 this.imageEl = document.createElement('img');
26938 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
26940 this.imageEl.src = src;
26944 onLoadCanvas : function()
26946 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
26947 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
26949 this.bodyEl.un('click', this.beforeSelectFile, this);
26951 this.notifyEl.hide();
26952 this.thumbEl.show();
26953 this.footerEl.show();
26955 this.baseRotateLevel();
26957 if(this.isDocument){
26958 this.setThumbBoxSize();
26961 this.setThumbBoxPosition();
26963 this.baseScaleLevel();
26969 this.canvasLoaded = true;
26972 this.maskEl.unmask();
26977 setCanvasPosition : function()
26979 if(!this.canvasEl){
26983 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
26984 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
26986 this.previewEl.setLeft(pw);
26987 this.previewEl.setTop(ph);
26991 onMouseDown : function(e)
26995 this.dragable = true;
26996 this.pinching = false;
26998 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
26999 this.dragable = false;
27003 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27004 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27008 onMouseMove : function(e)
27012 if(!this.canvasLoaded){
27016 if (!this.dragable){
27020 var minX = Math.ceil(this.thumbEl.getLeft(true));
27021 var minY = Math.ceil(this.thumbEl.getTop(true));
27023 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27024 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27026 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27027 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27029 x = x - this.mouseX;
27030 y = y - this.mouseY;
27032 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27033 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27035 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27036 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27038 this.previewEl.setLeft(bgX);
27039 this.previewEl.setTop(bgY);
27041 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27042 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27045 onMouseUp : function(e)
27049 this.dragable = false;
27052 onMouseWheel : function(e)
27056 this.startScale = this.scale;
27058 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27060 if(!this.zoomable()){
27061 this.scale = this.startScale;
27070 zoomable : function()
27072 var minScale = this.thumbEl.getWidth() / this.minWidth;
27074 if(this.minWidth < this.minHeight){
27075 minScale = this.thumbEl.getHeight() / this.minHeight;
27078 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27079 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27083 (this.rotate == 0 || this.rotate == 180) &&
27085 width > this.imageEl.OriginWidth ||
27086 height > this.imageEl.OriginHeight ||
27087 (width < this.minWidth && height < this.minHeight)
27095 (this.rotate == 90 || this.rotate == 270) &&
27097 width > this.imageEl.OriginWidth ||
27098 height > this.imageEl.OriginHeight ||
27099 (width < this.minHeight && height < this.minWidth)
27106 !this.isDocument &&
27107 (this.rotate == 0 || this.rotate == 180) &&
27109 width < this.minWidth ||
27110 width > this.imageEl.OriginWidth ||
27111 height < this.minHeight ||
27112 height > this.imageEl.OriginHeight
27119 !this.isDocument &&
27120 (this.rotate == 90 || this.rotate == 270) &&
27122 width < this.minHeight ||
27123 width > this.imageEl.OriginWidth ||
27124 height < this.minWidth ||
27125 height > this.imageEl.OriginHeight
27135 onRotateLeft : function(e)
27137 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27139 var minScale = this.thumbEl.getWidth() / this.minWidth;
27141 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27142 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27144 this.startScale = this.scale;
27146 while (this.getScaleLevel() < minScale){
27148 this.scale = this.scale + 1;
27150 if(!this.zoomable()){
27155 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27156 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27161 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27168 this.scale = this.startScale;
27170 this.onRotateFail();
27175 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27177 if(this.isDocument){
27178 this.setThumbBoxSize();
27179 this.setThumbBoxPosition();
27180 this.setCanvasPosition();
27185 this.fireEvent('rotate', this, 'left');
27189 onRotateRight : function(e)
27191 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27193 var minScale = this.thumbEl.getWidth() / this.minWidth;
27195 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27196 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27198 this.startScale = this.scale;
27200 while (this.getScaleLevel() < minScale){
27202 this.scale = this.scale + 1;
27204 if(!this.zoomable()){
27209 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27210 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27215 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27222 this.scale = this.startScale;
27224 this.onRotateFail();
27229 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27231 if(this.isDocument){
27232 this.setThumbBoxSize();
27233 this.setThumbBoxPosition();
27234 this.setCanvasPosition();
27239 this.fireEvent('rotate', this, 'right');
27242 onRotateFail : function()
27244 this.errorEl.show(true);
27248 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27253 this.previewEl.dom.innerHTML = '';
27255 var canvasEl = document.createElement("canvas");
27257 var contextEl = canvasEl.getContext("2d");
27259 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27260 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27261 var center = this.imageEl.OriginWidth / 2;
27263 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27264 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27265 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27266 center = this.imageEl.OriginHeight / 2;
27269 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27271 contextEl.translate(center, center);
27272 contextEl.rotate(this.rotate * Math.PI / 180);
27274 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27276 this.canvasEl = document.createElement("canvas");
27278 this.contextEl = this.canvasEl.getContext("2d");
27280 switch (this.rotate) {
27283 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27284 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27286 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27291 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27292 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27294 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27295 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);
27299 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27304 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27305 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27307 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27308 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);
27312 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);
27317 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27318 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27320 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27321 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27325 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);
27332 this.previewEl.appendChild(this.canvasEl);
27334 this.setCanvasPosition();
27339 if(!this.canvasLoaded){
27343 var imageCanvas = document.createElement("canvas");
27345 var imageContext = imageCanvas.getContext("2d");
27347 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27348 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27350 var center = imageCanvas.width / 2;
27352 imageContext.translate(center, center);
27354 imageContext.rotate(this.rotate * Math.PI / 180);
27356 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27358 var canvas = document.createElement("canvas");
27360 var context = canvas.getContext("2d");
27362 canvas.width = this.minWidth;
27363 canvas.height = this.minHeight;
27365 switch (this.rotate) {
27368 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27369 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27371 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27372 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27374 var targetWidth = this.minWidth - 2 * x;
27375 var targetHeight = this.minHeight - 2 * y;
27379 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27380 scale = targetWidth / width;
27383 if(x > 0 && y == 0){
27384 scale = targetHeight / height;
27387 if(x > 0 && y > 0){
27388 scale = targetWidth / width;
27390 if(width < height){
27391 scale = targetHeight / height;
27395 context.scale(scale, scale);
27397 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27398 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27400 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27401 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27403 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27408 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27409 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27411 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27412 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27414 var targetWidth = this.minWidth - 2 * x;
27415 var targetHeight = this.minHeight - 2 * y;
27419 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27420 scale = targetWidth / width;
27423 if(x > 0 && y == 0){
27424 scale = targetHeight / height;
27427 if(x > 0 && y > 0){
27428 scale = targetWidth / width;
27430 if(width < height){
27431 scale = targetHeight / height;
27435 context.scale(scale, scale);
27437 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27438 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27440 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27441 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27443 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27445 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27450 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27451 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27453 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27454 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27456 var targetWidth = this.minWidth - 2 * x;
27457 var targetHeight = this.minHeight - 2 * y;
27461 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27462 scale = targetWidth / width;
27465 if(x > 0 && y == 0){
27466 scale = targetHeight / height;
27469 if(x > 0 && y > 0){
27470 scale = targetWidth / width;
27472 if(width < height){
27473 scale = targetHeight / height;
27477 context.scale(scale, scale);
27479 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27480 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27482 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27483 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27485 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27486 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27488 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27493 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27494 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27496 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27497 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27499 var targetWidth = this.minWidth - 2 * x;
27500 var targetHeight = this.minHeight - 2 * y;
27504 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27505 scale = targetWidth / width;
27508 if(x > 0 && y == 0){
27509 scale = targetHeight / height;
27512 if(x > 0 && y > 0){
27513 scale = targetWidth / width;
27515 if(width < height){
27516 scale = targetHeight / height;
27520 context.scale(scale, scale);
27522 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27523 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27525 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27526 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27528 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27530 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27537 this.cropData = canvas.toDataURL(this.cropType);
27539 if(this.fireEvent('crop', this, this.cropData) !== false){
27540 this.process(this.file, this.cropData);
27547 setThumbBoxSize : function()
27551 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27552 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27553 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27555 this.minWidth = width;
27556 this.minHeight = height;
27558 if(this.rotate == 90 || this.rotate == 270){
27559 this.minWidth = height;
27560 this.minHeight = width;
27565 width = Math.ceil(this.minWidth * height / this.minHeight);
27567 if(this.minWidth > this.minHeight){
27569 height = Math.ceil(this.minHeight * width / this.minWidth);
27572 this.thumbEl.setStyle({
27573 width : width + 'px',
27574 height : height + 'px'
27581 setThumbBoxPosition : function()
27583 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27584 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27586 this.thumbEl.setLeft(x);
27587 this.thumbEl.setTop(y);
27591 baseRotateLevel : function()
27593 this.baseRotate = 1;
27596 typeof(this.exif) != 'undefined' &&
27597 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27598 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27600 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27603 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27607 baseScaleLevel : function()
27611 if(this.isDocument){
27613 if(this.baseRotate == 6 || this.baseRotate == 8){
27615 height = this.thumbEl.getHeight();
27616 this.baseScale = height / this.imageEl.OriginWidth;
27618 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27619 width = this.thumbEl.getWidth();
27620 this.baseScale = width / this.imageEl.OriginHeight;
27626 height = this.thumbEl.getHeight();
27627 this.baseScale = height / this.imageEl.OriginHeight;
27629 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27630 width = this.thumbEl.getWidth();
27631 this.baseScale = width / this.imageEl.OriginWidth;
27637 if(this.baseRotate == 6 || this.baseRotate == 8){
27639 width = this.thumbEl.getHeight();
27640 this.baseScale = width / this.imageEl.OriginHeight;
27642 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27643 height = this.thumbEl.getWidth();
27644 this.baseScale = height / this.imageEl.OriginHeight;
27647 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27648 height = this.thumbEl.getWidth();
27649 this.baseScale = height / this.imageEl.OriginHeight;
27651 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27652 width = this.thumbEl.getHeight();
27653 this.baseScale = width / this.imageEl.OriginWidth;
27660 width = this.thumbEl.getWidth();
27661 this.baseScale = width / this.imageEl.OriginWidth;
27663 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27664 height = this.thumbEl.getHeight();
27665 this.baseScale = height / this.imageEl.OriginHeight;
27668 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27670 height = this.thumbEl.getHeight();
27671 this.baseScale = height / this.imageEl.OriginHeight;
27673 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27674 width = this.thumbEl.getWidth();
27675 this.baseScale = width / this.imageEl.OriginWidth;
27683 getScaleLevel : function()
27685 return this.baseScale * Math.pow(1.1, this.scale);
27688 onTouchStart : function(e)
27690 if(!this.canvasLoaded){
27691 this.beforeSelectFile(e);
27695 var touches = e.browserEvent.touches;
27701 if(touches.length == 1){
27702 this.onMouseDown(e);
27706 if(touches.length != 2){
27712 for(var i = 0, finger; finger = touches[i]; i++){
27713 coords.push(finger.pageX, finger.pageY);
27716 var x = Math.pow(coords[0] - coords[2], 2);
27717 var y = Math.pow(coords[1] - coords[3], 2);
27719 this.startDistance = Math.sqrt(x + y);
27721 this.startScale = this.scale;
27723 this.pinching = true;
27724 this.dragable = false;
27728 onTouchMove : function(e)
27730 if(!this.pinching && !this.dragable){
27734 var touches = e.browserEvent.touches;
27741 this.onMouseMove(e);
27747 for(var i = 0, finger; finger = touches[i]; i++){
27748 coords.push(finger.pageX, finger.pageY);
27751 var x = Math.pow(coords[0] - coords[2], 2);
27752 var y = Math.pow(coords[1] - coords[3], 2);
27754 this.endDistance = Math.sqrt(x + y);
27756 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27758 if(!this.zoomable()){
27759 this.scale = this.startScale;
27767 onTouchEnd : function(e)
27769 this.pinching = false;
27770 this.dragable = false;
27774 process : function(file, crop)
27777 this.maskEl.mask(this.loadingText);
27780 this.xhr = new XMLHttpRequest();
27782 file.xhr = this.xhr;
27784 this.xhr.open(this.method, this.url, true);
27787 "Accept": "application/json",
27788 "Cache-Control": "no-cache",
27789 "X-Requested-With": "XMLHttpRequest"
27792 for (var headerName in headers) {
27793 var headerValue = headers[headerName];
27795 this.xhr.setRequestHeader(headerName, headerValue);
27801 this.xhr.onload = function()
27803 _this.xhrOnLoad(_this.xhr);
27806 this.xhr.onerror = function()
27808 _this.xhrOnError(_this.xhr);
27811 var formData = new FormData();
27813 formData.append('returnHTML', 'NO');
27816 formData.append('crop', crop);
27819 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27820 formData.append(this.paramName, file, file.name);
27823 if(typeof(file.filename) != 'undefined'){
27824 formData.append('filename', file.filename);
27827 if(typeof(file.mimetype) != 'undefined'){
27828 formData.append('mimetype', file.mimetype);
27831 if(this.fireEvent('arrange', this, formData) != false){
27832 this.xhr.send(formData);
27836 xhrOnLoad : function(xhr)
27839 this.maskEl.unmask();
27842 if (xhr.readyState !== 4) {
27843 this.fireEvent('exception', this, xhr);
27847 var response = Roo.decode(xhr.responseText);
27849 if(!response.success){
27850 this.fireEvent('exception', this, xhr);
27854 var response = Roo.decode(xhr.responseText);
27856 this.fireEvent('upload', this, response);
27860 xhrOnError : function()
27863 this.maskEl.unmask();
27866 Roo.log('xhr on error');
27868 var response = Roo.decode(xhr.responseText);
27874 prepare : function(file)
27877 this.maskEl.mask(this.loadingText);
27883 if(typeof(file) === 'string'){
27884 this.loadCanvas(file);
27888 if(!file || !this.urlAPI){
27893 this.cropType = file.type;
27897 if(this.fireEvent('prepare', this, this.file) != false){
27899 var reader = new FileReader();
27901 reader.onload = function (e) {
27902 if (e.target.error) {
27903 Roo.log(e.target.error);
27907 var buffer = e.target.result,
27908 dataView = new DataView(buffer),
27910 maxOffset = dataView.byteLength - 4,
27914 if (dataView.getUint16(0) === 0xffd8) {
27915 while (offset < maxOffset) {
27916 markerBytes = dataView.getUint16(offset);
27918 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
27919 markerLength = dataView.getUint16(offset + 2) + 2;
27920 if (offset + markerLength > dataView.byteLength) {
27921 Roo.log('Invalid meta data: Invalid segment size.');
27925 if(markerBytes == 0xffe1){
27926 _this.parseExifData(
27933 offset += markerLength;
27943 var url = _this.urlAPI.createObjectURL(_this.file);
27945 _this.loadCanvas(url);
27950 reader.readAsArrayBuffer(this.file);
27956 parseExifData : function(dataView, offset, length)
27958 var tiffOffset = offset + 10,
27962 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27963 // No Exif data, might be XMP data instead
27967 // Check for the ASCII code for "Exif" (0x45786966):
27968 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27969 // No Exif data, might be XMP data instead
27972 if (tiffOffset + 8 > dataView.byteLength) {
27973 Roo.log('Invalid Exif data: Invalid segment size.');
27976 // Check for the two null bytes:
27977 if (dataView.getUint16(offset + 8) !== 0x0000) {
27978 Roo.log('Invalid Exif data: Missing byte alignment offset.');
27981 // Check the byte alignment:
27982 switch (dataView.getUint16(tiffOffset)) {
27984 littleEndian = true;
27987 littleEndian = false;
27990 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
27993 // Check for the TIFF tag marker (0x002A):
27994 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
27995 Roo.log('Invalid Exif data: Missing TIFF marker.');
27998 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
27999 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28001 this.parseExifTags(
28004 tiffOffset + dirOffset,
28009 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28014 if (dirOffset + 6 > dataView.byteLength) {
28015 Roo.log('Invalid Exif data: Invalid directory offset.');
28018 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28019 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28020 if (dirEndOffset + 4 > dataView.byteLength) {
28021 Roo.log('Invalid Exif data: Invalid directory size.');
28024 for (i = 0; i < tagsNumber; i += 1) {
28028 dirOffset + 2 + 12 * i, // tag offset
28032 // Return the offset to the next directory:
28033 return dataView.getUint32(dirEndOffset, littleEndian);
28036 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28038 var tag = dataView.getUint16(offset, littleEndian);
28040 this.exif[tag] = this.getExifValue(
28044 dataView.getUint16(offset + 2, littleEndian), // tag type
28045 dataView.getUint32(offset + 4, littleEndian), // tag length
28050 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28052 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28061 Roo.log('Invalid Exif data: Invalid tag type.');
28065 tagSize = tagType.size * length;
28066 // Determine if the value is contained in the dataOffset bytes,
28067 // or if the value at the dataOffset is a pointer to the actual data:
28068 dataOffset = tagSize > 4 ?
28069 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28070 if (dataOffset + tagSize > dataView.byteLength) {
28071 Roo.log('Invalid Exif data: Invalid data offset.');
28074 if (length === 1) {
28075 return tagType.getValue(dataView, dataOffset, littleEndian);
28078 for (i = 0; i < length; i += 1) {
28079 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28082 if (tagType.ascii) {
28084 // Concatenate the chars:
28085 for (i = 0; i < values.length; i += 1) {
28087 // Ignore the terminating NULL byte(s):
28088 if (c === '\u0000') {
28100 Roo.apply(Roo.bootstrap.UploadCropbox, {
28102 'Orientation': 0x0112
28106 1: 0, //'top-left',
28108 3: 180, //'bottom-right',
28109 // 4: 'bottom-left',
28111 6: 90, //'right-top',
28112 // 7: 'right-bottom',
28113 8: 270 //'left-bottom'
28117 // byte, 8-bit unsigned int:
28119 getValue: function (dataView, dataOffset) {
28120 return dataView.getUint8(dataOffset);
28124 // ascii, 8-bit byte:
28126 getValue: function (dataView, dataOffset) {
28127 return String.fromCharCode(dataView.getUint8(dataOffset));
28132 // short, 16 bit int:
28134 getValue: function (dataView, dataOffset, littleEndian) {
28135 return dataView.getUint16(dataOffset, littleEndian);
28139 // long, 32 bit int:
28141 getValue: function (dataView, dataOffset, littleEndian) {
28142 return dataView.getUint32(dataOffset, littleEndian);
28146 // rational = two long values, first is numerator, second is denominator:
28148 getValue: function (dataView, dataOffset, littleEndian) {
28149 return dataView.getUint32(dataOffset, littleEndian) /
28150 dataView.getUint32(dataOffset + 4, littleEndian);
28154 // slong, 32 bit signed int:
28156 getValue: function (dataView, dataOffset, littleEndian) {
28157 return dataView.getInt32(dataOffset, littleEndian);
28161 // srational, two slongs, first is numerator, second is denominator:
28163 getValue: function (dataView, dataOffset, littleEndian) {
28164 return dataView.getInt32(dataOffset, littleEndian) /
28165 dataView.getInt32(dataOffset + 4, littleEndian);
28175 cls : 'btn-group roo-upload-cropbox-rotate-left',
28176 action : 'rotate-left',
28180 cls : 'btn btn-default',
28181 html : '<i class="fa fa-undo"></i>'
28187 cls : 'btn-group roo-upload-cropbox-picture',
28188 action : 'picture',
28192 cls : 'btn btn-default',
28193 html : '<i class="fa fa-picture-o"></i>'
28199 cls : 'btn-group roo-upload-cropbox-rotate-right',
28200 action : 'rotate-right',
28204 cls : 'btn btn-default',
28205 html : '<i class="fa fa-repeat"></i>'
28213 cls : 'btn-group roo-upload-cropbox-rotate-left',
28214 action : 'rotate-left',
28218 cls : 'btn btn-default',
28219 html : '<i class="fa fa-undo"></i>'
28225 cls : 'btn-group roo-upload-cropbox-download',
28226 action : 'download',
28230 cls : 'btn btn-default',
28231 html : '<i class="fa fa-download"></i>'
28237 cls : 'btn-group roo-upload-cropbox-crop',
28242 cls : 'btn btn-default',
28243 html : '<i class="fa fa-crop"></i>'
28249 cls : 'btn-group roo-upload-cropbox-trash',
28254 cls : 'btn btn-default',
28255 html : '<i class="fa fa-trash"></i>'
28261 cls : 'btn-group roo-upload-cropbox-rotate-right',
28262 action : 'rotate-right',
28266 cls : 'btn btn-default',
28267 html : '<i class="fa fa-repeat"></i>'
28275 cls : 'btn-group roo-upload-cropbox-rotate-left',
28276 action : 'rotate-left',
28280 cls : 'btn btn-default',
28281 html : '<i class="fa fa-undo"></i>'
28287 cls : 'btn-group roo-upload-cropbox-rotate-right',
28288 action : 'rotate-right',
28292 cls : 'btn btn-default',
28293 html : '<i class="fa fa-repeat"></i>'
28306 * @class Roo.bootstrap.DocumentManager
28307 * @extends Roo.bootstrap.Component
28308 * Bootstrap DocumentManager class
28309 * @cfg {String} paramName default 'imageUpload'
28310 * @cfg {String} toolTipName default 'filename'
28311 * @cfg {String} method default POST
28312 * @cfg {String} url action url
28313 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28314 * @cfg {Boolean} multiple multiple upload default true
28315 * @cfg {Number} thumbSize default 300
28316 * @cfg {String} fieldLabel
28317 * @cfg {Number} labelWidth default 4
28318 * @cfg {String} labelAlign (left|top) default left
28319 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28320 * @cfg {Number} labellg set the width of label (1-12)
28321 * @cfg {Number} labelmd set the width of label (1-12)
28322 * @cfg {Number} labelsm set the width of label (1-12)
28323 * @cfg {Number} labelxs set the width of label (1-12)
28326 * Create a new DocumentManager
28327 * @param {Object} config The config object
28330 Roo.bootstrap.DocumentManager = function(config){
28331 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28334 this.delegates = [];
28339 * Fire when initial the DocumentManager
28340 * @param {Roo.bootstrap.DocumentManager} this
28345 * inspect selected file
28346 * @param {Roo.bootstrap.DocumentManager} this
28347 * @param {File} file
28352 * Fire when xhr load exception
28353 * @param {Roo.bootstrap.DocumentManager} this
28354 * @param {XMLHttpRequest} xhr
28356 "exception" : true,
28358 * @event afterupload
28359 * Fire when xhr load exception
28360 * @param {Roo.bootstrap.DocumentManager} this
28361 * @param {XMLHttpRequest} xhr
28363 "afterupload" : true,
28366 * prepare the form data
28367 * @param {Roo.bootstrap.DocumentManager} this
28368 * @param {Object} formData
28373 * Fire when remove the file
28374 * @param {Roo.bootstrap.DocumentManager} this
28375 * @param {Object} file
28380 * Fire after refresh the file
28381 * @param {Roo.bootstrap.DocumentManager} this
28386 * Fire after click the image
28387 * @param {Roo.bootstrap.DocumentManager} this
28388 * @param {Object} file
28393 * Fire when upload a image and editable set to true
28394 * @param {Roo.bootstrap.DocumentManager} this
28395 * @param {Object} file
28399 * @event beforeselectfile
28400 * Fire before select file
28401 * @param {Roo.bootstrap.DocumentManager} this
28403 "beforeselectfile" : true,
28406 * Fire before process file
28407 * @param {Roo.bootstrap.DocumentManager} this
28408 * @param {Object} file
28415 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28424 paramName : 'imageUpload',
28425 toolTipName : 'filename',
28428 labelAlign : 'left',
28438 getAutoCreate : function()
28440 var managerWidget = {
28442 cls : 'roo-document-manager',
28446 cls : 'roo-document-manager-selector',
28451 cls : 'roo-document-manager-uploader',
28455 cls : 'roo-document-manager-upload-btn',
28456 html : '<i class="fa fa-plus"></i>'
28467 cls : 'column col-md-12',
28472 if(this.fieldLabel.length){
28477 cls : 'column col-md-12',
28478 html : this.fieldLabel
28482 cls : 'column col-md-12',
28487 if(this.labelAlign == 'left'){
28492 html : this.fieldLabel
28501 if(this.labelWidth > 12){
28502 content[0].style = "width: " + this.labelWidth + 'px';
28505 if(this.labelWidth < 13 && this.labelmd == 0){
28506 this.labelmd = this.labelWidth;
28509 if(this.labellg > 0){
28510 content[0].cls += ' col-lg-' + this.labellg;
28511 content[1].cls += ' col-lg-' + (12 - this.labellg);
28514 if(this.labelmd > 0){
28515 content[0].cls += ' col-md-' + this.labelmd;
28516 content[1].cls += ' col-md-' + (12 - this.labelmd);
28519 if(this.labelsm > 0){
28520 content[0].cls += ' col-sm-' + this.labelsm;
28521 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28524 if(this.labelxs > 0){
28525 content[0].cls += ' col-xs-' + this.labelxs;
28526 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28534 cls : 'row clearfix',
28542 initEvents : function()
28544 this.managerEl = this.el.select('.roo-document-manager', true).first();
28545 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28547 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28548 this.selectorEl.hide();
28551 this.selectorEl.attr('multiple', 'multiple');
28554 this.selectorEl.on('change', this.onFileSelected, this);
28556 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28557 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28559 this.uploader.on('click', this.onUploaderClick, this);
28561 this.renderProgressDialog();
28565 window.addEventListener("resize", function() { _this.refresh(); } );
28567 this.fireEvent('initial', this);
28570 renderProgressDialog : function()
28574 this.progressDialog = new Roo.bootstrap.Modal({
28575 cls : 'roo-document-manager-progress-dialog',
28576 allow_close : false,
28586 btnclick : function() {
28587 _this.uploadCancel();
28593 this.progressDialog.render(Roo.get(document.body));
28595 this.progress = new Roo.bootstrap.Progress({
28596 cls : 'roo-document-manager-progress',
28601 this.progress.render(this.progressDialog.getChildContainer());
28603 this.progressBar = new Roo.bootstrap.ProgressBar({
28604 cls : 'roo-document-manager-progress-bar',
28607 aria_valuemax : 12,
28611 this.progressBar.render(this.progress.getChildContainer());
28614 onUploaderClick : function(e)
28616 e.preventDefault();
28618 if(this.fireEvent('beforeselectfile', this) != false){
28619 this.selectorEl.dom.click();
28624 onFileSelected : function(e)
28626 e.preventDefault();
28628 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28632 Roo.each(this.selectorEl.dom.files, function(file){
28633 if(this.fireEvent('inspect', this, file) != false){
28634 this.files.push(file);
28644 this.selectorEl.dom.value = '';
28646 if(!this.files.length){
28650 if(this.boxes > 0 && this.files.length > this.boxes){
28651 this.files = this.files.slice(0, this.boxes);
28654 this.uploader.show();
28656 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28657 this.uploader.hide();
28666 Roo.each(this.files, function(file){
28668 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28669 var f = this.renderPreview(file);
28674 if(file.type.indexOf('image') != -1){
28675 this.delegates.push(
28677 _this.process(file);
28678 }).createDelegate(this)
28686 _this.process(file);
28687 }).createDelegate(this)
28692 this.files = files;
28694 this.delegates = this.delegates.concat(docs);
28696 if(!this.delegates.length){
28701 this.progressBar.aria_valuemax = this.delegates.length;
28708 arrange : function()
28710 if(!this.delegates.length){
28711 this.progressDialog.hide();
28716 var delegate = this.delegates.shift();
28718 this.progressDialog.show();
28720 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28722 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28727 refresh : function()
28729 this.uploader.show();
28731 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28732 this.uploader.hide();
28735 Roo.isTouch ? this.closable(false) : this.closable(true);
28737 this.fireEvent('refresh', this);
28740 onRemove : function(e, el, o)
28742 e.preventDefault();
28744 this.fireEvent('remove', this, o);
28748 remove : function(o)
28752 Roo.each(this.files, function(file){
28753 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28762 this.files = files;
28769 Roo.each(this.files, function(file){
28774 file.target.remove();
28783 onClick : function(e, el, o)
28785 e.preventDefault();
28787 this.fireEvent('click', this, o);
28791 closable : function(closable)
28793 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28795 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28807 xhrOnLoad : function(xhr)
28809 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28813 if (xhr.readyState !== 4) {
28815 this.fireEvent('exception', this, xhr);
28819 var response = Roo.decode(xhr.responseText);
28821 if(!response.success){
28823 this.fireEvent('exception', this, xhr);
28827 var file = this.renderPreview(response.data);
28829 this.files.push(file);
28833 this.fireEvent('afterupload', this, xhr);
28837 xhrOnError : function(xhr)
28839 Roo.log('xhr on error');
28841 var response = Roo.decode(xhr.responseText);
28848 process : function(file)
28850 if(this.fireEvent('process', this, file) !== false){
28851 if(this.editable && file.type.indexOf('image') != -1){
28852 this.fireEvent('edit', this, file);
28856 this.uploadStart(file, false);
28863 uploadStart : function(file, crop)
28865 this.xhr = new XMLHttpRequest();
28867 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28872 file.xhr = this.xhr;
28874 this.managerEl.createChild({
28876 cls : 'roo-document-manager-loading',
28880 tooltip : file.name,
28881 cls : 'roo-document-manager-thumb',
28882 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28888 this.xhr.open(this.method, this.url, true);
28891 "Accept": "application/json",
28892 "Cache-Control": "no-cache",
28893 "X-Requested-With": "XMLHttpRequest"
28896 for (var headerName in headers) {
28897 var headerValue = headers[headerName];
28899 this.xhr.setRequestHeader(headerName, headerValue);
28905 this.xhr.onload = function()
28907 _this.xhrOnLoad(_this.xhr);
28910 this.xhr.onerror = function()
28912 _this.xhrOnError(_this.xhr);
28915 var formData = new FormData();
28917 formData.append('returnHTML', 'NO');
28920 formData.append('crop', crop);
28923 formData.append(this.paramName, file, file.name);
28930 if(this.fireEvent('prepare', this, formData, options) != false){
28932 if(options.manually){
28936 this.xhr.send(formData);
28940 this.uploadCancel();
28943 uploadCancel : function()
28949 this.delegates = [];
28951 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28958 renderPreview : function(file)
28960 if(typeof(file.target) != 'undefined' && file.target){
28964 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
28966 var previewEl = this.managerEl.createChild({
28968 cls : 'roo-document-manager-preview',
28972 tooltip : file[this.toolTipName],
28973 cls : 'roo-document-manager-thumb',
28974 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
28979 html : '<i class="fa fa-times-circle"></i>'
28984 var close = previewEl.select('button.close', true).first();
28986 close.on('click', this.onRemove, this, file);
28988 file.target = previewEl;
28990 var image = previewEl.select('img', true).first();
28994 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
28996 image.on('click', this.onClick, this, file);
29002 onPreviewLoad : function(file, image)
29004 if(typeof(file.target) == 'undefined' || !file.target){
29008 var width = image.dom.naturalWidth || image.dom.width;
29009 var height = image.dom.naturalHeight || image.dom.height;
29011 if(width > height){
29012 file.target.addClass('wide');
29016 file.target.addClass('tall');
29021 uploadFromSource : function(file, crop)
29023 this.xhr = new XMLHttpRequest();
29025 this.managerEl.createChild({
29027 cls : 'roo-document-manager-loading',
29031 tooltip : file.name,
29032 cls : 'roo-document-manager-thumb',
29033 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29039 this.xhr.open(this.method, this.url, true);
29042 "Accept": "application/json",
29043 "Cache-Control": "no-cache",
29044 "X-Requested-With": "XMLHttpRequest"
29047 for (var headerName in headers) {
29048 var headerValue = headers[headerName];
29050 this.xhr.setRequestHeader(headerName, headerValue);
29056 this.xhr.onload = function()
29058 _this.xhrOnLoad(_this.xhr);
29061 this.xhr.onerror = function()
29063 _this.xhrOnError(_this.xhr);
29066 var formData = new FormData();
29068 formData.append('returnHTML', 'NO');
29070 formData.append('crop', crop);
29072 if(typeof(file.filename) != 'undefined'){
29073 formData.append('filename', file.filename);
29076 if(typeof(file.mimetype) != 'undefined'){
29077 formData.append('mimetype', file.mimetype);
29082 if(this.fireEvent('prepare', this, formData) != false){
29083 this.xhr.send(formData);
29093 * @class Roo.bootstrap.DocumentViewer
29094 * @extends Roo.bootstrap.Component
29095 * Bootstrap DocumentViewer class
29096 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29097 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29100 * Create a new DocumentViewer
29101 * @param {Object} config The config object
29104 Roo.bootstrap.DocumentViewer = function(config){
29105 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29110 * Fire after initEvent
29111 * @param {Roo.bootstrap.DocumentViewer} this
29117 * @param {Roo.bootstrap.DocumentViewer} this
29122 * Fire after download button
29123 * @param {Roo.bootstrap.DocumentViewer} this
29128 * Fire after trash button
29129 * @param {Roo.bootstrap.DocumentViewer} this
29136 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29138 showDownload : true,
29142 getAutoCreate : function()
29146 cls : 'roo-document-viewer',
29150 cls : 'roo-document-viewer-body',
29154 cls : 'roo-document-viewer-thumb',
29158 cls : 'roo-document-viewer-image'
29166 cls : 'roo-document-viewer-footer',
29169 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29173 cls : 'btn-group roo-document-viewer-download',
29177 cls : 'btn btn-default',
29178 html : '<i class="fa fa-download"></i>'
29184 cls : 'btn-group roo-document-viewer-trash',
29188 cls : 'btn btn-default',
29189 html : '<i class="fa fa-trash"></i>'
29202 initEvents : function()
29204 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29205 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29207 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29208 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29210 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29211 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29213 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29214 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29216 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29217 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29219 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29220 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29222 this.bodyEl.on('click', this.onClick, this);
29223 this.downloadBtn.on('click', this.onDownload, this);
29224 this.trashBtn.on('click', this.onTrash, this);
29226 this.downloadBtn.hide();
29227 this.trashBtn.hide();
29229 if(this.showDownload){
29230 this.downloadBtn.show();
29233 if(this.showTrash){
29234 this.trashBtn.show();
29237 if(!this.showDownload && !this.showTrash) {
29238 this.footerEl.hide();
29243 initial : function()
29245 this.fireEvent('initial', this);
29249 onClick : function(e)
29251 e.preventDefault();
29253 this.fireEvent('click', this);
29256 onDownload : function(e)
29258 e.preventDefault();
29260 this.fireEvent('download', this);
29263 onTrash : function(e)
29265 e.preventDefault();
29267 this.fireEvent('trash', this);
29279 * @class Roo.bootstrap.NavProgressBar
29280 * @extends Roo.bootstrap.Component
29281 * Bootstrap NavProgressBar class
29284 * Create a new nav progress bar
29285 * @param {Object} config The config object
29288 Roo.bootstrap.NavProgressBar = function(config){
29289 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29291 this.bullets = this.bullets || [];
29293 // Roo.bootstrap.NavProgressBar.register(this);
29297 * Fires when the active item changes
29298 * @param {Roo.bootstrap.NavProgressBar} this
29299 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29300 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29307 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29312 getAutoCreate : function()
29314 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29318 cls : 'roo-navigation-bar-group',
29322 cls : 'roo-navigation-top-bar'
29326 cls : 'roo-navigation-bullets-bar',
29330 cls : 'roo-navigation-bar'
29337 cls : 'roo-navigation-bottom-bar'
29347 initEvents: function()
29352 onRender : function(ct, position)
29354 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29356 if(this.bullets.length){
29357 Roo.each(this.bullets, function(b){
29366 addItem : function(cfg)
29368 var item = new Roo.bootstrap.NavProgressItem(cfg);
29370 item.parentId = this.id;
29371 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29374 var top = new Roo.bootstrap.Element({
29376 cls : 'roo-navigation-bar-text'
29379 var bottom = new Roo.bootstrap.Element({
29381 cls : 'roo-navigation-bar-text'
29384 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29385 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29387 var topText = new Roo.bootstrap.Element({
29389 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29392 var bottomText = new Roo.bootstrap.Element({
29394 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29397 topText.onRender(top.el, null);
29398 bottomText.onRender(bottom.el, null);
29401 item.bottomEl = bottom;
29404 this.barItems.push(item);
29409 getActive : function()
29411 var active = false;
29413 Roo.each(this.barItems, function(v){
29415 if (!v.isActive()) {
29427 setActiveItem : function(item)
29431 Roo.each(this.barItems, function(v){
29432 if (v.rid == item.rid) {
29436 if (v.isActive()) {
29437 v.setActive(false);
29442 item.setActive(true);
29444 this.fireEvent('changed', this, item, prev);
29447 getBarItem: function(rid)
29451 Roo.each(this.barItems, function(e) {
29452 if (e.rid != rid) {
29463 indexOfItem : function(item)
29467 Roo.each(this.barItems, function(v, i){
29469 if (v.rid != item.rid) {
29480 setActiveNext : function()
29482 var i = this.indexOfItem(this.getActive());
29484 if (i > this.barItems.length) {
29488 this.setActiveItem(this.barItems[i+1]);
29491 setActivePrev : function()
29493 var i = this.indexOfItem(this.getActive());
29499 this.setActiveItem(this.barItems[i-1]);
29502 format : function()
29504 if(!this.barItems.length){
29508 var width = 100 / this.barItems.length;
29510 Roo.each(this.barItems, function(i){
29511 i.el.setStyle('width', width + '%');
29512 i.topEl.el.setStyle('width', width + '%');
29513 i.bottomEl.el.setStyle('width', width + '%');
29522 * Nav Progress Item
29527 * @class Roo.bootstrap.NavProgressItem
29528 * @extends Roo.bootstrap.Component
29529 * Bootstrap NavProgressItem class
29530 * @cfg {String} rid the reference id
29531 * @cfg {Boolean} active (true|false) Is item active default false
29532 * @cfg {Boolean} disabled (true|false) Is item active default false
29533 * @cfg {String} html
29534 * @cfg {String} position (top|bottom) text position default bottom
29535 * @cfg {String} icon show icon instead of number
29538 * Create a new NavProgressItem
29539 * @param {Object} config The config object
29541 Roo.bootstrap.NavProgressItem = function(config){
29542 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29547 * The raw click event for the entire grid.
29548 * @param {Roo.bootstrap.NavProgressItem} this
29549 * @param {Roo.EventObject} e
29556 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29562 position : 'bottom',
29565 getAutoCreate : function()
29567 var iconCls = 'roo-navigation-bar-item-icon';
29569 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29573 cls: 'roo-navigation-bar-item',
29583 cfg.cls += ' active';
29586 cfg.cls += ' disabled';
29592 disable : function()
29594 this.setDisabled(true);
29597 enable : function()
29599 this.setDisabled(false);
29602 initEvents: function()
29604 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29606 this.iconEl.on('click', this.onClick, this);
29609 onClick : function(e)
29611 e.preventDefault();
29617 if(this.fireEvent('click', this, e) === false){
29621 this.parent().setActiveItem(this);
29624 isActive: function ()
29626 return this.active;
29629 setActive : function(state)
29631 if(this.active == state){
29635 this.active = state;
29638 this.el.addClass('active');
29642 this.el.removeClass('active');
29647 setDisabled : function(state)
29649 if(this.disabled == state){
29653 this.disabled = state;
29656 this.el.addClass('disabled');
29660 this.el.removeClass('disabled');
29663 tooltipEl : function()
29665 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29678 * @class Roo.bootstrap.FieldLabel
29679 * @extends Roo.bootstrap.Component
29680 * Bootstrap FieldLabel class
29681 * @cfg {String} html contents of the element
29682 * @cfg {String} tag tag of the element default label
29683 * @cfg {String} cls class of the element
29684 * @cfg {String} target label target
29685 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29686 * @cfg {String} invalidClass default "text-danger fa fa-lg fa-exclamation-triangle"
29687 * @cfg {String} validClass default "text-success fa fa-lg fa-check"
29688 * @cfg {String} iconTooltip default "This field is required"
29691 * Create a new FieldLabel
29692 * @param {Object} config The config object
29695 Roo.bootstrap.FieldLabel = function(config){
29696 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29701 * Fires after the field has been marked as invalid.
29702 * @param {Roo.form.FieldLabel} this
29703 * @param {String} msg The validation message
29708 * Fires after the field has been validated with no errors.
29709 * @param {Roo.form.FieldLabel} this
29715 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29722 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
29723 validClass : 'text-success fa fa-lg fa-check',
29724 iconTooltip : 'This field is required',
29726 getAutoCreate : function(){
29730 cls : 'roo-bootstrap-field-label ' + this.cls,
29736 tooltip : this.iconTooltip
29748 initEvents: function()
29750 Roo.bootstrap.Element.superclass.initEvents.call(this);
29752 this.iconEl = this.el.select('i', true).first();
29754 this.iconEl.setVisibilityMode(Roo.Element.DISPLAY).hide();
29756 Roo.bootstrap.FieldLabel.register(this);
29760 * Mark this field as valid
29762 markValid : function()
29764 this.iconEl.show();
29766 this.iconEl.removeClass(this.invalidClass);
29768 this.iconEl.addClass(this.validClass);
29770 this.fireEvent('valid', this);
29774 * Mark this field as invalid
29775 * @param {String} msg The validation message
29777 markInvalid : function(msg)
29779 this.iconEl.show();
29781 this.iconEl.removeClass(this.validClass);
29783 this.iconEl.addClass(this.invalidClass);
29785 this.fireEvent('invalid', this, msg);
29791 Roo.apply(Roo.bootstrap.FieldLabel, {
29796 * register a FieldLabel Group
29797 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29799 register : function(label)
29801 if(this.groups.hasOwnProperty(label.target)){
29805 this.groups[label.target] = label;
29809 * fetch a FieldLabel Group based on the target
29810 * @param {string} target
29811 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29813 get: function(target) {
29814 if (typeof(this.groups[target]) == 'undefined') {
29818 return this.groups[target] ;
29827 * page DateSplitField.
29833 * @class Roo.bootstrap.DateSplitField
29834 * @extends Roo.bootstrap.Component
29835 * Bootstrap DateSplitField class
29836 * @cfg {string} fieldLabel - the label associated
29837 * @cfg {Number} labelWidth set the width of label (0-12)
29838 * @cfg {String} labelAlign (top|left)
29839 * @cfg {Boolean} dayAllowBlank (true|false) default false
29840 * @cfg {Boolean} monthAllowBlank (true|false) default false
29841 * @cfg {Boolean} yearAllowBlank (true|false) default false
29842 * @cfg {string} dayPlaceholder
29843 * @cfg {string} monthPlaceholder
29844 * @cfg {string} yearPlaceholder
29845 * @cfg {string} dayFormat default 'd'
29846 * @cfg {string} monthFormat default 'm'
29847 * @cfg {string} yearFormat default 'Y'
29848 * @cfg {Number} labellg set the width of label (1-12)
29849 * @cfg {Number} labelmd set the width of label (1-12)
29850 * @cfg {Number} labelsm set the width of label (1-12)
29851 * @cfg {Number} labelxs set the width of label (1-12)
29855 * Create a new DateSplitField
29856 * @param {Object} config The config object
29859 Roo.bootstrap.DateSplitField = function(config){
29860 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
29866 * getting the data of years
29867 * @param {Roo.bootstrap.DateSplitField} this
29868 * @param {Object} years
29873 * getting the data of days
29874 * @param {Roo.bootstrap.DateSplitField} this
29875 * @param {Object} days
29880 * Fires after the field has been marked as invalid.
29881 * @param {Roo.form.Field} this
29882 * @param {String} msg The validation message
29887 * Fires after the field has been validated with no errors.
29888 * @param {Roo.form.Field} this
29894 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
29897 labelAlign : 'top',
29899 dayAllowBlank : false,
29900 monthAllowBlank : false,
29901 yearAllowBlank : false,
29902 dayPlaceholder : '',
29903 monthPlaceholder : '',
29904 yearPlaceholder : '',
29908 isFormField : true,
29914 getAutoCreate : function()
29918 cls : 'row roo-date-split-field-group',
29923 cls : 'form-hidden-field roo-date-split-field-group-value',
29929 var labelCls = 'col-md-12';
29930 var contentCls = 'col-md-4';
29932 if(this.fieldLabel){
29936 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
29940 html : this.fieldLabel
29945 if(this.labelAlign == 'left'){
29947 if(this.labelWidth > 12){
29948 label.style = "width: " + this.labelWidth + 'px';
29951 if(this.labelWidth < 13 && this.labelmd == 0){
29952 this.labelmd = this.labelWidth;
29955 if(this.labellg > 0){
29956 labelCls = ' col-lg-' + this.labellg;
29957 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
29960 if(this.labelmd > 0){
29961 labelCls = ' col-md-' + this.labelmd;
29962 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
29965 if(this.labelsm > 0){
29966 labelCls = ' col-sm-' + this.labelsm;
29967 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
29970 if(this.labelxs > 0){
29971 labelCls = ' col-xs-' + this.labelxs;
29972 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
29976 label.cls += ' ' + labelCls;
29978 cfg.cn.push(label);
29981 Roo.each(['day', 'month', 'year'], function(t){
29984 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
29991 inputEl: function ()
29993 return this.el.select('.roo-date-split-field-group-value', true).first();
29996 onRender : function(ct, position)
30000 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30002 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30004 this.dayField = new Roo.bootstrap.ComboBox({
30005 allowBlank : this.dayAllowBlank,
30006 alwaysQuery : true,
30007 displayField : 'value',
30010 forceSelection : true,
30012 placeholder : this.dayPlaceholder,
30013 selectOnFocus : true,
30014 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30015 triggerAction : 'all',
30017 valueField : 'value',
30018 store : new Roo.data.SimpleStore({
30019 data : (function() {
30021 _this.fireEvent('days', _this, days);
30024 fields : [ 'value' ]
30027 select : function (_self, record, index)
30029 _this.setValue(_this.getValue());
30034 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30036 this.monthField = new Roo.bootstrap.MonthField({
30037 after : '<i class=\"fa fa-calendar\"></i>',
30038 allowBlank : this.monthAllowBlank,
30039 placeholder : this.monthPlaceholder,
30042 render : function (_self)
30044 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30045 e.preventDefault();
30049 select : function (_self, oldvalue, newvalue)
30051 _this.setValue(_this.getValue());
30056 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30058 this.yearField = new Roo.bootstrap.ComboBox({
30059 allowBlank : this.yearAllowBlank,
30060 alwaysQuery : true,
30061 displayField : 'value',
30064 forceSelection : true,
30066 placeholder : this.yearPlaceholder,
30067 selectOnFocus : true,
30068 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30069 triggerAction : 'all',
30071 valueField : 'value',
30072 store : new Roo.data.SimpleStore({
30073 data : (function() {
30075 _this.fireEvent('years', _this, years);
30078 fields : [ 'value' ]
30081 select : function (_self, record, index)
30083 _this.setValue(_this.getValue());
30088 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30091 setValue : function(v, format)
30093 this.inputEl.dom.value = v;
30095 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30097 var d = Date.parseDate(v, f);
30104 this.setDay(d.format(this.dayFormat));
30105 this.setMonth(d.format(this.monthFormat));
30106 this.setYear(d.format(this.yearFormat));
30113 setDay : function(v)
30115 this.dayField.setValue(v);
30116 this.inputEl.dom.value = this.getValue();
30121 setMonth : function(v)
30123 this.monthField.setValue(v, true);
30124 this.inputEl.dom.value = this.getValue();
30129 setYear : function(v)
30131 this.yearField.setValue(v);
30132 this.inputEl.dom.value = this.getValue();
30137 getDay : function()
30139 return this.dayField.getValue();
30142 getMonth : function()
30144 return this.monthField.getValue();
30147 getYear : function()
30149 return this.yearField.getValue();
30152 getValue : function()
30154 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30156 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30166 this.inputEl.dom.value = '';
30171 validate : function()
30173 var d = this.dayField.validate();
30174 var m = this.monthField.validate();
30175 var y = this.yearField.validate();
30180 (!this.dayAllowBlank && !d) ||
30181 (!this.monthAllowBlank && !m) ||
30182 (!this.yearAllowBlank && !y)
30187 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30196 this.markInvalid();
30201 markValid : function()
30204 var label = this.el.select('label', true).first();
30205 var icon = this.el.select('i.fa-star', true).first();
30211 this.fireEvent('valid', this);
30215 * Mark this field as invalid
30216 * @param {String} msg The validation message
30218 markInvalid : function(msg)
30221 var label = this.el.select('label', true).first();
30222 var icon = this.el.select('i.fa-star', true).first();
30224 if(label && !icon){
30225 this.el.select('.roo-date-split-field-label', true).createChild({
30227 cls : 'text-danger fa fa-lg fa-star',
30228 tooltip : 'This field is required',
30229 style : 'margin-right:5px;'
30233 this.fireEvent('invalid', this, msg);
30236 clearInvalid : function()
30238 var label = this.el.select('label', true).first();
30239 var icon = this.el.select('i.fa-star', true).first();
30245 this.fireEvent('valid', this);
30248 getName: function()
30258 * http://masonry.desandro.com
30260 * The idea is to render all the bricks based on vertical width...
30262 * The original code extends 'outlayer' - we might need to use that....
30268 * @class Roo.bootstrap.LayoutMasonry
30269 * @extends Roo.bootstrap.Component
30270 * Bootstrap Layout Masonry class
30273 * Create a new Element
30274 * @param {Object} config The config object
30277 Roo.bootstrap.LayoutMasonry = function(config){
30279 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30283 Roo.bootstrap.LayoutMasonry.register(this);
30289 * Fire after layout the items
30290 * @param {Roo.bootstrap.LayoutMasonry} this
30291 * @param {Roo.EventObject} e
30298 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30301 * @cfg {Boolean} isLayoutInstant = no animation?
30303 isLayoutInstant : false, // needed?
30306 * @cfg {Number} boxWidth width of the columns
30311 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30316 * @cfg {Number} padWidth padding below box..
30321 * @cfg {Number} gutter gutter width..
30326 * @cfg {Number} maxCols maximum number of columns
30332 * @cfg {Boolean} isAutoInitial defalut true
30334 isAutoInitial : true,
30339 * @cfg {Boolean} isHorizontal defalut false
30341 isHorizontal : false,
30343 currentSize : null,
30349 bricks: null, //CompositeElement
30353 _isLayoutInited : false,
30355 // isAlternative : false, // only use for vertical layout...
30358 * @cfg {Number} alternativePadWidth padding below box..
30360 alternativePadWidth : 50,
30362 selectedBrick : [],
30364 getAutoCreate : function(){
30366 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30370 cls: 'blog-masonary-wrapper ' + this.cls,
30372 cls : 'mas-boxes masonary'
30379 getChildContainer: function( )
30381 if (this.boxesEl) {
30382 return this.boxesEl;
30385 this.boxesEl = this.el.select('.mas-boxes').first();
30387 return this.boxesEl;
30391 initEvents : function()
30395 if(this.isAutoInitial){
30396 Roo.log('hook children rendered');
30397 this.on('childrenrendered', function() {
30398 Roo.log('children rendered');
30404 initial : function()
30406 this.selectedBrick = [];
30408 this.currentSize = this.el.getBox(true);
30410 Roo.EventManager.onWindowResize(this.resize, this);
30412 if(!this.isAutoInitial){
30420 //this.layout.defer(500,this);
30424 resize : function()
30426 var cs = this.el.getBox(true);
30429 this.currentSize.width == cs.width &&
30430 this.currentSize.x == cs.x &&
30431 this.currentSize.height == cs.height &&
30432 this.currentSize.y == cs.y
30434 Roo.log("no change in with or X or Y");
30438 this.currentSize = cs;
30444 layout : function()
30446 this._resetLayout();
30448 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30450 this.layoutItems( isInstant );
30452 this._isLayoutInited = true;
30454 this.fireEvent('layout', this);
30458 _resetLayout : function()
30460 if(this.isHorizontal){
30461 this.horizontalMeasureColumns();
30465 this.verticalMeasureColumns();
30469 verticalMeasureColumns : function()
30471 this.getContainerWidth();
30473 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30474 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30478 var boxWidth = this.boxWidth + this.padWidth;
30480 if(this.containerWidth < this.boxWidth){
30481 boxWidth = this.containerWidth
30484 var containerWidth = this.containerWidth;
30486 var cols = Math.floor(containerWidth / boxWidth);
30488 this.cols = Math.max( cols, 1 );
30490 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30492 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30494 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30496 this.colWidth = boxWidth + avail - this.padWidth;
30498 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30499 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30502 horizontalMeasureColumns : function()
30504 this.getContainerWidth();
30506 var boxWidth = this.boxWidth;
30508 if(this.containerWidth < boxWidth){
30509 boxWidth = this.containerWidth;
30512 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30514 this.el.setHeight(boxWidth);
30518 getContainerWidth : function()
30520 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30523 layoutItems : function( isInstant )
30525 Roo.log(this.bricks);
30527 var items = Roo.apply([], this.bricks);
30529 if(this.isHorizontal){
30530 this._horizontalLayoutItems( items , isInstant );
30534 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30535 // this._verticalAlternativeLayoutItems( items , isInstant );
30539 this._verticalLayoutItems( items , isInstant );
30543 _verticalLayoutItems : function ( items , isInstant)
30545 if ( !items || !items.length ) {
30550 ['xs', 'xs', 'xs', 'tall'],
30551 ['xs', 'xs', 'tall'],
30552 ['xs', 'xs', 'sm'],
30553 ['xs', 'xs', 'xs'],
30559 ['sm', 'xs', 'xs'],
30563 ['tall', 'xs', 'xs', 'xs'],
30564 ['tall', 'xs', 'xs'],
30576 Roo.each(items, function(item, k){
30578 switch (item.size) {
30579 // these layouts take up a full box,
30590 boxes.push([item]);
30613 var filterPattern = function(box, length)
30621 var pattern = box.slice(0, length);
30625 Roo.each(pattern, function(i){
30626 format.push(i.size);
30629 Roo.each(standard, function(s){
30631 if(String(s) != String(format)){
30640 if(!match && length == 1){
30645 filterPattern(box, length - 1);
30649 queue.push(pattern);
30651 box = box.slice(length, box.length);
30653 filterPattern(box, 4);
30659 Roo.each(boxes, function(box, k){
30665 if(box.length == 1){
30670 filterPattern(box, 4);
30674 this._processVerticalLayoutQueue( queue, isInstant );
30678 // _verticalAlternativeLayoutItems : function( items , isInstant )
30680 // if ( !items || !items.length ) {
30684 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30688 _horizontalLayoutItems : function ( items , isInstant)
30690 if ( !items || !items.length || items.length < 3) {
30696 var eItems = items.slice(0, 3);
30698 items = items.slice(3, items.length);
30701 ['xs', 'xs', 'xs', 'wide'],
30702 ['xs', 'xs', 'wide'],
30703 ['xs', 'xs', 'sm'],
30704 ['xs', 'xs', 'xs'],
30710 ['sm', 'xs', 'xs'],
30714 ['wide', 'xs', 'xs', 'xs'],
30715 ['wide', 'xs', 'xs'],
30728 Roo.each(items, function(item, k){
30730 switch (item.size) {
30741 boxes.push([item]);
30765 var filterPattern = function(box, length)
30773 var pattern = box.slice(0, length);
30777 Roo.each(pattern, function(i){
30778 format.push(i.size);
30781 Roo.each(standard, function(s){
30783 if(String(s) != String(format)){
30792 if(!match && length == 1){
30797 filterPattern(box, length - 1);
30801 queue.push(pattern);
30803 box = box.slice(length, box.length);
30805 filterPattern(box, 4);
30811 Roo.each(boxes, function(box, k){
30817 if(box.length == 1){
30822 filterPattern(box, 4);
30829 var pos = this.el.getBox(true);
30833 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30835 var hit_end = false;
30837 Roo.each(queue, function(box){
30841 Roo.each(box, function(b){
30843 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30853 Roo.each(box, function(b){
30855 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30858 mx = Math.max(mx, b.x);
30862 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
30866 Roo.each(box, function(b){
30868 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30882 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
30885 /** Sets position of item in DOM
30886 * @param {Element} item
30887 * @param {Number} x - horizontal position
30888 * @param {Number} y - vertical position
30889 * @param {Boolean} isInstant - disables transitions
30891 _processVerticalLayoutQueue : function( queue, isInstant )
30893 var pos = this.el.getBox(true);
30898 for (var i = 0; i < this.cols; i++){
30902 Roo.each(queue, function(box, k){
30904 var col = k % this.cols;
30906 Roo.each(box, function(b,kk){
30908 b.el.position('absolute');
30910 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30911 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30913 if(b.size == 'md-left' || b.size == 'md-right'){
30914 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
30915 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
30918 b.el.setWidth(width);
30919 b.el.setHeight(height);
30921 b.el.select('iframe',true).setSize(width,height);
30925 for (var i = 0; i < this.cols; i++){
30927 if(maxY[i] < maxY[col]){
30932 col = Math.min(col, i);
30936 x = pos.x + col * (this.colWidth + this.padWidth);
30940 var positions = [];
30942 switch (box.length){
30944 positions = this.getVerticalOneBoxColPositions(x, y, box);
30947 positions = this.getVerticalTwoBoxColPositions(x, y, box);
30950 positions = this.getVerticalThreeBoxColPositions(x, y, box);
30953 positions = this.getVerticalFourBoxColPositions(x, y, box);
30959 Roo.each(box, function(b,kk){
30961 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
30963 var sz = b.el.getSize();
30965 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
30973 for (var i = 0; i < this.cols; i++){
30974 mY = Math.max(mY, maxY[i]);
30977 this.el.setHeight(mY - pos.y);
30981 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
30983 // var pos = this.el.getBox(true);
30986 // var maxX = pos.right;
30988 // var maxHeight = 0;
30990 // Roo.each(items, function(item, k){
30994 // item.el.position('absolute');
30996 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
30998 // item.el.setWidth(width);
31000 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31002 // item.el.setHeight(height);
31005 // item.el.setXY([x, y], isInstant ? false : true);
31007 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31010 // y = y + height + this.alternativePadWidth;
31012 // maxHeight = maxHeight + height + this.alternativePadWidth;
31016 // this.el.setHeight(maxHeight);
31020 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31022 var pos = this.el.getBox(true);
31027 var maxX = pos.right;
31029 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31031 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31033 Roo.each(queue, function(box, k){
31035 Roo.each(box, function(b, kk){
31037 b.el.position('absolute');
31039 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31040 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31042 if(b.size == 'md-left' || b.size == 'md-right'){
31043 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31044 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31047 b.el.setWidth(width);
31048 b.el.setHeight(height);
31056 var positions = [];
31058 switch (box.length){
31060 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31063 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31066 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31069 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31075 Roo.each(box, function(b,kk){
31077 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31079 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31087 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31089 Roo.each(eItems, function(b,k){
31091 b.size = (k == 0) ? 'sm' : 'xs';
31092 b.x = (k == 0) ? 2 : 1;
31093 b.y = (k == 0) ? 2 : 1;
31095 b.el.position('absolute');
31097 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31099 b.el.setWidth(width);
31101 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31103 b.el.setHeight(height);
31107 var positions = [];
31110 x : maxX - this.unitWidth * 2 - this.gutter,
31115 x : maxX - this.unitWidth,
31116 y : minY + (this.unitWidth + this.gutter) * 2
31120 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31124 Roo.each(eItems, function(b,k){
31126 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31132 getVerticalOneBoxColPositions : function(x, y, box)
31136 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31138 if(box[0].size == 'md-left'){
31142 if(box[0].size == 'md-right'){
31147 x : x + (this.unitWidth + this.gutter) * rand,
31154 getVerticalTwoBoxColPositions : function(x, y, box)
31158 if(box[0].size == 'xs'){
31162 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31166 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31180 x : x + (this.unitWidth + this.gutter) * 2,
31181 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31188 getVerticalThreeBoxColPositions : function(x, y, box)
31192 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31200 x : x + (this.unitWidth + this.gutter) * 1,
31205 x : x + (this.unitWidth + this.gutter) * 2,
31213 if(box[0].size == 'xs' && box[1].size == 'xs'){
31222 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31226 x : x + (this.unitWidth + this.gutter) * 1,
31240 x : x + (this.unitWidth + this.gutter) * 2,
31245 x : x + (this.unitWidth + this.gutter) * 2,
31246 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31253 getVerticalFourBoxColPositions : function(x, y, box)
31257 if(box[0].size == 'xs'){
31266 y : y + (this.unitHeight + this.gutter) * 1
31271 y : y + (this.unitHeight + this.gutter) * 2
31275 x : x + (this.unitWidth + this.gutter) * 1,
31289 x : x + (this.unitWidth + this.gutter) * 2,
31294 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31295 y : y + (this.unitHeight + this.gutter) * 1
31299 x : x + (this.unitWidth + this.gutter) * 2,
31300 y : y + (this.unitWidth + this.gutter) * 2
31307 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31311 if(box[0].size == 'md-left'){
31313 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31320 if(box[0].size == 'md-right'){
31322 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31323 y : minY + (this.unitWidth + this.gutter) * 1
31329 var rand = Math.floor(Math.random() * (4 - box[0].y));
31332 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31333 y : minY + (this.unitWidth + this.gutter) * rand
31340 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31344 if(box[0].size == 'xs'){
31347 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31352 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31353 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31361 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31366 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31367 y : minY + (this.unitWidth + this.gutter) * 2
31374 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31378 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31381 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31386 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31387 y : minY + (this.unitWidth + this.gutter) * 1
31391 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31392 y : minY + (this.unitWidth + this.gutter) * 2
31399 if(box[0].size == 'xs' && box[1].size == 'xs'){
31402 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31407 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31412 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31413 y : minY + (this.unitWidth + this.gutter) * 1
31421 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31426 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31427 y : minY + (this.unitWidth + this.gutter) * 2
31431 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31432 y : minY + (this.unitWidth + this.gutter) * 2
31439 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31443 if(box[0].size == 'xs'){
31446 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31451 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31456 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),
31461 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31462 y : minY + (this.unitWidth + this.gutter) * 1
31470 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31475 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31476 y : minY + (this.unitWidth + this.gutter) * 2
31480 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31481 y : minY + (this.unitWidth + this.gutter) * 2
31485 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),
31486 y : minY + (this.unitWidth + this.gutter) * 2
31494 * remove a Masonry Brick
31495 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31497 removeBrick : function(brick_id)
31503 for (var i = 0; i<this.bricks.length; i++) {
31504 if (this.bricks[i].id == brick_id) {
31505 this.bricks.splice(i,1);
31506 this.el.dom.removeChild(Roo.get(brick_id).dom);
31513 * adds a Masonry Brick
31514 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31516 addBrick : function(cfg)
31518 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31519 //this.register(cn);
31520 cn.parentId = this.id;
31521 cn.onRender(this.el, null);
31526 * register a Masonry Brick
31527 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31530 register : function(brick)
31532 this.bricks.push(brick);
31533 brick.masonryId = this.id;
31537 * clear all the Masonry Brick
31539 clearAll : function()
31542 //this.getChildContainer().dom.innerHTML = "";
31543 this.el.dom.innerHTML = '';
31546 getSelected : function()
31548 if (!this.selectedBrick) {
31552 return this.selectedBrick;
31556 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31560 * register a Masonry Layout
31561 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31564 register : function(layout)
31566 this.groups[layout.id] = layout;
31569 * fetch a Masonry Layout based on the masonry layout ID
31570 * @param {string} the masonry layout to add
31571 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31574 get: function(layout_id) {
31575 if (typeof(this.groups[layout_id]) == 'undefined') {
31578 return this.groups[layout_id] ;
31590 * http://masonry.desandro.com
31592 * The idea is to render all the bricks based on vertical width...
31594 * The original code extends 'outlayer' - we might need to use that....
31600 * @class Roo.bootstrap.LayoutMasonryAuto
31601 * @extends Roo.bootstrap.Component
31602 * Bootstrap Layout Masonry class
31605 * Create a new Element
31606 * @param {Object} config The config object
31609 Roo.bootstrap.LayoutMasonryAuto = function(config){
31610 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31613 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31616 * @cfg {Boolean} isFitWidth - resize the width..
31618 isFitWidth : false, // options..
31620 * @cfg {Boolean} isOriginLeft = left align?
31622 isOriginLeft : true,
31624 * @cfg {Boolean} isOriginTop = top align?
31626 isOriginTop : false,
31628 * @cfg {Boolean} isLayoutInstant = no animation?
31630 isLayoutInstant : false, // needed?
31632 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31634 isResizingContainer : true,
31636 * @cfg {Number} columnWidth width of the columns
31642 * @cfg {Number} maxCols maximum number of columns
31647 * @cfg {Number} padHeight padding below box..
31653 * @cfg {Boolean} isAutoInitial defalut true
31656 isAutoInitial : true,
31662 initialColumnWidth : 0,
31663 currentSize : null,
31665 colYs : null, // array.
31672 bricks: null, //CompositeElement
31673 cols : 0, // array?
31674 // element : null, // wrapped now this.el
31675 _isLayoutInited : null,
31678 getAutoCreate : function(){
31682 cls: 'blog-masonary-wrapper ' + this.cls,
31684 cls : 'mas-boxes masonary'
31691 getChildContainer: function( )
31693 if (this.boxesEl) {
31694 return this.boxesEl;
31697 this.boxesEl = this.el.select('.mas-boxes').first();
31699 return this.boxesEl;
31703 initEvents : function()
31707 if(this.isAutoInitial){
31708 Roo.log('hook children rendered');
31709 this.on('childrenrendered', function() {
31710 Roo.log('children rendered');
31717 initial : function()
31719 this.reloadItems();
31721 this.currentSize = this.el.getBox(true);
31723 /// was window resize... - let's see if this works..
31724 Roo.EventManager.onWindowResize(this.resize, this);
31726 if(!this.isAutoInitial){
31731 this.layout.defer(500,this);
31734 reloadItems: function()
31736 this.bricks = this.el.select('.masonry-brick', true);
31738 this.bricks.each(function(b) {
31739 //Roo.log(b.getSize());
31740 if (!b.attr('originalwidth')) {
31741 b.attr('originalwidth', b.getSize().width);
31746 Roo.log(this.bricks.elements.length);
31749 resize : function()
31752 var cs = this.el.getBox(true);
31754 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31755 Roo.log("no change in with or X");
31758 this.currentSize = cs;
31762 layout : function()
31765 this._resetLayout();
31766 //this._manageStamps();
31768 // don't animate first layout
31769 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31770 this.layoutItems( isInstant );
31772 // flag for initalized
31773 this._isLayoutInited = true;
31776 layoutItems : function( isInstant )
31778 //var items = this._getItemsForLayout( this.items );
31779 // original code supports filtering layout items.. we just ignore it..
31781 this._layoutItems( this.bricks , isInstant );
31783 this._postLayout();
31785 _layoutItems : function ( items , isInstant)
31787 //this.fireEvent( 'layout', this, items );
31790 if ( !items || !items.elements.length ) {
31791 // no items, emit event with empty array
31796 items.each(function(item) {
31797 Roo.log("layout item");
31799 // get x/y object from method
31800 var position = this._getItemLayoutPosition( item );
31802 position.item = item;
31803 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31804 queue.push( position );
31807 this._processLayoutQueue( queue );
31809 /** Sets position of item in DOM
31810 * @param {Element} item
31811 * @param {Number} x - horizontal position
31812 * @param {Number} y - vertical position
31813 * @param {Boolean} isInstant - disables transitions
31815 _processLayoutQueue : function( queue )
31817 for ( var i=0, len = queue.length; i < len; i++ ) {
31818 var obj = queue[i];
31819 obj.item.position('absolute');
31820 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31826 * Any logic you want to do after each layout,
31827 * i.e. size the container
31829 _postLayout : function()
31831 this.resizeContainer();
31834 resizeContainer : function()
31836 if ( !this.isResizingContainer ) {
31839 var size = this._getContainerSize();
31841 this.el.setSize(size.width,size.height);
31842 this.boxesEl.setSize(size.width,size.height);
31848 _resetLayout : function()
31850 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31851 this.colWidth = this.el.getWidth();
31852 //this.gutter = this.el.getWidth();
31854 this.measureColumns();
31860 this.colYs.push( 0 );
31866 measureColumns : function()
31868 this.getContainerWidth();
31869 // if columnWidth is 0, default to outerWidth of first item
31870 if ( !this.columnWidth ) {
31871 var firstItem = this.bricks.first();
31872 Roo.log(firstItem);
31873 this.columnWidth = this.containerWidth;
31874 if (firstItem && firstItem.attr('originalwidth') ) {
31875 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
31877 // columnWidth fall back to item of first element
31878 Roo.log("set column width?");
31879 this.initialColumnWidth = this.columnWidth ;
31881 // if first elem has no width, default to size of container
31886 if (this.initialColumnWidth) {
31887 this.columnWidth = this.initialColumnWidth;
31892 // column width is fixed at the top - however if container width get's smaller we should
31895 // this bit calcs how man columns..
31897 var columnWidth = this.columnWidth += this.gutter;
31899 // calculate columns
31900 var containerWidth = this.containerWidth + this.gutter;
31902 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
31903 // fix rounding errors, typically with gutters
31904 var excess = columnWidth - containerWidth % columnWidth;
31907 // if overshoot is less than a pixel, round up, otherwise floor it
31908 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
31909 cols = Math[ mathMethod ]( cols );
31910 this.cols = Math.max( cols, 1 );
31911 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31913 // padding positioning..
31914 var totalColWidth = this.cols * this.columnWidth;
31915 var padavail = this.containerWidth - totalColWidth;
31916 // so for 2 columns - we need 3 'pads'
31918 var padNeeded = (1+this.cols) * this.padWidth;
31920 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
31922 this.columnWidth += padExtra
31923 //this.padWidth = Math.floor(padavail / ( this.cols));
31925 // adjust colum width so that padding is fixed??
31927 // we have 3 columns ... total = width * 3
31928 // we have X left over... that should be used by
31930 //if (this.expandC) {
31938 getContainerWidth : function()
31940 /* // container is parent if fit width
31941 var container = this.isFitWidth ? this.element.parentNode : this.element;
31942 // check that this.size and size are there
31943 // IE8 triggers resize on body size change, so they might not be
31945 var size = getSize( container ); //FIXME
31946 this.containerWidth = size && size.innerWidth; //FIXME
31949 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31953 _getItemLayoutPosition : function( item ) // what is item?
31955 // we resize the item to our columnWidth..
31957 item.setWidth(this.columnWidth);
31958 item.autoBoxAdjust = false;
31960 var sz = item.getSize();
31962 // how many columns does this brick span
31963 var remainder = this.containerWidth % this.columnWidth;
31965 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
31966 // round if off by 1 pixel, otherwise use ceil
31967 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
31968 colSpan = Math.min( colSpan, this.cols );
31970 // normally this should be '1' as we dont' currently allow multi width columns..
31972 var colGroup = this._getColGroup( colSpan );
31973 // get the minimum Y value from the columns
31974 var minimumY = Math.min.apply( Math, colGroup );
31975 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31977 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
31979 // position the brick
31981 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
31982 y: this.currentSize.y + minimumY + this.padHeight
31986 // apply setHeight to necessary columns
31987 var setHeight = minimumY + sz.height + this.padHeight;
31988 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31990 var setSpan = this.cols + 1 - colGroup.length;
31991 for ( var i = 0; i < setSpan; i++ ) {
31992 this.colYs[ shortColIndex + i ] = setHeight ;
31999 * @param {Number} colSpan - number of columns the element spans
32000 * @returns {Array} colGroup
32002 _getColGroup : function( colSpan )
32004 if ( colSpan < 2 ) {
32005 // if brick spans only one column, use all the column Ys
32010 // how many different places could this brick fit horizontally
32011 var groupCount = this.cols + 1 - colSpan;
32012 // for each group potential horizontal position
32013 for ( var i = 0; i < groupCount; i++ ) {
32014 // make an array of colY values for that one group
32015 var groupColYs = this.colYs.slice( i, i + colSpan );
32016 // and get the max value of the array
32017 colGroup[i] = Math.max.apply( Math, groupColYs );
32022 _manageStamp : function( stamp )
32024 var stampSize = stamp.getSize();
32025 var offset = stamp.getBox();
32026 // get the columns that this stamp affects
32027 var firstX = this.isOriginLeft ? offset.x : offset.right;
32028 var lastX = firstX + stampSize.width;
32029 var firstCol = Math.floor( firstX / this.columnWidth );
32030 firstCol = Math.max( 0, firstCol );
32032 var lastCol = Math.floor( lastX / this.columnWidth );
32033 // lastCol should not go over if multiple of columnWidth #425
32034 lastCol -= lastX % this.columnWidth ? 0 : 1;
32035 lastCol = Math.min( this.cols - 1, lastCol );
32037 // set colYs to bottom of the stamp
32038 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32041 for ( var i = firstCol; i <= lastCol; i++ ) {
32042 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32047 _getContainerSize : function()
32049 this.maxY = Math.max.apply( Math, this.colYs );
32054 if ( this.isFitWidth ) {
32055 size.width = this._getContainerFitWidth();
32061 _getContainerFitWidth : function()
32063 var unusedCols = 0;
32064 // count unused columns
32067 if ( this.colYs[i] !== 0 ) {
32072 // fit container to columns that have been used
32073 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32076 needsResizeLayout : function()
32078 var previousWidth = this.containerWidth;
32079 this.getContainerWidth();
32080 return previousWidth !== this.containerWidth;
32095 * @class Roo.bootstrap.MasonryBrick
32096 * @extends Roo.bootstrap.Component
32097 * Bootstrap MasonryBrick class
32100 * Create a new MasonryBrick
32101 * @param {Object} config The config object
32104 Roo.bootstrap.MasonryBrick = function(config){
32106 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32108 Roo.bootstrap.MasonryBrick.register(this);
32114 * When a MasonryBrick is clcik
32115 * @param {Roo.bootstrap.MasonryBrick} this
32116 * @param {Roo.EventObject} e
32122 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32125 * @cfg {String} title
32129 * @cfg {String} html
32133 * @cfg {String} bgimage
32137 * @cfg {String} videourl
32141 * @cfg {String} cls
32145 * @cfg {String} href
32149 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32154 * @cfg {String} placetitle (center|bottom)
32159 * @cfg {Boolean} isFitContainer defalut true
32161 isFitContainer : true,
32164 * @cfg {Boolean} preventDefault defalut false
32166 preventDefault : false,
32169 * @cfg {Boolean} inverse defalut false
32171 maskInverse : false,
32173 getAutoCreate : function()
32175 if(!this.isFitContainer){
32176 return this.getSplitAutoCreate();
32179 var cls = 'masonry-brick masonry-brick-full';
32181 if(this.href.length){
32182 cls += ' masonry-brick-link';
32185 if(this.bgimage.length){
32186 cls += ' masonry-brick-image';
32189 if(this.maskInverse){
32190 cls += ' mask-inverse';
32193 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32194 cls += ' enable-mask';
32198 cls += ' masonry-' + this.size + '-brick';
32201 if(this.placetitle.length){
32203 switch (this.placetitle) {
32205 cls += ' masonry-center-title';
32208 cls += ' masonry-bottom-title';
32215 if(!this.html.length && !this.bgimage.length){
32216 cls += ' masonry-center-title';
32219 if(!this.html.length && this.bgimage.length){
32220 cls += ' masonry-bottom-title';
32225 cls += ' ' + this.cls;
32229 tag: (this.href.length) ? 'a' : 'div',
32234 cls: 'masonry-brick-mask'
32238 cls: 'masonry-brick-paragraph',
32244 if(this.href.length){
32245 cfg.href = this.href;
32248 var cn = cfg.cn[1].cn;
32250 if(this.title.length){
32253 cls: 'masonry-brick-title',
32258 if(this.html.length){
32261 cls: 'masonry-brick-text',
32266 if (!this.title.length && !this.html.length) {
32267 cfg.cn[1].cls += ' hide';
32270 if(this.bgimage.length){
32273 cls: 'masonry-brick-image-view',
32278 if(this.videourl.length){
32279 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32280 // youtube support only?
32283 cls: 'masonry-brick-image-view',
32286 allowfullscreen : true
32294 getSplitAutoCreate : function()
32296 var cls = 'masonry-brick masonry-brick-split';
32298 if(this.href.length){
32299 cls += ' masonry-brick-link';
32302 if(this.bgimage.length){
32303 cls += ' masonry-brick-image';
32307 cls += ' masonry-' + this.size + '-brick';
32310 switch (this.placetitle) {
32312 cls += ' masonry-center-title';
32315 cls += ' masonry-bottom-title';
32318 if(!this.bgimage.length){
32319 cls += ' masonry-center-title';
32322 if(this.bgimage.length){
32323 cls += ' masonry-bottom-title';
32329 cls += ' ' + this.cls;
32333 tag: (this.href.length) ? 'a' : 'div',
32338 cls: 'masonry-brick-split-head',
32342 cls: 'masonry-brick-paragraph',
32349 cls: 'masonry-brick-split-body',
32355 if(this.href.length){
32356 cfg.href = this.href;
32359 if(this.title.length){
32360 cfg.cn[0].cn[0].cn.push({
32362 cls: 'masonry-brick-title',
32367 if(this.html.length){
32368 cfg.cn[1].cn.push({
32370 cls: 'masonry-brick-text',
32375 if(this.bgimage.length){
32376 cfg.cn[0].cn.push({
32378 cls: 'masonry-brick-image-view',
32383 if(this.videourl.length){
32384 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32385 // youtube support only?
32386 cfg.cn[0].cn.cn.push({
32388 cls: 'masonry-brick-image-view',
32391 allowfullscreen : true
32398 initEvents: function()
32400 switch (this.size) {
32433 this.el.on('touchstart', this.onTouchStart, this);
32434 this.el.on('touchmove', this.onTouchMove, this);
32435 this.el.on('touchend', this.onTouchEnd, this);
32436 this.el.on('contextmenu', this.onContextMenu, this);
32438 this.el.on('mouseenter' ,this.enter, this);
32439 this.el.on('mouseleave', this.leave, this);
32440 this.el.on('click', this.onClick, this);
32443 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32444 this.parent().bricks.push(this);
32449 onClick: function(e, el)
32451 var time = this.endTimer - this.startTimer;
32452 // Roo.log(e.preventDefault());
32455 e.preventDefault();
32460 if(!this.preventDefault){
32464 e.preventDefault();
32466 if (this.activcClass != '') {
32467 this.selectBrick();
32470 this.fireEvent('click', this);
32473 enter: function(e, el)
32475 e.preventDefault();
32477 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32481 if(this.bgimage.length && this.html.length){
32482 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32486 leave: function(e, el)
32488 e.preventDefault();
32490 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32494 if(this.bgimage.length && this.html.length){
32495 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32499 onTouchStart: function(e, el)
32501 // e.preventDefault();
32503 this.touchmoved = false;
32505 if(!this.isFitContainer){
32509 if(!this.bgimage.length || !this.html.length){
32513 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32515 this.timer = new Date().getTime();
32519 onTouchMove: function(e, el)
32521 this.touchmoved = true;
32524 onContextMenu : function(e,el)
32526 e.preventDefault();
32527 e.stopPropagation();
32531 onTouchEnd: function(e, el)
32533 // e.preventDefault();
32535 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32542 if(!this.bgimage.length || !this.html.length){
32544 if(this.href.length){
32545 window.location.href = this.href;
32551 if(!this.isFitContainer){
32555 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32557 window.location.href = this.href;
32560 //selection on single brick only
32561 selectBrick : function() {
32563 if (!this.parentId) {
32567 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32568 var index = m.selectedBrick.indexOf(this.id);
32571 m.selectedBrick.splice(index,1);
32572 this.el.removeClass(this.activeClass);
32576 for(var i = 0; i < m.selectedBrick.length; i++) {
32577 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32578 b.el.removeClass(b.activeClass);
32581 m.selectedBrick = [];
32583 m.selectedBrick.push(this.id);
32584 this.el.addClass(this.activeClass);
32590 Roo.apply(Roo.bootstrap.MasonryBrick, {
32593 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32595 * register a Masonry Brick
32596 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32599 register : function(brick)
32601 //this.groups[brick.id] = brick;
32602 this.groups.add(brick.id, brick);
32605 * fetch a masonry brick based on the masonry brick ID
32606 * @param {string} the masonry brick to add
32607 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32610 get: function(brick_id)
32612 // if (typeof(this.groups[brick_id]) == 'undefined') {
32615 // return this.groups[brick_id] ;
32617 if(this.groups.key(brick_id)) {
32618 return this.groups.key(brick_id);
32636 * @class Roo.bootstrap.Brick
32637 * @extends Roo.bootstrap.Component
32638 * Bootstrap Brick class
32641 * Create a new Brick
32642 * @param {Object} config The config object
32645 Roo.bootstrap.Brick = function(config){
32646 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32652 * When a Brick is click
32653 * @param {Roo.bootstrap.Brick} this
32654 * @param {Roo.EventObject} e
32660 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32663 * @cfg {String} title
32667 * @cfg {String} html
32671 * @cfg {String} bgimage
32675 * @cfg {String} cls
32679 * @cfg {String} href
32683 * @cfg {String} video
32687 * @cfg {Boolean} square
32691 getAutoCreate : function()
32693 var cls = 'roo-brick';
32695 if(this.href.length){
32696 cls += ' roo-brick-link';
32699 if(this.bgimage.length){
32700 cls += ' roo-brick-image';
32703 if(!this.html.length && !this.bgimage.length){
32704 cls += ' roo-brick-center-title';
32707 if(!this.html.length && this.bgimage.length){
32708 cls += ' roo-brick-bottom-title';
32712 cls += ' ' + this.cls;
32716 tag: (this.href.length) ? 'a' : 'div',
32721 cls: 'roo-brick-paragraph',
32727 if(this.href.length){
32728 cfg.href = this.href;
32731 var cn = cfg.cn[0].cn;
32733 if(this.title.length){
32736 cls: 'roo-brick-title',
32741 if(this.html.length){
32744 cls: 'roo-brick-text',
32751 if(this.bgimage.length){
32754 cls: 'roo-brick-image-view',
32762 initEvents: function()
32764 if(this.title.length || this.html.length){
32765 this.el.on('mouseenter' ,this.enter, this);
32766 this.el.on('mouseleave', this.leave, this);
32769 Roo.EventManager.onWindowResize(this.resize, this);
32771 if(this.bgimage.length){
32772 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32773 this.imageEl.on('load', this.onImageLoad, this);
32780 onImageLoad : function()
32785 resize : function()
32787 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32789 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32791 if(this.bgimage.length){
32792 var image = this.el.select('.roo-brick-image-view', true).first();
32794 image.setWidth(paragraph.getWidth());
32797 image.setHeight(paragraph.getWidth());
32800 this.el.setHeight(image.getHeight());
32801 paragraph.setHeight(image.getHeight());
32807 enter: function(e, el)
32809 e.preventDefault();
32811 if(this.bgimage.length){
32812 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32813 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32817 leave: function(e, el)
32819 e.preventDefault();
32821 if(this.bgimage.length){
32822 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32823 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32839 * @class Roo.bootstrap.NumberField
32840 * @extends Roo.bootstrap.Input
32841 * Bootstrap NumberField class
32847 * Create a new NumberField
32848 * @param {Object} config The config object
32851 Roo.bootstrap.NumberField = function(config){
32852 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32855 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32858 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
32860 allowDecimals : true,
32862 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
32864 decimalSeparator : ".",
32866 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
32868 decimalPrecision : 2,
32870 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
32872 allowNegative : true,
32874 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
32876 minValue : Number.NEGATIVE_INFINITY,
32878 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
32880 maxValue : Number.MAX_VALUE,
32882 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
32884 minText : "The minimum value for this field is {0}",
32886 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
32888 maxText : "The maximum value for this field is {0}",
32890 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
32891 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
32893 nanText : "{0} is not a valid number",
32895 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
32900 initEvents : function()
32902 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
32904 var allowed = "0123456789";
32906 if(this.allowDecimals){
32907 allowed += this.decimalSeparator;
32910 if(this.allowNegative){
32914 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
32916 var keyPress = function(e){
32918 var k = e.getKey();
32920 var c = e.getCharCode();
32923 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
32924 allowed.indexOf(String.fromCharCode(c)) === -1
32930 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
32934 if(allowed.indexOf(String.fromCharCode(c)) === -1){
32939 this.el.on("keypress", keyPress, this);
32942 validateValue : function(value)
32945 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
32949 var num = this.parseValue(value);
32952 this.markInvalid(String.format(this.nanText, value));
32956 if(num < this.minValue){
32957 this.markInvalid(String.format(this.minText, this.minValue));
32961 if(num > this.maxValue){
32962 this.markInvalid(String.format(this.maxText, this.maxValue));
32969 getValue : function()
32971 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
32974 parseValue : function(value)
32976 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
32977 return isNaN(value) ? '' : value;
32980 fixPrecision : function(value)
32982 var nan = isNaN(value);
32984 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
32985 return nan ? '' : value;
32987 return parseFloat(value).toFixed(this.decimalPrecision);
32990 setValue : function(v)
32992 v = this.fixPrecision(v);
32993 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
32996 decimalPrecisionFcn : function(v)
32998 return Math.floor(v);
33001 beforeBlur : function()
33007 var v = this.parseValue(this.getRawValue());
33022 * @class Roo.bootstrap.DocumentSlider
33023 * @extends Roo.bootstrap.Component
33024 * Bootstrap DocumentSlider class
33027 * Create a new DocumentViewer
33028 * @param {Object} config The config object
33031 Roo.bootstrap.DocumentSlider = function(config){
33032 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33039 * Fire after initEvent
33040 * @param {Roo.bootstrap.DocumentSlider} this
33045 * Fire after update
33046 * @param {Roo.bootstrap.DocumentSlider} this
33052 * @param {Roo.bootstrap.DocumentSlider} this
33058 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33064 getAutoCreate : function()
33068 cls : 'roo-document-slider',
33072 cls : 'roo-document-slider-header',
33076 cls : 'roo-document-slider-header-title'
33082 cls : 'roo-document-slider-body',
33086 cls : 'roo-document-slider-prev',
33090 cls : 'fa fa-chevron-left'
33096 cls : 'roo-document-slider-thumb',
33100 cls : 'roo-document-slider-image'
33106 cls : 'roo-document-slider-next',
33110 cls : 'fa fa-chevron-right'
33122 initEvents : function()
33124 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33125 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33127 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33128 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33130 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33131 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33133 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33134 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33136 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33137 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33139 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33140 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33142 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33143 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33145 this.thumbEl.on('click', this.onClick, this);
33147 this.prevIndicator.on('click', this.prev, this);
33149 this.nextIndicator.on('click', this.next, this);
33153 initial : function()
33155 if(this.files.length){
33156 this.indicator = 1;
33160 this.fireEvent('initial', this);
33163 update : function()
33165 this.imageEl.attr('src', this.files[this.indicator - 1]);
33167 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33169 this.prevIndicator.show();
33171 if(this.indicator == 1){
33172 this.prevIndicator.hide();
33175 this.nextIndicator.show();
33177 if(this.indicator == this.files.length){
33178 this.nextIndicator.hide();
33181 this.thumbEl.scrollTo('top');
33183 this.fireEvent('update', this);
33186 onClick : function(e)
33188 e.preventDefault();
33190 this.fireEvent('click', this);
33195 e.preventDefault();
33197 this.indicator = Math.max(1, this.indicator - 1);
33204 e.preventDefault();
33206 this.indicator = Math.min(this.files.length, this.indicator + 1);
33220 * @class Roo.bootstrap.RadioSet
33221 * @extends Roo.bootstrap.Input
33222 * Bootstrap RadioSet class
33223 * @cfg {String} indicatorpos (left|right) default left
33224 * @cfg {Boolean} inline (true|false) inline the element (default true)
33225 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33227 * Create a new RadioSet
33228 * @param {Object} config The config object
33231 Roo.bootstrap.RadioSet = function(config){
33233 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33237 Roo.bootstrap.RadioSet.register(this);
33242 * Fires when the element is checked or unchecked.
33243 * @param {Roo.bootstrap.RadioSet} this This radio
33244 * @param {Roo.bootstrap.Radio} item The checked item
33251 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33259 indicatorpos : 'left',
33261 getAutoCreate : function()
33265 cls : 'roo-radio-set-label',
33269 html : this.fieldLabel
33274 if(this.indicatorpos == 'left'){
33277 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33278 tooltip : 'This field is required'
33283 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33284 tooltip : 'This field is required'
33290 cls : 'roo-radio-set-items'
33293 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33295 if (align === 'left' && this.fieldLabel.length) {
33298 cls : "roo-radio-set-right",
33304 if(this.labelWidth > 12){
33305 label.style = "width: " + this.labelWidth + 'px';
33308 if(this.labelWidth < 13 && this.labelmd == 0){
33309 this.labelmd = this.labelWidth;
33312 if(this.labellg > 0){
33313 label.cls += ' col-lg-' + this.labellg;
33314 items.cls += ' col-lg-' + (12 - this.labellg);
33317 if(this.labelmd > 0){
33318 label.cls += ' col-md-' + this.labelmd;
33319 items.cls += ' col-md-' + (12 - this.labelmd);
33322 if(this.labelsm > 0){
33323 label.cls += ' col-sm-' + this.labelsm;
33324 items.cls += ' col-sm-' + (12 - this.labelsm);
33327 if(this.labelxs > 0){
33328 label.cls += ' col-xs-' + this.labelxs;
33329 items.cls += ' col-xs-' + (12 - this.labelxs);
33335 cls : 'roo-radio-set',
33339 cls : 'roo-radio-set-input',
33342 value : this.value ? this.value : ''
33349 if(this.weight.length){
33350 cfg.cls += ' roo-radio-' + this.weight;
33354 cfg.cls += ' roo-radio-set-inline';
33358 ['xs','sm','md','lg'].map(function(size){
33359 if (settings[size]) {
33360 cfg.cls += ' col-' + size + '-' + settings[size];
33368 initEvents : function()
33370 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33371 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33373 if(!this.fieldLabel.length){
33374 this.labelEl.hide();
33377 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33378 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33380 this.indicatorEl().addClass('invisible');
33382 this.originalValue = this.getValue();
33386 inputEl: function ()
33388 return this.el.select('.roo-radio-set-input', true).first();
33391 getChildContainer : function()
33393 return this.itemsEl;
33396 register : function(item)
33398 this.radioes.push(item);
33402 validate : function()
33406 Roo.each(this.radioes, function(i){
33415 if(this.allowBlank) {
33419 if(this.disabled || valid){
33424 this.markInvalid();
33429 markValid : function()
33431 if(this.labelEl.isVisible(true)){
33432 this.indicatorEl().removeClass('visible');
33433 this.indicatorEl().addClass('invisible');
33436 this.el.removeClass([this.invalidClass, this.validClass]);
33437 this.el.addClass(this.validClass);
33439 this.fireEvent('valid', this);
33442 markInvalid : function(msg)
33444 if(this.allowBlank || this.disabled){
33448 if(this.labelEl.isVisible(true)){
33449 this.indicatorEl().removeClass('invisible');
33450 this.indicatorEl().addClass('visible');
33453 this.el.removeClass([this.invalidClass, this.validClass]);
33454 this.el.addClass(this.invalidClass);
33456 this.fireEvent('invalid', this, msg);
33460 setValue : function(v, suppressEvent)
33464 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33467 Roo.each(this.radioes, function(i){
33470 i.el.removeClass('checked');
33472 if(i.value === v || i.value.toString() === v.toString()){
33474 i.el.addClass('checked');
33476 if(suppressEvent !== true){
33477 this.fireEvent('check', this, i);
33486 clearInvalid : function(){
33488 if(!this.el || this.preventMark){
33492 this.el.removeClass([this.invalidClass]);
33494 this.fireEvent('valid', this);
33499 Roo.apply(Roo.bootstrap.RadioSet, {
33503 register : function(set)
33505 this.groups[set.name] = set;
33508 get: function(name)
33510 if (typeof(this.groups[name]) == 'undefined') {
33514 return this.groups[name] ;
33520 * Ext JS Library 1.1.1
33521 * Copyright(c) 2006-2007, Ext JS, LLC.
33523 * Originally Released Under LGPL - original licence link has changed is not relivant.
33526 * <script type="text/javascript">
33531 * @class Roo.bootstrap.SplitBar
33532 * @extends Roo.util.Observable
33533 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33537 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33538 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33539 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33540 split.minSize = 100;
33541 split.maxSize = 600;
33542 split.animate = true;
33543 split.on('moved', splitterMoved);
33546 * Create a new SplitBar
33547 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33548 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33549 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33550 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33551 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33552 position of the SplitBar).
33554 Roo.bootstrap.SplitBar = function(cfg){
33559 // dragElement : elm
33560 // resizingElement: el,
33562 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33563 // placement : Roo.bootstrap.SplitBar.LEFT ,
33564 // existingProxy ???
33567 this.el = Roo.get(cfg.dragElement, true);
33568 this.el.dom.unselectable = "on";
33570 this.resizingEl = Roo.get(cfg.resizingElement, true);
33574 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33575 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33578 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33581 * The minimum size of the resizing element. (Defaults to 0)
33587 * The maximum size of the resizing element. (Defaults to 2000)
33590 this.maxSize = 2000;
33593 * Whether to animate the transition to the new size
33596 this.animate = false;
33599 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33602 this.useShim = false;
33607 if(!cfg.existingProxy){
33609 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33611 this.proxy = Roo.get(cfg.existingProxy).dom;
33614 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33617 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33620 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33623 this.dragSpecs = {};
33626 * @private The adapter to use to positon and resize elements
33628 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33629 this.adapter.init(this);
33631 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33633 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33634 this.el.addClass("roo-splitbar-h");
33637 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33638 this.el.addClass("roo-splitbar-v");
33644 * Fires when the splitter is moved (alias for {@link #event-moved})
33645 * @param {Roo.bootstrap.SplitBar} this
33646 * @param {Number} newSize the new width or height
33651 * Fires when the splitter is moved
33652 * @param {Roo.bootstrap.SplitBar} this
33653 * @param {Number} newSize the new width or height
33657 * @event beforeresize
33658 * Fires before the splitter is dragged
33659 * @param {Roo.bootstrap.SplitBar} this
33661 "beforeresize" : true,
33663 "beforeapply" : true
33666 Roo.util.Observable.call(this);
33669 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33670 onStartProxyDrag : function(x, y){
33671 this.fireEvent("beforeresize", this);
33673 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33675 o.enableDisplayMode("block");
33676 // all splitbars share the same overlay
33677 Roo.bootstrap.SplitBar.prototype.overlay = o;
33679 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33680 this.overlay.show();
33681 Roo.get(this.proxy).setDisplayed("block");
33682 var size = this.adapter.getElementSize(this);
33683 this.activeMinSize = this.getMinimumSize();;
33684 this.activeMaxSize = this.getMaximumSize();;
33685 var c1 = size - this.activeMinSize;
33686 var c2 = Math.max(this.activeMaxSize - size, 0);
33687 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33688 this.dd.resetConstraints();
33689 this.dd.setXConstraint(
33690 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33691 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33693 this.dd.setYConstraint(0, 0);
33695 this.dd.resetConstraints();
33696 this.dd.setXConstraint(0, 0);
33697 this.dd.setYConstraint(
33698 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33699 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33702 this.dragSpecs.startSize = size;
33703 this.dragSpecs.startPoint = [x, y];
33704 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33708 * @private Called after the drag operation by the DDProxy
33710 onEndProxyDrag : function(e){
33711 Roo.get(this.proxy).setDisplayed(false);
33712 var endPoint = Roo.lib.Event.getXY(e);
33714 this.overlay.hide();
33717 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33718 newSize = this.dragSpecs.startSize +
33719 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33720 endPoint[0] - this.dragSpecs.startPoint[0] :
33721 this.dragSpecs.startPoint[0] - endPoint[0]
33724 newSize = this.dragSpecs.startSize +
33725 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33726 endPoint[1] - this.dragSpecs.startPoint[1] :
33727 this.dragSpecs.startPoint[1] - endPoint[1]
33730 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33731 if(newSize != this.dragSpecs.startSize){
33732 if(this.fireEvent('beforeapply', this, newSize) !== false){
33733 this.adapter.setElementSize(this, newSize);
33734 this.fireEvent("moved", this, newSize);
33735 this.fireEvent("resize", this, newSize);
33741 * Get the adapter this SplitBar uses
33742 * @return The adapter object
33744 getAdapter : function(){
33745 return this.adapter;
33749 * Set the adapter this SplitBar uses
33750 * @param {Object} adapter A SplitBar adapter object
33752 setAdapter : function(adapter){
33753 this.adapter = adapter;
33754 this.adapter.init(this);
33758 * Gets the minimum size for the resizing element
33759 * @return {Number} The minimum size
33761 getMinimumSize : function(){
33762 return this.minSize;
33766 * Sets the minimum size for the resizing element
33767 * @param {Number} minSize The minimum size
33769 setMinimumSize : function(minSize){
33770 this.minSize = minSize;
33774 * Gets the maximum size for the resizing element
33775 * @return {Number} The maximum size
33777 getMaximumSize : function(){
33778 return this.maxSize;
33782 * Sets the maximum size for the resizing element
33783 * @param {Number} maxSize The maximum size
33785 setMaximumSize : function(maxSize){
33786 this.maxSize = maxSize;
33790 * Sets the initialize size for the resizing element
33791 * @param {Number} size The initial size
33793 setCurrentSize : function(size){
33794 var oldAnimate = this.animate;
33795 this.animate = false;
33796 this.adapter.setElementSize(this, size);
33797 this.animate = oldAnimate;
33801 * Destroy this splitbar.
33802 * @param {Boolean} removeEl True to remove the element
33804 destroy : function(removeEl){
33806 this.shim.remove();
33809 this.proxy.parentNode.removeChild(this.proxy);
33817 * @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.
33819 Roo.bootstrap.SplitBar.createProxy = function(dir){
33820 var proxy = new Roo.Element(document.createElement("div"));
33821 proxy.unselectable();
33822 var cls = 'roo-splitbar-proxy';
33823 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
33824 document.body.appendChild(proxy.dom);
33829 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
33830 * Default Adapter. It assumes the splitter and resizing element are not positioned
33831 * elements and only gets/sets the width of the element. Generally used for table based layouts.
33833 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
33836 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
33837 // do nothing for now
33838 init : function(s){
33842 * Called before drag operations to get the current size of the resizing element.
33843 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33845 getElementSize : function(s){
33846 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33847 return s.resizingEl.getWidth();
33849 return s.resizingEl.getHeight();
33854 * Called after drag operations to set the size of the resizing element.
33855 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33856 * @param {Number} newSize The new size to set
33857 * @param {Function} onComplete A function to be invoked when resizing is complete
33859 setElementSize : function(s, newSize, onComplete){
33860 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33862 s.resizingEl.setWidth(newSize);
33864 onComplete(s, newSize);
33867 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
33872 s.resizingEl.setHeight(newSize);
33874 onComplete(s, newSize);
33877 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
33884 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
33885 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
33886 * Adapter that moves the splitter element to align with the resized sizing element.
33887 * Used with an absolute positioned SplitBar.
33888 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
33889 * document.body, make sure you assign an id to the body element.
33891 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
33892 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33893 this.container = Roo.get(container);
33896 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
33897 init : function(s){
33898 this.basic.init(s);
33901 getElementSize : function(s){
33902 return this.basic.getElementSize(s);
33905 setElementSize : function(s, newSize, onComplete){
33906 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
33909 moveSplitter : function(s){
33910 var yes = Roo.bootstrap.SplitBar;
33911 switch(s.placement){
33913 s.el.setX(s.resizingEl.getRight());
33916 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
33919 s.el.setY(s.resizingEl.getBottom());
33922 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
33929 * Orientation constant - Create a vertical SplitBar
33933 Roo.bootstrap.SplitBar.VERTICAL = 1;
33936 * Orientation constant - Create a horizontal SplitBar
33940 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
33943 * Placement constant - The resizing element is to the left of the splitter element
33947 Roo.bootstrap.SplitBar.LEFT = 1;
33950 * Placement constant - The resizing element is to the right of the splitter element
33954 Roo.bootstrap.SplitBar.RIGHT = 2;
33957 * Placement constant - The resizing element is positioned above the splitter element
33961 Roo.bootstrap.SplitBar.TOP = 3;
33964 * Placement constant - The resizing element is positioned under splitter element
33968 Roo.bootstrap.SplitBar.BOTTOM = 4;
33969 Roo.namespace("Roo.bootstrap.layout");/*
33971 * Ext JS Library 1.1.1
33972 * Copyright(c) 2006-2007, Ext JS, LLC.
33974 * Originally Released Under LGPL - original licence link has changed is not relivant.
33977 * <script type="text/javascript">
33981 * @class Roo.bootstrap.layout.Manager
33982 * @extends Roo.bootstrap.Component
33983 * Base class for layout managers.
33985 Roo.bootstrap.layout.Manager = function(config)
33987 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
33993 /** false to disable window resize monitoring @type Boolean */
33994 this.monitorWindowResize = true;
33999 * Fires when a layout is performed.
34000 * @param {Roo.LayoutManager} this
34004 * @event regionresized
34005 * Fires when the user resizes a region.
34006 * @param {Roo.LayoutRegion} region The resized region
34007 * @param {Number} newSize The new size (width for east/west, height for north/south)
34009 "regionresized" : true,
34011 * @event regioncollapsed
34012 * Fires when a region is collapsed.
34013 * @param {Roo.LayoutRegion} region The collapsed region
34015 "regioncollapsed" : true,
34017 * @event regionexpanded
34018 * Fires when a region is expanded.
34019 * @param {Roo.LayoutRegion} region The expanded region
34021 "regionexpanded" : true
34023 this.updating = false;
34026 this.el = Roo.get(config.el);
34032 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34037 monitorWindowResize : true,
34043 onRender : function(ct, position)
34046 this.el = Roo.get(ct);
34049 //this.fireEvent('render',this);
34053 initEvents: function()
34057 // ie scrollbar fix
34058 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34059 document.body.scroll = "no";
34060 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34061 this.el.position('relative');
34063 this.id = this.el.id;
34064 this.el.addClass("roo-layout-container");
34065 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34066 if(this.el.dom != document.body ) {
34067 this.el.on('resize', this.layout,this);
34068 this.el.on('show', this.layout,this);
34074 * Returns true if this layout is currently being updated
34075 * @return {Boolean}
34077 isUpdating : function(){
34078 return this.updating;
34082 * Suspend the LayoutManager from doing auto-layouts while
34083 * making multiple add or remove calls
34085 beginUpdate : function(){
34086 this.updating = true;
34090 * Restore auto-layouts and optionally disable the manager from performing a layout
34091 * @param {Boolean} noLayout true to disable a layout update
34093 endUpdate : function(noLayout){
34094 this.updating = false;
34100 layout: function(){
34104 onRegionResized : function(region, newSize){
34105 this.fireEvent("regionresized", region, newSize);
34109 onRegionCollapsed : function(region){
34110 this.fireEvent("regioncollapsed", region);
34113 onRegionExpanded : function(region){
34114 this.fireEvent("regionexpanded", region);
34118 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34119 * performs box-model adjustments.
34120 * @return {Object} The size as an object {width: (the width), height: (the height)}
34122 getViewSize : function()
34125 if(this.el.dom != document.body){
34126 size = this.el.getSize();
34128 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34130 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34131 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34136 * Returns the Element this layout is bound to.
34137 * @return {Roo.Element}
34139 getEl : function(){
34144 * Returns the specified region.
34145 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34146 * @return {Roo.LayoutRegion}
34148 getRegion : function(target){
34149 return this.regions[target.toLowerCase()];
34152 onWindowResize : function(){
34153 if(this.monitorWindowResize){
34160 * Ext JS Library 1.1.1
34161 * Copyright(c) 2006-2007, Ext JS, LLC.
34163 * Originally Released Under LGPL - original licence link has changed is not relivant.
34166 * <script type="text/javascript">
34169 * @class Roo.bootstrap.layout.Border
34170 * @extends Roo.bootstrap.layout.Manager
34171 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34172 * please see: examples/bootstrap/nested.html<br><br>
34174 <b>The container the layout is rendered into can be either the body element or any other element.
34175 If it is not the body element, the container needs to either be an absolute positioned element,
34176 or you will need to add "position:relative" to the css of the container. You will also need to specify
34177 the container size if it is not the body element.</b>
34180 * Create a new Border
34181 * @param {Object} config Configuration options
34183 Roo.bootstrap.layout.Border = function(config){
34184 config = config || {};
34185 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34189 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34190 if(config[region]){
34191 config[region].region = region;
34192 this.addRegion(config[region]);
34198 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34200 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34202 * Creates and adds a new region if it doesn't already exist.
34203 * @param {String} target The target region key (north, south, east, west or center).
34204 * @param {Object} config The regions config object
34205 * @return {BorderLayoutRegion} The new region
34207 addRegion : function(config)
34209 if(!this.regions[config.region]){
34210 var r = this.factory(config);
34211 this.bindRegion(r);
34213 return this.regions[config.region];
34217 bindRegion : function(r){
34218 this.regions[r.config.region] = r;
34220 r.on("visibilitychange", this.layout, this);
34221 r.on("paneladded", this.layout, this);
34222 r.on("panelremoved", this.layout, this);
34223 r.on("invalidated", this.layout, this);
34224 r.on("resized", this.onRegionResized, this);
34225 r.on("collapsed", this.onRegionCollapsed, this);
34226 r.on("expanded", this.onRegionExpanded, this);
34230 * Performs a layout update.
34232 layout : function()
34234 if(this.updating) {
34238 // render all the rebions if they have not been done alreayd?
34239 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34240 if(this.regions[region] && !this.regions[region].bodyEl){
34241 this.regions[region].onRender(this.el)
34245 var size = this.getViewSize();
34246 var w = size.width;
34247 var h = size.height;
34252 //var x = 0, y = 0;
34254 var rs = this.regions;
34255 var north = rs["north"];
34256 var south = rs["south"];
34257 var west = rs["west"];
34258 var east = rs["east"];
34259 var center = rs["center"];
34260 //if(this.hideOnLayout){ // not supported anymore
34261 //c.el.setStyle("display", "none");
34263 if(north && north.isVisible()){
34264 var b = north.getBox();
34265 var m = north.getMargins();
34266 b.width = w - (m.left+m.right);
34269 centerY = b.height + b.y + m.bottom;
34270 centerH -= centerY;
34271 north.updateBox(this.safeBox(b));
34273 if(south && south.isVisible()){
34274 var b = south.getBox();
34275 var m = south.getMargins();
34276 b.width = w - (m.left+m.right);
34278 var totalHeight = (b.height + m.top + m.bottom);
34279 b.y = h - totalHeight + m.top;
34280 centerH -= totalHeight;
34281 south.updateBox(this.safeBox(b));
34283 if(west && west.isVisible()){
34284 var b = west.getBox();
34285 var m = west.getMargins();
34286 b.height = centerH - (m.top+m.bottom);
34288 b.y = centerY + m.top;
34289 var totalWidth = (b.width + m.left + m.right);
34290 centerX += totalWidth;
34291 centerW -= totalWidth;
34292 west.updateBox(this.safeBox(b));
34294 if(east && east.isVisible()){
34295 var b = east.getBox();
34296 var m = east.getMargins();
34297 b.height = centerH - (m.top+m.bottom);
34298 var totalWidth = (b.width + m.left + m.right);
34299 b.x = w - totalWidth + m.left;
34300 b.y = centerY + m.top;
34301 centerW -= totalWidth;
34302 east.updateBox(this.safeBox(b));
34305 var m = center.getMargins();
34307 x: centerX + m.left,
34308 y: centerY + m.top,
34309 width: centerW - (m.left+m.right),
34310 height: centerH - (m.top+m.bottom)
34312 //if(this.hideOnLayout){
34313 //center.el.setStyle("display", "block");
34315 center.updateBox(this.safeBox(centerBox));
34318 this.fireEvent("layout", this);
34322 safeBox : function(box){
34323 box.width = Math.max(0, box.width);
34324 box.height = Math.max(0, box.height);
34329 * Adds a ContentPanel (or subclass) to this layout.
34330 * @param {String} target The target region key (north, south, east, west or center).
34331 * @param {Roo.ContentPanel} panel The panel to add
34332 * @return {Roo.ContentPanel} The added panel
34334 add : function(target, panel){
34336 target = target.toLowerCase();
34337 return this.regions[target].add(panel);
34341 * Remove a ContentPanel (or subclass) to this layout.
34342 * @param {String} target The target region key (north, south, east, west or center).
34343 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34344 * @return {Roo.ContentPanel} The removed panel
34346 remove : function(target, panel){
34347 target = target.toLowerCase();
34348 return this.regions[target].remove(panel);
34352 * Searches all regions for a panel with the specified id
34353 * @param {String} panelId
34354 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34356 findPanel : function(panelId){
34357 var rs = this.regions;
34358 for(var target in rs){
34359 if(typeof rs[target] != "function"){
34360 var p = rs[target].getPanel(panelId);
34370 * Searches all regions for a panel with the specified id and activates (shows) it.
34371 * @param {String/ContentPanel} panelId The panels id or the panel itself
34372 * @return {Roo.ContentPanel} The shown panel or null
34374 showPanel : function(panelId) {
34375 var rs = this.regions;
34376 for(var target in rs){
34377 var r = rs[target];
34378 if(typeof r != "function"){
34379 if(r.hasPanel(panelId)){
34380 return r.showPanel(panelId);
34388 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34389 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34392 restoreState : function(provider){
34394 provider = Roo.state.Manager;
34396 var sm = new Roo.LayoutStateManager();
34397 sm.init(this, provider);
34403 * Adds a xtype elements to the layout.
34407 xtype : 'ContentPanel',
34414 xtype : 'NestedLayoutPanel',
34420 items : [ ... list of content panels or nested layout panels.. ]
34424 * @param {Object} cfg Xtype definition of item to add.
34426 addxtype : function(cfg)
34428 // basically accepts a pannel...
34429 // can accept a layout region..!?!?
34430 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34433 // theory? children can only be panels??
34435 //if (!cfg.xtype.match(/Panel$/)) {
34440 if (typeof(cfg.region) == 'undefined') {
34441 Roo.log("Failed to add Panel, region was not set");
34445 var region = cfg.region;
34451 xitems = cfg.items;
34458 case 'Content': // ContentPanel (el, cfg)
34459 case 'Scroll': // ContentPanel (el, cfg)
34461 cfg.autoCreate = true;
34462 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34464 // var el = this.el.createChild();
34465 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34468 this.add(region, ret);
34472 case 'TreePanel': // our new panel!
34473 cfg.el = this.el.createChild();
34474 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34475 this.add(region, ret);
34480 // create a new Layout (which is a Border Layout...
34482 var clayout = cfg.layout;
34483 clayout.el = this.el.createChild();
34484 clayout.items = clayout.items || [];
34488 // replace this exitems with the clayout ones..
34489 xitems = clayout.items;
34491 // force background off if it's in center...
34492 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34493 cfg.background = false;
34495 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34498 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34499 //console.log('adding nested layout panel ' + cfg.toSource());
34500 this.add(region, ret);
34501 nb = {}; /// find first...
34506 // needs grid and region
34508 //var el = this.getRegion(region).el.createChild();
34510 *var el = this.el.createChild();
34511 // create the grid first...
34512 cfg.grid.container = el;
34513 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34516 if (region == 'center' && this.active ) {
34517 cfg.background = false;
34520 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34522 this.add(region, ret);
34524 if (cfg.background) {
34525 // render grid on panel activation (if panel background)
34526 ret.on('activate', function(gp) {
34527 if (!gp.grid.rendered) {
34528 // gp.grid.render(el);
34532 // cfg.grid.render(el);
34538 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34539 // it was the old xcomponent building that caused this before.
34540 // espeically if border is the top element in the tree.
34550 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34552 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34553 this.add(region, ret);
34557 throw "Can not add '" + cfg.xtype + "' to Border";
34563 this.beginUpdate();
34567 Roo.each(xitems, function(i) {
34568 region = nb && i.region ? i.region : false;
34570 var add = ret.addxtype(i);
34573 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34574 if (!i.background) {
34575 abn[region] = nb[region] ;
34582 // make the last non-background panel active..
34583 //if (nb) { Roo.log(abn); }
34586 for(var r in abn) {
34587 region = this.getRegion(r);
34589 // tried using nb[r], but it does not work..
34591 region.showPanel(abn[r]);
34602 factory : function(cfg)
34605 var validRegions = Roo.bootstrap.layout.Border.regions;
34607 var target = cfg.region;
34610 var r = Roo.bootstrap.layout;
34614 return new r.North(cfg);
34616 return new r.South(cfg);
34618 return new r.East(cfg);
34620 return new r.West(cfg);
34622 return new r.Center(cfg);
34624 throw 'Layout region "'+target+'" not supported.';
34631 * Ext JS Library 1.1.1
34632 * Copyright(c) 2006-2007, Ext JS, LLC.
34634 * Originally Released Under LGPL - original licence link has changed is not relivant.
34637 * <script type="text/javascript">
34641 * @class Roo.bootstrap.layout.Basic
34642 * @extends Roo.util.Observable
34643 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34644 * and does not have a titlebar, tabs or any other features. All it does is size and position
34645 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34646 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34647 * @cfg {string} region the region that it inhabits..
34648 * @cfg {bool} skipConfig skip config?
34652 Roo.bootstrap.layout.Basic = function(config){
34654 this.mgr = config.mgr;
34656 this.position = config.region;
34658 var skipConfig = config.skipConfig;
34662 * @scope Roo.BasicLayoutRegion
34666 * @event beforeremove
34667 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34668 * @param {Roo.LayoutRegion} this
34669 * @param {Roo.ContentPanel} panel The panel
34670 * @param {Object} e The cancel event object
34672 "beforeremove" : true,
34674 * @event invalidated
34675 * Fires when the layout for this region is changed.
34676 * @param {Roo.LayoutRegion} this
34678 "invalidated" : true,
34680 * @event visibilitychange
34681 * Fires when this region is shown or hidden
34682 * @param {Roo.LayoutRegion} this
34683 * @param {Boolean} visibility true or false
34685 "visibilitychange" : true,
34687 * @event paneladded
34688 * Fires when a panel is added.
34689 * @param {Roo.LayoutRegion} this
34690 * @param {Roo.ContentPanel} panel The panel
34692 "paneladded" : true,
34694 * @event panelremoved
34695 * Fires when a panel is removed.
34696 * @param {Roo.LayoutRegion} this
34697 * @param {Roo.ContentPanel} panel The panel
34699 "panelremoved" : true,
34701 * @event beforecollapse
34702 * Fires when this region before collapse.
34703 * @param {Roo.LayoutRegion} this
34705 "beforecollapse" : true,
34708 * Fires when this region is collapsed.
34709 * @param {Roo.LayoutRegion} this
34711 "collapsed" : true,
34714 * Fires when this region is expanded.
34715 * @param {Roo.LayoutRegion} this
34720 * Fires when this region is slid into view.
34721 * @param {Roo.LayoutRegion} this
34723 "slideshow" : true,
34726 * Fires when this region slides out of view.
34727 * @param {Roo.LayoutRegion} this
34729 "slidehide" : true,
34731 * @event panelactivated
34732 * Fires when a panel is activated.
34733 * @param {Roo.LayoutRegion} this
34734 * @param {Roo.ContentPanel} panel The activated panel
34736 "panelactivated" : true,
34739 * Fires when the user resizes this region.
34740 * @param {Roo.LayoutRegion} this
34741 * @param {Number} newSize The new size (width for east/west, height for north/south)
34745 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34746 this.panels = new Roo.util.MixedCollection();
34747 this.panels.getKey = this.getPanelId.createDelegate(this);
34749 this.activePanel = null;
34750 // ensure listeners are added...
34752 if (config.listeners || config.events) {
34753 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34754 listeners : config.listeners || {},
34755 events : config.events || {}
34759 if(skipConfig !== true){
34760 this.applyConfig(config);
34764 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34766 getPanelId : function(p){
34770 applyConfig : function(config){
34771 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34772 this.config = config;
34777 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34778 * the width, for horizontal (north, south) the height.
34779 * @param {Number} newSize The new width or height
34781 resizeTo : function(newSize){
34782 var el = this.el ? this.el :
34783 (this.activePanel ? this.activePanel.getEl() : null);
34785 switch(this.position){
34788 el.setWidth(newSize);
34789 this.fireEvent("resized", this, newSize);
34793 el.setHeight(newSize);
34794 this.fireEvent("resized", this, newSize);
34800 getBox : function(){
34801 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34804 getMargins : function(){
34805 return this.margins;
34808 updateBox : function(box){
34810 var el = this.activePanel.getEl();
34811 el.dom.style.left = box.x + "px";
34812 el.dom.style.top = box.y + "px";
34813 this.activePanel.setSize(box.width, box.height);
34817 * Returns the container element for this region.
34818 * @return {Roo.Element}
34820 getEl : function(){
34821 return this.activePanel;
34825 * Returns true if this region is currently visible.
34826 * @return {Boolean}
34828 isVisible : function(){
34829 return this.activePanel ? true : false;
34832 setActivePanel : function(panel){
34833 panel = this.getPanel(panel);
34834 if(this.activePanel && this.activePanel != panel){
34835 this.activePanel.setActiveState(false);
34836 this.activePanel.getEl().setLeftTop(-10000,-10000);
34838 this.activePanel = panel;
34839 panel.setActiveState(true);
34841 panel.setSize(this.box.width, this.box.height);
34843 this.fireEvent("panelactivated", this, panel);
34844 this.fireEvent("invalidated");
34848 * Show the specified panel.
34849 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
34850 * @return {Roo.ContentPanel} The shown panel or null
34852 showPanel : function(panel){
34853 panel = this.getPanel(panel);
34855 this.setActivePanel(panel);
34861 * Get the active panel for this region.
34862 * @return {Roo.ContentPanel} The active panel or null
34864 getActivePanel : function(){
34865 return this.activePanel;
34869 * Add the passed ContentPanel(s)
34870 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
34871 * @return {Roo.ContentPanel} The panel added (if only one was added)
34873 add : function(panel){
34874 if(arguments.length > 1){
34875 for(var i = 0, len = arguments.length; i < len; i++) {
34876 this.add(arguments[i]);
34880 if(this.hasPanel(panel)){
34881 this.showPanel(panel);
34884 var el = panel.getEl();
34885 if(el.dom.parentNode != this.mgr.el.dom){
34886 this.mgr.el.dom.appendChild(el.dom);
34888 if(panel.setRegion){
34889 panel.setRegion(this);
34891 this.panels.add(panel);
34892 el.setStyle("position", "absolute");
34893 if(!panel.background){
34894 this.setActivePanel(panel);
34895 if(this.config.initialSize && this.panels.getCount()==1){
34896 this.resizeTo(this.config.initialSize);
34899 this.fireEvent("paneladded", this, panel);
34904 * Returns true if the panel is in this region.
34905 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34906 * @return {Boolean}
34908 hasPanel : function(panel){
34909 if(typeof panel == "object"){ // must be panel obj
34910 panel = panel.getId();
34912 return this.getPanel(panel) ? true : false;
34916 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
34917 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34918 * @param {Boolean} preservePanel Overrides the config preservePanel option
34919 * @return {Roo.ContentPanel} The panel that was removed
34921 remove : function(panel, preservePanel){
34922 panel = this.getPanel(panel);
34927 this.fireEvent("beforeremove", this, panel, e);
34928 if(e.cancel === true){
34931 var panelId = panel.getId();
34932 this.panels.removeKey(panelId);
34937 * Returns the panel specified or null if it's not in this region.
34938 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34939 * @return {Roo.ContentPanel}
34941 getPanel : function(id){
34942 if(typeof id == "object"){ // must be panel obj
34945 return this.panels.get(id);
34949 * Returns this regions position (north/south/east/west/center).
34952 getPosition: function(){
34953 return this.position;
34957 * Ext JS Library 1.1.1
34958 * Copyright(c) 2006-2007, Ext JS, LLC.
34960 * Originally Released Under LGPL - original licence link has changed is not relivant.
34963 * <script type="text/javascript">
34967 * @class Roo.bootstrap.layout.Region
34968 * @extends Roo.bootstrap.layout.Basic
34969 * This class represents a region in a layout manager.
34971 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
34972 * @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})
34973 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
34974 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
34975 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
34976 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
34977 * @cfg {String} title The title for the region (overrides panel titles)
34978 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
34979 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
34980 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
34981 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
34982 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
34983 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
34984 * the space available, similar to FireFox 1.5 tabs (defaults to false)
34985 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
34986 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
34987 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
34989 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
34990 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
34991 * @cfg {Boolean} disableTabTips True to disable tab tooltips
34992 * @cfg {Number} width For East/West panels
34993 * @cfg {Number} height For North/South panels
34994 * @cfg {Boolean} split To show the splitter
34995 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
34997 * @cfg {string} cls Extra CSS classes to add to region
34999 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35000 * @cfg {string} region the region that it inhabits..
35003 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35004 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35006 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35007 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35008 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35010 Roo.bootstrap.layout.Region = function(config)
35012 this.applyConfig(config);
35014 var mgr = config.mgr;
35015 var pos = config.region;
35016 config.skipConfig = true;
35017 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35020 this.onRender(mgr.el);
35023 this.visible = true;
35024 this.collapsed = false;
35025 this.unrendered_panels = [];
35028 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35030 position: '', // set by wrapper (eg. north/south etc..)
35031 unrendered_panels : null, // unrendered panels.
35032 createBody : function(){
35033 /** This region's body element
35034 * @type Roo.Element */
35035 this.bodyEl = this.el.createChild({
35037 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35041 onRender: function(ctr, pos)
35043 var dh = Roo.DomHelper;
35044 /** This region's container element
35045 * @type Roo.Element */
35046 this.el = dh.append(ctr.dom, {
35048 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35050 /** This region's title element
35051 * @type Roo.Element */
35053 this.titleEl = dh.append(this.el.dom,
35056 unselectable: "on",
35057 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35059 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35060 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35063 this.titleEl.enableDisplayMode();
35064 /** This region's title text element
35065 * @type HTMLElement */
35066 this.titleTextEl = this.titleEl.dom.firstChild;
35067 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35069 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35070 this.closeBtn.enableDisplayMode();
35071 this.closeBtn.on("click", this.closeClicked, this);
35072 this.closeBtn.hide();
35074 this.createBody(this.config);
35075 if(this.config.hideWhenEmpty){
35077 this.on("paneladded", this.validateVisibility, this);
35078 this.on("panelremoved", this.validateVisibility, this);
35080 if(this.autoScroll){
35081 this.bodyEl.setStyle("overflow", "auto");
35083 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35085 //if(c.titlebar !== false){
35086 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35087 this.titleEl.hide();
35089 this.titleEl.show();
35090 if(this.config.title){
35091 this.titleTextEl.innerHTML = this.config.title;
35095 if(this.config.collapsed){
35096 this.collapse(true);
35098 if(this.config.hidden){
35102 if (this.unrendered_panels && this.unrendered_panels.length) {
35103 for (var i =0;i< this.unrendered_panels.length; i++) {
35104 this.add(this.unrendered_panels[i]);
35106 this.unrendered_panels = null;
35112 applyConfig : function(c)
35115 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35116 var dh = Roo.DomHelper;
35117 if(c.titlebar !== false){
35118 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35119 this.collapseBtn.on("click", this.collapse, this);
35120 this.collapseBtn.enableDisplayMode();
35122 if(c.showPin === true || this.showPin){
35123 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35124 this.stickBtn.enableDisplayMode();
35125 this.stickBtn.on("click", this.expand, this);
35126 this.stickBtn.hide();
35131 /** This region's collapsed element
35132 * @type Roo.Element */
35135 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35136 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35139 if(c.floatable !== false){
35140 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35141 this.collapsedEl.on("click", this.collapseClick, this);
35144 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35145 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35146 id: "message", unselectable: "on", style:{"float":"left"}});
35147 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35149 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35150 this.expandBtn.on("click", this.expand, this);
35154 if(this.collapseBtn){
35155 this.collapseBtn.setVisible(c.collapsible == true);
35158 this.cmargins = c.cmargins || this.cmargins ||
35159 (this.position == "west" || this.position == "east" ?
35160 {top: 0, left: 2, right:2, bottom: 0} :
35161 {top: 2, left: 0, right:0, bottom: 2});
35163 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35166 this.bottomTabs = c.tabPosition != "top";
35168 this.autoScroll = c.autoScroll || false;
35173 this.duration = c.duration || .30;
35174 this.slideDuration = c.slideDuration || .45;
35179 * Returns true if this region is currently visible.
35180 * @return {Boolean}
35182 isVisible : function(){
35183 return this.visible;
35187 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35188 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35190 //setCollapsedTitle : function(title){
35191 // title = title || " ";
35192 // if(this.collapsedTitleTextEl){
35193 // this.collapsedTitleTextEl.innerHTML = title;
35197 getBox : function(){
35199 // if(!this.collapsed){
35200 b = this.el.getBox(false, true);
35202 // b = this.collapsedEl.getBox(false, true);
35207 getMargins : function(){
35208 return this.margins;
35209 //return this.collapsed ? this.cmargins : this.margins;
35212 highlight : function(){
35213 this.el.addClass("x-layout-panel-dragover");
35216 unhighlight : function(){
35217 this.el.removeClass("x-layout-panel-dragover");
35220 updateBox : function(box)
35222 if (!this.bodyEl) {
35223 return; // not rendered yet..
35227 if(!this.collapsed){
35228 this.el.dom.style.left = box.x + "px";
35229 this.el.dom.style.top = box.y + "px";
35230 this.updateBody(box.width, box.height);
35232 this.collapsedEl.dom.style.left = box.x + "px";
35233 this.collapsedEl.dom.style.top = box.y + "px";
35234 this.collapsedEl.setSize(box.width, box.height);
35237 this.tabs.autoSizeTabs();
35241 updateBody : function(w, h)
35244 this.el.setWidth(w);
35245 w -= this.el.getBorderWidth("rl");
35246 if(this.config.adjustments){
35247 w += this.config.adjustments[0];
35250 if(h !== null && h > 0){
35251 this.el.setHeight(h);
35252 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35253 h -= this.el.getBorderWidth("tb");
35254 if(this.config.adjustments){
35255 h += this.config.adjustments[1];
35257 this.bodyEl.setHeight(h);
35259 h = this.tabs.syncHeight(h);
35262 if(this.panelSize){
35263 w = w !== null ? w : this.panelSize.width;
35264 h = h !== null ? h : this.panelSize.height;
35266 if(this.activePanel){
35267 var el = this.activePanel.getEl();
35268 w = w !== null ? w : el.getWidth();
35269 h = h !== null ? h : el.getHeight();
35270 this.panelSize = {width: w, height: h};
35271 this.activePanel.setSize(w, h);
35273 if(Roo.isIE && this.tabs){
35274 this.tabs.el.repaint();
35279 * Returns the container element for this region.
35280 * @return {Roo.Element}
35282 getEl : function(){
35287 * Hides this region.
35290 //if(!this.collapsed){
35291 this.el.dom.style.left = "-2000px";
35294 // this.collapsedEl.dom.style.left = "-2000px";
35295 // this.collapsedEl.hide();
35297 this.visible = false;
35298 this.fireEvent("visibilitychange", this, false);
35302 * Shows this region if it was previously hidden.
35305 //if(!this.collapsed){
35308 // this.collapsedEl.show();
35310 this.visible = true;
35311 this.fireEvent("visibilitychange", this, true);
35314 closeClicked : function(){
35315 if(this.activePanel){
35316 this.remove(this.activePanel);
35320 collapseClick : function(e){
35322 e.stopPropagation();
35325 e.stopPropagation();
35331 * Collapses this region.
35332 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35335 collapse : function(skipAnim, skipCheck = false){
35336 if(this.collapsed) {
35340 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35342 this.collapsed = true;
35344 this.split.el.hide();
35346 if(this.config.animate && skipAnim !== true){
35347 this.fireEvent("invalidated", this);
35348 this.animateCollapse();
35350 this.el.setLocation(-20000,-20000);
35352 this.collapsedEl.show();
35353 this.fireEvent("collapsed", this);
35354 this.fireEvent("invalidated", this);
35360 animateCollapse : function(){
35365 * Expands this region if it was previously collapsed.
35366 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35367 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35370 expand : function(e, skipAnim){
35372 e.stopPropagation();
35374 if(!this.collapsed || this.el.hasActiveFx()) {
35378 this.afterSlideIn();
35381 this.collapsed = false;
35382 if(this.config.animate && skipAnim !== true){
35383 this.animateExpand();
35387 this.split.el.show();
35389 this.collapsedEl.setLocation(-2000,-2000);
35390 this.collapsedEl.hide();
35391 this.fireEvent("invalidated", this);
35392 this.fireEvent("expanded", this);
35396 animateExpand : function(){
35400 initTabs : function()
35402 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35404 var ts = new Roo.bootstrap.panel.Tabs({
35405 el: this.bodyEl.dom,
35406 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35407 disableTooltips: this.config.disableTabTips,
35408 toolbar : this.config.toolbar
35411 if(this.config.hideTabs){
35412 ts.stripWrap.setDisplayed(false);
35415 ts.resizeTabs = this.config.resizeTabs === true;
35416 ts.minTabWidth = this.config.minTabWidth || 40;
35417 ts.maxTabWidth = this.config.maxTabWidth || 250;
35418 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35419 ts.monitorResize = false;
35420 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35421 ts.bodyEl.addClass('roo-layout-tabs-body');
35422 this.panels.each(this.initPanelAsTab, this);
35425 initPanelAsTab : function(panel){
35426 var ti = this.tabs.addTab(
35430 this.config.closeOnTab && panel.isClosable(),
35433 if(panel.tabTip !== undefined){
35434 ti.setTooltip(panel.tabTip);
35436 ti.on("activate", function(){
35437 this.setActivePanel(panel);
35440 if(this.config.closeOnTab){
35441 ti.on("beforeclose", function(t, e){
35443 this.remove(panel);
35447 panel.tabItem = ti;
35452 updatePanelTitle : function(panel, title)
35454 if(this.activePanel == panel){
35455 this.updateTitle(title);
35458 var ti = this.tabs.getTab(panel.getEl().id);
35460 if(panel.tabTip !== undefined){
35461 ti.setTooltip(panel.tabTip);
35466 updateTitle : function(title){
35467 if(this.titleTextEl && !this.config.title){
35468 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35472 setActivePanel : function(panel)
35474 panel = this.getPanel(panel);
35475 if(this.activePanel && this.activePanel != panel){
35476 if(this.activePanel.setActiveState(false) === false){
35480 this.activePanel = panel;
35481 panel.setActiveState(true);
35482 if(this.panelSize){
35483 panel.setSize(this.panelSize.width, this.panelSize.height);
35486 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35488 this.updateTitle(panel.getTitle());
35490 this.fireEvent("invalidated", this);
35492 this.fireEvent("panelactivated", this, panel);
35496 * Shows the specified panel.
35497 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35498 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35500 showPanel : function(panel)
35502 panel = this.getPanel(panel);
35505 var tab = this.tabs.getTab(panel.getEl().id);
35506 if(tab.isHidden()){
35507 this.tabs.unhideTab(tab.id);
35511 this.setActivePanel(panel);
35518 * Get the active panel for this region.
35519 * @return {Roo.ContentPanel} The active panel or null
35521 getActivePanel : function(){
35522 return this.activePanel;
35525 validateVisibility : function(){
35526 if(this.panels.getCount() < 1){
35527 this.updateTitle(" ");
35528 this.closeBtn.hide();
35531 if(!this.isVisible()){
35538 * Adds the passed ContentPanel(s) to this region.
35539 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35540 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35542 add : function(panel)
35544 if(arguments.length > 1){
35545 for(var i = 0, len = arguments.length; i < len; i++) {
35546 this.add(arguments[i]);
35551 // if we have not been rendered yet, then we can not really do much of this..
35552 if (!this.bodyEl) {
35553 this.unrendered_panels.push(panel);
35560 if(this.hasPanel(panel)){
35561 this.showPanel(panel);
35564 panel.setRegion(this);
35565 this.panels.add(panel);
35566 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35567 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35568 // and hide them... ???
35569 this.bodyEl.dom.appendChild(panel.getEl().dom);
35570 if(panel.background !== true){
35571 this.setActivePanel(panel);
35573 this.fireEvent("paneladded", this, panel);
35580 this.initPanelAsTab(panel);
35584 if(panel.background !== true){
35585 this.tabs.activate(panel.getEl().id);
35587 this.fireEvent("paneladded", this, panel);
35592 * Hides the tab for the specified panel.
35593 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35595 hidePanel : function(panel){
35596 if(this.tabs && (panel = this.getPanel(panel))){
35597 this.tabs.hideTab(panel.getEl().id);
35602 * Unhides the tab for a previously hidden panel.
35603 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35605 unhidePanel : function(panel){
35606 if(this.tabs && (panel = this.getPanel(panel))){
35607 this.tabs.unhideTab(panel.getEl().id);
35611 clearPanels : function(){
35612 while(this.panels.getCount() > 0){
35613 this.remove(this.panels.first());
35618 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35619 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35620 * @param {Boolean} preservePanel Overrides the config preservePanel option
35621 * @return {Roo.ContentPanel} The panel that was removed
35623 remove : function(panel, preservePanel)
35625 panel = this.getPanel(panel);
35630 this.fireEvent("beforeremove", this, panel, e);
35631 if(e.cancel === true){
35634 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35635 var panelId = panel.getId();
35636 this.panels.removeKey(panelId);
35638 document.body.appendChild(panel.getEl().dom);
35641 this.tabs.removeTab(panel.getEl().id);
35642 }else if (!preservePanel){
35643 this.bodyEl.dom.removeChild(panel.getEl().dom);
35645 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35646 var p = this.panels.first();
35647 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35648 tempEl.appendChild(p.getEl().dom);
35649 this.bodyEl.update("");
35650 this.bodyEl.dom.appendChild(p.getEl().dom);
35652 this.updateTitle(p.getTitle());
35654 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35655 this.setActivePanel(p);
35657 panel.setRegion(null);
35658 if(this.activePanel == panel){
35659 this.activePanel = null;
35661 if(this.config.autoDestroy !== false && preservePanel !== true){
35662 try{panel.destroy();}catch(e){}
35664 this.fireEvent("panelremoved", this, panel);
35669 * Returns the TabPanel component used by this region
35670 * @return {Roo.TabPanel}
35672 getTabs : function(){
35676 createTool : function(parentEl, className){
35677 var btn = Roo.DomHelper.append(parentEl, {
35679 cls: "x-layout-tools-button",
35682 cls: "roo-layout-tools-button-inner " + className,
35686 btn.addClassOnOver("roo-layout-tools-button-over");
35691 * Ext JS Library 1.1.1
35692 * Copyright(c) 2006-2007, Ext JS, LLC.
35694 * Originally Released Under LGPL - original licence link has changed is not relivant.
35697 * <script type="text/javascript">
35703 * @class Roo.SplitLayoutRegion
35704 * @extends Roo.LayoutRegion
35705 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35707 Roo.bootstrap.layout.Split = function(config){
35708 this.cursor = config.cursor;
35709 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35712 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35714 splitTip : "Drag to resize.",
35715 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35716 useSplitTips : false,
35718 applyConfig : function(config){
35719 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35722 onRender : function(ctr,pos) {
35724 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35725 if(!this.config.split){
35730 var splitEl = Roo.DomHelper.append(ctr.dom, {
35732 id: this.el.id + "-split",
35733 cls: "roo-layout-split roo-layout-split-"+this.position,
35736 /** The SplitBar for this region
35737 * @type Roo.SplitBar */
35738 // does not exist yet...
35739 Roo.log([this.position, this.orientation]);
35741 this.split = new Roo.bootstrap.SplitBar({
35742 dragElement : splitEl,
35743 resizingElement: this.el,
35744 orientation : this.orientation
35747 this.split.on("moved", this.onSplitMove, this);
35748 this.split.useShim = this.config.useShim === true;
35749 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35750 if(this.useSplitTips){
35751 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35753 //if(config.collapsible){
35754 // this.split.el.on("dblclick", this.collapse, this);
35757 if(typeof this.config.minSize != "undefined"){
35758 this.split.minSize = this.config.minSize;
35760 if(typeof this.config.maxSize != "undefined"){
35761 this.split.maxSize = this.config.maxSize;
35763 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35764 this.hideSplitter();
35769 getHMaxSize : function(){
35770 var cmax = this.config.maxSize || 10000;
35771 var center = this.mgr.getRegion("center");
35772 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35775 getVMaxSize : function(){
35776 var cmax = this.config.maxSize || 10000;
35777 var center = this.mgr.getRegion("center");
35778 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35781 onSplitMove : function(split, newSize){
35782 this.fireEvent("resized", this, newSize);
35786 * Returns the {@link Roo.SplitBar} for this region.
35787 * @return {Roo.SplitBar}
35789 getSplitBar : function(){
35794 this.hideSplitter();
35795 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35798 hideSplitter : function(){
35800 this.split.el.setLocation(-2000,-2000);
35801 this.split.el.hide();
35807 this.split.el.show();
35809 Roo.bootstrap.layout.Split.superclass.show.call(this);
35812 beforeSlide: function(){
35813 if(Roo.isGecko){// firefox overflow auto bug workaround
35814 this.bodyEl.clip();
35816 this.tabs.bodyEl.clip();
35818 if(this.activePanel){
35819 this.activePanel.getEl().clip();
35821 if(this.activePanel.beforeSlide){
35822 this.activePanel.beforeSlide();
35828 afterSlide : function(){
35829 if(Roo.isGecko){// firefox overflow auto bug workaround
35830 this.bodyEl.unclip();
35832 this.tabs.bodyEl.unclip();
35834 if(this.activePanel){
35835 this.activePanel.getEl().unclip();
35836 if(this.activePanel.afterSlide){
35837 this.activePanel.afterSlide();
35843 initAutoHide : function(){
35844 if(this.autoHide !== false){
35845 if(!this.autoHideHd){
35846 var st = new Roo.util.DelayedTask(this.slideIn, this);
35847 this.autoHideHd = {
35848 "mouseout": function(e){
35849 if(!e.within(this.el, true)){
35853 "mouseover" : function(e){
35859 this.el.on(this.autoHideHd);
35863 clearAutoHide : function(){
35864 if(this.autoHide !== false){
35865 this.el.un("mouseout", this.autoHideHd.mouseout);
35866 this.el.un("mouseover", this.autoHideHd.mouseover);
35870 clearMonitor : function(){
35871 Roo.get(document).un("click", this.slideInIf, this);
35874 // these names are backwards but not changed for compat
35875 slideOut : function(){
35876 if(this.isSlid || this.el.hasActiveFx()){
35879 this.isSlid = true;
35880 if(this.collapseBtn){
35881 this.collapseBtn.hide();
35883 this.closeBtnState = this.closeBtn.getStyle('display');
35884 this.closeBtn.hide();
35886 this.stickBtn.show();
35889 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
35890 this.beforeSlide();
35891 this.el.setStyle("z-index", 10001);
35892 this.el.slideIn(this.getSlideAnchor(), {
35893 callback: function(){
35895 this.initAutoHide();
35896 Roo.get(document).on("click", this.slideInIf, this);
35897 this.fireEvent("slideshow", this);
35904 afterSlideIn : function(){
35905 this.clearAutoHide();
35906 this.isSlid = false;
35907 this.clearMonitor();
35908 this.el.setStyle("z-index", "");
35909 if(this.collapseBtn){
35910 this.collapseBtn.show();
35912 this.closeBtn.setStyle('display', this.closeBtnState);
35914 this.stickBtn.hide();
35916 this.fireEvent("slidehide", this);
35919 slideIn : function(cb){
35920 if(!this.isSlid || this.el.hasActiveFx()){
35924 this.isSlid = false;
35925 this.beforeSlide();
35926 this.el.slideOut(this.getSlideAnchor(), {
35927 callback: function(){
35928 this.el.setLeftTop(-10000, -10000);
35930 this.afterSlideIn();
35938 slideInIf : function(e){
35939 if(!e.within(this.el)){
35944 animateCollapse : function(){
35945 this.beforeSlide();
35946 this.el.setStyle("z-index", 20000);
35947 var anchor = this.getSlideAnchor();
35948 this.el.slideOut(anchor, {
35949 callback : function(){
35950 this.el.setStyle("z-index", "");
35951 this.collapsedEl.slideIn(anchor, {duration:.3});
35953 this.el.setLocation(-10000,-10000);
35955 this.fireEvent("collapsed", this);
35962 animateExpand : function(){
35963 this.beforeSlide();
35964 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
35965 this.el.setStyle("z-index", 20000);
35966 this.collapsedEl.hide({
35969 this.el.slideIn(this.getSlideAnchor(), {
35970 callback : function(){
35971 this.el.setStyle("z-index", "");
35974 this.split.el.show();
35976 this.fireEvent("invalidated", this);
35977 this.fireEvent("expanded", this);
36005 getAnchor : function(){
36006 return this.anchors[this.position];
36009 getCollapseAnchor : function(){
36010 return this.canchors[this.position];
36013 getSlideAnchor : function(){
36014 return this.sanchors[this.position];
36017 getAlignAdj : function(){
36018 var cm = this.cmargins;
36019 switch(this.position){
36035 getExpandAdj : function(){
36036 var c = this.collapsedEl, cm = this.cmargins;
36037 switch(this.position){
36039 return [-(cm.right+c.getWidth()+cm.left), 0];
36042 return [cm.right+c.getWidth()+cm.left, 0];
36045 return [0, -(cm.top+cm.bottom+c.getHeight())];
36048 return [0, cm.top+cm.bottom+c.getHeight()];
36054 * Ext JS Library 1.1.1
36055 * Copyright(c) 2006-2007, Ext JS, LLC.
36057 * Originally Released Under LGPL - original licence link has changed is not relivant.
36060 * <script type="text/javascript">
36063 * These classes are private internal classes
36065 Roo.bootstrap.layout.Center = function(config){
36066 config.region = "center";
36067 Roo.bootstrap.layout.Region.call(this, config);
36068 this.visible = true;
36069 this.minWidth = config.minWidth || 20;
36070 this.minHeight = config.minHeight || 20;
36073 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36075 // center panel can't be hidden
36079 // center panel can't be hidden
36082 getMinWidth: function(){
36083 return this.minWidth;
36086 getMinHeight: function(){
36087 return this.minHeight;
36100 Roo.bootstrap.layout.North = function(config)
36102 config.region = 'north';
36103 config.cursor = 'n-resize';
36105 Roo.bootstrap.layout.Split.call(this, config);
36109 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36110 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36111 this.split.el.addClass("roo-layout-split-v");
36113 var size = config.initialSize || config.height;
36114 if(typeof size != "undefined"){
36115 this.el.setHeight(size);
36118 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36120 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36124 getBox : function(){
36125 if(this.collapsed){
36126 return this.collapsedEl.getBox();
36128 var box = this.el.getBox();
36130 box.height += this.split.el.getHeight();
36135 updateBox : function(box){
36136 if(this.split && !this.collapsed){
36137 box.height -= this.split.el.getHeight();
36138 this.split.el.setLeft(box.x);
36139 this.split.el.setTop(box.y+box.height);
36140 this.split.el.setWidth(box.width);
36142 if(this.collapsed){
36143 this.updateBody(box.width, null);
36145 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36153 Roo.bootstrap.layout.South = function(config){
36154 config.region = 'south';
36155 config.cursor = 's-resize';
36156 Roo.bootstrap.layout.Split.call(this, config);
36158 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36159 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36160 this.split.el.addClass("roo-layout-split-v");
36162 var size = config.initialSize || config.height;
36163 if(typeof size != "undefined"){
36164 this.el.setHeight(size);
36168 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36169 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36170 getBox : function(){
36171 if(this.collapsed){
36172 return this.collapsedEl.getBox();
36174 var box = this.el.getBox();
36176 var sh = this.split.el.getHeight();
36183 updateBox : function(box){
36184 if(this.split && !this.collapsed){
36185 var sh = this.split.el.getHeight();
36188 this.split.el.setLeft(box.x);
36189 this.split.el.setTop(box.y-sh);
36190 this.split.el.setWidth(box.width);
36192 if(this.collapsed){
36193 this.updateBody(box.width, null);
36195 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36199 Roo.bootstrap.layout.East = function(config){
36200 config.region = "east";
36201 config.cursor = "e-resize";
36202 Roo.bootstrap.layout.Split.call(this, config);
36204 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36205 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36206 this.split.el.addClass("roo-layout-split-h");
36208 var size = config.initialSize || config.width;
36209 if(typeof size != "undefined"){
36210 this.el.setWidth(size);
36213 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36214 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36215 getBox : function(){
36216 if(this.collapsed){
36217 return this.collapsedEl.getBox();
36219 var box = this.el.getBox();
36221 var sw = this.split.el.getWidth();
36228 updateBox : function(box){
36229 if(this.split && !this.collapsed){
36230 var sw = this.split.el.getWidth();
36232 this.split.el.setLeft(box.x);
36233 this.split.el.setTop(box.y);
36234 this.split.el.setHeight(box.height);
36237 if(this.collapsed){
36238 this.updateBody(null, box.height);
36240 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36244 Roo.bootstrap.layout.West = function(config){
36245 config.region = "west";
36246 config.cursor = "w-resize";
36248 Roo.bootstrap.layout.Split.call(this, config);
36250 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36251 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36252 this.split.el.addClass("roo-layout-split-h");
36256 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36257 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36259 onRender: function(ctr, pos)
36261 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36262 var size = this.config.initialSize || this.config.width;
36263 if(typeof size != "undefined"){
36264 this.el.setWidth(size);
36268 getBox : function(){
36269 if(this.collapsed){
36270 return this.collapsedEl.getBox();
36272 var box = this.el.getBox();
36274 box.width += this.split.el.getWidth();
36279 updateBox : function(box){
36280 if(this.split && !this.collapsed){
36281 var sw = this.split.el.getWidth();
36283 this.split.el.setLeft(box.x+box.width);
36284 this.split.el.setTop(box.y);
36285 this.split.el.setHeight(box.height);
36287 if(this.collapsed){
36288 this.updateBody(null, box.height);
36290 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36293 Roo.namespace("Roo.bootstrap.panel");/*
36295 * Ext JS Library 1.1.1
36296 * Copyright(c) 2006-2007, Ext JS, LLC.
36298 * Originally Released Under LGPL - original licence link has changed is not relivant.
36301 * <script type="text/javascript">
36304 * @class Roo.ContentPanel
36305 * @extends Roo.util.Observable
36306 * A basic ContentPanel element.
36307 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36308 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36309 * @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
36310 * @cfg {Boolean} closable True if the panel can be closed/removed
36311 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36312 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36313 * @cfg {Toolbar} toolbar A toolbar for this panel
36314 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36315 * @cfg {String} title The title for this panel
36316 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36317 * @cfg {String} url Calls {@link #setUrl} with this value
36318 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36319 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36320 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36321 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36322 * @cfg {Boolean} badges render the badges
36325 * Create a new ContentPanel.
36326 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36327 * @param {String/Object} config A string to set only the title or a config object
36328 * @param {String} content (optional) Set the HTML content for this panel
36329 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36331 Roo.bootstrap.panel.Content = function( config){
36333 this.tpl = config.tpl || false;
36335 var el = config.el;
36336 var content = config.content;
36338 if(config.autoCreate){ // xtype is available if this is called from factory
36341 this.el = Roo.get(el);
36342 if(!this.el && config && config.autoCreate){
36343 if(typeof config.autoCreate == "object"){
36344 if(!config.autoCreate.id){
36345 config.autoCreate.id = config.id||el;
36347 this.el = Roo.DomHelper.append(document.body,
36348 config.autoCreate, true);
36350 var elcfg = { tag: "div",
36351 cls: "roo-layout-inactive-content",
36355 elcfg.html = config.html;
36359 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36362 this.closable = false;
36363 this.loaded = false;
36364 this.active = false;
36367 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36369 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36371 this.wrapEl = this.el; //this.el.wrap();
36373 if (config.toolbar.items) {
36374 ti = config.toolbar.items ;
36375 delete config.toolbar.items ;
36379 this.toolbar.render(this.wrapEl, 'before');
36380 for(var i =0;i < ti.length;i++) {
36381 // Roo.log(['add child', items[i]]);
36382 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36384 this.toolbar.items = nitems;
36385 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36386 delete config.toolbar;
36390 // xtype created footer. - not sure if will work as we normally have to render first..
36391 if (this.footer && !this.footer.el && this.footer.xtype) {
36392 if (!this.wrapEl) {
36393 this.wrapEl = this.el.wrap();
36396 this.footer.container = this.wrapEl.createChild();
36398 this.footer = Roo.factory(this.footer, Roo);
36403 if(typeof config == "string"){
36404 this.title = config;
36406 Roo.apply(this, config);
36410 this.resizeEl = Roo.get(this.resizeEl, true);
36412 this.resizeEl = this.el;
36414 // handle view.xtype
36422 * Fires when this panel is activated.
36423 * @param {Roo.ContentPanel} this
36427 * @event deactivate
36428 * Fires when this panel is activated.
36429 * @param {Roo.ContentPanel} this
36431 "deactivate" : true,
36435 * Fires when this panel is resized if fitToFrame is true.
36436 * @param {Roo.ContentPanel} this
36437 * @param {Number} width The width after any component adjustments
36438 * @param {Number} height The height after any component adjustments
36444 * Fires when this tab is created
36445 * @param {Roo.ContentPanel} this
36456 if(this.autoScroll){
36457 this.resizeEl.setStyle("overflow", "auto");
36459 // fix randome scrolling
36460 //this.el.on('scroll', function() {
36461 // Roo.log('fix random scolling');
36462 // this.scrollTo('top',0);
36465 content = content || this.content;
36467 this.setContent(content);
36469 if(config && config.url){
36470 this.setUrl(this.url, this.params, this.loadOnce);
36475 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36477 if (this.view && typeof(this.view.xtype) != 'undefined') {
36478 this.view.el = this.el.appendChild(document.createElement("div"));
36479 this.view = Roo.factory(this.view);
36480 this.view.render && this.view.render(false, '');
36484 this.fireEvent('render', this);
36487 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36491 setRegion : function(region){
36492 this.region = region;
36493 this.setActiveClass(region && !this.background);
36497 setActiveClass: function(state)
36500 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36501 this.el.setStyle('position','relative');
36503 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36504 this.el.setStyle('position', 'absolute');
36509 * Returns the toolbar for this Panel if one was configured.
36510 * @return {Roo.Toolbar}
36512 getToolbar : function(){
36513 return this.toolbar;
36516 setActiveState : function(active)
36518 this.active = active;
36519 this.setActiveClass(active);
36521 if(this.fireEvent("deactivate", this) === false){
36526 this.fireEvent("activate", this);
36530 * Updates this panel's element
36531 * @param {String} content The new content
36532 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36534 setContent : function(content, loadScripts){
36535 this.el.update(content, loadScripts);
36538 ignoreResize : function(w, h){
36539 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36542 this.lastSize = {width: w, height: h};
36547 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36548 * @return {Roo.UpdateManager} The UpdateManager
36550 getUpdateManager : function(){
36551 return this.el.getUpdateManager();
36554 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36555 * @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:
36558 url: "your-url.php",
36559 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36560 callback: yourFunction,
36561 scope: yourObject, //(optional scope)
36564 text: "Loading...",
36569 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36570 * 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.
36571 * @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}
36572 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36573 * @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.
36574 * @return {Roo.ContentPanel} this
36577 var um = this.el.getUpdateManager();
36578 um.update.apply(um, arguments);
36584 * 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.
36585 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36586 * @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)
36587 * @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)
36588 * @return {Roo.UpdateManager} The UpdateManager
36590 setUrl : function(url, params, loadOnce){
36591 if(this.refreshDelegate){
36592 this.removeListener("activate", this.refreshDelegate);
36594 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36595 this.on("activate", this.refreshDelegate);
36596 return this.el.getUpdateManager();
36599 _handleRefresh : function(url, params, loadOnce){
36600 if(!loadOnce || !this.loaded){
36601 var updater = this.el.getUpdateManager();
36602 updater.update(url, params, this._setLoaded.createDelegate(this));
36606 _setLoaded : function(){
36607 this.loaded = true;
36611 * Returns this panel's id
36614 getId : function(){
36619 * Returns this panel's element - used by regiosn to add.
36620 * @return {Roo.Element}
36622 getEl : function(){
36623 return this.wrapEl || this.el;
36628 adjustForComponents : function(width, height)
36630 //Roo.log('adjustForComponents ');
36631 if(this.resizeEl != this.el){
36632 width -= this.el.getFrameWidth('lr');
36633 height -= this.el.getFrameWidth('tb');
36636 var te = this.toolbar.getEl();
36637 te.setWidth(width);
36638 height -= te.getHeight();
36641 var te = this.footer.getEl();
36642 te.setWidth(width);
36643 height -= te.getHeight();
36647 if(this.adjustments){
36648 width += this.adjustments[0];
36649 height += this.adjustments[1];
36651 return {"width": width, "height": height};
36654 setSize : function(width, height){
36655 if(this.fitToFrame && !this.ignoreResize(width, height)){
36656 if(this.fitContainer && this.resizeEl != this.el){
36657 this.el.setSize(width, height);
36659 var size = this.adjustForComponents(width, height);
36660 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36661 this.fireEvent('resize', this, size.width, size.height);
36666 * Returns this panel's title
36669 getTitle : function(){
36671 if (typeof(this.title) != 'object') {
36676 for (var k in this.title) {
36677 if (!this.title.hasOwnProperty(k)) {
36681 if (k.indexOf('-') >= 0) {
36682 var s = k.split('-');
36683 for (var i = 0; i<s.length; i++) {
36684 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36687 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36694 * Set this panel's title
36695 * @param {String} title
36697 setTitle : function(title){
36698 this.title = title;
36700 this.region.updatePanelTitle(this, title);
36705 * Returns true is this panel was configured to be closable
36706 * @return {Boolean}
36708 isClosable : function(){
36709 return this.closable;
36712 beforeSlide : function(){
36714 this.resizeEl.clip();
36717 afterSlide : function(){
36719 this.resizeEl.unclip();
36723 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36724 * Will fail silently if the {@link #setUrl} method has not been called.
36725 * This does not activate the panel, just updates its content.
36727 refresh : function(){
36728 if(this.refreshDelegate){
36729 this.loaded = false;
36730 this.refreshDelegate();
36735 * Destroys this panel
36737 destroy : function(){
36738 this.el.removeAllListeners();
36739 var tempEl = document.createElement("span");
36740 tempEl.appendChild(this.el.dom);
36741 tempEl.innerHTML = "";
36747 * form - if the content panel contains a form - this is a reference to it.
36748 * @type {Roo.form.Form}
36752 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36753 * This contains a reference to it.
36759 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36769 * @param {Object} cfg Xtype definition of item to add.
36773 getChildContainer: function () {
36774 return this.getEl();
36779 var ret = new Roo.factory(cfg);
36784 if (cfg.xtype.match(/^Form$/)) {
36787 //if (this.footer) {
36788 // el = this.footer.container.insertSibling(false, 'before');
36790 el = this.el.createChild();
36793 this.form = new Roo.form.Form(cfg);
36796 if ( this.form.allItems.length) {
36797 this.form.render(el.dom);
36801 // should only have one of theses..
36802 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36803 // views.. should not be just added - used named prop 'view''
36805 cfg.el = this.el.appendChild(document.createElement("div"));
36808 var ret = new Roo.factory(cfg);
36810 ret.render && ret.render(false, ''); // render blank..
36820 * @class Roo.bootstrap.panel.Grid
36821 * @extends Roo.bootstrap.panel.Content
36823 * Create a new GridPanel.
36824 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
36825 * @param {Object} config A the config object
36831 Roo.bootstrap.panel.Grid = function(config)
36835 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
36836 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
36838 config.el = this.wrapper;
36839 //this.el = this.wrapper;
36841 if (config.container) {
36842 // ctor'ed from a Border/panel.grid
36845 this.wrapper.setStyle("overflow", "hidden");
36846 this.wrapper.addClass('roo-grid-container');
36851 if(config.toolbar){
36852 var tool_el = this.wrapper.createChild();
36853 this.toolbar = Roo.factory(config.toolbar);
36855 if (config.toolbar.items) {
36856 ti = config.toolbar.items ;
36857 delete config.toolbar.items ;
36861 this.toolbar.render(tool_el);
36862 for(var i =0;i < ti.length;i++) {
36863 // Roo.log(['add child', items[i]]);
36864 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36866 this.toolbar.items = nitems;
36868 delete config.toolbar;
36871 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
36872 config.grid.scrollBody = true;;
36873 config.grid.monitorWindowResize = false; // turn off autosizing
36874 config.grid.autoHeight = false;
36875 config.grid.autoWidth = false;
36877 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
36879 if (config.background) {
36880 // render grid on panel activation (if panel background)
36881 this.on('activate', function(gp) {
36882 if (!gp.grid.rendered) {
36883 gp.grid.render(this.wrapper);
36884 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36889 this.grid.render(this.wrapper);
36890 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36893 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
36894 // ??? needed ??? config.el = this.wrapper;
36899 // xtype created footer. - not sure if will work as we normally have to render first..
36900 if (this.footer && !this.footer.el && this.footer.xtype) {
36902 var ctr = this.grid.getView().getFooterPanel(true);
36903 this.footer.dataSource = this.grid.dataSource;
36904 this.footer = Roo.factory(this.footer, Roo);
36905 this.footer.render(ctr);
36915 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
36916 getId : function(){
36917 return this.grid.id;
36921 * Returns the grid for this panel
36922 * @return {Roo.bootstrap.Table}
36924 getGrid : function(){
36928 setSize : function(width, height){
36929 if(!this.ignoreResize(width, height)){
36930 var grid = this.grid;
36931 var size = this.adjustForComponents(width, height);
36932 var gridel = grid.getGridEl();
36933 gridel.setSize(size.width, size.height);
36935 var thd = grid.getGridEl().select('thead',true).first();
36936 var tbd = grid.getGridEl().select('tbody', true).first();
36938 tbd.setSize(width, height - thd.getHeight());
36947 beforeSlide : function(){
36948 this.grid.getView().scroller.clip();
36951 afterSlide : function(){
36952 this.grid.getView().scroller.unclip();
36955 destroy : function(){
36956 this.grid.destroy();
36958 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
36963 * @class Roo.bootstrap.panel.Nest
36964 * @extends Roo.bootstrap.panel.Content
36966 * Create a new Panel, that can contain a layout.Border.
36969 * @param {Roo.BorderLayout} layout The layout for this panel
36970 * @param {String/Object} config A string to set only the title or a config object
36972 Roo.bootstrap.panel.Nest = function(config)
36974 // construct with only one argument..
36975 /* FIXME - implement nicer consturctors
36976 if (layout.layout) {
36978 layout = config.layout;
36979 delete config.layout;
36981 if (layout.xtype && !layout.getEl) {
36982 // then layout needs constructing..
36983 layout = Roo.factory(layout, Roo);
36987 config.el = config.layout.getEl();
36989 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
36991 config.layout.monitorWindowResize = false; // turn off autosizing
36992 this.layout = config.layout;
36993 this.layout.getEl().addClass("roo-layout-nested-layout");
37000 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37002 setSize : function(width, height){
37003 if(!this.ignoreResize(width, height)){
37004 var size = this.adjustForComponents(width, height);
37005 var el = this.layout.getEl();
37006 if (size.height < 1) {
37007 el.setWidth(size.width);
37009 el.setSize(size.width, size.height);
37011 var touch = el.dom.offsetWidth;
37012 this.layout.layout();
37013 // ie requires a double layout on the first pass
37014 if(Roo.isIE && !this.initialized){
37015 this.initialized = true;
37016 this.layout.layout();
37021 // activate all subpanels if not currently active..
37023 setActiveState : function(active){
37024 this.active = active;
37025 this.setActiveClass(active);
37028 this.fireEvent("deactivate", this);
37032 this.fireEvent("activate", this);
37033 // not sure if this should happen before or after..
37034 if (!this.layout) {
37035 return; // should not happen..
37038 for (var r in this.layout.regions) {
37039 reg = this.layout.getRegion(r);
37040 if (reg.getActivePanel()) {
37041 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37042 reg.setActivePanel(reg.getActivePanel());
37045 if (!reg.panels.length) {
37048 reg.showPanel(reg.getPanel(0));
37057 * Returns the nested BorderLayout for this panel
37058 * @return {Roo.BorderLayout}
37060 getLayout : function(){
37061 return this.layout;
37065 * Adds a xtype elements to the layout of the nested panel
37069 xtype : 'ContentPanel',
37076 xtype : 'NestedLayoutPanel',
37082 items : [ ... list of content panels or nested layout panels.. ]
37086 * @param {Object} cfg Xtype definition of item to add.
37088 addxtype : function(cfg) {
37089 return this.layout.addxtype(cfg);
37094 * Ext JS Library 1.1.1
37095 * Copyright(c) 2006-2007, Ext JS, LLC.
37097 * Originally Released Under LGPL - original licence link has changed is not relivant.
37100 * <script type="text/javascript">
37103 * @class Roo.TabPanel
37104 * @extends Roo.util.Observable
37105 * A lightweight tab container.
37109 // basic tabs 1, built from existing content
37110 var tabs = new Roo.TabPanel("tabs1");
37111 tabs.addTab("script", "View Script");
37112 tabs.addTab("markup", "View Markup");
37113 tabs.activate("script");
37115 // more advanced tabs, built from javascript
37116 var jtabs = new Roo.TabPanel("jtabs");
37117 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37119 // set up the UpdateManager
37120 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37121 var updater = tab2.getUpdateManager();
37122 updater.setDefaultUrl("ajax1.htm");
37123 tab2.on('activate', updater.refresh, updater, true);
37125 // Use setUrl for Ajax loading
37126 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37127 tab3.setUrl("ajax2.htm", null, true);
37130 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37133 jtabs.activate("jtabs-1");
37136 * Create a new TabPanel.
37137 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37138 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37140 Roo.bootstrap.panel.Tabs = function(config){
37142 * The container element for this TabPanel.
37143 * @type Roo.Element
37145 this.el = Roo.get(config.el);
37148 if(typeof config == "boolean"){
37149 this.tabPosition = config ? "bottom" : "top";
37151 Roo.apply(this, config);
37155 if(this.tabPosition == "bottom"){
37156 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37157 this.el.addClass("roo-tabs-bottom");
37159 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37160 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37161 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37163 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37165 if(this.tabPosition != "bottom"){
37166 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37167 * @type Roo.Element
37169 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37170 this.el.addClass("roo-tabs-top");
37174 this.bodyEl.setStyle("position", "relative");
37176 this.active = null;
37177 this.activateDelegate = this.activate.createDelegate(this);
37182 * Fires when the active tab changes
37183 * @param {Roo.TabPanel} this
37184 * @param {Roo.TabPanelItem} activePanel The new active tab
37188 * @event beforetabchange
37189 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37190 * @param {Roo.TabPanel} this
37191 * @param {Object} e Set cancel to true on this object to cancel the tab change
37192 * @param {Roo.TabPanelItem} tab The tab being changed to
37194 "beforetabchange" : true
37197 Roo.EventManager.onWindowResize(this.onResize, this);
37198 this.cpad = this.el.getPadding("lr");
37199 this.hiddenCount = 0;
37202 // toolbar on the tabbar support...
37203 if (this.toolbar) {
37204 alert("no toolbar support yet");
37205 this.toolbar = false;
37207 var tcfg = this.toolbar;
37208 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37209 this.toolbar = new Roo.Toolbar(tcfg);
37210 if (Roo.isSafari) {
37211 var tbl = tcfg.container.child('table', true);
37212 tbl.setAttribute('width', '100%');
37220 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37223 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37225 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37227 tabPosition : "top",
37229 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37231 currentTabWidth : 0,
37233 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37237 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37241 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37243 preferredTabWidth : 175,
37245 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37247 resizeTabs : false,
37249 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37251 monitorResize : true,
37253 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37258 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37259 * @param {String} id The id of the div to use <b>or create</b>
37260 * @param {String} text The text for the tab
37261 * @param {String} content (optional) Content to put in the TabPanelItem body
37262 * @param {Boolean} closable (optional) True to create a close icon on the tab
37263 * @return {Roo.TabPanelItem} The created TabPanelItem
37265 addTab : function(id, text, content, closable, tpl)
37267 var item = new Roo.bootstrap.panel.TabItem({
37271 closable : closable,
37274 this.addTabItem(item);
37276 item.setContent(content);
37282 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37283 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37284 * @return {Roo.TabPanelItem}
37286 getTab : function(id){
37287 return this.items[id];
37291 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37292 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37294 hideTab : function(id){
37295 var t = this.items[id];
37298 this.hiddenCount++;
37299 this.autoSizeTabs();
37304 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37305 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37307 unhideTab : function(id){
37308 var t = this.items[id];
37310 t.setHidden(false);
37311 this.hiddenCount--;
37312 this.autoSizeTabs();
37317 * Adds an existing {@link Roo.TabPanelItem}.
37318 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37320 addTabItem : function(item){
37321 this.items[item.id] = item;
37322 this.items.push(item);
37323 // if(this.resizeTabs){
37324 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37325 // this.autoSizeTabs();
37327 // item.autoSize();
37332 * Removes a {@link Roo.TabPanelItem}.
37333 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37335 removeTab : function(id){
37336 var items = this.items;
37337 var tab = items[id];
37338 if(!tab) { return; }
37339 var index = items.indexOf(tab);
37340 if(this.active == tab && items.length > 1){
37341 var newTab = this.getNextAvailable(index);
37346 this.stripEl.dom.removeChild(tab.pnode.dom);
37347 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37348 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37350 items.splice(index, 1);
37351 delete this.items[tab.id];
37352 tab.fireEvent("close", tab);
37353 tab.purgeListeners();
37354 this.autoSizeTabs();
37357 getNextAvailable : function(start){
37358 var items = this.items;
37360 // look for a next tab that will slide over to
37361 // replace the one being removed
37362 while(index < items.length){
37363 var item = items[++index];
37364 if(item && !item.isHidden()){
37368 // if one isn't found select the previous tab (on the left)
37371 var item = items[--index];
37372 if(item && !item.isHidden()){
37380 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37381 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37383 disableTab : function(id){
37384 var tab = this.items[id];
37385 if(tab && this.active != tab){
37391 * Enables a {@link Roo.TabPanelItem} that is disabled.
37392 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37394 enableTab : function(id){
37395 var tab = this.items[id];
37400 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37401 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37402 * @return {Roo.TabPanelItem} The TabPanelItem.
37404 activate : function(id){
37405 var tab = this.items[id];
37409 if(tab == this.active || tab.disabled){
37413 this.fireEvent("beforetabchange", this, e, tab);
37414 if(e.cancel !== true && !tab.disabled){
37416 this.active.hide();
37418 this.active = this.items[id];
37419 this.active.show();
37420 this.fireEvent("tabchange", this, this.active);
37426 * Gets the active {@link Roo.TabPanelItem}.
37427 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37429 getActiveTab : function(){
37430 return this.active;
37434 * Updates the tab body element to fit the height of the container element
37435 * for overflow scrolling
37436 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37438 syncHeight : function(targetHeight){
37439 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37440 var bm = this.bodyEl.getMargins();
37441 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37442 this.bodyEl.setHeight(newHeight);
37446 onResize : function(){
37447 if(this.monitorResize){
37448 this.autoSizeTabs();
37453 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37455 beginUpdate : function(){
37456 this.updating = true;
37460 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37462 endUpdate : function(){
37463 this.updating = false;
37464 this.autoSizeTabs();
37468 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37470 autoSizeTabs : function(){
37471 var count = this.items.length;
37472 var vcount = count - this.hiddenCount;
37473 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37476 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37477 var availWidth = Math.floor(w / vcount);
37478 var b = this.stripBody;
37479 if(b.getWidth() > w){
37480 var tabs = this.items;
37481 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37482 if(availWidth < this.minTabWidth){
37483 /*if(!this.sleft){ // incomplete scrolling code
37484 this.createScrollButtons();
37487 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37490 if(this.currentTabWidth < this.preferredTabWidth){
37491 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37497 * Returns the number of tabs in this TabPanel.
37500 getCount : function(){
37501 return this.items.length;
37505 * Resizes all the tabs to the passed width
37506 * @param {Number} The new width
37508 setTabWidth : function(width){
37509 this.currentTabWidth = width;
37510 for(var i = 0, len = this.items.length; i < len; i++) {
37511 if(!this.items[i].isHidden()) {
37512 this.items[i].setWidth(width);
37518 * Destroys this TabPanel
37519 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37521 destroy : function(removeEl){
37522 Roo.EventManager.removeResizeListener(this.onResize, this);
37523 for(var i = 0, len = this.items.length; i < len; i++){
37524 this.items[i].purgeListeners();
37526 if(removeEl === true){
37527 this.el.update("");
37532 createStrip : function(container)
37534 var strip = document.createElement("nav");
37535 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37536 container.appendChild(strip);
37540 createStripList : function(strip)
37542 // div wrapper for retard IE
37543 // returns the "tr" element.
37544 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37545 //'<div class="x-tabs-strip-wrap">'+
37546 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37547 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37548 return strip.firstChild; //.firstChild.firstChild.firstChild;
37550 createBody : function(container)
37552 var body = document.createElement("div");
37553 Roo.id(body, "tab-body");
37554 //Roo.fly(body).addClass("x-tabs-body");
37555 Roo.fly(body).addClass("tab-content");
37556 container.appendChild(body);
37559 createItemBody :function(bodyEl, id){
37560 var body = Roo.getDom(id);
37562 body = document.createElement("div");
37565 //Roo.fly(body).addClass("x-tabs-item-body");
37566 Roo.fly(body).addClass("tab-pane");
37567 bodyEl.insertBefore(body, bodyEl.firstChild);
37571 createStripElements : function(stripEl, text, closable, tpl)
37573 var td = document.createElement("li"); // was td..
37576 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37579 stripEl.appendChild(td);
37581 td.className = "x-tabs-closable";
37582 if(!this.closeTpl){
37583 this.closeTpl = new Roo.Template(
37584 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37585 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37586 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37589 var el = this.closeTpl.overwrite(td, {"text": text});
37590 var close = el.getElementsByTagName("div")[0];
37591 var inner = el.getElementsByTagName("em")[0];
37592 return {"el": el, "close": close, "inner": inner};
37595 // not sure what this is..
37596 // if(!this.tabTpl){
37597 //this.tabTpl = new Roo.Template(
37598 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37599 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37601 // this.tabTpl = new Roo.Template(
37602 // '<a href="#">' +
37603 // '<span unselectable="on"' +
37604 // (this.disableTooltips ? '' : ' title="{text}"') +
37605 // ' >{text}</span></a>'
37611 var template = tpl || this.tabTpl || false;
37615 template = new Roo.Template(
37617 '<span unselectable="on"' +
37618 (this.disableTooltips ? '' : ' title="{text}"') +
37619 ' >{text}</span></a>'
37623 switch (typeof(template)) {
37627 template = new Roo.Template(template);
37633 var el = template.overwrite(td, {"text": text});
37635 var inner = el.getElementsByTagName("span")[0];
37637 return {"el": el, "inner": inner};
37645 * @class Roo.TabPanelItem
37646 * @extends Roo.util.Observable
37647 * Represents an individual item (tab plus body) in a TabPanel.
37648 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37649 * @param {String} id The id of this TabPanelItem
37650 * @param {String} text The text for the tab of this TabPanelItem
37651 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37653 Roo.bootstrap.panel.TabItem = function(config){
37655 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37656 * @type Roo.TabPanel
37658 this.tabPanel = config.panel;
37660 * The id for this TabPanelItem
37663 this.id = config.id;
37665 this.disabled = false;
37667 this.text = config.text;
37669 this.loaded = false;
37670 this.closable = config.closable;
37673 * The body element for this TabPanelItem.
37674 * @type Roo.Element
37676 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37677 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37678 this.bodyEl.setStyle("display", "block");
37679 this.bodyEl.setStyle("zoom", "1");
37680 //this.hideAction();
37682 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37684 this.el = Roo.get(els.el);
37685 this.inner = Roo.get(els.inner, true);
37686 this.textEl = Roo.get(this.el.dom.firstChild, true);
37687 this.pnode = Roo.get(els.el.parentNode, true);
37688 // this.el.on("mousedown", this.onTabMouseDown, this);
37689 this.el.on("click", this.onTabClick, this);
37691 if(config.closable){
37692 var c = Roo.get(els.close, true);
37693 c.dom.title = this.closeText;
37694 c.addClassOnOver("close-over");
37695 c.on("click", this.closeClick, this);
37701 * Fires when this tab becomes the active tab.
37702 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37703 * @param {Roo.TabPanelItem} this
37707 * @event beforeclose
37708 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37709 * @param {Roo.TabPanelItem} this
37710 * @param {Object} e Set cancel to true on this object to cancel the close.
37712 "beforeclose": true,
37715 * Fires when this tab is closed.
37716 * @param {Roo.TabPanelItem} this
37720 * @event deactivate
37721 * Fires when this tab is no longer the active tab.
37722 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37723 * @param {Roo.TabPanelItem} this
37725 "deactivate" : true
37727 this.hidden = false;
37729 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37732 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37734 purgeListeners : function(){
37735 Roo.util.Observable.prototype.purgeListeners.call(this);
37736 this.el.removeAllListeners();
37739 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37742 this.pnode.addClass("active");
37745 this.tabPanel.stripWrap.repaint();
37747 this.fireEvent("activate", this.tabPanel, this);
37751 * Returns true if this tab is the active tab.
37752 * @return {Boolean}
37754 isActive : function(){
37755 return this.tabPanel.getActiveTab() == this;
37759 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37762 this.pnode.removeClass("active");
37764 this.fireEvent("deactivate", this.tabPanel, this);
37767 hideAction : function(){
37768 this.bodyEl.hide();
37769 this.bodyEl.setStyle("position", "absolute");
37770 this.bodyEl.setLeft("-20000px");
37771 this.bodyEl.setTop("-20000px");
37774 showAction : function(){
37775 this.bodyEl.setStyle("position", "relative");
37776 this.bodyEl.setTop("");
37777 this.bodyEl.setLeft("");
37778 this.bodyEl.show();
37782 * Set the tooltip for the tab.
37783 * @param {String} tooltip The tab's tooltip
37785 setTooltip : function(text){
37786 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37787 this.textEl.dom.qtip = text;
37788 this.textEl.dom.removeAttribute('title');
37790 this.textEl.dom.title = text;
37794 onTabClick : function(e){
37795 e.preventDefault();
37796 this.tabPanel.activate(this.id);
37799 onTabMouseDown : function(e){
37800 e.preventDefault();
37801 this.tabPanel.activate(this.id);
37804 getWidth : function(){
37805 return this.inner.getWidth();
37808 setWidth : function(width){
37809 var iwidth = width - this.pnode.getPadding("lr");
37810 this.inner.setWidth(iwidth);
37811 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
37812 this.pnode.setWidth(width);
37816 * Show or hide the tab
37817 * @param {Boolean} hidden True to hide or false to show.
37819 setHidden : function(hidden){
37820 this.hidden = hidden;
37821 this.pnode.setStyle("display", hidden ? "none" : "");
37825 * Returns true if this tab is "hidden"
37826 * @return {Boolean}
37828 isHidden : function(){
37829 return this.hidden;
37833 * Returns the text for this tab
37836 getText : function(){
37840 autoSize : function(){
37841 //this.el.beginMeasure();
37842 this.textEl.setWidth(1);
37844 * #2804 [new] Tabs in Roojs
37845 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
37847 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
37848 //this.el.endMeasure();
37852 * Sets the text for the tab (Note: this also sets the tooltip text)
37853 * @param {String} text The tab's text and tooltip
37855 setText : function(text){
37857 this.textEl.update(text);
37858 this.setTooltip(text);
37859 //if(!this.tabPanel.resizeTabs){
37860 // this.autoSize();
37864 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
37866 activate : function(){
37867 this.tabPanel.activate(this.id);
37871 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
37873 disable : function(){
37874 if(this.tabPanel.active != this){
37875 this.disabled = true;
37876 this.pnode.addClass("disabled");
37881 * Enables this TabPanelItem if it was previously disabled.
37883 enable : function(){
37884 this.disabled = false;
37885 this.pnode.removeClass("disabled");
37889 * Sets the content for this TabPanelItem.
37890 * @param {String} content The content
37891 * @param {Boolean} loadScripts true to look for and load scripts
37893 setContent : function(content, loadScripts){
37894 this.bodyEl.update(content, loadScripts);
37898 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
37899 * @return {Roo.UpdateManager} The UpdateManager
37901 getUpdateManager : function(){
37902 return this.bodyEl.getUpdateManager();
37906 * Set a URL to be used to load the content for this TabPanelItem.
37907 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
37908 * @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)
37909 * @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)
37910 * @return {Roo.UpdateManager} The UpdateManager
37912 setUrl : function(url, params, loadOnce){
37913 if(this.refreshDelegate){
37914 this.un('activate', this.refreshDelegate);
37916 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37917 this.on("activate", this.refreshDelegate);
37918 return this.bodyEl.getUpdateManager();
37922 _handleRefresh : function(url, params, loadOnce){
37923 if(!loadOnce || !this.loaded){
37924 var updater = this.bodyEl.getUpdateManager();
37925 updater.update(url, params, this._setLoaded.createDelegate(this));
37930 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
37931 * Will fail silently if the setUrl method has not been called.
37932 * This does not activate the panel, just updates its content.
37934 refresh : function(){
37935 if(this.refreshDelegate){
37936 this.loaded = false;
37937 this.refreshDelegate();
37942 _setLoaded : function(){
37943 this.loaded = true;
37947 closeClick : function(e){
37950 this.fireEvent("beforeclose", this, o);
37951 if(o.cancel !== true){
37952 this.tabPanel.removeTab(this.id);
37956 * The text displayed in the tooltip for the close icon.
37959 closeText : "Close this tab"
37962 * This script refer to:
37963 * Title: International Telephone Input
37964 * Author: Jack O'Connor
37965 * Code version: v12.1.12
37966 * Availability: https://github.com/jackocnr/intl-tel-input.git
37969 Roo.bootstrap.PhoneInputData = function() {
37972 "Afghanistan (افغانستان)",
37977 "Albania (Shqipëri)",
37982 "Algeria (الجزائر)",
38007 "Antigua and Barbuda",
38017 "Armenia (Հայաստան)",
38033 "Austria (Österreich)",
38038 "Azerbaijan (Azərbaycan)",
38048 "Bahrain (البحرين)",
38053 "Bangladesh (বাংলাদেশ)",
38063 "Belarus (Беларусь)",
38068 "Belgium (België)",
38098 "Bosnia and Herzegovina (Босна и Херцеговина)",
38113 "British Indian Ocean Territory",
38118 "British Virgin Islands",
38128 "Bulgaria (България)",
38138 "Burundi (Uburundi)",
38143 "Cambodia (កម្ពុជា)",
38148 "Cameroon (Cameroun)",
38157 ["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"]
38160 "Cape Verde (Kabu Verdi)",
38165 "Caribbean Netherlands",
38176 "Central African Republic (République centrafricaine)",
38196 "Christmas Island",
38202 "Cocos (Keeling) Islands",
38213 "Comoros (جزر القمر)",
38218 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38223 "Congo (Republic) (Congo-Brazzaville)",
38243 "Croatia (Hrvatska)",
38264 "Czech Republic (Česká republika)",
38269 "Denmark (Danmark)",
38284 "Dominican Republic (República Dominicana)",
38288 ["809", "829", "849"]
38306 "Equatorial Guinea (Guinea Ecuatorial)",
38326 "Falkland Islands (Islas Malvinas)",
38331 "Faroe Islands (Føroyar)",
38352 "French Guiana (Guyane française)",
38357 "French Polynesia (Polynésie française)",
38372 "Georgia (საქართველო)",
38377 "Germany (Deutschland)",
38397 "Greenland (Kalaallit Nunaat)",
38434 "Guinea-Bissau (Guiné Bissau)",
38459 "Hungary (Magyarország)",
38464 "Iceland (Ísland)",
38484 "Iraq (العراق)",
38500 "Israel (ישראל)",
38527 "Jordan (الأردن)",
38532 "Kazakhstan (Казахстан)",
38553 "Kuwait (الكويت)",
38558 "Kyrgyzstan (Кыргызстан)",
38568 "Latvia (Latvija)",
38573 "Lebanon (لبنان)",
38588 "Libya (ليبيا)",
38598 "Lithuania (Lietuva)",
38613 "Macedonia (FYROM) (Македонија)",
38618 "Madagascar (Madagasikara)",
38648 "Marshall Islands",
38658 "Mauritania (موريتانيا)",
38663 "Mauritius (Moris)",
38684 "Moldova (Republica Moldova)",
38694 "Mongolia (Монгол)",
38699 "Montenegro (Crna Gora)",
38709 "Morocco (المغرب)",
38715 "Mozambique (Moçambique)",
38720 "Myanmar (Burma) (မြန်မာ)",
38725 "Namibia (Namibië)",
38740 "Netherlands (Nederland)",
38745 "New Caledonia (Nouvelle-Calédonie)",
38780 "North Korea (조선 민주주의 인민 공화국)",
38785 "Northern Mariana Islands",
38801 "Pakistan (پاکستان)",
38811 "Palestine (فلسطين)",
38821 "Papua New Guinea",
38863 "Réunion (La Réunion)",
38869 "Romania (România)",
38885 "Saint Barthélemy",
38896 "Saint Kitts and Nevis",
38906 "Saint Martin (Saint-Martin (partie française))",
38912 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
38917 "Saint Vincent and the Grenadines",
38932 "São Tomé and Príncipe (São Tomé e Príncipe)",
38937 "Saudi Arabia (المملكة العربية السعودية)",
38942 "Senegal (Sénégal)",
38972 "Slovakia (Slovensko)",
38977 "Slovenia (Slovenija)",
38987 "Somalia (Soomaaliya)",
38997 "South Korea (대한민국)",
39002 "South Sudan (جنوب السودان)",
39012 "Sri Lanka (ශ්රී ලංකාව)",
39017 "Sudan (السودان)",
39027 "Svalbard and Jan Mayen",
39038 "Sweden (Sverige)",
39043 "Switzerland (Schweiz)",
39048 "Syria (سوريا)",
39093 "Trinidad and Tobago",
39098 "Tunisia (تونس)",
39103 "Turkey (Türkiye)",
39113 "Turks and Caicos Islands",
39123 "U.S. Virgin Islands",
39133 "Ukraine (Україна)",
39138 "United Arab Emirates (الإمارات العربية المتحدة)",
39160 "Uzbekistan (Oʻzbekiston)",
39170 "Vatican City (Città del Vaticano)",
39181 "Vietnam (Việt Nam)",
39186 "Wallis and Futuna (Wallis-et-Futuna)",
39191 "Western Sahara (الصحراء الغربية)",
39197 "Yemen (اليمن)",
39221 * This script refer to:
39222 * Title: International Telephone Input
39223 * Author: Jack O'Connor
39224 * Code version: v12.1.12
39225 * Availability: https://github.com/jackocnr/intl-tel-input.git
39229 * @class Roo.bootstrap.PhoneInput
39230 * @extends Roo.bootstrap.TriggerField
39231 * An input with International dial-code selection
39233 * @cfg {String} defaultDialCode default '+852'
39234 * @cfg {Array} preferedCountries default []
39237 * Create a new PhoneInput.
39238 * @param {Object} config Configuration options
39241 Roo.bootstrap.PhoneInput = function(config) {
39242 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39245 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39247 listWidth: undefined,
39249 selectedClass: 'active',
39251 invalidClass : "has-warning",
39253 validClass: 'has-success',
39255 allowed: '0123456789',
39258 * @cfg {String} defaultDialCode The default dial code when initializing the input
39260 defaultDialCode: '+852',
39263 * @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
39265 preferedCountries: false,
39267 getAutoCreate : function()
39269 var data = Roo.bootstrap.PhoneInputData();
39270 var align = this.labelAlign || this.parentLabelAlign();
39273 this.allCountries = [];
39274 this.dialCodeMapping = [];
39276 for (var i = 0; i < data.length; i++) {
39278 this.allCountries[i] = {
39282 priority: c[3] || 0,
39283 areaCodes: c[4] || null
39285 this.dialCodeMapping[c[2]] = {
39288 priority: c[3] || 0,
39289 areaCodes: c[4] || null
39301 cls : 'form-control tel-input',
39302 autocomplete: 'new-password'
39305 var hiddenInput = {
39308 cls: 'hidden-tel-input'
39312 hiddenInput.name = this.name;
39315 if (this.disabled) {
39316 input.disabled = true;
39319 var flag_container = {
39336 cls: this.hasFeedback ? 'has-feedback' : '',
39342 cls: 'dial-code-holder',
39349 cls: 'roo-select2-container input-group',
39356 if (this.fieldLabel.length) {
39359 tooltip: 'This field is required'
39365 cls: 'control-label',
39371 html: this.fieldLabel
39374 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39380 if(this.indicatorpos == 'right') {
39381 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39388 if(align == 'left') {
39396 if(this.labelWidth > 12){
39397 label.style = "width: " + this.labelWidth + 'px';
39399 if(this.labelWidth < 13 && this.labelmd == 0){
39400 this.labelmd = this.labelWidth;
39402 if(this.labellg > 0){
39403 label.cls += ' col-lg-' + this.labellg;
39404 input.cls += ' col-lg-' + (12 - this.labellg);
39406 if(this.labelmd > 0){
39407 label.cls += ' col-md-' + this.labelmd;
39408 container.cls += ' col-md-' + (12 - this.labelmd);
39410 if(this.labelsm > 0){
39411 label.cls += ' col-sm-' + this.labelsm;
39412 container.cls += ' col-sm-' + (12 - this.labelsm);
39414 if(this.labelxs > 0){
39415 label.cls += ' col-xs-' + this.labelxs;
39416 container.cls += ' col-xs-' + (12 - this.labelxs);
39426 var settings = this;
39428 ['xs','sm','md','lg'].map(function(size){
39429 if (settings[size]) {
39430 cfg.cls += ' col-' + size + '-' + settings[size];
39434 this.store = new Roo.data.Store({
39435 proxy : new Roo.data.MemoryProxy({}),
39436 reader : new Roo.data.JsonReader({
39447 'name' : 'dialCode',
39451 'name' : 'priority',
39455 'name' : 'areaCodes',
39462 if(!this.preferedCountries) {
39463 this.preferedCountries = [
39470 var p = this.preferedCountries.reverse();
39473 for (var i = 0; i < p.length; i++) {
39474 for (var j = 0; j < this.allCountries.length; j++) {
39475 if(this.allCountries[j].iso2 == p[i]) {
39476 var t = this.allCountries[j];
39477 this.allCountries.splice(j,1);
39478 this.allCountries.unshift(t);
39484 this.store.proxy.data = {
39486 data: this.allCountries
39492 initEvents : function()
39495 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39497 this.indicator = this.indicatorEl();
39498 this.flag = this.flagEl();
39499 this.dialCodeHolder = this.dialCodeHolderEl();
39501 this.trigger = this.el.select('div.flag-box',true).first();
39502 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39507 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39508 _this.list.setWidth(lw);
39511 this.list.on('mouseover', this.onViewOver, this);
39512 this.list.on('mousemove', this.onViewMove, this);
39513 this.inputEl().on("keyup", this.onKeyUp, this);
39515 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39517 this.view = new Roo.View(this.list, this.tpl, {
39518 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39521 this.view.on('click', this.onViewClick, this);
39522 this.setValue(this.defaultDialCode);
39525 onTriggerClick : function(e)
39527 Roo.log('trigger click');
39532 if(this.isExpanded()){
39534 this.hasFocus = false;
39536 this.store.load({});
39537 this.hasFocus = true;
39542 isExpanded : function()
39544 return this.list.isVisible();
39547 collapse : function()
39549 if(!this.isExpanded()){
39553 Roo.get(document).un('mousedown', this.collapseIf, this);
39554 Roo.get(document).un('mousewheel', this.collapseIf, this);
39555 this.fireEvent('collapse', this);
39559 expand : function()
39563 if(this.isExpanded() || !this.hasFocus){
39567 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39568 this.list.setWidth(lw);
39571 this.restrictHeight();
39573 Roo.get(document).on('mousedown', this.collapseIf, this);
39574 Roo.get(document).on('mousewheel', this.collapseIf, this);
39576 this.fireEvent('expand', this);
39579 restrictHeight : function()
39581 this.list.alignTo(this.inputEl(), this.listAlign);
39582 this.list.alignTo(this.inputEl(), this.listAlign);
39585 onViewOver : function(e, t)
39587 if(this.inKeyMode){
39590 var item = this.view.findItemFromChild(t);
39593 var index = this.view.indexOf(item);
39594 this.select(index, false);
39599 onViewClick : function(view, doFocus, el, e)
39601 var index = this.view.getSelectedIndexes()[0];
39603 var r = this.store.getAt(index);
39606 this.onSelect(r, index);
39608 if(doFocus !== false && !this.blockFocus){
39609 this.inputEl().focus();
39613 onViewMove : function(e, t)
39615 this.inKeyMode = false;
39618 select : function(index, scrollIntoView)
39620 this.selectedIndex = index;
39621 this.view.select(index);
39622 if(scrollIntoView !== false){
39623 var el = this.view.getNode(index);
39625 this.list.scrollChildIntoView(el, false);
39630 createList : function()
39632 this.list = Roo.get(document.body).createChild({
39634 cls: 'typeahead typeahead-long dropdown-menu tel-list',
39635 style: 'display:none'
39637 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
39640 collapseIf : function(e)
39642 var in_combo = e.within(this.el);
39643 var in_list = e.within(this.list);
39644 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
39646 if (in_combo || in_list || is_list) {
39652 onSelect : function(record, index)
39654 if(this.fireEvent('beforeselect', this, record, index) !== false){
39656 this.setFlagClass(record.data.iso2);
39657 this.setDialCode(record.data.dialCode);
39658 this.hasFocus = false;
39660 this.fireEvent('select', this, record, index);
39664 flagEl : function()
39666 var flag = this.el.select('div.flag',true).first();
39673 dialCodeHolderEl : function()
39675 var d = this.el.select('input.dial-code-holder',true).first();
39682 setDialCode : function(v)
39684 this.dialCodeHolder.dom.value = '+'+v;
39687 setFlagClass : function(n)
39689 this.flag.dom.className = 'flag '+n;
39692 getValue : function()
39694 var v = this.inputEl().getValue();
39695 if(this.dialCodeHolder) {
39696 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
39701 setValue : function(v)
39703 var d = this.getDialCode(v);
39705 //invalid dial code
39706 if(v.length == 0 || !d || d.length == 0) {
39708 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
39709 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39715 this.setFlagClass(this.dialCodeMapping[d].iso2);
39716 this.setDialCode(d);
39717 this.inputEl().dom.value = v.replace('+'+d,'');
39718 this.hiddenEl().dom.value = this.getValue();
39723 getDialCode : function(v = '')
39725 if (v.length == 0) {
39726 return this.dialCodeHolder.dom.value;
39730 if (v.charAt(0) != "+") {
39733 var numericChars = "";
39734 for (var i = 1; i < v.length; i++) {
39735 var c = v.charAt(i);
39738 if (this.dialCodeMapping[numericChars]) {
39739 dialCode = v.substr(1, i);
39741 if (numericChars.length == 4) {
39751 this.setValue(this.defaultDialCode);
39755 hiddenEl : function()
39757 return this.el.select('input.hidden-tel-input',true).first();
39760 onKeyUp : function(e){
39762 var k = e.getKey();
39763 var c = e.getCharCode();
39766 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39767 this.allowed.indexOf(String.fromCharCode(c)) === -1
39772 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39775 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
39779 this.setValue(this.getValue());
39784 * @class Roo.bootstrap.MoneyField
39785 * @extends Roo.bootstrap.ComboBox
39786 * Bootstrap MoneyField class
39789 * Create a new MoneyField.
39790 * @param {Object} config Configuration options
39793 Roo.bootstrap.MoneyField = function(config) {
39795 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
39799 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
39802 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
39804 allowDecimals : true,
39806 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
39808 decimalSeparator : ".",
39810 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
39812 decimalPrecision : 2,
39814 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
39816 allowNegative : true,
39818 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
39820 minValue : Number.NEGATIVE_INFINITY,
39822 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
39824 maxValue : Number.MAX_VALUE,
39826 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
39828 minText : "The minimum value for this field is {0}",
39830 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
39832 maxText : "The maximum value for this field is {0}",
39834 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
39835 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
39837 nanText : "{0} is not a valid number",
39839 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
39850 getAutoCreate : function()
39852 var align = this.labelAlign || this.parentLabelAlign();
39864 cls : 'form-control roo-money-amount-input',
39865 autocomplete: 'new-password'
39869 input.name = this.name;
39872 if (this.disabled) {
39873 input.disabled = true;
39876 var clg = 12 - this.inputlg;
39877 var cmd = 12 - this.inputmd;
39878 var csm = 12 - this.inputsm;
39879 var cxs = 12 - this.inputxs;
39883 cls : 'row roo-money-field',
39887 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
39891 cls: 'roo-select2-container input-group',
39895 cls : 'form-control roo-money-currency-input',
39896 autocomplete: 'new-password'
39900 cls : 'input-group-addon',
39914 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
39918 cls: this.hasFeedback ? 'has-feedback' : '',
39929 if (this.fieldLabel.length) {
39932 tooltip: 'This field is required'
39938 cls: 'control-label',
39944 html: this.fieldLabel
39947 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39953 if(this.indicatorpos == 'right') {
39954 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39961 if(align == 'left') {
39969 if(this.labelWidth > 12){
39970 label.style = "width: " + this.labelWidth + 'px';
39972 if(this.labelWidth < 13 && this.labelmd == 0){
39973 this.labelmd = this.labelWidth;
39975 if(this.labellg > 0){
39976 label.cls += ' col-lg-' + this.labellg;
39977 input.cls += ' col-lg-' + (12 - this.labellg);
39979 if(this.labelmd > 0){
39980 label.cls += ' col-md-' + this.labelmd;
39981 container.cls += ' col-md-' + (12 - this.labelmd);
39983 if(this.labelsm > 0){
39984 label.cls += ' col-sm-' + this.labelsm;
39985 container.cls += ' col-sm-' + (12 - this.labelsm);
39987 if(this.labelxs > 0){
39988 label.cls += ' col-xs-' + this.labelxs;
39989 container.cls += ' col-xs-' + (12 - this.labelxs);
39999 var settings = this;
40001 ['xs','sm','md','lg'].map(function(size){
40002 if (settings[size]) {
40003 cfg.cls += ' col-' + size + '-' + settings[size];
40011 initEvents : function()
40013 this.indicator = this.indicatorEl();
40015 this.initCurrencyEvent();
40017 this.initNumberEvent();
40021 initCurrencyEvent : function()
40024 throw "can not find store for combo";
40027 this.store = Roo.factory(this.store, Roo.data);
40028 this.store.parent = this;
40032 this.triggerEl = this.el.select('.input-group-addon', true).first();
40034 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40039 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40040 _this.list.setWidth(lw);
40043 this.list.on('mouseover', this.onViewOver, this);
40044 this.list.on('mousemove', this.onViewMove, this);
40045 this.list.on('scroll', this.onViewScroll, this);
40048 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40051 this.view = new Roo.View(this.list, this.tpl, {
40052 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40055 this.view.on('click', this.onViewClick, this);
40057 this.store.on('beforeload', this.onBeforeLoad, this);
40058 this.store.on('load', this.onLoad, this);
40059 this.store.on('loadexception', this.onLoadException, this);
40061 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40062 "up" : function(e){
40063 this.inKeyMode = true;
40067 "down" : function(e){
40068 if(!this.isExpanded()){
40069 this.onTriggerClick();
40071 this.inKeyMode = true;
40076 "enter" : function(e){
40079 if(this.fireEvent("specialkey", this, e)){
40080 this.onViewClick(false);
40086 "esc" : function(e){
40090 "tab" : function(e){
40093 if(this.fireEvent("specialkey", this, e)){
40094 this.onViewClick(false);
40102 doRelay : function(foo, bar, hname){
40103 if(hname == 'down' || this.scope.isExpanded()){
40104 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40112 this.queryDelay = Math.max(this.queryDelay || 10,
40113 this.mode == 'local' ? 10 : 250);
40116 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
40118 if(this.typeAhead){
40119 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
40122 this.currencyEl().on("keyup", this.onCurrencyKeyUp, this);
40126 initNumberEvent : function(e)
40128 this.inputEl().on("keydown" , this.fireKey, this);
40129 this.inputEl().on("focus", this.onFocus, this);
40130 this.inputEl().on("blur", this.onBlur, this);
40132 this.inputEl().relayEvent('keyup', this);
40134 if(this.indicator){
40135 this.indicator.addClass('invisible');
40138 this.originalValue = this.getValue();
40140 if(this.validationEvent == 'keyup'){
40141 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40142 this.inputEl().on('keyup', this.filterValidation, this);
40144 else if(this.validationEvent !== false){
40145 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40148 if(this.selectOnFocus){
40149 this.on("focus", this.preFocus, this);
40152 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40153 this.inputEl().on("keypress", this.filterKeys, this);
40155 this.inputEl().relayEvent('keypress', this);
40158 var allowed = "0123456789";
40160 if(this.allowDecimals){
40161 allowed += this.decimalSeparator;
40164 if(this.allowNegative){
40168 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40170 var keyPress = function(e){
40172 var k = e.getKey();
40174 var c = e.getCharCode();
40177 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40178 allowed.indexOf(String.fromCharCode(c)) === -1
40184 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40188 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40193 this.inputEl().on("keypress", keyPress, this);
40197 onTriggerClick : function(e)
40204 this.loadNext = false;
40206 if(this.isExpanded()){
40211 this.hasFocus = true;
40213 if(this.triggerAction == 'all') {
40214 this.doQuery(this.allQuery, true);
40218 this.doQuery(this.getCurrency());
40221 getCurrency : function()
40223 var v = this.currencyEl().getValue();
40228 restrictHeight : function()
40230 this.list.alignTo(this.currencyEl(), this.listAlign);
40231 this.list.alignTo(this.currencyEl(), this.listAlign);
40234 onViewClick : function(view, doFocus, el, e)
40236 var index = this.view.getSelectedIndexes()[0];
40238 var r = this.store.getAt(index);
40241 this.onSelect(r, index);
40245 onSelect : function(record, index){
40247 if(this.fireEvent('beforeselect', this, record, index) !== false){
40249 this.setFromCurrencyData(index > -1 ? record.data : false);
40253 this.fireEvent('select', this, record, index);
40257 setFromCurrencyData : function(o)
40261 this.lastCurrency = o;
40263 if (this.currencyField) {
40264 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40266 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40269 this.lastSelectionText = currency;
40271 this.setCurrency(currency);
40274 setFromData : function(o)
40278 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40280 this.setFromCurrencyData(c);
40285 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40287 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40290 this.setValue(value);
40294 setCurrency : function(v)
40296 this.currencyValue = v;
40299 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40304 setValue : function(v)
40306 v = this.fixPrecision(v);
40308 v = String(v).replace(".", this.decimalSeparator);
40313 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40318 getRawValue : function()
40320 var v = this.inputEl().getValue();
40325 getValue : function()
40327 return this.fixPrecision(this.parseValue(this.getRawValue()));
40330 parseValue : function(value)
40332 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40333 return isNaN(value) ? '' : value;
40336 fixPrecision : function(value)
40338 var nan = isNaN(value);
40340 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40341 return nan ? '' : value;
40344 return parseFloat(value).toFixed(this.decimalPrecision);
40347 decimalPrecisionFcn : function(v)
40349 return Math.floor(v);
40352 validateValue : function(value)
40354 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40358 var num = this.parseValue(value);
40361 this.markInvalid(String.format(this.nanText, value));
40365 if(num < this.minValue){
40366 this.markInvalid(String.format(this.minText, this.minValue));
40370 if(num > this.maxValue){
40371 this.markInvalid(String.format(this.maxText, this.maxValue));
40378 validate : function()
40385 var currency = this.getCurrency();
40387 if(this.validateValue(this.getRawValue()) && currency.length){
40392 this.markInvalid();
40396 getName: function()
40401 beforeBlur : function()
40407 var v = this.parseValue(this.getRawValue());
40414 onBlur : function()
40418 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40419 //this.el.removeClass(this.focusClass);
40422 this.hasFocus = false;
40424 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40428 var v = this.getValue();
40430 if(String(v) !== String(this.startValue)){
40431 this.fireEvent('change', this, v, this.startValue);
40434 this.fireEvent("blur", this);
40437 onCurrencyKeyUp : function(e)
40439 Roo.log('on currency keyup');
40440 if(!e.isSpecialKey()){
40441 this.lastKey = e.getKey();
40442 this.dqTask.delay(this.queryDelay);
40446 inputEl : function()
40448 return this.el.select('.roo-money-amount-input', true).first();
40451 currencyEl : function()
40453 return this.el.select('.roo-money-currency-input', true).first();
40456 initQuery : function()
40458 var v = this.getCurrency();
40459 Roo.log('initQuery???');
40463 onTypeAhead : function()
40465 if(this.store.getCount() > 0){
40466 var r = this.store.getAt(0);
40467 var newValue = r.data[this.currencyField];
40468 var len = newValue.length;
40469 var selStart = this.getCurrency().length;
40471 if(selStart != len){
40472 this.setCurrency(newValue);
40473 this.selectText(selStart, newValue.length);
40478 selectText : function(start, end)
40480 var v = this.getCurrency();
40483 start = start === undefined ? 0 : start;
40484 end = end === undefined ? v.length : end;
40485 var d = this.el.dom;
40486 if(d.setSelectionRange){
40487 d.setSelectionRange(start, end);
40488 }else if(d.createTextRange){
40489 var range = d.createTextRange();
40490 range.moveStart("character", start);
40491 range.moveEnd("character", v.length-end);