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){
7684 if(!target && f.el.isVisible(true)){
7690 if(this.errorMask && !valid){
7691 Roo.bootstrap.Form.popover.mask(this, target);
7698 * Returns true if any fields in this form have changed since their original load.
7701 isDirty : function(){
7703 var items = this.getItems();
7704 items.each(function(f){
7714 * Performs a predefined action (submit or load) or custom actions you define on this form.
7715 * @param {String} actionName The name of the action type
7716 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7717 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7718 * accept other config options):
7720 Property Type Description
7721 ---------------- --------------- ----------------------------------------------------------------------------------
7722 url String The url for the action (defaults to the form's url)
7723 method String The form method to use (defaults to the form's method, or POST if not defined)
7724 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7725 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7726 validate the form on the client (defaults to false)
7728 * @return {BasicForm} this
7730 doAction : function(action, options){
7731 if(typeof action == 'string'){
7732 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7734 if(this.fireEvent('beforeaction', this, action) !== false){
7735 this.beforeAction(action);
7736 action.run.defer(100, action);
7742 beforeAction : function(action){
7743 var o = action.options;
7746 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7748 // not really supported yet.. ??
7750 //if(this.waitMsgTarget === true){
7751 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7752 //}else if(this.waitMsgTarget){
7753 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7754 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7756 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7762 afterAction : function(action, success){
7763 this.activeAction = null;
7764 var o = action.options;
7766 //if(this.waitMsgTarget === true){
7768 //}else if(this.waitMsgTarget){
7769 // this.waitMsgTarget.unmask();
7771 // Roo.MessageBox.updateProgress(1);
7772 // Roo.MessageBox.hide();
7779 Roo.callback(o.success, o.scope, [this, action]);
7780 this.fireEvent('actioncomplete', this, action);
7784 // failure condition..
7785 // we have a scenario where updates need confirming.
7786 // eg. if a locking scenario exists..
7787 // we look for { errors : { needs_confirm : true }} in the response.
7789 (typeof(action.result) != 'undefined') &&
7790 (typeof(action.result.errors) != 'undefined') &&
7791 (typeof(action.result.errors.needs_confirm) != 'undefined')
7794 Roo.log("not supported yet");
7797 Roo.MessageBox.confirm(
7798 "Change requires confirmation",
7799 action.result.errorMsg,
7804 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7814 Roo.callback(o.failure, o.scope, [this, action]);
7815 // show an error message if no failed handler is set..
7816 if (!this.hasListener('actionfailed')) {
7817 Roo.log("need to add dialog support");
7819 Roo.MessageBox.alert("Error",
7820 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7821 action.result.errorMsg :
7822 "Saving Failed, please check your entries or try again"
7827 this.fireEvent('actionfailed', this, action);
7832 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7833 * @param {String} id The value to search for
7836 findField : function(id){
7837 var items = this.getItems();
7838 var field = items.get(id);
7840 items.each(function(f){
7841 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7848 return field || null;
7851 * Mark fields in this form invalid in bulk.
7852 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7853 * @return {BasicForm} this
7855 markInvalid : function(errors){
7856 if(errors instanceof Array){
7857 for(var i = 0, len = errors.length; i < len; i++){
7858 var fieldError = errors[i];
7859 var f = this.findField(fieldError.id);
7861 f.markInvalid(fieldError.msg);
7867 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7868 field.markInvalid(errors[id]);
7872 //Roo.each(this.childForms || [], function (f) {
7873 // f.markInvalid(errors);
7880 * Set values for fields in this form in bulk.
7881 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7882 * @return {BasicForm} this
7884 setValues : function(values){
7885 if(values instanceof Array){ // array of objects
7886 for(var i = 0, len = values.length; i < len; i++){
7888 var f = this.findField(v.id);
7890 f.setValue(v.value);
7891 if(this.trackResetOnLoad){
7892 f.originalValue = f.getValue();
7896 }else{ // object hash
7899 if(typeof values[id] != 'function' && (field = this.findField(id))){
7901 if (field.setFromData &&
7903 field.displayField &&
7904 // combos' with local stores can
7905 // be queried via setValue()
7906 // to set their value..
7907 (field.store && !field.store.isLocal)
7911 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
7912 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
7913 field.setFromData(sd);
7916 field.setValue(values[id]);
7920 if(this.trackResetOnLoad){
7921 field.originalValue = field.getValue();
7927 //Roo.each(this.childForms || [], function (f) {
7928 // f.setValues(values);
7935 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
7936 * they are returned as an array.
7937 * @param {Boolean} asString
7940 getValues : function(asString){
7941 //if (this.childForms) {
7942 // copy values from the child forms
7943 // Roo.each(this.childForms, function (f) {
7944 // this.setValues(f.getValues());
7950 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
7951 if(asString === true){
7954 return Roo.urlDecode(fs);
7958 * Returns the fields in this form as an object with key/value pairs.
7959 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
7962 getFieldValues : function(with_hidden)
7964 var items = this.getItems();
7966 items.each(function(f){
7970 var v = f.getValue();
7971 if (f.inputType =='radio') {
7972 if (typeof(ret[f.getName()]) == 'undefined') {
7973 ret[f.getName()] = ''; // empty..
7976 if (!f.el.dom.checked) {
7984 // not sure if this supported any more..
7985 if ((typeof(v) == 'object') && f.getRawValue) {
7986 v = f.getRawValue() ; // dates..
7988 // combo boxes where name != hiddenName...
7989 if (f.name !== false && f.name != '' && f.name != f.getName()) {
7990 ret[f.name] = f.getRawValue();
7992 ret[f.getName()] = v;
7999 * Clears all invalid messages in this form.
8000 * @return {BasicForm} this
8002 clearInvalid : function(){
8003 var items = this.getItems();
8005 items.each(function(f){
8016 * @return {BasicForm} this
8019 var items = this.getItems();
8020 items.each(function(f){
8024 Roo.each(this.childForms || [], function (f) {
8031 getItems : function()
8033 var r=new Roo.util.MixedCollection(false, function(o){
8034 return o.id || (o.id = Roo.id());
8036 var iter = function(el) {
8043 Roo.each(el.items,function(e) {
8060 Roo.apply(Roo.bootstrap.Form, {
8087 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8088 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8089 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8090 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8093 this.maskEl.top.enableDisplayMode("block");
8094 this.maskEl.left.enableDisplayMode("block");
8095 this.maskEl.bottom.enableDisplayMode("block");
8096 this.maskEl.right.enableDisplayMode("block");
8098 this.toolTip = new Roo.bootstrap.Tooltip({
8099 cls : 'roo-form-error-popover',
8101 'left' : ['r-l', [-2,0], 'right'],
8102 'right' : ['l-r', [2,0], 'left'],
8103 'bottom' : ['tl-bl', [0,2], 'top'],
8104 'top' : [ 'bl-tl', [0,-2], 'bottom']
8108 this.toolTip.render(Roo.get(document.body));
8110 this.toolTip.el.enableDisplayMode("block");
8112 Roo.get(document.body).on('click', function(){
8116 Roo.get(document.body).on('touchstart', function(){
8120 this.isApplied = true
8123 mask : function(form, target)
8127 this.target = target;
8129 if(!this.form.errorMask || !target.el){
8133 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8135 Roo.log(scrollable);
8137 var ot = this.target.el.calcOffsetsTo(scrollable);
8139 var scrollTo = ot[1] - this.form.maskOffset;
8141 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8143 scrollable.scrollTo('top', scrollTo);
8145 var box = this.target.el.getBox();
8147 var zIndex = Roo.bootstrap.Modal.zIndex++;
8150 this.maskEl.top.setStyle('position', 'absolute');
8151 this.maskEl.top.setStyle('z-index', zIndex);
8152 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8153 this.maskEl.top.setLeft(0);
8154 this.maskEl.top.setTop(0);
8155 this.maskEl.top.show();
8157 this.maskEl.left.setStyle('position', 'absolute');
8158 this.maskEl.left.setStyle('z-index', zIndex);
8159 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8160 this.maskEl.left.setLeft(0);
8161 this.maskEl.left.setTop(box.y - this.padding);
8162 this.maskEl.left.show();
8164 this.maskEl.bottom.setStyle('position', 'absolute');
8165 this.maskEl.bottom.setStyle('z-index', zIndex);
8166 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8167 this.maskEl.bottom.setLeft(0);
8168 this.maskEl.bottom.setTop(box.bottom + this.padding);
8169 this.maskEl.bottom.show();
8171 this.maskEl.right.setStyle('position', 'absolute');
8172 this.maskEl.right.setStyle('z-index', zIndex);
8173 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8174 this.maskEl.right.setLeft(box.right + this.padding);
8175 this.maskEl.right.setTop(box.y - this.padding);
8176 this.maskEl.right.show();
8178 this.toolTip.bindEl = this.target.el;
8180 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8182 var tip = this.target.blankText;
8184 if(this.target.getValue() !== '' ) {
8186 if (this.target.invalidText.length) {
8187 tip = this.target.invalidText;
8188 } else if (this.target.regexText.length){
8189 tip = this.target.regexText;
8193 this.toolTip.show(tip);
8195 this.intervalID = window.setInterval(function() {
8196 Roo.bootstrap.Form.popover.unmask();
8199 window.onwheel = function(){ return false;};
8201 (function(){ this.isMasked = true; }).defer(500, this);
8207 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8211 this.maskEl.top.setStyle('position', 'absolute');
8212 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8213 this.maskEl.top.hide();
8215 this.maskEl.left.setStyle('position', 'absolute');
8216 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8217 this.maskEl.left.hide();
8219 this.maskEl.bottom.setStyle('position', 'absolute');
8220 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8221 this.maskEl.bottom.hide();
8223 this.maskEl.right.setStyle('position', 'absolute');
8224 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8225 this.maskEl.right.hide();
8227 this.toolTip.hide();
8229 this.toolTip.el.hide();
8231 window.onwheel = function(){ return true;};
8233 if(this.intervalID){
8234 window.clearInterval(this.intervalID);
8235 this.intervalID = false;
8238 this.isMasked = false;
8248 * Ext JS Library 1.1.1
8249 * Copyright(c) 2006-2007, Ext JS, LLC.
8251 * Originally Released Under LGPL - original licence link has changed is not relivant.
8254 * <script type="text/javascript">
8257 * @class Roo.form.VTypes
8258 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8261 Roo.form.VTypes = function(){
8262 // closure these in so they are only created once.
8263 var alpha = /^[a-zA-Z_]+$/;
8264 var alphanum = /^[a-zA-Z0-9_]+$/;
8265 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8266 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8268 // All these messages and functions are configurable
8271 * The function used to validate email addresses
8272 * @param {String} value The email address
8274 'email' : function(v){
8275 return email.test(v);
8278 * The error text to display when the email validation function returns false
8281 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8283 * The keystroke filter mask to be applied on email input
8286 'emailMask' : /[a-z0-9_\.\-@]/i,
8289 * The function used to validate URLs
8290 * @param {String} value The URL
8292 'url' : function(v){
8296 * The error text to display when the url validation function returns false
8299 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8302 * The function used to validate alpha values
8303 * @param {String} value The value
8305 'alpha' : function(v){
8306 return alpha.test(v);
8309 * The error text to display when the alpha validation function returns false
8312 'alphaText' : 'This field should only contain letters and _',
8314 * The keystroke filter mask to be applied on alpha input
8317 'alphaMask' : /[a-z_]/i,
8320 * The function used to validate alphanumeric values
8321 * @param {String} value The value
8323 'alphanum' : function(v){
8324 return alphanum.test(v);
8327 * The error text to display when the alphanumeric validation function returns false
8330 'alphanumText' : 'This field should only contain letters, numbers and _',
8332 * The keystroke filter mask to be applied on alphanumeric input
8335 'alphanumMask' : /[a-z0-9_]/i
8345 * @class Roo.bootstrap.Input
8346 * @extends Roo.bootstrap.Component
8347 * Bootstrap Input class
8348 * @cfg {Boolean} disabled is it disabled
8349 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8350 * @cfg {String} name name of the input
8351 * @cfg {string} fieldLabel - the label associated
8352 * @cfg {string} placeholder - placeholder to put in text.
8353 * @cfg {string} before - input group add on before
8354 * @cfg {string} after - input group add on after
8355 * @cfg {string} size - (lg|sm) or leave empty..
8356 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8357 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8358 * @cfg {Number} md colspan out of 12 for computer-sized screens
8359 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8360 * @cfg {string} value default value of the input
8361 * @cfg {Number} labelWidth set the width of label
8362 * @cfg {Number} labellg set the width of label (1-12)
8363 * @cfg {Number} labelmd set the width of label (1-12)
8364 * @cfg {Number} labelsm set the width of label (1-12)
8365 * @cfg {Number} labelxs set the width of label (1-12)
8366 * @cfg {String} labelAlign (top|left)
8367 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8368 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8369 * @cfg {String} indicatorpos (left|right) default left
8371 * @cfg {String} align (left|center|right) Default left
8372 * @cfg {Boolean} forceFeedback (true|false) Default false
8378 * Create a new Input
8379 * @param {Object} config The config object
8382 Roo.bootstrap.Input = function(config){
8384 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8389 * Fires when this field receives input focus.
8390 * @param {Roo.form.Field} this
8395 * Fires when this field loses input focus.
8396 * @param {Roo.form.Field} this
8401 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8402 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8403 * @param {Roo.form.Field} this
8404 * @param {Roo.EventObject} e The event object
8409 * Fires just before the field blurs if the field value has changed.
8410 * @param {Roo.form.Field} this
8411 * @param {Mixed} newValue The new value
8412 * @param {Mixed} oldValue The original value
8417 * Fires after the field has been marked as invalid.
8418 * @param {Roo.form.Field} this
8419 * @param {String} msg The validation message
8424 * Fires after the field has been validated with no errors.
8425 * @param {Roo.form.Field} this
8430 * Fires after the key up
8431 * @param {Roo.form.Field} this
8432 * @param {Roo.EventObject} e The event Object
8438 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8440 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8441 automatic validation (defaults to "keyup").
8443 validationEvent : "keyup",
8445 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8447 validateOnBlur : true,
8449 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8451 validationDelay : 250,
8453 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8455 focusClass : "x-form-focus", // not needed???
8459 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8461 invalidClass : "has-warning",
8464 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8466 validClass : "has-success",
8469 * @cfg {Boolean} hasFeedback (true|false) default true
8474 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8476 invalidFeedbackClass : "glyphicon-warning-sign",
8479 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8481 validFeedbackClass : "glyphicon-ok",
8484 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8486 selectOnFocus : false,
8489 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8493 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8498 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8500 disableKeyFilter : false,
8503 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8507 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8511 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8513 blankText : "Please complete this mandatory field",
8516 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8520 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8522 maxLength : Number.MAX_VALUE,
8524 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8526 minLengthText : "The minimum length for this field is {0}",
8528 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8530 maxLengthText : "The maximum length for this field is {0}",
8534 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8535 * If available, this function will be called only after the basic validators all return true, and will be passed the
8536 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8540 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8541 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8542 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8546 * @cfg {String} regexText -- Depricated - use Invalid Text
8551 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8557 autocomplete: false,
8576 formatedValue : false,
8577 forceFeedback : false,
8579 indicatorpos : 'left',
8586 parentLabelAlign : function()
8589 while (parent.parent()) {
8590 parent = parent.parent();
8591 if (typeof(parent.labelAlign) !='undefined') {
8592 return parent.labelAlign;
8599 getAutoCreate : function()
8601 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8607 if(this.inputType != 'hidden'){
8608 cfg.cls = 'form-group' //input-group
8614 type : this.inputType,
8616 cls : 'form-control',
8617 placeholder : this.placeholder || '',
8618 autocomplete : this.autocomplete || 'new-password'
8622 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8625 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8626 input.maxLength = this.maxLength;
8629 if (this.disabled) {
8630 input.disabled=true;
8633 if (this.readOnly) {
8634 input.readonly=true;
8638 input.name = this.name;
8642 input.cls += ' input-' + this.size;
8646 ['xs','sm','md','lg'].map(function(size){
8647 if (settings[size]) {
8648 cfg.cls += ' col-' + size + '-' + settings[size];
8652 var inputblock = input;
8656 cls: 'glyphicon form-control-feedback'
8659 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8662 cls : 'has-feedback',
8670 if (this.before || this.after) {
8673 cls : 'input-group',
8677 if (this.before && typeof(this.before) == 'string') {
8679 inputblock.cn.push({
8681 cls : 'roo-input-before input-group-addon',
8685 if (this.before && typeof(this.before) == 'object') {
8686 this.before = Roo.factory(this.before);
8688 inputblock.cn.push({
8690 cls : 'roo-input-before input-group-' +
8691 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8695 inputblock.cn.push(input);
8697 if (this.after && typeof(this.after) == 'string') {
8698 inputblock.cn.push({
8700 cls : 'roo-input-after input-group-addon',
8704 if (this.after && typeof(this.after) == 'object') {
8705 this.after = Roo.factory(this.after);
8707 inputblock.cn.push({
8709 cls : 'roo-input-after input-group-' +
8710 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8714 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8715 inputblock.cls += ' has-feedback';
8716 inputblock.cn.push(feedback);
8720 if (align ==='left' && this.fieldLabel.length) {
8722 cfg.cls += ' roo-form-group-label-left';
8727 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8728 tooltip : 'This field is required'
8733 cls : 'control-label',
8734 html : this.fieldLabel
8745 var labelCfg = cfg.cn[1];
8746 var contentCfg = cfg.cn[2];
8748 if(this.indicatorpos == 'right'){
8753 cls : 'control-label',
8757 html : this.fieldLabel
8761 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8762 tooltip : 'This field is required'
8775 labelCfg = cfg.cn[0];
8776 contentCfg = cfg.cn[1];
8780 if(this.labelWidth > 12){
8781 labelCfg.style = "width: " + this.labelWidth + 'px';
8784 if(this.labelWidth < 13 && this.labelmd == 0){
8785 this.labelmd = this.labelWidth;
8788 if(this.labellg > 0){
8789 labelCfg.cls += ' col-lg-' + this.labellg;
8790 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8793 if(this.labelmd > 0){
8794 labelCfg.cls += ' col-md-' + this.labelmd;
8795 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8798 if(this.labelsm > 0){
8799 labelCfg.cls += ' col-sm-' + this.labelsm;
8800 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8803 if(this.labelxs > 0){
8804 labelCfg.cls += ' col-xs-' + this.labelxs;
8805 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8809 } else if ( this.fieldLabel.length) {
8814 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8815 tooltip : 'This field is required'
8819 //cls : 'input-group-addon',
8820 html : this.fieldLabel
8828 if(this.indicatorpos == 'right'){
8833 //cls : 'input-group-addon',
8834 html : this.fieldLabel
8839 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8840 tooltip : 'This field is required'
8860 if (this.parentType === 'Navbar' && this.parent().bar) {
8861 cfg.cls += ' navbar-form';
8864 if (this.parentType === 'NavGroup') {
8865 cfg.cls += ' navbar-form';
8873 * return the real input element.
8875 inputEl: function ()
8877 return this.el.select('input.form-control',true).first();
8880 tooltipEl : function()
8882 return this.inputEl();
8885 indicatorEl : function()
8887 var indicator = this.el.select('i.roo-required-indicator',true).first();
8897 setDisabled : function(v)
8899 var i = this.inputEl().dom;
8901 i.removeAttribute('disabled');
8905 i.setAttribute('disabled','true');
8907 initEvents : function()
8910 this.inputEl().on("keydown" , this.fireKey, this);
8911 this.inputEl().on("focus", this.onFocus, this);
8912 this.inputEl().on("blur", this.onBlur, this);
8914 this.inputEl().relayEvent('keyup', this);
8916 this.indicator = this.indicatorEl();
8919 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
8920 this.indicator.hide();
8923 // reference to original value for reset
8924 this.originalValue = this.getValue();
8925 //Roo.form.TextField.superclass.initEvents.call(this);
8926 if(this.validationEvent == 'keyup'){
8927 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8928 this.inputEl().on('keyup', this.filterValidation, this);
8930 else if(this.validationEvent !== false){
8931 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8934 if(this.selectOnFocus){
8935 this.on("focus", this.preFocus, this);
8938 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8939 this.inputEl().on("keypress", this.filterKeys, this);
8941 this.inputEl().relayEvent('keypress', this);
8944 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8945 this.el.on("click", this.autoSize, this);
8948 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
8949 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
8952 if (typeof(this.before) == 'object') {
8953 this.before.render(this.el.select('.roo-input-before',true).first());
8955 if (typeof(this.after) == 'object') {
8956 this.after.render(this.el.select('.roo-input-after',true).first());
8961 filterValidation : function(e){
8962 if(!e.isNavKeyPress()){
8963 this.validationTask.delay(this.validationDelay);
8967 * Validates the field value
8968 * @return {Boolean} True if the value is valid, else false
8970 validate : function(){
8971 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
8972 if(this.disabled || this.validateValue(this.getRawValue())){
8983 * Validates a value according to the field's validation rules and marks the field as invalid
8984 * if the validation fails
8985 * @param {Mixed} value The value to validate
8986 * @return {Boolean} True if the value is valid, else false
8988 validateValue : function(value){
8989 if(value.length < 1) { // if it's blank
8990 if(this.allowBlank){
8993 return this.inputEl().hasClass('hide') ? true : false;
8996 if(value.length < this.minLength){
8999 if(value.length > this.maxLength){
9003 var vt = Roo.form.VTypes;
9004 if(!vt[this.vtype](value, this)){
9008 if(typeof this.validator == "function"){
9009 var msg = this.validator(value);
9013 if (typeof(msg) == 'string') {
9014 this.invalidText = msg;
9018 if(this.regex && !this.regex.test(value)){
9028 fireKey : function(e){
9029 //Roo.log('field ' + e.getKey());
9030 if(e.isNavKeyPress()){
9031 this.fireEvent("specialkey", this, e);
9034 focus : function (selectText){
9036 this.inputEl().focus();
9037 if(selectText === true){
9038 this.inputEl().dom.select();
9044 onFocus : function(){
9045 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9046 // this.el.addClass(this.focusClass);
9049 this.hasFocus = true;
9050 this.startValue = this.getValue();
9051 this.fireEvent("focus", this);
9055 beforeBlur : Roo.emptyFn,
9059 onBlur : function(){
9061 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9062 //this.el.removeClass(this.focusClass);
9064 this.hasFocus = false;
9065 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9068 var v = this.getValue();
9069 if(String(v) !== String(this.startValue)){
9070 this.fireEvent('change', this, v, this.startValue);
9072 this.fireEvent("blur", this);
9076 * Resets the current field value to the originally loaded value and clears any validation messages
9079 this.setValue(this.originalValue);
9083 * Returns the name of the field
9084 * @return {Mixed} name The name field
9086 getName: function(){
9090 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9091 * @return {Mixed} value The field value
9093 getValue : function(){
9095 var v = this.inputEl().getValue();
9100 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9101 * @return {Mixed} value The field value
9103 getRawValue : function(){
9104 var v = this.inputEl().getValue();
9110 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9111 * @param {Mixed} value The value to set
9113 setRawValue : function(v){
9114 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9117 selectText : function(start, end){
9118 var v = this.getRawValue();
9120 start = start === undefined ? 0 : start;
9121 end = end === undefined ? v.length : end;
9122 var d = this.inputEl().dom;
9123 if(d.setSelectionRange){
9124 d.setSelectionRange(start, end);
9125 }else if(d.createTextRange){
9126 var range = d.createTextRange();
9127 range.moveStart("character", start);
9128 range.moveEnd("character", v.length-end);
9135 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9136 * @param {Mixed} value The value to set
9138 setValue : function(v){
9141 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9147 processValue : function(value){
9148 if(this.stripCharsRe){
9149 var newValue = value.replace(this.stripCharsRe, '');
9150 if(newValue !== value){
9151 this.setRawValue(newValue);
9158 preFocus : function(){
9160 if(this.selectOnFocus){
9161 this.inputEl().dom.select();
9164 filterKeys : function(e){
9166 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9169 var c = e.getCharCode(), cc = String.fromCharCode(c);
9170 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9173 if(!this.maskRe.test(cc)){
9178 * Clear any invalid styles/messages for this field
9180 clearInvalid : function(){
9182 if(!this.el || this.preventMark){ // not rendered
9187 this.el.removeClass(this.invalidClass);
9189 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9191 var feedback = this.el.select('.form-control-feedback', true).first();
9194 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9199 this.fireEvent('valid', this);
9203 * Mark this field as valid
9205 markValid : function()
9207 if(!this.el || this.preventMark){ // not rendered...
9211 this.el.removeClass([this.invalidClass, this.validClass]);
9213 var feedback = this.el.select('.form-control-feedback', true).first();
9216 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9223 if(this.allowBlank && !this.getRawValue().length){
9228 this.indicator.hide();
9231 this.el.addClass(this.validClass);
9233 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9235 var feedback = this.el.select('.form-control-feedback', true).first();
9238 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9239 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9244 this.fireEvent('valid', this);
9248 * Mark this field as invalid
9249 * @param {String} msg The validation message
9251 markInvalid : function(msg)
9253 if(!this.el || this.preventMark){ // not rendered
9257 this.el.removeClass([this.invalidClass, this.validClass]);
9259 var feedback = this.el.select('.form-control-feedback', true).first();
9262 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9269 if(this.allowBlank && !this.getRawValue().length){
9274 this.indicator.show();
9277 this.el.addClass(this.invalidClass);
9279 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9281 var feedback = this.el.select('.form-control-feedback', true).first();
9284 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9286 if(this.getValue().length || this.forceFeedback){
9287 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9294 this.fireEvent('invalid', this, msg);
9297 SafariOnKeyDown : function(event)
9299 // this is a workaround for a password hang bug on chrome/ webkit.
9300 if (this.inputEl().dom.type != 'password') {
9304 var isSelectAll = false;
9306 if(this.inputEl().dom.selectionEnd > 0){
9307 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9309 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9310 event.preventDefault();
9315 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9317 event.preventDefault();
9318 // this is very hacky as keydown always get's upper case.
9320 var cc = String.fromCharCode(event.getCharCode());
9321 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9325 adjustWidth : function(tag, w){
9326 tag = tag.toLowerCase();
9327 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9328 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9332 if(tag == 'textarea'){
9335 }else if(Roo.isOpera){
9339 if(tag == 'textarea'){
9347 setFieldLabel : function(v)
9349 this.fieldLabel = v;
9352 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9366 * @class Roo.bootstrap.TextArea
9367 * @extends Roo.bootstrap.Input
9368 * Bootstrap TextArea class
9369 * @cfg {Number} cols Specifies the visible width of a text area
9370 * @cfg {Number} rows Specifies the visible number of lines in a text area
9371 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9372 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9373 * @cfg {string} html text
9376 * Create a new TextArea
9377 * @param {Object} config The config object
9380 Roo.bootstrap.TextArea = function(config){
9381 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9385 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9395 getAutoCreate : function(){
9397 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9403 if(this.inputType != 'hidden'){
9404 cfg.cls = 'form-group' //input-group
9412 value : this.value || '',
9413 html: this.html || '',
9414 cls : 'form-control',
9415 placeholder : this.placeholder || ''
9419 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9420 input.maxLength = this.maxLength;
9424 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9428 input.cols = this.cols;
9431 if (this.readOnly) {
9432 input.readonly = true;
9436 input.name = this.name;
9440 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9444 ['xs','sm','md','lg'].map(function(size){
9445 if (settings[size]) {
9446 cfg.cls += ' col-' + size + '-' + settings[size];
9450 var inputblock = input;
9452 if(this.hasFeedback && !this.allowBlank){
9456 cls: 'glyphicon form-control-feedback'
9460 cls : 'has-feedback',
9469 if (this.before || this.after) {
9472 cls : 'input-group',
9476 inputblock.cn.push({
9478 cls : 'input-group-addon',
9483 inputblock.cn.push(input);
9485 if(this.hasFeedback && !this.allowBlank){
9486 inputblock.cls += ' has-feedback';
9487 inputblock.cn.push(feedback);
9491 inputblock.cn.push({
9493 cls : 'input-group-addon',
9500 if (align ==='left' && this.fieldLabel.length) {
9505 cls : 'control-label',
9506 html : this.fieldLabel
9517 if(this.labelWidth > 12){
9518 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9521 if(this.labelWidth < 13 && this.labelmd == 0){
9522 this.labelmd = this.labelWidth;
9525 if(this.labellg > 0){
9526 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9527 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9530 if(this.labelmd > 0){
9531 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9532 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9535 if(this.labelsm > 0){
9536 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9537 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9540 if(this.labelxs > 0){
9541 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9542 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9545 } else if ( this.fieldLabel.length) {
9550 //cls : 'input-group-addon',
9551 html : this.fieldLabel
9569 if (this.disabled) {
9570 input.disabled=true;
9577 * return the real textarea element.
9579 inputEl: function ()
9581 return this.el.select('textarea.form-control',true).first();
9585 * Clear any invalid styles/messages for this field
9587 clearInvalid : function()
9590 if(!this.el || this.preventMark){ // not rendered
9594 var label = this.el.select('label', true).first();
9595 var icon = this.el.select('i.fa-star', true).first();
9601 this.el.removeClass(this.invalidClass);
9603 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9605 var feedback = this.el.select('.form-control-feedback', true).first();
9608 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9613 this.fireEvent('valid', this);
9617 * Mark this field as valid
9619 markValid : function()
9621 if(!this.el || this.preventMark){ // not rendered
9625 this.el.removeClass([this.invalidClass, this.validClass]);
9627 var feedback = this.el.select('.form-control-feedback', true).first();
9630 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9633 if(this.disabled || this.allowBlank){
9637 var label = this.el.select('label', true).first();
9638 var icon = this.el.select('i.fa-star', true).first();
9644 this.el.addClass(this.validClass);
9646 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9648 var feedback = this.el.select('.form-control-feedback', true).first();
9651 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9652 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9657 this.fireEvent('valid', this);
9661 * Mark this field as invalid
9662 * @param {String} msg The validation message
9664 markInvalid : function(msg)
9666 if(!this.el || this.preventMark){ // not rendered
9670 this.el.removeClass([this.invalidClass, this.validClass]);
9672 var feedback = this.el.select('.form-control-feedback', true).first();
9675 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9678 if(this.disabled || this.allowBlank){
9682 var label = this.el.select('label', true).first();
9683 var icon = this.el.select('i.fa-star', true).first();
9685 if(!this.getValue().length && label && !icon){
9686 this.el.createChild({
9688 cls : 'text-danger fa fa-lg fa-star',
9689 tooltip : 'This field is required',
9690 style : 'margin-right:5px;'
9694 this.el.addClass(this.invalidClass);
9696 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9698 var feedback = this.el.select('.form-control-feedback', true).first();
9701 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9703 if(this.getValue().length || this.forceFeedback){
9704 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9711 this.fireEvent('invalid', this, msg);
9719 * trigger field - base class for combo..
9724 * @class Roo.bootstrap.TriggerField
9725 * @extends Roo.bootstrap.Input
9726 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9727 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9728 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9729 * for which you can provide a custom implementation. For example:
9731 var trigger = new Roo.bootstrap.TriggerField();
9732 trigger.onTriggerClick = myTriggerFn;
9733 trigger.applyTo('my-field');
9736 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9737 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9738 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9739 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9740 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9743 * Create a new TriggerField.
9744 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9745 * to the base TextField)
9747 Roo.bootstrap.TriggerField = function(config){
9748 this.mimicing = false;
9749 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9752 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9754 * @cfg {String} triggerClass A CSS class to apply to the trigger
9757 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9762 * @cfg {Boolean} removable (true|false) special filter default false
9766 /** @cfg {Boolean} grow @hide */
9767 /** @cfg {Number} growMin @hide */
9768 /** @cfg {Number} growMax @hide */
9774 autoSize: Roo.emptyFn,
9781 actionMode : 'wrap',
9786 getAutoCreate : function(){
9788 var align = this.labelAlign || this.parentLabelAlign();
9793 cls: 'form-group' //input-group
9800 type : this.inputType,
9801 cls : 'form-control',
9802 autocomplete: 'new-password',
9803 placeholder : this.placeholder || ''
9806 input.name = this.name;
9809 input.cls += ' input-' + this.size;
9812 if (this.disabled) {
9813 input.disabled=true;
9816 var inputblock = input;
9818 if(this.hasFeedback && !this.allowBlank){
9822 cls: 'glyphicon form-control-feedback'
9825 if(this.removable && !this.editable && !this.tickable){
9827 cls : 'has-feedback',
9833 cls : 'roo-combo-removable-btn close'
9840 cls : 'has-feedback',
9849 if(this.removable && !this.editable && !this.tickable){
9851 cls : 'roo-removable',
9857 cls : 'roo-combo-removable-btn close'
9864 if (this.before || this.after) {
9867 cls : 'input-group',
9871 inputblock.cn.push({
9873 cls : 'input-group-addon',
9878 inputblock.cn.push(input);
9880 if(this.hasFeedback && !this.allowBlank){
9881 inputblock.cls += ' has-feedback';
9882 inputblock.cn.push(feedback);
9886 inputblock.cn.push({
9888 cls : 'input-group-addon',
9901 cls: 'form-hidden-field'
9915 cls: 'form-hidden-field'
9919 cls: 'roo-select2-choices',
9923 cls: 'roo-select2-search-field',
9936 cls: 'roo-select2-container input-group',
9941 // cls: 'typeahead typeahead-long dropdown-menu',
9942 // style: 'display:none'
9947 if(!this.multiple && this.showToggleBtn){
9953 if (this.caret != false) {
9956 cls: 'fa fa-' + this.caret
9963 cls : 'input-group-addon btn dropdown-toggle',
9968 cls: 'combobox-clear',
9982 combobox.cls += ' roo-select2-container-multi';
9985 if (align ==='left' && this.fieldLabel.length) {
9987 cfg.cls += ' roo-form-group-label-left';
9992 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9993 tooltip : 'This field is required'
9998 cls : 'control-label',
9999 html : this.fieldLabel
10011 var labelCfg = cfg.cn[1];
10012 var contentCfg = cfg.cn[2];
10014 if(this.indicatorpos == 'right'){
10019 cls : 'control-label',
10023 html : this.fieldLabel
10027 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10028 tooltip : 'This field is required'
10041 labelCfg = cfg.cn[0];
10042 contentCfg = cfg.cn[1];
10045 if(this.labelWidth > 12){
10046 labelCfg.style = "width: " + this.labelWidth + 'px';
10049 if(this.labelWidth < 13 && this.labelmd == 0){
10050 this.labelmd = this.labelWidth;
10053 if(this.labellg > 0){
10054 labelCfg.cls += ' col-lg-' + this.labellg;
10055 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10058 if(this.labelmd > 0){
10059 labelCfg.cls += ' col-md-' + this.labelmd;
10060 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10063 if(this.labelsm > 0){
10064 labelCfg.cls += ' col-sm-' + this.labelsm;
10065 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10068 if(this.labelxs > 0){
10069 labelCfg.cls += ' col-xs-' + this.labelxs;
10070 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10073 } else if ( this.fieldLabel.length) {
10074 // Roo.log(" label");
10078 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10079 tooltip : 'This field is required'
10083 //cls : 'input-group-addon',
10084 html : this.fieldLabel
10092 if(this.indicatorpos == 'right'){
10100 html : this.fieldLabel
10104 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10105 tooltip : 'This field is required'
10118 // Roo.log(" no label && no align");
10125 ['xs','sm','md','lg'].map(function(size){
10126 if (settings[size]) {
10127 cfg.cls += ' col-' + size + '-' + settings[size];
10138 onResize : function(w, h){
10139 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10140 // if(typeof w == 'number'){
10141 // var x = w - this.trigger.getWidth();
10142 // this.inputEl().setWidth(this.adjustWidth('input', x));
10143 // this.trigger.setStyle('left', x+'px');
10148 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10151 getResizeEl : function(){
10152 return this.inputEl();
10156 getPositionEl : function(){
10157 return this.inputEl();
10161 alignErrorIcon : function(){
10162 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10166 initEvents : function(){
10170 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10171 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10172 if(!this.multiple && this.showToggleBtn){
10173 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10174 if(this.hideTrigger){
10175 this.trigger.setDisplayed(false);
10177 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10181 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10184 if(this.removable && !this.editable && !this.tickable){
10185 var close = this.closeTriggerEl();
10188 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10189 close.on('click', this.removeBtnClick, this, close);
10193 //this.trigger.addClassOnOver('x-form-trigger-over');
10194 //this.trigger.addClassOnClick('x-form-trigger-click');
10197 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10201 closeTriggerEl : function()
10203 var close = this.el.select('.roo-combo-removable-btn', true).first();
10204 return close ? close : false;
10207 removeBtnClick : function(e, h, el)
10209 e.preventDefault();
10211 if(this.fireEvent("remove", this) !== false){
10213 this.fireEvent("afterremove", this)
10217 createList : function()
10219 this.list = Roo.get(document.body).createChild({
10221 cls: 'typeahead typeahead-long dropdown-menu',
10222 style: 'display:none'
10225 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10230 initTrigger : function(){
10235 onDestroy : function(){
10237 this.trigger.removeAllListeners();
10238 // this.trigger.remove();
10241 // this.wrap.remove();
10243 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10247 onFocus : function(){
10248 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10250 if(!this.mimicing){
10251 this.wrap.addClass('x-trigger-wrap-focus');
10252 this.mimicing = true;
10253 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10254 if(this.monitorTab){
10255 this.el.on("keydown", this.checkTab, this);
10262 checkTab : function(e){
10263 if(e.getKey() == e.TAB){
10264 this.triggerBlur();
10269 onBlur : function(){
10274 mimicBlur : function(e, t){
10276 if(!this.wrap.contains(t) && this.validateBlur()){
10277 this.triggerBlur();
10283 triggerBlur : function(){
10284 this.mimicing = false;
10285 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10286 if(this.monitorTab){
10287 this.el.un("keydown", this.checkTab, this);
10289 //this.wrap.removeClass('x-trigger-wrap-focus');
10290 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10294 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10295 validateBlur : function(e, t){
10300 onDisable : function(){
10301 this.inputEl().dom.disabled = true;
10302 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10304 // this.wrap.addClass('x-item-disabled');
10309 onEnable : function(){
10310 this.inputEl().dom.disabled = false;
10311 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10313 // this.el.removeClass('x-item-disabled');
10318 onShow : function(){
10319 var ae = this.getActionEl();
10322 ae.dom.style.display = '';
10323 ae.dom.style.visibility = 'visible';
10329 onHide : function(){
10330 var ae = this.getActionEl();
10331 ae.dom.style.display = 'none';
10335 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10336 * by an implementing function.
10338 * @param {EventObject} e
10340 onTriggerClick : Roo.emptyFn
10344 * Ext JS Library 1.1.1
10345 * Copyright(c) 2006-2007, Ext JS, LLC.
10347 * Originally Released Under LGPL - original licence link has changed is not relivant.
10350 * <script type="text/javascript">
10355 * @class Roo.data.SortTypes
10357 * Defines the default sorting (casting?) comparison functions used when sorting data.
10359 Roo.data.SortTypes = {
10361 * Default sort that does nothing
10362 * @param {Mixed} s The value being converted
10363 * @return {Mixed} The comparison value
10365 none : function(s){
10370 * The regular expression used to strip tags
10374 stripTagsRE : /<\/?[^>]+>/gi,
10377 * Strips all HTML tags to sort on text only
10378 * @param {Mixed} s The value being converted
10379 * @return {String} The comparison value
10381 asText : function(s){
10382 return String(s).replace(this.stripTagsRE, "");
10386 * Strips all HTML tags to sort on text only - Case insensitive
10387 * @param {Mixed} s The value being converted
10388 * @return {String} The comparison value
10390 asUCText : function(s){
10391 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10395 * Case insensitive string
10396 * @param {Mixed} s The value being converted
10397 * @return {String} The comparison value
10399 asUCString : function(s) {
10400 return String(s).toUpperCase();
10405 * @param {Mixed} s The value being converted
10406 * @return {Number} The comparison value
10408 asDate : function(s) {
10412 if(s instanceof Date){
10413 return s.getTime();
10415 return Date.parse(String(s));
10420 * @param {Mixed} s The value being converted
10421 * @return {Float} The comparison value
10423 asFloat : function(s) {
10424 var val = parseFloat(String(s).replace(/,/g, ""));
10433 * @param {Mixed} s The value being converted
10434 * @return {Number} The comparison value
10436 asInt : function(s) {
10437 var val = parseInt(String(s).replace(/,/g, ""));
10445 * Ext JS Library 1.1.1
10446 * Copyright(c) 2006-2007, Ext JS, LLC.
10448 * Originally Released Under LGPL - original licence link has changed is not relivant.
10451 * <script type="text/javascript">
10455 * @class Roo.data.Record
10456 * Instances of this class encapsulate both record <em>definition</em> information, and record
10457 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10458 * to access Records cached in an {@link Roo.data.Store} object.<br>
10460 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10461 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10464 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10466 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10467 * {@link #create}. The parameters are the same.
10468 * @param {Array} data An associative Array of data values keyed by the field name.
10469 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10470 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10471 * not specified an integer id is generated.
10473 Roo.data.Record = function(data, id){
10474 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10479 * Generate a constructor for a specific record layout.
10480 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10481 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10482 * Each field definition object may contain the following properties: <ul>
10483 * <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,
10484 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10485 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10486 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10487 * is being used, then this is a string containing the javascript expression to reference the data relative to
10488 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10489 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10490 * this may be omitted.</p></li>
10491 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10492 * <ul><li>auto (Default, implies no conversion)</li>
10497 * <li>date</li></ul></p></li>
10498 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10499 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10500 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10501 * by the Reader into an object that will be stored in the Record. It is passed the
10502 * following parameters:<ul>
10503 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10505 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10507 * <br>usage:<br><pre><code>
10508 var TopicRecord = Roo.data.Record.create(
10509 {name: 'title', mapping: 'topic_title'},
10510 {name: 'author', mapping: 'username'},
10511 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10512 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10513 {name: 'lastPoster', mapping: 'user2'},
10514 {name: 'excerpt', mapping: 'post_text'}
10517 var myNewRecord = new TopicRecord({
10518 title: 'Do my job please',
10521 lastPost: new Date(),
10522 lastPoster: 'Animal',
10523 excerpt: 'No way dude!'
10525 myStore.add(myNewRecord);
10530 Roo.data.Record.create = function(o){
10531 var f = function(){
10532 f.superclass.constructor.apply(this, arguments);
10534 Roo.extend(f, Roo.data.Record);
10535 var p = f.prototype;
10536 p.fields = new Roo.util.MixedCollection(false, function(field){
10539 for(var i = 0, len = o.length; i < len; i++){
10540 p.fields.add(new Roo.data.Field(o[i]));
10542 f.getField = function(name){
10543 return p.fields.get(name);
10548 Roo.data.Record.AUTO_ID = 1000;
10549 Roo.data.Record.EDIT = 'edit';
10550 Roo.data.Record.REJECT = 'reject';
10551 Roo.data.Record.COMMIT = 'commit';
10553 Roo.data.Record.prototype = {
10555 * Readonly flag - true if this record has been modified.
10564 join : function(store){
10565 this.store = store;
10569 * Set the named field to the specified value.
10570 * @param {String} name The name of the field to set.
10571 * @param {Object} value The value to set the field to.
10573 set : function(name, value){
10574 if(this.data[name] == value){
10578 if(!this.modified){
10579 this.modified = {};
10581 if(typeof this.modified[name] == 'undefined'){
10582 this.modified[name] = this.data[name];
10584 this.data[name] = value;
10585 if(!this.editing && this.store){
10586 this.store.afterEdit(this);
10591 * Get the value of the named field.
10592 * @param {String} name The name of the field to get the value of.
10593 * @return {Object} The value of the field.
10595 get : function(name){
10596 return this.data[name];
10600 beginEdit : function(){
10601 this.editing = true;
10602 this.modified = {};
10606 cancelEdit : function(){
10607 this.editing = false;
10608 delete this.modified;
10612 endEdit : function(){
10613 this.editing = false;
10614 if(this.dirty && this.store){
10615 this.store.afterEdit(this);
10620 * Usually called by the {@link Roo.data.Store} which owns the Record.
10621 * Rejects all changes made to the Record since either creation, or the last commit operation.
10622 * Modified fields are reverted to their original values.
10624 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10625 * of reject operations.
10627 reject : function(){
10628 var m = this.modified;
10630 if(typeof m[n] != "function"){
10631 this.data[n] = m[n];
10634 this.dirty = false;
10635 delete this.modified;
10636 this.editing = false;
10638 this.store.afterReject(this);
10643 * Usually called by the {@link Roo.data.Store} which owns the Record.
10644 * Commits all changes made to the Record since either creation, or the last commit operation.
10646 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10647 * of commit operations.
10649 commit : function(){
10650 this.dirty = false;
10651 delete this.modified;
10652 this.editing = false;
10654 this.store.afterCommit(this);
10659 hasError : function(){
10660 return this.error != null;
10664 clearError : function(){
10669 * Creates a copy of this record.
10670 * @param {String} id (optional) A new record id if you don't want to use this record's id
10673 copy : function(newId) {
10674 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10678 * Ext JS Library 1.1.1
10679 * Copyright(c) 2006-2007, Ext JS, LLC.
10681 * Originally Released Under LGPL - original licence link has changed is not relivant.
10684 * <script type="text/javascript">
10690 * @class Roo.data.Store
10691 * @extends Roo.util.Observable
10692 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10693 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10695 * 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
10696 * has no knowledge of the format of the data returned by the Proxy.<br>
10698 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10699 * instances from the data object. These records are cached and made available through accessor functions.
10701 * Creates a new Store.
10702 * @param {Object} config A config object containing the objects needed for the Store to access data,
10703 * and read the data into Records.
10705 Roo.data.Store = function(config){
10706 this.data = new Roo.util.MixedCollection(false);
10707 this.data.getKey = function(o){
10710 this.baseParams = {};
10712 this.paramNames = {
10717 "multisort" : "_multisort"
10720 if(config && config.data){
10721 this.inlineData = config.data;
10722 delete config.data;
10725 Roo.apply(this, config);
10727 if(this.reader){ // reader passed
10728 this.reader = Roo.factory(this.reader, Roo.data);
10729 this.reader.xmodule = this.xmodule || false;
10730 if(!this.recordType){
10731 this.recordType = this.reader.recordType;
10733 if(this.reader.onMetaChange){
10734 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10738 if(this.recordType){
10739 this.fields = this.recordType.prototype.fields;
10741 this.modified = [];
10745 * @event datachanged
10746 * Fires when the data cache has changed, and a widget which is using this Store
10747 * as a Record cache should refresh its view.
10748 * @param {Store} this
10750 datachanged : true,
10752 * @event metachange
10753 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10754 * @param {Store} this
10755 * @param {Object} meta The JSON metadata
10760 * Fires when Records have been added to the Store
10761 * @param {Store} this
10762 * @param {Roo.data.Record[]} records The array of Records added
10763 * @param {Number} index The index at which the record(s) were added
10768 * Fires when a Record has been removed from the Store
10769 * @param {Store} this
10770 * @param {Roo.data.Record} record The Record that was removed
10771 * @param {Number} index The index at which the record was removed
10776 * Fires when a Record has been updated
10777 * @param {Store} this
10778 * @param {Roo.data.Record} record The Record that was updated
10779 * @param {String} operation The update operation being performed. Value may be one of:
10781 Roo.data.Record.EDIT
10782 Roo.data.Record.REJECT
10783 Roo.data.Record.COMMIT
10789 * Fires when the data cache has been cleared.
10790 * @param {Store} this
10794 * @event beforeload
10795 * Fires before a request is made for a new data object. If the beforeload handler returns false
10796 * the load action will be canceled.
10797 * @param {Store} this
10798 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10802 * @event beforeloadadd
10803 * Fires after a new set of Records has been loaded.
10804 * @param {Store} this
10805 * @param {Roo.data.Record[]} records The Records that were loaded
10806 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10808 beforeloadadd : true,
10811 * Fires after a new set of Records has been loaded, before they are added to the store.
10812 * @param {Store} this
10813 * @param {Roo.data.Record[]} records The Records that were loaded
10814 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10815 * @params {Object} return from reader
10819 * @event loadexception
10820 * Fires if an exception occurs in the Proxy during loading.
10821 * Called with the signature of the Proxy's "loadexception" event.
10822 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10825 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10826 * @param {Object} load options
10827 * @param {Object} jsonData from your request (normally this contains the Exception)
10829 loadexception : true
10833 this.proxy = Roo.factory(this.proxy, Roo.data);
10834 this.proxy.xmodule = this.xmodule || false;
10835 this.relayEvents(this.proxy, ["loadexception"]);
10837 this.sortToggle = {};
10838 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10840 Roo.data.Store.superclass.constructor.call(this);
10842 if(this.inlineData){
10843 this.loadData(this.inlineData);
10844 delete this.inlineData;
10848 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10850 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10851 * without a remote query - used by combo/forms at present.
10855 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10858 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10861 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10862 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10865 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10866 * on any HTTP request
10869 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10872 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10876 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10877 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10879 remoteSort : false,
10882 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10883 * loaded or when a record is removed. (defaults to false).
10885 pruneModifiedRecords : false,
10888 lastOptions : null,
10891 * Add Records to the Store and fires the add event.
10892 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10894 add : function(records){
10895 records = [].concat(records);
10896 for(var i = 0, len = records.length; i < len; i++){
10897 records[i].join(this);
10899 var index = this.data.length;
10900 this.data.addAll(records);
10901 this.fireEvent("add", this, records, index);
10905 * Remove a Record from the Store and fires the remove event.
10906 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10908 remove : function(record){
10909 var index = this.data.indexOf(record);
10910 this.data.removeAt(index);
10911 if(this.pruneModifiedRecords){
10912 this.modified.remove(record);
10914 this.fireEvent("remove", this, record, index);
10918 * Remove all Records from the Store and fires the clear event.
10920 removeAll : function(){
10922 if(this.pruneModifiedRecords){
10923 this.modified = [];
10925 this.fireEvent("clear", this);
10929 * Inserts Records to the Store at the given index and fires the add event.
10930 * @param {Number} index The start index at which to insert the passed Records.
10931 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10933 insert : function(index, records){
10934 records = [].concat(records);
10935 for(var i = 0, len = records.length; i < len; i++){
10936 this.data.insert(index, records[i]);
10937 records[i].join(this);
10939 this.fireEvent("add", this, records, index);
10943 * Get the index within the cache of the passed Record.
10944 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
10945 * @return {Number} The index of the passed Record. Returns -1 if not found.
10947 indexOf : function(record){
10948 return this.data.indexOf(record);
10952 * Get the index within the cache of the Record with the passed id.
10953 * @param {String} id The id of the Record to find.
10954 * @return {Number} The index of the Record. Returns -1 if not found.
10956 indexOfId : function(id){
10957 return this.data.indexOfKey(id);
10961 * Get the Record with the specified id.
10962 * @param {String} id The id of the Record to find.
10963 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
10965 getById : function(id){
10966 return this.data.key(id);
10970 * Get the Record at the specified index.
10971 * @param {Number} index The index of the Record to find.
10972 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
10974 getAt : function(index){
10975 return this.data.itemAt(index);
10979 * Returns a range of Records between specified indices.
10980 * @param {Number} startIndex (optional) The starting index (defaults to 0)
10981 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
10982 * @return {Roo.data.Record[]} An array of Records
10984 getRange : function(start, end){
10985 return this.data.getRange(start, end);
10989 storeOptions : function(o){
10990 o = Roo.apply({}, o);
10993 this.lastOptions = o;
10997 * Loads the Record cache from the configured Proxy using the configured Reader.
10999 * If using remote paging, then the first load call must specify the <em>start</em>
11000 * and <em>limit</em> properties in the options.params property to establish the initial
11001 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11003 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11004 * and this call will return before the new data has been loaded. Perform any post-processing
11005 * in a callback function, or in a "load" event handler.</strong>
11007 * @param {Object} options An object containing properties which control loading options:<ul>
11008 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11009 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11010 * passed the following arguments:<ul>
11011 * <li>r : Roo.data.Record[]</li>
11012 * <li>options: Options object from the load call</li>
11013 * <li>success: Boolean success indicator</li></ul></li>
11014 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11015 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11018 load : function(options){
11019 options = options || {};
11020 if(this.fireEvent("beforeload", this, options) !== false){
11021 this.storeOptions(options);
11022 var p = Roo.apply(options.params || {}, this.baseParams);
11023 // if meta was not loaded from remote source.. try requesting it.
11024 if (!this.reader.metaFromRemote) {
11025 p._requestMeta = 1;
11027 if(this.sortInfo && this.remoteSort){
11028 var pn = this.paramNames;
11029 p[pn["sort"]] = this.sortInfo.field;
11030 p[pn["dir"]] = this.sortInfo.direction;
11032 if (this.multiSort) {
11033 var pn = this.paramNames;
11034 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11037 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11042 * Reloads the Record cache from the configured Proxy using the configured Reader and
11043 * the options from the last load operation performed.
11044 * @param {Object} options (optional) An object containing properties which may override the options
11045 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11046 * the most recently used options are reused).
11048 reload : function(options){
11049 this.load(Roo.applyIf(options||{}, this.lastOptions));
11053 // Called as a callback by the Reader during a load operation.
11054 loadRecords : function(o, options, success){
11055 if(!o || success === false){
11056 if(success !== false){
11057 this.fireEvent("load", this, [], options, o);
11059 if(options.callback){
11060 options.callback.call(options.scope || this, [], options, false);
11064 // if data returned failure - throw an exception.
11065 if (o.success === false) {
11066 // show a message if no listener is registered.
11067 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11068 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11070 // loadmask wil be hooked into this..
11071 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11074 var r = o.records, t = o.totalRecords || r.length;
11076 this.fireEvent("beforeloadadd", this, r, options, o);
11078 if(!options || options.add !== true){
11079 if(this.pruneModifiedRecords){
11080 this.modified = [];
11082 for(var i = 0, len = r.length; i < len; i++){
11086 this.data = this.snapshot;
11087 delete this.snapshot;
11090 this.data.addAll(r);
11091 this.totalLength = t;
11093 this.fireEvent("datachanged", this);
11095 this.totalLength = Math.max(t, this.data.length+r.length);
11099 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11101 var e = new Roo.data.Record({});
11103 e.set(this.parent.displayField, this.parent.emptyTitle);
11104 e.set(this.parent.valueField, '');
11109 this.fireEvent("load", this, r, options, o);
11110 if(options.callback){
11111 options.callback.call(options.scope || this, r, options, true);
11117 * Loads data from a passed data block. A Reader which understands the format of the data
11118 * must have been configured in the constructor.
11119 * @param {Object} data The data block from which to read the Records. The format of the data expected
11120 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11121 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11123 loadData : function(o, append){
11124 var r = this.reader.readRecords(o);
11125 this.loadRecords(r, {add: append}, true);
11129 * Gets the number of cached records.
11131 * <em>If using paging, this may not be the total size of the dataset. If the data object
11132 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11133 * the data set size</em>
11135 getCount : function(){
11136 return this.data.length || 0;
11140 * Gets the total number of records in the dataset as returned by the server.
11142 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11143 * the dataset size</em>
11145 getTotalCount : function(){
11146 return this.totalLength || 0;
11150 * Returns the sort state of the Store as an object with two properties:
11152 field {String} The name of the field by which the Records are sorted
11153 direction {String} The sort order, "ASC" or "DESC"
11156 getSortState : function(){
11157 return this.sortInfo;
11161 applySort : function(){
11162 if(this.sortInfo && !this.remoteSort){
11163 var s = this.sortInfo, f = s.field;
11164 var st = this.fields.get(f).sortType;
11165 var fn = function(r1, r2){
11166 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11167 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11169 this.data.sort(s.direction, fn);
11170 if(this.snapshot && this.snapshot != this.data){
11171 this.snapshot.sort(s.direction, fn);
11177 * Sets the default sort column and order to be used by the next load operation.
11178 * @param {String} fieldName The name of the field to sort by.
11179 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11181 setDefaultSort : function(field, dir){
11182 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11186 * Sort the Records.
11187 * If remote sorting is used, the sort is performed on the server, and the cache is
11188 * reloaded. If local sorting is used, the cache is sorted internally.
11189 * @param {String} fieldName The name of the field to sort by.
11190 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11192 sort : function(fieldName, dir){
11193 var f = this.fields.get(fieldName);
11195 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11197 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11198 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11203 this.sortToggle[f.name] = dir;
11204 this.sortInfo = {field: f.name, direction: dir};
11205 if(!this.remoteSort){
11207 this.fireEvent("datachanged", this);
11209 this.load(this.lastOptions);
11214 * Calls the specified function for each of the Records in the cache.
11215 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11216 * Returning <em>false</em> aborts and exits the iteration.
11217 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11219 each : function(fn, scope){
11220 this.data.each(fn, scope);
11224 * Gets all records modified since the last commit. Modified records are persisted across load operations
11225 * (e.g., during paging).
11226 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11228 getModifiedRecords : function(){
11229 return this.modified;
11233 createFilterFn : function(property, value, anyMatch){
11234 if(!value.exec){ // not a regex
11235 value = String(value);
11236 if(value.length == 0){
11239 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11241 return function(r){
11242 return value.test(r.data[property]);
11247 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11248 * @param {String} property A field on your records
11249 * @param {Number} start The record index to start at (defaults to 0)
11250 * @param {Number} end The last record index to include (defaults to length - 1)
11251 * @return {Number} The sum
11253 sum : function(property, start, end){
11254 var rs = this.data.items, v = 0;
11255 start = start || 0;
11256 end = (end || end === 0) ? end : rs.length-1;
11258 for(var i = start; i <= end; i++){
11259 v += (rs[i].data[property] || 0);
11265 * Filter the records by a specified property.
11266 * @param {String} field A field on your records
11267 * @param {String/RegExp} value Either a string that the field
11268 * should start with or a RegExp to test against the field
11269 * @param {Boolean} anyMatch True to match any part not just the beginning
11271 filter : function(property, value, anyMatch){
11272 var fn = this.createFilterFn(property, value, anyMatch);
11273 return fn ? this.filterBy(fn) : this.clearFilter();
11277 * Filter by a function. The specified function will be called with each
11278 * record in this data source. If the function returns true the record is included,
11279 * otherwise it is filtered.
11280 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11281 * @param {Object} scope (optional) The scope of the function (defaults to this)
11283 filterBy : function(fn, scope){
11284 this.snapshot = this.snapshot || this.data;
11285 this.data = this.queryBy(fn, scope||this);
11286 this.fireEvent("datachanged", this);
11290 * Query the records by a specified property.
11291 * @param {String} field A field on your records
11292 * @param {String/RegExp} value Either a string that the field
11293 * should start with or a RegExp to test against the field
11294 * @param {Boolean} anyMatch True to match any part not just the beginning
11295 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11297 query : function(property, value, anyMatch){
11298 var fn = this.createFilterFn(property, value, anyMatch);
11299 return fn ? this.queryBy(fn) : this.data.clone();
11303 * Query by a function. The specified function will be called with each
11304 * record in this data source. If the function returns true the record is included
11306 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11307 * @param {Object} scope (optional) The scope of the function (defaults to this)
11308 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11310 queryBy : function(fn, scope){
11311 var data = this.snapshot || this.data;
11312 return data.filterBy(fn, scope||this);
11316 * Collects unique values for a particular dataIndex from this store.
11317 * @param {String} dataIndex The property to collect
11318 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11319 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11320 * @return {Array} An array of the unique values
11322 collect : function(dataIndex, allowNull, bypassFilter){
11323 var d = (bypassFilter === true && this.snapshot) ?
11324 this.snapshot.items : this.data.items;
11325 var v, sv, r = [], l = {};
11326 for(var i = 0, len = d.length; i < len; i++){
11327 v = d[i].data[dataIndex];
11329 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11338 * Revert to a view of the Record cache with no filtering applied.
11339 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11341 clearFilter : function(suppressEvent){
11342 if(this.snapshot && this.snapshot != this.data){
11343 this.data = this.snapshot;
11344 delete this.snapshot;
11345 if(suppressEvent !== true){
11346 this.fireEvent("datachanged", this);
11352 afterEdit : function(record){
11353 if(this.modified.indexOf(record) == -1){
11354 this.modified.push(record);
11356 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11360 afterReject : function(record){
11361 this.modified.remove(record);
11362 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11366 afterCommit : function(record){
11367 this.modified.remove(record);
11368 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11372 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11373 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11375 commitChanges : function(){
11376 var m = this.modified.slice(0);
11377 this.modified = [];
11378 for(var i = 0, len = m.length; i < len; i++){
11384 * Cancel outstanding changes on all changed records.
11386 rejectChanges : function(){
11387 var m = this.modified.slice(0);
11388 this.modified = [];
11389 for(var i = 0, len = m.length; i < len; i++){
11394 onMetaChange : function(meta, rtype, o){
11395 this.recordType = rtype;
11396 this.fields = rtype.prototype.fields;
11397 delete this.snapshot;
11398 this.sortInfo = meta.sortInfo || this.sortInfo;
11399 this.modified = [];
11400 this.fireEvent('metachange', this, this.reader.meta);
11403 moveIndex : function(data, type)
11405 var index = this.indexOf(data);
11407 var newIndex = index + type;
11411 this.insert(newIndex, data);
11416 * Ext JS Library 1.1.1
11417 * Copyright(c) 2006-2007, Ext JS, LLC.
11419 * Originally Released Under LGPL - original licence link has changed is not relivant.
11422 * <script type="text/javascript">
11426 * @class Roo.data.SimpleStore
11427 * @extends Roo.data.Store
11428 * Small helper class to make creating Stores from Array data easier.
11429 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11430 * @cfg {Array} fields An array of field definition objects, or field name strings.
11431 * @cfg {Array} data The multi-dimensional array of data
11433 * @param {Object} config
11435 Roo.data.SimpleStore = function(config){
11436 Roo.data.SimpleStore.superclass.constructor.call(this, {
11438 reader: new Roo.data.ArrayReader({
11441 Roo.data.Record.create(config.fields)
11443 proxy : new Roo.data.MemoryProxy(config.data)
11447 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11449 * Ext JS Library 1.1.1
11450 * Copyright(c) 2006-2007, Ext JS, LLC.
11452 * Originally Released Under LGPL - original licence link has changed is not relivant.
11455 * <script type="text/javascript">
11460 * @extends Roo.data.Store
11461 * @class Roo.data.JsonStore
11462 * Small helper class to make creating Stores for JSON data easier. <br/>
11464 var store = new Roo.data.JsonStore({
11465 url: 'get-images.php',
11467 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11470 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11471 * JsonReader and HttpProxy (unless inline data is provided).</b>
11472 * @cfg {Array} fields An array of field definition objects, or field name strings.
11474 * @param {Object} config
11476 Roo.data.JsonStore = function(c){
11477 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11478 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11479 reader: new Roo.data.JsonReader(c, c.fields)
11482 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11484 * Ext JS Library 1.1.1
11485 * Copyright(c) 2006-2007, Ext JS, LLC.
11487 * Originally Released Under LGPL - original licence link has changed is not relivant.
11490 * <script type="text/javascript">
11494 Roo.data.Field = function(config){
11495 if(typeof config == "string"){
11496 config = {name: config};
11498 Roo.apply(this, config);
11501 this.type = "auto";
11504 var st = Roo.data.SortTypes;
11505 // named sortTypes are supported, here we look them up
11506 if(typeof this.sortType == "string"){
11507 this.sortType = st[this.sortType];
11510 // set default sortType for strings and dates
11511 if(!this.sortType){
11514 this.sortType = st.asUCString;
11517 this.sortType = st.asDate;
11520 this.sortType = st.none;
11525 var stripRe = /[\$,%]/g;
11527 // prebuilt conversion function for this field, instead of
11528 // switching every time we're reading a value
11530 var cv, dateFormat = this.dateFormat;
11535 cv = function(v){ return v; };
11538 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11542 return v !== undefined && v !== null && v !== '' ?
11543 parseInt(String(v).replace(stripRe, ""), 10) : '';
11548 return v !== undefined && v !== null && v !== '' ?
11549 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11554 cv = function(v){ return v === true || v === "true" || v == 1; };
11561 if(v instanceof Date){
11565 if(dateFormat == "timestamp"){
11566 return new Date(v*1000);
11568 return Date.parseDate(v, dateFormat);
11570 var parsed = Date.parse(v);
11571 return parsed ? new Date(parsed) : null;
11580 Roo.data.Field.prototype = {
11588 * Ext JS Library 1.1.1
11589 * Copyright(c) 2006-2007, Ext JS, LLC.
11591 * Originally Released Under LGPL - original licence link has changed is not relivant.
11594 * <script type="text/javascript">
11597 // Base class for reading structured data from a data source. This class is intended to be
11598 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11601 * @class Roo.data.DataReader
11602 * Base class for reading structured data from a data source. This class is intended to be
11603 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11606 Roo.data.DataReader = function(meta, recordType){
11610 this.recordType = recordType instanceof Array ?
11611 Roo.data.Record.create(recordType) : recordType;
11614 Roo.data.DataReader.prototype = {
11616 * Create an empty record
11617 * @param {Object} data (optional) - overlay some values
11618 * @return {Roo.data.Record} record created.
11620 newRow : function(d) {
11622 this.recordType.prototype.fields.each(function(c) {
11624 case 'int' : da[c.name] = 0; break;
11625 case 'date' : da[c.name] = new Date(); break;
11626 case 'float' : da[c.name] = 0.0; break;
11627 case 'boolean' : da[c.name] = false; break;
11628 default : da[c.name] = ""; break;
11632 return new this.recordType(Roo.apply(da, d));
11637 * Ext JS Library 1.1.1
11638 * Copyright(c) 2006-2007, Ext JS, LLC.
11640 * Originally Released Under LGPL - original licence link has changed is not relivant.
11643 * <script type="text/javascript">
11647 * @class Roo.data.DataProxy
11648 * @extends Roo.data.Observable
11649 * This class is an abstract base class for implementations which provide retrieval of
11650 * unformatted data objects.<br>
11652 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11653 * (of the appropriate type which knows how to parse the data object) to provide a block of
11654 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11656 * Custom implementations must implement the load method as described in
11657 * {@link Roo.data.HttpProxy#load}.
11659 Roo.data.DataProxy = function(){
11662 * @event beforeload
11663 * Fires before a network request is made to retrieve a data object.
11664 * @param {Object} This DataProxy object.
11665 * @param {Object} params The params parameter to the load function.
11670 * Fires before the load method's callback is called.
11671 * @param {Object} This DataProxy object.
11672 * @param {Object} o The data object.
11673 * @param {Object} arg The callback argument object passed to the load function.
11677 * @event loadexception
11678 * Fires if an Exception occurs during data retrieval.
11679 * @param {Object} This DataProxy object.
11680 * @param {Object} o The data object.
11681 * @param {Object} arg The callback argument object passed to the load function.
11682 * @param {Object} e The Exception.
11684 loadexception : true
11686 Roo.data.DataProxy.superclass.constructor.call(this);
11689 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11692 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11696 * Ext JS Library 1.1.1
11697 * Copyright(c) 2006-2007, Ext JS, LLC.
11699 * Originally Released Under LGPL - original licence link has changed is not relivant.
11702 * <script type="text/javascript">
11705 * @class Roo.data.MemoryProxy
11706 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11707 * to the Reader when its load method is called.
11709 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11711 Roo.data.MemoryProxy = function(data){
11715 Roo.data.MemoryProxy.superclass.constructor.call(this);
11719 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11722 * Load data from the requested source (in this case an in-memory
11723 * data object passed to the constructor), read the data object into
11724 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11725 * process that block using the passed callback.
11726 * @param {Object} params This parameter is not used by the MemoryProxy class.
11727 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11728 * object into a block of Roo.data.Records.
11729 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11730 * The function must be passed <ul>
11731 * <li>The Record block object</li>
11732 * <li>The "arg" argument from the load function</li>
11733 * <li>A boolean success indicator</li>
11735 * @param {Object} scope The scope in which to call the callback
11736 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11738 load : function(params, reader, callback, scope, arg){
11739 params = params || {};
11742 result = reader.readRecords(this.data);
11744 this.fireEvent("loadexception", this, arg, null, e);
11745 callback.call(scope, null, arg, false);
11748 callback.call(scope, result, arg, true);
11752 update : function(params, records){
11757 * Ext JS Library 1.1.1
11758 * Copyright(c) 2006-2007, Ext JS, LLC.
11760 * Originally Released Under LGPL - original licence link has changed is not relivant.
11763 * <script type="text/javascript">
11766 * @class Roo.data.HttpProxy
11767 * @extends Roo.data.DataProxy
11768 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11769 * configured to reference a certain URL.<br><br>
11771 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11772 * from which the running page was served.<br><br>
11774 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11776 * Be aware that to enable the browser to parse an XML document, the server must set
11777 * the Content-Type header in the HTTP response to "text/xml".
11779 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11780 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11781 * will be used to make the request.
11783 Roo.data.HttpProxy = function(conn){
11784 Roo.data.HttpProxy.superclass.constructor.call(this);
11785 // is conn a conn config or a real conn?
11787 this.useAjax = !conn || !conn.events;
11791 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11792 // thse are take from connection...
11795 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11798 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11799 * extra parameters to each request made by this object. (defaults to undefined)
11802 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11803 * to each request made by this object. (defaults to undefined)
11806 * @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)
11809 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11812 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11818 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11822 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11823 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11824 * a finer-grained basis than the DataProxy events.
11826 getConnection : function(){
11827 return this.useAjax ? Roo.Ajax : this.conn;
11831 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11832 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11833 * process that block using the passed callback.
11834 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11835 * for the request to the remote server.
11836 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11837 * object into a block of Roo.data.Records.
11838 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11839 * The function must be passed <ul>
11840 * <li>The Record block object</li>
11841 * <li>The "arg" argument from the load function</li>
11842 * <li>A boolean success indicator</li>
11844 * @param {Object} scope The scope in which to call the callback
11845 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11847 load : function(params, reader, callback, scope, arg){
11848 if(this.fireEvent("beforeload", this, params) !== false){
11850 params : params || {},
11852 callback : callback,
11857 callback : this.loadResponse,
11861 Roo.applyIf(o, this.conn);
11862 if(this.activeRequest){
11863 Roo.Ajax.abort(this.activeRequest);
11865 this.activeRequest = Roo.Ajax.request(o);
11867 this.conn.request(o);
11870 callback.call(scope||this, null, arg, false);
11875 loadResponse : function(o, success, response){
11876 delete this.activeRequest;
11878 this.fireEvent("loadexception", this, o, response);
11879 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11884 result = o.reader.read(response);
11886 this.fireEvent("loadexception", this, o, response, e);
11887 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11891 this.fireEvent("load", this, o, o.request.arg);
11892 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11896 update : function(dataSet){
11901 updateResponse : function(dataSet){
11906 * Ext JS Library 1.1.1
11907 * Copyright(c) 2006-2007, Ext JS, LLC.
11909 * Originally Released Under LGPL - original licence link has changed is not relivant.
11912 * <script type="text/javascript">
11916 * @class Roo.data.ScriptTagProxy
11917 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11918 * other than the originating domain of the running page.<br><br>
11920 * <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
11921 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
11923 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
11924 * source code that is used as the source inside a <script> tag.<br><br>
11926 * In order for the browser to process the returned data, the server must wrap the data object
11927 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
11928 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
11929 * depending on whether the callback name was passed:
11932 boolean scriptTag = false;
11933 String cb = request.getParameter("callback");
11936 response.setContentType("text/javascript");
11938 response.setContentType("application/x-json");
11940 Writer out = response.getWriter();
11942 out.write(cb + "(");
11944 out.print(dataBlock.toJsonString());
11951 * @param {Object} config A configuration object.
11953 Roo.data.ScriptTagProxy = function(config){
11954 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
11955 Roo.apply(this, config);
11956 this.head = document.getElementsByTagName("head")[0];
11959 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
11961 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
11963 * @cfg {String} url The URL from which to request the data object.
11966 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
11970 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
11971 * the server the name of the callback function set up by the load call to process the returned data object.
11972 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
11973 * javascript output which calls this named function passing the data object as its only parameter.
11975 callbackParam : "callback",
11977 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
11978 * name to the request.
11983 * Load data from the configured URL, read the data object into
11984 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11985 * process that block using the passed callback.
11986 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11987 * for the request to the remote server.
11988 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11989 * object into a block of Roo.data.Records.
11990 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11991 * The function must be passed <ul>
11992 * <li>The Record block object</li>
11993 * <li>The "arg" argument from the load function</li>
11994 * <li>A boolean success indicator</li>
11996 * @param {Object} scope The scope in which to call the callback
11997 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11999 load : function(params, reader, callback, scope, arg){
12000 if(this.fireEvent("beforeload", this, params) !== false){
12002 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12004 var url = this.url;
12005 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12007 url += "&_dc=" + (new Date().getTime());
12009 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12012 cb : "stcCallback"+transId,
12013 scriptId : "stcScript"+transId,
12017 callback : callback,
12023 window[trans.cb] = function(o){
12024 conn.handleResponse(o, trans);
12027 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12029 if(this.autoAbort !== false){
12033 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12035 var script = document.createElement("script");
12036 script.setAttribute("src", url);
12037 script.setAttribute("type", "text/javascript");
12038 script.setAttribute("id", trans.scriptId);
12039 this.head.appendChild(script);
12041 this.trans = trans;
12043 callback.call(scope||this, null, arg, false);
12048 isLoading : function(){
12049 return this.trans ? true : false;
12053 * Abort the current server request.
12055 abort : function(){
12056 if(this.isLoading()){
12057 this.destroyTrans(this.trans);
12062 destroyTrans : function(trans, isLoaded){
12063 this.head.removeChild(document.getElementById(trans.scriptId));
12064 clearTimeout(trans.timeoutId);
12066 window[trans.cb] = undefined;
12068 delete window[trans.cb];
12071 // if hasn't been loaded, wait for load to remove it to prevent script error
12072 window[trans.cb] = function(){
12073 window[trans.cb] = undefined;
12075 delete window[trans.cb];
12082 handleResponse : function(o, trans){
12083 this.trans = false;
12084 this.destroyTrans(trans, true);
12087 result = trans.reader.readRecords(o);
12089 this.fireEvent("loadexception", this, o, trans.arg, e);
12090 trans.callback.call(trans.scope||window, null, trans.arg, false);
12093 this.fireEvent("load", this, o, trans.arg);
12094 trans.callback.call(trans.scope||window, result, trans.arg, true);
12098 handleFailure : function(trans){
12099 this.trans = false;
12100 this.destroyTrans(trans, false);
12101 this.fireEvent("loadexception", this, null, trans.arg);
12102 trans.callback.call(trans.scope||window, null, trans.arg, false);
12106 * Ext JS Library 1.1.1
12107 * Copyright(c) 2006-2007, Ext JS, LLC.
12109 * Originally Released Under LGPL - original licence link has changed is not relivant.
12112 * <script type="text/javascript">
12116 * @class Roo.data.JsonReader
12117 * @extends Roo.data.DataReader
12118 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12119 * based on mappings in a provided Roo.data.Record constructor.
12121 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12122 * in the reply previously.
12127 var RecordDef = Roo.data.Record.create([
12128 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12129 {name: 'occupation'} // This field will use "occupation" as the mapping.
12131 var myReader = new Roo.data.JsonReader({
12132 totalProperty: "results", // The property which contains the total dataset size (optional)
12133 root: "rows", // The property which contains an Array of row objects
12134 id: "id" // The property within each row object that provides an ID for the record (optional)
12138 * This would consume a JSON file like this:
12140 { 'results': 2, 'rows': [
12141 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12142 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12145 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12146 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12147 * paged from the remote server.
12148 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12149 * @cfg {String} root name of the property which contains the Array of row objects.
12150 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12151 * @cfg {Array} fields Array of field definition objects
12153 * Create a new JsonReader
12154 * @param {Object} meta Metadata configuration options
12155 * @param {Object} recordType Either an Array of field definition objects,
12156 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12158 Roo.data.JsonReader = function(meta, recordType){
12161 // set some defaults:
12162 Roo.applyIf(meta, {
12163 totalProperty: 'total',
12164 successProperty : 'success',
12169 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12171 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12174 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12175 * Used by Store query builder to append _requestMeta to params.
12178 metaFromRemote : false,
12180 * This method is only used by a DataProxy which has retrieved data from a remote server.
12181 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12182 * @return {Object} data A data block which is used by an Roo.data.Store object as
12183 * a cache of Roo.data.Records.
12185 read : function(response){
12186 var json = response.responseText;
12188 var o = /* eval:var:o */ eval("("+json+")");
12190 throw {message: "JsonReader.read: Json object not found"};
12196 this.metaFromRemote = true;
12197 this.meta = o.metaData;
12198 this.recordType = Roo.data.Record.create(o.metaData.fields);
12199 this.onMetaChange(this.meta, this.recordType, o);
12201 return this.readRecords(o);
12204 // private function a store will implement
12205 onMetaChange : function(meta, recordType, o){
12212 simpleAccess: function(obj, subsc) {
12219 getJsonAccessor: function(){
12221 return function(expr) {
12223 return(re.test(expr))
12224 ? new Function("obj", "return obj." + expr)
12229 return Roo.emptyFn;
12234 * Create a data block containing Roo.data.Records from an XML document.
12235 * @param {Object} o An object which contains an Array of row objects in the property specified
12236 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12237 * which contains the total size of the dataset.
12238 * @return {Object} data A data block which is used by an Roo.data.Store object as
12239 * a cache of Roo.data.Records.
12241 readRecords : function(o){
12243 * After any data loads, the raw JSON data is available for further custom processing.
12247 var s = this.meta, Record = this.recordType,
12248 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12250 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12252 if(s.totalProperty) {
12253 this.getTotal = this.getJsonAccessor(s.totalProperty);
12255 if(s.successProperty) {
12256 this.getSuccess = this.getJsonAccessor(s.successProperty);
12258 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12260 var g = this.getJsonAccessor(s.id);
12261 this.getId = function(rec) {
12263 return (r === undefined || r === "") ? null : r;
12266 this.getId = function(){return null;};
12269 for(var jj = 0; jj < fl; jj++){
12271 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12272 this.ef[jj] = this.getJsonAccessor(map);
12276 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12277 if(s.totalProperty){
12278 var vt = parseInt(this.getTotal(o), 10);
12283 if(s.successProperty){
12284 var vs = this.getSuccess(o);
12285 if(vs === false || vs === 'false'){
12290 for(var i = 0; i < c; i++){
12293 var id = this.getId(n);
12294 for(var j = 0; j < fl; j++){
12296 var v = this.ef[j](n);
12298 Roo.log('missing convert for ' + f.name);
12302 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12304 var record = new Record(values, id);
12306 records[i] = record;
12312 totalRecords : totalRecords
12317 * Ext JS Library 1.1.1
12318 * Copyright(c) 2006-2007, Ext JS, LLC.
12320 * Originally Released Under LGPL - original licence link has changed is not relivant.
12323 * <script type="text/javascript">
12327 * @class Roo.data.ArrayReader
12328 * @extends Roo.data.DataReader
12329 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12330 * Each element of that Array represents a row of data fields. The
12331 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12332 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12336 var RecordDef = Roo.data.Record.create([
12337 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12338 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12340 var myReader = new Roo.data.ArrayReader({
12341 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12345 * This would consume an Array like this:
12347 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12349 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12351 * Create a new JsonReader
12352 * @param {Object} meta Metadata configuration options.
12353 * @param {Object} recordType Either an Array of field definition objects
12354 * as specified to {@link Roo.data.Record#create},
12355 * or an {@link Roo.data.Record} object
12356 * created using {@link Roo.data.Record#create}.
12358 Roo.data.ArrayReader = function(meta, recordType){
12359 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12362 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12364 * Create a data block containing Roo.data.Records from an XML document.
12365 * @param {Object} o An Array of row objects which represents the dataset.
12366 * @return {Object} data A data block which is used by an Roo.data.Store object as
12367 * a cache of Roo.data.Records.
12369 readRecords : function(o){
12370 var sid = this.meta ? this.meta.id : null;
12371 var recordType = this.recordType, fields = recordType.prototype.fields;
12374 for(var i = 0; i < root.length; i++){
12377 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12378 for(var j = 0, jlen = fields.length; j < jlen; j++){
12379 var f = fields.items[j];
12380 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12381 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12383 values[f.name] = v;
12385 var record = new recordType(values, id);
12387 records[records.length] = record;
12391 totalRecords : records.length
12400 * @class Roo.bootstrap.ComboBox
12401 * @extends Roo.bootstrap.TriggerField
12402 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12403 * @cfg {Boolean} append (true|false) default false
12404 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12405 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12406 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12407 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12408 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12409 * @cfg {Boolean} animate default true
12410 * @cfg {Boolean} emptyResultText only for touch device
12411 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12412 * @cfg {String} emptyTitle default ''
12414 * Create a new ComboBox.
12415 * @param {Object} config Configuration options
12417 Roo.bootstrap.ComboBox = function(config){
12418 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12422 * Fires when the dropdown list is expanded
12423 * @param {Roo.bootstrap.ComboBox} combo This combo box
12428 * Fires when the dropdown list is collapsed
12429 * @param {Roo.bootstrap.ComboBox} combo This combo box
12433 * @event beforeselect
12434 * Fires before a list item is selected. Return false to cancel the selection.
12435 * @param {Roo.bootstrap.ComboBox} combo This combo box
12436 * @param {Roo.data.Record} record The data record returned from the underlying store
12437 * @param {Number} index The index of the selected item in the dropdown list
12439 'beforeselect' : true,
12442 * Fires when a list item is selected
12443 * @param {Roo.bootstrap.ComboBox} combo This combo box
12444 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12445 * @param {Number} index The index of the selected item in the dropdown list
12449 * @event beforequery
12450 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12451 * The event object passed has these properties:
12452 * @param {Roo.bootstrap.ComboBox} combo This combo box
12453 * @param {String} query The query
12454 * @param {Boolean} forceAll true to force "all" query
12455 * @param {Boolean} cancel true to cancel the query
12456 * @param {Object} e The query event object
12458 'beforequery': true,
12461 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12462 * @param {Roo.bootstrap.ComboBox} combo This combo box
12467 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12468 * @param {Roo.bootstrap.ComboBox} combo This combo box
12469 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12474 * Fires when the remove value from the combobox array
12475 * @param {Roo.bootstrap.ComboBox} combo This combo box
12479 * @event afterremove
12480 * Fires when the remove value from the combobox array
12481 * @param {Roo.bootstrap.ComboBox} combo This combo box
12483 'afterremove' : true,
12485 * @event specialfilter
12486 * Fires when specialfilter
12487 * @param {Roo.bootstrap.ComboBox} combo This combo box
12489 'specialfilter' : true,
12492 * Fires when tick the element
12493 * @param {Roo.bootstrap.ComboBox} combo This combo box
12497 * @event touchviewdisplay
12498 * Fires when touch view require special display (default is using displayField)
12499 * @param {Roo.bootstrap.ComboBox} combo This combo box
12500 * @param {Object} cfg set html .
12502 'touchviewdisplay' : true
12507 this.tickItems = [];
12509 this.selectedIndex = -1;
12510 if(this.mode == 'local'){
12511 if(config.queryDelay === undefined){
12512 this.queryDelay = 10;
12514 if(config.minChars === undefined){
12520 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12523 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12524 * rendering into an Roo.Editor, defaults to false)
12527 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12528 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12531 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12534 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12535 * the dropdown list (defaults to undefined, with no header element)
12539 * @cfg {String/Roo.Template} tpl The template to use to render the output
12543 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12545 listWidth: undefined,
12547 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12548 * mode = 'remote' or 'text' if mode = 'local')
12550 displayField: undefined,
12553 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12554 * mode = 'remote' or 'value' if mode = 'local').
12555 * Note: use of a valueField requires the user make a selection
12556 * in order for a value to be mapped.
12558 valueField: undefined,
12560 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12565 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12566 * field's data value (defaults to the underlying DOM element's name)
12568 hiddenName: undefined,
12570 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12574 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12576 selectedClass: 'active',
12579 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12583 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12584 * anchor positions (defaults to 'tl-bl')
12586 listAlign: 'tl-bl?',
12588 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12592 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12593 * query specified by the allQuery config option (defaults to 'query')
12595 triggerAction: 'query',
12597 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12598 * (defaults to 4, does not apply if editable = false)
12602 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12603 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12607 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12608 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12612 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12613 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12617 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12618 * when editable = true (defaults to false)
12620 selectOnFocus:false,
12622 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12624 queryParam: 'query',
12626 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12627 * when mode = 'remote' (defaults to 'Loading...')
12629 loadingText: 'Loading...',
12631 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12635 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12639 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12640 * traditional select (defaults to true)
12644 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12648 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12652 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12653 * listWidth has a higher value)
12657 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12658 * allow the user to set arbitrary text into the field (defaults to false)
12660 forceSelection:false,
12662 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12663 * if typeAhead = true (defaults to 250)
12665 typeAheadDelay : 250,
12667 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12668 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12670 valueNotFoundText : undefined,
12672 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12674 blockFocus : false,
12677 * @cfg {Boolean} disableClear Disable showing of clear button.
12679 disableClear : false,
12681 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12683 alwaysQuery : false,
12686 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12691 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12693 invalidClass : "has-warning",
12696 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12698 validClass : "has-success",
12701 * @cfg {Boolean} specialFilter (true|false) special filter default false
12703 specialFilter : false,
12706 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12708 mobileTouchView : true,
12711 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12713 useNativeIOS : false,
12715 ios_options : false,
12727 btnPosition : 'right',
12728 triggerList : true,
12729 showToggleBtn : true,
12731 emptyResultText: 'Empty',
12732 triggerText : 'Select',
12735 // element that contains real text value.. (when hidden is used..)
12737 getAutoCreate : function()
12742 * Render classic select for iso
12745 if(Roo.isIOS && this.useNativeIOS){
12746 cfg = this.getAutoCreateNativeIOS();
12754 if(Roo.isTouch && this.mobileTouchView){
12755 cfg = this.getAutoCreateTouchView();
12762 if(!this.tickable){
12763 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12768 * ComboBox with tickable selections
12771 var align = this.labelAlign || this.parentLabelAlign();
12774 cls : 'form-group roo-combobox-tickable' //input-group
12777 var btn_text_select = '';
12778 var btn_text_done = '';
12779 var btn_text_cancel = '';
12781 if (this.btn_text_show) {
12782 btn_text_select = 'Select';
12783 btn_text_done = 'Done';
12784 btn_text_cancel = 'Cancel';
12789 cls : 'tickable-buttons',
12794 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12795 //html : this.triggerText
12796 html: btn_text_select
12802 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12804 html: btn_text_done
12810 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12812 html: btn_text_cancel
12818 buttons.cn.unshift({
12820 cls: 'roo-select2-search-field-input'
12826 Roo.each(buttons.cn, function(c){
12828 c.cls += ' btn-' + _this.size;
12831 if (_this.disabled) {
12842 cls: 'form-hidden-field'
12846 cls: 'roo-select2-choices',
12850 cls: 'roo-select2-search-field',
12861 cls: 'roo-select2-container input-group roo-select2-container-multi',
12866 // cls: 'typeahead typeahead-long dropdown-menu',
12867 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12872 if(this.hasFeedback && !this.allowBlank){
12876 cls: 'glyphicon form-control-feedback'
12879 combobox.cn.push(feedback);
12883 if (align ==='left' && this.fieldLabel.length) {
12885 cfg.cls += ' roo-form-group-label-left';
12890 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12891 tooltip : 'This field is required'
12896 cls : 'control-label',
12897 html : this.fieldLabel
12909 var labelCfg = cfg.cn[1];
12910 var contentCfg = cfg.cn[2];
12913 if(this.indicatorpos == 'right'){
12919 cls : 'control-label',
12923 html : this.fieldLabel
12927 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12928 tooltip : 'This field is required'
12943 labelCfg = cfg.cn[0];
12944 contentCfg = cfg.cn[1];
12948 if(this.labelWidth > 12){
12949 labelCfg.style = "width: " + this.labelWidth + 'px';
12952 if(this.labelWidth < 13 && this.labelmd == 0){
12953 this.labelmd = this.labelWidth;
12956 if(this.labellg > 0){
12957 labelCfg.cls += ' col-lg-' + this.labellg;
12958 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12961 if(this.labelmd > 0){
12962 labelCfg.cls += ' col-md-' + this.labelmd;
12963 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12966 if(this.labelsm > 0){
12967 labelCfg.cls += ' col-sm-' + this.labelsm;
12968 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12971 if(this.labelxs > 0){
12972 labelCfg.cls += ' col-xs-' + this.labelxs;
12973 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12977 } else if ( this.fieldLabel.length) {
12978 // Roo.log(" label");
12982 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12983 tooltip : 'This field is required'
12987 //cls : 'input-group-addon',
12988 html : this.fieldLabel
12993 if(this.indicatorpos == 'right'){
12997 //cls : 'input-group-addon',
12998 html : this.fieldLabel
13002 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13003 tooltip : 'This field is required'
13012 // Roo.log(" no label && no align");
13019 ['xs','sm','md','lg'].map(function(size){
13020 if (settings[size]) {
13021 cfg.cls += ' col-' + size + '-' + settings[size];
13029 _initEventsCalled : false,
13032 initEvents: function()
13034 if (this._initEventsCalled) { // as we call render... prevent looping...
13037 this._initEventsCalled = true;
13040 throw "can not find store for combo";
13043 this.indicator = this.indicatorEl();
13045 this.store = Roo.factory(this.store, Roo.data);
13046 this.store.parent = this;
13048 // if we are building from html. then this element is so complex, that we can not really
13049 // use the rendered HTML.
13050 // so we have to trash and replace the previous code.
13051 if (Roo.XComponent.build_from_html) {
13052 // remove this element....
13053 var e = this.el.dom, k=0;
13054 while (e ) { e = e.previousSibling; ++k;}
13059 this.rendered = false;
13061 this.render(this.parent().getChildContainer(true), k);
13064 if(Roo.isIOS && this.useNativeIOS){
13065 this.initIOSView();
13073 if(Roo.isTouch && this.mobileTouchView){
13074 this.initTouchView();
13079 this.initTickableEvents();
13083 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13085 if(this.hiddenName){
13087 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13089 this.hiddenField.dom.value =
13090 this.hiddenValue !== undefined ? this.hiddenValue :
13091 this.value !== undefined ? this.value : '';
13093 // prevent input submission
13094 this.el.dom.removeAttribute('name');
13095 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13100 // this.el.dom.setAttribute('autocomplete', 'off');
13103 var cls = 'x-combo-list';
13105 //this.list = new Roo.Layer({
13106 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13112 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13113 _this.list.setWidth(lw);
13116 this.list.on('mouseover', this.onViewOver, this);
13117 this.list.on('mousemove', this.onViewMove, this);
13118 this.list.on('scroll', this.onViewScroll, this);
13121 this.list.swallowEvent('mousewheel');
13122 this.assetHeight = 0;
13125 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13126 this.assetHeight += this.header.getHeight();
13129 this.innerList = this.list.createChild({cls:cls+'-inner'});
13130 this.innerList.on('mouseover', this.onViewOver, this);
13131 this.innerList.on('mousemove', this.onViewMove, this);
13132 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13134 if(this.allowBlank && !this.pageSize && !this.disableClear){
13135 this.footer = this.list.createChild({cls:cls+'-ft'});
13136 this.pageTb = new Roo.Toolbar(this.footer);
13140 this.footer = this.list.createChild({cls:cls+'-ft'});
13141 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13142 {pageSize: this.pageSize});
13146 if (this.pageTb && this.allowBlank && !this.disableClear) {
13148 this.pageTb.add(new Roo.Toolbar.Fill(), {
13149 cls: 'x-btn-icon x-btn-clear',
13151 handler: function()
13154 _this.clearValue();
13155 _this.onSelect(false, -1);
13160 this.assetHeight += this.footer.getHeight();
13165 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13168 this.view = new Roo.View(this.list, this.tpl, {
13169 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13171 //this.view.wrapEl.setDisplayed(false);
13172 this.view.on('click', this.onViewClick, this);
13175 this.store.on('beforeload', this.onBeforeLoad, this);
13176 this.store.on('load', this.onLoad, this);
13177 this.store.on('loadexception', this.onLoadException, this);
13179 if(this.resizable){
13180 this.resizer = new Roo.Resizable(this.list, {
13181 pinned:true, handles:'se'
13183 this.resizer.on('resize', function(r, w, h){
13184 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13185 this.listWidth = w;
13186 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13187 this.restrictHeight();
13189 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13192 if(!this.editable){
13193 this.editable = true;
13194 this.setEditable(false);
13199 if (typeof(this.events.add.listeners) != 'undefined') {
13201 this.addicon = this.wrap.createChild(
13202 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13204 this.addicon.on('click', function(e) {
13205 this.fireEvent('add', this);
13208 if (typeof(this.events.edit.listeners) != 'undefined') {
13210 this.editicon = this.wrap.createChild(
13211 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13212 if (this.addicon) {
13213 this.editicon.setStyle('margin-left', '40px');
13215 this.editicon.on('click', function(e) {
13217 // we fire even if inothing is selected..
13218 this.fireEvent('edit', this, this.lastData );
13224 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13225 "up" : function(e){
13226 this.inKeyMode = true;
13230 "down" : function(e){
13231 if(!this.isExpanded()){
13232 this.onTriggerClick();
13234 this.inKeyMode = true;
13239 "enter" : function(e){
13240 // this.onViewClick();
13244 if(this.fireEvent("specialkey", this, e)){
13245 this.onViewClick(false);
13251 "esc" : function(e){
13255 "tab" : function(e){
13258 if(this.fireEvent("specialkey", this, e)){
13259 this.onViewClick(false);
13267 doRelay : function(foo, bar, hname){
13268 if(hname == 'down' || this.scope.isExpanded()){
13269 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13278 this.queryDelay = Math.max(this.queryDelay || 10,
13279 this.mode == 'local' ? 10 : 250);
13282 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13284 if(this.typeAhead){
13285 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13287 if(this.editable !== false){
13288 this.inputEl().on("keyup", this.onKeyUp, this);
13290 if(this.forceSelection){
13291 this.inputEl().on('blur', this.doForce, this);
13295 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13296 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13300 initTickableEvents: function()
13304 if(this.hiddenName){
13306 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13308 this.hiddenField.dom.value =
13309 this.hiddenValue !== undefined ? this.hiddenValue :
13310 this.value !== undefined ? this.value : '';
13312 // prevent input submission
13313 this.el.dom.removeAttribute('name');
13314 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13319 // this.list = this.el.select('ul.dropdown-menu',true).first();
13321 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13322 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13323 if(this.triggerList){
13324 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13327 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13328 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13330 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13331 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13333 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13334 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13336 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13337 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13338 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13341 this.cancelBtn.hide();
13346 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13347 _this.list.setWidth(lw);
13350 this.list.on('mouseover', this.onViewOver, this);
13351 this.list.on('mousemove', this.onViewMove, this);
13353 this.list.on('scroll', this.onViewScroll, this);
13356 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>';
13359 this.view = new Roo.View(this.list, this.tpl, {
13360 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13363 //this.view.wrapEl.setDisplayed(false);
13364 this.view.on('click', this.onViewClick, this);
13368 this.store.on('beforeload', this.onBeforeLoad, this);
13369 this.store.on('load', this.onLoad, this);
13370 this.store.on('loadexception', this.onLoadException, this);
13373 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13374 "up" : function(e){
13375 this.inKeyMode = true;
13379 "down" : function(e){
13380 this.inKeyMode = true;
13384 "enter" : function(e){
13385 if(this.fireEvent("specialkey", this, e)){
13386 this.onViewClick(false);
13392 "esc" : function(e){
13393 this.onTickableFooterButtonClick(e, false, false);
13396 "tab" : function(e){
13397 this.fireEvent("specialkey", this, e);
13399 this.onTickableFooterButtonClick(e, false, false);
13406 doRelay : function(e, fn, key){
13407 if(this.scope.isExpanded()){
13408 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13417 this.queryDelay = Math.max(this.queryDelay || 10,
13418 this.mode == 'local' ? 10 : 250);
13421 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13423 if(this.typeAhead){
13424 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13427 if(this.editable !== false){
13428 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13431 this.indicator = this.indicatorEl();
13433 if(this.indicator){
13434 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13435 this.indicator.hide();
13440 onDestroy : function(){
13442 this.view.setStore(null);
13443 this.view.el.removeAllListeners();
13444 this.view.el.remove();
13445 this.view.purgeListeners();
13448 this.list.dom.innerHTML = '';
13452 this.store.un('beforeload', this.onBeforeLoad, this);
13453 this.store.un('load', this.onLoad, this);
13454 this.store.un('loadexception', this.onLoadException, this);
13456 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13460 fireKey : function(e){
13461 if(e.isNavKeyPress() && !this.list.isVisible()){
13462 this.fireEvent("specialkey", this, e);
13467 onResize: function(w, h){
13468 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13470 // if(typeof w != 'number'){
13471 // // we do not handle it!?!?
13474 // var tw = this.trigger.getWidth();
13475 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13476 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13478 // this.inputEl().setWidth( this.adjustWidth('input', x));
13480 // //this.trigger.setStyle('left', x+'px');
13482 // if(this.list && this.listWidth === undefined){
13483 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13484 // this.list.setWidth(lw);
13485 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13493 * Allow or prevent the user from directly editing the field text. If false is passed,
13494 * the user will only be able to select from the items defined in the dropdown list. This method
13495 * is the runtime equivalent of setting the 'editable' config option at config time.
13496 * @param {Boolean} value True to allow the user to directly edit the field text
13498 setEditable : function(value){
13499 if(value == this.editable){
13502 this.editable = value;
13504 this.inputEl().dom.setAttribute('readOnly', true);
13505 this.inputEl().on('mousedown', this.onTriggerClick, this);
13506 this.inputEl().addClass('x-combo-noedit');
13508 this.inputEl().dom.setAttribute('readOnly', false);
13509 this.inputEl().un('mousedown', this.onTriggerClick, this);
13510 this.inputEl().removeClass('x-combo-noedit');
13516 onBeforeLoad : function(combo,opts){
13517 if(!this.hasFocus){
13521 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13523 this.restrictHeight();
13524 this.selectedIndex = -1;
13528 onLoad : function(){
13530 this.hasQuery = false;
13532 if(!this.hasFocus){
13536 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13537 this.loading.hide();
13540 if(this.store.getCount() > 0){
13543 this.restrictHeight();
13544 if(this.lastQuery == this.allQuery){
13545 if(this.editable && !this.tickable){
13546 this.inputEl().dom.select();
13550 !this.selectByValue(this.value, true) &&
13553 !this.store.lastOptions ||
13554 typeof(this.store.lastOptions.add) == 'undefined' ||
13555 this.store.lastOptions.add != true
13558 this.select(0, true);
13561 if(this.autoFocus){
13564 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13565 this.taTask.delay(this.typeAheadDelay);
13569 this.onEmptyResults();
13575 onLoadException : function()
13577 this.hasQuery = false;
13579 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13580 this.loading.hide();
13583 if(this.tickable && this.editable){
13588 // only causes errors at present
13589 //Roo.log(this.store.reader.jsonData);
13590 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13592 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13598 onTypeAhead : function(){
13599 if(this.store.getCount() > 0){
13600 var r = this.store.getAt(0);
13601 var newValue = r.data[this.displayField];
13602 var len = newValue.length;
13603 var selStart = this.getRawValue().length;
13605 if(selStart != len){
13606 this.setRawValue(newValue);
13607 this.selectText(selStart, newValue.length);
13613 onSelect : function(record, index){
13615 if(this.fireEvent('beforeselect', this, record, index) !== false){
13617 this.setFromData(index > -1 ? record.data : false);
13620 this.fireEvent('select', this, record, index);
13625 * Returns the currently selected field value or empty string if no value is set.
13626 * @return {String} value The selected value
13628 getValue : function()
13630 if(Roo.isIOS && this.useNativeIOS){
13631 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13635 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13638 if(this.valueField){
13639 return typeof this.value != 'undefined' ? this.value : '';
13641 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13645 getRawValue : function()
13647 if(Roo.isIOS && this.useNativeIOS){
13648 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13651 var v = this.inputEl().getValue();
13657 * Clears any text/value currently set in the field
13659 clearValue : function(){
13661 if(this.hiddenField){
13662 this.hiddenField.dom.value = '';
13665 this.setRawValue('');
13666 this.lastSelectionText = '';
13667 this.lastData = false;
13669 var close = this.closeTriggerEl();
13680 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13681 * will be displayed in the field. If the value does not match the data value of an existing item,
13682 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13683 * Otherwise the field will be blank (although the value will still be set).
13684 * @param {String} value The value to match
13686 setValue : function(v)
13688 if(Roo.isIOS && this.useNativeIOS){
13689 this.setIOSValue(v);
13699 if(this.valueField){
13700 var r = this.findRecord(this.valueField, v);
13702 text = r.data[this.displayField];
13703 }else if(this.valueNotFoundText !== undefined){
13704 text = this.valueNotFoundText;
13707 this.lastSelectionText = text;
13708 if(this.hiddenField){
13709 this.hiddenField.dom.value = v;
13711 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13714 var close = this.closeTriggerEl();
13717 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13723 * @property {Object} the last set data for the element
13728 * Sets the value of the field based on a object which is related to the record format for the store.
13729 * @param {Object} value the value to set as. or false on reset?
13731 setFromData : function(o){
13738 var dv = ''; // display value
13739 var vv = ''; // value value..
13741 if (this.displayField) {
13742 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13744 // this is an error condition!!!
13745 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13748 if(this.valueField){
13749 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13752 var close = this.closeTriggerEl();
13755 if(dv.length || vv * 1 > 0){
13757 this.blockFocus=true;
13763 if(this.hiddenField){
13764 this.hiddenField.dom.value = vv;
13766 this.lastSelectionText = dv;
13767 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13771 // no hidden field.. - we store the value in 'value', but still display
13772 // display field!!!!
13773 this.lastSelectionText = dv;
13774 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13781 reset : function(){
13782 // overridden so that last data is reset..
13789 this.setValue(this.originalValue);
13790 //this.clearInvalid();
13791 this.lastData = false;
13793 this.view.clearSelections();
13799 findRecord : function(prop, value){
13801 if(this.store.getCount() > 0){
13802 this.store.each(function(r){
13803 if(r.data[prop] == value){
13813 getName: function()
13815 // returns hidden if it's set..
13816 if (!this.rendered) {return ''};
13817 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13821 onViewMove : function(e, t){
13822 this.inKeyMode = false;
13826 onViewOver : function(e, t){
13827 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13830 var item = this.view.findItemFromChild(t);
13833 var index = this.view.indexOf(item);
13834 this.select(index, false);
13839 onViewClick : function(view, doFocus, el, e)
13841 var index = this.view.getSelectedIndexes()[0];
13843 var r = this.store.getAt(index);
13847 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13854 Roo.each(this.tickItems, function(v,k){
13856 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13858 _this.tickItems.splice(k, 1);
13860 if(typeof(e) == 'undefined' && view == false){
13861 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13873 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13874 this.tickItems.push(r.data);
13877 if(typeof(e) == 'undefined' && view == false){
13878 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13885 this.onSelect(r, index);
13887 if(doFocus !== false && !this.blockFocus){
13888 this.inputEl().focus();
13893 restrictHeight : function(){
13894 //this.innerList.dom.style.height = '';
13895 //var inner = this.innerList.dom;
13896 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13897 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13898 //this.list.beginUpdate();
13899 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13900 this.list.alignTo(this.inputEl(), this.listAlign);
13901 this.list.alignTo(this.inputEl(), this.listAlign);
13902 //this.list.endUpdate();
13906 onEmptyResults : function(){
13908 if(this.tickable && this.editable){
13909 this.restrictHeight();
13917 * Returns true if the dropdown list is expanded, else false.
13919 isExpanded : function(){
13920 return this.list.isVisible();
13924 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
13925 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13926 * @param {String} value The data value of the item to select
13927 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13928 * selected item if it is not currently in view (defaults to true)
13929 * @return {Boolean} True if the value matched an item in the list, else false
13931 selectByValue : function(v, scrollIntoView){
13932 if(v !== undefined && v !== null){
13933 var r = this.findRecord(this.valueField || this.displayField, v);
13935 this.select(this.store.indexOf(r), scrollIntoView);
13943 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
13944 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13945 * @param {Number} index The zero-based index of the list item to select
13946 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13947 * selected item if it is not currently in view (defaults to true)
13949 select : function(index, scrollIntoView){
13950 this.selectedIndex = index;
13951 this.view.select(index);
13952 if(scrollIntoView !== false){
13953 var el = this.view.getNode(index);
13955 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
13958 this.list.scrollChildIntoView(el, false);
13964 selectNext : function(){
13965 var ct = this.store.getCount();
13967 if(this.selectedIndex == -1){
13969 }else if(this.selectedIndex < ct-1){
13970 this.select(this.selectedIndex+1);
13976 selectPrev : function(){
13977 var ct = this.store.getCount();
13979 if(this.selectedIndex == -1){
13981 }else if(this.selectedIndex != 0){
13982 this.select(this.selectedIndex-1);
13988 onKeyUp : function(e){
13989 if(this.editable !== false && !e.isSpecialKey()){
13990 this.lastKey = e.getKey();
13991 this.dqTask.delay(this.queryDelay);
13996 validateBlur : function(){
13997 return !this.list || !this.list.isVisible();
14001 initQuery : function(){
14003 var v = this.getRawValue();
14005 if(this.tickable && this.editable){
14006 v = this.tickableInputEl().getValue();
14013 doForce : function(){
14014 if(this.inputEl().dom.value.length > 0){
14015 this.inputEl().dom.value =
14016 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14022 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14023 * query allowing the query action to be canceled if needed.
14024 * @param {String} query The SQL query to execute
14025 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14026 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14027 * saved in the current store (defaults to false)
14029 doQuery : function(q, forceAll){
14031 if(q === undefined || q === null){
14036 forceAll: forceAll,
14040 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14045 forceAll = qe.forceAll;
14046 if(forceAll === true || (q.length >= this.minChars)){
14048 this.hasQuery = true;
14050 if(this.lastQuery != q || this.alwaysQuery){
14051 this.lastQuery = q;
14052 if(this.mode == 'local'){
14053 this.selectedIndex = -1;
14055 this.store.clearFilter();
14058 if(this.specialFilter){
14059 this.fireEvent('specialfilter', this);
14064 this.store.filter(this.displayField, q);
14067 this.store.fireEvent("datachanged", this.store);
14074 this.store.baseParams[this.queryParam] = q;
14076 var options = {params : this.getParams(q)};
14079 options.add = true;
14080 options.params.start = this.page * this.pageSize;
14083 this.store.load(options);
14086 * this code will make the page width larger, at the beginning, the list not align correctly,
14087 * we should expand the list on onLoad
14088 * so command out it
14093 this.selectedIndex = -1;
14098 this.loadNext = false;
14102 getParams : function(q){
14104 //p[this.queryParam] = q;
14108 p.limit = this.pageSize;
14114 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14116 collapse : function(){
14117 if(!this.isExpanded()){
14123 this.hasFocus = false;
14127 this.cancelBtn.hide();
14128 this.trigger.show();
14131 this.tickableInputEl().dom.value = '';
14132 this.tickableInputEl().blur();
14137 Roo.get(document).un('mousedown', this.collapseIf, this);
14138 Roo.get(document).un('mousewheel', this.collapseIf, this);
14139 if (!this.editable) {
14140 Roo.get(document).un('keydown', this.listKeyPress, this);
14142 this.fireEvent('collapse', this);
14148 collapseIf : function(e){
14149 var in_combo = e.within(this.el);
14150 var in_list = e.within(this.list);
14151 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14153 if (in_combo || in_list || is_list) {
14154 //e.stopPropagation();
14159 this.onTickableFooterButtonClick(e, false, false);
14167 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14169 expand : function(){
14171 if(this.isExpanded() || !this.hasFocus){
14175 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14176 this.list.setWidth(lw);
14182 this.restrictHeight();
14186 this.tickItems = Roo.apply([], this.item);
14189 this.cancelBtn.show();
14190 this.trigger.hide();
14193 this.tickableInputEl().focus();
14198 Roo.get(document).on('mousedown', this.collapseIf, this);
14199 Roo.get(document).on('mousewheel', this.collapseIf, this);
14200 if (!this.editable) {
14201 Roo.get(document).on('keydown', this.listKeyPress, this);
14204 this.fireEvent('expand', this);
14208 // Implements the default empty TriggerField.onTriggerClick function
14209 onTriggerClick : function(e)
14211 Roo.log('trigger click');
14213 if(this.disabled || !this.triggerList){
14218 this.loadNext = false;
14220 if(this.isExpanded()){
14222 if (!this.blockFocus) {
14223 this.inputEl().focus();
14227 this.hasFocus = true;
14228 if(this.triggerAction == 'all') {
14229 this.doQuery(this.allQuery, true);
14231 this.doQuery(this.getRawValue());
14233 if (!this.blockFocus) {
14234 this.inputEl().focus();
14239 onTickableTriggerClick : function(e)
14246 this.loadNext = false;
14247 this.hasFocus = true;
14249 if(this.triggerAction == 'all') {
14250 this.doQuery(this.allQuery, true);
14252 this.doQuery(this.getRawValue());
14256 onSearchFieldClick : function(e)
14258 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14259 this.onTickableFooterButtonClick(e, false, false);
14263 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14268 this.loadNext = false;
14269 this.hasFocus = true;
14271 if(this.triggerAction == 'all') {
14272 this.doQuery(this.allQuery, true);
14274 this.doQuery(this.getRawValue());
14278 listKeyPress : function(e)
14280 //Roo.log('listkeypress');
14281 // scroll to first matching element based on key pres..
14282 if (e.isSpecialKey()) {
14285 var k = String.fromCharCode(e.getKey()).toUpperCase();
14288 var csel = this.view.getSelectedNodes();
14289 var cselitem = false;
14291 var ix = this.view.indexOf(csel[0]);
14292 cselitem = this.store.getAt(ix);
14293 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14299 this.store.each(function(v) {
14301 // start at existing selection.
14302 if (cselitem.id == v.id) {
14308 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14309 match = this.store.indexOf(v);
14315 if (match === false) {
14316 return true; // no more action?
14319 this.view.select(match);
14320 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14321 sn.scrollIntoView(sn.dom.parentNode, false);
14324 onViewScroll : function(e, t){
14326 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){
14330 this.hasQuery = true;
14332 this.loading = this.list.select('.loading', true).first();
14334 if(this.loading === null){
14335 this.list.createChild({
14337 cls: 'loading roo-select2-more-results roo-select2-active',
14338 html: 'Loading more results...'
14341 this.loading = this.list.select('.loading', true).first();
14343 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14345 this.loading.hide();
14348 this.loading.show();
14353 this.loadNext = true;
14355 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14360 addItem : function(o)
14362 var dv = ''; // display value
14364 if (this.displayField) {
14365 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14367 // this is an error condition!!!
14368 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14375 var choice = this.choices.createChild({
14377 cls: 'roo-select2-search-choice',
14386 cls: 'roo-select2-search-choice-close fa fa-times',
14391 }, this.searchField);
14393 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14395 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14403 this.inputEl().dom.value = '';
14408 onRemoveItem : function(e, _self, o)
14410 e.preventDefault();
14412 this.lastItem = Roo.apply([], this.item);
14414 var index = this.item.indexOf(o.data) * 1;
14417 Roo.log('not this item?!');
14421 this.item.splice(index, 1);
14426 this.fireEvent('remove', this, e);
14432 syncValue : function()
14434 if(!this.item.length){
14441 Roo.each(this.item, function(i){
14442 if(_this.valueField){
14443 value.push(i[_this.valueField]);
14450 this.value = value.join(',');
14452 if(this.hiddenField){
14453 this.hiddenField.dom.value = this.value;
14456 this.store.fireEvent("datachanged", this.store);
14461 clearItem : function()
14463 if(!this.multiple){
14469 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14477 if(this.tickable && !Roo.isTouch){
14478 this.view.refresh();
14482 inputEl: function ()
14484 if(Roo.isIOS && this.useNativeIOS){
14485 return this.el.select('select.roo-ios-select', true).first();
14488 if(Roo.isTouch && this.mobileTouchView){
14489 return this.el.select('input.form-control',true).first();
14493 return this.searchField;
14496 return this.el.select('input.form-control',true).first();
14499 onTickableFooterButtonClick : function(e, btn, el)
14501 e.preventDefault();
14503 this.lastItem = Roo.apply([], this.item);
14505 if(btn && btn.name == 'cancel'){
14506 this.tickItems = Roo.apply([], this.item);
14515 Roo.each(this.tickItems, function(o){
14523 validate : function()
14525 var v = this.getRawValue();
14528 v = this.getValue();
14531 if(this.disabled || this.allowBlank || v.length){
14536 this.markInvalid();
14540 tickableInputEl : function()
14542 if(!this.tickable || !this.editable){
14543 return this.inputEl();
14546 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14550 getAutoCreateTouchView : function()
14555 cls: 'form-group' //input-group
14561 type : this.inputType,
14562 cls : 'form-control x-combo-noedit',
14563 autocomplete: 'new-password',
14564 placeholder : this.placeholder || '',
14569 input.name = this.name;
14573 input.cls += ' input-' + this.size;
14576 if (this.disabled) {
14577 input.disabled = true;
14588 inputblock.cls += ' input-group';
14590 inputblock.cn.unshift({
14592 cls : 'input-group-addon',
14597 if(this.removable && !this.multiple){
14598 inputblock.cls += ' roo-removable';
14600 inputblock.cn.push({
14603 cls : 'roo-combo-removable-btn close'
14607 if(this.hasFeedback && !this.allowBlank){
14609 inputblock.cls += ' has-feedback';
14611 inputblock.cn.push({
14613 cls: 'glyphicon form-control-feedback'
14620 inputblock.cls += (this.before) ? '' : ' input-group';
14622 inputblock.cn.push({
14624 cls : 'input-group-addon',
14635 cls: 'form-hidden-field'
14649 cls: 'form-hidden-field'
14653 cls: 'roo-select2-choices',
14657 cls: 'roo-select2-search-field',
14670 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14676 if(!this.multiple && this.showToggleBtn){
14683 if (this.caret != false) {
14686 cls: 'fa fa-' + this.caret
14693 cls : 'input-group-addon btn dropdown-toggle',
14698 cls: 'combobox-clear',
14712 combobox.cls += ' roo-select2-container-multi';
14715 var align = this.labelAlign || this.parentLabelAlign();
14717 if (align ==='left' && this.fieldLabel.length) {
14722 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14723 tooltip : 'This field is required'
14727 cls : 'control-label',
14728 html : this.fieldLabel
14739 var labelCfg = cfg.cn[1];
14740 var contentCfg = cfg.cn[2];
14743 if(this.indicatorpos == 'right'){
14748 cls : 'control-label',
14752 html : this.fieldLabel
14756 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14757 tooltip : 'This field is required'
14770 labelCfg = cfg.cn[0];
14771 contentCfg = cfg.cn[1];
14776 if(this.labelWidth > 12){
14777 labelCfg.style = "width: " + this.labelWidth + 'px';
14780 if(this.labelWidth < 13 && this.labelmd == 0){
14781 this.labelmd = this.labelWidth;
14784 if(this.labellg > 0){
14785 labelCfg.cls += ' col-lg-' + this.labellg;
14786 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14789 if(this.labelmd > 0){
14790 labelCfg.cls += ' col-md-' + this.labelmd;
14791 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14794 if(this.labelsm > 0){
14795 labelCfg.cls += ' col-sm-' + this.labelsm;
14796 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14799 if(this.labelxs > 0){
14800 labelCfg.cls += ' col-xs-' + this.labelxs;
14801 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14805 } else if ( this.fieldLabel.length) {
14809 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14810 tooltip : 'This field is required'
14814 cls : 'control-label',
14815 html : this.fieldLabel
14826 if(this.indicatorpos == 'right'){
14830 cls : 'control-label',
14831 html : this.fieldLabel,
14835 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14836 tooltip : 'This field is required'
14853 var settings = this;
14855 ['xs','sm','md','lg'].map(function(size){
14856 if (settings[size]) {
14857 cfg.cls += ' col-' + size + '-' + settings[size];
14864 initTouchView : function()
14866 this.renderTouchView();
14868 this.touchViewEl.on('scroll', function(){
14869 this.el.dom.scrollTop = 0;
14872 this.originalValue = this.getValue();
14874 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14876 this.inputEl().on("click", this.showTouchView, this);
14877 if (this.triggerEl) {
14878 this.triggerEl.on("click", this.showTouchView, this);
14882 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14883 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14885 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14887 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14888 this.store.on('load', this.onTouchViewLoad, this);
14889 this.store.on('loadexception', this.onTouchViewLoadException, this);
14891 if(this.hiddenName){
14893 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14895 this.hiddenField.dom.value =
14896 this.hiddenValue !== undefined ? this.hiddenValue :
14897 this.value !== undefined ? this.value : '';
14899 this.el.dom.removeAttribute('name');
14900 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14904 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14905 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14908 if(this.removable && !this.multiple){
14909 var close = this.closeTriggerEl();
14911 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14912 close.on('click', this.removeBtnClick, this, close);
14916 * fix the bug in Safari iOS8
14918 this.inputEl().on("focus", function(e){
14919 document.activeElement.blur();
14927 renderTouchView : function()
14929 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
14930 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14932 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
14933 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14935 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
14936 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14937 this.touchViewBodyEl.setStyle('overflow', 'auto');
14939 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
14940 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14942 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
14943 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14947 showTouchView : function()
14953 this.touchViewHeaderEl.hide();
14955 if(this.modalTitle.length){
14956 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
14957 this.touchViewHeaderEl.show();
14960 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
14961 this.touchViewEl.show();
14963 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
14965 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
14966 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
14968 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
14970 if(this.modalTitle.length){
14971 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
14974 this.touchViewBodyEl.setHeight(bodyHeight);
14978 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
14980 this.touchViewEl.addClass('in');
14983 this.doTouchViewQuery();
14987 hideTouchView : function()
14989 this.touchViewEl.removeClass('in');
14993 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
14995 this.touchViewEl.setStyle('display', 'none');
15000 setTouchViewValue : function()
15007 Roo.each(this.tickItems, function(o){
15012 this.hideTouchView();
15015 doTouchViewQuery : function()
15024 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15028 if(!this.alwaysQuery || this.mode == 'local'){
15029 this.onTouchViewLoad();
15036 onTouchViewBeforeLoad : function(combo,opts)
15042 onTouchViewLoad : function()
15044 if(this.store.getCount() < 1){
15045 this.onTouchViewEmptyResults();
15049 this.clearTouchView();
15051 var rawValue = this.getRawValue();
15053 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15055 this.tickItems = [];
15057 this.store.data.each(function(d, rowIndex){
15058 var row = this.touchViewListGroup.createChild(template);
15060 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15061 row.addClass(d.data.cls);
15064 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15067 html : d.data[this.displayField]
15070 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15071 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15074 row.removeClass('selected');
15075 if(!this.multiple && this.valueField &&
15076 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15079 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15080 row.addClass('selected');
15083 if(this.multiple && this.valueField &&
15084 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15088 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15089 this.tickItems.push(d.data);
15092 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15096 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15098 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15100 if(this.modalTitle.length){
15101 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15104 var listHeight = this.touchViewListGroup.getHeight();
15108 if(firstChecked && listHeight > bodyHeight){
15109 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15114 onTouchViewLoadException : function()
15116 this.hideTouchView();
15119 onTouchViewEmptyResults : function()
15121 this.clearTouchView();
15123 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15125 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15129 clearTouchView : function()
15131 this.touchViewListGroup.dom.innerHTML = '';
15134 onTouchViewClick : function(e, el, o)
15136 e.preventDefault();
15139 var rowIndex = o.rowIndex;
15141 var r = this.store.getAt(rowIndex);
15143 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15145 if(!this.multiple){
15146 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15147 c.dom.removeAttribute('checked');
15150 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15152 this.setFromData(r.data);
15154 var close = this.closeTriggerEl();
15160 this.hideTouchView();
15162 this.fireEvent('select', this, r, rowIndex);
15167 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15168 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15169 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15173 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15174 this.addItem(r.data);
15175 this.tickItems.push(r.data);
15179 getAutoCreateNativeIOS : function()
15182 cls: 'form-group' //input-group,
15187 cls : 'roo-ios-select'
15191 combobox.name = this.name;
15194 if (this.disabled) {
15195 combobox.disabled = true;
15198 var settings = this;
15200 ['xs','sm','md','lg'].map(function(size){
15201 if (settings[size]) {
15202 cfg.cls += ' col-' + size + '-' + settings[size];
15212 initIOSView : function()
15214 this.store.on('load', this.onIOSViewLoad, this);
15219 onIOSViewLoad : function()
15221 if(this.store.getCount() < 1){
15225 this.clearIOSView();
15227 if(this.allowBlank) {
15229 var default_text = '-- SELECT --';
15231 var opt = this.inputEl().createChild({
15234 html : default_text
15238 o[this.valueField] = 0;
15239 o[this.displayField] = default_text;
15241 this.ios_options.push({
15248 this.store.data.each(function(d, rowIndex){
15252 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15253 html = d.data[this.displayField];
15258 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15259 value = d.data[this.valueField];
15268 if(this.value == d.data[this.valueField]){
15269 option['selected'] = true;
15272 var opt = this.inputEl().createChild(option);
15274 this.ios_options.push({
15281 this.inputEl().on('change', function(){
15282 this.fireEvent('select', this);
15287 clearIOSView: function()
15289 this.inputEl().dom.innerHTML = '';
15291 this.ios_options = [];
15294 setIOSValue: function(v)
15298 if(!this.ios_options){
15302 Roo.each(this.ios_options, function(opts){
15304 opts.el.dom.removeAttribute('selected');
15306 if(opts.data[this.valueField] != v){
15310 opts.el.dom.setAttribute('selected', true);
15316 * @cfg {Boolean} grow
15320 * @cfg {Number} growMin
15324 * @cfg {Number} growMax
15333 Roo.apply(Roo.bootstrap.ComboBox, {
15337 cls: 'modal-header',
15359 cls: 'list-group-item',
15363 cls: 'roo-combobox-list-group-item-value'
15367 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15381 listItemCheckbox : {
15383 cls: 'list-group-item',
15387 cls: 'roo-combobox-list-group-item-value'
15391 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15407 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15412 cls: 'modal-footer',
15420 cls: 'col-xs-6 text-left',
15423 cls: 'btn btn-danger roo-touch-view-cancel',
15429 cls: 'col-xs-6 text-right',
15432 cls: 'btn btn-success roo-touch-view-ok',
15443 Roo.apply(Roo.bootstrap.ComboBox, {
15445 touchViewTemplate : {
15447 cls: 'modal fade roo-combobox-touch-view',
15451 cls: 'modal-dialog',
15452 style : 'position:fixed', // we have to fix position....
15456 cls: 'modal-content',
15458 Roo.bootstrap.ComboBox.header,
15459 Roo.bootstrap.ComboBox.body,
15460 Roo.bootstrap.ComboBox.footer
15469 * Ext JS Library 1.1.1
15470 * Copyright(c) 2006-2007, Ext JS, LLC.
15472 * Originally Released Under LGPL - original licence link has changed is not relivant.
15475 * <script type="text/javascript">
15480 * @extends Roo.util.Observable
15481 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15482 * This class also supports single and multi selection modes. <br>
15483 * Create a data model bound view:
15485 var store = new Roo.data.Store(...);
15487 var view = new Roo.View({
15489 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15491 singleSelect: true,
15492 selectedClass: "ydataview-selected",
15496 // listen for node click?
15497 view.on("click", function(vw, index, node, e){
15498 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15502 dataModel.load("foobar.xml");
15504 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15506 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15507 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15509 * Note: old style constructor is still suported (container, template, config)
15512 * Create a new View
15513 * @param {Object} config The config object
15516 Roo.View = function(config, depreciated_tpl, depreciated_config){
15518 this.parent = false;
15520 if (typeof(depreciated_tpl) == 'undefined') {
15521 // new way.. - universal constructor.
15522 Roo.apply(this, config);
15523 this.el = Roo.get(this.el);
15526 this.el = Roo.get(config);
15527 this.tpl = depreciated_tpl;
15528 Roo.apply(this, depreciated_config);
15530 this.wrapEl = this.el.wrap().wrap();
15531 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15534 if(typeof(this.tpl) == "string"){
15535 this.tpl = new Roo.Template(this.tpl);
15537 // support xtype ctors..
15538 this.tpl = new Roo.factory(this.tpl, Roo);
15542 this.tpl.compile();
15547 * @event beforeclick
15548 * Fires before a click is processed. Returns false to cancel the default action.
15549 * @param {Roo.View} this
15550 * @param {Number} index The index of the target node
15551 * @param {HTMLElement} node The target node
15552 * @param {Roo.EventObject} e The raw event object
15554 "beforeclick" : true,
15557 * Fires when a template node is clicked.
15558 * @param {Roo.View} this
15559 * @param {Number} index The index of the target node
15560 * @param {HTMLElement} node The target node
15561 * @param {Roo.EventObject} e The raw event object
15566 * Fires when a template node is double clicked.
15567 * @param {Roo.View} this
15568 * @param {Number} index The index of the target node
15569 * @param {HTMLElement} node The target node
15570 * @param {Roo.EventObject} e The raw event object
15574 * @event contextmenu
15575 * Fires when a template node is right clicked.
15576 * @param {Roo.View} this
15577 * @param {Number} index The index of the target node
15578 * @param {HTMLElement} node The target node
15579 * @param {Roo.EventObject} e The raw event object
15581 "contextmenu" : true,
15583 * @event selectionchange
15584 * Fires when the selected nodes change.
15585 * @param {Roo.View} this
15586 * @param {Array} selections Array of the selected nodes
15588 "selectionchange" : true,
15591 * @event beforeselect
15592 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15593 * @param {Roo.View} this
15594 * @param {HTMLElement} node The node to be selected
15595 * @param {Array} selections Array of currently selected nodes
15597 "beforeselect" : true,
15599 * @event preparedata
15600 * Fires on every row to render, to allow you to change the data.
15601 * @param {Roo.View} this
15602 * @param {Object} data to be rendered (change this)
15604 "preparedata" : true
15612 "click": this.onClick,
15613 "dblclick": this.onDblClick,
15614 "contextmenu": this.onContextMenu,
15618 this.selections = [];
15620 this.cmp = new Roo.CompositeElementLite([]);
15622 this.store = Roo.factory(this.store, Roo.data);
15623 this.setStore(this.store, true);
15626 if ( this.footer && this.footer.xtype) {
15628 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15630 this.footer.dataSource = this.store;
15631 this.footer.container = fctr;
15632 this.footer = Roo.factory(this.footer, Roo);
15633 fctr.insertFirst(this.el);
15635 // this is a bit insane - as the paging toolbar seems to detach the el..
15636 // dom.parentNode.parentNode.parentNode
15637 // they get detached?
15641 Roo.View.superclass.constructor.call(this);
15646 Roo.extend(Roo.View, Roo.util.Observable, {
15649 * @cfg {Roo.data.Store} store Data store to load data from.
15654 * @cfg {String|Roo.Element} el The container element.
15659 * @cfg {String|Roo.Template} tpl The template used by this View
15663 * @cfg {String} dataName the named area of the template to use as the data area
15664 * Works with domtemplates roo-name="name"
15668 * @cfg {String} selectedClass The css class to add to selected nodes
15670 selectedClass : "x-view-selected",
15672 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15677 * @cfg {String} text to display on mask (default Loading)
15681 * @cfg {Boolean} multiSelect Allow multiple selection
15683 multiSelect : false,
15685 * @cfg {Boolean} singleSelect Allow single selection
15687 singleSelect: false,
15690 * @cfg {Boolean} toggleSelect - selecting
15692 toggleSelect : false,
15695 * @cfg {Boolean} tickable - selecting
15700 * Returns the element this view is bound to.
15701 * @return {Roo.Element}
15703 getEl : function(){
15704 return this.wrapEl;
15710 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15712 refresh : function(){
15713 //Roo.log('refresh');
15716 // if we are using something like 'domtemplate', then
15717 // the what gets used is:
15718 // t.applySubtemplate(NAME, data, wrapping data..)
15719 // the outer template then get' applied with
15720 // the store 'extra data'
15721 // and the body get's added to the
15722 // roo-name="data" node?
15723 // <span class='roo-tpl-{name}'></span> ?????
15727 this.clearSelections();
15728 this.el.update("");
15730 var records = this.store.getRange();
15731 if(records.length < 1) {
15733 // is this valid?? = should it render a template??
15735 this.el.update(this.emptyText);
15739 if (this.dataName) {
15740 this.el.update(t.apply(this.store.meta)); //????
15741 el = this.el.child('.roo-tpl-' + this.dataName);
15744 for(var i = 0, len = records.length; i < len; i++){
15745 var data = this.prepareData(records[i].data, i, records[i]);
15746 this.fireEvent("preparedata", this, data, i, records[i]);
15748 var d = Roo.apply({}, data);
15751 Roo.apply(d, {'roo-id' : Roo.id()});
15755 Roo.each(this.parent.item, function(item){
15756 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15759 Roo.apply(d, {'roo-data-checked' : 'checked'});
15763 html[html.length] = Roo.util.Format.trim(
15765 t.applySubtemplate(this.dataName, d, this.store.meta) :
15772 el.update(html.join(""));
15773 this.nodes = el.dom.childNodes;
15774 this.updateIndexes(0);
15779 * Function to override to reformat the data that is sent to
15780 * the template for each node.
15781 * DEPRICATED - use the preparedata event handler.
15782 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15783 * a JSON object for an UpdateManager bound view).
15785 prepareData : function(data, index, record)
15787 this.fireEvent("preparedata", this, data, index, record);
15791 onUpdate : function(ds, record){
15792 // Roo.log('on update');
15793 this.clearSelections();
15794 var index = this.store.indexOf(record);
15795 var n = this.nodes[index];
15796 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15797 n.parentNode.removeChild(n);
15798 this.updateIndexes(index, index);
15804 onAdd : function(ds, records, index)
15806 //Roo.log(['on Add', ds, records, index] );
15807 this.clearSelections();
15808 if(this.nodes.length == 0){
15812 var n = this.nodes[index];
15813 for(var i = 0, len = records.length; i < len; i++){
15814 var d = this.prepareData(records[i].data, i, records[i]);
15816 this.tpl.insertBefore(n, d);
15819 this.tpl.append(this.el, d);
15822 this.updateIndexes(index);
15825 onRemove : function(ds, record, index){
15826 // Roo.log('onRemove');
15827 this.clearSelections();
15828 var el = this.dataName ?
15829 this.el.child('.roo-tpl-' + this.dataName) :
15832 el.dom.removeChild(this.nodes[index]);
15833 this.updateIndexes(index);
15837 * Refresh an individual node.
15838 * @param {Number} index
15840 refreshNode : function(index){
15841 this.onUpdate(this.store, this.store.getAt(index));
15844 updateIndexes : function(startIndex, endIndex){
15845 var ns = this.nodes;
15846 startIndex = startIndex || 0;
15847 endIndex = endIndex || ns.length - 1;
15848 for(var i = startIndex; i <= endIndex; i++){
15849 ns[i].nodeIndex = i;
15854 * Changes the data store this view uses and refresh the view.
15855 * @param {Store} store
15857 setStore : function(store, initial){
15858 if(!initial && this.store){
15859 this.store.un("datachanged", this.refresh);
15860 this.store.un("add", this.onAdd);
15861 this.store.un("remove", this.onRemove);
15862 this.store.un("update", this.onUpdate);
15863 this.store.un("clear", this.refresh);
15864 this.store.un("beforeload", this.onBeforeLoad);
15865 this.store.un("load", this.onLoad);
15866 this.store.un("loadexception", this.onLoad);
15870 store.on("datachanged", this.refresh, this);
15871 store.on("add", this.onAdd, this);
15872 store.on("remove", this.onRemove, this);
15873 store.on("update", this.onUpdate, this);
15874 store.on("clear", this.refresh, this);
15875 store.on("beforeload", this.onBeforeLoad, this);
15876 store.on("load", this.onLoad, this);
15877 store.on("loadexception", this.onLoad, this);
15885 * onbeforeLoad - masks the loading area.
15888 onBeforeLoad : function(store,opts)
15890 //Roo.log('onBeforeLoad');
15892 this.el.update("");
15894 this.el.mask(this.mask ? this.mask : "Loading" );
15896 onLoad : function ()
15903 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15904 * @param {HTMLElement} node
15905 * @return {HTMLElement} The template node
15907 findItemFromChild : function(node){
15908 var el = this.dataName ?
15909 this.el.child('.roo-tpl-' + this.dataName,true) :
15912 if(!node || node.parentNode == el){
15915 var p = node.parentNode;
15916 while(p && p != el){
15917 if(p.parentNode == el){
15926 onClick : function(e){
15927 var item = this.findItemFromChild(e.getTarget());
15929 var index = this.indexOf(item);
15930 if(this.onItemClick(item, index, e) !== false){
15931 this.fireEvent("click", this, index, item, e);
15934 this.clearSelections();
15939 onContextMenu : function(e){
15940 var item = this.findItemFromChild(e.getTarget());
15942 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
15947 onDblClick : function(e){
15948 var item = this.findItemFromChild(e.getTarget());
15950 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
15954 onItemClick : function(item, index, e)
15956 if(this.fireEvent("beforeclick", this, index, item, e) === false){
15959 if (this.toggleSelect) {
15960 var m = this.isSelected(item) ? 'unselect' : 'select';
15963 _t[m](item, true, false);
15966 if(this.multiSelect || this.singleSelect){
15967 if(this.multiSelect && e.shiftKey && this.lastSelection){
15968 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
15970 this.select(item, this.multiSelect && e.ctrlKey);
15971 this.lastSelection = item;
15974 if(!this.tickable){
15975 e.preventDefault();
15983 * Get the number of selected nodes.
15986 getSelectionCount : function(){
15987 return this.selections.length;
15991 * Get the currently selected nodes.
15992 * @return {Array} An array of HTMLElements
15994 getSelectedNodes : function(){
15995 return this.selections;
15999 * Get the indexes of the selected nodes.
16002 getSelectedIndexes : function(){
16003 var indexes = [], s = this.selections;
16004 for(var i = 0, len = s.length; i < len; i++){
16005 indexes.push(s[i].nodeIndex);
16011 * Clear all selections
16012 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16014 clearSelections : function(suppressEvent){
16015 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16016 this.cmp.elements = this.selections;
16017 this.cmp.removeClass(this.selectedClass);
16018 this.selections = [];
16019 if(!suppressEvent){
16020 this.fireEvent("selectionchange", this, this.selections);
16026 * Returns true if the passed node is selected
16027 * @param {HTMLElement/Number} node The node or node index
16028 * @return {Boolean}
16030 isSelected : function(node){
16031 var s = this.selections;
16035 node = this.getNode(node);
16036 return s.indexOf(node) !== -1;
16041 * @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
16042 * @param {Boolean} keepExisting (optional) true to keep existing selections
16043 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16045 select : function(nodeInfo, keepExisting, suppressEvent){
16046 if(nodeInfo instanceof Array){
16048 this.clearSelections(true);
16050 for(var i = 0, len = nodeInfo.length; i < len; i++){
16051 this.select(nodeInfo[i], true, true);
16055 var node = this.getNode(nodeInfo);
16056 if(!node || this.isSelected(node)){
16057 return; // already selected.
16060 this.clearSelections(true);
16063 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16064 Roo.fly(node).addClass(this.selectedClass);
16065 this.selections.push(node);
16066 if(!suppressEvent){
16067 this.fireEvent("selectionchange", this, this.selections);
16075 * @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
16076 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16077 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16079 unselect : function(nodeInfo, keepExisting, suppressEvent)
16081 if(nodeInfo instanceof Array){
16082 Roo.each(this.selections, function(s) {
16083 this.unselect(s, nodeInfo);
16087 var node = this.getNode(nodeInfo);
16088 if(!node || !this.isSelected(node)){
16089 //Roo.log("not selected");
16090 return; // not selected.
16094 Roo.each(this.selections, function(s) {
16096 Roo.fly(node).removeClass(this.selectedClass);
16103 this.selections= ns;
16104 this.fireEvent("selectionchange", this, this.selections);
16108 * Gets a template node.
16109 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16110 * @return {HTMLElement} The node or null if it wasn't found
16112 getNode : function(nodeInfo){
16113 if(typeof nodeInfo == "string"){
16114 return document.getElementById(nodeInfo);
16115 }else if(typeof nodeInfo == "number"){
16116 return this.nodes[nodeInfo];
16122 * Gets a range template nodes.
16123 * @param {Number} startIndex
16124 * @param {Number} endIndex
16125 * @return {Array} An array of nodes
16127 getNodes : function(start, end){
16128 var ns = this.nodes;
16129 start = start || 0;
16130 end = typeof end == "undefined" ? ns.length - 1 : end;
16133 for(var i = start; i <= end; i++){
16137 for(var i = start; i >= end; i--){
16145 * Finds the index of the passed node
16146 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16147 * @return {Number} The index of the node or -1
16149 indexOf : function(node){
16150 node = this.getNode(node);
16151 if(typeof node.nodeIndex == "number"){
16152 return node.nodeIndex;
16154 var ns = this.nodes;
16155 for(var i = 0, len = ns.length; i < len; i++){
16166 * based on jquery fullcalendar
16170 Roo.bootstrap = Roo.bootstrap || {};
16172 * @class Roo.bootstrap.Calendar
16173 * @extends Roo.bootstrap.Component
16174 * Bootstrap Calendar class
16175 * @cfg {Boolean} loadMask (true|false) default false
16176 * @cfg {Object} header generate the user specific header of the calendar, default false
16179 * Create a new Container
16180 * @param {Object} config The config object
16185 Roo.bootstrap.Calendar = function(config){
16186 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16190 * Fires when a date is selected
16191 * @param {DatePicker} this
16192 * @param {Date} date The selected date
16196 * @event monthchange
16197 * Fires when the displayed month changes
16198 * @param {DatePicker} this
16199 * @param {Date} date The selected month
16201 'monthchange': true,
16203 * @event evententer
16204 * Fires when mouse over an event
16205 * @param {Calendar} this
16206 * @param {event} Event
16208 'evententer': true,
16210 * @event eventleave
16211 * Fires when the mouse leaves an
16212 * @param {Calendar} this
16215 'eventleave': true,
16217 * @event eventclick
16218 * Fires when the mouse click an
16219 * @param {Calendar} this
16228 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16231 * @cfg {Number} startDay
16232 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16240 getAutoCreate : function(){
16243 var fc_button = function(name, corner, style, content ) {
16244 return Roo.apply({},{
16246 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16248 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16251 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16262 style : 'width:100%',
16269 cls : 'fc-header-left',
16271 fc_button('prev', 'left', 'arrow', '‹' ),
16272 fc_button('next', 'right', 'arrow', '›' ),
16273 { tag: 'span', cls: 'fc-header-space' },
16274 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16282 cls : 'fc-header-center',
16286 cls: 'fc-header-title',
16289 html : 'month / year'
16297 cls : 'fc-header-right',
16299 /* fc_button('month', 'left', '', 'month' ),
16300 fc_button('week', '', '', 'week' ),
16301 fc_button('day', 'right', '', 'day' )
16313 header = this.header;
16316 var cal_heads = function() {
16318 // fixme - handle this.
16320 for (var i =0; i < Date.dayNames.length; i++) {
16321 var d = Date.dayNames[i];
16324 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16325 html : d.substring(0,3)
16329 ret[0].cls += ' fc-first';
16330 ret[6].cls += ' fc-last';
16333 var cal_cell = function(n) {
16336 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16341 cls: 'fc-day-number',
16345 cls: 'fc-day-content',
16349 style: 'position: relative;' // height: 17px;
16361 var cal_rows = function() {
16364 for (var r = 0; r < 6; r++) {
16371 for (var i =0; i < Date.dayNames.length; i++) {
16372 var d = Date.dayNames[i];
16373 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16376 row.cn[0].cls+=' fc-first';
16377 row.cn[0].cn[0].style = 'min-height:90px';
16378 row.cn[6].cls+=' fc-last';
16382 ret[0].cls += ' fc-first';
16383 ret[4].cls += ' fc-prev-last';
16384 ret[5].cls += ' fc-last';
16391 cls: 'fc-border-separate',
16392 style : 'width:100%',
16400 cls : 'fc-first fc-last',
16418 cls : 'fc-content',
16419 style : "position: relative;",
16422 cls : 'fc-view fc-view-month fc-grid',
16423 style : 'position: relative',
16424 unselectable : 'on',
16427 cls : 'fc-event-container',
16428 style : 'position:absolute;z-index:8;top:0;left:0;'
16446 initEvents : function()
16449 throw "can not find store for calendar";
16455 style: "text-align:center",
16459 style: "background-color:white;width:50%;margin:250 auto",
16463 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16474 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16476 var size = this.el.select('.fc-content', true).first().getSize();
16477 this.maskEl.setSize(size.width, size.height);
16478 this.maskEl.enableDisplayMode("block");
16479 if(!this.loadMask){
16480 this.maskEl.hide();
16483 this.store = Roo.factory(this.store, Roo.data);
16484 this.store.on('load', this.onLoad, this);
16485 this.store.on('beforeload', this.onBeforeLoad, this);
16489 this.cells = this.el.select('.fc-day',true);
16490 //Roo.log(this.cells);
16491 this.textNodes = this.el.query('.fc-day-number');
16492 this.cells.addClassOnOver('fc-state-hover');
16494 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16495 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16496 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16497 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16499 this.on('monthchange', this.onMonthChange, this);
16501 this.update(new Date().clearTime());
16504 resize : function() {
16505 var sz = this.el.getSize();
16507 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16508 this.el.select('.fc-day-content div',true).setHeight(34);
16513 showPrevMonth : function(e){
16514 this.update(this.activeDate.add("mo", -1));
16516 showToday : function(e){
16517 this.update(new Date().clearTime());
16520 showNextMonth : function(e){
16521 this.update(this.activeDate.add("mo", 1));
16525 showPrevYear : function(){
16526 this.update(this.activeDate.add("y", -1));
16530 showNextYear : function(){
16531 this.update(this.activeDate.add("y", 1));
16536 update : function(date)
16538 var vd = this.activeDate;
16539 this.activeDate = date;
16540 // if(vd && this.el){
16541 // var t = date.getTime();
16542 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16543 // Roo.log('using add remove');
16545 // this.fireEvent('monthchange', this, date);
16547 // this.cells.removeClass("fc-state-highlight");
16548 // this.cells.each(function(c){
16549 // if(c.dateValue == t){
16550 // c.addClass("fc-state-highlight");
16551 // setTimeout(function(){
16552 // try{c.dom.firstChild.focus();}catch(e){}
16562 var days = date.getDaysInMonth();
16564 var firstOfMonth = date.getFirstDateOfMonth();
16565 var startingPos = firstOfMonth.getDay()-this.startDay;
16567 if(startingPos < this.startDay){
16571 var pm = date.add(Date.MONTH, -1);
16572 var prevStart = pm.getDaysInMonth()-startingPos;
16574 this.cells = this.el.select('.fc-day',true);
16575 this.textNodes = this.el.query('.fc-day-number');
16576 this.cells.addClassOnOver('fc-state-hover');
16578 var cells = this.cells.elements;
16579 var textEls = this.textNodes;
16581 Roo.each(cells, function(cell){
16582 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16585 days += startingPos;
16587 // convert everything to numbers so it's fast
16588 var day = 86400000;
16589 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16592 //Roo.log(prevStart);
16594 var today = new Date().clearTime().getTime();
16595 var sel = date.clearTime().getTime();
16596 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16597 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16598 var ddMatch = this.disabledDatesRE;
16599 var ddText = this.disabledDatesText;
16600 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16601 var ddaysText = this.disabledDaysText;
16602 var format = this.format;
16604 var setCellClass = function(cal, cell){
16608 //Roo.log('set Cell Class');
16610 var t = d.getTime();
16614 cell.dateValue = t;
16616 cell.className += " fc-today";
16617 cell.className += " fc-state-highlight";
16618 cell.title = cal.todayText;
16621 // disable highlight in other month..
16622 //cell.className += " fc-state-highlight";
16627 cell.className = " fc-state-disabled";
16628 cell.title = cal.minText;
16632 cell.className = " fc-state-disabled";
16633 cell.title = cal.maxText;
16637 if(ddays.indexOf(d.getDay()) != -1){
16638 cell.title = ddaysText;
16639 cell.className = " fc-state-disabled";
16642 if(ddMatch && format){
16643 var fvalue = d.dateFormat(format);
16644 if(ddMatch.test(fvalue)){
16645 cell.title = ddText.replace("%0", fvalue);
16646 cell.className = " fc-state-disabled";
16650 if (!cell.initialClassName) {
16651 cell.initialClassName = cell.dom.className;
16654 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16659 for(; i < startingPos; i++) {
16660 textEls[i].innerHTML = (++prevStart);
16661 d.setDate(d.getDate()+1);
16663 cells[i].className = "fc-past fc-other-month";
16664 setCellClass(this, cells[i]);
16669 for(; i < days; i++){
16670 intDay = i - startingPos + 1;
16671 textEls[i].innerHTML = (intDay);
16672 d.setDate(d.getDate()+1);
16674 cells[i].className = ''; // "x-date-active";
16675 setCellClass(this, cells[i]);
16679 for(; i < 42; i++) {
16680 textEls[i].innerHTML = (++extraDays);
16681 d.setDate(d.getDate()+1);
16683 cells[i].className = "fc-future fc-other-month";
16684 setCellClass(this, cells[i]);
16687 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16689 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16691 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16692 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16694 if(totalRows != 6){
16695 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16696 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16699 this.fireEvent('monthchange', this, date);
16703 if(!this.internalRender){
16704 var main = this.el.dom.firstChild;
16705 var w = main.offsetWidth;
16706 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16707 Roo.fly(main).setWidth(w);
16708 this.internalRender = true;
16709 // opera does not respect the auto grow header center column
16710 // then, after it gets a width opera refuses to recalculate
16711 // without a second pass
16712 if(Roo.isOpera && !this.secondPass){
16713 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16714 this.secondPass = true;
16715 this.update.defer(10, this, [date]);
16722 findCell : function(dt) {
16723 dt = dt.clearTime().getTime();
16725 this.cells.each(function(c){
16726 //Roo.log("check " +c.dateValue + '?=' + dt);
16727 if(c.dateValue == dt){
16737 findCells : function(ev) {
16738 var s = ev.start.clone().clearTime().getTime();
16740 var e= ev.end.clone().clearTime().getTime();
16743 this.cells.each(function(c){
16744 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16746 if(c.dateValue > e){
16749 if(c.dateValue < s){
16758 // findBestRow: function(cells)
16762 // for (var i =0 ; i < cells.length;i++) {
16763 // ret = Math.max(cells[i].rows || 0,ret);
16770 addItem : function(ev)
16772 // look for vertical location slot in
16773 var cells = this.findCells(ev);
16775 // ev.row = this.findBestRow(cells);
16777 // work out the location.
16781 for(var i =0; i < cells.length; i++) {
16783 cells[i].row = cells[0].row;
16786 cells[i].row = cells[i].row + 1;
16796 if (crow.start.getY() == cells[i].getY()) {
16798 crow.end = cells[i];
16815 cells[0].events.push(ev);
16817 this.calevents.push(ev);
16820 clearEvents: function() {
16822 if(!this.calevents){
16826 Roo.each(this.cells.elements, function(c){
16832 Roo.each(this.calevents, function(e) {
16833 Roo.each(e.els, function(el) {
16834 el.un('mouseenter' ,this.onEventEnter, this);
16835 el.un('mouseleave' ,this.onEventLeave, this);
16840 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16846 renderEvents: function()
16850 this.cells.each(function(c) {
16859 if(c.row != c.events.length){
16860 r = 4 - (4 - (c.row - c.events.length));
16863 c.events = ev.slice(0, r);
16864 c.more = ev.slice(r);
16866 if(c.more.length && c.more.length == 1){
16867 c.events.push(c.more.pop());
16870 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16874 this.cells.each(function(c) {
16876 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16879 for (var e = 0; e < c.events.length; e++){
16880 var ev = c.events[e];
16881 var rows = ev.rows;
16883 for(var i = 0; i < rows.length; i++) {
16885 // how many rows should it span..
16888 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16889 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16891 unselectable : "on",
16894 cls: 'fc-event-inner',
16898 // cls: 'fc-event-time',
16899 // html : cells.length > 1 ? '' : ev.time
16903 cls: 'fc-event-title',
16904 html : String.format('{0}', ev.title)
16911 cls: 'ui-resizable-handle ui-resizable-e',
16912 html : '  '
16919 cfg.cls += ' fc-event-start';
16921 if ((i+1) == rows.length) {
16922 cfg.cls += ' fc-event-end';
16925 var ctr = _this.el.select('.fc-event-container',true).first();
16926 var cg = ctr.createChild(cfg);
16928 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
16929 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
16931 var r = (c.more.length) ? 1 : 0;
16932 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
16933 cg.setWidth(ebox.right - sbox.x -2);
16935 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
16936 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
16937 cg.on('click', _this.onEventClick, _this, ev);
16948 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
16949 style : 'position: absolute',
16950 unselectable : "on",
16953 cls: 'fc-event-inner',
16957 cls: 'fc-event-title',
16965 cls: 'ui-resizable-handle ui-resizable-e',
16966 html : '  '
16972 var ctr = _this.el.select('.fc-event-container',true).first();
16973 var cg = ctr.createChild(cfg);
16975 var sbox = c.select('.fc-day-content',true).first().getBox();
16976 var ebox = c.select('.fc-day-content',true).first().getBox();
16978 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
16979 cg.setWidth(ebox.right - sbox.x -2);
16981 cg.on('click', _this.onMoreEventClick, _this, c.more);
16991 onEventEnter: function (e, el,event,d) {
16992 this.fireEvent('evententer', this, el, event);
16995 onEventLeave: function (e, el,event,d) {
16996 this.fireEvent('eventleave', this, el, event);
16999 onEventClick: function (e, el,event,d) {
17000 this.fireEvent('eventclick', this, el, event);
17003 onMonthChange: function () {
17007 onMoreEventClick: function(e, el, more)
17011 this.calpopover.placement = 'right';
17012 this.calpopover.setTitle('More');
17014 this.calpopover.setContent('');
17016 var ctr = this.calpopover.el.select('.popover-content', true).first();
17018 Roo.each(more, function(m){
17020 cls : 'fc-event-hori fc-event-draggable',
17023 var cg = ctr.createChild(cfg);
17025 cg.on('click', _this.onEventClick, _this, m);
17028 this.calpopover.show(el);
17033 onLoad: function ()
17035 this.calevents = [];
17038 if(this.store.getCount() > 0){
17039 this.store.data.each(function(d){
17042 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17043 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17044 time : d.data.start_time,
17045 title : d.data.title,
17046 description : d.data.description,
17047 venue : d.data.venue
17052 this.renderEvents();
17054 if(this.calevents.length && this.loadMask){
17055 this.maskEl.hide();
17059 onBeforeLoad: function()
17061 this.clearEvents();
17063 this.maskEl.show();
17077 * @class Roo.bootstrap.Popover
17078 * @extends Roo.bootstrap.Component
17079 * Bootstrap Popover class
17080 * @cfg {String} html contents of the popover (or false to use children..)
17081 * @cfg {String} title of popover (or false to hide)
17082 * @cfg {String} placement how it is placed
17083 * @cfg {String} trigger click || hover (or false to trigger manually)
17084 * @cfg {String} over what (parent or false to trigger manually.)
17085 * @cfg {Number} delay - delay before showing
17088 * Create a new Popover
17089 * @param {Object} config The config object
17092 Roo.bootstrap.Popover = function(config){
17093 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17099 * After the popover show
17101 * @param {Roo.bootstrap.Popover} this
17106 * After the popover hide
17108 * @param {Roo.bootstrap.Popover} this
17114 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17116 title: 'Fill in a title',
17119 placement : 'right',
17120 trigger : 'hover', // hover
17126 can_build_overlaid : false,
17128 getChildContainer : function()
17130 return this.el.select('.popover-content',true).first();
17133 getAutoCreate : function(){
17136 cls : 'popover roo-dynamic',
17137 style: 'display:block',
17143 cls : 'popover-inner',
17147 cls: 'popover-title',
17151 cls : 'popover-content',
17162 setTitle: function(str)
17165 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17167 setContent: function(str)
17170 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17172 // as it get's added to the bottom of the page.
17173 onRender : function(ct, position)
17175 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17177 var cfg = Roo.apply({}, this.getAutoCreate());
17181 cfg.cls += ' ' + this.cls;
17184 cfg.style = this.style;
17186 //Roo.log("adding to ");
17187 this.el = Roo.get(document.body).createChild(cfg, position);
17188 // Roo.log(this.el);
17193 initEvents : function()
17195 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17196 this.el.enableDisplayMode('block');
17198 if (this.over === false) {
17201 if (this.triggers === false) {
17204 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17205 var triggers = this.trigger ? this.trigger.split(' ') : [];
17206 Roo.each(triggers, function(trigger) {
17208 if (trigger == 'click') {
17209 on_el.on('click', this.toggle, this);
17210 } else if (trigger != 'manual') {
17211 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17212 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17214 on_el.on(eventIn ,this.enter, this);
17215 on_el.on(eventOut, this.leave, this);
17226 toggle : function () {
17227 this.hoverState == 'in' ? this.leave() : this.enter();
17230 enter : function () {
17232 clearTimeout(this.timeout);
17234 this.hoverState = 'in';
17236 if (!this.delay || !this.delay.show) {
17241 this.timeout = setTimeout(function () {
17242 if (_t.hoverState == 'in') {
17245 }, this.delay.show)
17248 leave : function() {
17249 clearTimeout(this.timeout);
17251 this.hoverState = 'out';
17253 if (!this.delay || !this.delay.hide) {
17258 this.timeout = setTimeout(function () {
17259 if (_t.hoverState == 'out') {
17262 }, this.delay.hide)
17265 show : function (on_el)
17268 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17272 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17273 if (this.html !== false) {
17274 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17276 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17277 if (!this.title.length) {
17278 this.el.select('.popover-title',true).hide();
17281 var placement = typeof this.placement == 'function' ?
17282 this.placement.call(this, this.el, on_el) :
17285 var autoToken = /\s?auto?\s?/i;
17286 var autoPlace = autoToken.test(placement);
17288 placement = placement.replace(autoToken, '') || 'top';
17292 //this.el.setXY([0,0]);
17294 this.el.dom.style.display='block';
17295 this.el.addClass(placement);
17297 //this.el.appendTo(on_el);
17299 var p = this.getPosition();
17300 var box = this.el.getBox();
17305 var align = Roo.bootstrap.Popover.alignment[placement];
17306 this.el.alignTo(on_el, align[0],align[1]);
17307 //var arrow = this.el.select('.arrow',true).first();
17308 //arrow.set(align[2],
17310 this.el.addClass('in');
17313 if (this.el.hasClass('fade')) {
17317 this.hoverState = 'in';
17319 this.fireEvent('show', this);
17324 this.el.setXY([0,0]);
17325 this.el.removeClass('in');
17327 this.hoverState = null;
17329 this.fireEvent('hide', this);
17334 Roo.bootstrap.Popover.alignment = {
17335 'left' : ['r-l', [-10,0], 'right'],
17336 'right' : ['l-r', [10,0], 'left'],
17337 'bottom' : ['t-b', [0,10], 'top'],
17338 'top' : [ 'b-t', [0,-10], 'bottom']
17349 * @class Roo.bootstrap.Progress
17350 * @extends Roo.bootstrap.Component
17351 * Bootstrap Progress class
17352 * @cfg {Boolean} striped striped of the progress bar
17353 * @cfg {Boolean} active animated of the progress bar
17357 * Create a new Progress
17358 * @param {Object} config The config object
17361 Roo.bootstrap.Progress = function(config){
17362 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17365 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17370 getAutoCreate : function(){
17378 cfg.cls += ' progress-striped';
17382 cfg.cls += ' active';
17401 * @class Roo.bootstrap.ProgressBar
17402 * @extends Roo.bootstrap.Component
17403 * Bootstrap ProgressBar class
17404 * @cfg {Number} aria_valuenow aria-value now
17405 * @cfg {Number} aria_valuemin aria-value min
17406 * @cfg {Number} aria_valuemax aria-value max
17407 * @cfg {String} label label for the progress bar
17408 * @cfg {String} panel (success | info | warning | danger )
17409 * @cfg {String} role role of the progress bar
17410 * @cfg {String} sr_only text
17414 * Create a new ProgressBar
17415 * @param {Object} config The config object
17418 Roo.bootstrap.ProgressBar = function(config){
17419 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17422 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17426 aria_valuemax : 100,
17432 getAutoCreate : function()
17437 cls: 'progress-bar',
17438 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17450 cfg.role = this.role;
17453 if(this.aria_valuenow){
17454 cfg['aria-valuenow'] = this.aria_valuenow;
17457 if(this.aria_valuemin){
17458 cfg['aria-valuemin'] = this.aria_valuemin;
17461 if(this.aria_valuemax){
17462 cfg['aria-valuemax'] = this.aria_valuemax;
17465 if(this.label && !this.sr_only){
17466 cfg.html = this.label;
17470 cfg.cls += ' progress-bar-' + this.panel;
17476 update : function(aria_valuenow)
17478 this.aria_valuenow = aria_valuenow;
17480 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17495 * @class Roo.bootstrap.TabGroup
17496 * @extends Roo.bootstrap.Column
17497 * Bootstrap Column class
17498 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17499 * @cfg {Boolean} carousel true to make the group behave like a carousel
17500 * @cfg {Boolean} bullets show bullets for the panels
17501 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17502 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17503 * @cfg {Boolean} showarrow (true|false) show arrow default true
17506 * Create a new TabGroup
17507 * @param {Object} config The config object
17510 Roo.bootstrap.TabGroup = function(config){
17511 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17513 this.navId = Roo.id();
17516 Roo.bootstrap.TabGroup.register(this);
17520 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17523 transition : false,
17528 slideOnTouch : false,
17531 getAutoCreate : function()
17533 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17535 cfg.cls += ' tab-content';
17537 if (this.carousel) {
17538 cfg.cls += ' carousel slide';
17541 cls : 'carousel-inner',
17545 if(this.bullets && !Roo.isTouch){
17548 cls : 'carousel-bullets',
17552 if(this.bullets_cls){
17553 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17560 cfg.cn[0].cn.push(bullets);
17563 if(this.showarrow){
17564 cfg.cn[0].cn.push({
17566 class : 'carousel-arrow',
17570 class : 'carousel-prev',
17574 class : 'fa fa-chevron-left'
17580 class : 'carousel-next',
17584 class : 'fa fa-chevron-right'
17597 initEvents: function()
17599 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17600 // this.el.on("touchstart", this.onTouchStart, this);
17603 if(this.autoslide){
17606 this.slideFn = window.setInterval(function() {
17607 _this.showPanelNext();
17611 if(this.showarrow){
17612 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17613 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17619 // onTouchStart : function(e, el, o)
17621 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17625 // this.showPanelNext();
17629 getChildContainer : function()
17631 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17635 * register a Navigation item
17636 * @param {Roo.bootstrap.NavItem} the navitem to add
17638 register : function(item)
17640 this.tabs.push( item);
17641 item.navId = this.navId; // not really needed..
17646 getActivePanel : function()
17649 Roo.each(this.tabs, function(t) {
17659 getPanelByName : function(n)
17662 Roo.each(this.tabs, function(t) {
17663 if (t.tabId == n) {
17671 indexOfPanel : function(p)
17674 Roo.each(this.tabs, function(t,i) {
17675 if (t.tabId == p.tabId) {
17684 * show a specific panel
17685 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17686 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17688 showPanel : function (pan)
17690 if(this.transition || typeof(pan) == 'undefined'){
17691 Roo.log("waiting for the transitionend");
17695 if (typeof(pan) == 'number') {
17696 pan = this.tabs[pan];
17699 if (typeof(pan) == 'string') {
17700 pan = this.getPanelByName(pan);
17703 var cur = this.getActivePanel();
17706 Roo.log('pan or acitve pan is undefined');
17710 if (pan.tabId == this.getActivePanel().tabId) {
17714 if (false === cur.fireEvent('beforedeactivate')) {
17718 if(this.bullets > 0 && !Roo.isTouch){
17719 this.setActiveBullet(this.indexOfPanel(pan));
17722 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17724 this.transition = true;
17725 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17726 var lr = dir == 'next' ? 'left' : 'right';
17727 pan.el.addClass(dir); // or prev
17728 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17729 cur.el.addClass(lr); // or right
17730 pan.el.addClass(lr);
17733 cur.el.on('transitionend', function() {
17734 Roo.log("trans end?");
17736 pan.el.removeClass([lr,dir]);
17737 pan.setActive(true);
17739 cur.el.removeClass([lr]);
17740 cur.setActive(false);
17742 _this.transition = false;
17744 }, this, { single: true } );
17749 cur.setActive(false);
17750 pan.setActive(true);
17755 showPanelNext : function()
17757 var i = this.indexOfPanel(this.getActivePanel());
17759 if (i >= this.tabs.length - 1 && !this.autoslide) {
17763 if (i >= this.tabs.length - 1 && this.autoslide) {
17767 this.showPanel(this.tabs[i+1]);
17770 showPanelPrev : function()
17772 var i = this.indexOfPanel(this.getActivePanel());
17774 if (i < 1 && !this.autoslide) {
17778 if (i < 1 && this.autoslide) {
17779 i = this.tabs.length;
17782 this.showPanel(this.tabs[i-1]);
17786 addBullet: function()
17788 if(!this.bullets || Roo.isTouch){
17791 var ctr = this.el.select('.carousel-bullets',true).first();
17792 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17793 var bullet = ctr.createChild({
17794 cls : 'bullet bullet-' + i
17795 },ctr.dom.lastChild);
17800 bullet.on('click', (function(e, el, o, ii, t){
17802 e.preventDefault();
17804 this.showPanel(ii);
17806 if(this.autoslide && this.slideFn){
17807 clearInterval(this.slideFn);
17808 this.slideFn = window.setInterval(function() {
17809 _this.showPanelNext();
17813 }).createDelegate(this, [i, bullet], true));
17818 setActiveBullet : function(i)
17824 Roo.each(this.el.select('.bullet', true).elements, function(el){
17825 el.removeClass('selected');
17828 var bullet = this.el.select('.bullet-' + i, true).first();
17834 bullet.addClass('selected');
17845 Roo.apply(Roo.bootstrap.TabGroup, {
17849 * register a Navigation Group
17850 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17852 register : function(navgrp)
17854 this.groups[navgrp.navId] = navgrp;
17858 * fetch a Navigation Group based on the navigation ID
17859 * if one does not exist , it will get created.
17860 * @param {string} the navgroup to add
17861 * @returns {Roo.bootstrap.NavGroup} the navgroup
17863 get: function(navId) {
17864 if (typeof(this.groups[navId]) == 'undefined') {
17865 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17867 return this.groups[navId] ;
17882 * @class Roo.bootstrap.TabPanel
17883 * @extends Roo.bootstrap.Component
17884 * Bootstrap TabPanel class
17885 * @cfg {Boolean} active panel active
17886 * @cfg {String} html panel content
17887 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17888 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17889 * @cfg {String} href click to link..
17893 * Create a new TabPanel
17894 * @param {Object} config The config object
17897 Roo.bootstrap.TabPanel = function(config){
17898 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17902 * Fires when the active status changes
17903 * @param {Roo.bootstrap.TabPanel} this
17904 * @param {Boolean} state the new state
17909 * @event beforedeactivate
17910 * Fires before a tab is de-activated - can be used to do validation on a form.
17911 * @param {Roo.bootstrap.TabPanel} this
17912 * @return {Boolean} false if there is an error
17915 'beforedeactivate': true
17918 this.tabId = this.tabId || Roo.id();
17922 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
17930 getAutoCreate : function(){
17933 // item is needed for carousel - not sure if it has any effect otherwise
17934 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
17935 html: this.html || ''
17939 cfg.cls += ' active';
17943 cfg.tabId = this.tabId;
17950 initEvents: function()
17952 var p = this.parent();
17954 this.navId = this.navId || p.navId;
17956 if (typeof(this.navId) != 'undefined') {
17957 // not really needed.. but just in case.. parent should be a NavGroup.
17958 var tg = Roo.bootstrap.TabGroup.get(this.navId);
17962 var i = tg.tabs.length - 1;
17964 if(this.active && tg.bullets > 0 && i < tg.bullets){
17965 tg.setActiveBullet(i);
17969 this.el.on('click', this.onClick, this);
17972 this.el.on("touchstart", this.onTouchStart, this);
17973 this.el.on("touchmove", this.onTouchMove, this);
17974 this.el.on("touchend", this.onTouchEnd, this);
17979 onRender : function(ct, position)
17981 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
17984 setActive : function(state)
17986 Roo.log("panel - set active " + this.tabId + "=" + state);
17988 this.active = state;
17990 this.el.removeClass('active');
17992 } else if (!this.el.hasClass('active')) {
17993 this.el.addClass('active');
17996 this.fireEvent('changed', this, state);
17999 onClick : function(e)
18001 e.preventDefault();
18003 if(!this.href.length){
18007 window.location.href = this.href;
18016 onTouchStart : function(e)
18018 this.swiping = false;
18020 this.startX = e.browserEvent.touches[0].clientX;
18021 this.startY = e.browserEvent.touches[0].clientY;
18024 onTouchMove : function(e)
18026 this.swiping = true;
18028 this.endX = e.browserEvent.touches[0].clientX;
18029 this.endY = e.browserEvent.touches[0].clientY;
18032 onTouchEnd : function(e)
18039 var tabGroup = this.parent();
18041 if(this.endX > this.startX){ // swiping right
18042 tabGroup.showPanelPrev();
18046 if(this.startX > this.endX){ // swiping left
18047 tabGroup.showPanelNext();
18066 * @class Roo.bootstrap.DateField
18067 * @extends Roo.bootstrap.Input
18068 * Bootstrap DateField class
18069 * @cfg {Number} weekStart default 0
18070 * @cfg {String} viewMode default empty, (months|years)
18071 * @cfg {String} minViewMode default empty, (months|years)
18072 * @cfg {Number} startDate default -Infinity
18073 * @cfg {Number} endDate default Infinity
18074 * @cfg {Boolean} todayHighlight default false
18075 * @cfg {Boolean} todayBtn default false
18076 * @cfg {Boolean} calendarWeeks default false
18077 * @cfg {Object} daysOfWeekDisabled default empty
18078 * @cfg {Boolean} singleMode default false (true | false)
18080 * @cfg {Boolean} keyboardNavigation default true
18081 * @cfg {String} language default en
18084 * Create a new DateField
18085 * @param {Object} config The config object
18088 Roo.bootstrap.DateField = function(config){
18089 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18093 * Fires when this field show.
18094 * @param {Roo.bootstrap.DateField} this
18095 * @param {Mixed} date The date value
18100 * Fires when this field hide.
18101 * @param {Roo.bootstrap.DateField} this
18102 * @param {Mixed} date The date value
18107 * Fires when select a date.
18108 * @param {Roo.bootstrap.DateField} this
18109 * @param {Mixed} date The date value
18113 * @event beforeselect
18114 * Fires when before select a date.
18115 * @param {Roo.bootstrap.DateField} this
18116 * @param {Mixed} date The date value
18118 beforeselect : true
18122 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18125 * @cfg {String} format
18126 * The default date format string which can be overriden for localization support. The format must be
18127 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18131 * @cfg {String} altFormats
18132 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18133 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18135 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18143 todayHighlight : false,
18149 keyboardNavigation: true,
18151 calendarWeeks: false,
18153 startDate: -Infinity,
18157 daysOfWeekDisabled: [],
18161 singleMode : false,
18163 UTCDate: function()
18165 return new Date(Date.UTC.apply(Date, arguments));
18168 UTCToday: function()
18170 var today = new Date();
18171 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18174 getDate: function() {
18175 var d = this.getUTCDate();
18176 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18179 getUTCDate: function() {
18183 setDate: function(d) {
18184 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18187 setUTCDate: function(d) {
18189 this.setValue(this.formatDate(this.date));
18192 onRender: function(ct, position)
18195 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18197 this.language = this.language || 'en';
18198 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18199 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18201 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18202 this.format = this.format || 'm/d/y';
18203 this.isInline = false;
18204 this.isInput = true;
18205 this.component = this.el.select('.add-on', true).first() || false;
18206 this.component = (this.component && this.component.length === 0) ? false : this.component;
18207 this.hasInput = this.component && this.inputEl().length;
18209 if (typeof(this.minViewMode === 'string')) {
18210 switch (this.minViewMode) {
18212 this.minViewMode = 1;
18215 this.minViewMode = 2;
18218 this.minViewMode = 0;
18223 if (typeof(this.viewMode === 'string')) {
18224 switch (this.viewMode) {
18237 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18239 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18241 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18243 this.picker().on('mousedown', this.onMousedown, this);
18244 this.picker().on('click', this.onClick, this);
18246 this.picker().addClass('datepicker-dropdown');
18248 this.startViewMode = this.viewMode;
18250 if(this.singleMode){
18251 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18252 v.setVisibilityMode(Roo.Element.DISPLAY);
18256 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18257 v.setStyle('width', '189px');
18261 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18262 if(!this.calendarWeeks){
18267 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18268 v.attr('colspan', function(i, val){
18269 return parseInt(val) + 1;
18274 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18276 this.setStartDate(this.startDate);
18277 this.setEndDate(this.endDate);
18279 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18286 if(this.isInline) {
18291 picker : function()
18293 return this.pickerEl;
18294 // return this.el.select('.datepicker', true).first();
18297 fillDow: function()
18299 var dowCnt = this.weekStart;
18308 if(this.calendarWeeks){
18316 while (dowCnt < this.weekStart + 7) {
18320 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18324 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18327 fillMonths: function()
18330 var months = this.picker().select('>.datepicker-months td', true).first();
18332 months.dom.innerHTML = '';
18338 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18341 months.createChild(month);
18348 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;
18350 if (this.date < this.startDate) {
18351 this.viewDate = new Date(this.startDate);
18352 } else if (this.date > this.endDate) {
18353 this.viewDate = new Date(this.endDate);
18355 this.viewDate = new Date(this.date);
18363 var d = new Date(this.viewDate),
18364 year = d.getUTCFullYear(),
18365 month = d.getUTCMonth(),
18366 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18367 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18368 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18369 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18370 currentDate = this.date && this.date.valueOf(),
18371 today = this.UTCToday();
18373 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18375 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18377 // this.picker.select('>tfoot th.today').
18378 // .text(dates[this.language].today)
18379 // .toggle(this.todayBtn !== false);
18381 this.updateNavArrows();
18384 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18386 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18388 prevMonth.setUTCDate(day);
18390 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18392 var nextMonth = new Date(prevMonth);
18394 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18396 nextMonth = nextMonth.valueOf();
18398 var fillMonths = false;
18400 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18402 while(prevMonth.valueOf() < nextMonth) {
18405 if (prevMonth.getUTCDay() === this.weekStart) {
18407 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18415 if(this.calendarWeeks){
18416 // ISO 8601: First week contains first thursday.
18417 // ISO also states week starts on Monday, but we can be more abstract here.
18419 // Start of current week: based on weekstart/current date
18420 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18421 // Thursday of this week
18422 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18423 // First Thursday of year, year from thursday
18424 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18425 // Calendar week: ms between thursdays, div ms per day, div 7 days
18426 calWeek = (th - yth) / 864e5 / 7 + 1;
18428 fillMonths.cn.push({
18436 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18438 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18441 if (this.todayHighlight &&
18442 prevMonth.getUTCFullYear() == today.getFullYear() &&
18443 prevMonth.getUTCMonth() == today.getMonth() &&
18444 prevMonth.getUTCDate() == today.getDate()) {
18445 clsName += ' today';
18448 if (currentDate && prevMonth.valueOf() === currentDate) {
18449 clsName += ' active';
18452 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18453 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18454 clsName += ' disabled';
18457 fillMonths.cn.push({
18459 cls: 'day ' + clsName,
18460 html: prevMonth.getDate()
18463 prevMonth.setDate(prevMonth.getDate()+1);
18466 var currentYear = this.date && this.date.getUTCFullYear();
18467 var currentMonth = this.date && this.date.getUTCMonth();
18469 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18471 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18472 v.removeClass('active');
18474 if(currentYear === year && k === currentMonth){
18475 v.addClass('active');
18478 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18479 v.addClass('disabled');
18485 year = parseInt(year/10, 10) * 10;
18487 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18489 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18492 for (var i = -1; i < 11; i++) {
18493 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18495 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18503 showMode: function(dir)
18506 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18509 Roo.each(this.picker().select('>div',true).elements, function(v){
18510 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18513 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18518 if(this.isInline) {
18522 this.picker().removeClass(['bottom', 'top']);
18524 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18526 * place to the top of element!
18530 this.picker().addClass('top');
18531 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18536 this.picker().addClass('bottom');
18538 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18541 parseDate : function(value)
18543 if(!value || value instanceof Date){
18546 var v = Date.parseDate(value, this.format);
18547 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18548 v = Date.parseDate(value, 'Y-m-d');
18550 if(!v && this.altFormats){
18551 if(!this.altFormatsArray){
18552 this.altFormatsArray = this.altFormats.split("|");
18554 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18555 v = Date.parseDate(value, this.altFormatsArray[i]);
18561 formatDate : function(date, fmt)
18563 return (!date || !(date instanceof Date)) ?
18564 date : date.dateFormat(fmt || this.format);
18567 onFocus : function()
18569 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18573 onBlur : function()
18575 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18577 var d = this.inputEl().getValue();
18586 this.picker().show();
18590 this.fireEvent('show', this, this.date);
18595 if(this.isInline) {
18598 this.picker().hide();
18599 this.viewMode = this.startViewMode;
18602 this.fireEvent('hide', this, this.date);
18606 onMousedown: function(e)
18608 e.stopPropagation();
18609 e.preventDefault();
18614 Roo.bootstrap.DateField.superclass.keyup.call(this);
18618 setValue: function(v)
18620 if(this.fireEvent('beforeselect', this, v) !== false){
18621 var d = new Date(this.parseDate(v) ).clearTime();
18623 if(isNaN(d.getTime())){
18624 this.date = this.viewDate = '';
18625 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18629 v = this.formatDate(d);
18631 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18633 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18637 this.fireEvent('select', this, this.date);
18641 getValue: function()
18643 return this.formatDate(this.date);
18646 fireKey: function(e)
18648 if (!this.picker().isVisible()){
18649 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18655 var dateChanged = false,
18657 newDate, newViewDate;
18662 e.preventDefault();
18666 if (!this.keyboardNavigation) {
18669 dir = e.keyCode == 37 ? -1 : 1;
18672 newDate = this.moveYear(this.date, dir);
18673 newViewDate = this.moveYear(this.viewDate, dir);
18674 } else if (e.shiftKey){
18675 newDate = this.moveMonth(this.date, dir);
18676 newViewDate = this.moveMonth(this.viewDate, dir);
18678 newDate = new Date(this.date);
18679 newDate.setUTCDate(this.date.getUTCDate() + dir);
18680 newViewDate = new Date(this.viewDate);
18681 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18683 if (this.dateWithinRange(newDate)){
18684 this.date = newDate;
18685 this.viewDate = newViewDate;
18686 this.setValue(this.formatDate(this.date));
18688 e.preventDefault();
18689 dateChanged = true;
18694 if (!this.keyboardNavigation) {
18697 dir = e.keyCode == 38 ? -1 : 1;
18699 newDate = this.moveYear(this.date, dir);
18700 newViewDate = this.moveYear(this.viewDate, dir);
18701 } else if (e.shiftKey){
18702 newDate = this.moveMonth(this.date, dir);
18703 newViewDate = this.moveMonth(this.viewDate, dir);
18705 newDate = new Date(this.date);
18706 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18707 newViewDate = new Date(this.viewDate);
18708 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18710 if (this.dateWithinRange(newDate)){
18711 this.date = newDate;
18712 this.viewDate = newViewDate;
18713 this.setValue(this.formatDate(this.date));
18715 e.preventDefault();
18716 dateChanged = true;
18720 this.setValue(this.formatDate(this.date));
18722 e.preventDefault();
18725 this.setValue(this.formatDate(this.date));
18739 onClick: function(e)
18741 e.stopPropagation();
18742 e.preventDefault();
18744 var target = e.getTarget();
18746 if(target.nodeName.toLowerCase() === 'i'){
18747 target = Roo.get(target).dom.parentNode;
18750 var nodeName = target.nodeName;
18751 var className = target.className;
18752 var html = target.innerHTML;
18753 //Roo.log(nodeName);
18755 switch(nodeName.toLowerCase()) {
18757 switch(className) {
18763 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18764 switch(this.viewMode){
18766 this.viewDate = this.moveMonth(this.viewDate, dir);
18770 this.viewDate = this.moveYear(this.viewDate, dir);
18776 var date = new Date();
18777 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18779 this.setValue(this.formatDate(this.date));
18786 if (className.indexOf('disabled') < 0) {
18787 this.viewDate.setUTCDate(1);
18788 if (className.indexOf('month') > -1) {
18789 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18791 var year = parseInt(html, 10) || 0;
18792 this.viewDate.setUTCFullYear(year);
18796 if(this.singleMode){
18797 this.setValue(this.formatDate(this.viewDate));
18808 //Roo.log(className);
18809 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18810 var day = parseInt(html, 10) || 1;
18811 var year = this.viewDate.getUTCFullYear(),
18812 month = this.viewDate.getUTCMonth();
18814 if (className.indexOf('old') > -1) {
18821 } else if (className.indexOf('new') > -1) {
18829 //Roo.log([year,month,day]);
18830 this.date = this.UTCDate(year, month, day,0,0,0,0);
18831 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18833 //Roo.log(this.formatDate(this.date));
18834 this.setValue(this.formatDate(this.date));
18841 setStartDate: function(startDate)
18843 this.startDate = startDate || -Infinity;
18844 if (this.startDate !== -Infinity) {
18845 this.startDate = this.parseDate(this.startDate);
18848 this.updateNavArrows();
18851 setEndDate: function(endDate)
18853 this.endDate = endDate || Infinity;
18854 if (this.endDate !== Infinity) {
18855 this.endDate = this.parseDate(this.endDate);
18858 this.updateNavArrows();
18861 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18863 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18864 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18865 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18867 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18868 return parseInt(d, 10);
18871 this.updateNavArrows();
18874 updateNavArrows: function()
18876 if(this.singleMode){
18880 var d = new Date(this.viewDate),
18881 year = d.getUTCFullYear(),
18882 month = d.getUTCMonth();
18884 Roo.each(this.picker().select('.prev', true).elements, function(v){
18886 switch (this.viewMode) {
18889 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18895 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18902 Roo.each(this.picker().select('.next', true).elements, function(v){
18904 switch (this.viewMode) {
18907 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
18913 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
18921 moveMonth: function(date, dir)
18926 var new_date = new Date(date.valueOf()),
18927 day = new_date.getUTCDate(),
18928 month = new_date.getUTCMonth(),
18929 mag = Math.abs(dir),
18931 dir = dir > 0 ? 1 : -1;
18934 // If going back one month, make sure month is not current month
18935 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
18937 return new_date.getUTCMonth() == month;
18939 // If going forward one month, make sure month is as expected
18940 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
18942 return new_date.getUTCMonth() != new_month;
18944 new_month = month + dir;
18945 new_date.setUTCMonth(new_month);
18946 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
18947 if (new_month < 0 || new_month > 11) {
18948 new_month = (new_month + 12) % 12;
18951 // For magnitudes >1, move one month at a time...
18952 for (var i=0; i<mag; i++) {
18953 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
18954 new_date = this.moveMonth(new_date, dir);
18956 // ...then reset the day, keeping it in the new month
18957 new_month = new_date.getUTCMonth();
18958 new_date.setUTCDate(day);
18960 return new_month != new_date.getUTCMonth();
18963 // Common date-resetting loop -- if date is beyond end of month, make it
18966 new_date.setUTCDate(--day);
18967 new_date.setUTCMonth(new_month);
18972 moveYear: function(date, dir)
18974 return this.moveMonth(date, dir*12);
18977 dateWithinRange: function(date)
18979 return date >= this.startDate && date <= this.endDate;
18985 this.picker().remove();
18988 validateValue : function(value)
18990 if(value.length < 1) {
18991 if(this.allowBlank){
18997 if(value.length < this.minLength){
19000 if(value.length > this.maxLength){
19004 var vt = Roo.form.VTypes;
19005 if(!vt[this.vtype](value, this)){
19009 if(typeof this.validator == "function"){
19010 var msg = this.validator(value);
19016 if(this.regex && !this.regex.test(value)){
19020 if(typeof(this.parseDate(value)) == 'undefined'){
19024 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19028 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19038 Roo.apply(Roo.bootstrap.DateField, {
19049 html: '<i class="fa fa-arrow-left"/>'
19059 html: '<i class="fa fa-arrow-right"/>'
19101 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19102 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19103 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19104 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19105 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19118 navFnc: 'FullYear',
19123 navFnc: 'FullYear',
19128 Roo.apply(Roo.bootstrap.DateField, {
19132 cls: 'datepicker dropdown-menu roo-dynamic',
19136 cls: 'datepicker-days',
19140 cls: 'table-condensed',
19142 Roo.bootstrap.DateField.head,
19146 Roo.bootstrap.DateField.footer
19153 cls: 'datepicker-months',
19157 cls: 'table-condensed',
19159 Roo.bootstrap.DateField.head,
19160 Roo.bootstrap.DateField.content,
19161 Roo.bootstrap.DateField.footer
19168 cls: 'datepicker-years',
19172 cls: 'table-condensed',
19174 Roo.bootstrap.DateField.head,
19175 Roo.bootstrap.DateField.content,
19176 Roo.bootstrap.DateField.footer
19195 * @class Roo.bootstrap.TimeField
19196 * @extends Roo.bootstrap.Input
19197 * Bootstrap DateField class
19201 * Create a new TimeField
19202 * @param {Object} config The config object
19205 Roo.bootstrap.TimeField = function(config){
19206 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19210 * Fires when this field show.
19211 * @param {Roo.bootstrap.DateField} thisthis
19212 * @param {Mixed} date The date value
19217 * Fires when this field hide.
19218 * @param {Roo.bootstrap.DateField} this
19219 * @param {Mixed} date The date value
19224 * Fires when select a date.
19225 * @param {Roo.bootstrap.DateField} this
19226 * @param {Mixed} date The date value
19232 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19235 * @cfg {String} format
19236 * The default time format string which can be overriden for localization support. The format must be
19237 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19241 onRender: function(ct, position)
19244 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19246 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19248 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19250 this.pop = this.picker().select('>.datepicker-time',true).first();
19251 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19253 this.picker().on('mousedown', this.onMousedown, this);
19254 this.picker().on('click', this.onClick, this);
19256 this.picker().addClass('datepicker-dropdown');
19261 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19262 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19263 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19264 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19265 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19266 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19270 fireKey: function(e){
19271 if (!this.picker().isVisible()){
19272 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19278 e.preventDefault();
19286 this.onTogglePeriod();
19289 this.onIncrementMinutes();
19292 this.onDecrementMinutes();
19301 onClick: function(e) {
19302 e.stopPropagation();
19303 e.preventDefault();
19306 picker : function()
19308 return this.el.select('.datepicker', true).first();
19311 fillTime: function()
19313 var time = this.pop.select('tbody', true).first();
19315 time.dom.innerHTML = '';
19330 cls: 'hours-up glyphicon glyphicon-chevron-up'
19350 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19371 cls: 'timepicker-hour',
19386 cls: 'timepicker-minute',
19401 cls: 'btn btn-primary period',
19423 cls: 'hours-down glyphicon glyphicon-chevron-down'
19443 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19461 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19468 var hours = this.time.getHours();
19469 var minutes = this.time.getMinutes();
19482 hours = hours - 12;
19486 hours = '0' + hours;
19490 minutes = '0' + minutes;
19493 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19494 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19495 this.pop.select('button', true).first().dom.innerHTML = period;
19501 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19503 var cls = ['bottom'];
19505 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19512 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19517 this.picker().addClass(cls.join('-'));
19521 Roo.each(cls, function(c){
19523 _this.picker().setTop(_this.inputEl().getHeight());
19527 _this.picker().setTop(0 - _this.picker().getHeight());
19532 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19536 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19543 onFocus : function()
19545 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19549 onBlur : function()
19551 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19557 this.picker().show();
19562 this.fireEvent('show', this, this.date);
19567 this.picker().hide();
19570 this.fireEvent('hide', this, this.date);
19573 setTime : function()
19576 this.setValue(this.time.format(this.format));
19578 this.fireEvent('select', this, this.date);
19583 onMousedown: function(e){
19584 e.stopPropagation();
19585 e.preventDefault();
19588 onIncrementHours: function()
19590 Roo.log('onIncrementHours');
19591 this.time = this.time.add(Date.HOUR, 1);
19596 onDecrementHours: function()
19598 Roo.log('onDecrementHours');
19599 this.time = this.time.add(Date.HOUR, -1);
19603 onIncrementMinutes: function()
19605 Roo.log('onIncrementMinutes');
19606 this.time = this.time.add(Date.MINUTE, 1);
19610 onDecrementMinutes: function()
19612 Roo.log('onDecrementMinutes');
19613 this.time = this.time.add(Date.MINUTE, -1);
19617 onTogglePeriod: function()
19619 Roo.log('onTogglePeriod');
19620 this.time = this.time.add(Date.HOUR, 12);
19627 Roo.apply(Roo.bootstrap.TimeField, {
19657 cls: 'btn btn-info ok',
19669 Roo.apply(Roo.bootstrap.TimeField, {
19673 cls: 'datepicker dropdown-menu',
19677 cls: 'datepicker-time',
19681 cls: 'table-condensed',
19683 Roo.bootstrap.TimeField.content,
19684 Roo.bootstrap.TimeField.footer
19703 * @class Roo.bootstrap.MonthField
19704 * @extends Roo.bootstrap.Input
19705 * Bootstrap MonthField class
19707 * @cfg {String} language default en
19710 * Create a new MonthField
19711 * @param {Object} config The config object
19714 Roo.bootstrap.MonthField = function(config){
19715 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19720 * Fires when this field show.
19721 * @param {Roo.bootstrap.MonthField} this
19722 * @param {Mixed} date The date value
19727 * Fires when this field hide.
19728 * @param {Roo.bootstrap.MonthField} this
19729 * @param {Mixed} date The date value
19734 * Fires when select a date.
19735 * @param {Roo.bootstrap.MonthField} this
19736 * @param {String} oldvalue The old value
19737 * @param {String} newvalue The new value
19743 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19745 onRender: function(ct, position)
19748 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19750 this.language = this.language || 'en';
19751 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19752 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19754 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19755 this.isInline = false;
19756 this.isInput = true;
19757 this.component = this.el.select('.add-on', true).first() || false;
19758 this.component = (this.component && this.component.length === 0) ? false : this.component;
19759 this.hasInput = this.component && this.inputEL().length;
19761 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19763 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19765 this.picker().on('mousedown', this.onMousedown, this);
19766 this.picker().on('click', this.onClick, this);
19768 this.picker().addClass('datepicker-dropdown');
19770 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19771 v.setStyle('width', '189px');
19778 if(this.isInline) {
19784 setValue: function(v, suppressEvent)
19786 var o = this.getValue();
19788 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19792 if(suppressEvent !== true){
19793 this.fireEvent('select', this, o, v);
19798 getValue: function()
19803 onClick: function(e)
19805 e.stopPropagation();
19806 e.preventDefault();
19808 var target = e.getTarget();
19810 if(target.nodeName.toLowerCase() === 'i'){
19811 target = Roo.get(target).dom.parentNode;
19814 var nodeName = target.nodeName;
19815 var className = target.className;
19816 var html = target.innerHTML;
19818 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19822 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19824 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19830 picker : function()
19832 return this.pickerEl;
19835 fillMonths: function()
19838 var months = this.picker().select('>.datepicker-months td', true).first();
19840 months.dom.innerHTML = '';
19846 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19849 months.createChild(month);
19858 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19859 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19862 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19863 e.removeClass('active');
19865 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19866 e.addClass('active');
19873 if(this.isInline) {
19877 this.picker().removeClass(['bottom', 'top']);
19879 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19881 * place to the top of element!
19885 this.picker().addClass('top');
19886 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19891 this.picker().addClass('bottom');
19893 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19896 onFocus : function()
19898 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19902 onBlur : function()
19904 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19906 var d = this.inputEl().getValue();
19915 this.picker().show();
19916 this.picker().select('>.datepicker-months', true).first().show();
19920 this.fireEvent('show', this, this.date);
19925 if(this.isInline) {
19928 this.picker().hide();
19929 this.fireEvent('hide', this, this.date);
19933 onMousedown: function(e)
19935 e.stopPropagation();
19936 e.preventDefault();
19941 Roo.bootstrap.MonthField.superclass.keyup.call(this);
19945 fireKey: function(e)
19947 if (!this.picker().isVisible()){
19948 if (e.keyCode == 27) {// allow escape to hide and re-show picker
19959 e.preventDefault();
19963 dir = e.keyCode == 37 ? -1 : 1;
19965 this.vIndex = this.vIndex + dir;
19967 if(this.vIndex < 0){
19971 if(this.vIndex > 11){
19975 if(isNaN(this.vIndex)){
19979 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19985 dir = e.keyCode == 38 ? -1 : 1;
19987 this.vIndex = this.vIndex + dir * 4;
19989 if(this.vIndex < 0){
19993 if(this.vIndex > 11){
19997 if(isNaN(this.vIndex)){
20001 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20006 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20007 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20011 e.preventDefault();
20014 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20015 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20031 this.picker().remove();
20036 Roo.apply(Roo.bootstrap.MonthField, {
20055 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20056 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20061 Roo.apply(Roo.bootstrap.MonthField, {
20065 cls: 'datepicker dropdown-menu roo-dynamic',
20069 cls: 'datepicker-months',
20073 cls: 'table-condensed',
20075 Roo.bootstrap.DateField.content
20095 * @class Roo.bootstrap.CheckBox
20096 * @extends Roo.bootstrap.Input
20097 * Bootstrap CheckBox class
20099 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20100 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20101 * @cfg {String} boxLabel The text that appears beside the checkbox
20102 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20103 * @cfg {Boolean} checked initnal the element
20104 * @cfg {Boolean} inline inline the element (default false)
20105 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20108 * Create a new CheckBox
20109 * @param {Object} config The config object
20112 Roo.bootstrap.CheckBox = function(config){
20113 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20118 * Fires when the element is checked or unchecked.
20119 * @param {Roo.bootstrap.CheckBox} this This input
20120 * @param {Boolean} checked The new checked value
20127 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20129 inputType: 'checkbox',
20137 getAutoCreate : function()
20139 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20145 cfg.cls = 'form-group ' + this.inputType; //input-group
20148 cfg.cls += ' ' + this.inputType + '-inline';
20154 type : this.inputType,
20155 value : this.inputValue,
20156 cls : 'roo-' + this.inputType, //'form-box',
20157 placeholder : this.placeholder || ''
20161 if(this.inputType != 'radio'){
20165 cls : 'roo-hidden-value',
20166 value : this.checked ? this.valueOff : this.inputValue
20171 if (this.weight) { // Validity check?
20172 cfg.cls += " " + this.inputType + "-" + this.weight;
20175 if (this.disabled) {
20176 input.disabled=true;
20180 input.checked = this.checked;
20187 input.name = this.name;
20189 if(this.inputType != 'radio'){
20190 hidden.name = this.name;
20191 input.name = '_hidden_' + this.name;
20196 input.cls += ' input-' + this.size;
20201 ['xs','sm','md','lg'].map(function(size){
20202 if (settings[size]) {
20203 cfg.cls += ' col-' + size + '-' + settings[size];
20207 var inputblock = input;
20209 if (this.before || this.after) {
20212 cls : 'input-group',
20217 inputblock.cn.push({
20219 cls : 'input-group-addon',
20224 inputblock.cn.push(input);
20226 if(this.inputType != 'radio'){
20227 inputblock.cn.push(hidden);
20231 inputblock.cn.push({
20233 cls : 'input-group-addon',
20240 if (align ==='left' && this.fieldLabel.length) {
20241 // Roo.log("left and has label");
20246 cls : 'control-label',
20247 html : this.fieldLabel
20258 if(this.labelWidth > 12){
20259 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20262 if(this.labelWidth < 13 && this.labelmd == 0){
20263 this.labelmd = this.labelWidth;
20266 if(this.labellg > 0){
20267 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20268 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20271 if(this.labelmd > 0){
20272 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20273 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20276 if(this.labelsm > 0){
20277 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20278 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20281 if(this.labelxs > 0){
20282 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20283 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20286 } else if ( this.fieldLabel.length) {
20287 // Roo.log(" label");
20291 tag: this.boxLabel ? 'span' : 'label',
20293 cls: 'control-label box-input-label',
20294 //cls : 'input-group-addon',
20295 html : this.fieldLabel
20305 // Roo.log(" no label && no align");
20306 cfg.cn = [ inputblock ] ;
20312 var boxLabelCfg = {
20314 //'for': id, // box label is handled by onclick - so no for...
20316 html: this.boxLabel
20320 boxLabelCfg.tooltip = this.tooltip;
20323 cfg.cn.push(boxLabelCfg);
20326 if(this.inputType != 'radio'){
20327 cfg.cn.push(hidden);
20335 * return the real input element.
20337 inputEl: function ()
20339 return this.el.select('input.roo-' + this.inputType,true).first();
20341 hiddenEl: function ()
20343 return this.el.select('input.roo-hidden-value',true).first();
20346 labelEl: function()
20348 return this.el.select('label.control-label',true).first();
20350 /* depricated... */
20354 return this.labelEl();
20357 boxLabelEl: function()
20359 return this.el.select('label.box-label',true).first();
20362 initEvents : function()
20364 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20366 this.inputEl().on('click', this.onClick, this);
20368 if (this.boxLabel) {
20369 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20372 this.startValue = this.getValue();
20375 Roo.bootstrap.CheckBox.register(this);
20379 onClick : function()
20381 this.setChecked(!this.checked);
20384 setChecked : function(state,suppressEvent)
20386 this.startValue = this.getValue();
20388 if(this.inputType == 'radio'){
20390 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20391 e.dom.checked = false;
20394 this.inputEl().dom.checked = true;
20396 this.inputEl().dom.value = this.inputValue;
20398 if(suppressEvent !== true){
20399 this.fireEvent('check', this, true);
20407 this.checked = state;
20409 this.inputEl().dom.checked = state;
20412 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20414 if(suppressEvent !== true){
20415 this.fireEvent('check', this, state);
20421 getValue : function()
20423 if(this.inputType == 'radio'){
20424 return this.getGroupValue();
20427 return this.hiddenEl().dom.value;
20431 getGroupValue : function()
20433 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20437 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20440 setValue : function(v,suppressEvent)
20442 if(this.inputType == 'radio'){
20443 this.setGroupValue(v, suppressEvent);
20447 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20452 setGroupValue : function(v, suppressEvent)
20454 this.startValue = this.getValue();
20456 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20457 e.dom.checked = false;
20459 if(e.dom.value == v){
20460 e.dom.checked = true;
20464 if(suppressEvent !== true){
20465 this.fireEvent('check', this, true);
20473 validate : function()
20477 (this.inputType == 'radio' && this.validateRadio()) ||
20478 (this.inputType == 'checkbox' && this.validateCheckbox())
20484 this.markInvalid();
20488 validateRadio : function()
20490 if(this.allowBlank){
20496 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20497 if(!e.dom.checked){
20509 validateCheckbox : function()
20512 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20513 //return (this.getValue() == this.inputValue) ? true : false;
20516 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20524 for(var i in group){
20529 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20536 * Mark this field as valid
20538 markValid : function()
20542 this.fireEvent('valid', this);
20544 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20547 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20554 if(this.inputType == 'radio'){
20555 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20556 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20557 e.findParent('.form-group', false, true).addClass(_this.validClass);
20564 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20565 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20569 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20575 for(var i in group){
20576 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20577 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20582 * Mark this field as invalid
20583 * @param {String} msg The validation message
20585 markInvalid : function(msg)
20587 if(this.allowBlank){
20593 this.fireEvent('invalid', this, msg);
20595 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20598 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20602 label.markInvalid();
20605 if(this.inputType == 'radio'){
20606 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20607 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20608 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20615 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20616 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20620 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20626 for(var i in group){
20627 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20628 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20633 clearInvalid : function()
20635 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20637 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20639 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20642 label.iconEl.removeClass(label.validClass);
20643 label.iconEl.removeClass(label.invalidClass);
20647 disable : function()
20649 if(this.inputType != 'radio'){
20650 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20657 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20658 _this.getActionEl().addClass(this.disabledClass);
20659 e.dom.disabled = true;
20663 this.disabled = true;
20664 this.fireEvent("disable", this);
20668 enable : function()
20670 if(this.inputType != 'radio'){
20671 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20678 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20679 _this.getActionEl().removeClass(this.disabledClass);
20680 e.dom.disabled = false;
20684 this.disabled = false;
20685 this.fireEvent("enable", this);
20691 Roo.apply(Roo.bootstrap.CheckBox, {
20696 * register a CheckBox Group
20697 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20699 register : function(checkbox)
20701 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20702 this.groups[checkbox.groupId] = {};
20705 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20709 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20713 * fetch a CheckBox Group based on the group ID
20714 * @param {string} the group ID
20715 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20717 get: function(groupId) {
20718 if (typeof(this.groups[groupId]) == 'undefined') {
20722 return this.groups[groupId] ;
20735 * @class Roo.bootstrap.Radio
20736 * @extends Roo.bootstrap.Component
20737 * Bootstrap Radio class
20738 * @cfg {String} boxLabel - the label associated
20739 * @cfg {String} value - the value of radio
20742 * Create a new Radio
20743 * @param {Object} config The config object
20745 Roo.bootstrap.Radio = function(config){
20746 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20750 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20756 getAutoCreate : function()
20760 cls : 'form-group radio',
20765 html : this.boxLabel
20773 initEvents : function()
20775 this.parent().register(this);
20777 this.el.on('click', this.onClick, this);
20781 onClick : function()
20783 this.setChecked(true);
20786 setChecked : function(state, suppressEvent)
20788 this.parent().setValue(this.value, suppressEvent);
20792 setBoxLabel : function(v)
20797 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20812 * @class Roo.bootstrap.SecurePass
20813 * @extends Roo.bootstrap.Input
20814 * Bootstrap SecurePass class
20818 * Create a new SecurePass
20819 * @param {Object} config The config object
20822 Roo.bootstrap.SecurePass = function (config) {
20823 // these go here, so the translation tool can replace them..
20825 PwdEmpty: "Please type a password, and then retype it to confirm.",
20826 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20827 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20828 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20829 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20830 FNInPwd: "Your password can't contain your first name. Please type a different password.",
20831 LNInPwd: "Your password can't contain your last name. Please type a different password.",
20832 TooWeak: "Your password is Too Weak."
20834 this.meterLabel = "Password strength:";
20835 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
20836 this.meterClass = [
20837 "roo-password-meter-tooweak",
20838 "roo-password-meter-weak",
20839 "roo-password-meter-medium",
20840 "roo-password-meter-strong",
20841 "roo-password-meter-grey"
20846 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
20849 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
20851 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
20853 * PwdEmpty: "Please type a password, and then retype it to confirm.",
20854 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
20855 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
20856 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
20857 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
20858 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
20859 * LNInPwd: "Your password can't contain your last name. Please type a different password."
20869 * @cfg {String/Object} Label for the strength meter (defaults to
20870 * 'Password strength:')
20875 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
20876 * ['Weak', 'Medium', 'Strong'])
20879 pwdStrengths: false,
20892 initEvents: function ()
20894 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
20896 if (this.el.is('input[type=password]') && Roo.isSafari) {
20897 this.el.on('keydown', this.SafariOnKeyDown, this);
20900 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
20903 onRender: function (ct, position)
20905 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
20906 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
20907 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
20909 this.trigger.createChild({
20914 cls: 'roo-password-meter-grey col-xs-12',
20917 //width: this.meterWidth + 'px'
20921 cls: 'roo-password-meter-text'
20927 if (this.hideTrigger) {
20928 this.trigger.setDisplayed(false);
20930 this.setSize(this.width || '', this.height || '');
20933 onDestroy: function ()
20935 if (this.trigger) {
20936 this.trigger.removeAllListeners();
20937 this.trigger.remove();
20940 this.wrap.remove();
20942 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
20945 checkStrength: function ()
20947 var pwd = this.inputEl().getValue();
20948 if (pwd == this._lastPwd) {
20953 if (this.ClientSideStrongPassword(pwd)) {
20955 } else if (this.ClientSideMediumPassword(pwd)) {
20957 } else if (this.ClientSideWeakPassword(pwd)) {
20963 Roo.log('strength1: ' + strength);
20965 //var pm = this.trigger.child('div/div/div').dom;
20966 var pm = this.trigger.child('div/div');
20967 pm.removeClass(this.meterClass);
20968 pm.addClass(this.meterClass[strength]);
20971 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
20973 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
20975 this._lastPwd = pwd;
20979 Roo.bootstrap.SecurePass.superclass.reset.call(this);
20981 this._lastPwd = '';
20983 var pm = this.trigger.child('div/div');
20984 pm.removeClass(this.meterClass);
20985 pm.addClass('roo-password-meter-grey');
20988 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
20991 this.inputEl().dom.type='password';
20994 validateValue: function (value)
20997 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21000 if (value.length == 0) {
21001 if (this.allowBlank) {
21002 this.clearInvalid();
21006 this.markInvalid(this.errors.PwdEmpty);
21007 this.errorMsg = this.errors.PwdEmpty;
21015 if ('[\x21-\x7e]*'.match(value)) {
21016 this.markInvalid(this.errors.PwdBadChar);
21017 this.errorMsg = this.errors.PwdBadChar;
21020 if (value.length < 6) {
21021 this.markInvalid(this.errors.PwdShort);
21022 this.errorMsg = this.errors.PwdShort;
21025 if (value.length > 16) {
21026 this.markInvalid(this.errors.PwdLong);
21027 this.errorMsg = this.errors.PwdLong;
21031 if (this.ClientSideStrongPassword(value)) {
21033 } else if (this.ClientSideMediumPassword(value)) {
21035 } else if (this.ClientSideWeakPassword(value)) {
21042 if (strength < 2) {
21043 //this.markInvalid(this.errors.TooWeak);
21044 this.errorMsg = this.errors.TooWeak;
21049 console.log('strength2: ' + strength);
21051 //var pm = this.trigger.child('div/div/div').dom;
21053 var pm = this.trigger.child('div/div');
21054 pm.removeClass(this.meterClass);
21055 pm.addClass(this.meterClass[strength]);
21057 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21059 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21061 this.errorMsg = '';
21065 CharacterSetChecks: function (type)
21068 this.fResult = false;
21071 isctype: function (character, type)
21074 case this.kCapitalLetter:
21075 if (character >= 'A' && character <= 'Z') {
21080 case this.kSmallLetter:
21081 if (character >= 'a' && character <= 'z') {
21087 if (character >= '0' && character <= '9') {
21092 case this.kPunctuation:
21093 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21104 IsLongEnough: function (pwd, size)
21106 return !(pwd == null || isNaN(size) || pwd.length < size);
21109 SpansEnoughCharacterSets: function (word, nb)
21111 if (!this.IsLongEnough(word, nb))
21116 var characterSetChecks = new Array(
21117 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21118 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21121 for (var index = 0; index < word.length; ++index) {
21122 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21123 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21124 characterSetChecks[nCharSet].fResult = true;
21131 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21132 if (characterSetChecks[nCharSet].fResult) {
21137 if (nCharSets < nb) {
21143 ClientSideStrongPassword: function (pwd)
21145 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21148 ClientSideMediumPassword: function (pwd)
21150 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21153 ClientSideWeakPassword: function (pwd)
21155 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21158 })//<script type="text/javascript">
21161 * Based Ext JS Library 1.1.1
21162 * Copyright(c) 2006-2007, Ext JS, LLC.
21168 * @class Roo.HtmlEditorCore
21169 * @extends Roo.Component
21170 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21172 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21175 Roo.HtmlEditorCore = function(config){
21178 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21183 * @event initialize
21184 * Fires when the editor is fully initialized (including the iframe)
21185 * @param {Roo.HtmlEditorCore} this
21190 * Fires when the editor is first receives the focus. Any insertion must wait
21191 * until after this event.
21192 * @param {Roo.HtmlEditorCore} this
21196 * @event beforesync
21197 * Fires before the textarea is updated with content from the editor iframe. Return false
21198 * to cancel the sync.
21199 * @param {Roo.HtmlEditorCore} this
21200 * @param {String} html
21204 * @event beforepush
21205 * Fires before the iframe editor is updated with content from the textarea. Return false
21206 * to cancel the push.
21207 * @param {Roo.HtmlEditorCore} this
21208 * @param {String} html
21213 * Fires when the textarea is updated with content from the editor iframe.
21214 * @param {Roo.HtmlEditorCore} this
21215 * @param {String} html
21220 * Fires when the iframe editor is updated with content from the textarea.
21221 * @param {Roo.HtmlEditorCore} this
21222 * @param {String} html
21227 * @event editorevent
21228 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21229 * @param {Roo.HtmlEditorCore} this
21235 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21237 // defaults : white / black...
21238 this.applyBlacklists();
21245 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21249 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21255 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21260 * @cfg {Number} height (in pixels)
21264 * @cfg {Number} width (in pixels)
21269 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21272 stylesheets: false,
21277 // private properties
21278 validationEvent : false,
21280 initialized : false,
21282 sourceEditMode : false,
21283 onFocus : Roo.emptyFn,
21285 hideMode:'offsets',
21289 // blacklist + whitelisted elements..
21296 * Protected method that will not generally be called directly. It
21297 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21298 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21300 getDocMarkup : function(){
21304 // inherit styels from page...??
21305 if (this.stylesheets === false) {
21307 Roo.get(document.head).select('style').each(function(node) {
21308 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21311 Roo.get(document.head).select('link').each(function(node) {
21312 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21315 } else if (!this.stylesheets.length) {
21317 st = '<style type="text/css">' +
21318 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21321 st = '<style type="text/css">' +
21326 st += '<style type="text/css">' +
21327 'IMG { cursor: pointer } ' +
21330 var cls = 'roo-htmleditor-body';
21332 if(this.bodyCls.length){
21333 cls += ' ' + this.bodyCls;
21336 return '<html><head>' + st +
21337 //<style type="text/css">' +
21338 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21340 ' </head><body class="' + cls + '"></body></html>';
21344 onRender : function(ct, position)
21347 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21348 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21351 this.el.dom.style.border = '0 none';
21352 this.el.dom.setAttribute('tabIndex', -1);
21353 this.el.addClass('x-hidden hide');
21357 if(Roo.isIE){ // fix IE 1px bogus margin
21358 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21362 this.frameId = Roo.id();
21366 var iframe = this.owner.wrap.createChild({
21368 cls: 'form-control', // bootstrap..
21370 name: this.frameId,
21371 frameBorder : 'no',
21372 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21377 this.iframe = iframe.dom;
21379 this.assignDocWin();
21381 this.doc.designMode = 'on';
21384 this.doc.write(this.getDocMarkup());
21388 var task = { // must defer to wait for browser to be ready
21390 //console.log("run task?" + this.doc.readyState);
21391 this.assignDocWin();
21392 if(this.doc.body || this.doc.readyState == 'complete'){
21394 this.doc.designMode="on";
21398 Roo.TaskMgr.stop(task);
21399 this.initEditor.defer(10, this);
21406 Roo.TaskMgr.start(task);
21411 onResize : function(w, h)
21413 Roo.log('resize: ' +w + ',' + h );
21414 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21418 if(typeof w == 'number'){
21420 this.iframe.style.width = w + 'px';
21422 if(typeof h == 'number'){
21424 this.iframe.style.height = h + 'px';
21426 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21433 * Toggles the editor between standard and source edit mode.
21434 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21436 toggleSourceEdit : function(sourceEditMode){
21438 this.sourceEditMode = sourceEditMode === true;
21440 if(this.sourceEditMode){
21442 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21445 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21446 //this.iframe.className = '';
21449 //this.setSize(this.owner.wrap.getSize());
21450 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21457 * Protected method that will not generally be called directly. If you need/want
21458 * custom HTML cleanup, this is the method you should override.
21459 * @param {String} html The HTML to be cleaned
21460 * return {String} The cleaned HTML
21462 cleanHtml : function(html){
21463 html = String(html);
21464 if(html.length > 5){
21465 if(Roo.isSafari){ // strip safari nonsense
21466 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21469 if(html == ' '){
21476 * HTML Editor -> Textarea
21477 * Protected method that will not generally be called directly. Syncs the contents
21478 * of the editor iframe with the textarea.
21480 syncValue : function(){
21481 if(this.initialized){
21482 var bd = (this.doc.body || this.doc.documentElement);
21483 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21484 var html = bd.innerHTML;
21486 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21487 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21489 html = '<div style="'+m[0]+'">' + html + '</div>';
21492 html = this.cleanHtml(html);
21493 // fix up the special chars.. normaly like back quotes in word...
21494 // however we do not want to do this with chinese..
21495 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21496 var cc = b.charCodeAt();
21498 (cc >= 0x4E00 && cc < 0xA000 ) ||
21499 (cc >= 0x3400 && cc < 0x4E00 ) ||
21500 (cc >= 0xf900 && cc < 0xfb00 )
21506 if(this.owner.fireEvent('beforesync', this, html) !== false){
21507 this.el.dom.value = html;
21508 this.owner.fireEvent('sync', this, html);
21514 * Protected method that will not generally be called directly. Pushes the value of the textarea
21515 * into the iframe editor.
21517 pushValue : function(){
21518 if(this.initialized){
21519 var v = this.el.dom.value.trim();
21521 // if(v.length < 1){
21525 if(this.owner.fireEvent('beforepush', this, v) !== false){
21526 var d = (this.doc.body || this.doc.documentElement);
21528 this.cleanUpPaste();
21529 this.el.dom.value = d.innerHTML;
21530 this.owner.fireEvent('push', this, v);
21536 deferFocus : function(){
21537 this.focus.defer(10, this);
21541 focus : function(){
21542 if(this.win && !this.sourceEditMode){
21549 assignDocWin: function()
21551 var iframe = this.iframe;
21554 this.doc = iframe.contentWindow.document;
21555 this.win = iframe.contentWindow;
21557 // if (!Roo.get(this.frameId)) {
21560 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21561 // this.win = Roo.get(this.frameId).dom.contentWindow;
21563 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21567 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21568 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21573 initEditor : function(){
21574 //console.log("INIT EDITOR");
21575 this.assignDocWin();
21579 this.doc.designMode="on";
21581 this.doc.write(this.getDocMarkup());
21584 var dbody = (this.doc.body || this.doc.documentElement);
21585 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21586 // this copies styles from the containing element into thsi one..
21587 // not sure why we need all of this..
21588 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21590 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21591 //ss['background-attachment'] = 'fixed'; // w3c
21592 dbody.bgProperties = 'fixed'; // ie
21593 //Roo.DomHelper.applyStyles(dbody, ss);
21594 Roo.EventManager.on(this.doc, {
21595 //'mousedown': this.onEditorEvent,
21596 'mouseup': this.onEditorEvent,
21597 'dblclick': this.onEditorEvent,
21598 'click': this.onEditorEvent,
21599 'keyup': this.onEditorEvent,
21604 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21606 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21607 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21609 this.initialized = true;
21611 this.owner.fireEvent('initialize', this);
21616 onDestroy : function(){
21622 //for (var i =0; i < this.toolbars.length;i++) {
21623 // // fixme - ask toolbars for heights?
21624 // this.toolbars[i].onDestroy();
21627 //this.wrap.dom.innerHTML = '';
21628 //this.wrap.remove();
21633 onFirstFocus : function(){
21635 this.assignDocWin();
21638 this.activated = true;
21641 if(Roo.isGecko){ // prevent silly gecko errors
21643 var s = this.win.getSelection();
21644 if(!s.focusNode || s.focusNode.nodeType != 3){
21645 var r = s.getRangeAt(0);
21646 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21651 this.execCmd('useCSS', true);
21652 this.execCmd('styleWithCSS', false);
21655 this.owner.fireEvent('activate', this);
21659 adjustFont: function(btn){
21660 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21661 //if(Roo.isSafari){ // safari
21664 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21665 if(Roo.isSafari){ // safari
21666 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21667 v = (v < 10) ? 10 : v;
21668 v = (v > 48) ? 48 : v;
21669 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21674 v = Math.max(1, v+adjust);
21676 this.execCmd('FontSize', v );
21679 onEditorEvent : function(e)
21681 this.owner.fireEvent('editorevent', this, e);
21682 // this.updateToolbar();
21683 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21686 insertTag : function(tg)
21688 // could be a bit smarter... -> wrap the current selected tRoo..
21689 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21691 range = this.createRange(this.getSelection());
21692 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21693 wrappingNode.appendChild(range.extractContents());
21694 range.insertNode(wrappingNode);
21701 this.execCmd("formatblock", tg);
21705 insertText : function(txt)
21709 var range = this.createRange();
21710 range.deleteContents();
21711 //alert(Sender.getAttribute('label'));
21713 range.insertNode(this.doc.createTextNode(txt));
21719 * Executes a Midas editor command on the editor document and performs necessary focus and
21720 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21721 * @param {String} cmd The Midas command
21722 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21724 relayCmd : function(cmd, value){
21726 this.execCmd(cmd, value);
21727 this.owner.fireEvent('editorevent', this);
21728 //this.updateToolbar();
21729 this.owner.deferFocus();
21733 * Executes a Midas editor command directly on the editor document.
21734 * For visual commands, you should use {@link #relayCmd} instead.
21735 * <b>This should only be called after the editor is initialized.</b>
21736 * @param {String} cmd The Midas command
21737 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21739 execCmd : function(cmd, value){
21740 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21747 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21749 * @param {String} text | dom node..
21751 insertAtCursor : function(text)
21754 if(!this.activated){
21760 var r = this.doc.selection.createRange();
21771 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21775 // from jquery ui (MIT licenced)
21777 var win = this.win;
21779 if (win.getSelection && win.getSelection().getRangeAt) {
21780 range = win.getSelection().getRangeAt(0);
21781 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21782 range.insertNode(node);
21783 } else if (win.document.selection && win.document.selection.createRange) {
21784 // no firefox support
21785 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21786 win.document.selection.createRange().pasteHTML(txt);
21788 // no firefox support
21789 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21790 this.execCmd('InsertHTML', txt);
21799 mozKeyPress : function(e){
21801 var c = e.getCharCode(), cmd;
21804 c = String.fromCharCode(c).toLowerCase();
21818 this.cleanUpPaste.defer(100, this);
21826 e.preventDefault();
21834 fixKeys : function(){ // load time branching for fastest keydown performance
21836 return function(e){
21837 var k = e.getKey(), r;
21840 r = this.doc.selection.createRange();
21843 r.pasteHTML('    ');
21850 r = this.doc.selection.createRange();
21852 var target = r.parentElement();
21853 if(!target || target.tagName.toLowerCase() != 'li'){
21855 r.pasteHTML('<br />');
21861 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21862 this.cleanUpPaste.defer(100, this);
21868 }else if(Roo.isOpera){
21869 return function(e){
21870 var k = e.getKey();
21874 this.execCmd('InsertHTML','    ');
21877 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21878 this.cleanUpPaste.defer(100, this);
21883 }else if(Roo.isSafari){
21884 return function(e){
21885 var k = e.getKey();
21889 this.execCmd('InsertText','\t');
21893 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21894 this.cleanUpPaste.defer(100, this);
21902 getAllAncestors: function()
21904 var p = this.getSelectedNode();
21907 a.push(p); // push blank onto stack..
21908 p = this.getParentElement();
21912 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
21916 a.push(this.doc.body);
21920 lastSelNode : false,
21923 getSelection : function()
21925 this.assignDocWin();
21926 return Roo.isIE ? this.doc.selection : this.win.getSelection();
21929 getSelectedNode: function()
21931 // this may only work on Gecko!!!
21933 // should we cache this!!!!
21938 var range = this.createRange(this.getSelection()).cloneRange();
21941 var parent = range.parentElement();
21943 var testRange = range.duplicate();
21944 testRange.moveToElementText(parent);
21945 if (testRange.inRange(range)) {
21948 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
21951 parent = parent.parentElement;
21956 // is ancestor a text element.
21957 var ac = range.commonAncestorContainer;
21958 if (ac.nodeType == 3) {
21959 ac = ac.parentNode;
21962 var ar = ac.childNodes;
21965 var other_nodes = [];
21966 var has_other_nodes = false;
21967 for (var i=0;i<ar.length;i++) {
21968 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
21971 // fullly contained node.
21973 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
21978 // probably selected..
21979 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
21980 other_nodes.push(ar[i]);
21984 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
21989 has_other_nodes = true;
21991 if (!nodes.length && other_nodes.length) {
21992 nodes= other_nodes;
21994 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22000 createRange: function(sel)
22002 // this has strange effects when using with
22003 // top toolbar - not sure if it's a great idea.
22004 //this.editor.contentWindow.focus();
22005 if (typeof sel != "undefined") {
22007 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22009 return this.doc.createRange();
22012 return this.doc.createRange();
22015 getParentElement: function()
22018 this.assignDocWin();
22019 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22021 var range = this.createRange(sel);
22024 var p = range.commonAncestorContainer;
22025 while (p.nodeType == 3) { // text node
22036 * Range intersection.. the hard stuff...
22040 * [ -- selected range --- ]
22044 * if end is before start or hits it. fail.
22045 * if start is after end or hits it fail.
22047 * if either hits (but other is outside. - then it's not
22053 // @see http://www.thismuchiknow.co.uk/?p=64.
22054 rangeIntersectsNode : function(range, node)
22056 var nodeRange = node.ownerDocument.createRange();
22058 nodeRange.selectNode(node);
22060 nodeRange.selectNodeContents(node);
22063 var rangeStartRange = range.cloneRange();
22064 rangeStartRange.collapse(true);
22066 var rangeEndRange = range.cloneRange();
22067 rangeEndRange.collapse(false);
22069 var nodeStartRange = nodeRange.cloneRange();
22070 nodeStartRange.collapse(true);
22072 var nodeEndRange = nodeRange.cloneRange();
22073 nodeEndRange.collapse(false);
22075 return rangeStartRange.compareBoundaryPoints(
22076 Range.START_TO_START, nodeEndRange) == -1 &&
22077 rangeEndRange.compareBoundaryPoints(
22078 Range.START_TO_START, nodeStartRange) == 1;
22082 rangeCompareNode : function(range, node)
22084 var nodeRange = node.ownerDocument.createRange();
22086 nodeRange.selectNode(node);
22088 nodeRange.selectNodeContents(node);
22092 range.collapse(true);
22094 nodeRange.collapse(true);
22096 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22097 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22099 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22101 var nodeIsBefore = ss == 1;
22102 var nodeIsAfter = ee == -1;
22104 if (nodeIsBefore && nodeIsAfter) {
22107 if (!nodeIsBefore && nodeIsAfter) {
22108 return 1; //right trailed.
22111 if (nodeIsBefore && !nodeIsAfter) {
22112 return 2; // left trailed.
22118 // private? - in a new class?
22119 cleanUpPaste : function()
22121 // cleans up the whole document..
22122 Roo.log('cleanuppaste');
22124 this.cleanUpChildren(this.doc.body);
22125 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22126 if (clean != this.doc.body.innerHTML) {
22127 this.doc.body.innerHTML = clean;
22132 cleanWordChars : function(input) {// change the chars to hex code
22133 var he = Roo.HtmlEditorCore;
22135 var output = input;
22136 Roo.each(he.swapCodes, function(sw) {
22137 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22139 output = output.replace(swapper, sw[1]);
22146 cleanUpChildren : function (n)
22148 if (!n.childNodes.length) {
22151 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22152 this.cleanUpChild(n.childNodes[i]);
22159 cleanUpChild : function (node)
22162 //console.log(node);
22163 if (node.nodeName == "#text") {
22164 // clean up silly Windows -- stuff?
22167 if (node.nodeName == "#comment") {
22168 node.parentNode.removeChild(node);
22169 // clean up silly Windows -- stuff?
22172 var lcname = node.tagName.toLowerCase();
22173 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22174 // whitelist of tags..
22176 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22178 node.parentNode.removeChild(node);
22183 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22185 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22186 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22188 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22189 // remove_keep_children = true;
22192 if (remove_keep_children) {
22193 this.cleanUpChildren(node);
22194 // inserts everything just before this node...
22195 while (node.childNodes.length) {
22196 var cn = node.childNodes[0];
22197 node.removeChild(cn);
22198 node.parentNode.insertBefore(cn, node);
22200 node.parentNode.removeChild(node);
22204 if (!node.attributes || !node.attributes.length) {
22205 this.cleanUpChildren(node);
22209 function cleanAttr(n,v)
22212 if (v.match(/^\./) || v.match(/^\//)) {
22215 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22218 if (v.match(/^#/)) {
22221 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22222 node.removeAttribute(n);
22226 var cwhite = this.cwhite;
22227 var cblack = this.cblack;
22229 function cleanStyle(n,v)
22231 if (v.match(/expression/)) { //XSS?? should we even bother..
22232 node.removeAttribute(n);
22236 var parts = v.split(/;/);
22239 Roo.each(parts, function(p) {
22240 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22244 var l = p.split(':').shift().replace(/\s+/g,'');
22245 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22247 if ( cwhite.length && cblack.indexOf(l) > -1) {
22248 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22249 //node.removeAttribute(n);
22253 // only allow 'c whitelisted system attributes'
22254 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22255 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22256 //node.removeAttribute(n);
22266 if (clean.length) {
22267 node.setAttribute(n, clean.join(';'));
22269 node.removeAttribute(n);
22275 for (var i = node.attributes.length-1; i > -1 ; i--) {
22276 var a = node.attributes[i];
22279 if (a.name.toLowerCase().substr(0,2)=='on') {
22280 node.removeAttribute(a.name);
22283 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22284 node.removeAttribute(a.name);
22287 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22288 cleanAttr(a.name,a.value); // fixme..
22291 if (a.name == 'style') {
22292 cleanStyle(a.name,a.value);
22295 /// clean up MS crap..
22296 // tecnically this should be a list of valid class'es..
22299 if (a.name == 'class') {
22300 if (a.value.match(/^Mso/)) {
22301 node.className = '';
22304 if (a.value.match(/^body$/)) {
22305 node.className = '';
22316 this.cleanUpChildren(node);
22322 * Clean up MS wordisms...
22324 cleanWord : function(node)
22329 this.cleanWord(this.doc.body);
22332 if (node.nodeName == "#text") {
22333 // clean up silly Windows -- stuff?
22336 if (node.nodeName == "#comment") {
22337 node.parentNode.removeChild(node);
22338 // clean up silly Windows -- stuff?
22342 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22343 node.parentNode.removeChild(node);
22347 // remove - but keep children..
22348 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22349 while (node.childNodes.length) {
22350 var cn = node.childNodes[0];
22351 node.removeChild(cn);
22352 node.parentNode.insertBefore(cn, node);
22354 node.parentNode.removeChild(node);
22355 this.iterateChildren(node, this.cleanWord);
22359 if (node.className.length) {
22361 var cn = node.className.split(/\W+/);
22363 Roo.each(cn, function(cls) {
22364 if (cls.match(/Mso[a-zA-Z]+/)) {
22369 node.className = cna.length ? cna.join(' ') : '';
22371 node.removeAttribute("class");
22375 if (node.hasAttribute("lang")) {
22376 node.removeAttribute("lang");
22379 if (node.hasAttribute("style")) {
22381 var styles = node.getAttribute("style").split(";");
22383 Roo.each(styles, function(s) {
22384 if (!s.match(/:/)) {
22387 var kv = s.split(":");
22388 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22391 // what ever is left... we allow.
22394 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22395 if (!nstyle.length) {
22396 node.removeAttribute('style');
22399 this.iterateChildren(node, this.cleanWord);
22405 * iterateChildren of a Node, calling fn each time, using this as the scole..
22406 * @param {DomNode} node node to iterate children of.
22407 * @param {Function} fn method of this class to call on each item.
22409 iterateChildren : function(node, fn)
22411 if (!node.childNodes.length) {
22414 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22415 fn.call(this, node.childNodes[i])
22421 * cleanTableWidths.
22423 * Quite often pasting from word etc.. results in tables with column and widths.
22424 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22427 cleanTableWidths : function(node)
22432 this.cleanTableWidths(this.doc.body);
22437 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22440 Roo.log(node.tagName);
22441 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22442 this.iterateChildren(node, this.cleanTableWidths);
22445 if (node.hasAttribute('width')) {
22446 node.removeAttribute('width');
22450 if (node.hasAttribute("style")) {
22453 var styles = node.getAttribute("style").split(";");
22455 Roo.each(styles, function(s) {
22456 if (!s.match(/:/)) {
22459 var kv = s.split(":");
22460 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22463 // what ever is left... we allow.
22466 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22467 if (!nstyle.length) {
22468 node.removeAttribute('style');
22472 this.iterateChildren(node, this.cleanTableWidths);
22480 domToHTML : function(currentElement, depth, nopadtext) {
22482 depth = depth || 0;
22483 nopadtext = nopadtext || false;
22485 if (!currentElement) {
22486 return this.domToHTML(this.doc.body);
22489 //Roo.log(currentElement);
22491 var allText = false;
22492 var nodeName = currentElement.nodeName;
22493 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22495 if (nodeName == '#text') {
22497 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22502 if (nodeName != 'BODY') {
22505 // Prints the node tagName, such as <A>, <IMG>, etc
22508 for(i = 0; i < currentElement.attributes.length;i++) {
22510 var aname = currentElement.attributes.item(i).name;
22511 if (!currentElement.attributes.item(i).value.length) {
22514 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22517 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22526 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22529 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22534 // Traverse the tree
22536 var currentElementChild = currentElement.childNodes.item(i);
22537 var allText = true;
22538 var innerHTML = '';
22540 while (currentElementChild) {
22541 // Formatting code (indent the tree so it looks nice on the screen)
22542 var nopad = nopadtext;
22543 if (lastnode == 'SPAN') {
22547 if (currentElementChild.nodeName == '#text') {
22548 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22549 toadd = nopadtext ? toadd : toadd.trim();
22550 if (!nopad && toadd.length > 80) {
22551 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22553 innerHTML += toadd;
22556 currentElementChild = currentElement.childNodes.item(i);
22562 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22564 // Recursively traverse the tree structure of the child node
22565 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22566 lastnode = currentElementChild.nodeName;
22568 currentElementChild=currentElement.childNodes.item(i);
22574 // The remaining code is mostly for formatting the tree
22575 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22580 ret+= "</"+tagName+">";
22586 applyBlacklists : function()
22588 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22589 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22593 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22594 if (b.indexOf(tag) > -1) {
22597 this.white.push(tag);
22601 Roo.each(w, function(tag) {
22602 if (b.indexOf(tag) > -1) {
22605 if (this.white.indexOf(tag) > -1) {
22608 this.white.push(tag);
22613 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22614 if (w.indexOf(tag) > -1) {
22617 this.black.push(tag);
22621 Roo.each(b, function(tag) {
22622 if (w.indexOf(tag) > -1) {
22625 if (this.black.indexOf(tag) > -1) {
22628 this.black.push(tag);
22633 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22634 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22638 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22639 if (b.indexOf(tag) > -1) {
22642 this.cwhite.push(tag);
22646 Roo.each(w, function(tag) {
22647 if (b.indexOf(tag) > -1) {
22650 if (this.cwhite.indexOf(tag) > -1) {
22653 this.cwhite.push(tag);
22658 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22659 if (w.indexOf(tag) > -1) {
22662 this.cblack.push(tag);
22666 Roo.each(b, function(tag) {
22667 if (w.indexOf(tag) > -1) {
22670 if (this.cblack.indexOf(tag) > -1) {
22673 this.cblack.push(tag);
22678 setStylesheets : function(stylesheets)
22680 if(typeof(stylesheets) == 'string'){
22681 Roo.get(this.iframe.contentDocument.head).createChild({
22683 rel : 'stylesheet',
22692 Roo.each(stylesheets, function(s) {
22697 Roo.get(_this.iframe.contentDocument.head).createChild({
22699 rel : 'stylesheet',
22708 removeStylesheets : function()
22712 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22717 setStyle : function(style)
22719 Roo.get(this.iframe.contentDocument.head).createChild({
22728 // hide stuff that is not compatible
22742 * @event specialkey
22746 * @cfg {String} fieldClass @hide
22749 * @cfg {String} focusClass @hide
22752 * @cfg {String} autoCreate @hide
22755 * @cfg {String} inputType @hide
22758 * @cfg {String} invalidClass @hide
22761 * @cfg {String} invalidText @hide
22764 * @cfg {String} msgFx @hide
22767 * @cfg {String} validateOnBlur @hide
22771 Roo.HtmlEditorCore.white = [
22772 'area', 'br', 'img', 'input', 'hr', 'wbr',
22774 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22775 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22776 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22777 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22778 'table', 'ul', 'xmp',
22780 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22783 'dir', 'menu', 'ol', 'ul', 'dl',
22789 Roo.HtmlEditorCore.black = [
22790 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22792 'base', 'basefont', 'bgsound', 'blink', 'body',
22793 'frame', 'frameset', 'head', 'html', 'ilayer',
22794 'iframe', 'layer', 'link', 'meta', 'object',
22795 'script', 'style' ,'title', 'xml' // clean later..
22797 Roo.HtmlEditorCore.clean = [
22798 'script', 'style', 'title', 'xml'
22800 Roo.HtmlEditorCore.remove = [
22805 Roo.HtmlEditorCore.ablack = [
22809 Roo.HtmlEditorCore.aclean = [
22810 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22814 Roo.HtmlEditorCore.pwhite= [
22815 'http', 'https', 'mailto'
22818 // white listed style attributes.
22819 Roo.HtmlEditorCore.cwhite= [
22820 // 'text-align', /// default is to allow most things..
22826 // black listed style attributes.
22827 Roo.HtmlEditorCore.cblack= [
22828 // 'font-size' -- this can be set by the project
22832 Roo.HtmlEditorCore.swapCodes =[
22851 * @class Roo.bootstrap.HtmlEditor
22852 * @extends Roo.bootstrap.TextArea
22853 * Bootstrap HtmlEditor class
22856 * Create a new HtmlEditor
22857 * @param {Object} config The config object
22860 Roo.bootstrap.HtmlEditor = function(config){
22861 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22862 if (!this.toolbars) {
22863 this.toolbars = [];
22866 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22869 * @event initialize
22870 * Fires when the editor is fully initialized (including the iframe)
22871 * @param {HtmlEditor} this
22876 * Fires when the editor is first receives the focus. Any insertion must wait
22877 * until after this event.
22878 * @param {HtmlEditor} this
22882 * @event beforesync
22883 * Fires before the textarea is updated with content from the editor iframe. Return false
22884 * to cancel the sync.
22885 * @param {HtmlEditor} this
22886 * @param {String} html
22890 * @event beforepush
22891 * Fires before the iframe editor is updated with content from the textarea. Return false
22892 * to cancel the push.
22893 * @param {HtmlEditor} this
22894 * @param {String} html
22899 * Fires when the textarea is updated with content from the editor iframe.
22900 * @param {HtmlEditor} this
22901 * @param {String} html
22906 * Fires when the iframe editor is updated with content from the textarea.
22907 * @param {HtmlEditor} this
22908 * @param {String} html
22912 * @event editmodechange
22913 * Fires when the editor switches edit modes
22914 * @param {HtmlEditor} this
22915 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
22917 editmodechange: true,
22919 * @event editorevent
22920 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22921 * @param {HtmlEditor} this
22925 * @event firstfocus
22926 * Fires when on first focus - needed by toolbars..
22927 * @param {HtmlEditor} this
22932 * Auto save the htmlEditor value as a file into Events
22933 * @param {HtmlEditor} this
22937 * @event savedpreview
22938 * preview the saved version of htmlEditor
22939 * @param {HtmlEditor} this
22946 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
22950 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
22955 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
22960 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22965 * @cfg {Number} height (in pixels)
22969 * @cfg {Number} width (in pixels)
22974 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22977 stylesheets: false,
22982 // private properties
22983 validationEvent : false,
22985 initialized : false,
22988 onFocus : Roo.emptyFn,
22990 hideMode:'offsets',
22992 tbContainer : false,
22994 toolbarContainer :function() {
22995 return this.wrap.select('.x-html-editor-tb',true).first();
22999 * Protected method that will not generally be called directly. It
23000 * is called when the editor creates its toolbar. Override this method if you need to
23001 * add custom toolbar buttons.
23002 * @param {HtmlEditor} editor
23004 createToolbar : function(){
23005 Roo.log('renewing');
23006 Roo.log("create toolbars");
23008 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23009 this.toolbars[0].render(this.toolbarContainer());
23013 // if (!editor.toolbars || !editor.toolbars.length) {
23014 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23017 // for (var i =0 ; i < editor.toolbars.length;i++) {
23018 // editor.toolbars[i] = Roo.factory(
23019 // typeof(editor.toolbars[i]) == 'string' ?
23020 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23021 // Roo.bootstrap.HtmlEditor);
23022 // editor.toolbars[i].init(editor);
23028 onRender : function(ct, position)
23030 // Roo.log("Call onRender: " + this.xtype);
23032 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23034 this.wrap = this.inputEl().wrap({
23035 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23038 this.editorcore.onRender(ct, position);
23040 if (this.resizable) {
23041 this.resizeEl = new Roo.Resizable(this.wrap, {
23045 minHeight : this.height,
23046 height: this.height,
23047 handles : this.resizable,
23050 resize : function(r, w, h) {
23051 _t.onResize(w,h); // -something
23057 this.createToolbar(this);
23060 if(!this.width && this.resizable){
23061 this.setSize(this.wrap.getSize());
23063 if (this.resizeEl) {
23064 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23065 // should trigger onReize..
23071 onResize : function(w, h)
23073 Roo.log('resize: ' +w + ',' + h );
23074 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23078 if(this.inputEl() ){
23079 if(typeof w == 'number'){
23080 var aw = w - this.wrap.getFrameWidth('lr');
23081 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23084 if(typeof h == 'number'){
23085 var tbh = -11; // fixme it needs to tool bar size!
23086 for (var i =0; i < this.toolbars.length;i++) {
23087 // fixme - ask toolbars for heights?
23088 tbh += this.toolbars[i].el.getHeight();
23089 //if (this.toolbars[i].footer) {
23090 // tbh += this.toolbars[i].footer.el.getHeight();
23098 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23099 ah -= 5; // knock a few pixes off for look..
23100 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23104 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23105 this.editorcore.onResize(ew,eh);
23110 * Toggles the editor between standard and source edit mode.
23111 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23113 toggleSourceEdit : function(sourceEditMode)
23115 this.editorcore.toggleSourceEdit(sourceEditMode);
23117 if(this.editorcore.sourceEditMode){
23118 Roo.log('editor - showing textarea');
23121 // Roo.log(this.syncValue());
23123 this.inputEl().removeClass(['hide', 'x-hidden']);
23124 this.inputEl().dom.removeAttribute('tabIndex');
23125 this.inputEl().focus();
23127 Roo.log('editor - hiding textarea');
23129 // Roo.log(this.pushValue());
23132 this.inputEl().addClass(['hide', 'x-hidden']);
23133 this.inputEl().dom.setAttribute('tabIndex', -1);
23134 //this.deferFocus();
23137 if(this.resizable){
23138 this.setSize(this.wrap.getSize());
23141 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23144 // private (for BoxComponent)
23145 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23147 // private (for BoxComponent)
23148 getResizeEl : function(){
23152 // private (for BoxComponent)
23153 getPositionEl : function(){
23158 initEvents : function(){
23159 this.originalValue = this.getValue();
23163 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23166 // markInvalid : Roo.emptyFn,
23168 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23171 // clearInvalid : Roo.emptyFn,
23173 setValue : function(v){
23174 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23175 this.editorcore.pushValue();
23180 deferFocus : function(){
23181 this.focus.defer(10, this);
23185 focus : function(){
23186 this.editorcore.focus();
23192 onDestroy : function(){
23198 for (var i =0; i < this.toolbars.length;i++) {
23199 // fixme - ask toolbars for heights?
23200 this.toolbars[i].onDestroy();
23203 this.wrap.dom.innerHTML = '';
23204 this.wrap.remove();
23209 onFirstFocus : function(){
23210 //Roo.log("onFirstFocus");
23211 this.editorcore.onFirstFocus();
23212 for (var i =0; i < this.toolbars.length;i++) {
23213 this.toolbars[i].onFirstFocus();
23219 syncValue : function()
23221 this.editorcore.syncValue();
23224 pushValue : function()
23226 this.editorcore.pushValue();
23230 // hide stuff that is not compatible
23244 * @event specialkey
23248 * @cfg {String} fieldClass @hide
23251 * @cfg {String} focusClass @hide
23254 * @cfg {String} autoCreate @hide
23257 * @cfg {String} inputType @hide
23260 * @cfg {String} invalidClass @hide
23263 * @cfg {String} invalidText @hide
23266 * @cfg {String} msgFx @hide
23269 * @cfg {String} validateOnBlur @hide
23278 Roo.namespace('Roo.bootstrap.htmleditor');
23280 * @class Roo.bootstrap.HtmlEditorToolbar1
23285 new Roo.bootstrap.HtmlEditor({
23288 new Roo.bootstrap.HtmlEditorToolbar1({
23289 disable : { fonts: 1 , format: 1, ..., ... , ...],
23295 * @cfg {Object} disable List of elements to disable..
23296 * @cfg {Array} btns List of additional buttons.
23300 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23303 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23306 Roo.apply(this, config);
23308 // default disabled, based on 'good practice'..
23309 this.disable = this.disable || {};
23310 Roo.applyIf(this.disable, {
23313 specialElements : true
23315 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23317 this.editor = config.editor;
23318 this.editorcore = config.editor.editorcore;
23320 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23322 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23323 // dont call parent... till later.
23325 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23330 editorcore : false,
23335 "h1","h2","h3","h4","h5","h6",
23337 "abbr", "acronym", "address", "cite", "samp", "var",
23341 onRender : function(ct, position)
23343 // Roo.log("Call onRender: " + this.xtype);
23345 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23347 this.el.dom.style.marginBottom = '0';
23349 var editorcore = this.editorcore;
23350 var editor= this.editor;
23353 var btn = function(id,cmd , toggle, handler, html){
23355 var event = toggle ? 'toggle' : 'click';
23360 xns: Roo.bootstrap,
23363 enableToggle:toggle !== false,
23365 pressed : toggle ? false : null,
23368 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23369 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23375 // var cb_box = function...
23380 xns: Roo.bootstrap,
23381 glyphicon : 'font',
23385 xns: Roo.bootstrap,
23389 Roo.each(this.formats, function(f) {
23390 style.menu.items.push({
23392 xns: Roo.bootstrap,
23393 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23398 editorcore.insertTag(this.tagname);
23405 children.push(style);
23407 btn('bold',false,true);
23408 btn('italic',false,true);
23409 btn('align-left', 'justifyleft',true);
23410 btn('align-center', 'justifycenter',true);
23411 btn('align-right' , 'justifyright',true);
23412 btn('link', false, false, function(btn) {
23413 //Roo.log("create link?");
23414 var url = prompt(this.createLinkText, this.defaultLinkValue);
23415 if(url && url != 'http:/'+'/'){
23416 this.editorcore.relayCmd('createlink', url);
23419 btn('list','insertunorderedlist',true);
23420 btn('pencil', false,true, function(btn){
23422 this.toggleSourceEdit(btn.pressed);
23425 if (this.editor.btns.length > 0) {
23426 for (var i = 0; i<this.editor.btns.length; i++) {
23427 children.push(this.editor.btns[i]);
23435 xns: Roo.bootstrap,
23440 xns: Roo.bootstrap,
23445 cog.menu.items.push({
23447 xns: Roo.bootstrap,
23448 html : Clean styles,
23453 editorcore.insertTag(this.tagname);
23462 this.xtype = 'NavSimplebar';
23464 for(var i=0;i< children.length;i++) {
23466 this.buttons.add(this.addxtypeChild(children[i]));
23470 editor.on('editorevent', this.updateToolbar, this);
23472 onBtnClick : function(id)
23474 this.editorcore.relayCmd(id);
23475 this.editorcore.focus();
23479 * Protected method that will not generally be called directly. It triggers
23480 * a toolbar update by reading the markup state of the current selection in the editor.
23482 updateToolbar: function(){
23484 if(!this.editorcore.activated){
23485 this.editor.onFirstFocus(); // is this neeed?
23489 var btns = this.buttons;
23490 var doc = this.editorcore.doc;
23491 btns.get('bold').setActive(doc.queryCommandState('bold'));
23492 btns.get('italic').setActive(doc.queryCommandState('italic'));
23493 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23495 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23496 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23497 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23499 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23500 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23503 var ans = this.editorcore.getAllAncestors();
23504 if (this.formatCombo) {
23507 var store = this.formatCombo.store;
23508 this.formatCombo.setValue("");
23509 for (var i =0; i < ans.length;i++) {
23510 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23512 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23520 // hides menus... - so this cant be on a menu...
23521 Roo.bootstrap.MenuMgr.hideAll();
23523 Roo.bootstrap.MenuMgr.hideAll();
23524 //this.editorsyncValue();
23526 onFirstFocus: function() {
23527 this.buttons.each(function(item){
23531 toggleSourceEdit : function(sourceEditMode){
23534 if(sourceEditMode){
23535 Roo.log("disabling buttons");
23536 this.buttons.each( function(item){
23537 if(item.cmd != 'pencil'){
23543 Roo.log("enabling buttons");
23544 if(this.editorcore.initialized){
23545 this.buttons.each( function(item){
23551 Roo.log("calling toggole on editor");
23552 // tell the editor that it's been pressed..
23553 this.editor.toggleSourceEdit(sourceEditMode);
23563 * @class Roo.bootstrap.Table.AbstractSelectionModel
23564 * @extends Roo.util.Observable
23565 * Abstract base class for grid SelectionModels. It provides the interface that should be
23566 * implemented by descendant classes. This class should not be directly instantiated.
23569 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23570 this.locked = false;
23571 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23575 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23576 /** @ignore Called by the grid automatically. Do not call directly. */
23577 init : function(grid){
23583 * Locks the selections.
23586 this.locked = true;
23590 * Unlocks the selections.
23592 unlock : function(){
23593 this.locked = false;
23597 * Returns true if the selections are locked.
23598 * @return {Boolean}
23600 isLocked : function(){
23601 return this.locked;
23605 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23606 * @class Roo.bootstrap.Table.RowSelectionModel
23607 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23608 * It supports multiple selections and keyboard selection/navigation.
23610 * @param {Object} config
23613 Roo.bootstrap.Table.RowSelectionModel = function(config){
23614 Roo.apply(this, config);
23615 this.selections = new Roo.util.MixedCollection(false, function(o){
23620 this.lastActive = false;
23624 * @event selectionchange
23625 * Fires when the selection changes
23626 * @param {SelectionModel} this
23628 "selectionchange" : true,
23630 * @event afterselectionchange
23631 * Fires after the selection changes (eg. by key press or clicking)
23632 * @param {SelectionModel} this
23634 "afterselectionchange" : true,
23636 * @event beforerowselect
23637 * Fires when a row is selected being selected, return false to cancel.
23638 * @param {SelectionModel} this
23639 * @param {Number} rowIndex The selected index
23640 * @param {Boolean} keepExisting False if other selections will be cleared
23642 "beforerowselect" : true,
23645 * Fires when a row is selected.
23646 * @param {SelectionModel} this
23647 * @param {Number} rowIndex The selected index
23648 * @param {Roo.data.Record} r The record
23650 "rowselect" : true,
23652 * @event rowdeselect
23653 * Fires when a row is deselected.
23654 * @param {SelectionModel} this
23655 * @param {Number} rowIndex The selected index
23657 "rowdeselect" : true
23659 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23660 this.locked = false;
23663 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23665 * @cfg {Boolean} singleSelect
23666 * True to allow selection of only one row at a time (defaults to false)
23668 singleSelect : false,
23671 initEvents : function()
23674 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23675 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23676 //}else{ // allow click to work like normal
23677 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23679 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23680 this.grid.on("rowclick", this.handleMouseDown, this);
23682 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23683 "up" : function(e){
23685 this.selectPrevious(e.shiftKey);
23686 }else if(this.last !== false && this.lastActive !== false){
23687 var last = this.last;
23688 this.selectRange(this.last, this.lastActive-1);
23689 this.grid.getView().focusRow(this.lastActive);
23690 if(last !== false){
23694 this.selectFirstRow();
23696 this.fireEvent("afterselectionchange", this);
23698 "down" : function(e){
23700 this.selectNext(e.shiftKey);
23701 }else if(this.last !== false && this.lastActive !== false){
23702 var last = this.last;
23703 this.selectRange(this.last, this.lastActive+1);
23704 this.grid.getView().focusRow(this.lastActive);
23705 if(last !== false){
23709 this.selectFirstRow();
23711 this.fireEvent("afterselectionchange", this);
23715 this.grid.store.on('load', function(){
23716 this.selections.clear();
23719 var view = this.grid.view;
23720 view.on("refresh", this.onRefresh, this);
23721 view.on("rowupdated", this.onRowUpdated, this);
23722 view.on("rowremoved", this.onRemove, this);
23727 onRefresh : function()
23729 var ds = this.grid.store, i, v = this.grid.view;
23730 var s = this.selections;
23731 s.each(function(r){
23732 if((i = ds.indexOfId(r.id)) != -1){
23741 onRemove : function(v, index, r){
23742 this.selections.remove(r);
23746 onRowUpdated : function(v, index, r){
23747 if(this.isSelected(r)){
23748 v.onRowSelect(index);
23754 * @param {Array} records The records to select
23755 * @param {Boolean} keepExisting (optional) True to keep existing selections
23757 selectRecords : function(records, keepExisting)
23760 this.clearSelections();
23762 var ds = this.grid.store;
23763 for(var i = 0, len = records.length; i < len; i++){
23764 this.selectRow(ds.indexOf(records[i]), true);
23769 * Gets the number of selected rows.
23772 getCount : function(){
23773 return this.selections.length;
23777 * Selects the first row in the grid.
23779 selectFirstRow : function(){
23784 * Select the last row.
23785 * @param {Boolean} keepExisting (optional) True to keep existing selections
23787 selectLastRow : function(keepExisting){
23788 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23789 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23793 * Selects the row immediately following the last selected row.
23794 * @param {Boolean} keepExisting (optional) True to keep existing selections
23796 selectNext : function(keepExisting)
23798 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23799 this.selectRow(this.last+1, keepExisting);
23800 this.grid.getView().focusRow(this.last);
23805 * Selects the row that precedes the last selected row.
23806 * @param {Boolean} keepExisting (optional) True to keep existing selections
23808 selectPrevious : function(keepExisting){
23810 this.selectRow(this.last-1, keepExisting);
23811 this.grid.getView().focusRow(this.last);
23816 * Returns the selected records
23817 * @return {Array} Array of selected records
23819 getSelections : function(){
23820 return [].concat(this.selections.items);
23824 * Returns the first selected record.
23827 getSelected : function(){
23828 return this.selections.itemAt(0);
23833 * Clears all selections.
23835 clearSelections : function(fast)
23841 var ds = this.grid.store;
23842 var s = this.selections;
23843 s.each(function(r){
23844 this.deselectRow(ds.indexOfId(r.id));
23848 this.selections.clear();
23855 * Selects all rows.
23857 selectAll : function(){
23861 this.selections.clear();
23862 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23863 this.selectRow(i, true);
23868 * Returns True if there is a selection.
23869 * @return {Boolean}
23871 hasSelection : function(){
23872 return this.selections.length > 0;
23876 * Returns True if the specified row is selected.
23877 * @param {Number/Record} record The record or index of the record to check
23878 * @return {Boolean}
23880 isSelected : function(index){
23881 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
23882 return (r && this.selections.key(r.id) ? true : false);
23886 * Returns True if the specified record id is selected.
23887 * @param {String} id The id of record to check
23888 * @return {Boolean}
23890 isIdSelected : function(id){
23891 return (this.selections.key(id) ? true : false);
23896 handleMouseDBClick : function(e, t){
23900 handleMouseDown : function(e, t)
23902 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
23903 if(this.isLocked() || rowIndex < 0 ){
23906 if(e.shiftKey && this.last !== false){
23907 var last = this.last;
23908 this.selectRange(last, rowIndex, e.ctrlKey);
23909 this.last = last; // reset the last
23913 var isSelected = this.isSelected(rowIndex);
23914 //Roo.log("select row:" + rowIndex);
23916 this.deselectRow(rowIndex);
23918 this.selectRow(rowIndex, true);
23922 if(e.button !== 0 && isSelected){
23923 alert('rowIndex 2: ' + rowIndex);
23924 view.focusRow(rowIndex);
23925 }else if(e.ctrlKey && isSelected){
23926 this.deselectRow(rowIndex);
23927 }else if(!isSelected){
23928 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
23929 view.focusRow(rowIndex);
23933 this.fireEvent("afterselectionchange", this);
23936 handleDragableRowClick : function(grid, rowIndex, e)
23938 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
23939 this.selectRow(rowIndex, false);
23940 grid.view.focusRow(rowIndex);
23941 this.fireEvent("afterselectionchange", this);
23946 * Selects multiple rows.
23947 * @param {Array} rows Array of the indexes of the row to select
23948 * @param {Boolean} keepExisting (optional) True to keep existing selections
23950 selectRows : function(rows, keepExisting){
23952 this.clearSelections();
23954 for(var i = 0, len = rows.length; i < len; i++){
23955 this.selectRow(rows[i], true);
23960 * Selects a range of rows. All rows in between startRow and endRow are also selected.
23961 * @param {Number} startRow The index of the first row in the range
23962 * @param {Number} endRow The index of the last row in the range
23963 * @param {Boolean} keepExisting (optional) True to retain existing selections
23965 selectRange : function(startRow, endRow, keepExisting){
23970 this.clearSelections();
23972 if(startRow <= endRow){
23973 for(var i = startRow; i <= endRow; i++){
23974 this.selectRow(i, true);
23977 for(var i = startRow; i >= endRow; i--){
23978 this.selectRow(i, true);
23984 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
23985 * @param {Number} startRow The index of the first row in the range
23986 * @param {Number} endRow The index of the last row in the range
23988 deselectRange : function(startRow, endRow, preventViewNotify){
23992 for(var i = startRow; i <= endRow; i++){
23993 this.deselectRow(i, preventViewNotify);
23999 * @param {Number} row The index of the row to select
24000 * @param {Boolean} keepExisting (optional) True to keep existing selections
24002 selectRow : function(index, keepExisting, preventViewNotify)
24004 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24007 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24008 if(!keepExisting || this.singleSelect){
24009 this.clearSelections();
24012 var r = this.grid.store.getAt(index);
24013 //console.log('selectRow - record id :' + r.id);
24015 this.selections.add(r);
24016 this.last = this.lastActive = index;
24017 if(!preventViewNotify){
24018 var proxy = new Roo.Element(
24019 this.grid.getRowDom(index)
24021 proxy.addClass('bg-info info');
24023 this.fireEvent("rowselect", this, index, r);
24024 this.fireEvent("selectionchange", this);
24030 * @param {Number} row The index of the row to deselect
24032 deselectRow : function(index, preventViewNotify)
24037 if(this.last == index){
24040 if(this.lastActive == index){
24041 this.lastActive = false;
24044 var r = this.grid.store.getAt(index);
24049 this.selections.remove(r);
24050 //.console.log('deselectRow - record id :' + r.id);
24051 if(!preventViewNotify){
24053 var proxy = new Roo.Element(
24054 this.grid.getRowDom(index)
24056 proxy.removeClass('bg-info info');
24058 this.fireEvent("rowdeselect", this, index);
24059 this.fireEvent("selectionchange", this);
24063 restoreLast : function(){
24065 this.last = this._last;
24070 acceptsNav : function(row, col, cm){
24071 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24075 onEditorKey : function(field, e){
24076 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24081 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24083 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24085 }else if(k == e.ENTER && !e.ctrlKey){
24089 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24091 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24093 }else if(k == e.ESC){
24097 g.startEditing(newCell[0], newCell[1]);
24103 * Ext JS Library 1.1.1
24104 * Copyright(c) 2006-2007, Ext JS, LLC.
24106 * Originally Released Under LGPL - original licence link has changed is not relivant.
24109 * <script type="text/javascript">
24113 * @class Roo.bootstrap.PagingToolbar
24114 * @extends Roo.bootstrap.NavSimplebar
24115 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24117 * Create a new PagingToolbar
24118 * @param {Object} config The config object
24119 * @param {Roo.data.Store} store
24121 Roo.bootstrap.PagingToolbar = function(config)
24123 // old args format still supported... - xtype is prefered..
24124 // created from xtype...
24126 this.ds = config.dataSource;
24128 if (config.store && !this.ds) {
24129 this.store= Roo.factory(config.store, Roo.data);
24130 this.ds = this.store;
24131 this.ds.xmodule = this.xmodule || false;
24134 this.toolbarItems = [];
24135 if (config.items) {
24136 this.toolbarItems = config.items;
24139 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24144 this.bind(this.ds);
24147 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24151 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24153 * @cfg {Roo.data.Store} dataSource
24154 * The underlying data store providing the paged data
24157 * @cfg {String/HTMLElement/Element} container
24158 * container The id or element that will contain the toolbar
24161 * @cfg {Boolean} displayInfo
24162 * True to display the displayMsg (defaults to false)
24165 * @cfg {Number} pageSize
24166 * The number of records to display per page (defaults to 20)
24170 * @cfg {String} displayMsg
24171 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24173 displayMsg : 'Displaying {0} - {1} of {2}',
24175 * @cfg {String} emptyMsg
24176 * The message to display when no records are found (defaults to "No data to display")
24178 emptyMsg : 'No data to display',
24180 * Customizable piece of the default paging text (defaults to "Page")
24183 beforePageText : "Page",
24185 * Customizable piece of the default paging text (defaults to "of %0")
24188 afterPageText : "of {0}",
24190 * Customizable piece of the default paging text (defaults to "First Page")
24193 firstText : "First Page",
24195 * Customizable piece of the default paging text (defaults to "Previous Page")
24198 prevText : "Previous Page",
24200 * Customizable piece of the default paging text (defaults to "Next Page")
24203 nextText : "Next Page",
24205 * Customizable piece of the default paging text (defaults to "Last Page")
24208 lastText : "Last Page",
24210 * Customizable piece of the default paging text (defaults to "Refresh")
24213 refreshText : "Refresh",
24217 onRender : function(ct, position)
24219 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24220 this.navgroup.parentId = this.id;
24221 this.navgroup.onRender(this.el, null);
24222 // add the buttons to the navgroup
24224 if(this.displayInfo){
24225 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24226 this.displayEl = this.el.select('.x-paging-info', true).first();
24227 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24228 // this.displayEl = navel.el.select('span',true).first();
24234 Roo.each(_this.buttons, function(e){ // this might need to use render????
24235 Roo.factory(e).onRender(_this.el, null);
24239 Roo.each(_this.toolbarItems, function(e) {
24240 _this.navgroup.addItem(e);
24244 this.first = this.navgroup.addItem({
24245 tooltip: this.firstText,
24247 icon : 'fa fa-backward',
24249 preventDefault: true,
24250 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24253 this.prev = this.navgroup.addItem({
24254 tooltip: this.prevText,
24256 icon : 'fa fa-step-backward',
24258 preventDefault: true,
24259 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24261 //this.addSeparator();
24264 var field = this.navgroup.addItem( {
24266 cls : 'x-paging-position',
24268 html : this.beforePageText +
24269 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24270 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24273 this.field = field.el.select('input', true).first();
24274 this.field.on("keydown", this.onPagingKeydown, this);
24275 this.field.on("focus", function(){this.dom.select();});
24278 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24279 //this.field.setHeight(18);
24280 //this.addSeparator();
24281 this.next = this.navgroup.addItem({
24282 tooltip: this.nextText,
24284 html : ' <i class="fa fa-step-forward">',
24286 preventDefault: true,
24287 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24289 this.last = this.navgroup.addItem({
24290 tooltip: this.lastText,
24291 icon : 'fa fa-forward',
24294 preventDefault: true,
24295 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24297 //this.addSeparator();
24298 this.loading = this.navgroup.addItem({
24299 tooltip: this.refreshText,
24300 icon: 'fa fa-refresh',
24301 preventDefault: true,
24302 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24308 updateInfo : function(){
24309 if(this.displayEl){
24310 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24311 var msg = count == 0 ?
24315 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24317 this.displayEl.update(msg);
24322 onLoad : function(ds, r, o)
24324 this.cursor = o.params ? o.params.start : 0;
24325 var d = this.getPageData(),
24330 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24331 this.field.dom.value = ap;
24332 this.first.setDisabled(ap == 1);
24333 this.prev.setDisabled(ap == 1);
24334 this.next.setDisabled(ap == ps);
24335 this.last.setDisabled(ap == ps);
24336 this.loading.enable();
24341 getPageData : function(){
24342 var total = this.ds.getTotalCount();
24345 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24346 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24351 onLoadError : function(){
24352 this.loading.enable();
24356 onPagingKeydown : function(e){
24357 var k = e.getKey();
24358 var d = this.getPageData();
24360 var v = this.field.dom.value, pageNum;
24361 if(!v || isNaN(pageNum = parseInt(v, 10))){
24362 this.field.dom.value = d.activePage;
24365 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24366 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24369 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))
24371 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24372 this.field.dom.value = pageNum;
24373 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24376 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24378 var v = this.field.dom.value, pageNum;
24379 var increment = (e.shiftKey) ? 10 : 1;
24380 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24383 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24384 this.field.dom.value = d.activePage;
24387 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24389 this.field.dom.value = parseInt(v, 10) + increment;
24390 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24391 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24398 beforeLoad : function(){
24400 this.loading.disable();
24405 onClick : function(which){
24414 ds.load({params:{start: 0, limit: this.pageSize}});
24417 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24420 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24423 var total = ds.getTotalCount();
24424 var extra = total % this.pageSize;
24425 var lastStart = extra ? (total - extra) : total-this.pageSize;
24426 ds.load({params:{start: lastStart, limit: this.pageSize}});
24429 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24435 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24436 * @param {Roo.data.Store} store The data store to unbind
24438 unbind : function(ds){
24439 ds.un("beforeload", this.beforeLoad, this);
24440 ds.un("load", this.onLoad, this);
24441 ds.un("loadexception", this.onLoadError, this);
24442 ds.un("remove", this.updateInfo, this);
24443 ds.un("add", this.updateInfo, this);
24444 this.ds = undefined;
24448 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24449 * @param {Roo.data.Store} store The data store to bind
24451 bind : function(ds){
24452 ds.on("beforeload", this.beforeLoad, this);
24453 ds.on("load", this.onLoad, this);
24454 ds.on("loadexception", this.onLoadError, this);
24455 ds.on("remove", this.updateInfo, this);
24456 ds.on("add", this.updateInfo, this);
24467 * @class Roo.bootstrap.MessageBar
24468 * @extends Roo.bootstrap.Component
24469 * Bootstrap MessageBar class
24470 * @cfg {String} html contents of the MessageBar
24471 * @cfg {String} weight (info | success | warning | danger) default info
24472 * @cfg {String} beforeClass insert the bar before the given class
24473 * @cfg {Boolean} closable (true | false) default false
24474 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24477 * Create a new Element
24478 * @param {Object} config The config object
24481 Roo.bootstrap.MessageBar = function(config){
24482 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24485 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24491 beforeClass: 'bootstrap-sticky-wrap',
24493 getAutoCreate : function(){
24497 cls: 'alert alert-dismissable alert-' + this.weight,
24502 html: this.html || ''
24508 cfg.cls += ' alert-messages-fixed';
24522 onRender : function(ct, position)
24524 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24527 var cfg = Roo.apply({}, this.getAutoCreate());
24531 cfg.cls += ' ' + this.cls;
24534 cfg.style = this.style;
24536 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24538 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24541 this.el.select('>button.close').on('click', this.hide, this);
24547 if (!this.rendered) {
24553 this.fireEvent('show', this);
24559 if (!this.rendered) {
24565 this.fireEvent('hide', this);
24568 update : function()
24570 // var e = this.el.dom.firstChild;
24572 // if(this.closable){
24573 // e = e.nextSibling;
24576 // e.data = this.html || '';
24578 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24594 * @class Roo.bootstrap.Graph
24595 * @extends Roo.bootstrap.Component
24596 * Bootstrap Graph class
24600 @cfg {String} graphtype bar | vbar | pie
24601 @cfg {number} g_x coodinator | centre x (pie)
24602 @cfg {number} g_y coodinator | centre y (pie)
24603 @cfg {number} g_r radius (pie)
24604 @cfg {number} g_height height of the chart (respected by all elements in the set)
24605 @cfg {number} g_width width of the chart (respected by all elements in the set)
24606 @cfg {Object} title The title of the chart
24609 -opts (object) options for the chart
24611 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24612 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24614 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.
24615 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24617 o stretch (boolean)
24619 -opts (object) options for the pie
24622 o startAngle (number)
24623 o endAngle (number)
24627 * Create a new Input
24628 * @param {Object} config The config object
24631 Roo.bootstrap.Graph = function(config){
24632 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24638 * The img click event for the img.
24639 * @param {Roo.EventObject} e
24645 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24656 //g_colors: this.colors,
24663 getAutoCreate : function(){
24674 onRender : function(ct,position){
24677 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24679 if (typeof(Raphael) == 'undefined') {
24680 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24684 this.raphael = Raphael(this.el.dom);
24686 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24687 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24688 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24689 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24691 r.text(160, 10, "Single Series Chart").attr(txtattr);
24692 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24693 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24694 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24696 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24697 r.barchart(330, 10, 300, 220, data1);
24698 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24699 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24702 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24703 // r.barchart(30, 30, 560, 250, xdata, {
24704 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24705 // axis : "0 0 1 1",
24706 // axisxlabels : xdata
24707 // //yvalues : cols,
24710 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24712 // this.load(null,xdata,{
24713 // axis : "0 0 1 1",
24714 // axisxlabels : xdata
24719 load : function(graphtype,xdata,opts)
24721 this.raphael.clear();
24723 graphtype = this.graphtype;
24728 var r = this.raphael,
24729 fin = function () {
24730 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24732 fout = function () {
24733 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24735 pfin = function() {
24736 this.sector.stop();
24737 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24740 this.label[0].stop();
24741 this.label[0].attr({ r: 7.5 });
24742 this.label[1].attr({ "font-weight": 800 });
24745 pfout = function() {
24746 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24749 this.label[0].animate({ r: 5 }, 500, "bounce");
24750 this.label[1].attr({ "font-weight": 400 });
24756 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24759 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24762 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24763 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24765 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24772 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24777 setTitle: function(o)
24782 initEvents: function() {
24785 this.el.on('click', this.onClick, this);
24789 onClick : function(e)
24791 Roo.log('img onclick');
24792 this.fireEvent('click', this, e);
24804 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24807 * @class Roo.bootstrap.dash.NumberBox
24808 * @extends Roo.bootstrap.Component
24809 * Bootstrap NumberBox class
24810 * @cfg {String} headline Box headline
24811 * @cfg {String} content Box content
24812 * @cfg {String} icon Box icon
24813 * @cfg {String} footer Footer text
24814 * @cfg {String} fhref Footer href
24817 * Create a new NumberBox
24818 * @param {Object} config The config object
24822 Roo.bootstrap.dash.NumberBox = function(config){
24823 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24827 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24836 getAutoCreate : function(){
24840 cls : 'small-box ',
24848 cls : 'roo-headline',
24849 html : this.headline
24853 cls : 'roo-content',
24854 html : this.content
24868 cls : 'ion ' + this.icon
24877 cls : 'small-box-footer',
24878 href : this.fhref || '#',
24882 cfg.cn.push(footer);
24889 onRender : function(ct,position){
24890 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
24897 setHeadline: function (value)
24899 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
24902 setFooter: function (value, href)
24904 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
24907 this.el.select('a.small-box-footer',true).first().attr('href', href);
24912 setContent: function (value)
24914 this.el.select('.roo-content',true).first().dom.innerHTML = value;
24917 initEvents: function()
24931 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24934 * @class Roo.bootstrap.dash.TabBox
24935 * @extends Roo.bootstrap.Component
24936 * Bootstrap TabBox class
24937 * @cfg {String} title Title of the TabBox
24938 * @cfg {String} icon Icon of the TabBox
24939 * @cfg {Boolean} showtabs (true|false) show the tabs default true
24940 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
24943 * Create a new TabBox
24944 * @param {Object} config The config object
24948 Roo.bootstrap.dash.TabBox = function(config){
24949 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
24954 * When a pane is added
24955 * @param {Roo.bootstrap.dash.TabPane} pane
24959 * @event activatepane
24960 * When a pane is activated
24961 * @param {Roo.bootstrap.dash.TabPane} pane
24963 "activatepane" : true
24971 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
24976 tabScrollable : false,
24978 getChildContainer : function()
24980 return this.el.select('.tab-content', true).first();
24983 getAutoCreate : function(){
24987 cls: 'pull-left header',
24995 cls: 'fa ' + this.icon
25001 cls: 'nav nav-tabs pull-right',
25007 if(this.tabScrollable){
25014 cls: 'nav nav-tabs pull-right',
25025 cls: 'nav-tabs-custom',
25030 cls: 'tab-content no-padding',
25038 initEvents : function()
25040 //Roo.log('add add pane handler');
25041 this.on('addpane', this.onAddPane, this);
25044 * Updates the box title
25045 * @param {String} html to set the title to.
25047 setTitle : function(value)
25049 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25051 onAddPane : function(pane)
25053 this.panes.push(pane);
25054 //Roo.log('addpane');
25056 // tabs are rendere left to right..
25057 if(!this.showtabs){
25061 var ctr = this.el.select('.nav-tabs', true).first();
25064 var existing = ctr.select('.nav-tab',true);
25065 var qty = existing.getCount();;
25068 var tab = ctr.createChild({
25070 cls : 'nav-tab' + (qty ? '' : ' active'),
25078 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25081 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25083 pane.el.addClass('active');
25088 onTabClick : function(ev,un,ob,pane)
25090 //Roo.log('tab - prev default');
25091 ev.preventDefault();
25094 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25095 pane.tab.addClass('active');
25096 //Roo.log(pane.title);
25097 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25098 // technically we should have a deactivate event.. but maybe add later.
25099 // and it should not de-activate the selected tab...
25100 this.fireEvent('activatepane', pane);
25101 pane.el.addClass('active');
25102 pane.fireEvent('activate');
25107 getActivePane : function()
25110 Roo.each(this.panes, function(p) {
25111 if(p.el.hasClass('active')){
25132 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25134 * @class Roo.bootstrap.TabPane
25135 * @extends Roo.bootstrap.Component
25136 * Bootstrap TabPane class
25137 * @cfg {Boolean} active (false | true) Default false
25138 * @cfg {String} title title of panel
25142 * Create a new TabPane
25143 * @param {Object} config The config object
25146 Roo.bootstrap.dash.TabPane = function(config){
25147 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25153 * When a pane is activated
25154 * @param {Roo.bootstrap.dash.TabPane} pane
25161 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25166 // the tabBox that this is attached to.
25169 getAutoCreate : function()
25177 cfg.cls += ' active';
25182 initEvents : function()
25184 //Roo.log('trigger add pane handler');
25185 this.parent().fireEvent('addpane', this)
25189 * Updates the tab title
25190 * @param {String} html to set the title to.
25192 setTitle: function(str)
25198 this.tab.select('a', true).first().dom.innerHTML = str;
25215 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25218 * @class Roo.bootstrap.menu.Menu
25219 * @extends Roo.bootstrap.Component
25220 * Bootstrap Menu class - container for Menu
25221 * @cfg {String} html Text of the menu
25222 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25223 * @cfg {String} icon Font awesome icon
25224 * @cfg {String} pos Menu align to (top | bottom) default bottom
25228 * Create a new Menu
25229 * @param {Object} config The config object
25233 Roo.bootstrap.menu.Menu = function(config){
25234 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25238 * @event beforeshow
25239 * Fires before this menu is displayed
25240 * @param {Roo.bootstrap.menu.Menu} this
25244 * @event beforehide
25245 * Fires before this menu is hidden
25246 * @param {Roo.bootstrap.menu.Menu} this
25251 * Fires after this menu is displayed
25252 * @param {Roo.bootstrap.menu.Menu} this
25257 * Fires after this menu is hidden
25258 * @param {Roo.bootstrap.menu.Menu} this
25263 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25264 * @param {Roo.bootstrap.menu.Menu} this
25265 * @param {Roo.EventObject} e
25272 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25276 weight : 'default',
25281 getChildContainer : function() {
25282 if(this.isSubMenu){
25286 return this.el.select('ul.dropdown-menu', true).first();
25289 getAutoCreate : function()
25294 cls : 'roo-menu-text',
25302 cls : 'fa ' + this.icon
25313 cls : 'dropdown-button btn btn-' + this.weight,
25318 cls : 'dropdown-toggle btn btn-' + this.weight,
25328 cls : 'dropdown-menu'
25334 if(this.pos == 'top'){
25335 cfg.cls += ' dropup';
25338 if(this.isSubMenu){
25341 cls : 'dropdown-menu'
25348 onRender : function(ct, position)
25350 this.isSubMenu = ct.hasClass('dropdown-submenu');
25352 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25355 initEvents : function()
25357 if(this.isSubMenu){
25361 this.hidden = true;
25363 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25364 this.triggerEl.on('click', this.onTriggerPress, this);
25366 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25367 this.buttonEl.on('click', this.onClick, this);
25373 if(this.isSubMenu){
25377 return this.el.select('ul.dropdown-menu', true).first();
25380 onClick : function(e)
25382 this.fireEvent("click", this, e);
25385 onTriggerPress : function(e)
25387 if (this.isVisible()) {
25394 isVisible : function(){
25395 return !this.hidden;
25400 this.fireEvent("beforeshow", this);
25402 this.hidden = false;
25403 this.el.addClass('open');
25405 Roo.get(document).on("mouseup", this.onMouseUp, this);
25407 this.fireEvent("show", this);
25414 this.fireEvent("beforehide", this);
25416 this.hidden = true;
25417 this.el.removeClass('open');
25419 Roo.get(document).un("mouseup", this.onMouseUp);
25421 this.fireEvent("hide", this);
25424 onMouseUp : function()
25438 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25441 * @class Roo.bootstrap.menu.Item
25442 * @extends Roo.bootstrap.Component
25443 * Bootstrap MenuItem class
25444 * @cfg {Boolean} submenu (true | false) default false
25445 * @cfg {String} html text of the item
25446 * @cfg {String} href the link
25447 * @cfg {Boolean} disable (true | false) default false
25448 * @cfg {Boolean} preventDefault (true | false) default true
25449 * @cfg {String} icon Font awesome icon
25450 * @cfg {String} pos Submenu align to (left | right) default right
25454 * Create a new Item
25455 * @param {Object} config The config object
25459 Roo.bootstrap.menu.Item = function(config){
25460 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25464 * Fires when the mouse is hovering over this menu
25465 * @param {Roo.bootstrap.menu.Item} this
25466 * @param {Roo.EventObject} e
25471 * Fires when the mouse exits this menu
25472 * @param {Roo.bootstrap.menu.Item} this
25473 * @param {Roo.EventObject} e
25479 * The raw click event for the entire grid.
25480 * @param {Roo.EventObject} e
25486 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25491 preventDefault: true,
25496 getAutoCreate : function()
25501 cls : 'roo-menu-item-text',
25509 cls : 'fa ' + this.icon
25518 href : this.href || '#',
25525 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25529 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25531 if(this.pos == 'left'){
25532 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25539 initEvents : function()
25541 this.el.on('mouseover', this.onMouseOver, this);
25542 this.el.on('mouseout', this.onMouseOut, this);
25544 this.el.select('a', true).first().on('click', this.onClick, this);
25548 onClick : function(e)
25550 if(this.preventDefault){
25551 e.preventDefault();
25554 this.fireEvent("click", this, e);
25557 onMouseOver : function(e)
25559 if(this.submenu && this.pos == 'left'){
25560 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25563 this.fireEvent("mouseover", this, e);
25566 onMouseOut : function(e)
25568 this.fireEvent("mouseout", this, e);
25580 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25583 * @class Roo.bootstrap.menu.Separator
25584 * @extends Roo.bootstrap.Component
25585 * Bootstrap Separator class
25588 * Create a new Separator
25589 * @param {Object} config The config object
25593 Roo.bootstrap.menu.Separator = function(config){
25594 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25597 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25599 getAutoCreate : function(){
25620 * @class Roo.bootstrap.Tooltip
25621 * Bootstrap Tooltip class
25622 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25623 * to determine which dom element triggers the tooltip.
25625 * It needs to add support for additional attributes like tooltip-position
25628 * Create a new Toolti
25629 * @param {Object} config The config object
25632 Roo.bootstrap.Tooltip = function(config){
25633 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25635 this.alignment = Roo.bootstrap.Tooltip.alignment;
25637 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25638 this.alignment = config.alignment;
25643 Roo.apply(Roo.bootstrap.Tooltip, {
25645 * @function init initialize tooltip monitoring.
25649 currentTip : false,
25650 currentRegion : false,
25656 Roo.get(document).on('mouseover', this.enter ,this);
25657 Roo.get(document).on('mouseout', this.leave, this);
25660 this.currentTip = new Roo.bootstrap.Tooltip();
25663 enter : function(ev)
25665 var dom = ev.getTarget();
25667 //Roo.log(['enter',dom]);
25668 var el = Roo.fly(dom);
25669 if (this.currentEl) {
25671 //Roo.log(this.currentEl);
25672 //Roo.log(this.currentEl.contains(dom));
25673 if (this.currentEl == el) {
25676 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25682 if (this.currentTip.el) {
25683 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25687 if(!el || el.dom == document){
25693 // you can not look for children, as if el is the body.. then everythign is the child..
25694 if (!el.attr('tooltip')) { //
25695 if (!el.select("[tooltip]").elements.length) {
25698 // is the mouse over this child...?
25699 bindEl = el.select("[tooltip]").first();
25700 var xy = ev.getXY();
25701 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25702 //Roo.log("not in region.");
25705 //Roo.log("child element over..");
25708 this.currentEl = bindEl;
25709 this.currentTip.bind(bindEl);
25710 this.currentRegion = Roo.lib.Region.getRegion(dom);
25711 this.currentTip.enter();
25714 leave : function(ev)
25716 var dom = ev.getTarget();
25717 //Roo.log(['leave',dom]);
25718 if (!this.currentEl) {
25723 if (dom != this.currentEl.dom) {
25726 var xy = ev.getXY();
25727 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25730 // only activate leave if mouse cursor is outside... bounding box..
25735 if (this.currentTip) {
25736 this.currentTip.leave();
25738 //Roo.log('clear currentEl');
25739 this.currentEl = false;
25744 'left' : ['r-l', [-2,0], 'right'],
25745 'right' : ['l-r', [2,0], 'left'],
25746 'bottom' : ['t-b', [0,2], 'top'],
25747 'top' : [ 'b-t', [0,-2], 'bottom']
25753 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25758 delay : null, // can be { show : 300 , hide: 500}
25762 hoverState : null, //???
25764 placement : 'bottom',
25768 getAutoCreate : function(){
25775 cls : 'tooltip-arrow'
25778 cls : 'tooltip-inner'
25785 bind : function(el)
25791 enter : function () {
25793 if (this.timeout != null) {
25794 clearTimeout(this.timeout);
25797 this.hoverState = 'in';
25798 //Roo.log("enter - show");
25799 if (!this.delay || !this.delay.show) {
25804 this.timeout = setTimeout(function () {
25805 if (_t.hoverState == 'in') {
25808 }, this.delay.show);
25812 clearTimeout(this.timeout);
25814 this.hoverState = 'out';
25815 if (!this.delay || !this.delay.hide) {
25821 this.timeout = setTimeout(function () {
25822 //Roo.log("leave - timeout");
25824 if (_t.hoverState == 'out') {
25826 Roo.bootstrap.Tooltip.currentEl = false;
25831 show : function (msg)
25834 this.render(document.body);
25837 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25839 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25841 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25843 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25845 var placement = typeof this.placement == 'function' ?
25846 this.placement.call(this, this.el, on_el) :
25849 var autoToken = /\s?auto?\s?/i;
25850 var autoPlace = autoToken.test(placement);
25852 placement = placement.replace(autoToken, '') || 'top';
25856 //this.el.setXY([0,0]);
25858 //this.el.dom.style.display='block';
25860 //this.el.appendTo(on_el);
25862 var p = this.getPosition();
25863 var box = this.el.getBox();
25869 var align = this.alignment[placement];
25871 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25873 if(placement == 'top' || placement == 'bottom'){
25875 placement = 'right';
25878 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25879 placement = 'left';
25882 var scroll = Roo.select('body', true).first().getScroll();
25884 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
25890 this.el.alignTo(this.bindEl, align[0],align[1]);
25891 //var arrow = this.el.select('.arrow',true).first();
25892 //arrow.set(align[2],
25894 this.el.addClass(placement);
25896 this.el.addClass('in fade');
25898 this.hoverState = null;
25900 if (this.el.hasClass('fade')) {
25911 //this.el.setXY([0,0]);
25912 this.el.removeClass('in');
25928 * @class Roo.bootstrap.LocationPicker
25929 * @extends Roo.bootstrap.Component
25930 * Bootstrap LocationPicker class
25931 * @cfg {Number} latitude Position when init default 0
25932 * @cfg {Number} longitude Position when init default 0
25933 * @cfg {Number} zoom default 15
25934 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
25935 * @cfg {Boolean} mapTypeControl default false
25936 * @cfg {Boolean} disableDoubleClickZoom default false
25937 * @cfg {Boolean} scrollwheel default true
25938 * @cfg {Boolean} streetViewControl default false
25939 * @cfg {Number} radius default 0
25940 * @cfg {String} locationName
25941 * @cfg {Boolean} draggable default true
25942 * @cfg {Boolean} enableAutocomplete default false
25943 * @cfg {Boolean} enableReverseGeocode default true
25944 * @cfg {String} markerTitle
25947 * Create a new LocationPicker
25948 * @param {Object} config The config object
25952 Roo.bootstrap.LocationPicker = function(config){
25954 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
25959 * Fires when the picker initialized.
25960 * @param {Roo.bootstrap.LocationPicker} this
25961 * @param {Google Location} location
25965 * @event positionchanged
25966 * Fires when the picker position changed.
25967 * @param {Roo.bootstrap.LocationPicker} this
25968 * @param {Google Location} location
25970 positionchanged : true,
25973 * Fires when the map resize.
25974 * @param {Roo.bootstrap.LocationPicker} this
25979 * Fires when the map show.
25980 * @param {Roo.bootstrap.LocationPicker} this
25985 * Fires when the map hide.
25986 * @param {Roo.bootstrap.LocationPicker} this
25991 * Fires when click the map.
25992 * @param {Roo.bootstrap.LocationPicker} this
25993 * @param {Map event} e
25997 * @event mapRightClick
25998 * Fires when right click the map.
25999 * @param {Roo.bootstrap.LocationPicker} this
26000 * @param {Map event} e
26002 mapRightClick : true,
26004 * @event markerClick
26005 * Fires when click the marker.
26006 * @param {Roo.bootstrap.LocationPicker} this
26007 * @param {Map event} e
26009 markerClick : true,
26011 * @event markerRightClick
26012 * Fires when right click the marker.
26013 * @param {Roo.bootstrap.LocationPicker} this
26014 * @param {Map event} e
26016 markerRightClick : true,
26018 * @event OverlayViewDraw
26019 * Fires when OverlayView Draw
26020 * @param {Roo.bootstrap.LocationPicker} this
26022 OverlayViewDraw : true,
26024 * @event OverlayViewOnAdd
26025 * Fires when OverlayView Draw
26026 * @param {Roo.bootstrap.LocationPicker} this
26028 OverlayViewOnAdd : true,
26030 * @event OverlayViewOnRemove
26031 * Fires when OverlayView Draw
26032 * @param {Roo.bootstrap.LocationPicker} this
26034 OverlayViewOnRemove : true,
26036 * @event OverlayViewShow
26037 * Fires when OverlayView Draw
26038 * @param {Roo.bootstrap.LocationPicker} this
26039 * @param {Pixel} cpx
26041 OverlayViewShow : true,
26043 * @event OverlayViewHide
26044 * Fires when OverlayView Draw
26045 * @param {Roo.bootstrap.LocationPicker} this
26047 OverlayViewHide : true,
26049 * @event loadexception
26050 * Fires when load google lib failed.
26051 * @param {Roo.bootstrap.LocationPicker} this
26053 loadexception : true
26058 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26060 gMapContext: false,
26066 mapTypeControl: false,
26067 disableDoubleClickZoom: false,
26069 streetViewControl: false,
26073 enableAutocomplete: false,
26074 enableReverseGeocode: true,
26077 getAutoCreate: function()
26082 cls: 'roo-location-picker'
26088 initEvents: function(ct, position)
26090 if(!this.el.getWidth() || this.isApplied()){
26094 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26099 initial: function()
26101 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26102 this.fireEvent('loadexception', this);
26106 if(!this.mapTypeId){
26107 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26110 this.gMapContext = this.GMapContext();
26112 this.initOverlayView();
26114 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26118 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26119 _this.setPosition(_this.gMapContext.marker.position);
26122 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26123 _this.fireEvent('mapClick', this, event);
26127 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26128 _this.fireEvent('mapRightClick', this, event);
26132 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26133 _this.fireEvent('markerClick', this, event);
26137 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26138 _this.fireEvent('markerRightClick', this, event);
26142 this.setPosition(this.gMapContext.location);
26144 this.fireEvent('initial', this, this.gMapContext.location);
26147 initOverlayView: function()
26151 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26155 _this.fireEvent('OverlayViewDraw', _this);
26160 _this.fireEvent('OverlayViewOnAdd', _this);
26163 onRemove: function()
26165 _this.fireEvent('OverlayViewOnRemove', _this);
26168 show: function(cpx)
26170 _this.fireEvent('OverlayViewShow', _this, cpx);
26175 _this.fireEvent('OverlayViewHide', _this);
26181 fromLatLngToContainerPixel: function(event)
26183 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26186 isApplied: function()
26188 return this.getGmapContext() == false ? false : true;
26191 getGmapContext: function()
26193 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26196 GMapContext: function()
26198 var position = new google.maps.LatLng(this.latitude, this.longitude);
26200 var _map = new google.maps.Map(this.el.dom, {
26203 mapTypeId: this.mapTypeId,
26204 mapTypeControl: this.mapTypeControl,
26205 disableDoubleClickZoom: this.disableDoubleClickZoom,
26206 scrollwheel: this.scrollwheel,
26207 streetViewControl: this.streetViewControl,
26208 locationName: this.locationName,
26209 draggable: this.draggable,
26210 enableAutocomplete: this.enableAutocomplete,
26211 enableReverseGeocode: this.enableReverseGeocode
26214 var _marker = new google.maps.Marker({
26215 position: position,
26217 title: this.markerTitle,
26218 draggable: this.draggable
26225 location: position,
26226 radius: this.radius,
26227 locationName: this.locationName,
26228 addressComponents: {
26229 formatted_address: null,
26230 addressLine1: null,
26231 addressLine2: null,
26233 streetNumber: null,
26237 stateOrProvince: null
26240 domContainer: this.el.dom,
26241 geodecoder: new google.maps.Geocoder()
26245 drawCircle: function(center, radius, options)
26247 if (this.gMapContext.circle != null) {
26248 this.gMapContext.circle.setMap(null);
26252 options = Roo.apply({}, options, {
26253 strokeColor: "#0000FF",
26254 strokeOpacity: .35,
26256 fillColor: "#0000FF",
26260 options.map = this.gMapContext.map;
26261 options.radius = radius;
26262 options.center = center;
26263 this.gMapContext.circle = new google.maps.Circle(options);
26264 return this.gMapContext.circle;
26270 setPosition: function(location)
26272 this.gMapContext.location = location;
26273 this.gMapContext.marker.setPosition(location);
26274 this.gMapContext.map.panTo(location);
26275 this.drawCircle(location, this.gMapContext.radius, {});
26279 if (this.gMapContext.settings.enableReverseGeocode) {
26280 this.gMapContext.geodecoder.geocode({
26281 latLng: this.gMapContext.location
26282 }, function(results, status) {
26284 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26285 _this.gMapContext.locationName = results[0].formatted_address;
26286 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26288 _this.fireEvent('positionchanged', this, location);
26295 this.fireEvent('positionchanged', this, location);
26300 google.maps.event.trigger(this.gMapContext.map, "resize");
26302 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26304 this.fireEvent('resize', this);
26307 setPositionByLatLng: function(latitude, longitude)
26309 this.setPosition(new google.maps.LatLng(latitude, longitude));
26312 getCurrentPosition: function()
26315 latitude: this.gMapContext.location.lat(),
26316 longitude: this.gMapContext.location.lng()
26320 getAddressName: function()
26322 return this.gMapContext.locationName;
26325 getAddressComponents: function()
26327 return this.gMapContext.addressComponents;
26330 address_component_from_google_geocode: function(address_components)
26334 for (var i = 0; i < address_components.length; i++) {
26335 var component = address_components[i];
26336 if (component.types.indexOf("postal_code") >= 0) {
26337 result.postalCode = component.short_name;
26338 } else if (component.types.indexOf("street_number") >= 0) {
26339 result.streetNumber = component.short_name;
26340 } else if (component.types.indexOf("route") >= 0) {
26341 result.streetName = component.short_name;
26342 } else if (component.types.indexOf("neighborhood") >= 0) {
26343 result.city = component.short_name;
26344 } else if (component.types.indexOf("locality") >= 0) {
26345 result.city = component.short_name;
26346 } else if (component.types.indexOf("sublocality") >= 0) {
26347 result.district = component.short_name;
26348 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26349 result.stateOrProvince = component.short_name;
26350 } else if (component.types.indexOf("country") >= 0) {
26351 result.country = component.short_name;
26355 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26356 result.addressLine2 = "";
26360 setZoomLevel: function(zoom)
26362 this.gMapContext.map.setZoom(zoom);
26375 this.fireEvent('show', this);
26386 this.fireEvent('hide', this);
26391 Roo.apply(Roo.bootstrap.LocationPicker, {
26393 OverlayView : function(map, options)
26395 options = options || {};
26409 * @class Roo.bootstrap.Alert
26410 * @extends Roo.bootstrap.Component
26411 * Bootstrap Alert class
26412 * @cfg {String} title The title of alert
26413 * @cfg {String} html The content of alert
26414 * @cfg {String} weight ( success | info | warning | danger )
26415 * @cfg {String} faicon font-awesomeicon
26418 * Create a new alert
26419 * @param {Object} config The config object
26423 Roo.bootstrap.Alert = function(config){
26424 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26428 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26435 getAutoCreate : function()
26444 cls : 'roo-alert-icon'
26449 cls : 'roo-alert-title',
26454 cls : 'roo-alert-text',
26461 cfg.cn[0].cls += ' fa ' + this.faicon;
26465 cfg.cls += ' alert-' + this.weight;
26471 initEvents: function()
26473 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26476 setTitle : function(str)
26478 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26481 setText : function(str)
26483 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26486 setWeight : function(weight)
26489 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26492 this.weight = weight;
26494 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26497 setIcon : function(icon)
26500 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26503 this.faicon = icon;
26505 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26526 * @class Roo.bootstrap.UploadCropbox
26527 * @extends Roo.bootstrap.Component
26528 * Bootstrap UploadCropbox class
26529 * @cfg {String} emptyText show when image has been loaded
26530 * @cfg {String} rotateNotify show when image too small to rotate
26531 * @cfg {Number} errorTimeout default 3000
26532 * @cfg {Number} minWidth default 300
26533 * @cfg {Number} minHeight default 300
26534 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26535 * @cfg {Boolean} isDocument (true|false) default false
26536 * @cfg {String} url action url
26537 * @cfg {String} paramName default 'imageUpload'
26538 * @cfg {String} method default POST
26539 * @cfg {Boolean} loadMask (true|false) default true
26540 * @cfg {Boolean} loadingText default 'Loading...'
26543 * Create a new UploadCropbox
26544 * @param {Object} config The config object
26547 Roo.bootstrap.UploadCropbox = function(config){
26548 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26552 * @event beforeselectfile
26553 * Fire before select file
26554 * @param {Roo.bootstrap.UploadCropbox} this
26556 "beforeselectfile" : true,
26559 * Fire after initEvent
26560 * @param {Roo.bootstrap.UploadCropbox} this
26565 * Fire after initEvent
26566 * @param {Roo.bootstrap.UploadCropbox} this
26567 * @param {String} data
26572 * Fire when preparing the file data
26573 * @param {Roo.bootstrap.UploadCropbox} this
26574 * @param {Object} file
26579 * Fire when get exception
26580 * @param {Roo.bootstrap.UploadCropbox} this
26581 * @param {XMLHttpRequest} xhr
26583 "exception" : true,
26585 * @event beforeloadcanvas
26586 * Fire before load the canvas
26587 * @param {Roo.bootstrap.UploadCropbox} this
26588 * @param {String} src
26590 "beforeloadcanvas" : true,
26593 * Fire when trash image
26594 * @param {Roo.bootstrap.UploadCropbox} this
26599 * Fire when download the image
26600 * @param {Roo.bootstrap.UploadCropbox} this
26604 * @event footerbuttonclick
26605 * Fire when footerbuttonclick
26606 * @param {Roo.bootstrap.UploadCropbox} this
26607 * @param {String} type
26609 "footerbuttonclick" : true,
26613 * @param {Roo.bootstrap.UploadCropbox} this
26618 * Fire when rotate the image
26619 * @param {Roo.bootstrap.UploadCropbox} this
26620 * @param {String} pos
26625 * Fire when inspect the file
26626 * @param {Roo.bootstrap.UploadCropbox} this
26627 * @param {Object} file
26632 * Fire when xhr upload the file
26633 * @param {Roo.bootstrap.UploadCropbox} this
26634 * @param {Object} data
26639 * Fire when arrange the file data
26640 * @param {Roo.bootstrap.UploadCropbox} this
26641 * @param {Object} formData
26646 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26649 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26651 emptyText : 'Click to upload image',
26652 rotateNotify : 'Image is too small to rotate',
26653 errorTimeout : 3000,
26667 cropType : 'image/jpeg',
26669 canvasLoaded : false,
26670 isDocument : false,
26672 paramName : 'imageUpload',
26674 loadingText : 'Loading...',
26677 getAutoCreate : function()
26681 cls : 'roo-upload-cropbox',
26685 cls : 'roo-upload-cropbox-selector',
26690 cls : 'roo-upload-cropbox-body',
26691 style : 'cursor:pointer',
26695 cls : 'roo-upload-cropbox-preview'
26699 cls : 'roo-upload-cropbox-thumb'
26703 cls : 'roo-upload-cropbox-empty-notify',
26704 html : this.emptyText
26708 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26709 html : this.rotateNotify
26715 cls : 'roo-upload-cropbox-footer',
26718 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26728 onRender : function(ct, position)
26730 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26732 if (this.buttons.length) {
26734 Roo.each(this.buttons, function(bb) {
26736 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26738 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26744 this.maskEl = this.el;
26748 initEvents : function()
26750 this.urlAPI = (window.createObjectURL && window) ||
26751 (window.URL && URL.revokeObjectURL && URL) ||
26752 (window.webkitURL && webkitURL);
26754 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26755 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26757 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26758 this.selectorEl.hide();
26760 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26761 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26763 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26764 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26765 this.thumbEl.hide();
26767 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26768 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26770 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26771 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26772 this.errorEl.hide();
26774 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26775 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26776 this.footerEl.hide();
26778 this.setThumbBoxSize();
26784 this.fireEvent('initial', this);
26791 window.addEventListener("resize", function() { _this.resize(); } );
26793 this.bodyEl.on('click', this.beforeSelectFile, this);
26796 this.bodyEl.on('touchstart', this.onTouchStart, this);
26797 this.bodyEl.on('touchmove', this.onTouchMove, this);
26798 this.bodyEl.on('touchend', this.onTouchEnd, this);
26802 this.bodyEl.on('mousedown', this.onMouseDown, this);
26803 this.bodyEl.on('mousemove', this.onMouseMove, this);
26804 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26805 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26806 Roo.get(document).on('mouseup', this.onMouseUp, this);
26809 this.selectorEl.on('change', this.onFileSelected, this);
26815 this.baseScale = 1;
26817 this.baseRotate = 1;
26818 this.dragable = false;
26819 this.pinching = false;
26822 this.cropData = false;
26823 this.notifyEl.dom.innerHTML = this.emptyText;
26825 this.selectorEl.dom.value = '';
26829 resize : function()
26831 if(this.fireEvent('resize', this) != false){
26832 this.setThumbBoxPosition();
26833 this.setCanvasPosition();
26837 onFooterButtonClick : function(e, el, o, type)
26840 case 'rotate-left' :
26841 this.onRotateLeft(e);
26843 case 'rotate-right' :
26844 this.onRotateRight(e);
26847 this.beforeSelectFile(e);
26862 this.fireEvent('footerbuttonclick', this, type);
26865 beforeSelectFile : function(e)
26867 e.preventDefault();
26869 if(this.fireEvent('beforeselectfile', this) != false){
26870 this.selectorEl.dom.click();
26874 onFileSelected : function(e)
26876 e.preventDefault();
26878 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
26882 var file = this.selectorEl.dom.files[0];
26884 if(this.fireEvent('inspect', this, file) != false){
26885 this.prepare(file);
26890 trash : function(e)
26892 this.fireEvent('trash', this);
26895 download : function(e)
26897 this.fireEvent('download', this);
26900 loadCanvas : function(src)
26902 if(this.fireEvent('beforeloadcanvas', this, src) != false){
26906 this.imageEl = document.createElement('img');
26910 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
26912 this.imageEl.src = src;
26916 onLoadCanvas : function()
26918 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
26919 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
26921 this.bodyEl.un('click', this.beforeSelectFile, this);
26923 this.notifyEl.hide();
26924 this.thumbEl.show();
26925 this.footerEl.show();
26927 this.baseRotateLevel();
26929 if(this.isDocument){
26930 this.setThumbBoxSize();
26933 this.setThumbBoxPosition();
26935 this.baseScaleLevel();
26941 this.canvasLoaded = true;
26944 this.maskEl.unmask();
26949 setCanvasPosition : function()
26951 if(!this.canvasEl){
26955 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
26956 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
26958 this.previewEl.setLeft(pw);
26959 this.previewEl.setTop(ph);
26963 onMouseDown : function(e)
26967 this.dragable = true;
26968 this.pinching = false;
26970 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
26971 this.dragable = false;
26975 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
26976 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
26980 onMouseMove : function(e)
26984 if(!this.canvasLoaded){
26988 if (!this.dragable){
26992 var minX = Math.ceil(this.thumbEl.getLeft(true));
26993 var minY = Math.ceil(this.thumbEl.getTop(true));
26995 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
26996 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
26998 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
26999 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27001 x = x - this.mouseX;
27002 y = y - this.mouseY;
27004 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27005 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27007 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27008 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27010 this.previewEl.setLeft(bgX);
27011 this.previewEl.setTop(bgY);
27013 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27014 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27017 onMouseUp : function(e)
27021 this.dragable = false;
27024 onMouseWheel : function(e)
27028 this.startScale = this.scale;
27030 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27032 if(!this.zoomable()){
27033 this.scale = this.startScale;
27042 zoomable : function()
27044 var minScale = this.thumbEl.getWidth() / this.minWidth;
27046 if(this.minWidth < this.minHeight){
27047 minScale = this.thumbEl.getHeight() / this.minHeight;
27050 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27051 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27055 (this.rotate == 0 || this.rotate == 180) &&
27057 width > this.imageEl.OriginWidth ||
27058 height > this.imageEl.OriginHeight ||
27059 (width < this.minWidth && height < this.minHeight)
27067 (this.rotate == 90 || this.rotate == 270) &&
27069 width > this.imageEl.OriginWidth ||
27070 height > this.imageEl.OriginHeight ||
27071 (width < this.minHeight && height < this.minWidth)
27078 !this.isDocument &&
27079 (this.rotate == 0 || this.rotate == 180) &&
27081 width < this.minWidth ||
27082 width > this.imageEl.OriginWidth ||
27083 height < this.minHeight ||
27084 height > this.imageEl.OriginHeight
27091 !this.isDocument &&
27092 (this.rotate == 90 || this.rotate == 270) &&
27094 width < this.minHeight ||
27095 width > this.imageEl.OriginWidth ||
27096 height < this.minWidth ||
27097 height > this.imageEl.OriginHeight
27107 onRotateLeft : function(e)
27109 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27111 var minScale = this.thumbEl.getWidth() / this.minWidth;
27113 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27114 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27116 this.startScale = this.scale;
27118 while (this.getScaleLevel() < minScale){
27120 this.scale = this.scale + 1;
27122 if(!this.zoomable()){
27127 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27128 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27133 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27140 this.scale = this.startScale;
27142 this.onRotateFail();
27147 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27149 if(this.isDocument){
27150 this.setThumbBoxSize();
27151 this.setThumbBoxPosition();
27152 this.setCanvasPosition();
27157 this.fireEvent('rotate', this, 'left');
27161 onRotateRight : function(e)
27163 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27165 var minScale = this.thumbEl.getWidth() / this.minWidth;
27167 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27168 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27170 this.startScale = this.scale;
27172 while (this.getScaleLevel() < minScale){
27174 this.scale = this.scale + 1;
27176 if(!this.zoomable()){
27181 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27182 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27187 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27194 this.scale = this.startScale;
27196 this.onRotateFail();
27201 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27203 if(this.isDocument){
27204 this.setThumbBoxSize();
27205 this.setThumbBoxPosition();
27206 this.setCanvasPosition();
27211 this.fireEvent('rotate', this, 'right');
27214 onRotateFail : function()
27216 this.errorEl.show(true);
27220 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27225 this.previewEl.dom.innerHTML = '';
27227 var canvasEl = document.createElement("canvas");
27229 var contextEl = canvasEl.getContext("2d");
27231 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27232 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27233 var center = this.imageEl.OriginWidth / 2;
27235 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27236 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27237 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27238 center = this.imageEl.OriginHeight / 2;
27241 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27243 contextEl.translate(center, center);
27244 contextEl.rotate(this.rotate * Math.PI / 180);
27246 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27248 this.canvasEl = document.createElement("canvas");
27250 this.contextEl = this.canvasEl.getContext("2d");
27252 switch (this.rotate) {
27255 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27256 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27258 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27263 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27264 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27266 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27267 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);
27271 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27276 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27277 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27279 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27280 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);
27284 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);
27289 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27290 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27292 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27293 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27297 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);
27304 this.previewEl.appendChild(this.canvasEl);
27306 this.setCanvasPosition();
27311 if(!this.canvasLoaded){
27315 var imageCanvas = document.createElement("canvas");
27317 var imageContext = imageCanvas.getContext("2d");
27319 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27320 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27322 var center = imageCanvas.width / 2;
27324 imageContext.translate(center, center);
27326 imageContext.rotate(this.rotate * Math.PI / 180);
27328 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27330 var canvas = document.createElement("canvas");
27332 var context = canvas.getContext("2d");
27334 canvas.width = this.minWidth;
27335 canvas.height = this.minHeight;
27337 switch (this.rotate) {
27340 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27341 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27343 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27344 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27346 var targetWidth = this.minWidth - 2 * x;
27347 var targetHeight = this.minHeight - 2 * y;
27351 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27352 scale = targetWidth / width;
27355 if(x > 0 && y == 0){
27356 scale = targetHeight / height;
27359 if(x > 0 && y > 0){
27360 scale = targetWidth / width;
27362 if(width < height){
27363 scale = targetHeight / height;
27367 context.scale(scale, scale);
27369 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27370 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27372 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27373 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27375 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27380 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27381 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27383 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27384 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27386 var targetWidth = this.minWidth - 2 * x;
27387 var targetHeight = this.minHeight - 2 * y;
27391 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27392 scale = targetWidth / width;
27395 if(x > 0 && y == 0){
27396 scale = targetHeight / height;
27399 if(x > 0 && y > 0){
27400 scale = targetWidth / width;
27402 if(width < height){
27403 scale = targetHeight / height;
27407 context.scale(scale, scale);
27409 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27410 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27412 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27413 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27415 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27417 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27422 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27423 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27425 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27426 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27428 var targetWidth = this.minWidth - 2 * x;
27429 var targetHeight = this.minHeight - 2 * y;
27433 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27434 scale = targetWidth / width;
27437 if(x > 0 && y == 0){
27438 scale = targetHeight / height;
27441 if(x > 0 && y > 0){
27442 scale = targetWidth / width;
27444 if(width < height){
27445 scale = targetHeight / height;
27449 context.scale(scale, scale);
27451 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27452 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27454 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27455 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27457 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27458 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27460 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27465 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27466 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27468 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27469 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27471 var targetWidth = this.minWidth - 2 * x;
27472 var targetHeight = this.minHeight - 2 * y;
27476 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27477 scale = targetWidth / width;
27480 if(x > 0 && y == 0){
27481 scale = targetHeight / height;
27484 if(x > 0 && y > 0){
27485 scale = targetWidth / width;
27487 if(width < height){
27488 scale = targetHeight / height;
27492 context.scale(scale, scale);
27494 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27495 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27497 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27498 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27500 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27502 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27509 this.cropData = canvas.toDataURL(this.cropType);
27511 if(this.fireEvent('crop', this, this.cropData) !== false){
27512 this.process(this.file, this.cropData);
27519 setThumbBoxSize : function()
27523 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27524 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27525 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27527 this.minWidth = width;
27528 this.minHeight = height;
27530 if(this.rotate == 90 || this.rotate == 270){
27531 this.minWidth = height;
27532 this.minHeight = width;
27537 width = Math.ceil(this.minWidth * height / this.minHeight);
27539 if(this.minWidth > this.minHeight){
27541 height = Math.ceil(this.minHeight * width / this.minWidth);
27544 this.thumbEl.setStyle({
27545 width : width + 'px',
27546 height : height + 'px'
27553 setThumbBoxPosition : function()
27555 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27556 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27558 this.thumbEl.setLeft(x);
27559 this.thumbEl.setTop(y);
27563 baseRotateLevel : function()
27565 this.baseRotate = 1;
27568 typeof(this.exif) != 'undefined' &&
27569 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27570 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27572 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27575 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27579 baseScaleLevel : function()
27583 if(this.isDocument){
27585 if(this.baseRotate == 6 || this.baseRotate == 8){
27587 height = this.thumbEl.getHeight();
27588 this.baseScale = height / this.imageEl.OriginWidth;
27590 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27591 width = this.thumbEl.getWidth();
27592 this.baseScale = width / this.imageEl.OriginHeight;
27598 height = this.thumbEl.getHeight();
27599 this.baseScale = height / this.imageEl.OriginHeight;
27601 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27602 width = this.thumbEl.getWidth();
27603 this.baseScale = width / this.imageEl.OriginWidth;
27609 if(this.baseRotate == 6 || this.baseRotate == 8){
27611 width = this.thumbEl.getHeight();
27612 this.baseScale = width / this.imageEl.OriginHeight;
27614 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27615 height = this.thumbEl.getWidth();
27616 this.baseScale = height / this.imageEl.OriginHeight;
27619 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27620 height = this.thumbEl.getWidth();
27621 this.baseScale = height / this.imageEl.OriginHeight;
27623 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27624 width = this.thumbEl.getHeight();
27625 this.baseScale = width / this.imageEl.OriginWidth;
27632 width = this.thumbEl.getWidth();
27633 this.baseScale = width / this.imageEl.OriginWidth;
27635 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27636 height = this.thumbEl.getHeight();
27637 this.baseScale = height / this.imageEl.OriginHeight;
27640 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27642 height = this.thumbEl.getHeight();
27643 this.baseScale = height / this.imageEl.OriginHeight;
27645 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27646 width = this.thumbEl.getWidth();
27647 this.baseScale = width / this.imageEl.OriginWidth;
27655 getScaleLevel : function()
27657 return this.baseScale * Math.pow(1.1, this.scale);
27660 onTouchStart : function(e)
27662 if(!this.canvasLoaded){
27663 this.beforeSelectFile(e);
27667 var touches = e.browserEvent.touches;
27673 if(touches.length == 1){
27674 this.onMouseDown(e);
27678 if(touches.length != 2){
27684 for(var i = 0, finger; finger = touches[i]; i++){
27685 coords.push(finger.pageX, finger.pageY);
27688 var x = Math.pow(coords[0] - coords[2], 2);
27689 var y = Math.pow(coords[1] - coords[3], 2);
27691 this.startDistance = Math.sqrt(x + y);
27693 this.startScale = this.scale;
27695 this.pinching = true;
27696 this.dragable = false;
27700 onTouchMove : function(e)
27702 if(!this.pinching && !this.dragable){
27706 var touches = e.browserEvent.touches;
27713 this.onMouseMove(e);
27719 for(var i = 0, finger; finger = touches[i]; i++){
27720 coords.push(finger.pageX, finger.pageY);
27723 var x = Math.pow(coords[0] - coords[2], 2);
27724 var y = Math.pow(coords[1] - coords[3], 2);
27726 this.endDistance = Math.sqrt(x + y);
27728 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27730 if(!this.zoomable()){
27731 this.scale = this.startScale;
27739 onTouchEnd : function(e)
27741 this.pinching = false;
27742 this.dragable = false;
27746 process : function(file, crop)
27749 this.maskEl.mask(this.loadingText);
27752 this.xhr = new XMLHttpRequest();
27754 file.xhr = this.xhr;
27756 this.xhr.open(this.method, this.url, true);
27759 "Accept": "application/json",
27760 "Cache-Control": "no-cache",
27761 "X-Requested-With": "XMLHttpRequest"
27764 for (var headerName in headers) {
27765 var headerValue = headers[headerName];
27767 this.xhr.setRequestHeader(headerName, headerValue);
27773 this.xhr.onload = function()
27775 _this.xhrOnLoad(_this.xhr);
27778 this.xhr.onerror = function()
27780 _this.xhrOnError(_this.xhr);
27783 var formData = new FormData();
27785 formData.append('returnHTML', 'NO');
27788 formData.append('crop', crop);
27791 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27792 formData.append(this.paramName, file, file.name);
27795 if(typeof(file.filename) != 'undefined'){
27796 formData.append('filename', file.filename);
27799 if(typeof(file.mimetype) != 'undefined'){
27800 formData.append('mimetype', file.mimetype);
27803 if(this.fireEvent('arrange', this, formData) != false){
27804 this.xhr.send(formData);
27808 xhrOnLoad : function(xhr)
27811 this.maskEl.unmask();
27814 if (xhr.readyState !== 4) {
27815 this.fireEvent('exception', this, xhr);
27819 var response = Roo.decode(xhr.responseText);
27821 if(!response.success){
27822 this.fireEvent('exception', this, xhr);
27826 var response = Roo.decode(xhr.responseText);
27828 this.fireEvent('upload', this, response);
27832 xhrOnError : function()
27835 this.maskEl.unmask();
27838 Roo.log('xhr on error');
27840 var response = Roo.decode(xhr.responseText);
27846 prepare : function(file)
27849 this.maskEl.mask(this.loadingText);
27855 if(typeof(file) === 'string'){
27856 this.loadCanvas(file);
27860 if(!file || !this.urlAPI){
27865 this.cropType = file.type;
27869 if(this.fireEvent('prepare', this, this.file) != false){
27871 var reader = new FileReader();
27873 reader.onload = function (e) {
27874 if (e.target.error) {
27875 Roo.log(e.target.error);
27879 var buffer = e.target.result,
27880 dataView = new DataView(buffer),
27882 maxOffset = dataView.byteLength - 4,
27886 if (dataView.getUint16(0) === 0xffd8) {
27887 while (offset < maxOffset) {
27888 markerBytes = dataView.getUint16(offset);
27890 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
27891 markerLength = dataView.getUint16(offset + 2) + 2;
27892 if (offset + markerLength > dataView.byteLength) {
27893 Roo.log('Invalid meta data: Invalid segment size.');
27897 if(markerBytes == 0xffe1){
27898 _this.parseExifData(
27905 offset += markerLength;
27915 var url = _this.urlAPI.createObjectURL(_this.file);
27917 _this.loadCanvas(url);
27922 reader.readAsArrayBuffer(this.file);
27928 parseExifData : function(dataView, offset, length)
27930 var tiffOffset = offset + 10,
27934 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27935 // No Exif data, might be XMP data instead
27939 // Check for the ASCII code for "Exif" (0x45786966):
27940 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27941 // No Exif data, might be XMP data instead
27944 if (tiffOffset + 8 > dataView.byteLength) {
27945 Roo.log('Invalid Exif data: Invalid segment size.');
27948 // Check for the two null bytes:
27949 if (dataView.getUint16(offset + 8) !== 0x0000) {
27950 Roo.log('Invalid Exif data: Missing byte alignment offset.');
27953 // Check the byte alignment:
27954 switch (dataView.getUint16(tiffOffset)) {
27956 littleEndian = true;
27959 littleEndian = false;
27962 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
27965 // Check for the TIFF tag marker (0x002A):
27966 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
27967 Roo.log('Invalid Exif data: Missing TIFF marker.');
27970 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
27971 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
27973 this.parseExifTags(
27976 tiffOffset + dirOffset,
27981 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
27986 if (dirOffset + 6 > dataView.byteLength) {
27987 Roo.log('Invalid Exif data: Invalid directory offset.');
27990 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
27991 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
27992 if (dirEndOffset + 4 > dataView.byteLength) {
27993 Roo.log('Invalid Exif data: Invalid directory size.');
27996 for (i = 0; i < tagsNumber; i += 1) {
28000 dirOffset + 2 + 12 * i, // tag offset
28004 // Return the offset to the next directory:
28005 return dataView.getUint32(dirEndOffset, littleEndian);
28008 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28010 var tag = dataView.getUint16(offset, littleEndian);
28012 this.exif[tag] = this.getExifValue(
28016 dataView.getUint16(offset + 2, littleEndian), // tag type
28017 dataView.getUint32(offset + 4, littleEndian), // tag length
28022 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28024 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28033 Roo.log('Invalid Exif data: Invalid tag type.');
28037 tagSize = tagType.size * length;
28038 // Determine if the value is contained in the dataOffset bytes,
28039 // or if the value at the dataOffset is a pointer to the actual data:
28040 dataOffset = tagSize > 4 ?
28041 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28042 if (dataOffset + tagSize > dataView.byteLength) {
28043 Roo.log('Invalid Exif data: Invalid data offset.');
28046 if (length === 1) {
28047 return tagType.getValue(dataView, dataOffset, littleEndian);
28050 for (i = 0; i < length; i += 1) {
28051 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28054 if (tagType.ascii) {
28056 // Concatenate the chars:
28057 for (i = 0; i < values.length; i += 1) {
28059 // Ignore the terminating NULL byte(s):
28060 if (c === '\u0000') {
28072 Roo.apply(Roo.bootstrap.UploadCropbox, {
28074 'Orientation': 0x0112
28078 1: 0, //'top-left',
28080 3: 180, //'bottom-right',
28081 // 4: 'bottom-left',
28083 6: 90, //'right-top',
28084 // 7: 'right-bottom',
28085 8: 270 //'left-bottom'
28089 // byte, 8-bit unsigned int:
28091 getValue: function (dataView, dataOffset) {
28092 return dataView.getUint8(dataOffset);
28096 // ascii, 8-bit byte:
28098 getValue: function (dataView, dataOffset) {
28099 return String.fromCharCode(dataView.getUint8(dataOffset));
28104 // short, 16 bit int:
28106 getValue: function (dataView, dataOffset, littleEndian) {
28107 return dataView.getUint16(dataOffset, littleEndian);
28111 // long, 32 bit int:
28113 getValue: function (dataView, dataOffset, littleEndian) {
28114 return dataView.getUint32(dataOffset, littleEndian);
28118 // rational = two long values, first is numerator, second is denominator:
28120 getValue: function (dataView, dataOffset, littleEndian) {
28121 return dataView.getUint32(dataOffset, littleEndian) /
28122 dataView.getUint32(dataOffset + 4, littleEndian);
28126 // slong, 32 bit signed int:
28128 getValue: function (dataView, dataOffset, littleEndian) {
28129 return dataView.getInt32(dataOffset, littleEndian);
28133 // srational, two slongs, first is numerator, second is denominator:
28135 getValue: function (dataView, dataOffset, littleEndian) {
28136 return dataView.getInt32(dataOffset, littleEndian) /
28137 dataView.getInt32(dataOffset + 4, littleEndian);
28147 cls : 'btn-group roo-upload-cropbox-rotate-left',
28148 action : 'rotate-left',
28152 cls : 'btn btn-default',
28153 html : '<i class="fa fa-undo"></i>'
28159 cls : 'btn-group roo-upload-cropbox-picture',
28160 action : 'picture',
28164 cls : 'btn btn-default',
28165 html : '<i class="fa fa-picture-o"></i>'
28171 cls : 'btn-group roo-upload-cropbox-rotate-right',
28172 action : 'rotate-right',
28176 cls : 'btn btn-default',
28177 html : '<i class="fa fa-repeat"></i>'
28185 cls : 'btn-group roo-upload-cropbox-rotate-left',
28186 action : 'rotate-left',
28190 cls : 'btn btn-default',
28191 html : '<i class="fa fa-undo"></i>'
28197 cls : 'btn-group roo-upload-cropbox-download',
28198 action : 'download',
28202 cls : 'btn btn-default',
28203 html : '<i class="fa fa-download"></i>'
28209 cls : 'btn-group roo-upload-cropbox-crop',
28214 cls : 'btn btn-default',
28215 html : '<i class="fa fa-crop"></i>'
28221 cls : 'btn-group roo-upload-cropbox-trash',
28226 cls : 'btn btn-default',
28227 html : '<i class="fa fa-trash"></i>'
28233 cls : 'btn-group roo-upload-cropbox-rotate-right',
28234 action : 'rotate-right',
28238 cls : 'btn btn-default',
28239 html : '<i class="fa fa-repeat"></i>'
28247 cls : 'btn-group roo-upload-cropbox-rotate-left',
28248 action : 'rotate-left',
28252 cls : 'btn btn-default',
28253 html : '<i class="fa fa-undo"></i>'
28259 cls : 'btn-group roo-upload-cropbox-rotate-right',
28260 action : 'rotate-right',
28264 cls : 'btn btn-default',
28265 html : '<i class="fa fa-repeat"></i>'
28278 * @class Roo.bootstrap.DocumentManager
28279 * @extends Roo.bootstrap.Component
28280 * Bootstrap DocumentManager class
28281 * @cfg {String} paramName default 'imageUpload'
28282 * @cfg {String} toolTipName default 'filename'
28283 * @cfg {String} method default POST
28284 * @cfg {String} url action url
28285 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28286 * @cfg {Boolean} multiple multiple upload default true
28287 * @cfg {Number} thumbSize default 300
28288 * @cfg {String} fieldLabel
28289 * @cfg {Number} labelWidth default 4
28290 * @cfg {String} labelAlign (left|top) default left
28291 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28292 * @cfg {Number} labellg set the width of label (1-12)
28293 * @cfg {Number} labelmd set the width of label (1-12)
28294 * @cfg {Number} labelsm set the width of label (1-12)
28295 * @cfg {Number} labelxs set the width of label (1-12)
28298 * Create a new DocumentManager
28299 * @param {Object} config The config object
28302 Roo.bootstrap.DocumentManager = function(config){
28303 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28306 this.delegates = [];
28311 * Fire when initial the DocumentManager
28312 * @param {Roo.bootstrap.DocumentManager} this
28317 * inspect selected file
28318 * @param {Roo.bootstrap.DocumentManager} this
28319 * @param {File} file
28324 * Fire when xhr load exception
28325 * @param {Roo.bootstrap.DocumentManager} this
28326 * @param {XMLHttpRequest} xhr
28328 "exception" : true,
28330 * @event afterupload
28331 * Fire when xhr load exception
28332 * @param {Roo.bootstrap.DocumentManager} this
28333 * @param {XMLHttpRequest} xhr
28335 "afterupload" : true,
28338 * prepare the form data
28339 * @param {Roo.bootstrap.DocumentManager} this
28340 * @param {Object} formData
28345 * Fire when remove the file
28346 * @param {Roo.bootstrap.DocumentManager} this
28347 * @param {Object} file
28352 * Fire after refresh the file
28353 * @param {Roo.bootstrap.DocumentManager} this
28358 * Fire after click the image
28359 * @param {Roo.bootstrap.DocumentManager} this
28360 * @param {Object} file
28365 * Fire when upload a image and editable set to true
28366 * @param {Roo.bootstrap.DocumentManager} this
28367 * @param {Object} file
28371 * @event beforeselectfile
28372 * Fire before select file
28373 * @param {Roo.bootstrap.DocumentManager} this
28375 "beforeselectfile" : true,
28378 * Fire before process file
28379 * @param {Roo.bootstrap.DocumentManager} this
28380 * @param {Object} file
28387 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28396 paramName : 'imageUpload',
28397 toolTipName : 'filename',
28400 labelAlign : 'left',
28410 getAutoCreate : function()
28412 var managerWidget = {
28414 cls : 'roo-document-manager',
28418 cls : 'roo-document-manager-selector',
28423 cls : 'roo-document-manager-uploader',
28427 cls : 'roo-document-manager-upload-btn',
28428 html : '<i class="fa fa-plus"></i>'
28439 cls : 'column col-md-12',
28444 if(this.fieldLabel.length){
28449 cls : 'column col-md-12',
28450 html : this.fieldLabel
28454 cls : 'column col-md-12',
28459 if(this.labelAlign == 'left'){
28464 html : this.fieldLabel
28473 if(this.labelWidth > 12){
28474 content[0].style = "width: " + this.labelWidth + 'px';
28477 if(this.labelWidth < 13 && this.labelmd == 0){
28478 this.labelmd = this.labelWidth;
28481 if(this.labellg > 0){
28482 content[0].cls += ' col-lg-' + this.labellg;
28483 content[1].cls += ' col-lg-' + (12 - this.labellg);
28486 if(this.labelmd > 0){
28487 content[0].cls += ' col-md-' + this.labelmd;
28488 content[1].cls += ' col-md-' + (12 - this.labelmd);
28491 if(this.labelsm > 0){
28492 content[0].cls += ' col-sm-' + this.labelsm;
28493 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28496 if(this.labelxs > 0){
28497 content[0].cls += ' col-xs-' + this.labelxs;
28498 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28506 cls : 'row clearfix',
28514 initEvents : function()
28516 this.managerEl = this.el.select('.roo-document-manager', true).first();
28517 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28519 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28520 this.selectorEl.hide();
28523 this.selectorEl.attr('multiple', 'multiple');
28526 this.selectorEl.on('change', this.onFileSelected, this);
28528 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28529 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28531 this.uploader.on('click', this.onUploaderClick, this);
28533 this.renderProgressDialog();
28537 window.addEventListener("resize", function() { _this.refresh(); } );
28539 this.fireEvent('initial', this);
28542 renderProgressDialog : function()
28546 this.progressDialog = new Roo.bootstrap.Modal({
28547 cls : 'roo-document-manager-progress-dialog',
28548 allow_close : false,
28558 btnclick : function() {
28559 _this.uploadCancel();
28565 this.progressDialog.render(Roo.get(document.body));
28567 this.progress = new Roo.bootstrap.Progress({
28568 cls : 'roo-document-manager-progress',
28573 this.progress.render(this.progressDialog.getChildContainer());
28575 this.progressBar = new Roo.bootstrap.ProgressBar({
28576 cls : 'roo-document-manager-progress-bar',
28579 aria_valuemax : 12,
28583 this.progressBar.render(this.progress.getChildContainer());
28586 onUploaderClick : function(e)
28588 e.preventDefault();
28590 if(this.fireEvent('beforeselectfile', this) != false){
28591 this.selectorEl.dom.click();
28596 onFileSelected : function(e)
28598 e.preventDefault();
28600 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28604 Roo.each(this.selectorEl.dom.files, function(file){
28605 if(this.fireEvent('inspect', this, file) != false){
28606 this.files.push(file);
28616 this.selectorEl.dom.value = '';
28618 if(!this.files.length){
28622 if(this.boxes > 0 && this.files.length > this.boxes){
28623 this.files = this.files.slice(0, this.boxes);
28626 this.uploader.show();
28628 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28629 this.uploader.hide();
28638 Roo.each(this.files, function(file){
28640 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28641 var f = this.renderPreview(file);
28646 if(file.type.indexOf('image') != -1){
28647 this.delegates.push(
28649 _this.process(file);
28650 }).createDelegate(this)
28658 _this.process(file);
28659 }).createDelegate(this)
28664 this.files = files;
28666 this.delegates = this.delegates.concat(docs);
28668 if(!this.delegates.length){
28673 this.progressBar.aria_valuemax = this.delegates.length;
28680 arrange : function()
28682 if(!this.delegates.length){
28683 this.progressDialog.hide();
28688 var delegate = this.delegates.shift();
28690 this.progressDialog.show();
28692 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28694 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28699 refresh : function()
28701 this.uploader.show();
28703 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28704 this.uploader.hide();
28707 Roo.isTouch ? this.closable(false) : this.closable(true);
28709 this.fireEvent('refresh', this);
28712 onRemove : function(e, el, o)
28714 e.preventDefault();
28716 this.fireEvent('remove', this, o);
28720 remove : function(o)
28724 Roo.each(this.files, function(file){
28725 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28734 this.files = files;
28741 Roo.each(this.files, function(file){
28746 file.target.remove();
28755 onClick : function(e, el, o)
28757 e.preventDefault();
28759 this.fireEvent('click', this, o);
28763 closable : function(closable)
28765 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28767 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28779 xhrOnLoad : function(xhr)
28781 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28785 if (xhr.readyState !== 4) {
28787 this.fireEvent('exception', this, xhr);
28791 var response = Roo.decode(xhr.responseText);
28793 if(!response.success){
28795 this.fireEvent('exception', this, xhr);
28799 var file = this.renderPreview(response.data);
28801 this.files.push(file);
28805 this.fireEvent('afterupload', this, xhr);
28809 xhrOnError : function(xhr)
28811 Roo.log('xhr on error');
28813 var response = Roo.decode(xhr.responseText);
28820 process : function(file)
28822 if(this.fireEvent('process', this, file) !== false){
28823 if(this.editable && file.type.indexOf('image') != -1){
28824 this.fireEvent('edit', this, file);
28828 this.uploadStart(file, false);
28835 uploadStart : function(file, crop)
28837 this.xhr = new XMLHttpRequest();
28839 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28844 file.xhr = this.xhr;
28846 this.managerEl.createChild({
28848 cls : 'roo-document-manager-loading',
28852 tooltip : file.name,
28853 cls : 'roo-document-manager-thumb',
28854 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28860 this.xhr.open(this.method, this.url, true);
28863 "Accept": "application/json",
28864 "Cache-Control": "no-cache",
28865 "X-Requested-With": "XMLHttpRequest"
28868 for (var headerName in headers) {
28869 var headerValue = headers[headerName];
28871 this.xhr.setRequestHeader(headerName, headerValue);
28877 this.xhr.onload = function()
28879 _this.xhrOnLoad(_this.xhr);
28882 this.xhr.onerror = function()
28884 _this.xhrOnError(_this.xhr);
28887 var formData = new FormData();
28889 formData.append('returnHTML', 'NO');
28892 formData.append('crop', crop);
28895 formData.append(this.paramName, file, file.name);
28902 if(this.fireEvent('prepare', this, formData, options) != false){
28904 if(options.manually){
28908 this.xhr.send(formData);
28912 this.uploadCancel();
28915 uploadCancel : function()
28921 this.delegates = [];
28923 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28930 renderPreview : function(file)
28932 if(typeof(file.target) != 'undefined' && file.target){
28936 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
28938 var previewEl = this.managerEl.createChild({
28940 cls : 'roo-document-manager-preview',
28944 tooltip : file[this.toolTipName],
28945 cls : 'roo-document-manager-thumb',
28946 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
28951 html : '<i class="fa fa-times-circle"></i>'
28956 var close = previewEl.select('button.close', true).first();
28958 close.on('click', this.onRemove, this, file);
28960 file.target = previewEl;
28962 var image = previewEl.select('img', true).first();
28966 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
28968 image.on('click', this.onClick, this, file);
28974 onPreviewLoad : function(file, image)
28976 if(typeof(file.target) == 'undefined' || !file.target){
28980 var width = image.dom.naturalWidth || image.dom.width;
28981 var height = image.dom.naturalHeight || image.dom.height;
28983 if(width > height){
28984 file.target.addClass('wide');
28988 file.target.addClass('tall');
28993 uploadFromSource : function(file, crop)
28995 this.xhr = new XMLHttpRequest();
28997 this.managerEl.createChild({
28999 cls : 'roo-document-manager-loading',
29003 tooltip : file.name,
29004 cls : 'roo-document-manager-thumb',
29005 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29011 this.xhr.open(this.method, this.url, true);
29014 "Accept": "application/json",
29015 "Cache-Control": "no-cache",
29016 "X-Requested-With": "XMLHttpRequest"
29019 for (var headerName in headers) {
29020 var headerValue = headers[headerName];
29022 this.xhr.setRequestHeader(headerName, headerValue);
29028 this.xhr.onload = function()
29030 _this.xhrOnLoad(_this.xhr);
29033 this.xhr.onerror = function()
29035 _this.xhrOnError(_this.xhr);
29038 var formData = new FormData();
29040 formData.append('returnHTML', 'NO');
29042 formData.append('crop', crop);
29044 if(typeof(file.filename) != 'undefined'){
29045 formData.append('filename', file.filename);
29048 if(typeof(file.mimetype) != 'undefined'){
29049 formData.append('mimetype', file.mimetype);
29054 if(this.fireEvent('prepare', this, formData) != false){
29055 this.xhr.send(formData);
29065 * @class Roo.bootstrap.DocumentViewer
29066 * @extends Roo.bootstrap.Component
29067 * Bootstrap DocumentViewer class
29068 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29069 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29072 * Create a new DocumentViewer
29073 * @param {Object} config The config object
29076 Roo.bootstrap.DocumentViewer = function(config){
29077 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29082 * Fire after initEvent
29083 * @param {Roo.bootstrap.DocumentViewer} this
29089 * @param {Roo.bootstrap.DocumentViewer} this
29094 * Fire after download button
29095 * @param {Roo.bootstrap.DocumentViewer} this
29100 * Fire after trash button
29101 * @param {Roo.bootstrap.DocumentViewer} this
29108 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29110 showDownload : true,
29114 getAutoCreate : function()
29118 cls : 'roo-document-viewer',
29122 cls : 'roo-document-viewer-body',
29126 cls : 'roo-document-viewer-thumb',
29130 cls : 'roo-document-viewer-image'
29138 cls : 'roo-document-viewer-footer',
29141 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29145 cls : 'btn-group roo-document-viewer-download',
29149 cls : 'btn btn-default',
29150 html : '<i class="fa fa-download"></i>'
29156 cls : 'btn-group roo-document-viewer-trash',
29160 cls : 'btn btn-default',
29161 html : '<i class="fa fa-trash"></i>'
29174 initEvents : function()
29176 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29177 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29179 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29180 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29182 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29183 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29185 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29186 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29188 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29189 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29191 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29192 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29194 this.bodyEl.on('click', this.onClick, this);
29195 this.downloadBtn.on('click', this.onDownload, this);
29196 this.trashBtn.on('click', this.onTrash, this);
29198 this.downloadBtn.hide();
29199 this.trashBtn.hide();
29201 if(this.showDownload){
29202 this.downloadBtn.show();
29205 if(this.showTrash){
29206 this.trashBtn.show();
29209 if(!this.showDownload && !this.showTrash) {
29210 this.footerEl.hide();
29215 initial : function()
29217 this.fireEvent('initial', this);
29221 onClick : function(e)
29223 e.preventDefault();
29225 this.fireEvent('click', this);
29228 onDownload : function(e)
29230 e.preventDefault();
29232 this.fireEvent('download', this);
29235 onTrash : function(e)
29237 e.preventDefault();
29239 this.fireEvent('trash', this);
29251 * @class Roo.bootstrap.NavProgressBar
29252 * @extends Roo.bootstrap.Component
29253 * Bootstrap NavProgressBar class
29256 * Create a new nav progress bar
29257 * @param {Object} config The config object
29260 Roo.bootstrap.NavProgressBar = function(config){
29261 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29263 this.bullets = this.bullets || [];
29265 // Roo.bootstrap.NavProgressBar.register(this);
29269 * Fires when the active item changes
29270 * @param {Roo.bootstrap.NavProgressBar} this
29271 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29272 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29279 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29284 getAutoCreate : function()
29286 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29290 cls : 'roo-navigation-bar-group',
29294 cls : 'roo-navigation-top-bar'
29298 cls : 'roo-navigation-bullets-bar',
29302 cls : 'roo-navigation-bar'
29309 cls : 'roo-navigation-bottom-bar'
29319 initEvents: function()
29324 onRender : function(ct, position)
29326 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29328 if(this.bullets.length){
29329 Roo.each(this.bullets, function(b){
29338 addItem : function(cfg)
29340 var item = new Roo.bootstrap.NavProgressItem(cfg);
29342 item.parentId = this.id;
29343 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29346 var top = new Roo.bootstrap.Element({
29348 cls : 'roo-navigation-bar-text'
29351 var bottom = new Roo.bootstrap.Element({
29353 cls : 'roo-navigation-bar-text'
29356 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29357 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29359 var topText = new Roo.bootstrap.Element({
29361 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29364 var bottomText = new Roo.bootstrap.Element({
29366 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29369 topText.onRender(top.el, null);
29370 bottomText.onRender(bottom.el, null);
29373 item.bottomEl = bottom;
29376 this.barItems.push(item);
29381 getActive : function()
29383 var active = false;
29385 Roo.each(this.barItems, function(v){
29387 if (!v.isActive()) {
29399 setActiveItem : function(item)
29403 Roo.each(this.barItems, function(v){
29404 if (v.rid == item.rid) {
29408 if (v.isActive()) {
29409 v.setActive(false);
29414 item.setActive(true);
29416 this.fireEvent('changed', this, item, prev);
29419 getBarItem: function(rid)
29423 Roo.each(this.barItems, function(e) {
29424 if (e.rid != rid) {
29435 indexOfItem : function(item)
29439 Roo.each(this.barItems, function(v, i){
29441 if (v.rid != item.rid) {
29452 setActiveNext : function()
29454 var i = this.indexOfItem(this.getActive());
29456 if (i > this.barItems.length) {
29460 this.setActiveItem(this.barItems[i+1]);
29463 setActivePrev : function()
29465 var i = this.indexOfItem(this.getActive());
29471 this.setActiveItem(this.barItems[i-1]);
29474 format : function()
29476 if(!this.barItems.length){
29480 var width = 100 / this.barItems.length;
29482 Roo.each(this.barItems, function(i){
29483 i.el.setStyle('width', width + '%');
29484 i.topEl.el.setStyle('width', width + '%');
29485 i.bottomEl.el.setStyle('width', width + '%');
29494 * Nav Progress Item
29499 * @class Roo.bootstrap.NavProgressItem
29500 * @extends Roo.bootstrap.Component
29501 * Bootstrap NavProgressItem class
29502 * @cfg {String} rid the reference id
29503 * @cfg {Boolean} active (true|false) Is item active default false
29504 * @cfg {Boolean} disabled (true|false) Is item active default false
29505 * @cfg {String} html
29506 * @cfg {String} position (top|bottom) text position default bottom
29507 * @cfg {String} icon show icon instead of number
29510 * Create a new NavProgressItem
29511 * @param {Object} config The config object
29513 Roo.bootstrap.NavProgressItem = function(config){
29514 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29519 * The raw click event for the entire grid.
29520 * @param {Roo.bootstrap.NavProgressItem} this
29521 * @param {Roo.EventObject} e
29528 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29534 position : 'bottom',
29537 getAutoCreate : function()
29539 var iconCls = 'roo-navigation-bar-item-icon';
29541 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29545 cls: 'roo-navigation-bar-item',
29555 cfg.cls += ' active';
29558 cfg.cls += ' disabled';
29564 disable : function()
29566 this.setDisabled(true);
29569 enable : function()
29571 this.setDisabled(false);
29574 initEvents: function()
29576 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29578 this.iconEl.on('click', this.onClick, this);
29581 onClick : function(e)
29583 e.preventDefault();
29589 if(this.fireEvent('click', this, e) === false){
29593 this.parent().setActiveItem(this);
29596 isActive: function ()
29598 return this.active;
29601 setActive : function(state)
29603 if(this.active == state){
29607 this.active = state;
29610 this.el.addClass('active');
29614 this.el.removeClass('active');
29619 setDisabled : function(state)
29621 if(this.disabled == state){
29625 this.disabled = state;
29628 this.el.addClass('disabled');
29632 this.el.removeClass('disabled');
29635 tooltipEl : function()
29637 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29650 * @class Roo.bootstrap.FieldLabel
29651 * @extends Roo.bootstrap.Component
29652 * Bootstrap FieldLabel class
29653 * @cfg {String} html contents of the element
29654 * @cfg {String} tag tag of the element default label
29655 * @cfg {String} cls class of the element
29656 * @cfg {String} target label target
29657 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29658 * @cfg {String} invalidClass default "text-danger fa fa-lg fa-exclamation-triangle"
29659 * @cfg {String} validClass default "text-success fa fa-lg fa-check"
29660 * @cfg {String} iconTooltip default "This field is required"
29663 * Create a new FieldLabel
29664 * @param {Object} config The config object
29667 Roo.bootstrap.FieldLabel = function(config){
29668 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29673 * Fires after the field has been marked as invalid.
29674 * @param {Roo.form.FieldLabel} this
29675 * @param {String} msg The validation message
29680 * Fires after the field has been validated with no errors.
29681 * @param {Roo.form.FieldLabel} this
29687 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29694 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
29695 validClass : 'text-success fa fa-lg fa-check',
29696 iconTooltip : 'This field is required',
29698 getAutoCreate : function(){
29702 cls : 'roo-bootstrap-field-label ' + this.cls,
29708 tooltip : this.iconTooltip
29720 initEvents: function()
29722 Roo.bootstrap.Element.superclass.initEvents.call(this);
29724 this.iconEl = this.el.select('i', true).first();
29726 this.iconEl.setVisibilityMode(Roo.Element.DISPLAY).hide();
29728 Roo.bootstrap.FieldLabel.register(this);
29732 * Mark this field as valid
29734 markValid : function()
29736 this.iconEl.show();
29738 this.iconEl.removeClass(this.invalidClass);
29740 this.iconEl.addClass(this.validClass);
29742 this.fireEvent('valid', this);
29746 * Mark this field as invalid
29747 * @param {String} msg The validation message
29749 markInvalid : function(msg)
29751 this.iconEl.show();
29753 this.iconEl.removeClass(this.validClass);
29755 this.iconEl.addClass(this.invalidClass);
29757 this.fireEvent('invalid', this, msg);
29763 Roo.apply(Roo.bootstrap.FieldLabel, {
29768 * register a FieldLabel Group
29769 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29771 register : function(label)
29773 if(this.groups.hasOwnProperty(label.target)){
29777 this.groups[label.target] = label;
29781 * fetch a FieldLabel Group based on the target
29782 * @param {string} target
29783 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29785 get: function(target) {
29786 if (typeof(this.groups[target]) == 'undefined') {
29790 return this.groups[target] ;
29799 * page DateSplitField.
29805 * @class Roo.bootstrap.DateSplitField
29806 * @extends Roo.bootstrap.Component
29807 * Bootstrap DateSplitField class
29808 * @cfg {string} fieldLabel - the label associated
29809 * @cfg {Number} labelWidth set the width of label (0-12)
29810 * @cfg {String} labelAlign (top|left)
29811 * @cfg {Boolean} dayAllowBlank (true|false) default false
29812 * @cfg {Boolean} monthAllowBlank (true|false) default false
29813 * @cfg {Boolean} yearAllowBlank (true|false) default false
29814 * @cfg {string} dayPlaceholder
29815 * @cfg {string} monthPlaceholder
29816 * @cfg {string} yearPlaceholder
29817 * @cfg {string} dayFormat default 'd'
29818 * @cfg {string} monthFormat default 'm'
29819 * @cfg {string} yearFormat default 'Y'
29820 * @cfg {Number} labellg set the width of label (1-12)
29821 * @cfg {Number} labelmd set the width of label (1-12)
29822 * @cfg {Number} labelsm set the width of label (1-12)
29823 * @cfg {Number} labelxs set the width of label (1-12)
29827 * Create a new DateSplitField
29828 * @param {Object} config The config object
29831 Roo.bootstrap.DateSplitField = function(config){
29832 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
29838 * getting the data of years
29839 * @param {Roo.bootstrap.DateSplitField} this
29840 * @param {Object} years
29845 * getting the data of days
29846 * @param {Roo.bootstrap.DateSplitField} this
29847 * @param {Object} days
29852 * Fires after the field has been marked as invalid.
29853 * @param {Roo.form.Field} this
29854 * @param {String} msg The validation message
29859 * Fires after the field has been validated with no errors.
29860 * @param {Roo.form.Field} this
29866 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
29869 labelAlign : 'top',
29871 dayAllowBlank : false,
29872 monthAllowBlank : false,
29873 yearAllowBlank : false,
29874 dayPlaceholder : '',
29875 monthPlaceholder : '',
29876 yearPlaceholder : '',
29880 isFormField : true,
29886 getAutoCreate : function()
29890 cls : 'row roo-date-split-field-group',
29895 cls : 'form-hidden-field roo-date-split-field-group-value',
29901 var labelCls = 'col-md-12';
29902 var contentCls = 'col-md-4';
29904 if(this.fieldLabel){
29908 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
29912 html : this.fieldLabel
29917 if(this.labelAlign == 'left'){
29919 if(this.labelWidth > 12){
29920 label.style = "width: " + this.labelWidth + 'px';
29923 if(this.labelWidth < 13 && this.labelmd == 0){
29924 this.labelmd = this.labelWidth;
29927 if(this.labellg > 0){
29928 labelCls = ' col-lg-' + this.labellg;
29929 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
29932 if(this.labelmd > 0){
29933 labelCls = ' col-md-' + this.labelmd;
29934 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
29937 if(this.labelsm > 0){
29938 labelCls = ' col-sm-' + this.labelsm;
29939 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
29942 if(this.labelxs > 0){
29943 labelCls = ' col-xs-' + this.labelxs;
29944 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
29948 label.cls += ' ' + labelCls;
29950 cfg.cn.push(label);
29953 Roo.each(['day', 'month', 'year'], function(t){
29956 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
29963 inputEl: function ()
29965 return this.el.select('.roo-date-split-field-group-value', true).first();
29968 onRender : function(ct, position)
29972 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29974 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
29976 this.dayField = new Roo.bootstrap.ComboBox({
29977 allowBlank : this.dayAllowBlank,
29978 alwaysQuery : true,
29979 displayField : 'value',
29982 forceSelection : true,
29984 placeholder : this.dayPlaceholder,
29985 selectOnFocus : true,
29986 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
29987 triggerAction : 'all',
29989 valueField : 'value',
29990 store : new Roo.data.SimpleStore({
29991 data : (function() {
29993 _this.fireEvent('days', _this, days);
29996 fields : [ 'value' ]
29999 select : function (_self, record, index)
30001 _this.setValue(_this.getValue());
30006 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30008 this.monthField = new Roo.bootstrap.MonthField({
30009 after : '<i class=\"fa fa-calendar\"></i>',
30010 allowBlank : this.monthAllowBlank,
30011 placeholder : this.monthPlaceholder,
30014 render : function (_self)
30016 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30017 e.preventDefault();
30021 select : function (_self, oldvalue, newvalue)
30023 _this.setValue(_this.getValue());
30028 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30030 this.yearField = new Roo.bootstrap.ComboBox({
30031 allowBlank : this.yearAllowBlank,
30032 alwaysQuery : true,
30033 displayField : 'value',
30036 forceSelection : true,
30038 placeholder : this.yearPlaceholder,
30039 selectOnFocus : true,
30040 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30041 triggerAction : 'all',
30043 valueField : 'value',
30044 store : new Roo.data.SimpleStore({
30045 data : (function() {
30047 _this.fireEvent('years', _this, years);
30050 fields : [ 'value' ]
30053 select : function (_self, record, index)
30055 _this.setValue(_this.getValue());
30060 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30063 setValue : function(v, format)
30065 this.inputEl.dom.value = v;
30067 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30069 var d = Date.parseDate(v, f);
30076 this.setDay(d.format(this.dayFormat));
30077 this.setMonth(d.format(this.monthFormat));
30078 this.setYear(d.format(this.yearFormat));
30085 setDay : function(v)
30087 this.dayField.setValue(v);
30088 this.inputEl.dom.value = this.getValue();
30093 setMonth : function(v)
30095 this.monthField.setValue(v, true);
30096 this.inputEl.dom.value = this.getValue();
30101 setYear : function(v)
30103 this.yearField.setValue(v);
30104 this.inputEl.dom.value = this.getValue();
30109 getDay : function()
30111 return this.dayField.getValue();
30114 getMonth : function()
30116 return this.monthField.getValue();
30119 getYear : function()
30121 return this.yearField.getValue();
30124 getValue : function()
30126 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30128 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30138 this.inputEl.dom.value = '';
30143 validate : function()
30145 var d = this.dayField.validate();
30146 var m = this.monthField.validate();
30147 var y = this.yearField.validate();
30152 (!this.dayAllowBlank && !d) ||
30153 (!this.monthAllowBlank && !m) ||
30154 (!this.yearAllowBlank && !y)
30159 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30168 this.markInvalid();
30173 markValid : function()
30176 var label = this.el.select('label', true).first();
30177 var icon = this.el.select('i.fa-star', true).first();
30183 this.fireEvent('valid', this);
30187 * Mark this field as invalid
30188 * @param {String} msg The validation message
30190 markInvalid : function(msg)
30193 var label = this.el.select('label', true).first();
30194 var icon = this.el.select('i.fa-star', true).first();
30196 if(label && !icon){
30197 this.el.select('.roo-date-split-field-label', true).createChild({
30199 cls : 'text-danger fa fa-lg fa-star',
30200 tooltip : 'This field is required',
30201 style : 'margin-right:5px;'
30205 this.fireEvent('invalid', this, msg);
30208 clearInvalid : function()
30210 var label = this.el.select('label', true).first();
30211 var icon = this.el.select('i.fa-star', true).first();
30217 this.fireEvent('valid', this);
30220 getName: function()
30230 * http://masonry.desandro.com
30232 * The idea is to render all the bricks based on vertical width...
30234 * The original code extends 'outlayer' - we might need to use that....
30240 * @class Roo.bootstrap.LayoutMasonry
30241 * @extends Roo.bootstrap.Component
30242 * Bootstrap Layout Masonry class
30245 * Create a new Element
30246 * @param {Object} config The config object
30249 Roo.bootstrap.LayoutMasonry = function(config){
30251 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30255 Roo.bootstrap.LayoutMasonry.register(this);
30261 * Fire after layout the items
30262 * @param {Roo.bootstrap.LayoutMasonry} this
30263 * @param {Roo.EventObject} e
30270 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30273 * @cfg {Boolean} isLayoutInstant = no animation?
30275 isLayoutInstant : false, // needed?
30278 * @cfg {Number} boxWidth width of the columns
30283 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30288 * @cfg {Number} padWidth padding below box..
30293 * @cfg {Number} gutter gutter width..
30298 * @cfg {Number} maxCols maximum number of columns
30304 * @cfg {Boolean} isAutoInitial defalut true
30306 isAutoInitial : true,
30311 * @cfg {Boolean} isHorizontal defalut false
30313 isHorizontal : false,
30315 currentSize : null,
30321 bricks: null, //CompositeElement
30325 _isLayoutInited : false,
30327 // isAlternative : false, // only use for vertical layout...
30330 * @cfg {Number} alternativePadWidth padding below box..
30332 alternativePadWidth : 50,
30334 selectedBrick : [],
30336 getAutoCreate : function(){
30338 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30342 cls: 'blog-masonary-wrapper ' + this.cls,
30344 cls : 'mas-boxes masonary'
30351 getChildContainer: function( )
30353 if (this.boxesEl) {
30354 return this.boxesEl;
30357 this.boxesEl = this.el.select('.mas-boxes').first();
30359 return this.boxesEl;
30363 initEvents : function()
30367 if(this.isAutoInitial){
30368 Roo.log('hook children rendered');
30369 this.on('childrenrendered', function() {
30370 Roo.log('children rendered');
30376 initial : function()
30378 this.selectedBrick = [];
30380 this.currentSize = this.el.getBox(true);
30382 Roo.EventManager.onWindowResize(this.resize, this);
30384 if(!this.isAutoInitial){
30392 //this.layout.defer(500,this);
30396 resize : function()
30398 var cs = this.el.getBox(true);
30401 this.currentSize.width == cs.width &&
30402 this.currentSize.x == cs.x &&
30403 this.currentSize.height == cs.height &&
30404 this.currentSize.y == cs.y
30406 Roo.log("no change in with or X or Y");
30410 this.currentSize = cs;
30416 layout : function()
30418 this._resetLayout();
30420 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30422 this.layoutItems( isInstant );
30424 this._isLayoutInited = true;
30426 this.fireEvent('layout', this);
30430 _resetLayout : function()
30432 if(this.isHorizontal){
30433 this.horizontalMeasureColumns();
30437 this.verticalMeasureColumns();
30441 verticalMeasureColumns : function()
30443 this.getContainerWidth();
30445 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30446 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30450 var boxWidth = this.boxWidth + this.padWidth;
30452 if(this.containerWidth < this.boxWidth){
30453 boxWidth = this.containerWidth
30456 var containerWidth = this.containerWidth;
30458 var cols = Math.floor(containerWidth / boxWidth);
30460 this.cols = Math.max( cols, 1 );
30462 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30464 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30466 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30468 this.colWidth = boxWidth + avail - this.padWidth;
30470 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30471 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30474 horizontalMeasureColumns : function()
30476 this.getContainerWidth();
30478 var boxWidth = this.boxWidth;
30480 if(this.containerWidth < boxWidth){
30481 boxWidth = this.containerWidth;
30484 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30486 this.el.setHeight(boxWidth);
30490 getContainerWidth : function()
30492 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30495 layoutItems : function( isInstant )
30497 Roo.log(this.bricks);
30499 var items = Roo.apply([], this.bricks);
30501 if(this.isHorizontal){
30502 this._horizontalLayoutItems( items , isInstant );
30506 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30507 // this._verticalAlternativeLayoutItems( items , isInstant );
30511 this._verticalLayoutItems( items , isInstant );
30515 _verticalLayoutItems : function ( items , isInstant)
30517 if ( !items || !items.length ) {
30522 ['xs', 'xs', 'xs', 'tall'],
30523 ['xs', 'xs', 'tall'],
30524 ['xs', 'xs', 'sm'],
30525 ['xs', 'xs', 'xs'],
30531 ['sm', 'xs', 'xs'],
30535 ['tall', 'xs', 'xs', 'xs'],
30536 ['tall', 'xs', 'xs'],
30548 Roo.each(items, function(item, k){
30550 switch (item.size) {
30551 // these layouts take up a full box,
30562 boxes.push([item]);
30585 var filterPattern = function(box, length)
30593 var pattern = box.slice(0, length);
30597 Roo.each(pattern, function(i){
30598 format.push(i.size);
30601 Roo.each(standard, function(s){
30603 if(String(s) != String(format)){
30612 if(!match && length == 1){
30617 filterPattern(box, length - 1);
30621 queue.push(pattern);
30623 box = box.slice(length, box.length);
30625 filterPattern(box, 4);
30631 Roo.each(boxes, function(box, k){
30637 if(box.length == 1){
30642 filterPattern(box, 4);
30646 this._processVerticalLayoutQueue( queue, isInstant );
30650 // _verticalAlternativeLayoutItems : function( items , isInstant )
30652 // if ( !items || !items.length ) {
30656 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30660 _horizontalLayoutItems : function ( items , isInstant)
30662 if ( !items || !items.length || items.length < 3) {
30668 var eItems = items.slice(0, 3);
30670 items = items.slice(3, items.length);
30673 ['xs', 'xs', 'xs', 'wide'],
30674 ['xs', 'xs', 'wide'],
30675 ['xs', 'xs', 'sm'],
30676 ['xs', 'xs', 'xs'],
30682 ['sm', 'xs', 'xs'],
30686 ['wide', 'xs', 'xs', 'xs'],
30687 ['wide', 'xs', 'xs'],
30700 Roo.each(items, function(item, k){
30702 switch (item.size) {
30713 boxes.push([item]);
30737 var filterPattern = function(box, length)
30745 var pattern = box.slice(0, length);
30749 Roo.each(pattern, function(i){
30750 format.push(i.size);
30753 Roo.each(standard, function(s){
30755 if(String(s) != String(format)){
30764 if(!match && length == 1){
30769 filterPattern(box, length - 1);
30773 queue.push(pattern);
30775 box = box.slice(length, box.length);
30777 filterPattern(box, 4);
30783 Roo.each(boxes, function(box, k){
30789 if(box.length == 1){
30794 filterPattern(box, 4);
30801 var pos = this.el.getBox(true);
30805 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30807 var hit_end = false;
30809 Roo.each(queue, function(box){
30813 Roo.each(box, function(b){
30815 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30825 Roo.each(box, function(b){
30827 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30830 mx = Math.max(mx, b.x);
30834 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
30838 Roo.each(box, function(b){
30840 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30854 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
30857 /** Sets position of item in DOM
30858 * @param {Element} item
30859 * @param {Number} x - horizontal position
30860 * @param {Number} y - vertical position
30861 * @param {Boolean} isInstant - disables transitions
30863 _processVerticalLayoutQueue : function( queue, isInstant )
30865 var pos = this.el.getBox(true);
30870 for (var i = 0; i < this.cols; i++){
30874 Roo.each(queue, function(box, k){
30876 var col = k % this.cols;
30878 Roo.each(box, function(b,kk){
30880 b.el.position('absolute');
30882 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30883 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30885 if(b.size == 'md-left' || b.size == 'md-right'){
30886 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
30887 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
30890 b.el.setWidth(width);
30891 b.el.setHeight(height);
30893 b.el.select('iframe',true).setSize(width,height);
30897 for (var i = 0; i < this.cols; i++){
30899 if(maxY[i] < maxY[col]){
30904 col = Math.min(col, i);
30908 x = pos.x + col * (this.colWidth + this.padWidth);
30912 var positions = [];
30914 switch (box.length){
30916 positions = this.getVerticalOneBoxColPositions(x, y, box);
30919 positions = this.getVerticalTwoBoxColPositions(x, y, box);
30922 positions = this.getVerticalThreeBoxColPositions(x, y, box);
30925 positions = this.getVerticalFourBoxColPositions(x, y, box);
30931 Roo.each(box, function(b,kk){
30933 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
30935 var sz = b.el.getSize();
30937 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
30945 for (var i = 0; i < this.cols; i++){
30946 mY = Math.max(mY, maxY[i]);
30949 this.el.setHeight(mY - pos.y);
30953 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
30955 // var pos = this.el.getBox(true);
30958 // var maxX = pos.right;
30960 // var maxHeight = 0;
30962 // Roo.each(items, function(item, k){
30966 // item.el.position('absolute');
30968 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
30970 // item.el.setWidth(width);
30972 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
30974 // item.el.setHeight(height);
30977 // item.el.setXY([x, y], isInstant ? false : true);
30979 // item.el.setXY([maxX - width, y], isInstant ? false : true);
30982 // y = y + height + this.alternativePadWidth;
30984 // maxHeight = maxHeight + height + this.alternativePadWidth;
30988 // this.el.setHeight(maxHeight);
30992 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
30994 var pos = this.el.getBox(true);
30999 var maxX = pos.right;
31001 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31003 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31005 Roo.each(queue, function(box, k){
31007 Roo.each(box, function(b, kk){
31009 b.el.position('absolute');
31011 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31012 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31014 if(b.size == 'md-left' || b.size == 'md-right'){
31015 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31016 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31019 b.el.setWidth(width);
31020 b.el.setHeight(height);
31028 var positions = [];
31030 switch (box.length){
31032 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31035 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31038 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31041 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31047 Roo.each(box, function(b,kk){
31049 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31051 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31059 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31061 Roo.each(eItems, function(b,k){
31063 b.size = (k == 0) ? 'sm' : 'xs';
31064 b.x = (k == 0) ? 2 : 1;
31065 b.y = (k == 0) ? 2 : 1;
31067 b.el.position('absolute');
31069 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31071 b.el.setWidth(width);
31073 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31075 b.el.setHeight(height);
31079 var positions = [];
31082 x : maxX - this.unitWidth * 2 - this.gutter,
31087 x : maxX - this.unitWidth,
31088 y : minY + (this.unitWidth + this.gutter) * 2
31092 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31096 Roo.each(eItems, function(b,k){
31098 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31104 getVerticalOneBoxColPositions : function(x, y, box)
31108 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31110 if(box[0].size == 'md-left'){
31114 if(box[0].size == 'md-right'){
31119 x : x + (this.unitWidth + this.gutter) * rand,
31126 getVerticalTwoBoxColPositions : function(x, y, box)
31130 if(box[0].size == 'xs'){
31134 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31138 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31152 x : x + (this.unitWidth + this.gutter) * 2,
31153 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31160 getVerticalThreeBoxColPositions : function(x, y, box)
31164 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31172 x : x + (this.unitWidth + this.gutter) * 1,
31177 x : x + (this.unitWidth + this.gutter) * 2,
31185 if(box[0].size == 'xs' && box[1].size == 'xs'){
31194 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31198 x : x + (this.unitWidth + this.gutter) * 1,
31212 x : x + (this.unitWidth + this.gutter) * 2,
31217 x : x + (this.unitWidth + this.gutter) * 2,
31218 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31225 getVerticalFourBoxColPositions : function(x, y, box)
31229 if(box[0].size == 'xs'){
31238 y : y + (this.unitHeight + this.gutter) * 1
31243 y : y + (this.unitHeight + this.gutter) * 2
31247 x : x + (this.unitWidth + this.gutter) * 1,
31261 x : x + (this.unitWidth + this.gutter) * 2,
31266 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31267 y : y + (this.unitHeight + this.gutter) * 1
31271 x : x + (this.unitWidth + this.gutter) * 2,
31272 y : y + (this.unitWidth + this.gutter) * 2
31279 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31283 if(box[0].size == 'md-left'){
31285 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31292 if(box[0].size == 'md-right'){
31294 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31295 y : minY + (this.unitWidth + this.gutter) * 1
31301 var rand = Math.floor(Math.random() * (4 - box[0].y));
31304 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31305 y : minY + (this.unitWidth + this.gutter) * rand
31312 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31316 if(box[0].size == 'xs'){
31319 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31324 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31325 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31333 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31338 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31339 y : minY + (this.unitWidth + this.gutter) * 2
31346 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31350 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31353 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31358 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31359 y : minY + (this.unitWidth + this.gutter) * 1
31363 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31364 y : minY + (this.unitWidth + this.gutter) * 2
31371 if(box[0].size == 'xs' && box[1].size == 'xs'){
31374 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31379 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31384 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31385 y : minY + (this.unitWidth + this.gutter) * 1
31393 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31398 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31399 y : minY + (this.unitWidth + this.gutter) * 2
31403 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31404 y : minY + (this.unitWidth + this.gutter) * 2
31411 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31415 if(box[0].size == 'xs'){
31418 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31423 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31428 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),
31433 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31434 y : minY + (this.unitWidth + this.gutter) * 1
31442 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31447 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31448 y : minY + (this.unitWidth + this.gutter) * 2
31452 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31453 y : minY + (this.unitWidth + this.gutter) * 2
31457 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),
31458 y : minY + (this.unitWidth + this.gutter) * 2
31466 * remove a Masonry Brick
31467 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31469 removeBrick : function(brick_id)
31475 for (var i = 0; i<this.bricks.length; i++) {
31476 if (this.bricks[i].id == brick_id) {
31477 this.bricks.splice(i,1);
31478 this.el.dom.removeChild(Roo.get(brick_id).dom);
31485 * adds a Masonry Brick
31486 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31488 addBrick : function(cfg)
31490 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31491 //this.register(cn);
31492 cn.parentId = this.id;
31493 cn.onRender(this.el, null);
31498 * register a Masonry Brick
31499 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31502 register : function(brick)
31504 this.bricks.push(brick);
31505 brick.masonryId = this.id;
31509 * clear all the Masonry Brick
31511 clearAll : function()
31514 //this.getChildContainer().dom.innerHTML = "";
31515 this.el.dom.innerHTML = '';
31518 getSelected : function()
31520 if (!this.selectedBrick) {
31524 return this.selectedBrick;
31528 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31532 * register a Masonry Layout
31533 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31536 register : function(layout)
31538 this.groups[layout.id] = layout;
31541 * fetch a Masonry Layout based on the masonry layout ID
31542 * @param {string} the masonry layout to add
31543 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31546 get: function(layout_id) {
31547 if (typeof(this.groups[layout_id]) == 'undefined') {
31550 return this.groups[layout_id] ;
31562 * http://masonry.desandro.com
31564 * The idea is to render all the bricks based on vertical width...
31566 * The original code extends 'outlayer' - we might need to use that....
31572 * @class Roo.bootstrap.LayoutMasonryAuto
31573 * @extends Roo.bootstrap.Component
31574 * Bootstrap Layout Masonry class
31577 * Create a new Element
31578 * @param {Object} config The config object
31581 Roo.bootstrap.LayoutMasonryAuto = function(config){
31582 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31585 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31588 * @cfg {Boolean} isFitWidth - resize the width..
31590 isFitWidth : false, // options..
31592 * @cfg {Boolean} isOriginLeft = left align?
31594 isOriginLeft : true,
31596 * @cfg {Boolean} isOriginTop = top align?
31598 isOriginTop : false,
31600 * @cfg {Boolean} isLayoutInstant = no animation?
31602 isLayoutInstant : false, // needed?
31604 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31606 isResizingContainer : true,
31608 * @cfg {Number} columnWidth width of the columns
31614 * @cfg {Number} maxCols maximum number of columns
31619 * @cfg {Number} padHeight padding below box..
31625 * @cfg {Boolean} isAutoInitial defalut true
31628 isAutoInitial : true,
31634 initialColumnWidth : 0,
31635 currentSize : null,
31637 colYs : null, // array.
31644 bricks: null, //CompositeElement
31645 cols : 0, // array?
31646 // element : null, // wrapped now this.el
31647 _isLayoutInited : null,
31650 getAutoCreate : function(){
31654 cls: 'blog-masonary-wrapper ' + this.cls,
31656 cls : 'mas-boxes masonary'
31663 getChildContainer: function( )
31665 if (this.boxesEl) {
31666 return this.boxesEl;
31669 this.boxesEl = this.el.select('.mas-boxes').first();
31671 return this.boxesEl;
31675 initEvents : function()
31679 if(this.isAutoInitial){
31680 Roo.log('hook children rendered');
31681 this.on('childrenrendered', function() {
31682 Roo.log('children rendered');
31689 initial : function()
31691 this.reloadItems();
31693 this.currentSize = this.el.getBox(true);
31695 /// was window resize... - let's see if this works..
31696 Roo.EventManager.onWindowResize(this.resize, this);
31698 if(!this.isAutoInitial){
31703 this.layout.defer(500,this);
31706 reloadItems: function()
31708 this.bricks = this.el.select('.masonry-brick', true);
31710 this.bricks.each(function(b) {
31711 //Roo.log(b.getSize());
31712 if (!b.attr('originalwidth')) {
31713 b.attr('originalwidth', b.getSize().width);
31718 Roo.log(this.bricks.elements.length);
31721 resize : function()
31724 var cs = this.el.getBox(true);
31726 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31727 Roo.log("no change in with or X");
31730 this.currentSize = cs;
31734 layout : function()
31737 this._resetLayout();
31738 //this._manageStamps();
31740 // don't animate first layout
31741 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31742 this.layoutItems( isInstant );
31744 // flag for initalized
31745 this._isLayoutInited = true;
31748 layoutItems : function( isInstant )
31750 //var items = this._getItemsForLayout( this.items );
31751 // original code supports filtering layout items.. we just ignore it..
31753 this._layoutItems( this.bricks , isInstant );
31755 this._postLayout();
31757 _layoutItems : function ( items , isInstant)
31759 //this.fireEvent( 'layout', this, items );
31762 if ( !items || !items.elements.length ) {
31763 // no items, emit event with empty array
31768 items.each(function(item) {
31769 Roo.log("layout item");
31771 // get x/y object from method
31772 var position = this._getItemLayoutPosition( item );
31774 position.item = item;
31775 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31776 queue.push( position );
31779 this._processLayoutQueue( queue );
31781 /** Sets position of item in DOM
31782 * @param {Element} item
31783 * @param {Number} x - horizontal position
31784 * @param {Number} y - vertical position
31785 * @param {Boolean} isInstant - disables transitions
31787 _processLayoutQueue : function( queue )
31789 for ( var i=0, len = queue.length; i < len; i++ ) {
31790 var obj = queue[i];
31791 obj.item.position('absolute');
31792 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31798 * Any logic you want to do after each layout,
31799 * i.e. size the container
31801 _postLayout : function()
31803 this.resizeContainer();
31806 resizeContainer : function()
31808 if ( !this.isResizingContainer ) {
31811 var size = this._getContainerSize();
31813 this.el.setSize(size.width,size.height);
31814 this.boxesEl.setSize(size.width,size.height);
31820 _resetLayout : function()
31822 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31823 this.colWidth = this.el.getWidth();
31824 //this.gutter = this.el.getWidth();
31826 this.measureColumns();
31832 this.colYs.push( 0 );
31838 measureColumns : function()
31840 this.getContainerWidth();
31841 // if columnWidth is 0, default to outerWidth of first item
31842 if ( !this.columnWidth ) {
31843 var firstItem = this.bricks.first();
31844 Roo.log(firstItem);
31845 this.columnWidth = this.containerWidth;
31846 if (firstItem && firstItem.attr('originalwidth') ) {
31847 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
31849 // columnWidth fall back to item of first element
31850 Roo.log("set column width?");
31851 this.initialColumnWidth = this.columnWidth ;
31853 // if first elem has no width, default to size of container
31858 if (this.initialColumnWidth) {
31859 this.columnWidth = this.initialColumnWidth;
31864 // column width is fixed at the top - however if container width get's smaller we should
31867 // this bit calcs how man columns..
31869 var columnWidth = this.columnWidth += this.gutter;
31871 // calculate columns
31872 var containerWidth = this.containerWidth + this.gutter;
31874 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
31875 // fix rounding errors, typically with gutters
31876 var excess = columnWidth - containerWidth % columnWidth;
31879 // if overshoot is less than a pixel, round up, otherwise floor it
31880 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
31881 cols = Math[ mathMethod ]( cols );
31882 this.cols = Math.max( cols, 1 );
31883 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31885 // padding positioning..
31886 var totalColWidth = this.cols * this.columnWidth;
31887 var padavail = this.containerWidth - totalColWidth;
31888 // so for 2 columns - we need 3 'pads'
31890 var padNeeded = (1+this.cols) * this.padWidth;
31892 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
31894 this.columnWidth += padExtra
31895 //this.padWidth = Math.floor(padavail / ( this.cols));
31897 // adjust colum width so that padding is fixed??
31899 // we have 3 columns ... total = width * 3
31900 // we have X left over... that should be used by
31902 //if (this.expandC) {
31910 getContainerWidth : function()
31912 /* // container is parent if fit width
31913 var container = this.isFitWidth ? this.element.parentNode : this.element;
31914 // check that this.size and size are there
31915 // IE8 triggers resize on body size change, so they might not be
31917 var size = getSize( container ); //FIXME
31918 this.containerWidth = size && size.innerWidth; //FIXME
31921 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31925 _getItemLayoutPosition : function( item ) // what is item?
31927 // we resize the item to our columnWidth..
31929 item.setWidth(this.columnWidth);
31930 item.autoBoxAdjust = false;
31932 var sz = item.getSize();
31934 // how many columns does this brick span
31935 var remainder = this.containerWidth % this.columnWidth;
31937 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
31938 // round if off by 1 pixel, otherwise use ceil
31939 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
31940 colSpan = Math.min( colSpan, this.cols );
31942 // normally this should be '1' as we dont' currently allow multi width columns..
31944 var colGroup = this._getColGroup( colSpan );
31945 // get the minimum Y value from the columns
31946 var minimumY = Math.min.apply( Math, colGroup );
31947 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31949 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
31951 // position the brick
31953 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
31954 y: this.currentSize.y + minimumY + this.padHeight
31958 // apply setHeight to necessary columns
31959 var setHeight = minimumY + sz.height + this.padHeight;
31960 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31962 var setSpan = this.cols + 1 - colGroup.length;
31963 for ( var i = 0; i < setSpan; i++ ) {
31964 this.colYs[ shortColIndex + i ] = setHeight ;
31971 * @param {Number} colSpan - number of columns the element spans
31972 * @returns {Array} colGroup
31974 _getColGroup : function( colSpan )
31976 if ( colSpan < 2 ) {
31977 // if brick spans only one column, use all the column Ys
31982 // how many different places could this brick fit horizontally
31983 var groupCount = this.cols + 1 - colSpan;
31984 // for each group potential horizontal position
31985 for ( var i = 0; i < groupCount; i++ ) {
31986 // make an array of colY values for that one group
31987 var groupColYs = this.colYs.slice( i, i + colSpan );
31988 // and get the max value of the array
31989 colGroup[i] = Math.max.apply( Math, groupColYs );
31994 _manageStamp : function( stamp )
31996 var stampSize = stamp.getSize();
31997 var offset = stamp.getBox();
31998 // get the columns that this stamp affects
31999 var firstX = this.isOriginLeft ? offset.x : offset.right;
32000 var lastX = firstX + stampSize.width;
32001 var firstCol = Math.floor( firstX / this.columnWidth );
32002 firstCol = Math.max( 0, firstCol );
32004 var lastCol = Math.floor( lastX / this.columnWidth );
32005 // lastCol should not go over if multiple of columnWidth #425
32006 lastCol -= lastX % this.columnWidth ? 0 : 1;
32007 lastCol = Math.min( this.cols - 1, lastCol );
32009 // set colYs to bottom of the stamp
32010 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32013 for ( var i = firstCol; i <= lastCol; i++ ) {
32014 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32019 _getContainerSize : function()
32021 this.maxY = Math.max.apply( Math, this.colYs );
32026 if ( this.isFitWidth ) {
32027 size.width = this._getContainerFitWidth();
32033 _getContainerFitWidth : function()
32035 var unusedCols = 0;
32036 // count unused columns
32039 if ( this.colYs[i] !== 0 ) {
32044 // fit container to columns that have been used
32045 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32048 needsResizeLayout : function()
32050 var previousWidth = this.containerWidth;
32051 this.getContainerWidth();
32052 return previousWidth !== this.containerWidth;
32067 * @class Roo.bootstrap.MasonryBrick
32068 * @extends Roo.bootstrap.Component
32069 * Bootstrap MasonryBrick class
32072 * Create a new MasonryBrick
32073 * @param {Object} config The config object
32076 Roo.bootstrap.MasonryBrick = function(config){
32078 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32080 Roo.bootstrap.MasonryBrick.register(this);
32086 * When a MasonryBrick is clcik
32087 * @param {Roo.bootstrap.MasonryBrick} this
32088 * @param {Roo.EventObject} e
32094 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32097 * @cfg {String} title
32101 * @cfg {String} html
32105 * @cfg {String} bgimage
32109 * @cfg {String} videourl
32113 * @cfg {String} cls
32117 * @cfg {String} href
32121 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32126 * @cfg {String} placetitle (center|bottom)
32131 * @cfg {Boolean} isFitContainer defalut true
32133 isFitContainer : true,
32136 * @cfg {Boolean} preventDefault defalut false
32138 preventDefault : false,
32141 * @cfg {Boolean} inverse defalut false
32143 maskInverse : false,
32145 getAutoCreate : function()
32147 if(!this.isFitContainer){
32148 return this.getSplitAutoCreate();
32151 var cls = 'masonry-brick masonry-brick-full';
32153 if(this.href.length){
32154 cls += ' masonry-brick-link';
32157 if(this.bgimage.length){
32158 cls += ' masonry-brick-image';
32161 if(this.maskInverse){
32162 cls += ' mask-inverse';
32165 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32166 cls += ' enable-mask';
32170 cls += ' masonry-' + this.size + '-brick';
32173 if(this.placetitle.length){
32175 switch (this.placetitle) {
32177 cls += ' masonry-center-title';
32180 cls += ' masonry-bottom-title';
32187 if(!this.html.length && !this.bgimage.length){
32188 cls += ' masonry-center-title';
32191 if(!this.html.length && this.bgimage.length){
32192 cls += ' masonry-bottom-title';
32197 cls += ' ' + this.cls;
32201 tag: (this.href.length) ? 'a' : 'div',
32206 cls: 'masonry-brick-mask'
32210 cls: 'masonry-brick-paragraph',
32216 if(this.href.length){
32217 cfg.href = this.href;
32220 var cn = cfg.cn[1].cn;
32222 if(this.title.length){
32225 cls: 'masonry-brick-title',
32230 if(this.html.length){
32233 cls: 'masonry-brick-text',
32238 if (!this.title.length && !this.html.length) {
32239 cfg.cn[1].cls += ' hide';
32242 if(this.bgimage.length){
32245 cls: 'masonry-brick-image-view',
32250 if(this.videourl.length){
32251 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32252 // youtube support only?
32255 cls: 'masonry-brick-image-view',
32258 allowfullscreen : true
32266 getSplitAutoCreate : function()
32268 var cls = 'masonry-brick masonry-brick-split';
32270 if(this.href.length){
32271 cls += ' masonry-brick-link';
32274 if(this.bgimage.length){
32275 cls += ' masonry-brick-image';
32279 cls += ' masonry-' + this.size + '-brick';
32282 switch (this.placetitle) {
32284 cls += ' masonry-center-title';
32287 cls += ' masonry-bottom-title';
32290 if(!this.bgimage.length){
32291 cls += ' masonry-center-title';
32294 if(this.bgimage.length){
32295 cls += ' masonry-bottom-title';
32301 cls += ' ' + this.cls;
32305 tag: (this.href.length) ? 'a' : 'div',
32310 cls: 'masonry-brick-split-head',
32314 cls: 'masonry-brick-paragraph',
32321 cls: 'masonry-brick-split-body',
32327 if(this.href.length){
32328 cfg.href = this.href;
32331 if(this.title.length){
32332 cfg.cn[0].cn[0].cn.push({
32334 cls: 'masonry-brick-title',
32339 if(this.html.length){
32340 cfg.cn[1].cn.push({
32342 cls: 'masonry-brick-text',
32347 if(this.bgimage.length){
32348 cfg.cn[0].cn.push({
32350 cls: 'masonry-brick-image-view',
32355 if(this.videourl.length){
32356 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32357 // youtube support only?
32358 cfg.cn[0].cn.cn.push({
32360 cls: 'masonry-brick-image-view',
32363 allowfullscreen : true
32370 initEvents: function()
32372 switch (this.size) {
32405 this.el.on('touchstart', this.onTouchStart, this);
32406 this.el.on('touchmove', this.onTouchMove, this);
32407 this.el.on('touchend', this.onTouchEnd, this);
32408 this.el.on('contextmenu', this.onContextMenu, this);
32410 this.el.on('mouseenter' ,this.enter, this);
32411 this.el.on('mouseleave', this.leave, this);
32412 this.el.on('click', this.onClick, this);
32415 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32416 this.parent().bricks.push(this);
32421 onClick: function(e, el)
32423 var time = this.endTimer - this.startTimer;
32424 // Roo.log(e.preventDefault());
32427 e.preventDefault();
32432 if(!this.preventDefault){
32436 e.preventDefault();
32438 if (this.activcClass != '') {
32439 this.selectBrick();
32442 this.fireEvent('click', this);
32445 enter: function(e, el)
32447 e.preventDefault();
32449 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32453 if(this.bgimage.length && this.html.length){
32454 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32458 leave: function(e, el)
32460 e.preventDefault();
32462 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32466 if(this.bgimage.length && this.html.length){
32467 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32471 onTouchStart: function(e, el)
32473 // e.preventDefault();
32475 this.touchmoved = false;
32477 if(!this.isFitContainer){
32481 if(!this.bgimage.length || !this.html.length){
32485 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32487 this.timer = new Date().getTime();
32491 onTouchMove: function(e, el)
32493 this.touchmoved = true;
32496 onContextMenu : function(e,el)
32498 e.preventDefault();
32499 e.stopPropagation();
32503 onTouchEnd: function(e, el)
32505 // e.preventDefault();
32507 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32514 if(!this.bgimage.length || !this.html.length){
32516 if(this.href.length){
32517 window.location.href = this.href;
32523 if(!this.isFitContainer){
32527 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32529 window.location.href = this.href;
32532 //selection on single brick only
32533 selectBrick : function() {
32535 if (!this.parentId) {
32539 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32540 var index = m.selectedBrick.indexOf(this.id);
32543 m.selectedBrick.splice(index,1);
32544 this.el.removeClass(this.activeClass);
32548 for(var i = 0; i < m.selectedBrick.length; i++) {
32549 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32550 b.el.removeClass(b.activeClass);
32553 m.selectedBrick = [];
32555 m.selectedBrick.push(this.id);
32556 this.el.addClass(this.activeClass);
32562 Roo.apply(Roo.bootstrap.MasonryBrick, {
32565 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32567 * register a Masonry Brick
32568 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32571 register : function(brick)
32573 //this.groups[brick.id] = brick;
32574 this.groups.add(brick.id, brick);
32577 * fetch a masonry brick based on the masonry brick ID
32578 * @param {string} the masonry brick to add
32579 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32582 get: function(brick_id)
32584 // if (typeof(this.groups[brick_id]) == 'undefined') {
32587 // return this.groups[brick_id] ;
32589 if(this.groups.key(brick_id)) {
32590 return this.groups.key(brick_id);
32608 * @class Roo.bootstrap.Brick
32609 * @extends Roo.bootstrap.Component
32610 * Bootstrap Brick class
32613 * Create a new Brick
32614 * @param {Object} config The config object
32617 Roo.bootstrap.Brick = function(config){
32618 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32624 * When a Brick is click
32625 * @param {Roo.bootstrap.Brick} this
32626 * @param {Roo.EventObject} e
32632 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32635 * @cfg {String} title
32639 * @cfg {String} html
32643 * @cfg {String} bgimage
32647 * @cfg {String} cls
32651 * @cfg {String} href
32655 * @cfg {String} video
32659 * @cfg {Boolean} square
32663 getAutoCreate : function()
32665 var cls = 'roo-brick';
32667 if(this.href.length){
32668 cls += ' roo-brick-link';
32671 if(this.bgimage.length){
32672 cls += ' roo-brick-image';
32675 if(!this.html.length && !this.bgimage.length){
32676 cls += ' roo-brick-center-title';
32679 if(!this.html.length && this.bgimage.length){
32680 cls += ' roo-brick-bottom-title';
32684 cls += ' ' + this.cls;
32688 tag: (this.href.length) ? 'a' : 'div',
32693 cls: 'roo-brick-paragraph',
32699 if(this.href.length){
32700 cfg.href = this.href;
32703 var cn = cfg.cn[0].cn;
32705 if(this.title.length){
32708 cls: 'roo-brick-title',
32713 if(this.html.length){
32716 cls: 'roo-brick-text',
32723 if(this.bgimage.length){
32726 cls: 'roo-brick-image-view',
32734 initEvents: function()
32736 if(this.title.length || this.html.length){
32737 this.el.on('mouseenter' ,this.enter, this);
32738 this.el.on('mouseleave', this.leave, this);
32741 Roo.EventManager.onWindowResize(this.resize, this);
32743 if(this.bgimage.length){
32744 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
32745 this.imageEl.on('load', this.onImageLoad, this);
32752 onImageLoad : function()
32757 resize : function()
32759 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32761 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32763 if(this.bgimage.length){
32764 var image = this.el.select('.roo-brick-image-view', true).first();
32766 image.setWidth(paragraph.getWidth());
32769 image.setHeight(paragraph.getWidth());
32772 this.el.setHeight(image.getHeight());
32773 paragraph.setHeight(image.getHeight());
32779 enter: function(e, el)
32781 e.preventDefault();
32783 if(this.bgimage.length){
32784 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32785 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32789 leave: function(e, el)
32791 e.preventDefault();
32793 if(this.bgimage.length){
32794 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32795 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32811 * @class Roo.bootstrap.NumberField
32812 * @extends Roo.bootstrap.Input
32813 * Bootstrap NumberField class
32819 * Create a new NumberField
32820 * @param {Object} config The config object
32823 Roo.bootstrap.NumberField = function(config){
32824 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32827 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32830 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
32832 allowDecimals : true,
32834 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
32836 decimalSeparator : ".",
32838 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
32840 decimalPrecision : 2,
32842 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
32844 allowNegative : true,
32846 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
32848 minValue : Number.NEGATIVE_INFINITY,
32850 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
32852 maxValue : Number.MAX_VALUE,
32854 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
32856 minText : "The minimum value for this field is {0}",
32858 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
32860 maxText : "The maximum value for this field is {0}",
32862 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
32863 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
32865 nanText : "{0} is not a valid number",
32867 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
32872 initEvents : function()
32874 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
32876 var allowed = "0123456789";
32878 if(this.allowDecimals){
32879 allowed += this.decimalSeparator;
32882 if(this.allowNegative){
32886 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
32888 var keyPress = function(e){
32890 var k = e.getKey();
32892 var c = e.getCharCode();
32895 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
32896 allowed.indexOf(String.fromCharCode(c)) === -1
32902 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
32906 if(allowed.indexOf(String.fromCharCode(c)) === -1){
32911 this.el.on("keypress", keyPress, this);
32914 validateValue : function(value)
32917 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
32921 var num = this.parseValue(value);
32924 this.markInvalid(String.format(this.nanText, value));
32928 if(num < this.minValue){
32929 this.markInvalid(String.format(this.minText, this.minValue));
32933 if(num > this.maxValue){
32934 this.markInvalid(String.format(this.maxText, this.maxValue));
32941 getValue : function()
32943 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
32946 parseValue : function(value)
32948 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
32949 return isNaN(value) ? '' : value;
32952 fixPrecision : function(value)
32954 var nan = isNaN(value);
32956 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
32957 return nan ? '' : value;
32959 return parseFloat(value).toFixed(this.decimalPrecision);
32962 setValue : function(v)
32964 v = this.fixPrecision(v);
32965 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
32968 decimalPrecisionFcn : function(v)
32970 return Math.floor(v);
32973 beforeBlur : function()
32979 var v = this.parseValue(this.getRawValue());
32994 * @class Roo.bootstrap.DocumentSlider
32995 * @extends Roo.bootstrap.Component
32996 * Bootstrap DocumentSlider class
32999 * Create a new DocumentViewer
33000 * @param {Object} config The config object
33003 Roo.bootstrap.DocumentSlider = function(config){
33004 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33011 * Fire after initEvent
33012 * @param {Roo.bootstrap.DocumentSlider} this
33017 * Fire after update
33018 * @param {Roo.bootstrap.DocumentSlider} this
33024 * @param {Roo.bootstrap.DocumentSlider} this
33030 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33036 getAutoCreate : function()
33040 cls : 'roo-document-slider',
33044 cls : 'roo-document-slider-header',
33048 cls : 'roo-document-slider-header-title'
33054 cls : 'roo-document-slider-body',
33058 cls : 'roo-document-slider-prev',
33062 cls : 'fa fa-chevron-left'
33068 cls : 'roo-document-slider-thumb',
33072 cls : 'roo-document-slider-image'
33078 cls : 'roo-document-slider-next',
33082 cls : 'fa fa-chevron-right'
33094 initEvents : function()
33096 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33097 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33099 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33100 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33102 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33103 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33105 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33106 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33108 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33109 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33111 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33112 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33114 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33115 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33117 this.thumbEl.on('click', this.onClick, this);
33119 this.prevIndicator.on('click', this.prev, this);
33121 this.nextIndicator.on('click', this.next, this);
33125 initial : function()
33127 if(this.files.length){
33128 this.indicator = 1;
33132 this.fireEvent('initial', this);
33135 update : function()
33137 this.imageEl.attr('src', this.files[this.indicator - 1]);
33139 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33141 this.prevIndicator.show();
33143 if(this.indicator == 1){
33144 this.prevIndicator.hide();
33147 this.nextIndicator.show();
33149 if(this.indicator == this.files.length){
33150 this.nextIndicator.hide();
33153 this.thumbEl.scrollTo('top');
33155 this.fireEvent('update', this);
33158 onClick : function(e)
33160 e.preventDefault();
33162 this.fireEvent('click', this);
33167 e.preventDefault();
33169 this.indicator = Math.max(1, this.indicator - 1);
33176 e.preventDefault();
33178 this.indicator = Math.min(this.files.length, this.indicator + 1);
33192 * @class Roo.bootstrap.RadioSet
33193 * @extends Roo.bootstrap.Input
33194 * Bootstrap RadioSet class
33195 * @cfg {String} indicatorpos (left|right) default left
33196 * @cfg {Boolean} inline (true|false) inline the element (default true)
33197 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33199 * Create a new RadioSet
33200 * @param {Object} config The config object
33203 Roo.bootstrap.RadioSet = function(config){
33205 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33209 Roo.bootstrap.RadioSet.register(this);
33214 * Fires when the element is checked or unchecked.
33215 * @param {Roo.bootstrap.RadioSet} this This radio
33216 * @param {Roo.bootstrap.Radio} item The checked item
33223 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33231 indicatorpos : 'left',
33233 getAutoCreate : function()
33237 cls : 'roo-radio-set-label',
33241 html : this.fieldLabel
33246 if(this.indicatorpos == 'left'){
33249 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33250 tooltip : 'This field is required'
33255 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33256 tooltip : 'This field is required'
33262 cls : 'roo-radio-set-items'
33265 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33267 if (align === 'left' && this.fieldLabel.length) {
33270 cls : "roo-radio-set-right",
33276 if(this.labelWidth > 12){
33277 label.style = "width: " + this.labelWidth + 'px';
33280 if(this.labelWidth < 13 && this.labelmd == 0){
33281 this.labelmd = this.labelWidth;
33284 if(this.labellg > 0){
33285 label.cls += ' col-lg-' + this.labellg;
33286 items.cls += ' col-lg-' + (12 - this.labellg);
33289 if(this.labelmd > 0){
33290 label.cls += ' col-md-' + this.labelmd;
33291 items.cls += ' col-md-' + (12 - this.labelmd);
33294 if(this.labelsm > 0){
33295 label.cls += ' col-sm-' + this.labelsm;
33296 items.cls += ' col-sm-' + (12 - this.labelsm);
33299 if(this.labelxs > 0){
33300 label.cls += ' col-xs-' + this.labelxs;
33301 items.cls += ' col-xs-' + (12 - this.labelxs);
33307 cls : 'roo-radio-set',
33311 cls : 'roo-radio-set-input',
33314 value : this.value ? this.value : ''
33321 if(this.weight.length){
33322 cfg.cls += ' roo-radio-' + this.weight;
33326 cfg.cls += ' roo-radio-set-inline';
33330 ['xs','sm','md','lg'].map(function(size){
33331 if (settings[size]) {
33332 cfg.cls += ' col-' + size + '-' + settings[size];
33340 initEvents : function()
33342 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33343 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33345 if(!this.fieldLabel.length){
33346 this.labelEl.hide();
33349 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33350 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33352 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
33353 this.indicatorEl().hide();
33355 this.originalValue = this.getValue();
33359 inputEl: function ()
33361 return this.el.select('.roo-radio-set-input', true).first();
33364 getChildContainer : function()
33366 return this.itemsEl;
33369 register : function(item)
33371 this.radioes.push(item);
33375 validate : function()
33379 Roo.each(this.radioes, function(i){
33388 if(this.allowBlank) {
33392 if(this.disabled || valid){
33397 this.markInvalid();
33402 markValid : function()
33404 if(this.labelEl.isVisible(true)){
33405 this.indicatorEl().hide();
33408 this.el.removeClass([this.invalidClass, this.validClass]);
33409 this.el.addClass(this.validClass);
33411 this.fireEvent('valid', this);
33414 markInvalid : function(msg)
33416 if(this.allowBlank || this.disabled){
33420 if(this.labelEl.isVisible(true)){
33421 this.indicatorEl().show();
33424 this.el.removeClass([this.invalidClass, this.validClass]);
33425 this.el.addClass(this.invalidClass);
33427 this.fireEvent('invalid', this, msg);
33431 setValue : function(v, suppressEvent)
33435 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33438 Roo.each(this.radioes, function(i){
33441 i.el.removeClass('checked');
33443 if(i.value === v || i.value.toString() === v.toString()){
33445 i.el.addClass('checked');
33447 if(suppressEvent !== true){
33448 this.fireEvent('check', this, i);
33457 clearInvalid : function(){
33459 if(!this.el || this.preventMark){
33463 this.el.removeClass([this.invalidClass]);
33465 this.fireEvent('valid', this);
33470 Roo.apply(Roo.bootstrap.RadioSet, {
33474 register : function(set)
33476 this.groups[set.name] = set;
33479 get: function(name)
33481 if (typeof(this.groups[name]) == 'undefined') {
33485 return this.groups[name] ;
33491 * Ext JS Library 1.1.1
33492 * Copyright(c) 2006-2007, Ext JS, LLC.
33494 * Originally Released Under LGPL - original licence link has changed is not relivant.
33497 * <script type="text/javascript">
33502 * @class Roo.bootstrap.SplitBar
33503 * @extends Roo.util.Observable
33504 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33508 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33509 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33510 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33511 split.minSize = 100;
33512 split.maxSize = 600;
33513 split.animate = true;
33514 split.on('moved', splitterMoved);
33517 * Create a new SplitBar
33518 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33519 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33520 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33521 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33522 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33523 position of the SplitBar).
33525 Roo.bootstrap.SplitBar = function(cfg){
33530 // dragElement : elm
33531 // resizingElement: el,
33533 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33534 // placement : Roo.bootstrap.SplitBar.LEFT ,
33535 // existingProxy ???
33538 this.el = Roo.get(cfg.dragElement, true);
33539 this.el.dom.unselectable = "on";
33541 this.resizingEl = Roo.get(cfg.resizingElement, true);
33545 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33546 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33549 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33552 * The minimum size of the resizing element. (Defaults to 0)
33558 * The maximum size of the resizing element. (Defaults to 2000)
33561 this.maxSize = 2000;
33564 * Whether to animate the transition to the new size
33567 this.animate = false;
33570 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33573 this.useShim = false;
33578 if(!cfg.existingProxy){
33580 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33582 this.proxy = Roo.get(cfg.existingProxy).dom;
33585 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33588 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33591 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
33594 this.dragSpecs = {};
33597 * @private The adapter to use to positon and resize elements
33599 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33600 this.adapter.init(this);
33602 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33604 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
33605 this.el.addClass("roo-splitbar-h");
33608 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
33609 this.el.addClass("roo-splitbar-v");
33615 * Fires when the splitter is moved (alias for {@link #event-moved})
33616 * @param {Roo.bootstrap.SplitBar} this
33617 * @param {Number} newSize the new width or height
33622 * Fires when the splitter is moved
33623 * @param {Roo.bootstrap.SplitBar} this
33624 * @param {Number} newSize the new width or height
33628 * @event beforeresize
33629 * Fires before the splitter is dragged
33630 * @param {Roo.bootstrap.SplitBar} this
33632 "beforeresize" : true,
33634 "beforeapply" : true
33637 Roo.util.Observable.call(this);
33640 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
33641 onStartProxyDrag : function(x, y){
33642 this.fireEvent("beforeresize", this);
33644 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
33646 o.enableDisplayMode("block");
33647 // all splitbars share the same overlay
33648 Roo.bootstrap.SplitBar.prototype.overlay = o;
33650 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
33651 this.overlay.show();
33652 Roo.get(this.proxy).setDisplayed("block");
33653 var size = this.adapter.getElementSize(this);
33654 this.activeMinSize = this.getMinimumSize();;
33655 this.activeMaxSize = this.getMaximumSize();;
33656 var c1 = size - this.activeMinSize;
33657 var c2 = Math.max(this.activeMaxSize - size, 0);
33658 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33659 this.dd.resetConstraints();
33660 this.dd.setXConstraint(
33661 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
33662 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
33664 this.dd.setYConstraint(0, 0);
33666 this.dd.resetConstraints();
33667 this.dd.setXConstraint(0, 0);
33668 this.dd.setYConstraint(
33669 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
33670 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
33673 this.dragSpecs.startSize = size;
33674 this.dragSpecs.startPoint = [x, y];
33675 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
33679 * @private Called after the drag operation by the DDProxy
33681 onEndProxyDrag : function(e){
33682 Roo.get(this.proxy).setDisplayed(false);
33683 var endPoint = Roo.lib.Event.getXY(e);
33685 this.overlay.hide();
33688 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33689 newSize = this.dragSpecs.startSize +
33690 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
33691 endPoint[0] - this.dragSpecs.startPoint[0] :
33692 this.dragSpecs.startPoint[0] - endPoint[0]
33695 newSize = this.dragSpecs.startSize +
33696 (this.placement == Roo.bootstrap.SplitBar.TOP ?
33697 endPoint[1] - this.dragSpecs.startPoint[1] :
33698 this.dragSpecs.startPoint[1] - endPoint[1]
33701 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33702 if(newSize != this.dragSpecs.startSize){
33703 if(this.fireEvent('beforeapply', this, newSize) !== false){
33704 this.adapter.setElementSize(this, newSize);
33705 this.fireEvent("moved", this, newSize);
33706 this.fireEvent("resize", this, newSize);
33712 * Get the adapter this SplitBar uses
33713 * @return The adapter object
33715 getAdapter : function(){
33716 return this.adapter;
33720 * Set the adapter this SplitBar uses
33721 * @param {Object} adapter A SplitBar adapter object
33723 setAdapter : function(adapter){
33724 this.adapter = adapter;
33725 this.adapter.init(this);
33729 * Gets the minimum size for the resizing element
33730 * @return {Number} The minimum size
33732 getMinimumSize : function(){
33733 return this.minSize;
33737 * Sets the minimum size for the resizing element
33738 * @param {Number} minSize The minimum size
33740 setMinimumSize : function(minSize){
33741 this.minSize = minSize;
33745 * Gets the maximum size for the resizing element
33746 * @return {Number} The maximum size
33748 getMaximumSize : function(){
33749 return this.maxSize;
33753 * Sets the maximum size for the resizing element
33754 * @param {Number} maxSize The maximum size
33756 setMaximumSize : function(maxSize){
33757 this.maxSize = maxSize;
33761 * Sets the initialize size for the resizing element
33762 * @param {Number} size The initial size
33764 setCurrentSize : function(size){
33765 var oldAnimate = this.animate;
33766 this.animate = false;
33767 this.adapter.setElementSize(this, size);
33768 this.animate = oldAnimate;
33772 * Destroy this splitbar.
33773 * @param {Boolean} removeEl True to remove the element
33775 destroy : function(removeEl){
33777 this.shim.remove();
33780 this.proxy.parentNode.removeChild(this.proxy);
33788 * @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.
33790 Roo.bootstrap.SplitBar.createProxy = function(dir){
33791 var proxy = new Roo.Element(document.createElement("div"));
33792 proxy.unselectable();
33793 var cls = 'roo-splitbar-proxy';
33794 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
33795 document.body.appendChild(proxy.dom);
33800 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
33801 * Default Adapter. It assumes the splitter and resizing element are not positioned
33802 * elements and only gets/sets the width of the element. Generally used for table based layouts.
33804 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
33807 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
33808 // do nothing for now
33809 init : function(s){
33813 * Called before drag operations to get the current size of the resizing element.
33814 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33816 getElementSize : function(s){
33817 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33818 return s.resizingEl.getWidth();
33820 return s.resizingEl.getHeight();
33825 * Called after drag operations to set the size of the resizing element.
33826 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33827 * @param {Number} newSize The new size to set
33828 * @param {Function} onComplete A function to be invoked when resizing is complete
33830 setElementSize : function(s, newSize, onComplete){
33831 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33833 s.resizingEl.setWidth(newSize);
33835 onComplete(s, newSize);
33838 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
33843 s.resizingEl.setHeight(newSize);
33845 onComplete(s, newSize);
33848 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
33855 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
33856 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
33857 * Adapter that moves the splitter element to align with the resized sizing element.
33858 * Used with an absolute positioned SplitBar.
33859 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
33860 * document.body, make sure you assign an id to the body element.
33862 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
33863 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33864 this.container = Roo.get(container);
33867 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
33868 init : function(s){
33869 this.basic.init(s);
33872 getElementSize : function(s){
33873 return this.basic.getElementSize(s);
33876 setElementSize : function(s, newSize, onComplete){
33877 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
33880 moveSplitter : function(s){
33881 var yes = Roo.bootstrap.SplitBar;
33882 switch(s.placement){
33884 s.el.setX(s.resizingEl.getRight());
33887 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
33890 s.el.setY(s.resizingEl.getBottom());
33893 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
33900 * Orientation constant - Create a vertical SplitBar
33904 Roo.bootstrap.SplitBar.VERTICAL = 1;
33907 * Orientation constant - Create a horizontal SplitBar
33911 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
33914 * Placement constant - The resizing element is to the left of the splitter element
33918 Roo.bootstrap.SplitBar.LEFT = 1;
33921 * Placement constant - The resizing element is to the right of the splitter element
33925 Roo.bootstrap.SplitBar.RIGHT = 2;
33928 * Placement constant - The resizing element is positioned above the splitter element
33932 Roo.bootstrap.SplitBar.TOP = 3;
33935 * Placement constant - The resizing element is positioned under splitter element
33939 Roo.bootstrap.SplitBar.BOTTOM = 4;
33940 Roo.namespace("Roo.bootstrap.layout");/*
33942 * Ext JS Library 1.1.1
33943 * Copyright(c) 2006-2007, Ext JS, LLC.
33945 * Originally Released Under LGPL - original licence link has changed is not relivant.
33948 * <script type="text/javascript">
33952 * @class Roo.bootstrap.layout.Manager
33953 * @extends Roo.bootstrap.Component
33954 * Base class for layout managers.
33956 Roo.bootstrap.layout.Manager = function(config)
33958 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
33964 /** false to disable window resize monitoring @type Boolean */
33965 this.monitorWindowResize = true;
33970 * Fires when a layout is performed.
33971 * @param {Roo.LayoutManager} this
33975 * @event regionresized
33976 * Fires when the user resizes a region.
33977 * @param {Roo.LayoutRegion} region The resized region
33978 * @param {Number} newSize The new size (width for east/west, height for north/south)
33980 "regionresized" : true,
33982 * @event regioncollapsed
33983 * Fires when a region is collapsed.
33984 * @param {Roo.LayoutRegion} region The collapsed region
33986 "regioncollapsed" : true,
33988 * @event regionexpanded
33989 * Fires when a region is expanded.
33990 * @param {Roo.LayoutRegion} region The expanded region
33992 "regionexpanded" : true
33994 this.updating = false;
33997 this.el = Roo.get(config.el);
34003 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34008 monitorWindowResize : true,
34014 onRender : function(ct, position)
34017 this.el = Roo.get(ct);
34020 //this.fireEvent('render',this);
34024 initEvents: function()
34028 // ie scrollbar fix
34029 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34030 document.body.scroll = "no";
34031 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34032 this.el.position('relative');
34034 this.id = this.el.id;
34035 this.el.addClass("roo-layout-container");
34036 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34037 if(this.el.dom != document.body ) {
34038 this.el.on('resize', this.layout,this);
34039 this.el.on('show', this.layout,this);
34045 * Returns true if this layout is currently being updated
34046 * @return {Boolean}
34048 isUpdating : function(){
34049 return this.updating;
34053 * Suspend the LayoutManager from doing auto-layouts while
34054 * making multiple add or remove calls
34056 beginUpdate : function(){
34057 this.updating = true;
34061 * Restore auto-layouts and optionally disable the manager from performing a layout
34062 * @param {Boolean} noLayout true to disable a layout update
34064 endUpdate : function(noLayout){
34065 this.updating = false;
34071 layout: function(){
34075 onRegionResized : function(region, newSize){
34076 this.fireEvent("regionresized", region, newSize);
34080 onRegionCollapsed : function(region){
34081 this.fireEvent("regioncollapsed", region);
34084 onRegionExpanded : function(region){
34085 this.fireEvent("regionexpanded", region);
34089 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34090 * performs box-model adjustments.
34091 * @return {Object} The size as an object {width: (the width), height: (the height)}
34093 getViewSize : function()
34096 if(this.el.dom != document.body){
34097 size = this.el.getSize();
34099 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34101 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34102 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34107 * Returns the Element this layout is bound to.
34108 * @return {Roo.Element}
34110 getEl : function(){
34115 * Returns the specified region.
34116 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34117 * @return {Roo.LayoutRegion}
34119 getRegion : function(target){
34120 return this.regions[target.toLowerCase()];
34123 onWindowResize : function(){
34124 if(this.monitorWindowResize){
34131 * Ext JS Library 1.1.1
34132 * Copyright(c) 2006-2007, Ext JS, LLC.
34134 * Originally Released Under LGPL - original licence link has changed is not relivant.
34137 * <script type="text/javascript">
34140 * @class Roo.bootstrap.layout.Border
34141 * @extends Roo.bootstrap.layout.Manager
34142 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34143 * please see: examples/bootstrap/nested.html<br><br>
34145 <b>The container the layout is rendered into can be either the body element or any other element.
34146 If it is not the body element, the container needs to either be an absolute positioned element,
34147 or you will need to add "position:relative" to the css of the container. You will also need to specify
34148 the container size if it is not the body element.</b>
34151 * Create a new Border
34152 * @param {Object} config Configuration options
34154 Roo.bootstrap.layout.Border = function(config){
34155 config = config || {};
34156 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34160 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34161 if(config[region]){
34162 config[region].region = region;
34163 this.addRegion(config[region]);
34169 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34171 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34173 * Creates and adds a new region if it doesn't already exist.
34174 * @param {String} target The target region key (north, south, east, west or center).
34175 * @param {Object} config The regions config object
34176 * @return {BorderLayoutRegion} The new region
34178 addRegion : function(config)
34180 if(!this.regions[config.region]){
34181 var r = this.factory(config);
34182 this.bindRegion(r);
34184 return this.regions[config.region];
34188 bindRegion : function(r){
34189 this.regions[r.config.region] = r;
34191 r.on("visibilitychange", this.layout, this);
34192 r.on("paneladded", this.layout, this);
34193 r.on("panelremoved", this.layout, this);
34194 r.on("invalidated", this.layout, this);
34195 r.on("resized", this.onRegionResized, this);
34196 r.on("collapsed", this.onRegionCollapsed, this);
34197 r.on("expanded", this.onRegionExpanded, this);
34201 * Performs a layout update.
34203 layout : function()
34205 if(this.updating) {
34209 // render all the rebions if they have not been done alreayd?
34210 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34211 if(this.regions[region] && !this.regions[region].bodyEl){
34212 this.regions[region].onRender(this.el)
34216 var size = this.getViewSize();
34217 var w = size.width;
34218 var h = size.height;
34223 //var x = 0, y = 0;
34225 var rs = this.regions;
34226 var north = rs["north"];
34227 var south = rs["south"];
34228 var west = rs["west"];
34229 var east = rs["east"];
34230 var center = rs["center"];
34231 //if(this.hideOnLayout){ // not supported anymore
34232 //c.el.setStyle("display", "none");
34234 if(north && north.isVisible()){
34235 var b = north.getBox();
34236 var m = north.getMargins();
34237 b.width = w - (m.left+m.right);
34240 centerY = b.height + b.y + m.bottom;
34241 centerH -= centerY;
34242 north.updateBox(this.safeBox(b));
34244 if(south && south.isVisible()){
34245 var b = south.getBox();
34246 var m = south.getMargins();
34247 b.width = w - (m.left+m.right);
34249 var totalHeight = (b.height + m.top + m.bottom);
34250 b.y = h - totalHeight + m.top;
34251 centerH -= totalHeight;
34252 south.updateBox(this.safeBox(b));
34254 if(west && west.isVisible()){
34255 var b = west.getBox();
34256 var m = west.getMargins();
34257 b.height = centerH - (m.top+m.bottom);
34259 b.y = centerY + m.top;
34260 var totalWidth = (b.width + m.left + m.right);
34261 centerX += totalWidth;
34262 centerW -= totalWidth;
34263 west.updateBox(this.safeBox(b));
34265 if(east && east.isVisible()){
34266 var b = east.getBox();
34267 var m = east.getMargins();
34268 b.height = centerH - (m.top+m.bottom);
34269 var totalWidth = (b.width + m.left + m.right);
34270 b.x = w - totalWidth + m.left;
34271 b.y = centerY + m.top;
34272 centerW -= totalWidth;
34273 east.updateBox(this.safeBox(b));
34276 var m = center.getMargins();
34278 x: centerX + m.left,
34279 y: centerY + m.top,
34280 width: centerW - (m.left+m.right),
34281 height: centerH - (m.top+m.bottom)
34283 //if(this.hideOnLayout){
34284 //center.el.setStyle("display", "block");
34286 center.updateBox(this.safeBox(centerBox));
34289 this.fireEvent("layout", this);
34293 safeBox : function(box){
34294 box.width = Math.max(0, box.width);
34295 box.height = Math.max(0, box.height);
34300 * Adds a ContentPanel (or subclass) to this layout.
34301 * @param {String} target The target region key (north, south, east, west or center).
34302 * @param {Roo.ContentPanel} panel The panel to add
34303 * @return {Roo.ContentPanel} The added panel
34305 add : function(target, panel){
34307 target = target.toLowerCase();
34308 return this.regions[target].add(panel);
34312 * Remove a ContentPanel (or subclass) to this layout.
34313 * @param {String} target The target region key (north, south, east, west or center).
34314 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34315 * @return {Roo.ContentPanel} The removed panel
34317 remove : function(target, panel){
34318 target = target.toLowerCase();
34319 return this.regions[target].remove(panel);
34323 * Searches all regions for a panel with the specified id
34324 * @param {String} panelId
34325 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34327 findPanel : function(panelId){
34328 var rs = this.regions;
34329 for(var target in rs){
34330 if(typeof rs[target] != "function"){
34331 var p = rs[target].getPanel(panelId);
34341 * Searches all regions for a panel with the specified id and activates (shows) it.
34342 * @param {String/ContentPanel} panelId The panels id or the panel itself
34343 * @return {Roo.ContentPanel} The shown panel or null
34345 showPanel : function(panelId) {
34346 var rs = this.regions;
34347 for(var target in rs){
34348 var r = rs[target];
34349 if(typeof r != "function"){
34350 if(r.hasPanel(panelId)){
34351 return r.showPanel(panelId);
34359 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34360 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34363 restoreState : function(provider){
34365 provider = Roo.state.Manager;
34367 var sm = new Roo.LayoutStateManager();
34368 sm.init(this, provider);
34374 * Adds a xtype elements to the layout.
34378 xtype : 'ContentPanel',
34385 xtype : 'NestedLayoutPanel',
34391 items : [ ... list of content panels or nested layout panels.. ]
34395 * @param {Object} cfg Xtype definition of item to add.
34397 addxtype : function(cfg)
34399 // basically accepts a pannel...
34400 // can accept a layout region..!?!?
34401 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34404 // theory? children can only be panels??
34406 //if (!cfg.xtype.match(/Panel$/)) {
34411 if (typeof(cfg.region) == 'undefined') {
34412 Roo.log("Failed to add Panel, region was not set");
34416 var region = cfg.region;
34422 xitems = cfg.items;
34429 case 'Content': // ContentPanel (el, cfg)
34430 case 'Scroll': // ContentPanel (el, cfg)
34432 cfg.autoCreate = true;
34433 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34435 // var el = this.el.createChild();
34436 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34439 this.add(region, ret);
34443 case 'TreePanel': // our new panel!
34444 cfg.el = this.el.createChild();
34445 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34446 this.add(region, ret);
34451 // create a new Layout (which is a Border Layout...
34453 var clayout = cfg.layout;
34454 clayout.el = this.el.createChild();
34455 clayout.items = clayout.items || [];
34459 // replace this exitems with the clayout ones..
34460 xitems = clayout.items;
34462 // force background off if it's in center...
34463 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34464 cfg.background = false;
34466 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34469 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34470 //console.log('adding nested layout panel ' + cfg.toSource());
34471 this.add(region, ret);
34472 nb = {}; /// find first...
34477 // needs grid and region
34479 //var el = this.getRegion(region).el.createChild();
34481 *var el = this.el.createChild();
34482 // create the grid first...
34483 cfg.grid.container = el;
34484 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34487 if (region == 'center' && this.active ) {
34488 cfg.background = false;
34491 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34493 this.add(region, ret);
34495 if (cfg.background) {
34496 // render grid on panel activation (if panel background)
34497 ret.on('activate', function(gp) {
34498 if (!gp.grid.rendered) {
34499 // gp.grid.render(el);
34503 // cfg.grid.render(el);
34509 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34510 // it was the old xcomponent building that caused this before.
34511 // espeically if border is the top element in the tree.
34521 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34523 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34524 this.add(region, ret);
34528 throw "Can not add '" + cfg.xtype + "' to Border";
34534 this.beginUpdate();
34538 Roo.each(xitems, function(i) {
34539 region = nb && i.region ? i.region : false;
34541 var add = ret.addxtype(i);
34544 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34545 if (!i.background) {
34546 abn[region] = nb[region] ;
34553 // make the last non-background panel active..
34554 //if (nb) { Roo.log(abn); }
34557 for(var r in abn) {
34558 region = this.getRegion(r);
34560 // tried using nb[r], but it does not work..
34562 region.showPanel(abn[r]);
34573 factory : function(cfg)
34576 var validRegions = Roo.bootstrap.layout.Border.regions;
34578 var target = cfg.region;
34581 var r = Roo.bootstrap.layout;
34585 return new r.North(cfg);
34587 return new r.South(cfg);
34589 return new r.East(cfg);
34591 return new r.West(cfg);
34593 return new r.Center(cfg);
34595 throw 'Layout region "'+target+'" not supported.';
34602 * Ext JS Library 1.1.1
34603 * Copyright(c) 2006-2007, Ext JS, LLC.
34605 * Originally Released Under LGPL - original licence link has changed is not relivant.
34608 * <script type="text/javascript">
34612 * @class Roo.bootstrap.layout.Basic
34613 * @extends Roo.util.Observable
34614 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
34615 * and does not have a titlebar, tabs or any other features. All it does is size and position
34616 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
34617 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34618 * @cfg {string} region the region that it inhabits..
34619 * @cfg {bool} skipConfig skip config?
34623 Roo.bootstrap.layout.Basic = function(config){
34625 this.mgr = config.mgr;
34627 this.position = config.region;
34629 var skipConfig = config.skipConfig;
34633 * @scope Roo.BasicLayoutRegion
34637 * @event beforeremove
34638 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
34639 * @param {Roo.LayoutRegion} this
34640 * @param {Roo.ContentPanel} panel The panel
34641 * @param {Object} e The cancel event object
34643 "beforeremove" : true,
34645 * @event invalidated
34646 * Fires when the layout for this region is changed.
34647 * @param {Roo.LayoutRegion} this
34649 "invalidated" : true,
34651 * @event visibilitychange
34652 * Fires when this region is shown or hidden
34653 * @param {Roo.LayoutRegion} this
34654 * @param {Boolean} visibility true or false
34656 "visibilitychange" : true,
34658 * @event paneladded
34659 * Fires when a panel is added.
34660 * @param {Roo.LayoutRegion} this
34661 * @param {Roo.ContentPanel} panel The panel
34663 "paneladded" : true,
34665 * @event panelremoved
34666 * Fires when a panel is removed.
34667 * @param {Roo.LayoutRegion} this
34668 * @param {Roo.ContentPanel} panel The panel
34670 "panelremoved" : true,
34672 * @event beforecollapse
34673 * Fires when this region before collapse.
34674 * @param {Roo.LayoutRegion} this
34676 "beforecollapse" : true,
34679 * Fires when this region is collapsed.
34680 * @param {Roo.LayoutRegion} this
34682 "collapsed" : true,
34685 * Fires when this region is expanded.
34686 * @param {Roo.LayoutRegion} this
34691 * Fires when this region is slid into view.
34692 * @param {Roo.LayoutRegion} this
34694 "slideshow" : true,
34697 * Fires when this region slides out of view.
34698 * @param {Roo.LayoutRegion} this
34700 "slidehide" : true,
34702 * @event panelactivated
34703 * Fires when a panel is activated.
34704 * @param {Roo.LayoutRegion} this
34705 * @param {Roo.ContentPanel} panel The activated panel
34707 "panelactivated" : true,
34710 * Fires when the user resizes this region.
34711 * @param {Roo.LayoutRegion} this
34712 * @param {Number} newSize The new size (width for east/west, height for north/south)
34716 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34717 this.panels = new Roo.util.MixedCollection();
34718 this.panels.getKey = this.getPanelId.createDelegate(this);
34720 this.activePanel = null;
34721 // ensure listeners are added...
34723 if (config.listeners || config.events) {
34724 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34725 listeners : config.listeners || {},
34726 events : config.events || {}
34730 if(skipConfig !== true){
34731 this.applyConfig(config);
34735 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34737 getPanelId : function(p){
34741 applyConfig : function(config){
34742 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34743 this.config = config;
34748 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34749 * the width, for horizontal (north, south) the height.
34750 * @param {Number} newSize The new width or height
34752 resizeTo : function(newSize){
34753 var el = this.el ? this.el :
34754 (this.activePanel ? this.activePanel.getEl() : null);
34756 switch(this.position){
34759 el.setWidth(newSize);
34760 this.fireEvent("resized", this, newSize);
34764 el.setHeight(newSize);
34765 this.fireEvent("resized", this, newSize);
34771 getBox : function(){
34772 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34775 getMargins : function(){
34776 return this.margins;
34779 updateBox : function(box){
34781 var el = this.activePanel.getEl();
34782 el.dom.style.left = box.x + "px";
34783 el.dom.style.top = box.y + "px";
34784 this.activePanel.setSize(box.width, box.height);
34788 * Returns the container element for this region.
34789 * @return {Roo.Element}
34791 getEl : function(){
34792 return this.activePanel;
34796 * Returns true if this region is currently visible.
34797 * @return {Boolean}
34799 isVisible : function(){
34800 return this.activePanel ? true : false;
34803 setActivePanel : function(panel){
34804 panel = this.getPanel(panel);
34805 if(this.activePanel && this.activePanel != panel){
34806 this.activePanel.setActiveState(false);
34807 this.activePanel.getEl().setLeftTop(-10000,-10000);
34809 this.activePanel = panel;
34810 panel.setActiveState(true);
34812 panel.setSize(this.box.width, this.box.height);
34814 this.fireEvent("panelactivated", this, panel);
34815 this.fireEvent("invalidated");
34819 * Show the specified panel.
34820 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
34821 * @return {Roo.ContentPanel} The shown panel or null
34823 showPanel : function(panel){
34824 panel = this.getPanel(panel);
34826 this.setActivePanel(panel);
34832 * Get the active panel for this region.
34833 * @return {Roo.ContentPanel} The active panel or null
34835 getActivePanel : function(){
34836 return this.activePanel;
34840 * Add the passed ContentPanel(s)
34841 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
34842 * @return {Roo.ContentPanel} The panel added (if only one was added)
34844 add : function(panel){
34845 if(arguments.length > 1){
34846 for(var i = 0, len = arguments.length; i < len; i++) {
34847 this.add(arguments[i]);
34851 if(this.hasPanel(panel)){
34852 this.showPanel(panel);
34855 var el = panel.getEl();
34856 if(el.dom.parentNode != this.mgr.el.dom){
34857 this.mgr.el.dom.appendChild(el.dom);
34859 if(panel.setRegion){
34860 panel.setRegion(this);
34862 this.panels.add(panel);
34863 el.setStyle("position", "absolute");
34864 if(!panel.background){
34865 this.setActivePanel(panel);
34866 if(this.config.initialSize && this.panels.getCount()==1){
34867 this.resizeTo(this.config.initialSize);
34870 this.fireEvent("paneladded", this, panel);
34875 * Returns true if the panel is in this region.
34876 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34877 * @return {Boolean}
34879 hasPanel : function(panel){
34880 if(typeof panel == "object"){ // must be panel obj
34881 panel = panel.getId();
34883 return this.getPanel(panel) ? true : false;
34887 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
34888 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34889 * @param {Boolean} preservePanel Overrides the config preservePanel option
34890 * @return {Roo.ContentPanel} The panel that was removed
34892 remove : function(panel, preservePanel){
34893 panel = this.getPanel(panel);
34898 this.fireEvent("beforeremove", this, panel, e);
34899 if(e.cancel === true){
34902 var panelId = panel.getId();
34903 this.panels.removeKey(panelId);
34908 * Returns the panel specified or null if it's not in this region.
34909 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34910 * @return {Roo.ContentPanel}
34912 getPanel : function(id){
34913 if(typeof id == "object"){ // must be panel obj
34916 return this.panels.get(id);
34920 * Returns this regions position (north/south/east/west/center).
34923 getPosition: function(){
34924 return this.position;
34928 * Ext JS Library 1.1.1
34929 * Copyright(c) 2006-2007, Ext JS, LLC.
34931 * Originally Released Under LGPL - original licence link has changed is not relivant.
34934 * <script type="text/javascript">
34938 * @class Roo.bootstrap.layout.Region
34939 * @extends Roo.bootstrap.layout.Basic
34940 * This class represents a region in a layout manager.
34942 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
34943 * @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})
34944 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
34945 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
34946 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
34947 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
34948 * @cfg {String} title The title for the region (overrides panel titles)
34949 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
34950 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
34951 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
34952 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
34953 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
34954 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
34955 * the space available, similar to FireFox 1.5 tabs (defaults to false)
34956 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
34957 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
34958 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
34960 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
34961 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
34962 * @cfg {Boolean} disableTabTips True to disable tab tooltips
34963 * @cfg {Number} width For East/West panels
34964 * @cfg {Number} height For North/South panels
34965 * @cfg {Boolean} split To show the splitter
34966 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
34968 * @cfg {string} cls Extra CSS classes to add to region
34970 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34971 * @cfg {string} region the region that it inhabits..
34974 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
34975 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
34977 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
34978 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
34979 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
34981 Roo.bootstrap.layout.Region = function(config)
34983 this.applyConfig(config);
34985 var mgr = config.mgr;
34986 var pos = config.region;
34987 config.skipConfig = true;
34988 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
34991 this.onRender(mgr.el);
34994 this.visible = true;
34995 this.collapsed = false;
34996 this.unrendered_panels = [];
34999 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35001 position: '', // set by wrapper (eg. north/south etc..)
35002 unrendered_panels : null, // unrendered panels.
35003 createBody : function(){
35004 /** This region's body element
35005 * @type Roo.Element */
35006 this.bodyEl = this.el.createChild({
35008 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35012 onRender: function(ctr, pos)
35014 var dh = Roo.DomHelper;
35015 /** This region's container element
35016 * @type Roo.Element */
35017 this.el = dh.append(ctr.dom, {
35019 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35021 /** This region's title element
35022 * @type Roo.Element */
35024 this.titleEl = dh.append(this.el.dom,
35027 unselectable: "on",
35028 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35030 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35031 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35034 this.titleEl.enableDisplayMode();
35035 /** This region's title text element
35036 * @type HTMLElement */
35037 this.titleTextEl = this.titleEl.dom.firstChild;
35038 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35040 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35041 this.closeBtn.enableDisplayMode();
35042 this.closeBtn.on("click", this.closeClicked, this);
35043 this.closeBtn.hide();
35045 this.createBody(this.config);
35046 if(this.config.hideWhenEmpty){
35048 this.on("paneladded", this.validateVisibility, this);
35049 this.on("panelremoved", this.validateVisibility, this);
35051 if(this.autoScroll){
35052 this.bodyEl.setStyle("overflow", "auto");
35054 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35056 //if(c.titlebar !== false){
35057 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35058 this.titleEl.hide();
35060 this.titleEl.show();
35061 if(this.config.title){
35062 this.titleTextEl.innerHTML = this.config.title;
35066 if(this.config.collapsed){
35067 this.collapse(true);
35069 if(this.config.hidden){
35073 if (this.unrendered_panels && this.unrendered_panels.length) {
35074 for (var i =0;i< this.unrendered_panels.length; i++) {
35075 this.add(this.unrendered_panels[i]);
35077 this.unrendered_panels = null;
35083 applyConfig : function(c)
35086 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35087 var dh = Roo.DomHelper;
35088 if(c.titlebar !== false){
35089 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35090 this.collapseBtn.on("click", this.collapse, this);
35091 this.collapseBtn.enableDisplayMode();
35093 if(c.showPin === true || this.showPin){
35094 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35095 this.stickBtn.enableDisplayMode();
35096 this.stickBtn.on("click", this.expand, this);
35097 this.stickBtn.hide();
35102 /** This region's collapsed element
35103 * @type Roo.Element */
35106 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35107 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35110 if(c.floatable !== false){
35111 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35112 this.collapsedEl.on("click", this.collapseClick, this);
35115 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35116 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35117 id: "message", unselectable: "on", style:{"float":"left"}});
35118 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35120 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35121 this.expandBtn.on("click", this.expand, this);
35125 if(this.collapseBtn){
35126 this.collapseBtn.setVisible(c.collapsible == true);
35129 this.cmargins = c.cmargins || this.cmargins ||
35130 (this.position == "west" || this.position == "east" ?
35131 {top: 0, left: 2, right:2, bottom: 0} :
35132 {top: 2, left: 0, right:0, bottom: 2});
35134 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35137 this.bottomTabs = c.tabPosition != "top";
35139 this.autoScroll = c.autoScroll || false;
35144 this.duration = c.duration || .30;
35145 this.slideDuration = c.slideDuration || .45;
35150 * Returns true if this region is currently visible.
35151 * @return {Boolean}
35153 isVisible : function(){
35154 return this.visible;
35158 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35159 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35161 //setCollapsedTitle : function(title){
35162 // title = title || " ";
35163 // if(this.collapsedTitleTextEl){
35164 // this.collapsedTitleTextEl.innerHTML = title;
35168 getBox : function(){
35170 // if(!this.collapsed){
35171 b = this.el.getBox(false, true);
35173 // b = this.collapsedEl.getBox(false, true);
35178 getMargins : function(){
35179 return this.margins;
35180 //return this.collapsed ? this.cmargins : this.margins;
35183 highlight : function(){
35184 this.el.addClass("x-layout-panel-dragover");
35187 unhighlight : function(){
35188 this.el.removeClass("x-layout-panel-dragover");
35191 updateBox : function(box)
35193 if (!this.bodyEl) {
35194 return; // not rendered yet..
35198 if(!this.collapsed){
35199 this.el.dom.style.left = box.x + "px";
35200 this.el.dom.style.top = box.y + "px";
35201 this.updateBody(box.width, box.height);
35203 this.collapsedEl.dom.style.left = box.x + "px";
35204 this.collapsedEl.dom.style.top = box.y + "px";
35205 this.collapsedEl.setSize(box.width, box.height);
35208 this.tabs.autoSizeTabs();
35212 updateBody : function(w, h)
35215 this.el.setWidth(w);
35216 w -= this.el.getBorderWidth("rl");
35217 if(this.config.adjustments){
35218 w += this.config.adjustments[0];
35221 if(h !== null && h > 0){
35222 this.el.setHeight(h);
35223 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35224 h -= this.el.getBorderWidth("tb");
35225 if(this.config.adjustments){
35226 h += this.config.adjustments[1];
35228 this.bodyEl.setHeight(h);
35230 h = this.tabs.syncHeight(h);
35233 if(this.panelSize){
35234 w = w !== null ? w : this.panelSize.width;
35235 h = h !== null ? h : this.panelSize.height;
35237 if(this.activePanel){
35238 var el = this.activePanel.getEl();
35239 w = w !== null ? w : el.getWidth();
35240 h = h !== null ? h : el.getHeight();
35241 this.panelSize = {width: w, height: h};
35242 this.activePanel.setSize(w, h);
35244 if(Roo.isIE && this.tabs){
35245 this.tabs.el.repaint();
35250 * Returns the container element for this region.
35251 * @return {Roo.Element}
35253 getEl : function(){
35258 * Hides this region.
35261 //if(!this.collapsed){
35262 this.el.dom.style.left = "-2000px";
35265 // this.collapsedEl.dom.style.left = "-2000px";
35266 // this.collapsedEl.hide();
35268 this.visible = false;
35269 this.fireEvent("visibilitychange", this, false);
35273 * Shows this region if it was previously hidden.
35276 //if(!this.collapsed){
35279 // this.collapsedEl.show();
35281 this.visible = true;
35282 this.fireEvent("visibilitychange", this, true);
35285 closeClicked : function(){
35286 if(this.activePanel){
35287 this.remove(this.activePanel);
35291 collapseClick : function(e){
35293 e.stopPropagation();
35296 e.stopPropagation();
35302 * Collapses this region.
35303 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35306 collapse : function(skipAnim, skipCheck = false){
35307 if(this.collapsed) {
35311 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35313 this.collapsed = true;
35315 this.split.el.hide();
35317 if(this.config.animate && skipAnim !== true){
35318 this.fireEvent("invalidated", this);
35319 this.animateCollapse();
35321 this.el.setLocation(-20000,-20000);
35323 this.collapsedEl.show();
35324 this.fireEvent("collapsed", this);
35325 this.fireEvent("invalidated", this);
35331 animateCollapse : function(){
35336 * Expands this region if it was previously collapsed.
35337 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35338 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35341 expand : function(e, skipAnim){
35343 e.stopPropagation();
35345 if(!this.collapsed || this.el.hasActiveFx()) {
35349 this.afterSlideIn();
35352 this.collapsed = false;
35353 if(this.config.animate && skipAnim !== true){
35354 this.animateExpand();
35358 this.split.el.show();
35360 this.collapsedEl.setLocation(-2000,-2000);
35361 this.collapsedEl.hide();
35362 this.fireEvent("invalidated", this);
35363 this.fireEvent("expanded", this);
35367 animateExpand : function(){
35371 initTabs : function()
35373 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35375 var ts = new Roo.bootstrap.panel.Tabs({
35376 el: this.bodyEl.dom,
35377 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35378 disableTooltips: this.config.disableTabTips,
35379 toolbar : this.config.toolbar
35382 if(this.config.hideTabs){
35383 ts.stripWrap.setDisplayed(false);
35386 ts.resizeTabs = this.config.resizeTabs === true;
35387 ts.minTabWidth = this.config.minTabWidth || 40;
35388 ts.maxTabWidth = this.config.maxTabWidth || 250;
35389 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35390 ts.monitorResize = false;
35391 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35392 ts.bodyEl.addClass('roo-layout-tabs-body');
35393 this.panels.each(this.initPanelAsTab, this);
35396 initPanelAsTab : function(panel){
35397 var ti = this.tabs.addTab(
35401 this.config.closeOnTab && panel.isClosable(),
35404 if(panel.tabTip !== undefined){
35405 ti.setTooltip(panel.tabTip);
35407 ti.on("activate", function(){
35408 this.setActivePanel(panel);
35411 if(this.config.closeOnTab){
35412 ti.on("beforeclose", function(t, e){
35414 this.remove(panel);
35418 panel.tabItem = ti;
35423 updatePanelTitle : function(panel, title)
35425 if(this.activePanel == panel){
35426 this.updateTitle(title);
35429 var ti = this.tabs.getTab(panel.getEl().id);
35431 if(panel.tabTip !== undefined){
35432 ti.setTooltip(panel.tabTip);
35437 updateTitle : function(title){
35438 if(this.titleTextEl && !this.config.title){
35439 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35443 setActivePanel : function(panel)
35445 panel = this.getPanel(panel);
35446 if(this.activePanel && this.activePanel != panel){
35447 this.activePanel.setActiveState(false);
35449 this.activePanel = panel;
35450 panel.setActiveState(true);
35451 if(this.panelSize){
35452 panel.setSize(this.panelSize.width, this.panelSize.height);
35455 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35457 this.updateTitle(panel.getTitle());
35459 this.fireEvent("invalidated", this);
35461 this.fireEvent("panelactivated", this, panel);
35465 * Shows the specified panel.
35466 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35467 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35469 showPanel : function(panel)
35471 panel = this.getPanel(panel);
35474 var tab = this.tabs.getTab(panel.getEl().id);
35475 if(tab.isHidden()){
35476 this.tabs.unhideTab(tab.id);
35480 this.setActivePanel(panel);
35487 * Get the active panel for this region.
35488 * @return {Roo.ContentPanel} The active panel or null
35490 getActivePanel : function(){
35491 return this.activePanel;
35494 validateVisibility : function(){
35495 if(this.panels.getCount() < 1){
35496 this.updateTitle(" ");
35497 this.closeBtn.hide();
35500 if(!this.isVisible()){
35507 * Adds the passed ContentPanel(s) to this region.
35508 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35509 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35511 add : function(panel)
35513 if(arguments.length > 1){
35514 for(var i = 0, len = arguments.length; i < len; i++) {
35515 this.add(arguments[i]);
35520 // if we have not been rendered yet, then we can not really do much of this..
35521 if (!this.bodyEl) {
35522 this.unrendered_panels.push(panel);
35529 if(this.hasPanel(panel)){
35530 this.showPanel(panel);
35533 panel.setRegion(this);
35534 this.panels.add(panel);
35535 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35536 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35537 // and hide them... ???
35538 this.bodyEl.dom.appendChild(panel.getEl().dom);
35539 if(panel.background !== true){
35540 this.setActivePanel(panel);
35542 this.fireEvent("paneladded", this, panel);
35549 this.initPanelAsTab(panel);
35553 if(panel.background !== true){
35554 this.tabs.activate(panel.getEl().id);
35556 this.fireEvent("paneladded", this, panel);
35561 * Hides the tab for the specified panel.
35562 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35564 hidePanel : function(panel){
35565 if(this.tabs && (panel = this.getPanel(panel))){
35566 this.tabs.hideTab(panel.getEl().id);
35571 * Unhides the tab for a previously hidden panel.
35572 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35574 unhidePanel : function(panel){
35575 if(this.tabs && (panel = this.getPanel(panel))){
35576 this.tabs.unhideTab(panel.getEl().id);
35580 clearPanels : function(){
35581 while(this.panels.getCount() > 0){
35582 this.remove(this.panels.first());
35587 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35588 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35589 * @param {Boolean} preservePanel Overrides the config preservePanel option
35590 * @return {Roo.ContentPanel} The panel that was removed
35592 remove : function(panel, preservePanel)
35594 panel = this.getPanel(panel);
35599 this.fireEvent("beforeremove", this, panel, e);
35600 if(e.cancel === true){
35603 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
35604 var panelId = panel.getId();
35605 this.panels.removeKey(panelId);
35607 document.body.appendChild(panel.getEl().dom);
35610 this.tabs.removeTab(panel.getEl().id);
35611 }else if (!preservePanel){
35612 this.bodyEl.dom.removeChild(panel.getEl().dom);
35614 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
35615 var p = this.panels.first();
35616 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
35617 tempEl.appendChild(p.getEl().dom);
35618 this.bodyEl.update("");
35619 this.bodyEl.dom.appendChild(p.getEl().dom);
35621 this.updateTitle(p.getTitle());
35623 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
35624 this.setActivePanel(p);
35626 panel.setRegion(null);
35627 if(this.activePanel == panel){
35628 this.activePanel = null;
35630 if(this.config.autoDestroy !== false && preservePanel !== true){
35631 try{panel.destroy();}catch(e){}
35633 this.fireEvent("panelremoved", this, panel);
35638 * Returns the TabPanel component used by this region
35639 * @return {Roo.TabPanel}
35641 getTabs : function(){
35645 createTool : function(parentEl, className){
35646 var btn = Roo.DomHelper.append(parentEl, {
35648 cls: "x-layout-tools-button",
35651 cls: "roo-layout-tools-button-inner " + className,
35655 btn.addClassOnOver("roo-layout-tools-button-over");
35660 * Ext JS Library 1.1.1
35661 * Copyright(c) 2006-2007, Ext JS, LLC.
35663 * Originally Released Under LGPL - original licence link has changed is not relivant.
35666 * <script type="text/javascript">
35672 * @class Roo.SplitLayoutRegion
35673 * @extends Roo.LayoutRegion
35674 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
35676 Roo.bootstrap.layout.Split = function(config){
35677 this.cursor = config.cursor;
35678 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
35681 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
35683 splitTip : "Drag to resize.",
35684 collapsibleSplitTip : "Drag to resize. Double click to hide.",
35685 useSplitTips : false,
35687 applyConfig : function(config){
35688 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
35691 onRender : function(ctr,pos) {
35693 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
35694 if(!this.config.split){
35699 var splitEl = Roo.DomHelper.append(ctr.dom, {
35701 id: this.el.id + "-split",
35702 cls: "roo-layout-split roo-layout-split-"+this.position,
35705 /** The SplitBar for this region
35706 * @type Roo.SplitBar */
35707 // does not exist yet...
35708 Roo.log([this.position, this.orientation]);
35710 this.split = new Roo.bootstrap.SplitBar({
35711 dragElement : splitEl,
35712 resizingElement: this.el,
35713 orientation : this.orientation
35716 this.split.on("moved", this.onSplitMove, this);
35717 this.split.useShim = this.config.useShim === true;
35718 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35719 if(this.useSplitTips){
35720 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35722 //if(config.collapsible){
35723 // this.split.el.on("dblclick", this.collapse, this);
35726 if(typeof this.config.minSize != "undefined"){
35727 this.split.minSize = this.config.minSize;
35729 if(typeof this.config.maxSize != "undefined"){
35730 this.split.maxSize = this.config.maxSize;
35732 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35733 this.hideSplitter();
35738 getHMaxSize : function(){
35739 var cmax = this.config.maxSize || 10000;
35740 var center = this.mgr.getRegion("center");
35741 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35744 getVMaxSize : function(){
35745 var cmax = this.config.maxSize || 10000;
35746 var center = this.mgr.getRegion("center");
35747 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35750 onSplitMove : function(split, newSize){
35751 this.fireEvent("resized", this, newSize);
35755 * Returns the {@link Roo.SplitBar} for this region.
35756 * @return {Roo.SplitBar}
35758 getSplitBar : function(){
35763 this.hideSplitter();
35764 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35767 hideSplitter : function(){
35769 this.split.el.setLocation(-2000,-2000);
35770 this.split.el.hide();
35776 this.split.el.show();
35778 Roo.bootstrap.layout.Split.superclass.show.call(this);
35781 beforeSlide: function(){
35782 if(Roo.isGecko){// firefox overflow auto bug workaround
35783 this.bodyEl.clip();
35785 this.tabs.bodyEl.clip();
35787 if(this.activePanel){
35788 this.activePanel.getEl().clip();
35790 if(this.activePanel.beforeSlide){
35791 this.activePanel.beforeSlide();
35797 afterSlide : function(){
35798 if(Roo.isGecko){// firefox overflow auto bug workaround
35799 this.bodyEl.unclip();
35801 this.tabs.bodyEl.unclip();
35803 if(this.activePanel){
35804 this.activePanel.getEl().unclip();
35805 if(this.activePanel.afterSlide){
35806 this.activePanel.afterSlide();
35812 initAutoHide : function(){
35813 if(this.autoHide !== false){
35814 if(!this.autoHideHd){
35815 var st = new Roo.util.DelayedTask(this.slideIn, this);
35816 this.autoHideHd = {
35817 "mouseout": function(e){
35818 if(!e.within(this.el, true)){
35822 "mouseover" : function(e){
35828 this.el.on(this.autoHideHd);
35832 clearAutoHide : function(){
35833 if(this.autoHide !== false){
35834 this.el.un("mouseout", this.autoHideHd.mouseout);
35835 this.el.un("mouseover", this.autoHideHd.mouseover);
35839 clearMonitor : function(){
35840 Roo.get(document).un("click", this.slideInIf, this);
35843 // these names are backwards but not changed for compat
35844 slideOut : function(){
35845 if(this.isSlid || this.el.hasActiveFx()){
35848 this.isSlid = true;
35849 if(this.collapseBtn){
35850 this.collapseBtn.hide();
35852 this.closeBtnState = this.closeBtn.getStyle('display');
35853 this.closeBtn.hide();
35855 this.stickBtn.show();
35858 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
35859 this.beforeSlide();
35860 this.el.setStyle("z-index", 10001);
35861 this.el.slideIn(this.getSlideAnchor(), {
35862 callback: function(){
35864 this.initAutoHide();
35865 Roo.get(document).on("click", this.slideInIf, this);
35866 this.fireEvent("slideshow", this);
35873 afterSlideIn : function(){
35874 this.clearAutoHide();
35875 this.isSlid = false;
35876 this.clearMonitor();
35877 this.el.setStyle("z-index", "");
35878 if(this.collapseBtn){
35879 this.collapseBtn.show();
35881 this.closeBtn.setStyle('display', this.closeBtnState);
35883 this.stickBtn.hide();
35885 this.fireEvent("slidehide", this);
35888 slideIn : function(cb){
35889 if(!this.isSlid || this.el.hasActiveFx()){
35893 this.isSlid = false;
35894 this.beforeSlide();
35895 this.el.slideOut(this.getSlideAnchor(), {
35896 callback: function(){
35897 this.el.setLeftTop(-10000, -10000);
35899 this.afterSlideIn();
35907 slideInIf : function(e){
35908 if(!e.within(this.el)){
35913 animateCollapse : function(){
35914 this.beforeSlide();
35915 this.el.setStyle("z-index", 20000);
35916 var anchor = this.getSlideAnchor();
35917 this.el.slideOut(anchor, {
35918 callback : function(){
35919 this.el.setStyle("z-index", "");
35920 this.collapsedEl.slideIn(anchor, {duration:.3});
35922 this.el.setLocation(-10000,-10000);
35924 this.fireEvent("collapsed", this);
35931 animateExpand : function(){
35932 this.beforeSlide();
35933 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
35934 this.el.setStyle("z-index", 20000);
35935 this.collapsedEl.hide({
35938 this.el.slideIn(this.getSlideAnchor(), {
35939 callback : function(){
35940 this.el.setStyle("z-index", "");
35943 this.split.el.show();
35945 this.fireEvent("invalidated", this);
35946 this.fireEvent("expanded", this);
35974 getAnchor : function(){
35975 return this.anchors[this.position];
35978 getCollapseAnchor : function(){
35979 return this.canchors[this.position];
35982 getSlideAnchor : function(){
35983 return this.sanchors[this.position];
35986 getAlignAdj : function(){
35987 var cm = this.cmargins;
35988 switch(this.position){
36004 getExpandAdj : function(){
36005 var c = this.collapsedEl, cm = this.cmargins;
36006 switch(this.position){
36008 return [-(cm.right+c.getWidth()+cm.left), 0];
36011 return [cm.right+c.getWidth()+cm.left, 0];
36014 return [0, -(cm.top+cm.bottom+c.getHeight())];
36017 return [0, cm.top+cm.bottom+c.getHeight()];
36023 * Ext JS Library 1.1.1
36024 * Copyright(c) 2006-2007, Ext JS, LLC.
36026 * Originally Released Under LGPL - original licence link has changed is not relivant.
36029 * <script type="text/javascript">
36032 * These classes are private internal classes
36034 Roo.bootstrap.layout.Center = function(config){
36035 config.region = "center";
36036 Roo.bootstrap.layout.Region.call(this, config);
36037 this.visible = true;
36038 this.minWidth = config.minWidth || 20;
36039 this.minHeight = config.minHeight || 20;
36042 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36044 // center panel can't be hidden
36048 // center panel can't be hidden
36051 getMinWidth: function(){
36052 return this.minWidth;
36055 getMinHeight: function(){
36056 return this.minHeight;
36069 Roo.bootstrap.layout.North = function(config)
36071 config.region = 'north';
36072 config.cursor = 'n-resize';
36074 Roo.bootstrap.layout.Split.call(this, config);
36078 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36079 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36080 this.split.el.addClass("roo-layout-split-v");
36082 var size = config.initialSize || config.height;
36083 if(typeof size != "undefined"){
36084 this.el.setHeight(size);
36087 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36089 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36093 getBox : function(){
36094 if(this.collapsed){
36095 return this.collapsedEl.getBox();
36097 var box = this.el.getBox();
36099 box.height += this.split.el.getHeight();
36104 updateBox : function(box){
36105 if(this.split && !this.collapsed){
36106 box.height -= this.split.el.getHeight();
36107 this.split.el.setLeft(box.x);
36108 this.split.el.setTop(box.y+box.height);
36109 this.split.el.setWidth(box.width);
36111 if(this.collapsed){
36112 this.updateBody(box.width, null);
36114 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36122 Roo.bootstrap.layout.South = function(config){
36123 config.region = 'south';
36124 config.cursor = 's-resize';
36125 Roo.bootstrap.layout.Split.call(this, config);
36127 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36128 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36129 this.split.el.addClass("roo-layout-split-v");
36131 var size = config.initialSize || config.height;
36132 if(typeof size != "undefined"){
36133 this.el.setHeight(size);
36137 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36138 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36139 getBox : function(){
36140 if(this.collapsed){
36141 return this.collapsedEl.getBox();
36143 var box = this.el.getBox();
36145 var sh = this.split.el.getHeight();
36152 updateBox : function(box){
36153 if(this.split && !this.collapsed){
36154 var sh = this.split.el.getHeight();
36157 this.split.el.setLeft(box.x);
36158 this.split.el.setTop(box.y-sh);
36159 this.split.el.setWidth(box.width);
36161 if(this.collapsed){
36162 this.updateBody(box.width, null);
36164 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36168 Roo.bootstrap.layout.East = function(config){
36169 config.region = "east";
36170 config.cursor = "e-resize";
36171 Roo.bootstrap.layout.Split.call(this, config);
36173 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36174 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36175 this.split.el.addClass("roo-layout-split-h");
36177 var size = config.initialSize || config.width;
36178 if(typeof size != "undefined"){
36179 this.el.setWidth(size);
36182 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36183 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36184 getBox : function(){
36185 if(this.collapsed){
36186 return this.collapsedEl.getBox();
36188 var box = this.el.getBox();
36190 var sw = this.split.el.getWidth();
36197 updateBox : function(box){
36198 if(this.split && !this.collapsed){
36199 var sw = this.split.el.getWidth();
36201 this.split.el.setLeft(box.x);
36202 this.split.el.setTop(box.y);
36203 this.split.el.setHeight(box.height);
36206 if(this.collapsed){
36207 this.updateBody(null, box.height);
36209 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36213 Roo.bootstrap.layout.West = function(config){
36214 config.region = "west";
36215 config.cursor = "w-resize";
36217 Roo.bootstrap.layout.Split.call(this, config);
36219 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36220 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36221 this.split.el.addClass("roo-layout-split-h");
36225 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36226 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36228 onRender: function(ctr, pos)
36230 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36231 var size = this.config.initialSize || this.config.width;
36232 if(typeof size != "undefined"){
36233 this.el.setWidth(size);
36237 getBox : function(){
36238 if(this.collapsed){
36239 return this.collapsedEl.getBox();
36241 var box = this.el.getBox();
36243 box.width += this.split.el.getWidth();
36248 updateBox : function(box){
36249 if(this.split && !this.collapsed){
36250 var sw = this.split.el.getWidth();
36252 this.split.el.setLeft(box.x+box.width);
36253 this.split.el.setTop(box.y);
36254 this.split.el.setHeight(box.height);
36256 if(this.collapsed){
36257 this.updateBody(null, box.height);
36259 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36262 Roo.namespace("Roo.bootstrap.panel");/*
36264 * Ext JS Library 1.1.1
36265 * Copyright(c) 2006-2007, Ext JS, LLC.
36267 * Originally Released Under LGPL - original licence link has changed is not relivant.
36270 * <script type="text/javascript">
36273 * @class Roo.ContentPanel
36274 * @extends Roo.util.Observable
36275 * A basic ContentPanel element.
36276 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36277 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36278 * @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
36279 * @cfg {Boolean} closable True if the panel can be closed/removed
36280 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36281 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36282 * @cfg {Toolbar} toolbar A toolbar for this panel
36283 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36284 * @cfg {String} title The title for this panel
36285 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36286 * @cfg {String} url Calls {@link #setUrl} with this value
36287 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36288 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36289 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36290 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36291 * @cfg {Boolean} badges render the badges
36294 * Create a new ContentPanel.
36295 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36296 * @param {String/Object} config A string to set only the title or a config object
36297 * @param {String} content (optional) Set the HTML content for this panel
36298 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36300 Roo.bootstrap.panel.Content = function( config){
36302 this.tpl = config.tpl || false;
36304 var el = config.el;
36305 var content = config.content;
36307 if(config.autoCreate){ // xtype is available if this is called from factory
36310 this.el = Roo.get(el);
36311 if(!this.el && config && config.autoCreate){
36312 if(typeof config.autoCreate == "object"){
36313 if(!config.autoCreate.id){
36314 config.autoCreate.id = config.id||el;
36316 this.el = Roo.DomHelper.append(document.body,
36317 config.autoCreate, true);
36319 var elcfg = { tag: "div",
36320 cls: "roo-layout-inactive-content",
36324 elcfg.html = config.html;
36328 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36331 this.closable = false;
36332 this.loaded = false;
36333 this.active = false;
36336 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36338 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36340 this.wrapEl = this.el; //this.el.wrap();
36342 if (config.toolbar.items) {
36343 ti = config.toolbar.items ;
36344 delete config.toolbar.items ;
36348 this.toolbar.render(this.wrapEl, 'before');
36349 for(var i =0;i < ti.length;i++) {
36350 // Roo.log(['add child', items[i]]);
36351 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36353 this.toolbar.items = nitems;
36354 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36355 delete config.toolbar;
36359 // xtype created footer. - not sure if will work as we normally have to render first..
36360 if (this.footer && !this.footer.el && this.footer.xtype) {
36361 if (!this.wrapEl) {
36362 this.wrapEl = this.el.wrap();
36365 this.footer.container = this.wrapEl.createChild();
36367 this.footer = Roo.factory(this.footer, Roo);
36372 if(typeof config == "string"){
36373 this.title = config;
36375 Roo.apply(this, config);
36379 this.resizeEl = Roo.get(this.resizeEl, true);
36381 this.resizeEl = this.el;
36383 // handle view.xtype
36391 * Fires when this panel is activated.
36392 * @param {Roo.ContentPanel} this
36396 * @event deactivate
36397 * Fires when this panel is activated.
36398 * @param {Roo.ContentPanel} this
36400 "deactivate" : true,
36404 * Fires when this panel is resized if fitToFrame is true.
36405 * @param {Roo.ContentPanel} this
36406 * @param {Number} width The width after any component adjustments
36407 * @param {Number} height The height after any component adjustments
36413 * Fires when this tab is created
36414 * @param {Roo.ContentPanel} this
36425 if(this.autoScroll){
36426 this.resizeEl.setStyle("overflow", "auto");
36428 // fix randome scrolling
36429 //this.el.on('scroll', function() {
36430 // Roo.log('fix random scolling');
36431 // this.scrollTo('top',0);
36434 content = content || this.content;
36436 this.setContent(content);
36438 if(config && config.url){
36439 this.setUrl(this.url, this.params, this.loadOnce);
36444 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36446 if (this.view && typeof(this.view.xtype) != 'undefined') {
36447 this.view.el = this.el.appendChild(document.createElement("div"));
36448 this.view = Roo.factory(this.view);
36449 this.view.render && this.view.render(false, '');
36453 this.fireEvent('render', this);
36456 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36460 setRegion : function(region){
36461 this.region = region;
36462 this.setActiveClass(region && !this.background);
36466 setActiveClass: function(state)
36469 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36470 this.el.setStyle('position','relative');
36472 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36473 this.el.setStyle('position', 'absolute');
36478 * Returns the toolbar for this Panel if one was configured.
36479 * @return {Roo.Toolbar}
36481 getToolbar : function(){
36482 return this.toolbar;
36485 setActiveState : function(active)
36487 this.active = active;
36488 this.setActiveClass(active);
36490 this.fireEvent("deactivate", this);
36492 this.fireEvent("activate", this);
36496 * Updates this panel's element
36497 * @param {String} content The new content
36498 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36500 setContent : function(content, loadScripts){
36501 this.el.update(content, loadScripts);
36504 ignoreResize : function(w, h){
36505 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36508 this.lastSize = {width: w, height: h};
36513 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36514 * @return {Roo.UpdateManager} The UpdateManager
36516 getUpdateManager : function(){
36517 return this.el.getUpdateManager();
36520 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36521 * @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:
36524 url: "your-url.php",
36525 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36526 callback: yourFunction,
36527 scope: yourObject, //(optional scope)
36530 text: "Loading...",
36535 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36536 * 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.
36537 * @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}
36538 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36539 * @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.
36540 * @return {Roo.ContentPanel} this
36543 var um = this.el.getUpdateManager();
36544 um.update.apply(um, arguments);
36550 * 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.
36551 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36552 * @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)
36553 * @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)
36554 * @return {Roo.UpdateManager} The UpdateManager
36556 setUrl : function(url, params, loadOnce){
36557 if(this.refreshDelegate){
36558 this.removeListener("activate", this.refreshDelegate);
36560 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36561 this.on("activate", this.refreshDelegate);
36562 return this.el.getUpdateManager();
36565 _handleRefresh : function(url, params, loadOnce){
36566 if(!loadOnce || !this.loaded){
36567 var updater = this.el.getUpdateManager();
36568 updater.update(url, params, this._setLoaded.createDelegate(this));
36572 _setLoaded : function(){
36573 this.loaded = true;
36577 * Returns this panel's id
36580 getId : function(){
36585 * Returns this panel's element - used by regiosn to add.
36586 * @return {Roo.Element}
36588 getEl : function(){
36589 return this.wrapEl || this.el;
36594 adjustForComponents : function(width, height)
36596 //Roo.log('adjustForComponents ');
36597 if(this.resizeEl != this.el){
36598 width -= this.el.getFrameWidth('lr');
36599 height -= this.el.getFrameWidth('tb');
36602 var te = this.toolbar.getEl();
36603 te.setWidth(width);
36604 height -= te.getHeight();
36607 var te = this.footer.getEl();
36608 te.setWidth(width);
36609 height -= te.getHeight();
36613 if(this.adjustments){
36614 width += this.adjustments[0];
36615 height += this.adjustments[1];
36617 return {"width": width, "height": height};
36620 setSize : function(width, height){
36621 if(this.fitToFrame && !this.ignoreResize(width, height)){
36622 if(this.fitContainer && this.resizeEl != this.el){
36623 this.el.setSize(width, height);
36625 var size = this.adjustForComponents(width, height);
36626 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
36627 this.fireEvent('resize', this, size.width, size.height);
36632 * Returns this panel's title
36635 getTitle : function(){
36637 if (typeof(this.title) != 'object') {
36642 for (var k in this.title) {
36643 if (!this.title.hasOwnProperty(k)) {
36647 if (k.indexOf('-') >= 0) {
36648 var s = k.split('-');
36649 for (var i = 0; i<s.length; i++) {
36650 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
36653 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
36660 * Set this panel's title
36661 * @param {String} title
36663 setTitle : function(title){
36664 this.title = title;
36666 this.region.updatePanelTitle(this, title);
36671 * Returns true is this panel was configured to be closable
36672 * @return {Boolean}
36674 isClosable : function(){
36675 return this.closable;
36678 beforeSlide : function(){
36680 this.resizeEl.clip();
36683 afterSlide : function(){
36685 this.resizeEl.unclip();
36689 * Force a content refresh from the URL specified in the {@link #setUrl} method.
36690 * Will fail silently if the {@link #setUrl} method has not been called.
36691 * This does not activate the panel, just updates its content.
36693 refresh : function(){
36694 if(this.refreshDelegate){
36695 this.loaded = false;
36696 this.refreshDelegate();
36701 * Destroys this panel
36703 destroy : function(){
36704 this.el.removeAllListeners();
36705 var tempEl = document.createElement("span");
36706 tempEl.appendChild(this.el.dom);
36707 tempEl.innerHTML = "";
36713 * form - if the content panel contains a form - this is a reference to it.
36714 * @type {Roo.form.Form}
36718 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36719 * This contains a reference to it.
36725 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36735 * @param {Object} cfg Xtype definition of item to add.
36739 getChildContainer: function () {
36740 return this.getEl();
36745 var ret = new Roo.factory(cfg);
36750 if (cfg.xtype.match(/^Form$/)) {
36753 //if (this.footer) {
36754 // el = this.footer.container.insertSibling(false, 'before');
36756 el = this.el.createChild();
36759 this.form = new Roo.form.Form(cfg);
36762 if ( this.form.allItems.length) {
36763 this.form.render(el.dom);
36767 // should only have one of theses..
36768 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36769 // views.. should not be just added - used named prop 'view''
36771 cfg.el = this.el.appendChild(document.createElement("div"));
36774 var ret = new Roo.factory(cfg);
36776 ret.render && ret.render(false, ''); // render blank..
36786 * @class Roo.bootstrap.panel.Grid
36787 * @extends Roo.bootstrap.panel.Content
36789 * Create a new GridPanel.
36790 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
36791 * @param {Object} config A the config object
36797 Roo.bootstrap.panel.Grid = function(config)
36801 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
36802 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
36804 config.el = this.wrapper;
36805 //this.el = this.wrapper;
36807 if (config.container) {
36808 // ctor'ed from a Border/panel.grid
36811 this.wrapper.setStyle("overflow", "hidden");
36812 this.wrapper.addClass('roo-grid-container');
36817 if(config.toolbar){
36818 var tool_el = this.wrapper.createChild();
36819 this.toolbar = Roo.factory(config.toolbar);
36821 if (config.toolbar.items) {
36822 ti = config.toolbar.items ;
36823 delete config.toolbar.items ;
36827 this.toolbar.render(tool_el);
36828 for(var i =0;i < ti.length;i++) {
36829 // Roo.log(['add child', items[i]]);
36830 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36832 this.toolbar.items = nitems;
36834 delete config.toolbar;
36837 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
36838 config.grid.scrollBody = true;;
36839 config.grid.monitorWindowResize = false; // turn off autosizing
36840 config.grid.autoHeight = false;
36841 config.grid.autoWidth = false;
36843 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
36845 if (config.background) {
36846 // render grid on panel activation (if panel background)
36847 this.on('activate', function(gp) {
36848 if (!gp.grid.rendered) {
36849 gp.grid.render(this.wrapper);
36850 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36855 this.grid.render(this.wrapper);
36856 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36859 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
36860 // ??? needed ??? config.el = this.wrapper;
36865 // xtype created footer. - not sure if will work as we normally have to render first..
36866 if (this.footer && !this.footer.el && this.footer.xtype) {
36868 var ctr = this.grid.getView().getFooterPanel(true);
36869 this.footer.dataSource = this.grid.dataSource;
36870 this.footer = Roo.factory(this.footer, Roo);
36871 this.footer.render(ctr);
36881 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
36882 getId : function(){
36883 return this.grid.id;
36887 * Returns the grid for this panel
36888 * @return {Roo.bootstrap.Table}
36890 getGrid : function(){
36894 setSize : function(width, height){
36895 if(!this.ignoreResize(width, height)){
36896 var grid = this.grid;
36897 var size = this.adjustForComponents(width, height);
36898 var gridel = grid.getGridEl();
36899 gridel.setSize(size.width, size.height);
36901 var thd = grid.getGridEl().select('thead',true).first();
36902 var tbd = grid.getGridEl().select('tbody', true).first();
36904 tbd.setSize(width, height - thd.getHeight());
36913 beforeSlide : function(){
36914 this.grid.getView().scroller.clip();
36917 afterSlide : function(){
36918 this.grid.getView().scroller.unclip();
36921 destroy : function(){
36922 this.grid.destroy();
36924 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
36929 * @class Roo.bootstrap.panel.Nest
36930 * @extends Roo.bootstrap.panel.Content
36932 * Create a new Panel, that can contain a layout.Border.
36935 * @param {Roo.BorderLayout} layout The layout for this panel
36936 * @param {String/Object} config A string to set only the title or a config object
36938 Roo.bootstrap.panel.Nest = function(config)
36940 // construct with only one argument..
36941 /* FIXME - implement nicer consturctors
36942 if (layout.layout) {
36944 layout = config.layout;
36945 delete config.layout;
36947 if (layout.xtype && !layout.getEl) {
36948 // then layout needs constructing..
36949 layout = Roo.factory(layout, Roo);
36953 config.el = config.layout.getEl();
36955 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
36957 config.layout.monitorWindowResize = false; // turn off autosizing
36958 this.layout = config.layout;
36959 this.layout.getEl().addClass("roo-layout-nested-layout");
36966 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
36968 setSize : function(width, height){
36969 if(!this.ignoreResize(width, height)){
36970 var size = this.adjustForComponents(width, height);
36971 var el = this.layout.getEl();
36972 if (size.height < 1) {
36973 el.setWidth(size.width);
36975 el.setSize(size.width, size.height);
36977 var touch = el.dom.offsetWidth;
36978 this.layout.layout();
36979 // ie requires a double layout on the first pass
36980 if(Roo.isIE && !this.initialized){
36981 this.initialized = true;
36982 this.layout.layout();
36987 // activate all subpanels if not currently active..
36989 setActiveState : function(active){
36990 this.active = active;
36991 this.setActiveClass(active);
36994 this.fireEvent("deactivate", this);
36998 this.fireEvent("activate", this);
36999 // not sure if this should happen before or after..
37000 if (!this.layout) {
37001 return; // should not happen..
37004 for (var r in this.layout.regions) {
37005 reg = this.layout.getRegion(r);
37006 if (reg.getActivePanel()) {
37007 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37008 reg.setActivePanel(reg.getActivePanel());
37011 if (!reg.panels.length) {
37014 reg.showPanel(reg.getPanel(0));
37023 * Returns the nested BorderLayout for this panel
37024 * @return {Roo.BorderLayout}
37026 getLayout : function(){
37027 return this.layout;
37031 * Adds a xtype elements to the layout of the nested panel
37035 xtype : 'ContentPanel',
37042 xtype : 'NestedLayoutPanel',
37048 items : [ ... list of content panels or nested layout panels.. ]
37052 * @param {Object} cfg Xtype definition of item to add.
37054 addxtype : function(cfg) {
37055 return this.layout.addxtype(cfg);
37060 * Ext JS Library 1.1.1
37061 * Copyright(c) 2006-2007, Ext JS, LLC.
37063 * Originally Released Under LGPL - original licence link has changed is not relivant.
37066 * <script type="text/javascript">
37069 * @class Roo.TabPanel
37070 * @extends Roo.util.Observable
37071 * A lightweight tab container.
37075 // basic tabs 1, built from existing content
37076 var tabs = new Roo.TabPanel("tabs1");
37077 tabs.addTab("script", "View Script");
37078 tabs.addTab("markup", "View Markup");
37079 tabs.activate("script");
37081 // more advanced tabs, built from javascript
37082 var jtabs = new Roo.TabPanel("jtabs");
37083 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37085 // set up the UpdateManager
37086 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37087 var updater = tab2.getUpdateManager();
37088 updater.setDefaultUrl("ajax1.htm");
37089 tab2.on('activate', updater.refresh, updater, true);
37091 // Use setUrl for Ajax loading
37092 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37093 tab3.setUrl("ajax2.htm", null, true);
37096 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37099 jtabs.activate("jtabs-1");
37102 * Create a new TabPanel.
37103 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37104 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37106 Roo.bootstrap.panel.Tabs = function(config){
37108 * The container element for this TabPanel.
37109 * @type Roo.Element
37111 this.el = Roo.get(config.el);
37114 if(typeof config == "boolean"){
37115 this.tabPosition = config ? "bottom" : "top";
37117 Roo.apply(this, config);
37121 if(this.tabPosition == "bottom"){
37122 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37123 this.el.addClass("roo-tabs-bottom");
37125 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37126 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37127 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37129 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37131 if(this.tabPosition != "bottom"){
37132 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37133 * @type Roo.Element
37135 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37136 this.el.addClass("roo-tabs-top");
37140 this.bodyEl.setStyle("position", "relative");
37142 this.active = null;
37143 this.activateDelegate = this.activate.createDelegate(this);
37148 * Fires when the active tab changes
37149 * @param {Roo.TabPanel} this
37150 * @param {Roo.TabPanelItem} activePanel The new active tab
37154 * @event beforetabchange
37155 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37156 * @param {Roo.TabPanel} this
37157 * @param {Object} e Set cancel to true on this object to cancel the tab change
37158 * @param {Roo.TabPanelItem} tab The tab being changed to
37160 "beforetabchange" : true
37163 Roo.EventManager.onWindowResize(this.onResize, this);
37164 this.cpad = this.el.getPadding("lr");
37165 this.hiddenCount = 0;
37168 // toolbar on the tabbar support...
37169 if (this.toolbar) {
37170 alert("no toolbar support yet");
37171 this.toolbar = false;
37173 var tcfg = this.toolbar;
37174 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37175 this.toolbar = new Roo.Toolbar(tcfg);
37176 if (Roo.isSafari) {
37177 var tbl = tcfg.container.child('table', true);
37178 tbl.setAttribute('width', '100%');
37186 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37189 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37191 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37193 tabPosition : "top",
37195 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37197 currentTabWidth : 0,
37199 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37203 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37207 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37209 preferredTabWidth : 175,
37211 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37213 resizeTabs : false,
37215 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37217 monitorResize : true,
37219 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37224 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37225 * @param {String} id The id of the div to use <b>or create</b>
37226 * @param {String} text The text for the tab
37227 * @param {String} content (optional) Content to put in the TabPanelItem body
37228 * @param {Boolean} closable (optional) True to create a close icon on the tab
37229 * @return {Roo.TabPanelItem} The created TabPanelItem
37231 addTab : function(id, text, content, closable, tpl)
37233 var item = new Roo.bootstrap.panel.TabItem({
37237 closable : closable,
37240 this.addTabItem(item);
37242 item.setContent(content);
37248 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37249 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37250 * @return {Roo.TabPanelItem}
37252 getTab : function(id){
37253 return this.items[id];
37257 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37258 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37260 hideTab : function(id){
37261 var t = this.items[id];
37264 this.hiddenCount++;
37265 this.autoSizeTabs();
37270 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37271 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37273 unhideTab : function(id){
37274 var t = this.items[id];
37276 t.setHidden(false);
37277 this.hiddenCount--;
37278 this.autoSizeTabs();
37283 * Adds an existing {@link Roo.TabPanelItem}.
37284 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37286 addTabItem : function(item){
37287 this.items[item.id] = item;
37288 this.items.push(item);
37289 // if(this.resizeTabs){
37290 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37291 // this.autoSizeTabs();
37293 // item.autoSize();
37298 * Removes a {@link Roo.TabPanelItem}.
37299 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37301 removeTab : function(id){
37302 var items = this.items;
37303 var tab = items[id];
37304 if(!tab) { return; }
37305 var index = items.indexOf(tab);
37306 if(this.active == tab && items.length > 1){
37307 var newTab = this.getNextAvailable(index);
37312 this.stripEl.dom.removeChild(tab.pnode.dom);
37313 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37314 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37316 items.splice(index, 1);
37317 delete this.items[tab.id];
37318 tab.fireEvent("close", tab);
37319 tab.purgeListeners();
37320 this.autoSizeTabs();
37323 getNextAvailable : function(start){
37324 var items = this.items;
37326 // look for a next tab that will slide over to
37327 // replace the one being removed
37328 while(index < items.length){
37329 var item = items[++index];
37330 if(item && !item.isHidden()){
37334 // if one isn't found select the previous tab (on the left)
37337 var item = items[--index];
37338 if(item && !item.isHidden()){
37346 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37347 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37349 disableTab : function(id){
37350 var tab = this.items[id];
37351 if(tab && this.active != tab){
37357 * Enables a {@link Roo.TabPanelItem} that is disabled.
37358 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37360 enableTab : function(id){
37361 var tab = this.items[id];
37366 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37367 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37368 * @return {Roo.TabPanelItem} The TabPanelItem.
37370 activate : function(id){
37371 var tab = this.items[id];
37375 if(tab == this.active || tab.disabled){
37379 this.fireEvent("beforetabchange", this, e, tab);
37380 if(e.cancel !== true && !tab.disabled){
37382 this.active.hide();
37384 this.active = this.items[id];
37385 this.active.show();
37386 this.fireEvent("tabchange", this, this.active);
37392 * Gets the active {@link Roo.TabPanelItem}.
37393 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37395 getActiveTab : function(){
37396 return this.active;
37400 * Updates the tab body element to fit the height of the container element
37401 * for overflow scrolling
37402 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37404 syncHeight : function(targetHeight){
37405 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37406 var bm = this.bodyEl.getMargins();
37407 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37408 this.bodyEl.setHeight(newHeight);
37412 onResize : function(){
37413 if(this.monitorResize){
37414 this.autoSizeTabs();
37419 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37421 beginUpdate : function(){
37422 this.updating = true;
37426 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37428 endUpdate : function(){
37429 this.updating = false;
37430 this.autoSizeTabs();
37434 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37436 autoSizeTabs : function(){
37437 var count = this.items.length;
37438 var vcount = count - this.hiddenCount;
37439 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37442 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37443 var availWidth = Math.floor(w / vcount);
37444 var b = this.stripBody;
37445 if(b.getWidth() > w){
37446 var tabs = this.items;
37447 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37448 if(availWidth < this.minTabWidth){
37449 /*if(!this.sleft){ // incomplete scrolling code
37450 this.createScrollButtons();
37453 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37456 if(this.currentTabWidth < this.preferredTabWidth){
37457 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37463 * Returns the number of tabs in this TabPanel.
37466 getCount : function(){
37467 return this.items.length;
37471 * Resizes all the tabs to the passed width
37472 * @param {Number} The new width
37474 setTabWidth : function(width){
37475 this.currentTabWidth = width;
37476 for(var i = 0, len = this.items.length; i < len; i++) {
37477 if(!this.items[i].isHidden()) {
37478 this.items[i].setWidth(width);
37484 * Destroys this TabPanel
37485 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37487 destroy : function(removeEl){
37488 Roo.EventManager.removeResizeListener(this.onResize, this);
37489 for(var i = 0, len = this.items.length; i < len; i++){
37490 this.items[i].purgeListeners();
37492 if(removeEl === true){
37493 this.el.update("");
37498 createStrip : function(container)
37500 var strip = document.createElement("nav");
37501 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37502 container.appendChild(strip);
37506 createStripList : function(strip)
37508 // div wrapper for retard IE
37509 // returns the "tr" element.
37510 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37511 //'<div class="x-tabs-strip-wrap">'+
37512 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37513 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37514 return strip.firstChild; //.firstChild.firstChild.firstChild;
37516 createBody : function(container)
37518 var body = document.createElement("div");
37519 Roo.id(body, "tab-body");
37520 //Roo.fly(body).addClass("x-tabs-body");
37521 Roo.fly(body).addClass("tab-content");
37522 container.appendChild(body);
37525 createItemBody :function(bodyEl, id){
37526 var body = Roo.getDom(id);
37528 body = document.createElement("div");
37531 //Roo.fly(body).addClass("x-tabs-item-body");
37532 Roo.fly(body).addClass("tab-pane");
37533 bodyEl.insertBefore(body, bodyEl.firstChild);
37537 createStripElements : function(stripEl, text, closable, tpl)
37539 var td = document.createElement("li"); // was td..
37542 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37545 stripEl.appendChild(td);
37547 td.className = "x-tabs-closable";
37548 if(!this.closeTpl){
37549 this.closeTpl = new Roo.Template(
37550 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37551 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37552 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37555 var el = this.closeTpl.overwrite(td, {"text": text});
37556 var close = el.getElementsByTagName("div")[0];
37557 var inner = el.getElementsByTagName("em")[0];
37558 return {"el": el, "close": close, "inner": inner};
37561 // not sure what this is..
37562 // if(!this.tabTpl){
37563 //this.tabTpl = new Roo.Template(
37564 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37565 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37567 // this.tabTpl = new Roo.Template(
37568 // '<a href="#">' +
37569 // '<span unselectable="on"' +
37570 // (this.disableTooltips ? '' : ' title="{text}"') +
37571 // ' >{text}</span></a>'
37577 var template = tpl || this.tabTpl || false;
37581 template = new Roo.Template(
37583 '<span unselectable="on"' +
37584 (this.disableTooltips ? '' : ' title="{text}"') +
37585 ' >{text}</span></a>'
37589 switch (typeof(template)) {
37593 template = new Roo.Template(template);
37599 var el = template.overwrite(td, {"text": text});
37601 var inner = el.getElementsByTagName("span")[0];
37603 return {"el": el, "inner": inner};
37611 * @class Roo.TabPanelItem
37612 * @extends Roo.util.Observable
37613 * Represents an individual item (tab plus body) in a TabPanel.
37614 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
37615 * @param {String} id The id of this TabPanelItem
37616 * @param {String} text The text for the tab of this TabPanelItem
37617 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
37619 Roo.bootstrap.panel.TabItem = function(config){
37621 * The {@link Roo.TabPanel} this TabPanelItem belongs to
37622 * @type Roo.TabPanel
37624 this.tabPanel = config.panel;
37626 * The id for this TabPanelItem
37629 this.id = config.id;
37631 this.disabled = false;
37633 this.text = config.text;
37635 this.loaded = false;
37636 this.closable = config.closable;
37639 * The body element for this TabPanelItem.
37640 * @type Roo.Element
37642 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
37643 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
37644 this.bodyEl.setStyle("display", "block");
37645 this.bodyEl.setStyle("zoom", "1");
37646 //this.hideAction();
37648 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
37650 this.el = Roo.get(els.el);
37651 this.inner = Roo.get(els.inner, true);
37652 this.textEl = Roo.get(this.el.dom.firstChild, true);
37653 this.pnode = Roo.get(els.el.parentNode, true);
37654 this.el.on("mousedown", this.onTabMouseDown, this);
37655 this.el.on("click", this.onTabClick, this);
37657 if(config.closable){
37658 var c = Roo.get(els.close, true);
37659 c.dom.title = this.closeText;
37660 c.addClassOnOver("close-over");
37661 c.on("click", this.closeClick, this);
37667 * Fires when this tab becomes the active tab.
37668 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37669 * @param {Roo.TabPanelItem} this
37673 * @event beforeclose
37674 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
37675 * @param {Roo.TabPanelItem} this
37676 * @param {Object} e Set cancel to true on this object to cancel the close.
37678 "beforeclose": true,
37681 * Fires when this tab is closed.
37682 * @param {Roo.TabPanelItem} this
37686 * @event deactivate
37687 * Fires when this tab is no longer the active tab.
37688 * @param {Roo.TabPanel} tabPanel The parent TabPanel
37689 * @param {Roo.TabPanelItem} this
37691 "deactivate" : true
37693 this.hidden = false;
37695 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
37698 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37700 purgeListeners : function(){
37701 Roo.util.Observable.prototype.purgeListeners.call(this);
37702 this.el.removeAllListeners();
37705 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37708 this.pnode.addClass("active");
37711 this.tabPanel.stripWrap.repaint();
37713 this.fireEvent("activate", this.tabPanel, this);
37717 * Returns true if this tab is the active tab.
37718 * @return {Boolean}
37720 isActive : function(){
37721 return this.tabPanel.getActiveTab() == this;
37725 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37728 this.pnode.removeClass("active");
37730 this.fireEvent("deactivate", this.tabPanel, this);
37733 hideAction : function(){
37734 this.bodyEl.hide();
37735 this.bodyEl.setStyle("position", "absolute");
37736 this.bodyEl.setLeft("-20000px");
37737 this.bodyEl.setTop("-20000px");
37740 showAction : function(){
37741 this.bodyEl.setStyle("position", "relative");
37742 this.bodyEl.setTop("");
37743 this.bodyEl.setLeft("");
37744 this.bodyEl.show();
37748 * Set the tooltip for the tab.
37749 * @param {String} tooltip The tab's tooltip
37751 setTooltip : function(text){
37752 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37753 this.textEl.dom.qtip = text;
37754 this.textEl.dom.removeAttribute('title');
37756 this.textEl.dom.title = text;
37760 onTabClick : function(e){
37761 e.preventDefault();
37762 this.tabPanel.activate(this.id);
37765 onTabMouseDown : function(e){
37766 e.preventDefault();
37767 this.tabPanel.activate(this.id);
37770 getWidth : function(){
37771 return this.inner.getWidth();
37774 setWidth : function(width){
37775 var iwidth = width - this.pnode.getPadding("lr");
37776 this.inner.setWidth(iwidth);
37777 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
37778 this.pnode.setWidth(width);
37782 * Show or hide the tab
37783 * @param {Boolean} hidden True to hide or false to show.
37785 setHidden : function(hidden){
37786 this.hidden = hidden;
37787 this.pnode.setStyle("display", hidden ? "none" : "");
37791 * Returns true if this tab is "hidden"
37792 * @return {Boolean}
37794 isHidden : function(){
37795 return this.hidden;
37799 * Returns the text for this tab
37802 getText : function(){
37806 autoSize : function(){
37807 //this.el.beginMeasure();
37808 this.textEl.setWidth(1);
37810 * #2804 [new] Tabs in Roojs
37811 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
37813 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
37814 //this.el.endMeasure();
37818 * Sets the text for the tab (Note: this also sets the tooltip text)
37819 * @param {String} text The tab's text and tooltip
37821 setText : function(text){
37823 this.textEl.update(text);
37824 this.setTooltip(text);
37825 //if(!this.tabPanel.resizeTabs){
37826 // this.autoSize();
37830 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
37832 activate : function(){
37833 this.tabPanel.activate(this.id);
37837 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
37839 disable : function(){
37840 if(this.tabPanel.active != this){
37841 this.disabled = true;
37842 this.pnode.addClass("disabled");
37847 * Enables this TabPanelItem if it was previously disabled.
37849 enable : function(){
37850 this.disabled = false;
37851 this.pnode.removeClass("disabled");
37855 * Sets the content for this TabPanelItem.
37856 * @param {String} content The content
37857 * @param {Boolean} loadScripts true to look for and load scripts
37859 setContent : function(content, loadScripts){
37860 this.bodyEl.update(content, loadScripts);
37864 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
37865 * @return {Roo.UpdateManager} The UpdateManager
37867 getUpdateManager : function(){
37868 return this.bodyEl.getUpdateManager();
37872 * Set a URL to be used to load the content for this TabPanelItem.
37873 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
37874 * @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)
37875 * @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)
37876 * @return {Roo.UpdateManager} The UpdateManager
37878 setUrl : function(url, params, loadOnce){
37879 if(this.refreshDelegate){
37880 this.un('activate', this.refreshDelegate);
37882 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37883 this.on("activate", this.refreshDelegate);
37884 return this.bodyEl.getUpdateManager();
37888 _handleRefresh : function(url, params, loadOnce){
37889 if(!loadOnce || !this.loaded){
37890 var updater = this.bodyEl.getUpdateManager();
37891 updater.update(url, params, this._setLoaded.createDelegate(this));
37896 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
37897 * Will fail silently if the setUrl method has not been called.
37898 * This does not activate the panel, just updates its content.
37900 refresh : function(){
37901 if(this.refreshDelegate){
37902 this.loaded = false;
37903 this.refreshDelegate();
37908 _setLoaded : function(){
37909 this.loaded = true;
37913 closeClick : function(e){
37916 this.fireEvent("beforeclose", this, o);
37917 if(o.cancel !== true){
37918 this.tabPanel.removeTab(this.id);
37922 * The text displayed in the tooltip for the close icon.
37925 closeText : "Close this tab"
37927 Roo.bootstrap.PhoneInput = function(config) {
37928 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
37931 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
37933 triggerList : true,
37935 getAutoCreate : function()
37937 var align = this.labelAlign || this.parentLabelAlign();
37941 cls: 'form-group', //input-group
37949 cls : 'form-control tel-input',
37950 autocomplete: 'new-password'
37951 //placeholder : this.placeholder || ''
37955 input.name = this.name;
37958 if (this.disabled) {
37959 input.disabled=true;
37962 var flag_container = {
37964 cls: 'flag-container',
37979 cls: this.hasFeedback ? 'has-feedback' : '',
37986 cls: 'roo-select2-container input-group',
37993 if (this.fieldLabel.length) {
37996 tooltip: 'This field is required'
38002 cls: 'control-label',
38008 html: this.fieldLabel
38011 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
38017 if(this.indicatorpos == 'right') {
38018 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
38025 if(align == 'left') {
38033 if(this.labelWidth > 12){
38034 label.style = "width: " + this.labelWidth + 'px';
38036 if(this.labelWidth < 13 && this.labelmd == 0){
38037 this.labelmd = this.labelWidth;
38039 if(this.labellg > 0){
38040 label.cls += ' col-lg-' + this.labellg;
38041 input.cls += ' col-lg-' + (12 - this.labellg);
38043 if(this.labelmd > 0){
38044 label.cls += ' col-md-' + this.labelmd;
38045 container.cls += ' col-md-' + (12 - this.labelmd);
38047 if(this.labelsm > 0){
38048 label.cls += ' col-sm-' + this.labelsm;
38049 container.cls += ' col-sm-' + (12 - this.labelsm);
38051 if(this.labelxs > 0){
38052 label.cls += ' col-xs-' + this.labelxs;
38053 container.cls += ' col-xs-' + (12 - this.labelxs);
38064 var settings = this;
38066 ['xs','sm','md','lg'].map(function(size){
38067 if (settings[size]) {
38068 cfg.cls += ' col-' + size + '-' + settings[size];
38075 initEvents : function()
38079 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
38081 this.trigger = this.el.select('div.flag-container',true).first();
38082 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
38085 onTriggerClick : function(e)
38087 Roo.log('trigger click');
38089 if(this.disabled || !this.triggerList){
38094 this.loadNext = false;
38096 if(this.isExpanded()){
38099 this.hasFocus = true;
38100 if(this.triggerAction == 'all') {
38101 //Original data flow: doQuery() -> store.load() -> proxy.load() -> store.loadRecords()
38105 if (!this.blockFocus) {
38106 this.inputEl().focus();
38111 isExpanded : function(){
38112 return this.list.isVisible();
38115 collapse : function(){
38116 if(!this.isExpanded()){
38120 this.hasFocus = false;
38121 Roo.get(document).un('mousedown', this.collapseIf, this);
38122 Roo.get(document).un('mousewheel', this.collapseIf, this);
38123 this.fireEvent('collapse', this);