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)
21 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
24 * Do not use directly - it does not do anything..
25 * @param {Object} config The config object
30 Roo.bootstrap.Component = function(config){
31 Roo.bootstrap.Component.superclass.constructor.call(this, config);
35 * @event childrenrendered
36 * Fires when the children have been rendered..
37 * @param {Roo.bootstrap.Component} this
39 "childrenrendered" : true
48 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
51 allowDomMove : false, // to stop relocations in parent onRender...
61 * Initialize Events for the element
63 initEvents : function() { },
69 can_build_overlaid : true,
71 container_method : false,
78 // returns the parent component..
79 return Roo.ComponentMgr.get(this.parentId)
85 onRender : function(ct, position)
87 // Roo.log("Call onRender: " + this.xtype);
89 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
92 if (this.el.attr('xtype')) {
93 this.el.attr('xtypex', this.el.attr('xtype'));
94 this.el.dom.removeAttribute('xtype');
104 var cfg = Roo.apply({}, this.getAutoCreate());
106 cfg.id = this.id || Roo.id();
108 // fill in the extra attributes
109 if (this.xattr && typeof(this.xattr) =='object') {
110 for (var i in this.xattr) {
111 cfg[i] = this.xattr[i];
116 cfg.dataId = this.dataId;
120 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
123 if (this.style) { // fixme needs to support more complex style data.
124 cfg.style = this.style;
128 cfg.name = this.name;
131 this.el = ct.createChild(cfg, position);
134 this.tooltipEl().attr('tooltip', this.tooltip);
137 if(this.tabIndex !== undefined){
138 this.el.dom.setAttribute('tabIndex', this.tabIndex);
145 * Fetch the element to add children to
146 * @return {Roo.Element} defaults to this.el
148 getChildContainer : function()
153 * Fetch the element to display the tooltip on.
154 * @return {Roo.Element} defaults to this.el
156 tooltipEl : function()
161 addxtype : function(tree,cntr)
165 cn = Roo.factory(tree);
166 //Roo.log(['addxtype', cn]);
168 cn.parentType = this.xtype; //??
169 cn.parentId = this.id;
171 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
172 if (typeof(cn.container_method) == 'string') {
173 cntr = cn.container_method;
177 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
179 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
181 var build_from_html = Roo.XComponent.build_from_html;
183 var is_body = (tree.xtype == 'Body') ;
185 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
187 var self_cntr_el = Roo.get(this[cntr](false));
189 // do not try and build conditional elements
190 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
194 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
195 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
196 return this.addxtypeChild(tree,cntr, is_body);
199 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
202 return this.addxtypeChild(Roo.apply({}, tree),cntr);
205 Roo.log('skipping render');
211 if (!build_from_html) {
215 // this i think handles overlaying multiple children of the same type
216 // with the sam eelement.. - which might be buggy..
218 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
224 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
228 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
235 addxtypeChild : function (tree, cntr, is_body)
237 Roo.debug && Roo.log('addxtypeChild:' + cntr);
239 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
242 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
243 (typeof(tree['flexy:foreach']) != 'undefined');
247 skip_children = false;
248 // render the element if it's not BODY.
251 // if parent was disabled, then do not try and create the children..
252 if(!this[cntr](true)){
257 cn = Roo.factory(tree);
259 cn.parentType = this.xtype; //??
260 cn.parentId = this.id;
262 var build_from_html = Roo.XComponent.build_from_html;
265 // does the container contain child eleemnts with 'xtype' attributes.
266 // that match this xtype..
267 // note - when we render we create these as well..
268 // so we should check to see if body has xtype set.
269 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
271 var self_cntr_el = Roo.get(this[cntr](false));
272 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
274 //Roo.log(Roo.XComponent.build_from_html);
275 //Roo.log("got echild:");
278 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
279 // and are not displayed -this causes this to use up the wrong element when matching.
280 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
283 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
284 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
290 //echild.dom.removeAttribute('xtype');
292 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
293 Roo.debug && Roo.log(self_cntr_el);
294 Roo.debug && Roo.log(echild);
295 Roo.debug && Roo.log(cn);
301 // if object has flexy:if - then it may or may not be rendered.
302 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
303 // skip a flexy if element.
304 Roo.debug && Roo.log('skipping render');
305 Roo.debug && Roo.log(tree);
307 Roo.debug && Roo.log('skipping all children');
308 skip_children = true;
313 // actually if flexy:foreach is found, we really want to create
314 // multiple copies here...
316 //Roo.log(this[cntr]());
317 // some elements do not have render methods.. like the layouts...
319 if(this[cntr](true) === false){
324 cn.render && cn.render(this[cntr](true));
327 // then add the element..
334 if (typeof (tree.menu) != 'undefined') {
335 tree.menu.parentType = cn.xtype;
336 tree.menu.triggerEl = cn.el;
337 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
341 if (!tree.items || !tree.items.length) {
343 //Roo.log(["no children", this]);
348 var items = tree.items;
351 //Roo.log(items.length);
353 if (!skip_children) {
354 for(var i =0;i < items.length;i++) {
355 // Roo.log(['add child', items[i]]);
356 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
362 //Roo.log("fire childrenrendered");
364 cn.fireEvent('childrenrendered', this);
369 * Get the element that will be used to show or hide
371 getVisibilityEl : function()
374 if (typeof(this.visibilityEl) == 'object') {
375 return this.visibilityEl;
378 if (typeof(this.visibilityEl) == 'string') {
379 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
388 * Show a component - removes 'hidden' class
392 if(!this.getVisibilityEl()){
396 this.getVisibilityEl().removeClass('hidden');
401 * Hide a component - adds 'hidden' class
405 if(!this.getVisibilityEl()){
409 this.getVisibilityEl().addClass('hidden');
422 * @class Roo.bootstrap.Body
423 * @extends Roo.bootstrap.Component
424 * Bootstrap Body class
428 * @param {Object} config The config object
431 Roo.bootstrap.Body = function(config){
433 config = config || {};
435 Roo.bootstrap.Body.superclass.constructor.call(this, config);
436 this.el = Roo.get(config.el ? config.el : document.body );
437 if (this.cls && this.cls.length) {
438 Roo.get(document.body).addClass(this.cls);
442 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
444 is_body : true,// just to make sure it's constructed?
449 onRender : function(ct, position)
451 /* Roo.log("Roo.bootstrap.Body - onRender");
452 if (this.cls && this.cls.length) {
453 Roo.get(document.body).addClass(this.cls);
472 * @class Roo.bootstrap.ButtonGroup
473 * @extends Roo.bootstrap.Component
474 * Bootstrap ButtonGroup class
475 * @cfg {String} size lg | sm | xs (default empty normal)
476 * @cfg {String} align vertical | justified (default none)
477 * @cfg {String} direction up | down (default down)
478 * @cfg {Boolean} toolbar false | true
479 * @cfg {Boolean} btn true | false
484 * @param {Object} config The config object
487 Roo.bootstrap.ButtonGroup = function(config){
488 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
491 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
499 getAutoCreate : function(){
505 cfg.html = this.html || cfg.html;
516 if (['vertical','justified'].indexOf(this.align)!==-1) {
517 cfg.cls = 'btn-group-' + this.align;
519 if (this.align == 'justified') {
520 console.log(this.items);
524 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
525 cfg.cls += ' btn-group-' + this.size;
528 if (this.direction == 'up') {
529 cfg.cls += ' dropup' ;
545 * @class Roo.bootstrap.Button
546 * @extends Roo.bootstrap.Component
547 * Bootstrap Button class
548 * @cfg {String} html The button content
549 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
550 * @cfg {String} size ( lg | sm | xs)
551 * @cfg {String} tag ( a | input | submit)
552 * @cfg {String} href empty or href
553 * @cfg {Boolean} disabled default false;
554 * @cfg {Boolean} isClose default false;
555 * @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)
556 * @cfg {String} badge text for badge
557 * @cfg {String} theme default
558 * @cfg {Boolean} inverse
559 * @cfg {Boolean} toggle
560 * @cfg {String} ontext text for on toggle state
561 * @cfg {String} offtext text for off toggle state
562 * @cfg {Boolean} defaulton
563 * @cfg {Boolean} preventDefault default true
564 * @cfg {Boolean} removeClass remove the standard class..
565 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
568 * Create a new button
569 * @param {Object} config The config object
573 Roo.bootstrap.Button = function(config){
574 Roo.bootstrap.Button.superclass.constructor.call(this, config);
575 this.weightClass = ["btn-default",
587 * When a butotn is pressed
588 * @param {Roo.bootstrap.Button} this
589 * @param {Roo.EventObject} e
594 * After the button has been toggles
595 * @param {Roo.EventObject} e
596 * @param {boolean} pressed (also available as button.pressed)
602 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
620 preventDefault: true,
629 getAutoCreate : function(){
637 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
638 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
643 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
645 if (this.toggle == true) {
648 cls: 'slider-frame roo-button',
653 'data-off-text':'OFF',
654 cls: 'slider-button',
660 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
661 cfg.cls += ' '+this.weight;
670 cfg["aria-hidden"] = true;
672 cfg.html = "×";
678 if (this.theme==='default') {
679 cfg.cls = 'btn roo-button';
681 //if (this.parentType != 'Navbar') {
682 this.weight = this.weight.length ? this.weight : 'default';
684 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
686 cfg.cls += ' btn-' + this.weight;
688 } else if (this.theme==='glow') {
691 cfg.cls = 'btn-glow roo-button';
693 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
695 cfg.cls += ' ' + this.weight;
701 this.cls += ' inverse';
706 cfg.cls += ' active';
710 cfg.disabled = 'disabled';
714 Roo.log('changing to ul' );
716 this.glyphicon = 'caret';
719 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
721 //gsRoo.log(this.parentType);
722 if (this.parentType === 'Navbar' && !this.parent().bar) {
723 Roo.log('changing to li?');
732 href : this.href || '#'
735 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
736 cfg.cls += ' dropdown';
743 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
745 if (this.glyphicon) {
746 cfg.html = ' ' + cfg.html;
751 cls: 'glyphicon glyphicon-' + this.glyphicon
761 // cfg.cls='btn roo-button';
765 var value = cfg.html;
770 cls: 'glyphicon glyphicon-' + this.glyphicon,
789 cfg.cls += ' dropdown';
790 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
793 if (cfg.tag !== 'a' && this.href !== '') {
794 throw "Tag must be a to set href.";
795 } else if (this.href.length > 0) {
796 cfg.href = this.href;
799 if(this.removeClass){
804 cfg.target = this.target;
809 initEvents: function() {
810 // Roo.log('init events?');
811 // Roo.log(this.el.dom);
814 if (typeof (this.menu) != 'undefined') {
815 this.menu.parentType = this.xtype;
816 this.menu.triggerEl = this.el;
817 this.addxtype(Roo.apply({}, this.menu));
821 if (this.el.hasClass('roo-button')) {
822 this.el.on('click', this.onClick, this);
824 this.el.select('.roo-button').on('click', this.onClick, this);
827 if(this.removeClass){
828 this.el.on('click', this.onClick, this);
831 this.el.enableDisplayMode();
834 onClick : function(e)
841 Roo.log('button on click ');
842 if(this.preventDefault){
845 if (this.pressed === true || this.pressed === false) {
846 this.pressed = !this.pressed;
847 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
848 this.fireEvent('toggle', this, e, this.pressed);
852 this.fireEvent('click', this, e);
856 * Enables this button
860 this.disabled = false;
861 this.el.removeClass('disabled');
865 * Disable this button
869 this.disabled = true;
870 this.el.addClass('disabled');
873 * sets the active state on/off,
874 * @param {Boolean} state (optional) Force a particular state
876 setActive : function(v) {
878 this.el[v ? 'addClass' : 'removeClass']('active');
881 * toggles the current active state
883 toggleActive : function()
885 var active = this.el.hasClass('active');
886 this.setActive(!active);
890 setText : function(str)
892 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
896 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
907 setWeight : function(str)
909 this.el.removeClass(this.weightClass);
910 this.el.addClass('btn-' + str);
924 * @class Roo.bootstrap.Column
925 * @extends Roo.bootstrap.Component
926 * Bootstrap Column class
927 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
928 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
929 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
930 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
931 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
932 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
933 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
934 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
937 * @cfg {Boolean} hidden (true|false) hide the element
938 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
939 * @cfg {String} fa (ban|check|...) font awesome icon
940 * @cfg {Number} fasize (1|2|....) font awsome size
942 * @cfg {String} icon (info-sign|check|...) glyphicon name
944 * @cfg {String} html content of column.
947 * Create a new Column
948 * @param {Object} config The config object
951 Roo.bootstrap.Column = function(config){
952 Roo.bootstrap.Column.superclass.constructor.call(this, config);
955 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
973 getAutoCreate : function(){
974 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
982 ['xs','sm','md','lg'].map(function(size){
983 //Roo.log( size + ':' + settings[size]);
985 if (settings[size+'off'] !== false) {
986 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
989 if (settings[size] === false) {
993 if (!settings[size]) { // 0 = hidden
994 cfg.cls += ' hidden-' + size;
997 cfg.cls += ' col-' + size + '-' + settings[size];
1002 cfg.cls += ' hidden';
1005 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1006 cfg.cls +=' alert alert-' + this.alert;
1010 if (this.html.length) {
1011 cfg.html = this.html;
1015 if (this.fasize > 1) {
1016 fasize = ' fa-' + this.fasize + 'x';
1018 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1023 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1042 * @class Roo.bootstrap.Container
1043 * @extends Roo.bootstrap.Component
1044 * Bootstrap Container class
1045 * @cfg {Boolean} jumbotron is it a jumbotron element
1046 * @cfg {String} html content of element
1047 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1048 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1049 * @cfg {String} header content of header (for panel)
1050 * @cfg {String} footer content of footer (for panel)
1051 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1052 * @cfg {String} tag (header|aside|section) type of HTML tag.
1053 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1054 * @cfg {String} fa font awesome icon
1055 * @cfg {String} icon (info-sign|check|...) glyphicon name
1056 * @cfg {Boolean} hidden (true|false) hide the element
1057 * @cfg {Boolean} expandable (true|false) default false
1058 * @cfg {Boolean} expanded (true|false) default true
1059 * @cfg {String} rheader contet on the right of header
1060 * @cfg {Boolean} clickable (true|false) default false
1064 * Create a new Container
1065 * @param {Object} config The config object
1068 Roo.bootstrap.Container = function(config){
1069 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1075 * After the panel has been expand
1077 * @param {Roo.bootstrap.Container} this
1082 * After the panel has been collapsed
1084 * @param {Roo.bootstrap.Container} this
1089 * When a element is chick
1090 * @param {Roo.bootstrap.Container} this
1091 * @param {Roo.EventObject} e
1097 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1115 getChildContainer : function() {
1121 if (this.panel.length) {
1122 return this.el.select('.panel-body',true).first();
1129 getAutoCreate : function(){
1132 tag : this.tag || 'div',
1136 if (this.jumbotron) {
1137 cfg.cls = 'jumbotron';
1142 // - this is applied by the parent..
1144 // cfg.cls = this.cls + '';
1147 if (this.sticky.length) {
1149 var bd = Roo.get(document.body);
1150 if (!bd.hasClass('bootstrap-sticky')) {
1151 bd.addClass('bootstrap-sticky');
1152 Roo.select('html',true).setStyle('height', '100%');
1155 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1159 if (this.well.length) {
1160 switch (this.well) {
1163 cfg.cls +=' well well-' +this.well;
1172 cfg.cls += ' hidden';
1176 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1177 cfg.cls +=' alert alert-' + this.alert;
1182 if (this.panel.length) {
1183 cfg.cls += ' panel panel-' + this.panel;
1185 if (this.header.length) {
1189 if(this.expandable){
1191 cfg.cls = cfg.cls + ' expandable';
1195 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1203 cls : 'panel-title',
1204 html : (this.expandable ? ' ' : '') + this.header
1208 cls: 'panel-header-right',
1214 cls : 'panel-heading',
1215 style : this.expandable ? 'cursor: pointer' : '',
1223 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1228 if (this.footer.length) {
1230 cls : 'panel-footer',
1239 body.html = this.html || cfg.html;
1240 // prefix with the icons..
1242 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1245 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1250 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1251 cfg.cls = 'container';
1257 initEvents: function()
1259 if(this.expandable){
1260 var headerEl = this.headerEl();
1263 headerEl.on('click', this.onToggleClick, this);
1268 this.el.on('click', this.onClick, this);
1273 onToggleClick : function()
1275 var headerEl = this.headerEl();
1291 if(this.fireEvent('expand', this)) {
1293 this.expanded = true;
1295 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1297 this.el.select('.panel-body',true).first().removeClass('hide');
1299 var toggleEl = this.toggleEl();
1305 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1310 collapse : function()
1312 if(this.fireEvent('collapse', this)) {
1314 this.expanded = false;
1316 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1317 this.el.select('.panel-body',true).first().addClass('hide');
1319 var toggleEl = this.toggleEl();
1325 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1329 toggleEl : function()
1331 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1335 return this.el.select('.panel-heading .fa',true).first();
1338 headerEl : function()
1340 if(!this.el || !this.panel.length || !this.header.length){
1344 return this.el.select('.panel-heading',true).first()
1349 if(!this.el || !this.panel.length){
1353 return this.el.select('.panel-body',true).first()
1356 titleEl : function()
1358 if(!this.el || !this.panel.length || !this.header.length){
1362 return this.el.select('.panel-title',true).first();
1365 setTitle : function(v)
1367 var titleEl = this.titleEl();
1373 titleEl.dom.innerHTML = v;
1376 getTitle : function()
1379 var titleEl = this.titleEl();
1385 return titleEl.dom.innerHTML;
1388 setRightTitle : function(v)
1390 var t = this.el.select('.panel-header-right',true).first();
1396 t.dom.innerHTML = v;
1399 onClick : function(e)
1403 this.fireEvent('click', this, e);
1406 allChildren : function()
1408 var r=new Roo.util.MixedCollection(false, function(o){
1409 return o.id || (o.id = Roo.id());
1411 var iter = function(el) {
1418 Roo.each(el.items,function(e) {
1427 checkEmpty : function()
1429 var items = this.allChildren();
1432 items.each(function(f){
1433 if(f.el.isVisible()) {
1452 * @class Roo.bootstrap.Img
1453 * @extends Roo.bootstrap.Component
1454 * Bootstrap Img class
1455 * @cfg {Boolean} imgResponsive false | true
1456 * @cfg {String} border rounded | circle | thumbnail
1457 * @cfg {String} src image source
1458 * @cfg {String} alt image alternative text
1459 * @cfg {String} href a tag href
1460 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1461 * @cfg {String} xsUrl xs image source
1462 * @cfg {String} smUrl sm image source
1463 * @cfg {String} mdUrl md image source
1464 * @cfg {String} lgUrl lg image source
1467 * Create a new Input
1468 * @param {Object} config The config object
1471 Roo.bootstrap.Img = function(config){
1472 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1478 * The img click event for the img.
1479 * @param {Roo.EventObject} e
1485 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1487 imgResponsive: true,
1497 getAutoCreate : function()
1499 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1500 return this.createSingleImg();
1505 cls: 'roo-image-responsive-group',
1510 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1512 if(!_this[size + 'Url']){
1518 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1519 html: _this.html || cfg.html,
1520 src: _this[size + 'Url']
1523 img.cls += ' roo-image-responsive-' + size;
1525 var s = ['xs', 'sm', 'md', 'lg'];
1527 s.splice(s.indexOf(size), 1);
1529 Roo.each(s, function(ss){
1530 img.cls += ' hidden-' + ss;
1533 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1534 cfg.cls += ' img-' + _this.border;
1538 cfg.alt = _this.alt;
1551 a.target = _this.target;
1555 cfg.cn.push((_this.href) ? a : img);
1562 createSingleImg : function()
1566 cls: (this.imgResponsive) ? 'img-responsive' : '',
1568 src : 'about:blank' // just incase src get's set to undefined?!?
1571 cfg.html = this.html || cfg.html;
1573 cfg.src = this.src || cfg.src;
1575 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1576 cfg.cls += ' img-' + this.border;
1593 a.target = this.target;
1598 return (this.href) ? a : cfg;
1601 initEvents: function()
1604 this.el.on('click', this.onClick, this);
1609 onClick : function(e)
1611 Roo.log('img onclick');
1612 this.fireEvent('click', this, e);
1615 * Sets the url of the image - used to update it
1616 * @param {String} url the url of the image
1619 setSrc : function(url)
1623 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1624 this.el.dom.src = url;
1628 this.el.select('img', true).first().dom.src = url;
1644 * @class Roo.bootstrap.Link
1645 * @extends Roo.bootstrap.Component
1646 * Bootstrap Link Class
1647 * @cfg {String} alt image alternative text
1648 * @cfg {String} href a tag href
1649 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1650 * @cfg {String} html the content of the link.
1651 * @cfg {String} anchor name for the anchor link
1652 * @cfg {String} fa - favicon
1654 * @cfg {Boolean} preventDefault (true | false) default false
1658 * Create a new Input
1659 * @param {Object} config The config object
1662 Roo.bootstrap.Link = function(config){
1663 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1669 * The img click event for the img.
1670 * @param {Roo.EventObject} e
1676 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1680 preventDefault: false,
1686 getAutoCreate : function()
1688 var html = this.html || '';
1690 if (this.fa !== false) {
1691 html = '<i class="fa fa-' + this.fa + '"></i>';
1696 // anchor's do not require html/href...
1697 if (this.anchor === false) {
1699 cfg.href = this.href || '#';
1701 cfg.name = this.anchor;
1702 if (this.html !== false || this.fa !== false) {
1705 if (this.href !== false) {
1706 cfg.href = this.href;
1710 if(this.alt !== false){
1715 if(this.target !== false) {
1716 cfg.target = this.target;
1722 initEvents: function() {
1724 if(!this.href || this.preventDefault){
1725 this.el.on('click', this.onClick, this);
1729 onClick : function(e)
1731 if(this.preventDefault){
1734 //Roo.log('img onclick');
1735 this.fireEvent('click', this, e);
1748 * @class Roo.bootstrap.Header
1749 * @extends Roo.bootstrap.Component
1750 * Bootstrap Header class
1751 * @cfg {String} html content of header
1752 * @cfg {Number} level (1|2|3|4|5|6) default 1
1755 * Create a new Header
1756 * @param {Object} config The config object
1760 Roo.bootstrap.Header = function(config){
1761 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1764 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1772 getAutoCreate : function(){
1777 tag: 'h' + (1 *this.level),
1778 html: this.html || ''
1790 * Ext JS Library 1.1.1
1791 * Copyright(c) 2006-2007, Ext JS, LLC.
1793 * Originally Released Under LGPL - original licence link has changed is not relivant.
1796 * <script type="text/javascript">
1800 * @class Roo.bootstrap.MenuMgr
1801 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1804 Roo.bootstrap.MenuMgr = function(){
1805 var menus, active, groups = {}, attached = false, lastShow = new Date();
1807 // private - called when first menu is created
1810 active = new Roo.util.MixedCollection();
1811 Roo.get(document).addKeyListener(27, function(){
1812 if(active.length > 0){
1820 if(active && active.length > 0){
1821 var c = active.clone();
1831 if(active.length < 1){
1832 Roo.get(document).un("mouseup", onMouseDown);
1840 var last = active.last();
1841 lastShow = new Date();
1844 Roo.get(document).on("mouseup", onMouseDown);
1849 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1850 m.parentMenu.activeChild = m;
1851 }else if(last && last.isVisible()){
1852 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1857 function onBeforeHide(m){
1859 m.activeChild.hide();
1861 if(m.autoHideTimer){
1862 clearTimeout(m.autoHideTimer);
1863 delete m.autoHideTimer;
1868 function onBeforeShow(m){
1869 var pm = m.parentMenu;
1870 if(!pm && !m.allowOtherMenus){
1872 }else if(pm && pm.activeChild && active != m){
1873 pm.activeChild.hide();
1877 // private this should really trigger on mouseup..
1878 function onMouseDown(e){
1879 Roo.log("on Mouse Up");
1881 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1882 Roo.log("MenuManager hideAll");
1891 function onBeforeCheck(mi, state){
1893 var g = groups[mi.group];
1894 for(var i = 0, l = g.length; i < l; i++){
1896 g[i].setChecked(false);
1905 * Hides all menus that are currently visible
1907 hideAll : function(){
1912 register : function(menu){
1916 menus[menu.id] = menu;
1917 menu.on("beforehide", onBeforeHide);
1918 menu.on("hide", onHide);
1919 menu.on("beforeshow", onBeforeShow);
1920 menu.on("show", onShow);
1922 if(g && menu.events["checkchange"]){
1926 groups[g].push(menu);
1927 menu.on("checkchange", onCheck);
1932 * Returns a {@link Roo.menu.Menu} object
1933 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1934 * be used to generate and return a new Menu instance.
1936 get : function(menu){
1937 if(typeof menu == "string"){ // menu id
1939 }else if(menu.events){ // menu instance
1942 /*else if(typeof menu.length == 'number'){ // array of menu items?
1943 return new Roo.bootstrap.Menu({items:menu});
1944 }else{ // otherwise, must be a config
1945 return new Roo.bootstrap.Menu(menu);
1952 unregister : function(menu){
1953 delete menus[menu.id];
1954 menu.un("beforehide", onBeforeHide);
1955 menu.un("hide", onHide);
1956 menu.un("beforeshow", onBeforeShow);
1957 menu.un("show", onShow);
1959 if(g && menu.events["checkchange"]){
1960 groups[g].remove(menu);
1961 menu.un("checkchange", onCheck);
1966 registerCheckable : function(menuItem){
1967 var g = menuItem.group;
1972 groups[g].push(menuItem);
1973 menuItem.on("beforecheckchange", onBeforeCheck);
1978 unregisterCheckable : function(menuItem){
1979 var g = menuItem.group;
1981 groups[g].remove(menuItem);
1982 menuItem.un("beforecheckchange", onBeforeCheck);
1994 * @class Roo.bootstrap.Menu
1995 * @extends Roo.bootstrap.Component
1996 * Bootstrap Menu class - container for MenuItems
1997 * @cfg {String} type (dropdown|treeview|submenu) type of menu
1998 * @cfg {bool} hidden if the menu should be hidden when rendered.
1999 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2000 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2004 * @param {Object} config The config object
2008 Roo.bootstrap.Menu = function(config){
2009 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2010 if (this.registerMenu && this.type != 'treeview') {
2011 Roo.bootstrap.MenuMgr.register(this);
2016 * Fires before this menu is displayed
2017 * @param {Roo.menu.Menu} this
2022 * Fires before this menu is hidden
2023 * @param {Roo.menu.Menu} this
2028 * Fires after this menu is displayed
2029 * @param {Roo.menu.Menu} this
2034 * Fires after this menu is hidden
2035 * @param {Roo.menu.Menu} this
2040 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2041 * @param {Roo.menu.Menu} this
2042 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2043 * @param {Roo.EventObject} e
2048 * Fires when the mouse is hovering over this menu
2049 * @param {Roo.menu.Menu} this
2050 * @param {Roo.EventObject} e
2051 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2056 * Fires when the mouse exits this menu
2057 * @param {Roo.menu.Menu} this
2058 * @param {Roo.EventObject} e
2059 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2064 * Fires when a menu item contained in this menu is clicked
2065 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2066 * @param {Roo.EventObject} e
2070 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2073 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2077 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2080 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2082 registerMenu : true,
2084 menuItems :false, // stores the menu items..
2094 getChildContainer : function() {
2098 getAutoCreate : function(){
2100 //if (['right'].indexOf(this.align)!==-1) {
2101 // cfg.cn[1].cls += ' pull-right'
2107 cls : 'dropdown-menu' ,
2108 style : 'z-index:1000'
2112 if (this.type === 'submenu') {
2113 cfg.cls = 'submenu active';
2115 if (this.type === 'treeview') {
2116 cfg.cls = 'treeview-menu';
2121 initEvents : function() {
2123 // Roo.log("ADD event");
2124 // Roo.log(this.triggerEl.dom);
2126 this.triggerEl.on('click', this.onTriggerClick, this);
2128 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2130 this.triggerEl.addClass('dropdown-toggle');
2133 this.el.on('touchstart' , this.onTouch, this);
2135 this.el.on('click' , this.onClick, this);
2137 this.el.on("mouseover", this.onMouseOver, this);
2138 this.el.on("mouseout", this.onMouseOut, this);
2142 findTargetItem : function(e)
2144 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2148 //Roo.log(t); Roo.log(t.id);
2150 //Roo.log(this.menuitems);
2151 return this.menuitems.get(t.id);
2153 //return this.items.get(t.menuItemId);
2159 onTouch : function(e)
2161 Roo.log("menu.onTouch");
2162 //e.stopEvent(); this make the user popdown broken
2166 onClick : function(e)
2168 Roo.log("menu.onClick");
2170 var t = this.findTargetItem(e);
2171 if(!t || t.isContainer){
2176 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2177 if(t == this.activeItem && t.shouldDeactivate(e)){
2178 this.activeItem.deactivate();
2179 delete this.activeItem;
2183 this.setActiveItem(t, true);
2191 Roo.log('pass click event');
2195 this.fireEvent("click", this, t, e);
2199 if(!t.href.length || t.href == '#'){
2200 (function() { _this.hide(); }).defer(100);
2205 onMouseOver : function(e){
2206 var t = this.findTargetItem(e);
2209 // if(t.canActivate && !t.disabled){
2210 // this.setActiveItem(t, true);
2214 this.fireEvent("mouseover", this, e, t);
2216 isVisible : function(){
2217 return !this.hidden;
2219 onMouseOut : function(e){
2220 var t = this.findTargetItem(e);
2223 // if(t == this.activeItem && t.shouldDeactivate(e)){
2224 // this.activeItem.deactivate();
2225 // delete this.activeItem;
2228 this.fireEvent("mouseout", this, e, t);
2233 * Displays this menu relative to another element
2234 * @param {String/HTMLElement/Roo.Element} element The element to align to
2235 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2236 * the element (defaults to this.defaultAlign)
2237 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2239 show : function(el, pos, parentMenu){
2240 this.parentMenu = parentMenu;
2244 this.fireEvent("beforeshow", this);
2245 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2248 * Displays this menu at a specific xy position
2249 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2250 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2252 showAt : function(xy, parentMenu, /* private: */_e){
2253 this.parentMenu = parentMenu;
2258 this.fireEvent("beforeshow", this);
2259 //xy = this.el.adjustForConstraints(xy);
2263 this.hideMenuItems();
2264 this.hidden = false;
2265 this.triggerEl.addClass('open');
2267 if(this.el.getWidth() + xy[0] > Roo.lib.Dom.getViewWidth()){
2268 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2271 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2276 this.fireEvent("show", this);
2282 this.doFocus.defer(50, this);
2286 doFocus : function(){
2288 this.focusEl.focus();
2293 * Hides this menu and optionally all parent menus
2294 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2296 hide : function(deep)
2299 this.hideMenuItems();
2300 if(this.el && this.isVisible()){
2301 this.fireEvent("beforehide", this);
2302 if(this.activeItem){
2303 this.activeItem.deactivate();
2304 this.activeItem = null;
2306 this.triggerEl.removeClass('open');;
2308 this.fireEvent("hide", this);
2310 if(deep === true && this.parentMenu){
2311 this.parentMenu.hide(true);
2315 onTriggerClick : function(e)
2317 Roo.log('trigger click');
2319 var target = e.getTarget();
2321 Roo.log(target.nodeName.toLowerCase());
2323 if(target.nodeName.toLowerCase() === 'i'){
2329 onTriggerPress : function(e)
2331 Roo.log('trigger press');
2332 //Roo.log(e.getTarget());
2333 // Roo.log(this.triggerEl.dom);
2335 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2336 var pel = Roo.get(e.getTarget());
2337 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2338 Roo.log('is treeview or dropdown?');
2342 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2346 if (this.isVisible()) {
2351 this.show(this.triggerEl, false, false);
2354 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2361 hideMenuItems : function()
2363 Roo.log("hide Menu Items");
2367 //$(backdrop).remove()
2368 this.el.select('.open',true).each(function(aa) {
2370 aa.removeClass('open');
2371 //var parent = getParent($(this))
2372 //var relatedTarget = { relatedTarget: this }
2374 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2375 //if (e.isDefaultPrevented()) return
2376 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2379 addxtypeChild : function (tree, cntr) {
2380 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2382 this.menuitems.add(comp);
2394 this.getEl().dom.innerHTML = '';
2395 this.menuitems.clear();
2409 * @class Roo.bootstrap.MenuItem
2410 * @extends Roo.bootstrap.Component
2411 * Bootstrap MenuItem class
2412 * @cfg {String} html the menu label
2413 * @cfg {String} href the link
2414 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2415 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2416 * @cfg {Boolean} active used on sidebars to highlight active itesm
2417 * @cfg {String} fa favicon to show on left of menu item.
2418 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2422 * Create a new MenuItem
2423 * @param {Object} config The config object
2427 Roo.bootstrap.MenuItem = function(config){
2428 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2433 * The raw click event for the entire grid.
2434 * @param {Roo.bootstrap.MenuItem} this
2435 * @param {Roo.EventObject} e
2441 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2445 preventDefault: false,
2446 isContainer : false,
2450 getAutoCreate : function(){
2452 if(this.isContainer){
2455 cls: 'dropdown-menu-item'
2469 if (this.fa !== false) {
2472 cls : 'fa fa-' + this.fa
2481 cls: 'dropdown-menu-item',
2484 if (this.parent().type == 'treeview') {
2485 cfg.cls = 'treeview-menu';
2488 cfg.cls += ' active';
2493 anc.href = this.href || cfg.cn[0].href ;
2494 ctag.html = this.html || cfg.cn[0].html ;
2498 initEvents: function()
2500 if (this.parent().type == 'treeview') {
2501 this.el.select('a').on('click', this.onClick, this);
2505 this.menu.parentType = this.xtype;
2506 this.menu.triggerEl = this.el;
2507 this.menu = this.addxtype(Roo.apply({}, this.menu));
2511 onClick : function(e)
2513 Roo.log('item on click ');
2515 if(this.preventDefault){
2518 //this.parent().hideMenuItems();
2520 this.fireEvent('click', this, e);
2539 * @class Roo.bootstrap.MenuSeparator
2540 * @extends Roo.bootstrap.Component
2541 * Bootstrap MenuSeparator class
2544 * Create a new MenuItem
2545 * @param {Object} config The config object
2549 Roo.bootstrap.MenuSeparator = function(config){
2550 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2553 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2555 getAutoCreate : function(){
2574 * @class Roo.bootstrap.Modal
2575 * @extends Roo.bootstrap.Component
2576 * Bootstrap Modal class
2577 * @cfg {String} title Title of dialog
2578 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2579 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2580 * @cfg {Boolean} specificTitle default false
2581 * @cfg {Array} buttons Array of buttons or standard button set..
2582 * @cfg {String} buttonPosition (left|right|center) default right
2583 * @cfg {Boolean} animate default true
2584 * @cfg {Boolean} allow_close default true
2585 * @cfg {Boolean} fitwindow default false
2586 * @cfg {String} size (sm|lg) default empty
2590 * Create a new Modal Dialog
2591 * @param {Object} config The config object
2594 Roo.bootstrap.Modal = function(config){
2595 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2600 * The raw btnclick event for the button
2601 * @param {Roo.EventObject} e
2606 * Fire when dialog resize
2607 * @param {Roo.bootstrap.Modal} this
2608 * @param {Roo.EventObject} e
2612 this.buttons = this.buttons || [];
2615 this.tmpl = Roo.factory(this.tmpl);
2620 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2622 title : 'test dialog',
2632 specificTitle: false,
2634 buttonPosition: 'right',
2653 onRender : function(ct, position)
2655 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2658 var cfg = Roo.apply({}, this.getAutoCreate());
2661 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2663 //if (!cfg.name.length) {
2667 cfg.cls += ' ' + this.cls;
2670 cfg.style = this.style;
2672 this.el = Roo.get(document.body).createChild(cfg, position);
2674 //var type = this.el.dom.type;
2677 if(this.tabIndex !== undefined){
2678 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2681 this.dialogEl = this.el.select('.modal-dialog',true).first();
2682 this.bodyEl = this.el.select('.modal-body',true).first();
2683 this.closeEl = this.el.select('.modal-header .close', true).first();
2684 this.headerEl = this.el.select('.modal-header',true).first();
2685 this.titleEl = this.el.select('.modal-title',true).first();
2686 this.footerEl = this.el.select('.modal-footer',true).first();
2688 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2689 this.maskEl.enableDisplayMode("block");
2691 //this.el.addClass("x-dlg-modal");
2693 if (this.buttons.length) {
2694 Roo.each(this.buttons, function(bb) {
2695 var b = Roo.apply({}, bb);
2696 b.xns = b.xns || Roo.bootstrap;
2697 b.xtype = b.xtype || 'Button';
2698 if (typeof(b.listeners) == 'undefined') {
2699 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2702 var btn = Roo.factory(b);
2704 btn.render(this.el.select('.modal-footer div').first());
2708 // render the children.
2711 if(typeof(this.items) != 'undefined'){
2712 var items = this.items;
2715 for(var i =0;i < items.length;i++) {
2716 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2720 this.items = nitems;
2722 // where are these used - they used to be body/close/footer
2726 //this.el.addClass([this.fieldClass, this.cls]);
2730 getAutoCreate : function(){
2735 html : this.html || ''
2740 cls : 'modal-title',
2744 if(this.specificTitle){
2750 if (this.allow_close) {
2762 if(this.size.length){
2763 size = 'modal-' + this.size;
2768 style : 'display: none',
2771 cls: "modal-dialog " + size,
2774 cls : "modal-content",
2777 cls : 'modal-header',
2782 cls : 'modal-footer',
2786 cls: 'btn-' + this.buttonPosition
2803 modal.cls += ' fade';
2809 getChildContainer : function() {
2814 getButtonContainer : function() {
2815 return this.el.select('.modal-footer div',true).first();
2818 initEvents : function()
2820 if (this.allow_close) {
2821 this.closeEl.on('click', this.hide, this);
2823 Roo.EventManager.onWindowResize(this.resize, this, true);
2830 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2831 if (this.fitwindow) {
2832 var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
2833 var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
2838 setSize : function(w,h)
2848 if (!this.rendered) {
2852 this.el.setStyle('display', 'block');
2854 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2857 this.el.addClass('in');
2860 this.el.addClass('in');
2864 // not sure how we can show data in here..
2866 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2869 Roo.get(document.body).addClass("x-body-masked");
2871 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2872 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2877 this.fireEvent('show', this);
2879 // set zindex here - otherwise it appears to be ignored...
2880 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2883 this.items.forEach( function(e) {
2884 e.layout ? e.layout() : false;
2892 if(this.fireEvent("beforehide", this) !== false){
2894 Roo.get(document.body).removeClass("x-body-masked");
2895 this.el.removeClass('in');
2896 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2898 if(this.animate){ // why
2900 (function(){ _this.el.setStyle('display', 'none'); }).defer(150);
2902 this.el.setStyle('display', 'none');
2904 this.fireEvent('hide', this);
2908 addButton : function(str, cb)
2912 var b = Roo.apply({}, { html : str } );
2913 b.xns = b.xns || Roo.bootstrap;
2914 b.xtype = b.xtype || 'Button';
2915 if (typeof(b.listeners) == 'undefined') {
2916 b.listeners = { click : cb.createDelegate(this) };
2919 var btn = Roo.factory(b);
2921 btn.render(this.el.select('.modal-footer div').first());
2927 setDefaultButton : function(btn)
2929 //this.el.select('.modal-footer').()
2933 resizeTo: function(w,h)
2937 this.dialogEl.setWidth(w);
2938 if (this.diff === false) {
2939 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
2942 this.bodyEl.setHeight(h-this.diff);
2944 this.fireEvent('resize', this);
2947 setContentSize : function(w, h)
2951 onButtonClick: function(btn,e)
2954 this.fireEvent('btnclick', btn.name, e);
2957 * Set the title of the Dialog
2958 * @param {String} str new Title
2960 setTitle: function(str) {
2961 this.titleEl.dom.innerHTML = str;
2964 * Set the body of the Dialog
2965 * @param {String} str new Title
2967 setBody: function(str) {
2968 this.bodyEl.dom.innerHTML = str;
2971 * Set the body of the Dialog using the template
2972 * @param {Obj} data - apply this data to the template and replace the body contents.
2974 applyBody: function(obj)
2977 Roo.log("Error - using apply Body without a template");
2980 this.tmpl.overwrite(this.bodyEl, obj);
2986 Roo.apply(Roo.bootstrap.Modal, {
2988 * Button config that displays a single OK button
2997 * Button config that displays Yes and No buttons
3013 * Button config that displays OK and Cancel buttons
3028 * Button config that displays Yes, No and Cancel buttons
3052 * messagebox - can be used as a replace
3056 * @class Roo.MessageBox
3057 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3061 Roo.Msg.alert('Status', 'Changes saved successfully.');
3063 // Prompt for user data:
3064 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3066 // process text value...
3070 // Show a dialog using config options:
3072 title:'Save Changes?',
3073 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3074 buttons: Roo.Msg.YESNOCANCEL,
3081 Roo.bootstrap.MessageBox = function(){
3082 var dlg, opt, mask, waitTimer;
3083 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3084 var buttons, activeTextEl, bwidth;
3088 var handleButton = function(button){
3090 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3094 var handleHide = function(){
3096 dlg.el.removeClass(opt.cls);
3099 // Roo.TaskMgr.stop(waitTimer);
3100 // waitTimer = null;
3105 var updateButtons = function(b){
3108 buttons["ok"].hide();
3109 buttons["cancel"].hide();
3110 buttons["yes"].hide();
3111 buttons["no"].hide();
3112 //dlg.footer.dom.style.display = 'none';
3115 dlg.footerEl.dom.style.display = '';
3116 for(var k in buttons){
3117 if(typeof buttons[k] != "function"){
3120 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3121 width += buttons[k].el.getWidth()+15;
3131 var handleEsc = function(d, k, e){
3132 if(opt && opt.closable !== false){
3142 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3143 * @return {Roo.BasicDialog} The BasicDialog element
3145 getDialog : function(){
3147 dlg = new Roo.bootstrap.Modal( {
3150 //constraintoviewport:false,
3152 //collapsible : false,
3157 //buttonAlign:"center",
3158 closeClick : function(){
3159 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3162 handleButton("cancel");
3167 dlg.on("hide", handleHide);
3169 //dlg.addKeyListener(27, handleEsc);
3171 this.buttons = buttons;
3172 var bt = this.buttonText;
3173 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3174 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3175 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3176 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3178 bodyEl = dlg.bodyEl.createChild({
3180 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3181 '<textarea class="roo-mb-textarea"></textarea>' +
3182 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3184 msgEl = bodyEl.dom.firstChild;
3185 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3186 textboxEl.enableDisplayMode();
3187 textboxEl.addKeyListener([10,13], function(){
3188 if(dlg.isVisible() && opt && opt.buttons){
3191 }else if(opt.buttons.yes){
3192 handleButton("yes");
3196 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3197 textareaEl.enableDisplayMode();
3198 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3199 progressEl.enableDisplayMode();
3201 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3202 var pf = progressEl.dom.firstChild;
3204 pp = Roo.get(pf.firstChild);
3205 pp.setHeight(pf.offsetHeight);
3213 * Updates the message box body text
3214 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3215 * the XHTML-compliant non-breaking space character '&#160;')
3216 * @return {Roo.MessageBox} This message box
3218 updateText : function(text)
3220 if(!dlg.isVisible() && !opt.width){
3221 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3222 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3224 msgEl.innerHTML = text || ' ';
3226 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3227 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3229 Math.min(opt.width || cw , this.maxWidth),
3230 Math.max(opt.minWidth || this.minWidth, bwidth)
3233 activeTextEl.setWidth(w);
3235 if(dlg.isVisible()){
3236 dlg.fixedcenter = false;
3238 // to big, make it scroll. = But as usual stupid IE does not support
3241 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3242 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3243 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3245 bodyEl.dom.style.height = '';
3246 bodyEl.dom.style.overflowY = '';
3249 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3251 bodyEl.dom.style.overflowX = '';
3254 dlg.setContentSize(w, bodyEl.getHeight());
3255 if(dlg.isVisible()){
3256 dlg.fixedcenter = true;
3262 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3263 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3264 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3265 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3266 * @return {Roo.MessageBox} This message box
3268 updateProgress : function(value, text){
3270 this.updateText(text);
3273 if (pp) { // weird bug on my firefox - for some reason this is not defined
3274 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3275 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3281 * Returns true if the message box is currently displayed
3282 * @return {Boolean} True if the message box is visible, else false
3284 isVisible : function(){
3285 return dlg && dlg.isVisible();
3289 * Hides the message box if it is displayed
3292 if(this.isVisible()){
3298 * Displays a new message box, or reinitializes an existing message box, based on the config options
3299 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3300 * The following config object properties are supported:
3302 Property Type Description
3303 ---------- --------------- ------------------------------------------------------------------------------------
3304 animEl String/Element An id or Element from which the message box should animate as it opens and
3305 closes (defaults to undefined)
3306 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3307 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3308 closable Boolean False to hide the top-right close button (defaults to true). Note that
3309 progress and wait dialogs will ignore this property and always hide the
3310 close button as they can only be closed programmatically.
3311 cls String A custom CSS class to apply to the message box element
3312 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3313 displayed (defaults to 75)
3314 fn Function A callback function to execute after closing the dialog. The arguments to the
3315 function will be btn (the name of the button that was clicked, if applicable,
3316 e.g. "ok"), and text (the value of the active text field, if applicable).
3317 Progress and wait dialogs will ignore this option since they do not respond to
3318 user actions and can only be closed programmatically, so any required function
3319 should be called by the same code after it closes the dialog.
3320 icon String A CSS class that provides a background image to be used as an icon for
3321 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3322 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3323 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3324 modal Boolean False to allow user interaction with the page while the message box is
3325 displayed (defaults to true)
3326 msg String A string that will replace the existing message box body text (defaults
3327 to the XHTML-compliant non-breaking space character ' ')
3328 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3329 progress Boolean True to display a progress bar (defaults to false)
3330 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3331 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3332 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3333 title String The title text
3334 value String The string value to set into the active textbox element if displayed
3335 wait Boolean True to display a progress bar (defaults to false)
3336 width Number The width of the dialog in pixels
3343 msg: 'Please enter your address:',
3345 buttons: Roo.MessageBox.OKCANCEL,
3348 animEl: 'addAddressBtn'
3351 * @param {Object} config Configuration options
3352 * @return {Roo.MessageBox} This message box
3354 show : function(options)
3357 // this causes nightmares if you show one dialog after another
3358 // especially on callbacks..
3360 if(this.isVisible()){
3363 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3364 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3365 Roo.log("New Dialog Message:" + options.msg )
3366 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3367 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3370 var d = this.getDialog();
3372 d.setTitle(opt.title || " ");
3373 d.closeEl.setDisplayed(opt.closable !== false);
3374 activeTextEl = textboxEl;
3375 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3380 textareaEl.setHeight(typeof opt.multiline == "number" ?
3381 opt.multiline : this.defaultTextHeight);
3382 activeTextEl = textareaEl;
3391 progressEl.setDisplayed(opt.progress === true);
3392 this.updateProgress(0);
3393 activeTextEl.dom.value = opt.value || "";
3395 dlg.setDefaultButton(activeTextEl);
3397 var bs = opt.buttons;
3401 }else if(bs && bs.yes){
3402 db = buttons["yes"];
3404 dlg.setDefaultButton(db);
3406 bwidth = updateButtons(opt.buttons);
3407 this.updateText(opt.msg);
3409 d.el.addClass(opt.cls);
3411 d.proxyDrag = opt.proxyDrag === true;
3412 d.modal = opt.modal !== false;
3413 d.mask = opt.modal !== false ? mask : false;
3415 // force it to the end of the z-index stack so it gets a cursor in FF
3416 document.body.appendChild(dlg.el.dom);
3417 d.animateTarget = null;
3418 d.show(options.animEl);
3424 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3425 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3426 * and closing the message box when the process is complete.
3427 * @param {String} title The title bar text
3428 * @param {String} msg The message box body text
3429 * @return {Roo.MessageBox} This message box
3431 progress : function(title, msg){
3438 minWidth: this.minProgressWidth,
3445 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3446 * If a callback function is passed it will be called after the user clicks the button, and the
3447 * id of the button that was clicked will be passed as the only parameter to the callback
3448 * (could also be the top-right close button).
3449 * @param {String} title The title bar text
3450 * @param {String} msg The message box body text
3451 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3452 * @param {Object} scope (optional) The scope of the callback function
3453 * @return {Roo.MessageBox} This message box
3455 alert : function(title, msg, fn, scope)
3470 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3471 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3472 * You are responsible for closing the message box when the process is complete.
3473 * @param {String} msg The message box body text
3474 * @param {String} title (optional) The title bar text
3475 * @return {Roo.MessageBox} This message box
3477 wait : function(msg, title){
3488 waitTimer = Roo.TaskMgr.start({
3490 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3498 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3499 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3500 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3501 * @param {String} title The title bar text
3502 * @param {String} msg The message box body text
3503 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3504 * @param {Object} scope (optional) The scope of the callback function
3505 * @return {Roo.MessageBox} This message box
3507 confirm : function(title, msg, fn, scope){
3511 buttons: this.YESNO,
3520 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3521 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3522 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3523 * (could also be the top-right close button) and the text that was entered will be passed as the two
3524 * parameters to the callback.
3525 * @param {String} title The title bar text
3526 * @param {String} msg The message box body text
3527 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3528 * @param {Object} scope (optional) The scope of the callback function
3529 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3530 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3531 * @return {Roo.MessageBox} This message box
3533 prompt : function(title, msg, fn, scope, multiline){
3537 buttons: this.OKCANCEL,
3542 multiline: multiline,
3549 * Button config that displays a single OK button
3554 * Button config that displays Yes and No buttons
3557 YESNO : {yes:true, no:true},
3559 * Button config that displays OK and Cancel buttons
3562 OKCANCEL : {ok:true, cancel:true},
3564 * Button config that displays Yes, No and Cancel buttons
3567 YESNOCANCEL : {yes:true, no:true, cancel:true},
3570 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3573 defaultTextHeight : 75,
3575 * The maximum width in pixels of the message box (defaults to 600)
3580 * The minimum width in pixels of the message box (defaults to 100)
3585 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3586 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3589 minProgressWidth : 250,
3591 * An object containing the default button text strings that can be overriden for localized language support.
3592 * Supported properties are: ok, cancel, yes and no.
3593 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3606 * Shorthand for {@link Roo.MessageBox}
3608 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3609 Roo.Msg = Roo.Msg || Roo.MessageBox;
3618 * @class Roo.bootstrap.Navbar
3619 * @extends Roo.bootstrap.Component
3620 * Bootstrap Navbar class
3623 * Create a new Navbar
3624 * @param {Object} config The config object
3628 Roo.bootstrap.Navbar = function(config){
3629 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3633 * @event beforetoggle
3634 * Fire before toggle the menu
3635 * @param {Roo.EventObject} e
3637 "beforetoggle" : true
3641 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3650 getAutoCreate : function(){
3653 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3657 initEvents :function ()
3659 //Roo.log(this.el.select('.navbar-toggle',true));
3660 this.el.select('.navbar-toggle',true).on('click', function() {
3661 if(this.fireEvent('beforetoggle', this) !== false){
3662 this.el.select('.navbar-collapse',true).toggleClass('in');
3672 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3674 var size = this.el.getSize();
3675 this.maskEl.setSize(size.width, size.height);
3676 this.maskEl.enableDisplayMode("block");
3685 getChildContainer : function()
3687 if (this.el.select('.collapse').getCount()) {
3688 return this.el.select('.collapse',true).first();
3721 * @class Roo.bootstrap.NavSimplebar
3722 * @extends Roo.bootstrap.Navbar
3723 * Bootstrap Sidebar class
3725 * @cfg {Boolean} inverse is inverted color
3727 * @cfg {String} type (nav | pills | tabs)
3728 * @cfg {Boolean} arrangement stacked | justified
3729 * @cfg {String} align (left | right) alignment
3731 * @cfg {Boolean} main (true|false) main nav bar? default false
3732 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3734 * @cfg {String} tag (header|footer|nav|div) default is nav
3740 * Create a new Sidebar
3741 * @param {Object} config The config object
3745 Roo.bootstrap.NavSimplebar = function(config){
3746 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3749 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3765 getAutoCreate : function(){
3769 tag : this.tag || 'div',
3782 this.type = this.type || 'nav';
3783 if (['tabs','pills'].indexOf(this.type)!==-1) {
3784 cfg.cn[0].cls += ' nav-' + this.type
3788 if (this.type!=='nav') {
3789 Roo.log('nav type must be nav/tabs/pills')
3791 cfg.cn[0].cls += ' navbar-nav'
3797 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3798 cfg.cn[0].cls += ' nav-' + this.arrangement;
3802 if (this.align === 'right') {
3803 cfg.cn[0].cls += ' navbar-right';
3807 cfg.cls += ' navbar-inverse';
3834 * @class Roo.bootstrap.NavHeaderbar
3835 * @extends Roo.bootstrap.NavSimplebar
3836 * Bootstrap Sidebar class
3838 * @cfg {String} brand what is brand
3839 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
3840 * @cfg {String} brand_href href of the brand
3841 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
3842 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
3843 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
3844 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
3847 * Create a new Sidebar
3848 * @param {Object} config The config object
3852 Roo.bootstrap.NavHeaderbar = function(config){
3853 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
3857 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
3864 desktopCenter : false,
3867 getAutoCreate : function(){
3870 tag: this.nav || 'nav',
3877 if (this.desktopCenter) {
3878 cn.push({cls : 'container', cn : []});
3885 cls: 'navbar-header',
3890 cls: 'navbar-toggle',
3891 'data-toggle': 'collapse',
3896 html: 'Toggle navigation'
3918 cls: 'collapse navbar-collapse',
3922 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
3924 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
3925 cfg.cls += ' navbar-' + this.position;
3927 // tag can override this..
3929 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
3932 if (this.brand !== '') {
3935 href: this.brand_href ? this.brand_href : '#',
3936 cls: 'navbar-brand',
3944 cfg.cls += ' main-nav';
3952 getHeaderChildContainer : function()
3954 if (this.srButton && this.el.select('.navbar-header').getCount()) {
3955 return this.el.select('.navbar-header',true).first();
3958 return this.getChildContainer();
3962 initEvents : function()
3964 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
3966 if (this.autohide) {
3971 Roo.get(document).on('scroll',function(e) {
3972 var ns = Roo.get(document).getScroll().top;
3973 var os = prevScroll;
3977 ft.removeClass('slideDown');
3978 ft.addClass('slideUp');
3981 ft.removeClass('slideUp');
3982 ft.addClass('slideDown');
4003 * @class Roo.bootstrap.NavSidebar
4004 * @extends Roo.bootstrap.Navbar
4005 * Bootstrap Sidebar class
4008 * Create a new Sidebar
4009 * @param {Object} config The config object
4013 Roo.bootstrap.NavSidebar = function(config){
4014 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4017 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4019 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4021 getAutoCreate : function(){
4026 cls: 'sidebar sidebar-nav'
4048 * @class Roo.bootstrap.NavGroup
4049 * @extends Roo.bootstrap.Component
4050 * Bootstrap NavGroup class
4051 * @cfg {String} align (left|right)
4052 * @cfg {Boolean} inverse
4053 * @cfg {String} type (nav|pills|tab) default nav
4054 * @cfg {String} navId - reference Id for navbar.
4058 * Create a new nav group
4059 * @param {Object} config The config object
4062 Roo.bootstrap.NavGroup = function(config){
4063 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4066 Roo.bootstrap.NavGroup.register(this);
4070 * Fires when the active item changes
4071 * @param {Roo.bootstrap.NavGroup} this
4072 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4073 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4080 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4091 getAutoCreate : function()
4093 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4100 if (['tabs','pills'].indexOf(this.type)!==-1) {
4101 cfg.cls += ' nav-' + this.type
4103 if (this.type!=='nav') {
4104 Roo.log('nav type must be nav/tabs/pills')
4106 cfg.cls += ' navbar-nav'
4109 if (this.parent() && this.parent().sidebar) {
4112 cls: 'dashboard-menu sidebar-menu'
4118 if (this.form === true) {
4124 if (this.align === 'right') {
4125 cfg.cls += ' navbar-right';
4127 cfg.cls += ' navbar-left';
4131 if (this.align === 'right') {
4132 cfg.cls += ' navbar-right';
4136 cfg.cls += ' navbar-inverse';
4144 * sets the active Navigation item
4145 * @param {Roo.bootstrap.NavItem} the new current navitem
4147 setActiveItem : function(item)
4150 Roo.each(this.navItems, function(v){
4155 v.setActive(false, true);
4162 item.setActive(true, true);
4163 this.fireEvent('changed', this, item, prev);
4168 * gets the active Navigation item
4169 * @return {Roo.bootstrap.NavItem} the current navitem
4171 getActive : function()
4175 Roo.each(this.navItems, function(v){
4186 indexOfNav : function()
4190 Roo.each(this.navItems, function(v,i){
4201 * adds a Navigation item
4202 * @param {Roo.bootstrap.NavItem} the navitem to add
4204 addItem : function(cfg)
4206 var cn = new Roo.bootstrap.NavItem(cfg);
4208 cn.parentId = this.id;
4209 cn.onRender(this.el, null);
4213 * register a Navigation item
4214 * @param {Roo.bootstrap.NavItem} the navitem to add
4216 register : function(item)
4218 this.navItems.push( item);
4219 item.navId = this.navId;
4224 * clear all the Navigation item
4227 clearAll : function()
4230 this.el.dom.innerHTML = '';
4233 getNavItem: function(tabId)
4236 Roo.each(this.navItems, function(e) {
4237 if (e.tabId == tabId) {
4247 setActiveNext : function()
4249 var i = this.indexOfNav(this.getActive());
4250 if (i > this.navItems.length) {
4253 this.setActiveItem(this.navItems[i+1]);
4255 setActivePrev : function()
4257 var i = this.indexOfNav(this.getActive());
4261 this.setActiveItem(this.navItems[i-1]);
4263 clearWasActive : function(except) {
4264 Roo.each(this.navItems, function(e) {
4265 if (e.tabId != except.tabId && e.was_active) {
4266 e.was_active = false;
4273 getWasActive : function ()
4276 Roo.each(this.navItems, function(e) {
4291 Roo.apply(Roo.bootstrap.NavGroup, {
4295 * register a Navigation Group
4296 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4298 register : function(navgrp)
4300 this.groups[navgrp.navId] = navgrp;
4304 * fetch a Navigation Group based on the navigation ID
4305 * @param {string} the navgroup to add
4306 * @returns {Roo.bootstrap.NavGroup} the navgroup
4308 get: function(navId) {
4309 if (typeof(this.groups[navId]) == 'undefined') {
4311 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4313 return this.groups[navId] ;
4328 * @class Roo.bootstrap.NavItem
4329 * @extends Roo.bootstrap.Component
4330 * Bootstrap Navbar.NavItem class
4331 * @cfg {String} href link to
4332 * @cfg {String} html content of button
4333 * @cfg {String} badge text inside badge
4334 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4335 * @cfg {String} glyphicon name of glyphicon
4336 * @cfg {String} icon name of font awesome icon
4337 * @cfg {Boolean} active Is item active
4338 * @cfg {Boolean} disabled Is item disabled
4340 * @cfg {Boolean} preventDefault (true | false) default false
4341 * @cfg {String} tabId the tab that this item activates.
4342 * @cfg {String} tagtype (a|span) render as a href or span?
4343 * @cfg {Boolean} animateRef (true|false) link to element default false
4346 * Create a new Navbar Item
4347 * @param {Object} config The config object
4349 Roo.bootstrap.NavItem = function(config){
4350 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4355 * The raw click event for the entire grid.
4356 * @param {Roo.EventObject} e
4361 * Fires when the active item active state changes
4362 * @param {Roo.bootstrap.NavItem} this
4363 * @param {boolean} state the new state
4369 * Fires when scroll to element
4370 * @param {Roo.bootstrap.NavItem} this
4371 * @param {Object} options
4372 * @param {Roo.EventObject} e
4380 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4388 preventDefault : false,
4395 getAutoCreate : function(){
4404 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4406 if (this.disabled) {
4407 cfg.cls += ' disabled';
4410 if (this.href || this.html || this.glyphicon || this.icon) {
4414 href : this.href || "#",
4415 html: this.html || ''
4420 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4423 if(this.glyphicon) {
4424 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4429 cfg.cn[0].html += " <span class='caret'></span>";
4433 if (this.badge !== '') {
4435 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
4443 initEvents: function()
4445 if (typeof (this.menu) != 'undefined') {
4446 this.menu.parentType = this.xtype;
4447 this.menu.triggerEl = this.el;
4448 this.menu = this.addxtype(Roo.apply({}, this.menu));
4451 this.el.select('a',true).on('click', this.onClick, this);
4453 if(this.tagtype == 'span'){
4454 this.el.select('span',true).on('click', this.onClick, this);
4457 // at this point parent should be available..
4458 this.parent().register(this);
4461 onClick : function(e)
4463 if (e.getTarget('.dropdown-menu-item')) {
4464 // did you click on a menu itemm.... - then don't trigger onclick..
4469 this.preventDefault ||
4472 Roo.log("NavItem - prevent Default?");
4476 if (this.disabled) {
4480 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4481 if (tg && tg.transition) {
4482 Roo.log("waiting for the transitionend");
4488 //Roo.log("fire event clicked");
4489 if(this.fireEvent('click', this, e) === false){
4493 if(this.tagtype == 'span'){
4497 //Roo.log(this.href);
4498 var ael = this.el.select('a',true).first();
4501 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4502 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4503 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4504 return; // ignore... - it's a 'hash' to another page.
4506 Roo.log("NavItem - prevent Default?");
4508 this.scrollToElement(e);
4512 var p = this.parent();
4514 if (['tabs','pills'].indexOf(p.type)!==-1) {
4515 if (typeof(p.setActiveItem) !== 'undefined') {
4516 p.setActiveItem(this);
4520 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4521 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4522 // remove the collapsed menu expand...
4523 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4527 isActive: function () {
4530 setActive : function(state, fire, is_was_active)
4532 if (this.active && !state && this.navId) {
4533 this.was_active = true;
4534 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4536 nv.clearWasActive(this);
4540 this.active = state;
4543 this.el.removeClass('active');
4544 } else if (!this.el.hasClass('active')) {
4545 this.el.addClass('active');
4548 this.fireEvent('changed', this, state);
4551 // show a panel if it's registered and related..
4553 if (!this.navId || !this.tabId || !state || is_was_active) {
4557 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4561 var pan = tg.getPanelByName(this.tabId);
4565 // if we can not flip to new panel - go back to old nav highlight..
4566 if (false == tg.showPanel(pan)) {
4567 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4569 var onav = nv.getWasActive();
4571 onav.setActive(true, false, true);
4580 // this should not be here...
4581 setDisabled : function(state)
4583 this.disabled = state;
4585 this.el.removeClass('disabled');
4586 } else if (!this.el.hasClass('disabled')) {
4587 this.el.addClass('disabled');
4593 * Fetch the element to display the tooltip on.
4594 * @return {Roo.Element} defaults to this.el
4596 tooltipEl : function()
4598 return this.el.select('' + this.tagtype + '', true).first();
4601 scrollToElement : function(e)
4603 var c = document.body;
4606 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4608 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4609 c = document.documentElement;
4612 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4618 var o = target.calcOffsetsTo(c);
4625 this.fireEvent('scrollto', this, options, e);
4627 Roo.get(c).scrollTo('top', options.value, true);
4640 * <span> icon </span>
4641 * <span> text </span>
4642 * <span>badge </span>
4646 * @class Roo.bootstrap.NavSidebarItem
4647 * @extends Roo.bootstrap.NavItem
4648 * Bootstrap Navbar.NavSidebarItem class
4649 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4650 * {Boolean} open is the menu open
4651 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4652 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4653 * {String} buttonSize (sm|md|lg)the extra classes for the button
4654 * {Boolean} showArrow show arrow next to the text (default true)
4656 * Create a new Navbar Button
4657 * @param {Object} config The config object
4659 Roo.bootstrap.NavSidebarItem = function(config){
4660 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4665 * The raw click event for the entire grid.
4666 * @param {Roo.EventObject} e
4671 * Fires when the active item active state changes
4672 * @param {Roo.bootstrap.NavSidebarItem} this
4673 * @param {boolean} state the new state
4681 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4683 badgeWeight : 'default',
4689 buttonWeight : 'default',
4695 getAutoCreate : function(){
4700 href : this.href || '#',
4706 if(this.buttonView){
4709 href : this.href || '#',
4710 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4723 cfg.cls += ' active';
4726 if (this.disabled) {
4727 cfg.cls += ' disabled';
4730 cfg.cls += ' open x-open';
4733 if (this.glyphicon || this.icon) {
4734 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4735 a.cn.push({ tag : 'i', cls : c }) ;
4738 if(!this.buttonView){
4741 html : this.html || ''
4748 if (this.badge !== '') {
4749 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4755 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4758 a.cls += ' dropdown-toggle treeview' ;
4764 initEvents : function()
4766 if (typeof (this.menu) != 'undefined') {
4767 this.menu.parentType = this.xtype;
4768 this.menu.triggerEl = this.el;
4769 this.menu = this.addxtype(Roo.apply({}, this.menu));
4772 this.el.on('click', this.onClick, this);
4774 if(this.badge !== ''){
4775 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4780 onClick : function(e)
4787 if(this.preventDefault){
4791 this.fireEvent('click', this);
4794 disable : function()
4796 this.setDisabled(true);
4801 this.setDisabled(false);
4804 setDisabled : function(state)
4806 if(this.disabled == state){
4810 this.disabled = state;
4813 this.el.addClass('disabled');
4817 this.el.removeClass('disabled');
4822 setActive : function(state)
4824 if(this.active == state){
4828 this.active = state;
4831 this.el.addClass('active');
4835 this.el.removeClass('active');
4840 isActive: function ()
4845 setBadge : function(str)
4851 this.badgeEl.dom.innerHTML = str;
4868 * @class Roo.bootstrap.Row
4869 * @extends Roo.bootstrap.Component
4870 * Bootstrap Row class (contains columns...)
4874 * @param {Object} config The config object
4877 Roo.bootstrap.Row = function(config){
4878 Roo.bootstrap.Row.superclass.constructor.call(this, config);
4881 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
4883 getAutoCreate : function(){
4902 * @class Roo.bootstrap.Element
4903 * @extends Roo.bootstrap.Component
4904 * Bootstrap Element class
4905 * @cfg {String} html contents of the element
4906 * @cfg {String} tag tag of the element
4907 * @cfg {String} cls class of the element
4908 * @cfg {Boolean} preventDefault (true|false) default false
4909 * @cfg {Boolean} clickable (true|false) default false
4912 * Create a new Element
4913 * @param {Object} config The config object
4916 Roo.bootstrap.Element = function(config){
4917 Roo.bootstrap.Element.superclass.constructor.call(this, config);
4923 * When a element is chick
4924 * @param {Roo.bootstrap.Element} this
4925 * @param {Roo.EventObject} e
4931 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
4936 preventDefault: false,
4939 getAutoCreate : function(){
4943 // cls: this.cls, double assign in parent class Component.js :: onRender
4950 initEvents: function()
4952 Roo.bootstrap.Element.superclass.initEvents.call(this);
4955 this.el.on('click', this.onClick, this);
4960 onClick : function(e)
4962 if(this.preventDefault){
4966 this.fireEvent('click', this, e);
4969 getValue : function()
4971 return this.el.dom.innerHTML;
4974 setValue : function(value)
4976 this.el.dom.innerHTML = value;
4991 * @class Roo.bootstrap.Pagination
4992 * @extends Roo.bootstrap.Component
4993 * Bootstrap Pagination class
4994 * @cfg {String} size xs | sm | md | lg
4995 * @cfg {Boolean} inverse false | true
4998 * Create a new Pagination
4999 * @param {Object} config The config object
5002 Roo.bootstrap.Pagination = function(config){
5003 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5006 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5012 getAutoCreate : function(){
5018 cfg.cls += ' inverse';
5024 cfg.cls += " " + this.cls;
5042 * @class Roo.bootstrap.PaginationItem
5043 * @extends Roo.bootstrap.Component
5044 * Bootstrap PaginationItem class
5045 * @cfg {String} html text
5046 * @cfg {String} href the link
5047 * @cfg {Boolean} preventDefault (true | false) default true
5048 * @cfg {Boolean} active (true | false) default false
5049 * @cfg {Boolean} disabled default false
5053 * Create a new PaginationItem
5054 * @param {Object} config The config object
5058 Roo.bootstrap.PaginationItem = function(config){
5059 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5064 * The raw click event for the entire grid.
5065 * @param {Roo.EventObject} e
5071 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5075 preventDefault: true,
5080 getAutoCreate : function(){
5086 href : this.href ? this.href : '#',
5087 html : this.html ? this.html : ''
5097 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5101 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5107 initEvents: function() {
5109 this.el.on('click', this.onClick, this);
5112 onClick : function(e)
5114 Roo.log('PaginationItem on click ');
5115 if(this.preventDefault){
5123 this.fireEvent('click', this, e);
5139 * @class Roo.bootstrap.Slider
5140 * @extends Roo.bootstrap.Component
5141 * Bootstrap Slider class
5144 * Create a new Slider
5145 * @param {Object} config The config object
5148 Roo.bootstrap.Slider = function(config){
5149 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5152 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5154 getAutoCreate : function(){
5158 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5162 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5174 * Ext JS Library 1.1.1
5175 * Copyright(c) 2006-2007, Ext JS, LLC.
5177 * Originally Released Under LGPL - original licence link has changed is not relivant.
5180 * <script type="text/javascript">
5185 * @class Roo.grid.ColumnModel
5186 * @extends Roo.util.Observable
5187 * This is the default implementation of a ColumnModel used by the Grid. It defines
5188 * the columns in the grid.
5191 var colModel = new Roo.grid.ColumnModel([
5192 {header: "Ticker", width: 60, sortable: true, locked: true},
5193 {header: "Company Name", width: 150, sortable: true},
5194 {header: "Market Cap.", width: 100, sortable: true},
5195 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5196 {header: "Employees", width: 100, sortable: true, resizable: false}
5201 * The config options listed for this class are options which may appear in each
5202 * individual column definition.
5203 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5205 * @param {Object} config An Array of column config objects. See this class's
5206 * config objects for details.
5208 Roo.grid.ColumnModel = function(config){
5210 * The config passed into the constructor
5212 this.config = config;
5215 // if no id, create one
5216 // if the column does not have a dataIndex mapping,
5217 // map it to the order it is in the config
5218 for(var i = 0, len = config.length; i < len; i++){
5220 if(typeof c.dataIndex == "undefined"){
5223 if(typeof c.renderer == "string"){
5224 c.renderer = Roo.util.Format[c.renderer];
5226 if(typeof c.id == "undefined"){
5229 if(c.editor && c.editor.xtype){
5230 c.editor = Roo.factory(c.editor, Roo.grid);
5232 if(c.editor && c.editor.isFormField){
5233 c.editor = new Roo.grid.GridEditor(c.editor);
5235 this.lookup[c.id] = c;
5239 * The width of columns which have no width specified (defaults to 100)
5242 this.defaultWidth = 100;
5245 * Default sortable of columns which have no sortable specified (defaults to false)
5248 this.defaultSortable = false;
5252 * @event widthchange
5253 * Fires when the width of a column changes.
5254 * @param {ColumnModel} this
5255 * @param {Number} columnIndex The column index
5256 * @param {Number} newWidth The new width
5258 "widthchange": true,
5260 * @event headerchange
5261 * Fires when the text of a header changes.
5262 * @param {ColumnModel} this
5263 * @param {Number} columnIndex The column index
5264 * @param {Number} newText The new header text
5266 "headerchange": true,
5268 * @event hiddenchange
5269 * Fires when a column is hidden or "unhidden".
5270 * @param {ColumnModel} this
5271 * @param {Number} columnIndex The column index
5272 * @param {Boolean} hidden true if hidden, false otherwise
5274 "hiddenchange": true,
5276 * @event columnmoved
5277 * Fires when a column is moved.
5278 * @param {ColumnModel} this
5279 * @param {Number} oldIndex
5280 * @param {Number} newIndex
5282 "columnmoved" : true,
5284 * @event columlockchange
5285 * Fires when a column's locked state is changed
5286 * @param {ColumnModel} this
5287 * @param {Number} colIndex
5288 * @param {Boolean} locked true if locked
5290 "columnlockchange" : true
5292 Roo.grid.ColumnModel.superclass.constructor.call(this);
5294 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5296 * @cfg {String} header The header text to display in the Grid view.
5299 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5300 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5301 * specified, the column's index is used as an index into the Record's data Array.
5304 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5305 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5308 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5309 * Defaults to the value of the {@link #defaultSortable} property.
5310 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5313 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5316 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5319 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5322 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5325 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5326 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5327 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5328 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5331 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5334 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5337 * @cfg {String} cursor (Optional)
5340 * @cfg {String} tooltip (Optional)
5343 * @cfg {Number} xs (Optional)
5346 * @cfg {Number} sm (Optional)
5349 * @cfg {Number} md (Optional)
5352 * @cfg {Number} lg (Optional)
5355 * Returns the id of the column at the specified index.
5356 * @param {Number} index The column index
5357 * @return {String} the id
5359 getColumnId : function(index){
5360 return this.config[index].id;
5364 * Returns the column for a specified id.
5365 * @param {String} id The column id
5366 * @return {Object} the column
5368 getColumnById : function(id){
5369 return this.lookup[id];
5374 * Returns the column for a specified dataIndex.
5375 * @param {String} dataIndex The column dataIndex
5376 * @return {Object|Boolean} the column or false if not found
5378 getColumnByDataIndex: function(dataIndex){
5379 var index = this.findColumnIndex(dataIndex);
5380 return index > -1 ? this.config[index] : false;
5384 * Returns the index for a specified column id.
5385 * @param {String} id The column id
5386 * @return {Number} the index, or -1 if not found
5388 getIndexById : function(id){
5389 for(var i = 0, len = this.config.length; i < len; i++){
5390 if(this.config[i].id == id){
5398 * Returns the index for a specified column dataIndex.
5399 * @param {String} dataIndex The column dataIndex
5400 * @return {Number} the index, or -1 if not found
5403 findColumnIndex : function(dataIndex){
5404 for(var i = 0, len = this.config.length; i < len; i++){
5405 if(this.config[i].dataIndex == dataIndex){
5413 moveColumn : function(oldIndex, newIndex){
5414 var c = this.config[oldIndex];
5415 this.config.splice(oldIndex, 1);
5416 this.config.splice(newIndex, 0, c);
5417 this.dataMap = null;
5418 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5421 isLocked : function(colIndex){
5422 return this.config[colIndex].locked === true;
5425 setLocked : function(colIndex, value, suppressEvent){
5426 if(this.isLocked(colIndex) == value){
5429 this.config[colIndex].locked = value;
5431 this.fireEvent("columnlockchange", this, colIndex, value);
5435 getTotalLockedWidth : function(){
5437 for(var i = 0; i < this.config.length; i++){
5438 if(this.isLocked(i) && !this.isHidden(i)){
5439 this.totalWidth += this.getColumnWidth(i);
5445 getLockedCount : function(){
5446 for(var i = 0, len = this.config.length; i < len; i++){
5447 if(!this.isLocked(i)){
5452 return this.config.length;
5456 * Returns the number of columns.
5459 getColumnCount : function(visibleOnly){
5460 if(visibleOnly === true){
5462 for(var i = 0, len = this.config.length; i < len; i++){
5463 if(!this.isHidden(i)){
5469 return this.config.length;
5473 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5474 * @param {Function} fn
5475 * @param {Object} scope (optional)
5476 * @return {Array} result
5478 getColumnsBy : function(fn, scope){
5480 for(var i = 0, len = this.config.length; i < len; i++){
5481 var c = this.config[i];
5482 if(fn.call(scope||this, c, i) === true){
5490 * Returns true if the specified column is sortable.
5491 * @param {Number} col The column index
5494 isSortable : function(col){
5495 if(typeof this.config[col].sortable == "undefined"){
5496 return this.defaultSortable;
5498 return this.config[col].sortable;
5502 * Returns the rendering (formatting) function defined for the column.
5503 * @param {Number} col The column index.
5504 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5506 getRenderer : function(col){
5507 if(!this.config[col].renderer){
5508 return Roo.grid.ColumnModel.defaultRenderer;
5510 return this.config[col].renderer;
5514 * Sets the rendering (formatting) function for a column.
5515 * @param {Number} col The column index
5516 * @param {Function} fn The function to use to process the cell's raw data
5517 * to return HTML markup for the grid view. The render function is called with
5518 * the following parameters:<ul>
5519 * <li>Data value.</li>
5520 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5521 * <li>css A CSS style string to apply to the table cell.</li>
5522 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5523 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5524 * <li>Row index</li>
5525 * <li>Column index</li>
5526 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5528 setRenderer : function(col, fn){
5529 this.config[col].renderer = fn;
5533 * Returns the width for the specified column.
5534 * @param {Number} col The column index
5537 getColumnWidth : function(col){
5538 return this.config[col].width * 1 || this.defaultWidth;
5542 * Sets the width for a column.
5543 * @param {Number} col The column index
5544 * @param {Number} width The new width
5546 setColumnWidth : function(col, width, suppressEvent){
5547 this.config[col].width = width;
5548 this.totalWidth = null;
5550 this.fireEvent("widthchange", this, col, width);
5555 * Returns the total width of all columns.
5556 * @param {Boolean} includeHidden True to include hidden column widths
5559 getTotalWidth : function(includeHidden){
5560 if(!this.totalWidth){
5561 this.totalWidth = 0;
5562 for(var i = 0, len = this.config.length; i < len; i++){
5563 if(includeHidden || !this.isHidden(i)){
5564 this.totalWidth += this.getColumnWidth(i);
5568 return this.totalWidth;
5572 * Returns the header for the specified column.
5573 * @param {Number} col The column index
5576 getColumnHeader : function(col){
5577 return this.config[col].header;
5581 * Sets the header for a column.
5582 * @param {Number} col The column index
5583 * @param {String} header The new header
5585 setColumnHeader : function(col, header){
5586 this.config[col].header = header;
5587 this.fireEvent("headerchange", this, col, header);
5591 * Returns the tooltip for the specified column.
5592 * @param {Number} col The column index
5595 getColumnTooltip : function(col){
5596 return this.config[col].tooltip;
5599 * Sets the tooltip for a column.
5600 * @param {Number} col The column index
5601 * @param {String} tooltip The new tooltip
5603 setColumnTooltip : function(col, tooltip){
5604 this.config[col].tooltip = tooltip;
5608 * Returns the dataIndex for the specified column.
5609 * @param {Number} col The column index
5612 getDataIndex : function(col){
5613 return this.config[col].dataIndex;
5617 * Sets the dataIndex for a column.
5618 * @param {Number} col The column index
5619 * @param {Number} dataIndex The new dataIndex
5621 setDataIndex : function(col, dataIndex){
5622 this.config[col].dataIndex = dataIndex;
5628 * Returns true if the cell is editable.
5629 * @param {Number} colIndex The column index
5630 * @param {Number} rowIndex The row index - this is nto actually used..?
5633 isCellEditable : function(colIndex, rowIndex){
5634 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5638 * Returns the editor defined for the cell/column.
5639 * return false or null to disable editing.
5640 * @param {Number} colIndex The column index
5641 * @param {Number} rowIndex The row index
5644 getCellEditor : function(colIndex, rowIndex){
5645 return this.config[colIndex].editor;
5649 * Sets if a column is editable.
5650 * @param {Number} col The column index
5651 * @param {Boolean} editable True if the column is editable
5653 setEditable : function(col, editable){
5654 this.config[col].editable = editable;
5659 * Returns true if the column is hidden.
5660 * @param {Number} colIndex The column index
5663 isHidden : function(colIndex){
5664 return this.config[colIndex].hidden;
5669 * Returns true if the column width cannot be changed
5671 isFixed : function(colIndex){
5672 return this.config[colIndex].fixed;
5676 * Returns true if the column can be resized
5679 isResizable : function(colIndex){
5680 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5683 * Sets if a column is hidden.
5684 * @param {Number} colIndex The column index
5685 * @param {Boolean} hidden True if the column is hidden
5687 setHidden : function(colIndex, hidden){
5688 this.config[colIndex].hidden = hidden;
5689 this.totalWidth = null;
5690 this.fireEvent("hiddenchange", this, colIndex, hidden);
5694 * Sets the editor for a column.
5695 * @param {Number} col The column index
5696 * @param {Object} editor The editor object
5698 setEditor : function(col, editor){
5699 this.config[col].editor = editor;
5703 Roo.grid.ColumnModel.defaultRenderer = function(value)
5705 if(typeof value == "object") {
5708 if(typeof value == "string" && value.length < 1){
5712 return String.format("{0}", value);
5715 // Alias for backwards compatibility
5716 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5719 * Ext JS Library 1.1.1
5720 * Copyright(c) 2006-2007, Ext JS, LLC.
5722 * Originally Released Under LGPL - original licence link has changed is not relivant.
5725 * <script type="text/javascript">
5729 * @class Roo.LoadMask
5730 * A simple utility class for generically masking elements while loading data. If the element being masked has
5731 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5732 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5733 * element's UpdateManager load indicator and will be destroyed after the initial load.
5735 * Create a new LoadMask
5736 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5737 * @param {Object} config The config object
5739 Roo.LoadMask = function(el, config){
5740 this.el = Roo.get(el);
5741 Roo.apply(this, config);
5743 this.store.on('beforeload', this.onBeforeLoad, this);
5744 this.store.on('load', this.onLoad, this);
5745 this.store.on('loadexception', this.onLoadException, this);
5746 this.removeMask = false;
5748 var um = this.el.getUpdateManager();
5749 um.showLoadIndicator = false; // disable the default indicator
5750 um.on('beforeupdate', this.onBeforeLoad, this);
5751 um.on('update', this.onLoad, this);
5752 um.on('failure', this.onLoad, this);
5753 this.removeMask = true;
5757 Roo.LoadMask.prototype = {
5759 * @cfg {Boolean} removeMask
5760 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5761 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5765 * The text to display in a centered loading message box (defaults to 'Loading...')
5769 * @cfg {String} msgCls
5770 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5772 msgCls : 'x-mask-loading',
5775 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5781 * Disables the mask to prevent it from being displayed
5783 disable : function(){
5784 this.disabled = true;
5788 * Enables the mask so that it can be displayed
5790 enable : function(){
5791 this.disabled = false;
5794 onLoadException : function()
5798 if (typeof(arguments[3]) != 'undefined') {
5799 Roo.MessageBox.alert("Error loading",arguments[3]);
5803 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5804 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5811 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5816 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5820 onBeforeLoad : function(){
5822 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5827 destroy : function(){
5829 this.store.un('beforeload', this.onBeforeLoad, this);
5830 this.store.un('load', this.onLoad, this);
5831 this.store.un('loadexception', this.onLoadException, this);
5833 var um = this.el.getUpdateManager();
5834 um.un('beforeupdate', this.onBeforeLoad, this);
5835 um.un('update', this.onLoad, this);
5836 um.un('failure', this.onLoad, this);
5847 * @class Roo.bootstrap.Table
5848 * @extends Roo.bootstrap.Component
5849 * Bootstrap Table class
5850 * @cfg {String} cls table class
5851 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
5852 * @cfg {String} bgcolor Specifies the background color for a table
5853 * @cfg {Number} border Specifies whether the table cells should have borders or not
5854 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
5855 * @cfg {Number} cellspacing Specifies the space between cells
5856 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
5857 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
5858 * @cfg {String} sortable Specifies that the table should be sortable
5859 * @cfg {String} summary Specifies a summary of the content of a table
5860 * @cfg {Number} width Specifies the width of a table
5861 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
5863 * @cfg {boolean} striped Should the rows be alternative striped
5864 * @cfg {boolean} bordered Add borders to the table
5865 * @cfg {boolean} hover Add hover highlighting
5866 * @cfg {boolean} condensed Format condensed
5867 * @cfg {boolean} responsive Format condensed
5868 * @cfg {Boolean} loadMask (true|false) default false
5869 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
5870 * @cfg {Boolean} headerShow (true|false) generate thead, default true
5871 * @cfg {Boolean} rowSelection (true|false) default false
5872 * @cfg {Boolean} cellSelection (true|false) default false
5873 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
5874 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
5875 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
5879 * Create a new Table
5880 * @param {Object} config The config object
5883 Roo.bootstrap.Table = function(config){
5884 Roo.bootstrap.Table.superclass.constructor.call(this, config);
5889 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
5890 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
5891 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
5892 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
5894 this.sm = this.sm || {xtype: 'RowSelectionModel'};
5896 this.sm.grid = this;
5897 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
5898 this.sm = this.selModel;
5899 this.sm.xmodule = this.xmodule || false;
5902 if (this.cm && typeof(this.cm.config) == 'undefined') {
5903 this.colModel = new Roo.grid.ColumnModel(this.cm);
5904 this.cm = this.colModel;
5905 this.cm.xmodule = this.xmodule || false;
5908 this.store= Roo.factory(this.store, Roo.data);
5909 this.ds = this.store;
5910 this.ds.xmodule = this.xmodule || false;
5913 if (this.footer && this.store) {
5914 this.footer.dataSource = this.ds;
5915 this.footer = Roo.factory(this.footer);
5922 * Fires when a cell is clicked
5923 * @param {Roo.bootstrap.Table} this
5924 * @param {Roo.Element} el
5925 * @param {Number} rowIndex
5926 * @param {Number} columnIndex
5927 * @param {Roo.EventObject} e
5931 * @event celldblclick
5932 * Fires when a cell is double clicked
5933 * @param {Roo.bootstrap.Table} this
5934 * @param {Roo.Element} el
5935 * @param {Number} rowIndex
5936 * @param {Number} columnIndex
5937 * @param {Roo.EventObject} e
5939 "celldblclick" : true,
5942 * Fires when a row is clicked
5943 * @param {Roo.bootstrap.Table} this
5944 * @param {Roo.Element} el
5945 * @param {Number} rowIndex
5946 * @param {Roo.EventObject} e
5950 * @event rowdblclick
5951 * Fires when a row is double clicked
5952 * @param {Roo.bootstrap.Table} this
5953 * @param {Roo.Element} el
5954 * @param {Number} rowIndex
5955 * @param {Roo.EventObject} e
5957 "rowdblclick" : true,
5960 * Fires when a mouseover occur
5961 * @param {Roo.bootstrap.Table} this
5962 * @param {Roo.Element} el
5963 * @param {Number} rowIndex
5964 * @param {Number} columnIndex
5965 * @param {Roo.EventObject} e
5970 * Fires when a mouseout occur
5971 * @param {Roo.bootstrap.Table} this
5972 * @param {Roo.Element} el
5973 * @param {Number} rowIndex
5974 * @param {Number} columnIndex
5975 * @param {Roo.EventObject} e
5980 * Fires when a row is rendered, so you can change add a style to it.
5981 * @param {Roo.bootstrap.Table} this
5982 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
5986 * @event rowsrendered
5987 * Fires when all the rows have been rendered
5988 * @param {Roo.bootstrap.Table} this
5990 'rowsrendered' : true,
5992 * @event contextmenu
5993 * The raw contextmenu event for the entire grid.
5994 * @param {Roo.EventObject} e
5996 "contextmenu" : true,
5998 * @event rowcontextmenu
5999 * Fires when a row is right clicked
6000 * @param {Roo.bootstrap.Table} this
6001 * @param {Number} rowIndex
6002 * @param {Roo.EventObject} e
6004 "rowcontextmenu" : true,
6006 * @event cellcontextmenu
6007 * Fires when a cell is right clicked
6008 * @param {Roo.bootstrap.Table} this
6009 * @param {Number} rowIndex
6010 * @param {Number} cellIndex
6011 * @param {Roo.EventObject} e
6013 "cellcontextmenu" : true,
6015 * @event headercontextmenu
6016 * Fires when a header is right clicked
6017 * @param {Roo.bootstrap.Table} this
6018 * @param {Number} columnIndex
6019 * @param {Roo.EventObject} e
6021 "headercontextmenu" : true
6025 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6051 rowSelection : false,
6052 cellSelection : false,
6055 // Roo.Element - the tbody
6057 // Roo.Element - thead element
6060 container: false, // used by gridpanel...
6064 getAutoCreate : function()
6066 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6073 if (this.scrollBody) {
6074 cfg.cls += ' table-body-fixed';
6077 cfg.cls += ' table-striped';
6081 cfg.cls += ' table-hover';
6083 if (this.bordered) {
6084 cfg.cls += ' table-bordered';
6086 if (this.condensed) {
6087 cfg.cls += ' table-condensed';
6089 if (this.responsive) {
6090 cfg.cls += ' table-responsive';
6094 cfg.cls+= ' ' +this.cls;
6097 // this lot should be simplifed...
6100 cfg.align=this.align;
6103 cfg.bgcolor=this.bgcolor;
6106 cfg.border=this.border;
6108 if (this.cellpadding) {
6109 cfg.cellpadding=this.cellpadding;
6111 if (this.cellspacing) {
6112 cfg.cellspacing=this.cellspacing;
6115 cfg.frame=this.frame;
6118 cfg.rules=this.rules;
6120 if (this.sortable) {
6121 cfg.sortable=this.sortable;
6124 cfg.summary=this.summary;
6127 cfg.width=this.width;
6130 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6133 if(this.store || this.cm){
6134 if(this.headerShow){
6135 cfg.cn.push(this.renderHeader());
6138 cfg.cn.push(this.renderBody());
6140 if(this.footerShow){
6141 cfg.cn.push(this.renderFooter());
6143 // where does this come from?
6144 //cfg.cls+= ' TableGrid';
6147 return { cn : [ cfg ] };
6150 initEvents : function()
6152 if(!this.store || !this.cm){
6155 if (this.selModel) {
6156 this.selModel.initEvents();
6160 //Roo.log('initEvents with ds!!!!');
6162 this.mainBody = this.el.select('tbody', true).first();
6163 this.mainHead = this.el.select('thead', true).first();
6170 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6171 e.on('click', _this.sort, _this);
6174 this.mainBody.on("click", this.onClick, this);
6175 this.mainBody.on("dblclick", this.onDblClick, this);
6177 // why is this done????? = it breaks dialogs??
6178 //this.parent().el.setStyle('position', 'relative');
6182 this.footer.parentId = this.id;
6183 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6186 this.el.select('tfoot tr td').first().addClass('hide');
6190 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6192 this.store.on('load', this.onLoad, this);
6193 this.store.on('beforeload', this.onBeforeLoad, this);
6194 this.store.on('update', this.onUpdate, this);
6195 this.store.on('add', this.onAdd, this);
6196 this.store.on("clear", this.clear, this);
6198 this.el.on("contextmenu", this.onContextMenu, this);
6200 this.mainBody.on('scroll', this.onBodyScroll, this);
6202 this.cm.on("headerchange", this.onHeaderChange, this);
6206 onContextMenu : function(e, t)
6208 this.processEvent("contextmenu", e);
6211 processEvent : function(name, e)
6213 if (name != 'touchstart' ) {
6214 this.fireEvent(name, e);
6217 var t = e.getTarget();
6219 var cell = Roo.get(t);
6225 if(cell.findParent('tfoot', false, true)){
6229 if(cell.findParent('thead', false, true)){
6231 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6232 cell = Roo.get(t).findParent('th', false, true);
6234 Roo.log("failed to find th in thead?");
6235 Roo.log(e.getTarget());
6240 var cellIndex = cell.dom.cellIndex;
6242 var ename = name == 'touchstart' ? 'click' : name;
6243 this.fireEvent("header" + ename, this, cellIndex, e);
6248 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6249 cell = Roo.get(t).findParent('td', false, true);
6251 Roo.log("failed to find th in tbody?");
6252 Roo.log(e.getTarget());
6257 var row = cell.findParent('tr', false, true);
6258 var cellIndex = cell.dom.cellIndex;
6259 var rowIndex = row.dom.rowIndex - 1;
6263 this.fireEvent("row" + name, this, rowIndex, e);
6267 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6273 onMouseover : function(e, el)
6275 var cell = Roo.get(el);
6281 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6282 cell = cell.findParent('td', false, true);
6285 var row = cell.findParent('tr', false, true);
6286 var cellIndex = cell.dom.cellIndex;
6287 var rowIndex = row.dom.rowIndex - 1; // start from 0
6289 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6293 onMouseout : function(e, el)
6295 var cell = Roo.get(el);
6301 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6302 cell = cell.findParent('td', false, true);
6305 var row = cell.findParent('tr', false, true);
6306 var cellIndex = cell.dom.cellIndex;
6307 var rowIndex = row.dom.rowIndex - 1; // start from 0
6309 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6313 onClick : function(e, el)
6315 var cell = Roo.get(el);
6317 if(!cell || (!this.cellSelection && !this.rowSelection)){
6321 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6322 cell = cell.findParent('td', false, true);
6325 if(!cell || typeof(cell) == 'undefined'){
6329 var row = cell.findParent('tr', false, true);
6331 if(!row || typeof(row) == 'undefined'){
6335 var cellIndex = cell.dom.cellIndex;
6336 var rowIndex = this.getRowIndex(row);
6338 // why??? - should these not be based on SelectionModel?
6339 if(this.cellSelection){
6340 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6343 if(this.rowSelection){
6344 this.fireEvent('rowclick', this, row, rowIndex, e);
6350 onDblClick : function(e,el)
6352 var cell = Roo.get(el);
6354 if(!cell || (!this.cellSelection && !this.rowSelection)){
6358 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6359 cell = cell.findParent('td', false, true);
6362 if(!cell || typeof(cell) == 'undefined'){
6366 var row = cell.findParent('tr', false, true);
6368 if(!row || typeof(row) == 'undefined'){
6372 var cellIndex = cell.dom.cellIndex;
6373 var rowIndex = this.getRowIndex(row);
6375 if(this.cellSelection){
6376 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6379 if(this.rowSelection){
6380 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6384 sort : function(e,el)
6386 var col = Roo.get(el);
6388 if(!col.hasClass('sortable')){
6392 var sort = col.attr('sort');
6395 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6399 this.store.sortInfo = {field : sort, direction : dir};
6402 Roo.log("calling footer first");
6403 this.footer.onClick('first');
6406 this.store.load({ params : { start : 0 } });
6410 renderHeader : function()
6418 this.totalWidth = 0;
6420 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6422 var config = cm.config[i];
6427 html: cm.getColumnHeader(i)
6432 if(typeof(config.sortable) != 'undefined' && config.sortable){
6434 c.html = '<i class="glyphicon"></i>' + c.html;
6437 if(typeof(config.lgHeader) != 'undefined'){
6438 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6441 if(typeof(config.mdHeader) != 'undefined'){
6442 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6445 if(typeof(config.smHeader) != 'undefined'){
6446 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6449 if(typeof(config.xsHeader) != 'undefined'){
6450 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6457 if(typeof(config.tooltip) != 'undefined'){
6458 c.tooltip = config.tooltip;
6461 if(typeof(config.colspan) != 'undefined'){
6462 c.colspan = config.colspan;
6465 if(typeof(config.hidden) != 'undefined' && config.hidden){
6466 c.style += ' display:none;';
6469 if(typeof(config.dataIndex) != 'undefined'){
6470 c.sort = config.dataIndex;
6475 if(typeof(config.align) != 'undefined' && config.align.length){
6476 c.style += ' text-align:' + config.align + ';';
6479 if(typeof(config.width) != 'undefined'){
6480 c.style += ' width:' + config.width + 'px;';
6481 this.totalWidth += config.width;
6483 this.totalWidth += 100; // assume minimum of 100 per column?
6486 if(typeof(config.cls) != 'undefined'){
6487 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6490 ['xs','sm','md','lg'].map(function(size){
6492 if(typeof(config[size]) == 'undefined'){
6496 if (!config[size]) { // 0 = hidden
6497 c.cls += ' hidden-' + size;
6501 c.cls += ' col-' + size + '-' + config[size];
6511 renderBody : function()
6521 colspan : this.cm.getColumnCount()
6531 renderFooter : function()
6541 colspan : this.cm.getColumnCount()
6555 // Roo.log('ds onload');
6560 var ds = this.store;
6562 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6563 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6564 if (_this.store.sortInfo) {
6566 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6567 e.select('i', true).addClass(['glyphicon-arrow-up']);
6570 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6571 e.select('i', true).addClass(['glyphicon-arrow-down']);
6576 var tbody = this.mainBody;
6578 if(ds.getCount() > 0){
6579 ds.data.each(function(d,rowIndex){
6580 var row = this.renderRow(cm, ds, rowIndex);
6582 tbody.createChild(row);
6586 if(row.cellObjects.length){
6587 Roo.each(row.cellObjects, function(r){
6588 _this.renderCellObject(r);
6595 Roo.each(this.el.select('tbody td', true).elements, function(e){
6596 e.on('mouseover', _this.onMouseover, _this);
6599 Roo.each(this.el.select('tbody td', true).elements, function(e){
6600 e.on('mouseout', _this.onMouseout, _this);
6602 this.fireEvent('rowsrendered', this);
6603 //if(this.loadMask){
6604 // this.maskEl.hide();
6611 onUpdate : function(ds,record)
6613 this.refreshRow(record);
6617 onRemove : function(ds, record, index, isUpdate){
6618 if(isUpdate !== true){
6619 this.fireEvent("beforerowremoved", this, index, record);
6621 var bt = this.mainBody.dom;
6623 var rows = this.el.select('tbody > tr', true).elements;
6625 if(typeof(rows[index]) != 'undefined'){
6626 bt.removeChild(rows[index].dom);
6629 // if(bt.rows[index]){
6630 // bt.removeChild(bt.rows[index]);
6633 if(isUpdate !== true){
6634 //this.stripeRows(index);
6635 //this.syncRowHeights(index, index);
6637 this.fireEvent("rowremoved", this, index, record);
6641 onAdd : function(ds, records, rowIndex)
6643 //Roo.log('on Add called');
6644 // - note this does not handle multiple adding very well..
6645 var bt = this.mainBody.dom;
6646 for (var i =0 ; i < records.length;i++) {
6647 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6648 //Roo.log(records[i]);
6649 //Roo.log(this.store.getAt(rowIndex+i));
6650 this.insertRow(this.store, rowIndex + i, false);
6657 refreshRow : function(record){
6658 var ds = this.store, index;
6659 if(typeof record == 'number'){
6661 record = ds.getAt(index);
6663 index = ds.indexOf(record);
6665 this.insertRow(ds, index, true);
6667 this.onRemove(ds, record, index+1, true);
6669 //this.syncRowHeights(index, index);
6671 this.fireEvent("rowupdated", this, index, record);
6674 insertRow : function(dm, rowIndex, isUpdate){
6677 this.fireEvent("beforerowsinserted", this, rowIndex);
6679 //var s = this.getScrollState();
6680 var row = this.renderRow(this.cm, this.store, rowIndex);
6681 // insert before rowIndex..
6682 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6686 if(row.cellObjects.length){
6687 Roo.each(row.cellObjects, function(r){
6688 _this.renderCellObject(r);
6693 this.fireEvent("rowsinserted", this, rowIndex);
6694 //this.syncRowHeights(firstRow, lastRow);
6695 //this.stripeRows(firstRow);
6702 getRowDom : function(rowIndex)
6704 var rows = this.el.select('tbody > tr', true).elements;
6706 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6709 // returns the object tree for a tr..
6712 renderRow : function(cm, ds, rowIndex)
6715 var d = ds.getAt(rowIndex);
6722 var cellObjects = [];
6724 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6725 var config = cm.config[i];
6727 var renderer = cm.getRenderer(i);
6731 if(typeof(renderer) !== 'undefined'){
6732 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6734 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6735 // and are rendered into the cells after the row is rendered - using the id for the element.
6737 if(typeof(value) === 'object'){
6747 rowIndex : rowIndex,
6752 this.fireEvent('rowclass', this, rowcfg);
6756 cls : rowcfg.rowClass,
6758 html: (typeof(value) === 'object') ? '' : value
6765 if(typeof(config.colspan) != 'undefined'){
6766 td.colspan = config.colspan;
6769 if(typeof(config.hidden) != 'undefined' && config.hidden){
6770 td.style += ' display:none;';
6773 if(typeof(config.align) != 'undefined' && config.align.length){
6774 td.style += ' text-align:' + config.align + ';';
6777 if(typeof(config.width) != 'undefined'){
6778 td.style += ' width:' + config.width + 'px;';
6781 if(typeof(config.cursor) != 'undefined'){
6782 td.style += ' cursor:' + config.cursor + ';';
6785 if(typeof(config.cls) != 'undefined'){
6786 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6789 ['xs','sm','md','lg'].map(function(size){
6791 if(typeof(config[size]) == 'undefined'){
6795 if (!config[size]) { // 0 = hidden
6796 td.cls += ' hidden-' + size;
6800 td.cls += ' col-' + size + '-' + config[size];
6808 row.cellObjects = cellObjects;
6816 onBeforeLoad : function()
6818 //Roo.log('ds onBeforeLoad');
6822 //if(this.loadMask){
6823 // this.maskEl.show();
6831 this.el.select('tbody', true).first().dom.innerHTML = '';
6834 * Show or hide a row.
6835 * @param {Number} rowIndex to show or hide
6836 * @param {Boolean} state hide
6838 setRowVisibility : function(rowIndex, state)
6840 var bt = this.mainBody.dom;
6842 var rows = this.el.select('tbody > tr', true).elements;
6844 if(typeof(rows[rowIndex]) == 'undefined'){
6847 rows[rowIndex].dom.style.display = state ? '' : 'none';
6851 getSelectionModel : function(){
6853 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
6855 return this.selModel;
6858 * Render the Roo.bootstrap object from renderder
6860 renderCellObject : function(r)
6864 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
6866 var t = r.cfg.render(r.container);
6869 Roo.each(r.cfg.cn, function(c){
6871 container: t.getChildContainer(),
6874 _this.renderCellObject(child);
6879 getRowIndex : function(row)
6883 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
6894 * Returns the grid's underlying element = used by panel.Grid
6895 * @return {Element} The element
6897 getGridEl : function(){
6901 * Forces a resize - used by panel.Grid
6902 * @return {Element} The element
6904 autoSize : function()
6906 //var ctr = Roo.get(this.container.dom.parentElement);
6907 var ctr = Roo.get(this.el.dom);
6909 var thd = this.getGridEl().select('thead',true).first();
6910 var tbd = this.getGridEl().select('tbody', true).first();
6911 var tfd = this.getGridEl().select('tfoot', true).first();
6913 var cw = ctr.getWidth();
6917 tbd.setSize(ctr.getWidth(),
6918 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
6920 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
6923 cw = Math.max(cw, this.totalWidth);
6924 this.getGridEl().select('tr',true).setWidth(cw);
6925 // resize 'expandable coloumn?
6927 return; // we doe not have a view in this design..
6930 onBodyScroll: function()
6932 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
6934 this.mainHead.setStyle({
6935 'position' : 'relative',
6936 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6942 var scrollHeight = this.mainBody.dom.scrollHeight;
6944 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
6946 var height = this.mainBody.getHeight();
6948 if(scrollHeight - height == scrollTop) {
6950 var total = this.ds.getTotalCount();
6952 if(this.footer.cursor + this.footer.pageSize < total){
6954 this.footer.ds.load({
6956 start : this.footer.cursor + this.footer.pageSize,
6957 limit : this.footer.pageSize
6967 onHeaderChange : function()
6970 var header = this.renderHeader();
6971 var table = this.el.select('table', true).first();
6973 this.mainHead.remove();
6974 this.mainHead = table.createChild(header, this.mainBody, false);
6989 * @class Roo.bootstrap.TableCell
6990 * @extends Roo.bootstrap.Component
6991 * Bootstrap TableCell class
6992 * @cfg {String} html cell contain text
6993 * @cfg {String} cls cell class
6994 * @cfg {String} tag cell tag (td|th) default td
6995 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6996 * @cfg {String} align Aligns the content in a cell
6997 * @cfg {String} axis Categorizes cells
6998 * @cfg {String} bgcolor Specifies the background color of a cell
6999 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7000 * @cfg {Number} colspan Specifies the number of columns a cell should span
7001 * @cfg {String} headers Specifies one or more header cells a cell is related to
7002 * @cfg {Number} height Sets the height of a cell
7003 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7004 * @cfg {Number} rowspan Sets the number of rows a cell should span
7005 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7006 * @cfg {String} valign Vertical aligns the content in a cell
7007 * @cfg {Number} width Specifies the width of a cell
7010 * Create a new TableCell
7011 * @param {Object} config The config object
7014 Roo.bootstrap.TableCell = function(config){
7015 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7018 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7038 getAutoCreate : function(){
7039 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7059 cfg.align=this.align
7065 cfg.bgcolor=this.bgcolor
7068 cfg.charoff=this.charoff
7071 cfg.colspan=this.colspan
7074 cfg.headers=this.headers
7077 cfg.height=this.height
7080 cfg.nowrap=this.nowrap
7083 cfg.rowspan=this.rowspan
7086 cfg.scope=this.scope
7089 cfg.valign=this.valign
7092 cfg.width=this.width
7111 * @class Roo.bootstrap.TableRow
7112 * @extends Roo.bootstrap.Component
7113 * Bootstrap TableRow class
7114 * @cfg {String} cls row class
7115 * @cfg {String} align Aligns the content in a table row
7116 * @cfg {String} bgcolor Specifies a background color for a table row
7117 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7118 * @cfg {String} valign Vertical aligns the content in a table row
7121 * Create a new TableRow
7122 * @param {Object} config The config object
7125 Roo.bootstrap.TableRow = function(config){
7126 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7129 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7137 getAutoCreate : function(){
7138 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7148 cfg.align = this.align;
7151 cfg.bgcolor = this.bgcolor;
7154 cfg.charoff = this.charoff;
7157 cfg.valign = this.valign;
7175 * @class Roo.bootstrap.TableBody
7176 * @extends Roo.bootstrap.Component
7177 * Bootstrap TableBody class
7178 * @cfg {String} cls element class
7179 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7180 * @cfg {String} align Aligns the content inside the element
7181 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7182 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7185 * Create a new TableBody
7186 * @param {Object} config The config object
7189 Roo.bootstrap.TableBody = function(config){
7190 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7193 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7201 getAutoCreate : function(){
7202 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7216 cfg.align = this.align;
7219 cfg.charoff = this.charoff;
7222 cfg.valign = this.valign;
7229 // initEvents : function()
7236 // this.store = Roo.factory(this.store, Roo.data);
7237 // this.store.on('load', this.onLoad, this);
7239 // this.store.load();
7243 // onLoad: function ()
7245 // this.fireEvent('load', this);
7255 * Ext JS Library 1.1.1
7256 * Copyright(c) 2006-2007, Ext JS, LLC.
7258 * Originally Released Under LGPL - original licence link has changed is not relivant.
7261 * <script type="text/javascript">
7264 // as we use this in bootstrap.
7265 Roo.namespace('Roo.form');
7267 * @class Roo.form.Action
7268 * Internal Class used to handle form actions
7270 * @param {Roo.form.BasicForm} el The form element or its id
7271 * @param {Object} config Configuration options
7276 // define the action interface
7277 Roo.form.Action = function(form, options){
7279 this.options = options || {};
7282 * Client Validation Failed
7285 Roo.form.Action.CLIENT_INVALID = 'client';
7287 * Server Validation Failed
7290 Roo.form.Action.SERVER_INVALID = 'server';
7292 * Connect to Server Failed
7295 Roo.form.Action.CONNECT_FAILURE = 'connect';
7297 * Reading Data from Server Failed
7300 Roo.form.Action.LOAD_FAILURE = 'load';
7302 Roo.form.Action.prototype = {
7304 failureType : undefined,
7305 response : undefined,
7309 run : function(options){
7314 success : function(response){
7319 handleResponse : function(response){
7323 // default connection failure
7324 failure : function(response){
7326 this.response = response;
7327 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7328 this.form.afterAction(this, false);
7331 processResponse : function(response){
7332 this.response = response;
7333 if(!response.responseText){
7336 this.result = this.handleResponse(response);
7340 // utility functions used internally
7341 getUrl : function(appendParams){
7342 var url = this.options.url || this.form.url || this.form.el.dom.action;
7344 var p = this.getParams();
7346 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7352 getMethod : function(){
7353 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7356 getParams : function(){
7357 var bp = this.form.baseParams;
7358 var p = this.options.params;
7360 if(typeof p == "object"){
7361 p = Roo.urlEncode(Roo.applyIf(p, bp));
7362 }else if(typeof p == 'string' && bp){
7363 p += '&' + Roo.urlEncode(bp);
7366 p = Roo.urlEncode(bp);
7371 createCallback : function(){
7373 success: this.success,
7374 failure: this.failure,
7376 timeout: (this.form.timeout*1000),
7377 upload: this.form.fileUpload ? this.success : undefined
7382 Roo.form.Action.Submit = function(form, options){
7383 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7386 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7389 haveProgress : false,
7390 uploadComplete : false,
7392 // uploadProgress indicator.
7393 uploadProgress : function()
7395 if (!this.form.progressUrl) {
7399 if (!this.haveProgress) {
7400 Roo.MessageBox.progress("Uploading", "Uploading");
7402 if (this.uploadComplete) {
7403 Roo.MessageBox.hide();
7407 this.haveProgress = true;
7409 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7411 var c = new Roo.data.Connection();
7413 url : this.form.progressUrl,
7418 success : function(req){
7419 //console.log(data);
7423 rdata = Roo.decode(req.responseText)
7425 Roo.log("Invalid data from server..");
7429 if (!rdata || !rdata.success) {
7431 Roo.MessageBox.alert(Roo.encode(rdata));
7434 var data = rdata.data;
7436 if (this.uploadComplete) {
7437 Roo.MessageBox.hide();
7442 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7443 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7446 this.uploadProgress.defer(2000,this);
7449 failure: function(data) {
7450 Roo.log('progress url failed ');
7461 // run get Values on the form, so it syncs any secondary forms.
7462 this.form.getValues();
7464 var o = this.options;
7465 var method = this.getMethod();
7466 var isPost = method == 'POST';
7467 if(o.clientValidation === false || this.form.isValid()){
7469 if (this.form.progressUrl) {
7470 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7471 (new Date() * 1) + '' + Math.random());
7476 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7477 form:this.form.el.dom,
7478 url:this.getUrl(!isPost),
7480 params:isPost ? this.getParams() : null,
7481 isUpload: this.form.fileUpload
7484 this.uploadProgress();
7486 }else if (o.clientValidation !== false){ // client validation failed
7487 this.failureType = Roo.form.Action.CLIENT_INVALID;
7488 this.form.afterAction(this, false);
7492 success : function(response)
7494 this.uploadComplete= true;
7495 if (this.haveProgress) {
7496 Roo.MessageBox.hide();
7500 var result = this.processResponse(response);
7501 if(result === true || result.success){
7502 this.form.afterAction(this, true);
7506 this.form.markInvalid(result.errors);
7507 this.failureType = Roo.form.Action.SERVER_INVALID;
7509 this.form.afterAction(this, false);
7511 failure : function(response)
7513 this.uploadComplete= true;
7514 if (this.haveProgress) {
7515 Roo.MessageBox.hide();
7518 this.response = response;
7519 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7520 this.form.afterAction(this, false);
7523 handleResponse : function(response){
7524 if(this.form.errorReader){
7525 var rs = this.form.errorReader.read(response);
7528 for(var i = 0, len = rs.records.length; i < len; i++) {
7529 var r = rs.records[i];
7533 if(errors.length < 1){
7537 success : rs.success,
7543 ret = Roo.decode(response.responseText);
7547 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7557 Roo.form.Action.Load = function(form, options){
7558 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7559 this.reader = this.form.reader;
7562 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7567 Roo.Ajax.request(Roo.apply(
7568 this.createCallback(), {
7569 method:this.getMethod(),
7570 url:this.getUrl(false),
7571 params:this.getParams()
7575 success : function(response){
7577 var result = this.processResponse(response);
7578 if(result === true || !result.success || !result.data){
7579 this.failureType = Roo.form.Action.LOAD_FAILURE;
7580 this.form.afterAction(this, false);
7583 this.form.clearInvalid();
7584 this.form.setValues(result.data);
7585 this.form.afterAction(this, true);
7588 handleResponse : function(response){
7589 if(this.form.reader){
7590 var rs = this.form.reader.read(response);
7591 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7593 success : rs.success,
7597 return Roo.decode(response.responseText);
7601 Roo.form.Action.ACTION_TYPES = {
7602 'load' : Roo.form.Action.Load,
7603 'submit' : Roo.form.Action.Submit
7612 * @class Roo.bootstrap.Form
7613 * @extends Roo.bootstrap.Component
7614 * Bootstrap Form class
7615 * @cfg {String} method GET | POST (default POST)
7616 * @cfg {String} labelAlign top | left (default top)
7617 * @cfg {String} align left | right - for navbars
7618 * @cfg {Boolean} loadMask load mask when submit (default true)
7623 * @param {Object} config The config object
7627 Roo.bootstrap.Form = function(config){
7629 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7631 Roo.bootstrap.Form.popover.apply();
7635 * @event clientvalidation
7636 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7637 * @param {Form} this
7638 * @param {Boolean} valid true if the form has passed client-side validation
7640 clientvalidation: true,
7642 * @event beforeaction
7643 * Fires before any action is performed. Return false to cancel the action.
7644 * @param {Form} this
7645 * @param {Action} action The action to be performed
7649 * @event actionfailed
7650 * Fires when an action fails.
7651 * @param {Form} this
7652 * @param {Action} action The action that failed
7654 actionfailed : true,
7656 * @event actioncomplete
7657 * Fires when an action is completed.
7658 * @param {Form} this
7659 * @param {Action} action The action that completed
7661 actioncomplete : true
7665 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7668 * @cfg {String} method
7669 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7674 * The URL to use for form actions if one isn't supplied in the action options.
7677 * @cfg {Boolean} fileUpload
7678 * Set to true if this form is a file upload.
7682 * @cfg {Object} baseParams
7683 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7687 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7691 * @cfg {Sting} align (left|right) for navbar forms
7696 activeAction : null,
7699 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7700 * element by passing it or its id or mask the form itself by passing in true.
7703 waitMsgTarget : false,
7708 * @cfg {Boolean} errorMask (true|false) default false
7713 * @cfg {Number} maskOffset Default 100
7718 * @cfg {Boolean} maskBody
7722 getAutoCreate : function(){
7726 method : this.method || 'POST',
7727 id : this.id || Roo.id(),
7730 if (this.parent().xtype.match(/^Nav/)) {
7731 cfg.cls = 'navbar-form navbar-' + this.align;
7735 if (this.labelAlign == 'left' ) {
7736 cfg.cls += ' form-horizontal';
7742 initEvents : function()
7744 this.el.on('submit', this.onSubmit, this);
7745 // this was added as random key presses on the form where triggering form submit.
7746 this.el.on('keypress', function(e) {
7747 if (e.getCharCode() != 13) {
7750 // we might need to allow it for textareas.. and some other items.
7751 // check e.getTarget().
7753 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7757 Roo.log("keypress blocked");
7765 onSubmit : function(e){
7770 * Returns true if client-side validation on the form is successful.
7773 isValid : function(){
7774 var items = this.getItems();
7778 items.each(function(f){
7784 if(!target && f.el.isVisible(true)){
7790 if(this.errorMask && !valid){
7791 Roo.bootstrap.Form.popover.mask(this, target);
7798 * Returns true if any fields in this form have changed since their original load.
7801 isDirty : function(){
7803 var items = this.getItems();
7804 items.each(function(f){
7814 * Performs a predefined action (submit or load) or custom actions you define on this form.
7815 * @param {String} actionName The name of the action type
7816 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7817 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7818 * accept other config options):
7820 Property Type Description
7821 ---------------- --------------- ----------------------------------------------------------------------------------
7822 url String The url for the action (defaults to the form's url)
7823 method String The form method to use (defaults to the form's method, or POST if not defined)
7824 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7825 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7826 validate the form on the client (defaults to false)
7828 * @return {BasicForm} this
7830 doAction : function(action, options){
7831 if(typeof action == 'string'){
7832 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7834 if(this.fireEvent('beforeaction', this, action) !== false){
7835 this.beforeAction(action);
7836 action.run.defer(100, action);
7842 beforeAction : function(action){
7843 var o = action.options;
7848 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
7850 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7853 // not really supported yet.. ??
7855 //if(this.waitMsgTarget === true){
7856 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7857 //}else if(this.waitMsgTarget){
7858 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7859 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7861 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7867 afterAction : function(action, success){
7868 this.activeAction = null;
7869 var o = action.options;
7874 Roo.get(document.body).unmask();
7880 //if(this.waitMsgTarget === true){
7881 // this.el.unmask();
7882 //}else if(this.waitMsgTarget){
7883 // this.waitMsgTarget.unmask();
7885 // Roo.MessageBox.updateProgress(1);
7886 // Roo.MessageBox.hide();
7893 Roo.callback(o.success, o.scope, [this, action]);
7894 this.fireEvent('actioncomplete', this, action);
7898 // failure condition..
7899 // we have a scenario where updates need confirming.
7900 // eg. if a locking scenario exists..
7901 // we look for { errors : { needs_confirm : true }} in the response.
7903 (typeof(action.result) != 'undefined') &&
7904 (typeof(action.result.errors) != 'undefined') &&
7905 (typeof(action.result.errors.needs_confirm) != 'undefined')
7908 Roo.log("not supported yet");
7911 Roo.MessageBox.confirm(
7912 "Change requires confirmation",
7913 action.result.errorMsg,
7918 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7928 Roo.callback(o.failure, o.scope, [this, action]);
7929 // show an error message if no failed handler is set..
7930 if (!this.hasListener('actionfailed')) {
7931 Roo.log("need to add dialog support");
7933 Roo.MessageBox.alert("Error",
7934 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7935 action.result.errorMsg :
7936 "Saving Failed, please check your entries or try again"
7941 this.fireEvent('actionfailed', this, action);
7946 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7947 * @param {String} id The value to search for
7950 findField : function(id){
7951 var items = this.getItems();
7952 var field = items.get(id);
7954 items.each(function(f){
7955 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7962 return field || null;
7965 * Mark fields in this form invalid in bulk.
7966 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7967 * @return {BasicForm} this
7969 markInvalid : function(errors){
7970 if(errors instanceof Array){
7971 for(var i = 0, len = errors.length; i < len; i++){
7972 var fieldError = errors[i];
7973 var f = this.findField(fieldError.id);
7975 f.markInvalid(fieldError.msg);
7981 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7982 field.markInvalid(errors[id]);
7986 //Roo.each(this.childForms || [], function (f) {
7987 // f.markInvalid(errors);
7994 * Set values for fields in this form in bulk.
7995 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7996 * @return {BasicForm} this
7998 setValues : function(values){
7999 if(values instanceof Array){ // array of objects
8000 for(var i = 0, len = values.length; i < len; i++){
8002 var f = this.findField(v.id);
8004 f.setValue(v.value);
8005 if(this.trackResetOnLoad){
8006 f.originalValue = f.getValue();
8010 }else{ // object hash
8013 if(typeof values[id] != 'function' && (field = this.findField(id))){
8015 if (field.setFromData &&
8017 field.displayField &&
8018 // combos' with local stores can
8019 // be queried via setValue()
8020 // to set their value..
8021 (field.store && !field.store.isLocal)
8025 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8026 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8027 field.setFromData(sd);
8029 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8031 field.setFromData(values);
8034 field.setValue(values[id]);
8038 if(this.trackResetOnLoad){
8039 field.originalValue = field.getValue();
8045 //Roo.each(this.childForms || [], function (f) {
8046 // f.setValues(values);
8053 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8054 * they are returned as an array.
8055 * @param {Boolean} asString
8058 getValues : function(asString){
8059 //if (this.childForms) {
8060 // copy values from the child forms
8061 // Roo.each(this.childForms, function (f) {
8062 // this.setValues(f.getValues());
8068 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8069 if(asString === true){
8072 return Roo.urlDecode(fs);
8076 * Returns the fields in this form as an object with key/value pairs.
8077 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8080 getFieldValues : function(with_hidden)
8082 var items = this.getItems();
8084 items.each(function(f){
8090 var v = f.getValue();
8092 if (f.inputType =='radio') {
8093 if (typeof(ret[f.getName()]) == 'undefined') {
8094 ret[f.getName()] = ''; // empty..
8097 if (!f.el.dom.checked) {
8105 if(f.xtype == 'MoneyField'){
8106 ret[f.currencyName] = f.getCurrency();
8109 // not sure if this supported any more..
8110 if ((typeof(v) == 'object') && f.getRawValue) {
8111 v = f.getRawValue() ; // dates..
8113 // combo boxes where name != hiddenName...
8114 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8115 ret[f.name] = f.getRawValue();
8117 ret[f.getName()] = v;
8124 * Clears all invalid messages in this form.
8125 * @return {BasicForm} this
8127 clearInvalid : function(){
8128 var items = this.getItems();
8130 items.each(function(f){
8139 * @return {BasicForm} this
8142 var items = this.getItems();
8143 items.each(function(f){
8147 Roo.each(this.childForms || [], function (f) {
8155 getItems : function()
8157 var r=new Roo.util.MixedCollection(false, function(o){
8158 return o.id || (o.id = Roo.id());
8160 var iter = function(el) {
8167 Roo.each(el.items,function(e) {
8176 hideFields : function(items)
8178 Roo.each(items, function(i){
8180 var f = this.findField(i);
8186 if(f.xtype == 'DateField'){
8187 f.setVisible(false);
8196 showFields : function(items)
8198 Roo.each(items, function(i){
8200 var f = this.findField(i);
8206 if(f.xtype == 'DateField'){
8218 Roo.apply(Roo.bootstrap.Form, {
8245 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8246 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8247 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8248 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8251 this.maskEl.top.enableDisplayMode("block");
8252 this.maskEl.left.enableDisplayMode("block");
8253 this.maskEl.bottom.enableDisplayMode("block");
8254 this.maskEl.right.enableDisplayMode("block");
8256 this.toolTip = new Roo.bootstrap.Tooltip({
8257 cls : 'roo-form-error-popover',
8259 'left' : ['r-l', [-2,0], 'right'],
8260 'right' : ['l-r', [2,0], 'left'],
8261 'bottom' : ['tl-bl', [0,2], 'top'],
8262 'top' : [ 'bl-tl', [0,-2], 'bottom']
8266 this.toolTip.render(Roo.get(document.body));
8268 this.toolTip.el.enableDisplayMode("block");
8270 Roo.get(document.body).on('click', function(){
8274 Roo.get(document.body).on('touchstart', function(){
8278 this.isApplied = true
8281 mask : function(form, target)
8285 this.target = target;
8287 if(!this.form.errorMask || !target.el){
8291 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8293 Roo.log(scrollable);
8295 var ot = this.target.el.calcOffsetsTo(scrollable);
8297 var scrollTo = ot[1] - this.form.maskOffset;
8299 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8301 scrollable.scrollTo('top', scrollTo);
8303 var box = this.target.el.getBox();
8305 var zIndex = Roo.bootstrap.Modal.zIndex++;
8308 this.maskEl.top.setStyle('position', 'absolute');
8309 this.maskEl.top.setStyle('z-index', zIndex);
8310 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8311 this.maskEl.top.setLeft(0);
8312 this.maskEl.top.setTop(0);
8313 this.maskEl.top.show();
8315 this.maskEl.left.setStyle('position', 'absolute');
8316 this.maskEl.left.setStyle('z-index', zIndex);
8317 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8318 this.maskEl.left.setLeft(0);
8319 this.maskEl.left.setTop(box.y - this.padding);
8320 this.maskEl.left.show();
8322 this.maskEl.bottom.setStyle('position', 'absolute');
8323 this.maskEl.bottom.setStyle('z-index', zIndex);
8324 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8325 this.maskEl.bottom.setLeft(0);
8326 this.maskEl.bottom.setTop(box.bottom + this.padding);
8327 this.maskEl.bottom.show();
8329 this.maskEl.right.setStyle('position', 'absolute');
8330 this.maskEl.right.setStyle('z-index', zIndex);
8331 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8332 this.maskEl.right.setLeft(box.right + this.padding);
8333 this.maskEl.right.setTop(box.y - this.padding);
8334 this.maskEl.right.show();
8336 this.toolTip.bindEl = this.target.el;
8338 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8340 var tip = this.target.blankText;
8342 if(this.target.getValue() !== '' ) {
8344 if (this.target.invalidText.length) {
8345 tip = this.target.invalidText;
8346 } else if (this.target.regexText.length){
8347 tip = this.target.regexText;
8351 this.toolTip.show(tip);
8353 this.intervalID = window.setInterval(function() {
8354 Roo.bootstrap.Form.popover.unmask();
8357 window.onwheel = function(){ return false;};
8359 (function(){ this.isMasked = true; }).defer(500, this);
8365 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8369 this.maskEl.top.setStyle('position', 'absolute');
8370 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8371 this.maskEl.top.hide();
8373 this.maskEl.left.setStyle('position', 'absolute');
8374 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8375 this.maskEl.left.hide();
8377 this.maskEl.bottom.setStyle('position', 'absolute');
8378 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8379 this.maskEl.bottom.hide();
8381 this.maskEl.right.setStyle('position', 'absolute');
8382 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8383 this.maskEl.right.hide();
8385 this.toolTip.hide();
8387 this.toolTip.el.hide();
8389 window.onwheel = function(){ return true;};
8391 if(this.intervalID){
8392 window.clearInterval(this.intervalID);
8393 this.intervalID = false;
8396 this.isMasked = false;
8406 * Ext JS Library 1.1.1
8407 * Copyright(c) 2006-2007, Ext JS, LLC.
8409 * Originally Released Under LGPL - original licence link has changed is not relivant.
8412 * <script type="text/javascript">
8415 * @class Roo.form.VTypes
8416 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8419 Roo.form.VTypes = function(){
8420 // closure these in so they are only created once.
8421 var alpha = /^[a-zA-Z_]+$/;
8422 var alphanum = /^[a-zA-Z0-9_]+$/;
8423 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8424 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8426 // All these messages and functions are configurable
8429 * The function used to validate email addresses
8430 * @param {String} value The email address
8432 'email' : function(v){
8433 return email.test(v);
8436 * The error text to display when the email validation function returns false
8439 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8441 * The keystroke filter mask to be applied on email input
8444 'emailMask' : /[a-z0-9_\.\-@]/i,
8447 * The function used to validate URLs
8448 * @param {String} value The URL
8450 'url' : function(v){
8454 * The error text to display when the url validation function returns false
8457 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8460 * The function used to validate alpha values
8461 * @param {String} value The value
8463 'alpha' : function(v){
8464 return alpha.test(v);
8467 * The error text to display when the alpha validation function returns false
8470 'alphaText' : 'This field should only contain letters and _',
8472 * The keystroke filter mask to be applied on alpha input
8475 'alphaMask' : /[a-z_]/i,
8478 * The function used to validate alphanumeric values
8479 * @param {String} value The value
8481 'alphanum' : function(v){
8482 return alphanum.test(v);
8485 * The error text to display when the alphanumeric validation function returns false
8488 'alphanumText' : 'This field should only contain letters, numbers and _',
8490 * The keystroke filter mask to be applied on alphanumeric input
8493 'alphanumMask' : /[a-z0-9_]/i
8503 * @class Roo.bootstrap.Input
8504 * @extends Roo.bootstrap.Component
8505 * Bootstrap Input class
8506 * @cfg {Boolean} disabled is it disabled
8507 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8508 * @cfg {String} name name of the input
8509 * @cfg {string} fieldLabel - the label associated
8510 * @cfg {string} placeholder - placeholder to put in text.
8511 * @cfg {string} before - input group add on before
8512 * @cfg {string} after - input group add on after
8513 * @cfg {string} size - (lg|sm) or leave empty..
8514 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8515 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8516 * @cfg {Number} md colspan out of 12 for computer-sized screens
8517 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8518 * @cfg {string} value default value of the input
8519 * @cfg {Number} labelWidth set the width of label
8520 * @cfg {Number} labellg set the width of label (1-12)
8521 * @cfg {Number} labelmd set the width of label (1-12)
8522 * @cfg {Number} labelsm set the width of label (1-12)
8523 * @cfg {Number} labelxs set the width of label (1-12)
8524 * @cfg {String} labelAlign (top|left)
8525 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8526 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8527 * @cfg {String} indicatorpos (left|right) default left
8529 * @cfg {String} align (left|center|right) Default left
8530 * @cfg {Boolean} forceFeedback (true|false) Default false
8533 * Create a new Input
8534 * @param {Object} config The config object
8537 Roo.bootstrap.Input = function(config){
8539 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8544 * Fires when this field receives input focus.
8545 * @param {Roo.form.Field} this
8550 * Fires when this field loses input focus.
8551 * @param {Roo.form.Field} this
8556 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8557 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8558 * @param {Roo.form.Field} this
8559 * @param {Roo.EventObject} e The event object
8564 * Fires just before the field blurs if the field value has changed.
8565 * @param {Roo.form.Field} this
8566 * @param {Mixed} newValue The new value
8567 * @param {Mixed} oldValue The original value
8572 * Fires after the field has been marked as invalid.
8573 * @param {Roo.form.Field} this
8574 * @param {String} msg The validation message
8579 * Fires after the field has been validated with no errors.
8580 * @param {Roo.form.Field} this
8585 * Fires after the key up
8586 * @param {Roo.form.Field} this
8587 * @param {Roo.EventObject} e The event Object
8593 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8595 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8596 automatic validation (defaults to "keyup").
8598 validationEvent : "keyup",
8600 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8602 validateOnBlur : true,
8604 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8606 validationDelay : 250,
8608 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8610 focusClass : "x-form-focus", // not needed???
8614 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8616 invalidClass : "has-warning",
8619 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8621 validClass : "has-success",
8624 * @cfg {Boolean} hasFeedback (true|false) default true
8629 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8631 invalidFeedbackClass : "glyphicon-warning-sign",
8634 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8636 validFeedbackClass : "glyphicon-ok",
8639 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8641 selectOnFocus : false,
8644 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8648 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8653 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8655 disableKeyFilter : false,
8658 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8662 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8666 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8668 blankText : "Please complete this mandatory field",
8671 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8675 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8677 maxLength : Number.MAX_VALUE,
8679 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8681 minLengthText : "The minimum length for this field is {0}",
8683 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8685 maxLengthText : "The maximum length for this field is {0}",
8689 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8690 * If available, this function will be called only after the basic validators all return true, and will be passed the
8691 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8695 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8696 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8697 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8701 * @cfg {String} regexText -- Depricated - use Invalid Text
8706 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8712 autocomplete: false,
8731 formatedValue : false,
8732 forceFeedback : false,
8734 indicatorpos : 'left',
8741 parentLabelAlign : function()
8744 while (parent.parent()) {
8745 parent = parent.parent();
8746 if (typeof(parent.labelAlign) !='undefined') {
8747 return parent.labelAlign;
8754 getAutoCreate : function()
8756 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8762 if(this.inputType != 'hidden'){
8763 cfg.cls = 'form-group' //input-group
8769 type : this.inputType,
8771 cls : 'form-control',
8772 placeholder : this.placeholder || '',
8773 autocomplete : this.autocomplete || 'new-password'
8777 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8780 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8781 input.maxLength = this.maxLength;
8784 if (this.disabled) {
8785 input.disabled=true;
8788 if (this.readOnly) {
8789 input.readonly=true;
8793 input.name = this.name;
8797 input.cls += ' input-' + this.size;
8801 ['xs','sm','md','lg'].map(function(size){
8802 if (settings[size]) {
8803 cfg.cls += ' col-' + size + '-' + settings[size];
8807 var inputblock = input;
8811 cls: 'glyphicon form-control-feedback'
8814 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8817 cls : 'has-feedback',
8825 if (this.before || this.after) {
8828 cls : 'input-group',
8832 if (this.before && typeof(this.before) == 'string') {
8834 inputblock.cn.push({
8836 cls : 'roo-input-before input-group-addon',
8840 if (this.before && typeof(this.before) == 'object') {
8841 this.before = Roo.factory(this.before);
8843 inputblock.cn.push({
8845 cls : 'roo-input-before input-group-' +
8846 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8850 inputblock.cn.push(input);
8852 if (this.after && typeof(this.after) == 'string') {
8853 inputblock.cn.push({
8855 cls : 'roo-input-after input-group-addon',
8859 if (this.after && typeof(this.after) == 'object') {
8860 this.after = Roo.factory(this.after);
8862 inputblock.cn.push({
8864 cls : 'roo-input-after input-group-' +
8865 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8869 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8870 inputblock.cls += ' has-feedback';
8871 inputblock.cn.push(feedback);
8875 if (align ==='left' && this.fieldLabel.length) {
8877 cfg.cls += ' roo-form-group-label-left';
8882 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8883 tooltip : 'This field is required'
8888 cls : 'control-label',
8889 html : this.fieldLabel
8900 var labelCfg = cfg.cn[1];
8901 var contentCfg = cfg.cn[2];
8903 if(this.indicatorpos == 'right'){
8908 cls : 'control-label',
8912 html : this.fieldLabel
8916 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8917 tooltip : 'This field is required'
8930 labelCfg = cfg.cn[0];
8931 contentCfg = cfg.cn[1];
8935 if(this.labelWidth > 12){
8936 labelCfg.style = "width: " + this.labelWidth + 'px';
8939 if(this.labelWidth < 13 && this.labelmd == 0){
8940 this.labelmd = this.labelWidth;
8943 if(this.labellg > 0){
8944 labelCfg.cls += ' col-lg-' + this.labellg;
8945 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8948 if(this.labelmd > 0){
8949 labelCfg.cls += ' col-md-' + this.labelmd;
8950 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8953 if(this.labelsm > 0){
8954 labelCfg.cls += ' col-sm-' + this.labelsm;
8955 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8958 if(this.labelxs > 0){
8959 labelCfg.cls += ' col-xs-' + this.labelxs;
8960 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8964 } else if ( this.fieldLabel.length) {
8969 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8970 tooltip : 'This field is required'
8974 //cls : 'input-group-addon',
8975 html : this.fieldLabel
8983 if(this.indicatorpos == 'right'){
8988 //cls : 'input-group-addon',
8989 html : this.fieldLabel
8994 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8995 tooltip : 'This field is required'
9015 if (this.parentType === 'Navbar' && this.parent().bar) {
9016 cfg.cls += ' navbar-form';
9019 if (this.parentType === 'NavGroup') {
9020 cfg.cls += ' navbar-form';
9028 * return the real input element.
9030 inputEl: function ()
9032 return this.el.select('input.form-control',true).first();
9035 tooltipEl : function()
9037 return this.inputEl();
9040 indicatorEl : function()
9042 var indicator = this.el.select('i.roo-required-indicator',true).first();
9052 setDisabled : function(v)
9054 var i = this.inputEl().dom;
9056 i.removeAttribute('disabled');
9060 i.setAttribute('disabled','true');
9062 initEvents : function()
9065 this.inputEl().on("keydown" , this.fireKey, this);
9066 this.inputEl().on("focus", this.onFocus, this);
9067 this.inputEl().on("blur", this.onBlur, this);
9069 this.inputEl().relayEvent('keyup', this);
9071 this.indicator = this.indicatorEl();
9074 this.indicator.addClass('invisible');
9078 // reference to original value for reset
9079 this.originalValue = this.getValue();
9080 //Roo.form.TextField.superclass.initEvents.call(this);
9081 if(this.validationEvent == 'keyup'){
9082 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9083 this.inputEl().on('keyup', this.filterValidation, this);
9085 else if(this.validationEvent !== false){
9086 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9089 if(this.selectOnFocus){
9090 this.on("focus", this.preFocus, this);
9093 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9094 this.inputEl().on("keypress", this.filterKeys, this);
9096 this.inputEl().relayEvent('keypress', this);
9099 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9100 this.el.on("click", this.autoSize, this);
9103 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9104 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9107 if (typeof(this.before) == 'object') {
9108 this.before.render(this.el.select('.roo-input-before',true).first());
9110 if (typeof(this.after) == 'object') {
9111 this.after.render(this.el.select('.roo-input-after',true).first());
9116 filterValidation : function(e){
9117 if(!e.isNavKeyPress()){
9118 this.validationTask.delay(this.validationDelay);
9122 * Validates the field value
9123 * @return {Boolean} True if the value is valid, else false
9125 validate : function(){
9126 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9127 if(this.disabled || this.validateValue(this.getRawValue())){
9138 * Validates a value according to the field's validation rules and marks the field as invalid
9139 * if the validation fails
9140 * @param {Mixed} value The value to validate
9141 * @return {Boolean} True if the value is valid, else false
9143 validateValue : function(value)
9145 if(this.getEl().hasClass('hidden') || !this.inputEl().isVisible(true)){
9149 if(value.length < 1) { // if it's blank
9150 if(this.allowBlank){
9156 if(value.length < this.minLength){
9159 if(value.length > this.maxLength){
9163 var vt = Roo.form.VTypes;
9164 if(!vt[this.vtype](value, this)){
9168 if(typeof this.validator == "function"){
9169 var msg = this.validator(value);
9173 if (typeof(msg) == 'string') {
9174 this.invalidText = msg;
9178 if(this.regex && !this.regex.test(value)){
9186 fireKey : function(e){
9187 //Roo.log('field ' + e.getKey());
9188 if(e.isNavKeyPress()){
9189 this.fireEvent("specialkey", this, e);
9192 focus : function (selectText){
9194 this.inputEl().focus();
9195 if(selectText === true){
9196 this.inputEl().dom.select();
9202 onFocus : function(){
9203 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9204 // this.el.addClass(this.focusClass);
9207 this.hasFocus = true;
9208 this.startValue = this.getValue();
9209 this.fireEvent("focus", this);
9213 beforeBlur : Roo.emptyFn,
9217 onBlur : function(){
9219 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9220 //this.el.removeClass(this.focusClass);
9222 this.hasFocus = false;
9223 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9226 var v = this.getValue();
9227 if(String(v) !== String(this.startValue)){
9228 this.fireEvent('change', this, v, this.startValue);
9230 this.fireEvent("blur", this);
9234 * Resets the current field value to the originally loaded value and clears any validation messages
9237 this.setValue(this.originalValue);
9241 * Returns the name of the field
9242 * @return {Mixed} name The name field
9244 getName: function(){
9248 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9249 * @return {Mixed} value The field value
9251 getValue : function(){
9253 var v = this.inputEl().getValue();
9258 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9259 * @return {Mixed} value The field value
9261 getRawValue : function(){
9262 var v = this.inputEl().getValue();
9268 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9269 * @param {Mixed} value The value to set
9271 setRawValue : function(v){
9272 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9275 selectText : function(start, end){
9276 var v = this.getRawValue();
9278 start = start === undefined ? 0 : start;
9279 end = end === undefined ? v.length : end;
9280 var d = this.inputEl().dom;
9281 if(d.setSelectionRange){
9282 d.setSelectionRange(start, end);
9283 }else if(d.createTextRange){
9284 var range = d.createTextRange();
9285 range.moveStart("character", start);
9286 range.moveEnd("character", v.length-end);
9293 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9294 * @param {Mixed} value The value to set
9296 setValue : function(v){
9299 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9305 processValue : function(value){
9306 if(this.stripCharsRe){
9307 var newValue = value.replace(this.stripCharsRe, '');
9308 if(newValue !== value){
9309 this.setRawValue(newValue);
9316 preFocus : function(){
9318 if(this.selectOnFocus){
9319 this.inputEl().dom.select();
9322 filterKeys : function(e){
9324 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9327 var c = e.getCharCode(), cc = String.fromCharCode(c);
9328 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9331 if(!this.maskRe.test(cc)){
9336 * Clear any invalid styles/messages for this field
9338 clearInvalid : function(){
9340 if(!this.el || this.preventMark){ // not rendered
9345 this.el.removeClass(this.invalidClass);
9347 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9349 var feedback = this.el.select('.form-control-feedback', true).first();
9352 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9357 this.fireEvent('valid', this);
9361 * Mark this field as valid
9363 markValid : function()
9365 if(!this.el || this.preventMark){ // not rendered...
9369 this.el.removeClass([this.invalidClass, this.validClass]);
9371 var feedback = this.el.select('.form-control-feedback', true).first();
9374 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9378 this.indicator.removeClass('visible');
9379 this.indicator.addClass('invisible');
9386 if(this.allowBlank && !this.getRawValue().length){
9390 this.el.addClass(this.validClass);
9392 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9394 var feedback = this.el.select('.form-control-feedback', true).first();
9397 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9398 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9403 this.fireEvent('valid', this);
9407 * Mark this field as invalid
9408 * @param {String} msg The validation message
9410 markInvalid : function(msg)
9412 if(!this.el || this.preventMark){ // not rendered
9416 this.el.removeClass([this.invalidClass, this.validClass]);
9418 var feedback = this.el.select('.form-control-feedback', true).first();
9421 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9428 if(this.allowBlank && !this.getRawValue().length){
9433 this.indicator.removeClass('invisible');
9434 this.indicator.addClass('visible');
9437 this.el.addClass(this.invalidClass);
9439 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9441 var feedback = this.el.select('.form-control-feedback', true).first();
9444 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9446 if(this.getValue().length || this.forceFeedback){
9447 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9454 this.fireEvent('invalid', this, msg);
9457 SafariOnKeyDown : function(event)
9459 // this is a workaround for a password hang bug on chrome/ webkit.
9460 if (this.inputEl().dom.type != 'password') {
9464 var isSelectAll = false;
9466 if(this.inputEl().dom.selectionEnd > 0){
9467 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9469 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9470 event.preventDefault();
9475 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9477 event.preventDefault();
9478 // this is very hacky as keydown always get's upper case.
9480 var cc = String.fromCharCode(event.getCharCode());
9481 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9485 adjustWidth : function(tag, w){
9486 tag = tag.toLowerCase();
9487 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9488 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9492 if(tag == 'textarea'){
9495 }else if(Roo.isOpera){
9499 if(tag == 'textarea'){
9507 setFieldLabel : function(v)
9514 var ar = this.el.select('label > span',true);
9516 if (ar.elements.length) {
9517 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9518 this.fieldLabel = v;
9522 var br = this.el.select('label',true);
9524 if(br.elements.length) {
9525 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9526 this.fieldLabel = v;
9530 Roo.log('Cannot Found any of label > span || label in input');
9534 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9535 this.fieldLabel = v;
9550 * @class Roo.bootstrap.TextArea
9551 * @extends Roo.bootstrap.Input
9552 * Bootstrap TextArea class
9553 * @cfg {Number} cols Specifies the visible width of a text area
9554 * @cfg {Number} rows Specifies the visible number of lines in a text area
9555 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9556 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9557 * @cfg {string} html text
9560 * Create a new TextArea
9561 * @param {Object} config The config object
9564 Roo.bootstrap.TextArea = function(config){
9565 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9569 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9579 getAutoCreate : function(){
9581 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9587 if(this.inputType != 'hidden'){
9588 cfg.cls = 'form-group' //input-group
9596 value : this.value || '',
9597 html: this.html || '',
9598 cls : 'form-control',
9599 placeholder : this.placeholder || ''
9603 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9604 input.maxLength = this.maxLength;
9608 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9612 input.cols = this.cols;
9615 if (this.readOnly) {
9616 input.readonly = true;
9620 input.name = this.name;
9624 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9628 ['xs','sm','md','lg'].map(function(size){
9629 if (settings[size]) {
9630 cfg.cls += ' col-' + size + '-' + settings[size];
9634 var inputblock = input;
9636 if(this.hasFeedback && !this.allowBlank){
9640 cls: 'glyphicon form-control-feedback'
9644 cls : 'has-feedback',
9653 if (this.before || this.after) {
9656 cls : 'input-group',
9660 inputblock.cn.push({
9662 cls : 'input-group-addon',
9667 inputblock.cn.push(input);
9669 if(this.hasFeedback && !this.allowBlank){
9670 inputblock.cls += ' has-feedback';
9671 inputblock.cn.push(feedback);
9675 inputblock.cn.push({
9677 cls : 'input-group-addon',
9684 if (align ==='left' && this.fieldLabel.length) {
9689 cls : 'control-label',
9690 html : this.fieldLabel
9701 if(this.labelWidth > 12){
9702 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9705 if(this.labelWidth < 13 && this.labelmd == 0){
9706 this.labelmd = this.labelWidth;
9709 if(this.labellg > 0){
9710 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9711 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9714 if(this.labelmd > 0){
9715 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9716 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9719 if(this.labelsm > 0){
9720 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9721 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9724 if(this.labelxs > 0){
9725 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9726 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9729 } else if ( this.fieldLabel.length) {
9734 //cls : 'input-group-addon',
9735 html : this.fieldLabel
9753 if (this.disabled) {
9754 input.disabled=true;
9761 * return the real textarea element.
9763 inputEl: function ()
9765 return this.el.select('textarea.form-control',true).first();
9769 * Clear any invalid styles/messages for this field
9771 clearInvalid : function()
9774 if(!this.el || this.preventMark){ // not rendered
9778 var label = this.el.select('label', true).first();
9779 var icon = this.el.select('i.fa-star', true).first();
9785 this.el.removeClass(this.invalidClass);
9787 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9789 var feedback = this.el.select('.form-control-feedback', true).first();
9792 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9797 this.fireEvent('valid', this);
9801 * Mark this field as valid
9803 markValid : function()
9805 if(!this.el || this.preventMark){ // not rendered
9809 this.el.removeClass([this.invalidClass, this.validClass]);
9811 var feedback = this.el.select('.form-control-feedback', true).first();
9814 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9817 if(this.disabled || this.allowBlank){
9821 var label = this.el.select('label', true).first();
9822 var icon = this.el.select('i.fa-star', true).first();
9828 this.el.addClass(this.validClass);
9830 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9832 var feedback = this.el.select('.form-control-feedback', true).first();
9835 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9836 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9841 this.fireEvent('valid', this);
9845 * Mark this field as invalid
9846 * @param {String} msg The validation message
9848 markInvalid : function(msg)
9850 if(!this.el || this.preventMark){ // not rendered
9854 this.el.removeClass([this.invalidClass, this.validClass]);
9856 var feedback = this.el.select('.form-control-feedback', true).first();
9859 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9862 if(this.disabled || this.allowBlank){
9866 var label = this.el.select('label', true).first();
9867 var icon = this.el.select('i.fa-star', true).first();
9869 if(!this.getValue().length && label && !icon){
9870 this.el.createChild({
9872 cls : 'text-danger fa fa-lg fa-star',
9873 tooltip : 'This field is required',
9874 style : 'margin-right:5px;'
9878 this.el.addClass(this.invalidClass);
9880 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9882 var feedback = this.el.select('.form-control-feedback', true).first();
9885 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9887 if(this.getValue().length || this.forceFeedback){
9888 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9895 this.fireEvent('invalid', this, msg);
9903 * trigger field - base class for combo..
9908 * @class Roo.bootstrap.TriggerField
9909 * @extends Roo.bootstrap.Input
9910 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9911 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9912 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9913 * for which you can provide a custom implementation. For example:
9915 var trigger = new Roo.bootstrap.TriggerField();
9916 trigger.onTriggerClick = myTriggerFn;
9917 trigger.applyTo('my-field');
9920 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9921 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9922 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9923 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9924 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9927 * Create a new TriggerField.
9928 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9929 * to the base TextField)
9931 Roo.bootstrap.TriggerField = function(config){
9932 this.mimicing = false;
9933 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9936 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9938 * @cfg {String} triggerClass A CSS class to apply to the trigger
9941 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9946 * @cfg {Boolean} removable (true|false) special filter default false
9950 /** @cfg {Boolean} grow @hide */
9951 /** @cfg {Number} growMin @hide */
9952 /** @cfg {Number} growMax @hide */
9958 autoSize: Roo.emptyFn,
9965 actionMode : 'wrap',
9970 getAutoCreate : function(){
9972 var align = this.labelAlign || this.parentLabelAlign();
9977 cls: 'form-group' //input-group
9984 type : this.inputType,
9985 cls : 'form-control',
9986 autocomplete: 'new-password',
9987 placeholder : this.placeholder || ''
9991 input.name = this.name;
9994 input.cls += ' input-' + this.size;
9997 if (this.disabled) {
9998 input.disabled=true;
10001 var inputblock = input;
10003 if(this.hasFeedback && !this.allowBlank){
10007 cls: 'glyphicon form-control-feedback'
10010 if(this.removable && !this.editable && !this.tickable){
10012 cls : 'has-feedback',
10018 cls : 'roo-combo-removable-btn close'
10025 cls : 'has-feedback',
10034 if(this.removable && !this.editable && !this.tickable){
10036 cls : 'roo-removable',
10042 cls : 'roo-combo-removable-btn close'
10049 if (this.before || this.after) {
10052 cls : 'input-group',
10056 inputblock.cn.push({
10058 cls : 'input-group-addon',
10063 inputblock.cn.push(input);
10065 if(this.hasFeedback && !this.allowBlank){
10066 inputblock.cls += ' has-feedback';
10067 inputblock.cn.push(feedback);
10071 inputblock.cn.push({
10073 cls : 'input-group-addon',
10086 cls: 'form-hidden-field'
10100 cls: 'form-hidden-field'
10104 cls: 'roo-select2-choices',
10108 cls: 'roo-select2-search-field',
10121 cls: 'roo-select2-container input-group',
10126 // cls: 'typeahead typeahead-long dropdown-menu',
10127 // style: 'display:none'
10132 if(!this.multiple && this.showToggleBtn){
10138 if (this.caret != false) {
10141 cls: 'fa fa-' + this.caret
10148 cls : 'input-group-addon btn dropdown-toggle',
10153 cls: 'combobox-clear',
10167 combobox.cls += ' roo-select2-container-multi';
10170 if (align ==='left' && this.fieldLabel.length) {
10172 cfg.cls += ' roo-form-group-label-left';
10177 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10178 tooltip : 'This field is required'
10183 cls : 'control-label',
10184 html : this.fieldLabel
10196 var labelCfg = cfg.cn[1];
10197 var contentCfg = cfg.cn[2];
10199 if(this.indicatorpos == 'right'){
10204 cls : 'control-label',
10208 html : this.fieldLabel
10212 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10213 tooltip : 'This field is required'
10226 labelCfg = cfg.cn[0];
10227 contentCfg = cfg.cn[1];
10230 if(this.labelWidth > 12){
10231 labelCfg.style = "width: " + this.labelWidth + 'px';
10234 if(this.labelWidth < 13 && this.labelmd == 0){
10235 this.labelmd = this.labelWidth;
10238 if(this.labellg > 0){
10239 labelCfg.cls += ' col-lg-' + this.labellg;
10240 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10243 if(this.labelmd > 0){
10244 labelCfg.cls += ' col-md-' + this.labelmd;
10245 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10248 if(this.labelsm > 0){
10249 labelCfg.cls += ' col-sm-' + this.labelsm;
10250 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10253 if(this.labelxs > 0){
10254 labelCfg.cls += ' col-xs-' + this.labelxs;
10255 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10258 } else if ( this.fieldLabel.length) {
10259 // Roo.log(" label");
10263 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10264 tooltip : 'This field is required'
10268 //cls : 'input-group-addon',
10269 html : this.fieldLabel
10277 if(this.indicatorpos == 'right'){
10285 html : this.fieldLabel
10289 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10290 tooltip : 'This field is required'
10303 // Roo.log(" no label && no align");
10310 ['xs','sm','md','lg'].map(function(size){
10311 if (settings[size]) {
10312 cfg.cls += ' col-' + size + '-' + settings[size];
10323 onResize : function(w, h){
10324 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10325 // if(typeof w == 'number'){
10326 // var x = w - this.trigger.getWidth();
10327 // this.inputEl().setWidth(this.adjustWidth('input', x));
10328 // this.trigger.setStyle('left', x+'px');
10333 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10336 getResizeEl : function(){
10337 return this.inputEl();
10341 getPositionEl : function(){
10342 return this.inputEl();
10346 alignErrorIcon : function(){
10347 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10351 initEvents : function(){
10355 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10356 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10357 if(!this.multiple && this.showToggleBtn){
10358 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10359 if(this.hideTrigger){
10360 this.trigger.setDisplayed(false);
10362 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10366 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10369 if(this.removable && !this.editable && !this.tickable){
10370 var close = this.closeTriggerEl();
10373 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10374 close.on('click', this.removeBtnClick, this, close);
10378 //this.trigger.addClassOnOver('x-form-trigger-over');
10379 //this.trigger.addClassOnClick('x-form-trigger-click');
10382 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10386 closeTriggerEl : function()
10388 var close = this.el.select('.roo-combo-removable-btn', true).first();
10389 return close ? close : false;
10392 removeBtnClick : function(e, h, el)
10394 e.preventDefault();
10396 if(this.fireEvent("remove", this) !== false){
10398 this.fireEvent("afterremove", this)
10402 createList : function()
10404 this.list = Roo.get(document.body).createChild({
10406 cls: 'typeahead typeahead-long dropdown-menu',
10407 style: 'display:none'
10410 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10415 initTrigger : function(){
10420 onDestroy : function(){
10422 this.trigger.removeAllListeners();
10423 // this.trigger.remove();
10426 // this.wrap.remove();
10428 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10432 onFocus : function(){
10433 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10435 if(!this.mimicing){
10436 this.wrap.addClass('x-trigger-wrap-focus');
10437 this.mimicing = true;
10438 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10439 if(this.monitorTab){
10440 this.el.on("keydown", this.checkTab, this);
10447 checkTab : function(e){
10448 if(e.getKey() == e.TAB){
10449 this.triggerBlur();
10454 onBlur : function(){
10459 mimicBlur : function(e, t){
10461 if(!this.wrap.contains(t) && this.validateBlur()){
10462 this.triggerBlur();
10468 triggerBlur : function(){
10469 this.mimicing = false;
10470 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10471 if(this.monitorTab){
10472 this.el.un("keydown", this.checkTab, this);
10474 //this.wrap.removeClass('x-trigger-wrap-focus');
10475 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10479 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10480 validateBlur : function(e, t){
10485 onDisable : function(){
10486 this.inputEl().dom.disabled = true;
10487 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10489 // this.wrap.addClass('x-item-disabled');
10494 onEnable : function(){
10495 this.inputEl().dom.disabled = false;
10496 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10498 // this.el.removeClass('x-item-disabled');
10503 onShow : function(){
10504 var ae = this.getActionEl();
10507 ae.dom.style.display = '';
10508 ae.dom.style.visibility = 'visible';
10514 onHide : function(){
10515 var ae = this.getActionEl();
10516 ae.dom.style.display = 'none';
10520 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10521 * by an implementing function.
10523 * @param {EventObject} e
10525 onTriggerClick : Roo.emptyFn
10529 * Ext JS Library 1.1.1
10530 * Copyright(c) 2006-2007, Ext JS, LLC.
10532 * Originally Released Under LGPL - original licence link has changed is not relivant.
10535 * <script type="text/javascript">
10540 * @class Roo.data.SortTypes
10542 * Defines the default sorting (casting?) comparison functions used when sorting data.
10544 Roo.data.SortTypes = {
10546 * Default sort that does nothing
10547 * @param {Mixed} s The value being converted
10548 * @return {Mixed} The comparison value
10550 none : function(s){
10555 * The regular expression used to strip tags
10559 stripTagsRE : /<\/?[^>]+>/gi,
10562 * Strips all HTML tags to sort on text only
10563 * @param {Mixed} s The value being converted
10564 * @return {String} The comparison value
10566 asText : function(s){
10567 return String(s).replace(this.stripTagsRE, "");
10571 * Strips all HTML tags to sort on text only - Case insensitive
10572 * @param {Mixed} s The value being converted
10573 * @return {String} The comparison value
10575 asUCText : function(s){
10576 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10580 * Case insensitive string
10581 * @param {Mixed} s The value being converted
10582 * @return {String} The comparison value
10584 asUCString : function(s) {
10585 return String(s).toUpperCase();
10590 * @param {Mixed} s The value being converted
10591 * @return {Number} The comparison value
10593 asDate : function(s) {
10597 if(s instanceof Date){
10598 return s.getTime();
10600 return Date.parse(String(s));
10605 * @param {Mixed} s The value being converted
10606 * @return {Float} The comparison value
10608 asFloat : function(s) {
10609 var val = parseFloat(String(s).replace(/,/g, ""));
10618 * @param {Mixed} s The value being converted
10619 * @return {Number} The comparison value
10621 asInt : function(s) {
10622 var val = parseInt(String(s).replace(/,/g, ""));
10630 * Ext JS Library 1.1.1
10631 * Copyright(c) 2006-2007, Ext JS, LLC.
10633 * Originally Released Under LGPL - original licence link has changed is not relivant.
10636 * <script type="text/javascript">
10640 * @class Roo.data.Record
10641 * Instances of this class encapsulate both record <em>definition</em> information, and record
10642 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10643 * to access Records cached in an {@link Roo.data.Store} object.<br>
10645 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10646 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10649 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10651 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10652 * {@link #create}. The parameters are the same.
10653 * @param {Array} data An associative Array of data values keyed by the field name.
10654 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10655 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10656 * not specified an integer id is generated.
10658 Roo.data.Record = function(data, id){
10659 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10664 * Generate a constructor for a specific record layout.
10665 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10666 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10667 * Each field definition object may contain the following properties: <ul>
10668 * <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,
10669 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10670 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10671 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10672 * is being used, then this is a string containing the javascript expression to reference the data relative to
10673 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10674 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10675 * this may be omitted.</p></li>
10676 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10677 * <ul><li>auto (Default, implies no conversion)</li>
10682 * <li>date</li></ul></p></li>
10683 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10684 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10685 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10686 * by the Reader into an object that will be stored in the Record. It is passed the
10687 * following parameters:<ul>
10688 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10690 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10692 * <br>usage:<br><pre><code>
10693 var TopicRecord = Roo.data.Record.create(
10694 {name: 'title', mapping: 'topic_title'},
10695 {name: 'author', mapping: 'username'},
10696 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10697 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10698 {name: 'lastPoster', mapping: 'user2'},
10699 {name: 'excerpt', mapping: 'post_text'}
10702 var myNewRecord = new TopicRecord({
10703 title: 'Do my job please',
10706 lastPost: new Date(),
10707 lastPoster: 'Animal',
10708 excerpt: 'No way dude!'
10710 myStore.add(myNewRecord);
10715 Roo.data.Record.create = function(o){
10716 var f = function(){
10717 f.superclass.constructor.apply(this, arguments);
10719 Roo.extend(f, Roo.data.Record);
10720 var p = f.prototype;
10721 p.fields = new Roo.util.MixedCollection(false, function(field){
10724 for(var i = 0, len = o.length; i < len; i++){
10725 p.fields.add(new Roo.data.Field(o[i]));
10727 f.getField = function(name){
10728 return p.fields.get(name);
10733 Roo.data.Record.AUTO_ID = 1000;
10734 Roo.data.Record.EDIT = 'edit';
10735 Roo.data.Record.REJECT = 'reject';
10736 Roo.data.Record.COMMIT = 'commit';
10738 Roo.data.Record.prototype = {
10740 * Readonly flag - true if this record has been modified.
10749 join : function(store){
10750 this.store = store;
10754 * Set the named field to the specified value.
10755 * @param {String} name The name of the field to set.
10756 * @param {Object} value The value to set the field to.
10758 set : function(name, value){
10759 if(this.data[name] == value){
10763 if(!this.modified){
10764 this.modified = {};
10766 if(typeof this.modified[name] == 'undefined'){
10767 this.modified[name] = this.data[name];
10769 this.data[name] = value;
10770 if(!this.editing && this.store){
10771 this.store.afterEdit(this);
10776 * Get the value of the named field.
10777 * @param {String} name The name of the field to get the value of.
10778 * @return {Object} The value of the field.
10780 get : function(name){
10781 return this.data[name];
10785 beginEdit : function(){
10786 this.editing = true;
10787 this.modified = {};
10791 cancelEdit : function(){
10792 this.editing = false;
10793 delete this.modified;
10797 endEdit : function(){
10798 this.editing = false;
10799 if(this.dirty && this.store){
10800 this.store.afterEdit(this);
10805 * Usually called by the {@link Roo.data.Store} which owns the Record.
10806 * Rejects all changes made to the Record since either creation, or the last commit operation.
10807 * Modified fields are reverted to their original values.
10809 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10810 * of reject operations.
10812 reject : function(){
10813 var m = this.modified;
10815 if(typeof m[n] != "function"){
10816 this.data[n] = m[n];
10819 this.dirty = false;
10820 delete this.modified;
10821 this.editing = false;
10823 this.store.afterReject(this);
10828 * Usually called by the {@link Roo.data.Store} which owns the Record.
10829 * Commits all changes made to the Record since either creation, or the last commit operation.
10831 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10832 * of commit operations.
10834 commit : function(){
10835 this.dirty = false;
10836 delete this.modified;
10837 this.editing = false;
10839 this.store.afterCommit(this);
10844 hasError : function(){
10845 return this.error != null;
10849 clearError : function(){
10854 * Creates a copy of this record.
10855 * @param {String} id (optional) A new record id if you don't want to use this record's id
10858 copy : function(newId) {
10859 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10863 * Ext JS Library 1.1.1
10864 * Copyright(c) 2006-2007, Ext JS, LLC.
10866 * Originally Released Under LGPL - original licence link has changed is not relivant.
10869 * <script type="text/javascript">
10875 * @class Roo.data.Store
10876 * @extends Roo.util.Observable
10877 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10878 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10880 * 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
10881 * has no knowledge of the format of the data returned by the Proxy.<br>
10883 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10884 * instances from the data object. These records are cached and made available through accessor functions.
10886 * Creates a new Store.
10887 * @param {Object} config A config object containing the objects needed for the Store to access data,
10888 * and read the data into Records.
10890 Roo.data.Store = function(config){
10891 this.data = new Roo.util.MixedCollection(false);
10892 this.data.getKey = function(o){
10895 this.baseParams = {};
10897 this.paramNames = {
10902 "multisort" : "_multisort"
10905 if(config && config.data){
10906 this.inlineData = config.data;
10907 delete config.data;
10910 Roo.apply(this, config);
10912 if(this.reader){ // reader passed
10913 this.reader = Roo.factory(this.reader, Roo.data);
10914 this.reader.xmodule = this.xmodule || false;
10915 if(!this.recordType){
10916 this.recordType = this.reader.recordType;
10918 if(this.reader.onMetaChange){
10919 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10923 if(this.recordType){
10924 this.fields = this.recordType.prototype.fields;
10926 this.modified = [];
10930 * @event datachanged
10931 * Fires when the data cache has changed, and a widget which is using this Store
10932 * as a Record cache should refresh its view.
10933 * @param {Store} this
10935 datachanged : true,
10937 * @event metachange
10938 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10939 * @param {Store} this
10940 * @param {Object} meta The JSON metadata
10945 * Fires when Records have been added to the Store
10946 * @param {Store} this
10947 * @param {Roo.data.Record[]} records The array of Records added
10948 * @param {Number} index The index at which the record(s) were added
10953 * Fires when a Record has been removed from the Store
10954 * @param {Store} this
10955 * @param {Roo.data.Record} record The Record that was removed
10956 * @param {Number} index The index at which the record was removed
10961 * Fires when a Record has been updated
10962 * @param {Store} this
10963 * @param {Roo.data.Record} record The Record that was updated
10964 * @param {String} operation The update operation being performed. Value may be one of:
10966 Roo.data.Record.EDIT
10967 Roo.data.Record.REJECT
10968 Roo.data.Record.COMMIT
10974 * Fires when the data cache has been cleared.
10975 * @param {Store} this
10979 * @event beforeload
10980 * Fires before a request is made for a new data object. If the beforeload handler returns false
10981 * the load action will be canceled.
10982 * @param {Store} this
10983 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10987 * @event beforeloadadd
10988 * Fires after a new set of Records has been loaded.
10989 * @param {Store} this
10990 * @param {Roo.data.Record[]} records The Records that were loaded
10991 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10993 beforeloadadd : true,
10996 * Fires after a new set of Records has been loaded, before they are added to the store.
10997 * @param {Store} this
10998 * @param {Roo.data.Record[]} records The Records that were loaded
10999 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11000 * @params {Object} return from reader
11004 * @event loadexception
11005 * Fires if an exception occurs in the Proxy during loading.
11006 * Called with the signature of the Proxy's "loadexception" event.
11007 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11010 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11011 * @param {Object} load options
11012 * @param {Object} jsonData from your request (normally this contains the Exception)
11014 loadexception : true
11018 this.proxy = Roo.factory(this.proxy, Roo.data);
11019 this.proxy.xmodule = this.xmodule || false;
11020 this.relayEvents(this.proxy, ["loadexception"]);
11022 this.sortToggle = {};
11023 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11025 Roo.data.Store.superclass.constructor.call(this);
11027 if(this.inlineData){
11028 this.loadData(this.inlineData);
11029 delete this.inlineData;
11033 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11035 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11036 * without a remote query - used by combo/forms at present.
11040 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11043 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11046 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11047 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11050 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11051 * on any HTTP request
11054 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11057 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11061 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11062 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11064 remoteSort : false,
11067 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11068 * loaded or when a record is removed. (defaults to false).
11070 pruneModifiedRecords : false,
11073 lastOptions : null,
11076 * Add Records to the Store and fires the add event.
11077 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11079 add : function(records){
11080 records = [].concat(records);
11081 for(var i = 0, len = records.length; i < len; i++){
11082 records[i].join(this);
11084 var index = this.data.length;
11085 this.data.addAll(records);
11086 this.fireEvent("add", this, records, index);
11090 * Remove a Record from the Store and fires the remove event.
11091 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11093 remove : function(record){
11094 var index = this.data.indexOf(record);
11095 this.data.removeAt(index);
11096 if(this.pruneModifiedRecords){
11097 this.modified.remove(record);
11099 this.fireEvent("remove", this, record, index);
11103 * Remove all Records from the Store and fires the clear event.
11105 removeAll : function(){
11107 if(this.pruneModifiedRecords){
11108 this.modified = [];
11110 this.fireEvent("clear", this);
11114 * Inserts Records to the Store at the given index and fires the add event.
11115 * @param {Number} index The start index at which to insert the passed Records.
11116 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11118 insert : function(index, records){
11119 records = [].concat(records);
11120 for(var i = 0, len = records.length; i < len; i++){
11121 this.data.insert(index, records[i]);
11122 records[i].join(this);
11124 this.fireEvent("add", this, records, index);
11128 * Get the index within the cache of the passed Record.
11129 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11130 * @return {Number} The index of the passed Record. Returns -1 if not found.
11132 indexOf : function(record){
11133 return this.data.indexOf(record);
11137 * Get the index within the cache of the Record with the passed id.
11138 * @param {String} id The id of the Record to find.
11139 * @return {Number} The index of the Record. Returns -1 if not found.
11141 indexOfId : function(id){
11142 return this.data.indexOfKey(id);
11146 * Get the Record with the specified id.
11147 * @param {String} id The id of the Record to find.
11148 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11150 getById : function(id){
11151 return this.data.key(id);
11155 * Get the Record at the specified index.
11156 * @param {Number} index The index of the Record to find.
11157 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11159 getAt : function(index){
11160 return this.data.itemAt(index);
11164 * Returns a range of Records between specified indices.
11165 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11166 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11167 * @return {Roo.data.Record[]} An array of Records
11169 getRange : function(start, end){
11170 return this.data.getRange(start, end);
11174 storeOptions : function(o){
11175 o = Roo.apply({}, o);
11178 this.lastOptions = o;
11182 * Loads the Record cache from the configured Proxy using the configured Reader.
11184 * If using remote paging, then the first load call must specify the <em>start</em>
11185 * and <em>limit</em> properties in the options.params property to establish the initial
11186 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11188 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11189 * and this call will return before the new data has been loaded. Perform any post-processing
11190 * in a callback function, or in a "load" event handler.</strong>
11192 * @param {Object} options An object containing properties which control loading options:<ul>
11193 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11194 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11195 * passed the following arguments:<ul>
11196 * <li>r : Roo.data.Record[]</li>
11197 * <li>options: Options object from the load call</li>
11198 * <li>success: Boolean success indicator</li></ul></li>
11199 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11200 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11203 load : function(options){
11204 options = options || {};
11205 if(this.fireEvent("beforeload", this, options) !== false){
11206 this.storeOptions(options);
11207 var p = Roo.apply(options.params || {}, this.baseParams);
11208 // if meta was not loaded from remote source.. try requesting it.
11209 if (!this.reader.metaFromRemote) {
11210 p._requestMeta = 1;
11212 if(this.sortInfo && this.remoteSort){
11213 var pn = this.paramNames;
11214 p[pn["sort"]] = this.sortInfo.field;
11215 p[pn["dir"]] = this.sortInfo.direction;
11217 if (this.multiSort) {
11218 var pn = this.paramNames;
11219 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11222 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11227 * Reloads the Record cache from the configured Proxy using the configured Reader and
11228 * the options from the last load operation performed.
11229 * @param {Object} options (optional) An object containing properties which may override the options
11230 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11231 * the most recently used options are reused).
11233 reload : function(options){
11234 this.load(Roo.applyIf(options||{}, this.lastOptions));
11238 // Called as a callback by the Reader during a load operation.
11239 loadRecords : function(o, options, success){
11240 if(!o || success === false){
11241 if(success !== false){
11242 this.fireEvent("load", this, [], options, o);
11244 if(options.callback){
11245 options.callback.call(options.scope || this, [], options, false);
11249 // if data returned failure - throw an exception.
11250 if (o.success === false) {
11251 // show a message if no listener is registered.
11252 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11253 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11255 // loadmask wil be hooked into this..
11256 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11259 var r = o.records, t = o.totalRecords || r.length;
11261 this.fireEvent("beforeloadadd", this, r, options, o);
11263 if(!options || options.add !== true){
11264 if(this.pruneModifiedRecords){
11265 this.modified = [];
11267 for(var i = 0, len = r.length; i < len; i++){
11271 this.data = this.snapshot;
11272 delete this.snapshot;
11275 this.data.addAll(r);
11276 this.totalLength = t;
11278 this.fireEvent("datachanged", this);
11280 this.totalLength = Math.max(t, this.data.length+r.length);
11284 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11286 var e = new Roo.data.Record({});
11288 e.set(this.parent.displayField, this.parent.emptyTitle);
11289 e.set(this.parent.valueField, '');
11294 this.fireEvent("load", this, r, options, o);
11295 if(options.callback){
11296 options.callback.call(options.scope || this, r, options, true);
11302 * Loads data from a passed data block. A Reader which understands the format of the data
11303 * must have been configured in the constructor.
11304 * @param {Object} data The data block from which to read the Records. The format of the data expected
11305 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11306 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11308 loadData : function(o, append){
11309 var r = this.reader.readRecords(o);
11310 this.loadRecords(r, {add: append}, true);
11314 * Gets the number of cached records.
11316 * <em>If using paging, this may not be the total size of the dataset. If the data object
11317 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11318 * the data set size</em>
11320 getCount : function(){
11321 return this.data.length || 0;
11325 * Gets the total number of records in the dataset as returned by the server.
11327 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11328 * the dataset size</em>
11330 getTotalCount : function(){
11331 return this.totalLength || 0;
11335 * Returns the sort state of the Store as an object with two properties:
11337 field {String} The name of the field by which the Records are sorted
11338 direction {String} The sort order, "ASC" or "DESC"
11341 getSortState : function(){
11342 return this.sortInfo;
11346 applySort : function(){
11347 if(this.sortInfo && !this.remoteSort){
11348 var s = this.sortInfo, f = s.field;
11349 var st = this.fields.get(f).sortType;
11350 var fn = function(r1, r2){
11351 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11352 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11354 this.data.sort(s.direction, fn);
11355 if(this.snapshot && this.snapshot != this.data){
11356 this.snapshot.sort(s.direction, fn);
11362 * Sets the default sort column and order to be used by the next load operation.
11363 * @param {String} fieldName The name of the field to sort by.
11364 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11366 setDefaultSort : function(field, dir){
11367 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11371 * Sort the Records.
11372 * If remote sorting is used, the sort is performed on the server, and the cache is
11373 * reloaded. If local sorting is used, the cache is sorted internally.
11374 * @param {String} fieldName The name of the field to sort by.
11375 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11377 sort : function(fieldName, dir){
11378 var f = this.fields.get(fieldName);
11380 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11382 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11383 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11388 this.sortToggle[f.name] = dir;
11389 this.sortInfo = {field: f.name, direction: dir};
11390 if(!this.remoteSort){
11392 this.fireEvent("datachanged", this);
11394 this.load(this.lastOptions);
11399 * Calls the specified function for each of the Records in the cache.
11400 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11401 * Returning <em>false</em> aborts and exits the iteration.
11402 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11404 each : function(fn, scope){
11405 this.data.each(fn, scope);
11409 * Gets all records modified since the last commit. Modified records are persisted across load operations
11410 * (e.g., during paging).
11411 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11413 getModifiedRecords : function(){
11414 return this.modified;
11418 createFilterFn : function(property, value, anyMatch){
11419 if(!value.exec){ // not a regex
11420 value = String(value);
11421 if(value.length == 0){
11424 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11426 return function(r){
11427 return value.test(r.data[property]);
11432 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11433 * @param {String} property A field on your records
11434 * @param {Number} start The record index to start at (defaults to 0)
11435 * @param {Number} end The last record index to include (defaults to length - 1)
11436 * @return {Number} The sum
11438 sum : function(property, start, end){
11439 var rs = this.data.items, v = 0;
11440 start = start || 0;
11441 end = (end || end === 0) ? end : rs.length-1;
11443 for(var i = start; i <= end; i++){
11444 v += (rs[i].data[property] || 0);
11450 * Filter the records by a specified property.
11451 * @param {String} field A field on your records
11452 * @param {String/RegExp} value Either a string that the field
11453 * should start with or a RegExp to test against the field
11454 * @param {Boolean} anyMatch True to match any part not just the beginning
11456 filter : function(property, value, anyMatch){
11457 var fn = this.createFilterFn(property, value, anyMatch);
11458 return fn ? this.filterBy(fn) : this.clearFilter();
11462 * Filter by a function. The specified function will be called with each
11463 * record in this data source. If the function returns true the record is included,
11464 * otherwise it is filtered.
11465 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11466 * @param {Object} scope (optional) The scope of the function (defaults to this)
11468 filterBy : function(fn, scope){
11469 this.snapshot = this.snapshot || this.data;
11470 this.data = this.queryBy(fn, scope||this);
11471 this.fireEvent("datachanged", this);
11475 * Query the records by a specified property.
11476 * @param {String} field A field on your records
11477 * @param {String/RegExp} value Either a string that the field
11478 * should start with or a RegExp to test against the field
11479 * @param {Boolean} anyMatch True to match any part not just the beginning
11480 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11482 query : function(property, value, anyMatch){
11483 var fn = this.createFilterFn(property, value, anyMatch);
11484 return fn ? this.queryBy(fn) : this.data.clone();
11488 * Query by a function. The specified function will be called with each
11489 * record in this data source. If the function returns true the record is included
11491 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11492 * @param {Object} scope (optional) The scope of the function (defaults to this)
11493 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11495 queryBy : function(fn, scope){
11496 var data = this.snapshot || this.data;
11497 return data.filterBy(fn, scope||this);
11501 * Collects unique values for a particular dataIndex from this store.
11502 * @param {String} dataIndex The property to collect
11503 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11504 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11505 * @return {Array} An array of the unique values
11507 collect : function(dataIndex, allowNull, bypassFilter){
11508 var d = (bypassFilter === true && this.snapshot) ?
11509 this.snapshot.items : this.data.items;
11510 var v, sv, r = [], l = {};
11511 for(var i = 0, len = d.length; i < len; i++){
11512 v = d[i].data[dataIndex];
11514 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11523 * Revert to a view of the Record cache with no filtering applied.
11524 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11526 clearFilter : function(suppressEvent){
11527 if(this.snapshot && this.snapshot != this.data){
11528 this.data = this.snapshot;
11529 delete this.snapshot;
11530 if(suppressEvent !== true){
11531 this.fireEvent("datachanged", this);
11537 afterEdit : function(record){
11538 if(this.modified.indexOf(record) == -1){
11539 this.modified.push(record);
11541 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11545 afterReject : function(record){
11546 this.modified.remove(record);
11547 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11551 afterCommit : function(record){
11552 this.modified.remove(record);
11553 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11557 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11558 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11560 commitChanges : function(){
11561 var m = this.modified.slice(0);
11562 this.modified = [];
11563 for(var i = 0, len = m.length; i < len; i++){
11569 * Cancel outstanding changes on all changed records.
11571 rejectChanges : function(){
11572 var m = this.modified.slice(0);
11573 this.modified = [];
11574 for(var i = 0, len = m.length; i < len; i++){
11579 onMetaChange : function(meta, rtype, o){
11580 this.recordType = rtype;
11581 this.fields = rtype.prototype.fields;
11582 delete this.snapshot;
11583 this.sortInfo = meta.sortInfo || this.sortInfo;
11584 this.modified = [];
11585 this.fireEvent('metachange', this, this.reader.meta);
11588 moveIndex : function(data, type)
11590 var index = this.indexOf(data);
11592 var newIndex = index + type;
11596 this.insert(newIndex, data);
11601 * Ext JS Library 1.1.1
11602 * Copyright(c) 2006-2007, Ext JS, LLC.
11604 * Originally Released Under LGPL - original licence link has changed is not relivant.
11607 * <script type="text/javascript">
11611 * @class Roo.data.SimpleStore
11612 * @extends Roo.data.Store
11613 * Small helper class to make creating Stores from Array data easier.
11614 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11615 * @cfg {Array} fields An array of field definition objects, or field name strings.
11616 * @cfg {Array} data The multi-dimensional array of data
11618 * @param {Object} config
11620 Roo.data.SimpleStore = function(config){
11621 Roo.data.SimpleStore.superclass.constructor.call(this, {
11623 reader: new Roo.data.ArrayReader({
11626 Roo.data.Record.create(config.fields)
11628 proxy : new Roo.data.MemoryProxy(config.data)
11632 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11634 * Ext JS Library 1.1.1
11635 * Copyright(c) 2006-2007, Ext JS, LLC.
11637 * Originally Released Under LGPL - original licence link has changed is not relivant.
11640 * <script type="text/javascript">
11645 * @extends Roo.data.Store
11646 * @class Roo.data.JsonStore
11647 * Small helper class to make creating Stores for JSON data easier. <br/>
11649 var store = new Roo.data.JsonStore({
11650 url: 'get-images.php',
11652 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11655 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11656 * JsonReader and HttpProxy (unless inline data is provided).</b>
11657 * @cfg {Array} fields An array of field definition objects, or field name strings.
11659 * @param {Object} config
11661 Roo.data.JsonStore = function(c){
11662 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11663 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11664 reader: new Roo.data.JsonReader(c, c.fields)
11667 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11669 * Ext JS Library 1.1.1
11670 * Copyright(c) 2006-2007, Ext JS, LLC.
11672 * Originally Released Under LGPL - original licence link has changed is not relivant.
11675 * <script type="text/javascript">
11679 Roo.data.Field = function(config){
11680 if(typeof config == "string"){
11681 config = {name: config};
11683 Roo.apply(this, config);
11686 this.type = "auto";
11689 var st = Roo.data.SortTypes;
11690 // named sortTypes are supported, here we look them up
11691 if(typeof this.sortType == "string"){
11692 this.sortType = st[this.sortType];
11695 // set default sortType for strings and dates
11696 if(!this.sortType){
11699 this.sortType = st.asUCString;
11702 this.sortType = st.asDate;
11705 this.sortType = st.none;
11710 var stripRe = /[\$,%]/g;
11712 // prebuilt conversion function for this field, instead of
11713 // switching every time we're reading a value
11715 var cv, dateFormat = this.dateFormat;
11720 cv = function(v){ return v; };
11723 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11727 return v !== undefined && v !== null && v !== '' ?
11728 parseInt(String(v).replace(stripRe, ""), 10) : '';
11733 return v !== undefined && v !== null && v !== '' ?
11734 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11739 cv = function(v){ return v === true || v === "true" || v == 1; };
11746 if(v instanceof Date){
11750 if(dateFormat == "timestamp"){
11751 return new Date(v*1000);
11753 return Date.parseDate(v, dateFormat);
11755 var parsed = Date.parse(v);
11756 return parsed ? new Date(parsed) : null;
11765 Roo.data.Field.prototype = {
11773 * Ext JS Library 1.1.1
11774 * Copyright(c) 2006-2007, Ext JS, LLC.
11776 * Originally Released Under LGPL - original licence link has changed is not relivant.
11779 * <script type="text/javascript">
11782 // Base class for reading structured data from a data source. This class is intended to be
11783 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11786 * @class Roo.data.DataReader
11787 * Base class for reading structured data from a data source. This class is intended to be
11788 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11791 Roo.data.DataReader = function(meta, recordType){
11795 this.recordType = recordType instanceof Array ?
11796 Roo.data.Record.create(recordType) : recordType;
11799 Roo.data.DataReader.prototype = {
11801 * Create an empty record
11802 * @param {Object} data (optional) - overlay some values
11803 * @return {Roo.data.Record} record created.
11805 newRow : function(d) {
11807 this.recordType.prototype.fields.each(function(c) {
11809 case 'int' : da[c.name] = 0; break;
11810 case 'date' : da[c.name] = new Date(); break;
11811 case 'float' : da[c.name] = 0.0; break;
11812 case 'boolean' : da[c.name] = false; break;
11813 default : da[c.name] = ""; break;
11817 return new this.recordType(Roo.apply(da, d));
11822 * Ext JS Library 1.1.1
11823 * Copyright(c) 2006-2007, Ext JS, LLC.
11825 * Originally Released Under LGPL - original licence link has changed is not relivant.
11828 * <script type="text/javascript">
11832 * @class Roo.data.DataProxy
11833 * @extends Roo.data.Observable
11834 * This class is an abstract base class for implementations which provide retrieval of
11835 * unformatted data objects.<br>
11837 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11838 * (of the appropriate type which knows how to parse the data object) to provide a block of
11839 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11841 * Custom implementations must implement the load method as described in
11842 * {@link Roo.data.HttpProxy#load}.
11844 Roo.data.DataProxy = function(){
11847 * @event beforeload
11848 * Fires before a network request is made to retrieve a data object.
11849 * @param {Object} This DataProxy object.
11850 * @param {Object} params The params parameter to the load function.
11855 * Fires before the load method's callback is called.
11856 * @param {Object} This DataProxy object.
11857 * @param {Object} o The data object.
11858 * @param {Object} arg The callback argument object passed to the load function.
11862 * @event loadexception
11863 * Fires if an Exception occurs during data retrieval.
11864 * @param {Object} This DataProxy object.
11865 * @param {Object} o The data object.
11866 * @param {Object} arg The callback argument object passed to the load function.
11867 * @param {Object} e The Exception.
11869 loadexception : true
11871 Roo.data.DataProxy.superclass.constructor.call(this);
11874 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11877 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11881 * Ext JS Library 1.1.1
11882 * Copyright(c) 2006-2007, Ext JS, LLC.
11884 * Originally Released Under LGPL - original licence link has changed is not relivant.
11887 * <script type="text/javascript">
11890 * @class Roo.data.MemoryProxy
11891 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11892 * to the Reader when its load method is called.
11894 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11896 Roo.data.MemoryProxy = function(data){
11900 Roo.data.MemoryProxy.superclass.constructor.call(this);
11904 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11907 * Load data from the requested source (in this case an in-memory
11908 * data object passed to the constructor), read the data object into
11909 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11910 * process that block using the passed callback.
11911 * @param {Object} params This parameter is not used by the MemoryProxy class.
11912 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11913 * object into a block of Roo.data.Records.
11914 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11915 * The function must be passed <ul>
11916 * <li>The Record block object</li>
11917 * <li>The "arg" argument from the load function</li>
11918 * <li>A boolean success indicator</li>
11920 * @param {Object} scope The scope in which to call the callback
11921 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11923 load : function(params, reader, callback, scope, arg){
11924 params = params || {};
11927 result = reader.readRecords(this.data);
11929 this.fireEvent("loadexception", this, arg, null, e);
11930 callback.call(scope, null, arg, false);
11933 callback.call(scope, result, arg, true);
11937 update : function(params, records){
11942 * Ext JS Library 1.1.1
11943 * Copyright(c) 2006-2007, Ext JS, LLC.
11945 * Originally Released Under LGPL - original licence link has changed is not relivant.
11948 * <script type="text/javascript">
11951 * @class Roo.data.HttpProxy
11952 * @extends Roo.data.DataProxy
11953 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11954 * configured to reference a certain URL.<br><br>
11956 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11957 * from which the running page was served.<br><br>
11959 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11961 * Be aware that to enable the browser to parse an XML document, the server must set
11962 * the Content-Type header in the HTTP response to "text/xml".
11964 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11965 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11966 * will be used to make the request.
11968 Roo.data.HttpProxy = function(conn){
11969 Roo.data.HttpProxy.superclass.constructor.call(this);
11970 // is conn a conn config or a real conn?
11972 this.useAjax = !conn || !conn.events;
11976 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11977 // thse are take from connection...
11980 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11983 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11984 * extra parameters to each request made by this object. (defaults to undefined)
11987 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11988 * to each request made by this object. (defaults to undefined)
11991 * @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)
11994 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11997 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12003 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12007 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12008 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12009 * a finer-grained basis than the DataProxy events.
12011 getConnection : function(){
12012 return this.useAjax ? Roo.Ajax : this.conn;
12016 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12017 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12018 * process that block using the passed callback.
12019 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12020 * for the request to the remote server.
12021 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12022 * object into a block of Roo.data.Records.
12023 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12024 * The function must be passed <ul>
12025 * <li>The Record block object</li>
12026 * <li>The "arg" argument from the load function</li>
12027 * <li>A boolean success indicator</li>
12029 * @param {Object} scope The scope in which to call the callback
12030 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12032 load : function(params, reader, callback, scope, arg){
12033 if(this.fireEvent("beforeload", this, params) !== false){
12035 params : params || {},
12037 callback : callback,
12042 callback : this.loadResponse,
12046 Roo.applyIf(o, this.conn);
12047 if(this.activeRequest){
12048 Roo.Ajax.abort(this.activeRequest);
12050 this.activeRequest = Roo.Ajax.request(o);
12052 this.conn.request(o);
12055 callback.call(scope||this, null, arg, false);
12060 loadResponse : function(o, success, response){
12061 delete this.activeRequest;
12063 this.fireEvent("loadexception", this, o, response);
12064 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12069 result = o.reader.read(response);
12071 this.fireEvent("loadexception", this, o, response, e);
12072 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12076 this.fireEvent("load", this, o, o.request.arg);
12077 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12081 update : function(dataSet){
12086 updateResponse : function(dataSet){
12091 * Ext JS Library 1.1.1
12092 * Copyright(c) 2006-2007, Ext JS, LLC.
12094 * Originally Released Under LGPL - original licence link has changed is not relivant.
12097 * <script type="text/javascript">
12101 * @class Roo.data.ScriptTagProxy
12102 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12103 * other than the originating domain of the running page.<br><br>
12105 * <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
12106 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12108 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12109 * source code that is used as the source inside a <script> tag.<br><br>
12111 * In order for the browser to process the returned data, the server must wrap the data object
12112 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12113 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12114 * depending on whether the callback name was passed:
12117 boolean scriptTag = false;
12118 String cb = request.getParameter("callback");
12121 response.setContentType("text/javascript");
12123 response.setContentType("application/x-json");
12125 Writer out = response.getWriter();
12127 out.write(cb + "(");
12129 out.print(dataBlock.toJsonString());
12136 * @param {Object} config A configuration object.
12138 Roo.data.ScriptTagProxy = function(config){
12139 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12140 Roo.apply(this, config);
12141 this.head = document.getElementsByTagName("head")[0];
12144 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12146 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12148 * @cfg {String} url The URL from which to request the data object.
12151 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12155 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12156 * the server the name of the callback function set up by the load call to process the returned data object.
12157 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12158 * javascript output which calls this named function passing the data object as its only parameter.
12160 callbackParam : "callback",
12162 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12163 * name to the request.
12168 * Load data from the configured URL, read the data object into
12169 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12170 * process that block using the passed callback.
12171 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12172 * for the request to the remote server.
12173 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12174 * object into a block of Roo.data.Records.
12175 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12176 * The function must be passed <ul>
12177 * <li>The Record block object</li>
12178 * <li>The "arg" argument from the load function</li>
12179 * <li>A boolean success indicator</li>
12181 * @param {Object} scope The scope in which to call the callback
12182 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12184 load : function(params, reader, callback, scope, arg){
12185 if(this.fireEvent("beforeload", this, params) !== false){
12187 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12189 var url = this.url;
12190 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12192 url += "&_dc=" + (new Date().getTime());
12194 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12197 cb : "stcCallback"+transId,
12198 scriptId : "stcScript"+transId,
12202 callback : callback,
12208 window[trans.cb] = function(o){
12209 conn.handleResponse(o, trans);
12212 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12214 if(this.autoAbort !== false){
12218 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12220 var script = document.createElement("script");
12221 script.setAttribute("src", url);
12222 script.setAttribute("type", "text/javascript");
12223 script.setAttribute("id", trans.scriptId);
12224 this.head.appendChild(script);
12226 this.trans = trans;
12228 callback.call(scope||this, null, arg, false);
12233 isLoading : function(){
12234 return this.trans ? true : false;
12238 * Abort the current server request.
12240 abort : function(){
12241 if(this.isLoading()){
12242 this.destroyTrans(this.trans);
12247 destroyTrans : function(trans, isLoaded){
12248 this.head.removeChild(document.getElementById(trans.scriptId));
12249 clearTimeout(trans.timeoutId);
12251 window[trans.cb] = undefined;
12253 delete window[trans.cb];
12256 // if hasn't been loaded, wait for load to remove it to prevent script error
12257 window[trans.cb] = function(){
12258 window[trans.cb] = undefined;
12260 delete window[trans.cb];
12267 handleResponse : function(o, trans){
12268 this.trans = false;
12269 this.destroyTrans(trans, true);
12272 result = trans.reader.readRecords(o);
12274 this.fireEvent("loadexception", this, o, trans.arg, e);
12275 trans.callback.call(trans.scope||window, null, trans.arg, false);
12278 this.fireEvent("load", this, o, trans.arg);
12279 trans.callback.call(trans.scope||window, result, trans.arg, true);
12283 handleFailure : function(trans){
12284 this.trans = false;
12285 this.destroyTrans(trans, false);
12286 this.fireEvent("loadexception", this, null, trans.arg);
12287 trans.callback.call(trans.scope||window, null, trans.arg, false);
12291 * Ext JS Library 1.1.1
12292 * Copyright(c) 2006-2007, Ext JS, LLC.
12294 * Originally Released Under LGPL - original licence link has changed is not relivant.
12297 * <script type="text/javascript">
12301 * @class Roo.data.JsonReader
12302 * @extends Roo.data.DataReader
12303 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12304 * based on mappings in a provided Roo.data.Record constructor.
12306 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12307 * in the reply previously.
12312 var RecordDef = Roo.data.Record.create([
12313 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12314 {name: 'occupation'} // This field will use "occupation" as the mapping.
12316 var myReader = new Roo.data.JsonReader({
12317 totalProperty: "results", // The property which contains the total dataset size (optional)
12318 root: "rows", // The property which contains an Array of row objects
12319 id: "id" // The property within each row object that provides an ID for the record (optional)
12323 * This would consume a JSON file like this:
12325 { 'results': 2, 'rows': [
12326 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12327 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12330 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12331 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12332 * paged from the remote server.
12333 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12334 * @cfg {String} root name of the property which contains the Array of row objects.
12335 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12336 * @cfg {Array} fields Array of field definition objects
12338 * Create a new JsonReader
12339 * @param {Object} meta Metadata configuration options
12340 * @param {Object} recordType Either an Array of field definition objects,
12341 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12343 Roo.data.JsonReader = function(meta, recordType){
12346 // set some defaults:
12347 Roo.applyIf(meta, {
12348 totalProperty: 'total',
12349 successProperty : 'success',
12354 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12356 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12359 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12360 * Used by Store query builder to append _requestMeta to params.
12363 metaFromRemote : false,
12365 * This method is only used by a DataProxy which has retrieved data from a remote server.
12366 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12367 * @return {Object} data A data block which is used by an Roo.data.Store object as
12368 * a cache of Roo.data.Records.
12370 read : function(response){
12371 var json = response.responseText;
12373 var o = /* eval:var:o */ eval("("+json+")");
12375 throw {message: "JsonReader.read: Json object not found"};
12381 this.metaFromRemote = true;
12382 this.meta = o.metaData;
12383 this.recordType = Roo.data.Record.create(o.metaData.fields);
12384 this.onMetaChange(this.meta, this.recordType, o);
12386 return this.readRecords(o);
12389 // private function a store will implement
12390 onMetaChange : function(meta, recordType, o){
12397 simpleAccess: function(obj, subsc) {
12404 getJsonAccessor: function(){
12406 return function(expr) {
12408 return(re.test(expr))
12409 ? new Function("obj", "return obj." + expr)
12414 return Roo.emptyFn;
12419 * Create a data block containing Roo.data.Records from an XML document.
12420 * @param {Object} o An object which contains an Array of row objects in the property specified
12421 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12422 * which contains the total size of the dataset.
12423 * @return {Object} data A data block which is used by an Roo.data.Store object as
12424 * a cache of Roo.data.Records.
12426 readRecords : function(o){
12428 * After any data loads, the raw JSON data is available for further custom processing.
12432 var s = this.meta, Record = this.recordType,
12433 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12435 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12437 if(s.totalProperty) {
12438 this.getTotal = this.getJsonAccessor(s.totalProperty);
12440 if(s.successProperty) {
12441 this.getSuccess = this.getJsonAccessor(s.successProperty);
12443 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12445 var g = this.getJsonAccessor(s.id);
12446 this.getId = function(rec) {
12448 return (r === undefined || r === "") ? null : r;
12451 this.getId = function(){return null;};
12454 for(var jj = 0; jj < fl; jj++){
12456 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12457 this.ef[jj] = this.getJsonAccessor(map);
12461 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12462 if(s.totalProperty){
12463 var vt = parseInt(this.getTotal(o), 10);
12468 if(s.successProperty){
12469 var vs = this.getSuccess(o);
12470 if(vs === false || vs === 'false'){
12475 for(var i = 0; i < c; i++){
12478 var id = this.getId(n);
12479 for(var j = 0; j < fl; j++){
12481 var v = this.ef[j](n);
12483 Roo.log('missing convert for ' + f.name);
12487 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12489 var record = new Record(values, id);
12491 records[i] = record;
12497 totalRecords : totalRecords
12502 * Ext JS Library 1.1.1
12503 * Copyright(c) 2006-2007, Ext JS, LLC.
12505 * Originally Released Under LGPL - original licence link has changed is not relivant.
12508 * <script type="text/javascript">
12512 * @class Roo.data.ArrayReader
12513 * @extends Roo.data.DataReader
12514 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12515 * Each element of that Array represents a row of data fields. The
12516 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12517 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12521 var RecordDef = Roo.data.Record.create([
12522 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12523 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12525 var myReader = new Roo.data.ArrayReader({
12526 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12530 * This would consume an Array like this:
12532 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12534 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12536 * Create a new JsonReader
12537 * @param {Object} meta Metadata configuration options.
12538 * @param {Object} recordType Either an Array of field definition objects
12539 * as specified to {@link Roo.data.Record#create},
12540 * or an {@link Roo.data.Record} object
12541 * created using {@link Roo.data.Record#create}.
12543 Roo.data.ArrayReader = function(meta, recordType){
12544 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12547 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12549 * Create a data block containing Roo.data.Records from an XML document.
12550 * @param {Object} o An Array of row objects which represents the dataset.
12551 * @return {Object} data A data block which is used by an Roo.data.Store object as
12552 * a cache of Roo.data.Records.
12554 readRecords : function(o){
12555 var sid = this.meta ? this.meta.id : null;
12556 var recordType = this.recordType, fields = recordType.prototype.fields;
12559 for(var i = 0; i < root.length; i++){
12562 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12563 for(var j = 0, jlen = fields.length; j < jlen; j++){
12564 var f = fields.items[j];
12565 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12566 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12568 values[f.name] = v;
12570 var record = new recordType(values, id);
12572 records[records.length] = record;
12576 totalRecords : records.length
12585 * @class Roo.bootstrap.ComboBox
12586 * @extends Roo.bootstrap.TriggerField
12587 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12588 * @cfg {Boolean} append (true|false) default false
12589 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12590 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12591 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12592 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12593 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12594 * @cfg {Boolean} animate default true
12595 * @cfg {Boolean} emptyResultText only for touch device
12596 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12597 * @cfg {String} emptyTitle default ''
12599 * Create a new ComboBox.
12600 * @param {Object} config Configuration options
12602 Roo.bootstrap.ComboBox = function(config){
12603 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12607 * Fires when the dropdown list is expanded
12608 * @param {Roo.bootstrap.ComboBox} combo This combo box
12613 * Fires when the dropdown list is collapsed
12614 * @param {Roo.bootstrap.ComboBox} combo This combo box
12618 * @event beforeselect
12619 * Fires before a list item is selected. Return false to cancel the selection.
12620 * @param {Roo.bootstrap.ComboBox} combo This combo box
12621 * @param {Roo.data.Record} record The data record returned from the underlying store
12622 * @param {Number} index The index of the selected item in the dropdown list
12624 'beforeselect' : true,
12627 * Fires when a list item is selected
12628 * @param {Roo.bootstrap.ComboBox} combo This combo box
12629 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12630 * @param {Number} index The index of the selected item in the dropdown list
12634 * @event beforequery
12635 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12636 * The event object passed has these properties:
12637 * @param {Roo.bootstrap.ComboBox} combo This combo box
12638 * @param {String} query The query
12639 * @param {Boolean} forceAll true to force "all" query
12640 * @param {Boolean} cancel true to cancel the query
12641 * @param {Object} e The query event object
12643 'beforequery': true,
12646 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12647 * @param {Roo.bootstrap.ComboBox} combo This combo box
12652 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12653 * @param {Roo.bootstrap.ComboBox} combo This combo box
12654 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12659 * Fires when the remove value from the combobox array
12660 * @param {Roo.bootstrap.ComboBox} combo This combo box
12664 * @event afterremove
12665 * Fires when the remove value from the combobox array
12666 * @param {Roo.bootstrap.ComboBox} combo This combo box
12668 'afterremove' : true,
12670 * @event specialfilter
12671 * Fires when specialfilter
12672 * @param {Roo.bootstrap.ComboBox} combo This combo box
12674 'specialfilter' : true,
12677 * Fires when tick the element
12678 * @param {Roo.bootstrap.ComboBox} combo This combo box
12682 * @event touchviewdisplay
12683 * Fires when touch view require special display (default is using displayField)
12684 * @param {Roo.bootstrap.ComboBox} combo This combo box
12685 * @param {Object} cfg set html .
12687 'touchviewdisplay' : true
12692 this.tickItems = [];
12694 this.selectedIndex = -1;
12695 if(this.mode == 'local'){
12696 if(config.queryDelay === undefined){
12697 this.queryDelay = 10;
12699 if(config.minChars === undefined){
12705 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12708 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12709 * rendering into an Roo.Editor, defaults to false)
12712 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12713 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12716 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12719 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12720 * the dropdown list (defaults to undefined, with no header element)
12724 * @cfg {String/Roo.Template} tpl The template to use to render the output
12728 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12730 listWidth: undefined,
12732 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12733 * mode = 'remote' or 'text' if mode = 'local')
12735 displayField: undefined,
12738 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12739 * mode = 'remote' or 'value' if mode = 'local').
12740 * Note: use of a valueField requires the user make a selection
12741 * in order for a value to be mapped.
12743 valueField: undefined,
12745 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12750 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12751 * field's data value (defaults to the underlying DOM element's name)
12753 hiddenName: undefined,
12755 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12759 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12761 selectedClass: 'active',
12764 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12768 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12769 * anchor positions (defaults to 'tl-bl')
12771 listAlign: 'tl-bl?',
12773 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12777 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12778 * query specified by the allQuery config option (defaults to 'query')
12780 triggerAction: 'query',
12782 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12783 * (defaults to 4, does not apply if editable = false)
12787 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12788 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12792 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12793 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12797 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12798 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12802 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12803 * when editable = true (defaults to false)
12805 selectOnFocus:false,
12807 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12809 queryParam: 'query',
12811 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12812 * when mode = 'remote' (defaults to 'Loading...')
12814 loadingText: 'Loading...',
12816 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12820 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12824 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12825 * traditional select (defaults to true)
12829 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12833 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12837 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12838 * listWidth has a higher value)
12842 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12843 * allow the user to set arbitrary text into the field (defaults to false)
12845 forceSelection:false,
12847 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12848 * if typeAhead = true (defaults to 250)
12850 typeAheadDelay : 250,
12852 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12853 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12855 valueNotFoundText : undefined,
12857 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12859 blockFocus : false,
12862 * @cfg {Boolean} disableClear Disable showing of clear button.
12864 disableClear : false,
12866 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12868 alwaysQuery : false,
12871 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12876 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12878 invalidClass : "has-warning",
12881 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12883 validClass : "has-success",
12886 * @cfg {Boolean} specialFilter (true|false) special filter default false
12888 specialFilter : false,
12891 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12893 mobileTouchView : true,
12896 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12898 useNativeIOS : false,
12900 ios_options : false,
12912 btnPosition : 'right',
12913 triggerList : true,
12914 showToggleBtn : true,
12916 emptyResultText: 'Empty',
12917 triggerText : 'Select',
12920 // element that contains real text value.. (when hidden is used..)
12922 getAutoCreate : function()
12927 * Render classic select for iso
12930 if(Roo.isIOS && this.useNativeIOS){
12931 cfg = this.getAutoCreateNativeIOS();
12939 if(Roo.isTouch && this.mobileTouchView){
12940 cfg = this.getAutoCreateTouchView();
12947 if(!this.tickable){
12948 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12953 * ComboBox with tickable selections
12956 var align = this.labelAlign || this.parentLabelAlign();
12959 cls : 'form-group roo-combobox-tickable' //input-group
12962 var btn_text_select = '';
12963 var btn_text_done = '';
12964 var btn_text_cancel = '';
12966 if (this.btn_text_show) {
12967 btn_text_select = 'Select';
12968 btn_text_done = 'Done';
12969 btn_text_cancel = 'Cancel';
12974 cls : 'tickable-buttons',
12979 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12980 //html : this.triggerText
12981 html: btn_text_select
12987 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12989 html: btn_text_done
12995 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12997 html: btn_text_cancel
13003 buttons.cn.unshift({
13005 cls: 'roo-select2-search-field-input'
13011 Roo.each(buttons.cn, function(c){
13013 c.cls += ' btn-' + _this.size;
13016 if (_this.disabled) {
13027 cls: 'form-hidden-field'
13031 cls: 'roo-select2-choices',
13035 cls: 'roo-select2-search-field',
13046 cls: 'roo-select2-container input-group roo-select2-container-multi',
13051 // cls: 'typeahead typeahead-long dropdown-menu',
13052 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13057 if(this.hasFeedback && !this.allowBlank){
13061 cls: 'glyphicon form-control-feedback'
13064 combobox.cn.push(feedback);
13068 if (align ==='left' && this.fieldLabel.length) {
13070 cfg.cls += ' roo-form-group-label-left';
13075 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13076 tooltip : 'This field is required'
13081 cls : 'control-label',
13082 html : this.fieldLabel
13094 var labelCfg = cfg.cn[1];
13095 var contentCfg = cfg.cn[2];
13098 if(this.indicatorpos == 'right'){
13104 cls : 'control-label',
13108 html : this.fieldLabel
13112 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13113 tooltip : 'This field is required'
13128 labelCfg = cfg.cn[0];
13129 contentCfg = cfg.cn[1];
13133 if(this.labelWidth > 12){
13134 labelCfg.style = "width: " + this.labelWidth + 'px';
13137 if(this.labelWidth < 13 && this.labelmd == 0){
13138 this.labelmd = this.labelWidth;
13141 if(this.labellg > 0){
13142 labelCfg.cls += ' col-lg-' + this.labellg;
13143 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13146 if(this.labelmd > 0){
13147 labelCfg.cls += ' col-md-' + this.labelmd;
13148 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13151 if(this.labelsm > 0){
13152 labelCfg.cls += ' col-sm-' + this.labelsm;
13153 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13156 if(this.labelxs > 0){
13157 labelCfg.cls += ' col-xs-' + this.labelxs;
13158 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13162 } else if ( this.fieldLabel.length) {
13163 // Roo.log(" label");
13167 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13168 tooltip : 'This field is required'
13172 //cls : 'input-group-addon',
13173 html : this.fieldLabel
13178 if(this.indicatorpos == 'right'){
13182 //cls : 'input-group-addon',
13183 html : this.fieldLabel
13187 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13188 tooltip : 'This field is required'
13197 // Roo.log(" no label && no align");
13204 ['xs','sm','md','lg'].map(function(size){
13205 if (settings[size]) {
13206 cfg.cls += ' col-' + size + '-' + settings[size];
13214 _initEventsCalled : false,
13217 initEvents: function()
13219 if (this._initEventsCalled) { // as we call render... prevent looping...
13222 this._initEventsCalled = true;
13225 throw "can not find store for combo";
13228 this.indicator = this.indicatorEl();
13230 this.store = Roo.factory(this.store, Roo.data);
13231 this.store.parent = this;
13233 // if we are building from html. then this element is so complex, that we can not really
13234 // use the rendered HTML.
13235 // so we have to trash and replace the previous code.
13236 if (Roo.XComponent.build_from_html) {
13237 // remove this element....
13238 var e = this.el.dom, k=0;
13239 while (e ) { e = e.previousSibling; ++k;}
13244 this.rendered = false;
13246 this.render(this.parent().getChildContainer(true), k);
13249 if(Roo.isIOS && this.useNativeIOS){
13250 this.initIOSView();
13258 if(Roo.isTouch && this.mobileTouchView){
13259 this.initTouchView();
13264 this.initTickableEvents();
13268 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13270 if(this.hiddenName){
13272 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13274 this.hiddenField.dom.value =
13275 this.hiddenValue !== undefined ? this.hiddenValue :
13276 this.value !== undefined ? this.value : '';
13278 // prevent input submission
13279 this.el.dom.removeAttribute('name');
13280 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13285 // this.el.dom.setAttribute('autocomplete', 'off');
13288 var cls = 'x-combo-list';
13290 //this.list = new Roo.Layer({
13291 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13297 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13298 _this.list.setWidth(lw);
13301 this.list.on('mouseover', this.onViewOver, this);
13302 this.list.on('mousemove', this.onViewMove, this);
13303 this.list.on('scroll', this.onViewScroll, this);
13306 this.list.swallowEvent('mousewheel');
13307 this.assetHeight = 0;
13310 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13311 this.assetHeight += this.header.getHeight();
13314 this.innerList = this.list.createChild({cls:cls+'-inner'});
13315 this.innerList.on('mouseover', this.onViewOver, this);
13316 this.innerList.on('mousemove', this.onViewMove, this);
13317 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13319 if(this.allowBlank && !this.pageSize && !this.disableClear){
13320 this.footer = this.list.createChild({cls:cls+'-ft'});
13321 this.pageTb = new Roo.Toolbar(this.footer);
13325 this.footer = this.list.createChild({cls:cls+'-ft'});
13326 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13327 {pageSize: this.pageSize});
13331 if (this.pageTb && this.allowBlank && !this.disableClear) {
13333 this.pageTb.add(new Roo.Toolbar.Fill(), {
13334 cls: 'x-btn-icon x-btn-clear',
13336 handler: function()
13339 _this.clearValue();
13340 _this.onSelect(false, -1);
13345 this.assetHeight += this.footer.getHeight();
13350 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13353 this.view = new Roo.View(this.list, this.tpl, {
13354 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13356 //this.view.wrapEl.setDisplayed(false);
13357 this.view.on('click', this.onViewClick, this);
13360 this.store.on('beforeload', this.onBeforeLoad, this);
13361 this.store.on('load', this.onLoad, this);
13362 this.store.on('loadexception', this.onLoadException, this);
13364 if(this.resizable){
13365 this.resizer = new Roo.Resizable(this.list, {
13366 pinned:true, handles:'se'
13368 this.resizer.on('resize', function(r, w, h){
13369 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13370 this.listWidth = w;
13371 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13372 this.restrictHeight();
13374 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13377 if(!this.editable){
13378 this.editable = true;
13379 this.setEditable(false);
13384 if (typeof(this.events.add.listeners) != 'undefined') {
13386 this.addicon = this.wrap.createChild(
13387 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13389 this.addicon.on('click', function(e) {
13390 this.fireEvent('add', this);
13393 if (typeof(this.events.edit.listeners) != 'undefined') {
13395 this.editicon = this.wrap.createChild(
13396 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13397 if (this.addicon) {
13398 this.editicon.setStyle('margin-left', '40px');
13400 this.editicon.on('click', function(e) {
13402 // we fire even if inothing is selected..
13403 this.fireEvent('edit', this, this.lastData );
13409 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13410 "up" : function(e){
13411 this.inKeyMode = true;
13415 "down" : function(e){
13416 if(!this.isExpanded()){
13417 this.onTriggerClick();
13419 this.inKeyMode = true;
13424 "enter" : function(e){
13425 // this.onViewClick();
13429 if(this.fireEvent("specialkey", this, e)){
13430 this.onViewClick(false);
13436 "esc" : function(e){
13440 "tab" : function(e){
13443 if(this.fireEvent("specialkey", this, e)){
13444 this.onViewClick(false);
13452 doRelay : function(foo, bar, hname){
13453 if(hname == 'down' || this.scope.isExpanded()){
13454 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13463 this.queryDelay = Math.max(this.queryDelay || 10,
13464 this.mode == 'local' ? 10 : 250);
13467 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13469 if(this.typeAhead){
13470 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13472 if(this.editable !== false){
13473 this.inputEl().on("keyup", this.onKeyUp, this);
13475 if(this.forceSelection){
13476 this.inputEl().on('blur', this.doForce, this);
13480 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13481 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13485 initTickableEvents: function()
13489 if(this.hiddenName){
13491 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13493 this.hiddenField.dom.value =
13494 this.hiddenValue !== undefined ? this.hiddenValue :
13495 this.value !== undefined ? this.value : '';
13497 // prevent input submission
13498 this.el.dom.removeAttribute('name');
13499 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13504 // this.list = this.el.select('ul.dropdown-menu',true).first();
13506 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13507 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13508 if(this.triggerList){
13509 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13512 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13513 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13515 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13516 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13518 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13519 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13521 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13522 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13523 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13526 this.cancelBtn.hide();
13531 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13532 _this.list.setWidth(lw);
13535 this.list.on('mouseover', this.onViewOver, this);
13536 this.list.on('mousemove', this.onViewMove, this);
13538 this.list.on('scroll', this.onViewScroll, this);
13541 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>';
13544 this.view = new Roo.View(this.list, this.tpl, {
13545 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13548 //this.view.wrapEl.setDisplayed(false);
13549 this.view.on('click', this.onViewClick, this);
13553 this.store.on('beforeload', this.onBeforeLoad, this);
13554 this.store.on('load', this.onLoad, this);
13555 this.store.on('loadexception', this.onLoadException, this);
13558 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13559 "up" : function(e){
13560 this.inKeyMode = true;
13564 "down" : function(e){
13565 this.inKeyMode = true;
13569 "enter" : function(e){
13570 if(this.fireEvent("specialkey", this, e)){
13571 this.onViewClick(false);
13577 "esc" : function(e){
13578 this.onTickableFooterButtonClick(e, false, false);
13581 "tab" : function(e){
13582 this.fireEvent("specialkey", this, e);
13584 this.onTickableFooterButtonClick(e, false, false);
13591 doRelay : function(e, fn, key){
13592 if(this.scope.isExpanded()){
13593 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13602 this.queryDelay = Math.max(this.queryDelay || 10,
13603 this.mode == 'local' ? 10 : 250);
13606 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13608 if(this.typeAhead){
13609 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13612 if(this.editable !== false){
13613 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13616 this.indicator = this.indicatorEl();
13618 if(this.indicator){
13619 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13620 this.indicator.hide();
13625 onDestroy : function(){
13627 this.view.setStore(null);
13628 this.view.el.removeAllListeners();
13629 this.view.el.remove();
13630 this.view.purgeListeners();
13633 this.list.dom.innerHTML = '';
13637 this.store.un('beforeload', this.onBeforeLoad, this);
13638 this.store.un('load', this.onLoad, this);
13639 this.store.un('loadexception', this.onLoadException, this);
13641 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13645 fireKey : function(e){
13646 if(e.isNavKeyPress() && !this.list.isVisible()){
13647 this.fireEvent("specialkey", this, e);
13652 onResize: function(w, h){
13653 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13655 // if(typeof w != 'number'){
13656 // // we do not handle it!?!?
13659 // var tw = this.trigger.getWidth();
13660 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13661 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13663 // this.inputEl().setWidth( this.adjustWidth('input', x));
13665 // //this.trigger.setStyle('left', x+'px');
13667 // if(this.list && this.listWidth === undefined){
13668 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13669 // this.list.setWidth(lw);
13670 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13678 * Allow or prevent the user from directly editing the field text. If false is passed,
13679 * the user will only be able to select from the items defined in the dropdown list. This method
13680 * is the runtime equivalent of setting the 'editable' config option at config time.
13681 * @param {Boolean} value True to allow the user to directly edit the field text
13683 setEditable : function(value){
13684 if(value == this.editable){
13687 this.editable = value;
13689 this.inputEl().dom.setAttribute('readOnly', true);
13690 this.inputEl().on('mousedown', this.onTriggerClick, this);
13691 this.inputEl().addClass('x-combo-noedit');
13693 this.inputEl().dom.setAttribute('readOnly', false);
13694 this.inputEl().un('mousedown', this.onTriggerClick, this);
13695 this.inputEl().removeClass('x-combo-noedit');
13701 onBeforeLoad : function(combo,opts){
13702 if(!this.hasFocus){
13706 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13708 this.restrictHeight();
13709 this.selectedIndex = -1;
13713 onLoad : function(){
13715 this.hasQuery = false;
13717 if(!this.hasFocus){
13721 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13722 this.loading.hide();
13725 if(this.store.getCount() > 0){
13728 this.restrictHeight();
13729 if(this.lastQuery == this.allQuery){
13730 if(this.editable && !this.tickable){
13731 this.inputEl().dom.select();
13735 !this.selectByValue(this.value, true) &&
13738 !this.store.lastOptions ||
13739 typeof(this.store.lastOptions.add) == 'undefined' ||
13740 this.store.lastOptions.add != true
13743 this.select(0, true);
13746 if(this.autoFocus){
13749 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13750 this.taTask.delay(this.typeAheadDelay);
13754 this.onEmptyResults();
13760 onLoadException : function()
13762 this.hasQuery = false;
13764 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13765 this.loading.hide();
13768 if(this.tickable && this.editable){
13773 // only causes errors at present
13774 //Roo.log(this.store.reader.jsonData);
13775 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13777 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13783 onTypeAhead : function(){
13784 if(this.store.getCount() > 0){
13785 var r = this.store.getAt(0);
13786 var newValue = r.data[this.displayField];
13787 var len = newValue.length;
13788 var selStart = this.getRawValue().length;
13790 if(selStart != len){
13791 this.setRawValue(newValue);
13792 this.selectText(selStart, newValue.length);
13798 onSelect : function(record, index){
13800 if(this.fireEvent('beforeselect', this, record, index) !== false){
13802 this.setFromData(index > -1 ? record.data : false);
13805 this.fireEvent('select', this, record, index);
13810 * Returns the currently selected field value or empty string if no value is set.
13811 * @return {String} value The selected value
13813 getValue : function()
13815 if(Roo.isIOS && this.useNativeIOS){
13816 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13820 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13823 if(this.valueField){
13824 return typeof this.value != 'undefined' ? this.value : '';
13826 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13830 getRawValue : function()
13832 if(Roo.isIOS && this.useNativeIOS){
13833 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13836 var v = this.inputEl().getValue();
13842 * Clears any text/value currently set in the field
13844 clearValue : function(){
13846 if(this.hiddenField){
13847 this.hiddenField.dom.value = '';
13850 this.setRawValue('');
13851 this.lastSelectionText = '';
13852 this.lastData = false;
13854 var close = this.closeTriggerEl();
13865 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13866 * will be displayed in the field. If the value does not match the data value of an existing item,
13867 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13868 * Otherwise the field will be blank (although the value will still be set).
13869 * @param {String} value The value to match
13871 setValue : function(v)
13873 if(Roo.isIOS && this.useNativeIOS){
13874 this.setIOSValue(v);
13884 if(this.valueField){
13885 var r = this.findRecord(this.valueField, v);
13887 text = r.data[this.displayField];
13888 }else if(this.valueNotFoundText !== undefined){
13889 text = this.valueNotFoundText;
13892 this.lastSelectionText = text;
13893 if(this.hiddenField){
13894 this.hiddenField.dom.value = v;
13896 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13899 var close = this.closeTriggerEl();
13902 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13908 * @property {Object} the last set data for the element
13913 * Sets the value of the field based on a object which is related to the record format for the store.
13914 * @param {Object} value the value to set as. or false on reset?
13916 setFromData : function(o){
13923 var dv = ''; // display value
13924 var vv = ''; // value value..
13926 if (this.displayField) {
13927 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13929 // this is an error condition!!!
13930 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13933 if(this.valueField){
13934 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13937 var close = this.closeTriggerEl();
13940 if(dv.length || vv * 1 > 0){
13942 this.blockFocus=true;
13948 if(this.hiddenField){
13949 this.hiddenField.dom.value = vv;
13951 this.lastSelectionText = dv;
13952 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13956 // no hidden field.. - we store the value in 'value', but still display
13957 // display field!!!!
13958 this.lastSelectionText = dv;
13959 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13966 reset : function(){
13967 // overridden so that last data is reset..
13974 this.setValue(this.originalValue);
13975 //this.clearInvalid();
13976 this.lastData = false;
13978 this.view.clearSelections();
13984 findRecord : function(prop, value){
13986 if(this.store.getCount() > 0){
13987 this.store.each(function(r){
13988 if(r.data[prop] == value){
13998 getName: function()
14000 // returns hidden if it's set..
14001 if (!this.rendered) {return ''};
14002 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14006 onViewMove : function(e, t){
14007 this.inKeyMode = false;
14011 onViewOver : function(e, t){
14012 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14015 var item = this.view.findItemFromChild(t);
14018 var index = this.view.indexOf(item);
14019 this.select(index, false);
14024 onViewClick : function(view, doFocus, el, e)
14026 var index = this.view.getSelectedIndexes()[0];
14028 var r = this.store.getAt(index);
14032 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14039 Roo.each(this.tickItems, function(v,k){
14041 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14043 _this.tickItems.splice(k, 1);
14045 if(typeof(e) == 'undefined' && view == false){
14046 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14058 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14059 this.tickItems.push(r.data);
14062 if(typeof(e) == 'undefined' && view == false){
14063 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14070 this.onSelect(r, index);
14072 if(doFocus !== false && !this.blockFocus){
14073 this.inputEl().focus();
14078 restrictHeight : function(){
14079 //this.innerList.dom.style.height = '';
14080 //var inner = this.innerList.dom;
14081 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14082 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14083 //this.list.beginUpdate();
14084 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14085 this.list.alignTo(this.inputEl(), this.listAlign);
14086 this.list.alignTo(this.inputEl(), this.listAlign);
14087 //this.list.endUpdate();
14091 onEmptyResults : function(){
14093 if(this.tickable && this.editable){
14094 this.hasFocus = false;
14095 this.restrictHeight();
14103 * Returns true if the dropdown list is expanded, else false.
14105 isExpanded : function(){
14106 return this.list.isVisible();
14110 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14111 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14112 * @param {String} value The data value of the item to select
14113 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14114 * selected item if it is not currently in view (defaults to true)
14115 * @return {Boolean} True if the value matched an item in the list, else false
14117 selectByValue : function(v, scrollIntoView){
14118 if(v !== undefined && v !== null){
14119 var r = this.findRecord(this.valueField || this.displayField, v);
14121 this.select(this.store.indexOf(r), scrollIntoView);
14129 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14130 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14131 * @param {Number} index The zero-based index of the list item to select
14132 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14133 * selected item if it is not currently in view (defaults to true)
14135 select : function(index, scrollIntoView){
14136 this.selectedIndex = index;
14137 this.view.select(index);
14138 if(scrollIntoView !== false){
14139 var el = this.view.getNode(index);
14141 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14144 this.list.scrollChildIntoView(el, false);
14150 selectNext : function(){
14151 var ct = this.store.getCount();
14153 if(this.selectedIndex == -1){
14155 }else if(this.selectedIndex < ct-1){
14156 this.select(this.selectedIndex+1);
14162 selectPrev : function(){
14163 var ct = this.store.getCount();
14165 if(this.selectedIndex == -1){
14167 }else if(this.selectedIndex != 0){
14168 this.select(this.selectedIndex-1);
14174 onKeyUp : function(e){
14175 if(this.editable !== false && !e.isSpecialKey()){
14176 this.lastKey = e.getKey();
14177 this.dqTask.delay(this.queryDelay);
14182 validateBlur : function(){
14183 return !this.list || !this.list.isVisible();
14187 initQuery : function(){
14189 var v = this.getRawValue();
14191 if(this.tickable && this.editable){
14192 v = this.tickableInputEl().getValue();
14199 doForce : function(){
14200 if(this.inputEl().dom.value.length > 0){
14201 this.inputEl().dom.value =
14202 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14208 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14209 * query allowing the query action to be canceled if needed.
14210 * @param {String} query The SQL query to execute
14211 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14212 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14213 * saved in the current store (defaults to false)
14215 doQuery : function(q, forceAll){
14217 if(q === undefined || q === null){
14222 forceAll: forceAll,
14226 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14231 forceAll = qe.forceAll;
14232 if(forceAll === true || (q.length >= this.minChars)){
14234 this.hasQuery = true;
14236 if(this.lastQuery != q || this.alwaysQuery){
14237 this.lastQuery = q;
14238 if(this.mode == 'local'){
14239 this.selectedIndex = -1;
14241 this.store.clearFilter();
14244 if(this.specialFilter){
14245 this.fireEvent('specialfilter', this);
14250 this.store.filter(this.displayField, q);
14253 this.store.fireEvent("datachanged", this.store);
14260 this.store.baseParams[this.queryParam] = q;
14262 var options = {params : this.getParams(q)};
14265 options.add = true;
14266 options.params.start = this.page * this.pageSize;
14269 this.store.load(options);
14272 * this code will make the page width larger, at the beginning, the list not align correctly,
14273 * we should expand the list on onLoad
14274 * so command out it
14279 this.selectedIndex = -1;
14284 this.loadNext = false;
14288 getParams : function(q){
14290 //p[this.queryParam] = q;
14294 p.limit = this.pageSize;
14300 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14302 collapse : function(){
14303 if(!this.isExpanded()){
14309 this.hasFocus = false;
14313 this.cancelBtn.hide();
14314 this.trigger.show();
14317 this.tickableInputEl().dom.value = '';
14318 this.tickableInputEl().blur();
14323 Roo.get(document).un('mousedown', this.collapseIf, this);
14324 Roo.get(document).un('mousewheel', this.collapseIf, this);
14325 if (!this.editable) {
14326 Roo.get(document).un('keydown', this.listKeyPress, this);
14328 this.fireEvent('collapse', this);
14334 collapseIf : function(e){
14335 var in_combo = e.within(this.el);
14336 var in_list = e.within(this.list);
14337 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14339 if (in_combo || in_list || is_list) {
14340 //e.stopPropagation();
14345 this.onTickableFooterButtonClick(e, false, false);
14353 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14355 expand : function(){
14357 if(this.isExpanded() || !this.hasFocus){
14361 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14362 this.list.setWidth(lw);
14368 this.restrictHeight();
14372 this.tickItems = Roo.apply([], this.item);
14375 this.cancelBtn.show();
14376 this.trigger.hide();
14379 this.tickableInputEl().focus();
14384 Roo.get(document).on('mousedown', this.collapseIf, this);
14385 Roo.get(document).on('mousewheel', this.collapseIf, this);
14386 if (!this.editable) {
14387 Roo.get(document).on('keydown', this.listKeyPress, this);
14390 this.fireEvent('expand', this);
14394 // Implements the default empty TriggerField.onTriggerClick function
14395 onTriggerClick : function(e)
14397 Roo.log('trigger click');
14399 if(this.disabled || !this.triggerList){
14404 this.loadNext = false;
14406 if(this.isExpanded()){
14408 if (!this.blockFocus) {
14409 this.inputEl().focus();
14413 this.hasFocus = true;
14414 if(this.triggerAction == 'all') {
14415 this.doQuery(this.allQuery, true);
14417 this.doQuery(this.getRawValue());
14419 if (!this.blockFocus) {
14420 this.inputEl().focus();
14425 onTickableTriggerClick : function(e)
14432 this.loadNext = false;
14433 this.hasFocus = true;
14435 if(this.triggerAction == 'all') {
14436 this.doQuery(this.allQuery, true);
14438 this.doQuery(this.getRawValue());
14442 onSearchFieldClick : function(e)
14444 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14445 this.onTickableFooterButtonClick(e, false, false);
14449 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14454 this.loadNext = false;
14455 this.hasFocus = true;
14457 if(this.triggerAction == 'all') {
14458 this.doQuery(this.allQuery, true);
14460 this.doQuery(this.getRawValue());
14464 listKeyPress : function(e)
14466 //Roo.log('listkeypress');
14467 // scroll to first matching element based on key pres..
14468 if (e.isSpecialKey()) {
14471 var k = String.fromCharCode(e.getKey()).toUpperCase();
14474 var csel = this.view.getSelectedNodes();
14475 var cselitem = false;
14477 var ix = this.view.indexOf(csel[0]);
14478 cselitem = this.store.getAt(ix);
14479 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14485 this.store.each(function(v) {
14487 // start at existing selection.
14488 if (cselitem.id == v.id) {
14494 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14495 match = this.store.indexOf(v);
14501 if (match === false) {
14502 return true; // no more action?
14505 this.view.select(match);
14506 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14507 sn.scrollIntoView(sn.dom.parentNode, false);
14510 onViewScroll : function(e, t){
14512 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){
14516 this.hasQuery = true;
14518 this.loading = this.list.select('.loading', true).first();
14520 if(this.loading === null){
14521 this.list.createChild({
14523 cls: 'loading roo-select2-more-results roo-select2-active',
14524 html: 'Loading more results...'
14527 this.loading = this.list.select('.loading', true).first();
14529 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14531 this.loading.hide();
14534 this.loading.show();
14539 this.loadNext = true;
14541 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14546 addItem : function(o)
14548 var dv = ''; // display value
14550 if (this.displayField) {
14551 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14553 // this is an error condition!!!
14554 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14561 var choice = this.choices.createChild({
14563 cls: 'roo-select2-search-choice',
14572 cls: 'roo-select2-search-choice-close fa fa-times',
14577 }, this.searchField);
14579 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14581 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14589 this.inputEl().dom.value = '';
14594 onRemoveItem : function(e, _self, o)
14596 e.preventDefault();
14598 this.lastItem = Roo.apply([], this.item);
14600 var index = this.item.indexOf(o.data) * 1;
14603 Roo.log('not this item?!');
14607 this.item.splice(index, 1);
14612 this.fireEvent('remove', this, e);
14618 syncValue : function()
14620 if(!this.item.length){
14627 Roo.each(this.item, function(i){
14628 if(_this.valueField){
14629 value.push(i[_this.valueField]);
14636 this.value = value.join(',');
14638 if(this.hiddenField){
14639 this.hiddenField.dom.value = this.value;
14642 this.store.fireEvent("datachanged", this.store);
14647 clearItem : function()
14649 if(!this.multiple){
14655 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14663 if(this.tickable && !Roo.isTouch){
14664 this.view.refresh();
14668 inputEl: function ()
14670 if(Roo.isIOS && this.useNativeIOS){
14671 return this.el.select('select.roo-ios-select', true).first();
14674 if(Roo.isTouch && this.mobileTouchView){
14675 return this.el.select('input.form-control',true).first();
14679 return this.searchField;
14682 return this.el.select('input.form-control',true).first();
14685 onTickableFooterButtonClick : function(e, btn, el)
14687 e.preventDefault();
14689 this.lastItem = Roo.apply([], this.item);
14691 if(btn && btn.name == 'cancel'){
14692 this.tickItems = Roo.apply([], this.item);
14701 Roo.each(this.tickItems, function(o){
14709 validate : function()
14711 if(this.getEl().hasClass('hidden')){
14715 var v = this.getRawValue();
14718 v = this.getValue();
14721 if(this.disabled || this.allowBlank || v.length){
14726 this.markInvalid();
14730 tickableInputEl : function()
14732 if(!this.tickable || !this.editable){
14733 return this.inputEl();
14736 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14740 getAutoCreateTouchView : function()
14745 cls: 'form-group' //input-group
14751 type : this.inputType,
14752 cls : 'form-control x-combo-noedit',
14753 autocomplete: 'new-password',
14754 placeholder : this.placeholder || '',
14759 input.name = this.name;
14763 input.cls += ' input-' + this.size;
14766 if (this.disabled) {
14767 input.disabled = true;
14778 inputblock.cls += ' input-group';
14780 inputblock.cn.unshift({
14782 cls : 'input-group-addon',
14787 if(this.removable && !this.multiple){
14788 inputblock.cls += ' roo-removable';
14790 inputblock.cn.push({
14793 cls : 'roo-combo-removable-btn close'
14797 if(this.hasFeedback && !this.allowBlank){
14799 inputblock.cls += ' has-feedback';
14801 inputblock.cn.push({
14803 cls: 'glyphicon form-control-feedback'
14810 inputblock.cls += (this.before) ? '' : ' input-group';
14812 inputblock.cn.push({
14814 cls : 'input-group-addon',
14825 cls: 'form-hidden-field'
14839 cls: 'form-hidden-field'
14843 cls: 'roo-select2-choices',
14847 cls: 'roo-select2-search-field',
14860 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14866 if(!this.multiple && this.showToggleBtn){
14873 if (this.caret != false) {
14876 cls: 'fa fa-' + this.caret
14883 cls : 'input-group-addon btn dropdown-toggle',
14888 cls: 'combobox-clear',
14902 combobox.cls += ' roo-select2-container-multi';
14905 var align = this.labelAlign || this.parentLabelAlign();
14907 if (align ==='left' && this.fieldLabel.length) {
14912 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14913 tooltip : 'This field is required'
14917 cls : 'control-label',
14918 html : this.fieldLabel
14929 var labelCfg = cfg.cn[1];
14930 var contentCfg = cfg.cn[2];
14933 if(this.indicatorpos == 'right'){
14938 cls : 'control-label',
14942 html : this.fieldLabel
14946 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14947 tooltip : 'This field is required'
14960 labelCfg = cfg.cn[0];
14961 contentCfg = cfg.cn[1];
14966 if(this.labelWidth > 12){
14967 labelCfg.style = "width: " + this.labelWidth + 'px';
14970 if(this.labelWidth < 13 && this.labelmd == 0){
14971 this.labelmd = this.labelWidth;
14974 if(this.labellg > 0){
14975 labelCfg.cls += ' col-lg-' + this.labellg;
14976 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14979 if(this.labelmd > 0){
14980 labelCfg.cls += ' col-md-' + this.labelmd;
14981 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14984 if(this.labelsm > 0){
14985 labelCfg.cls += ' col-sm-' + this.labelsm;
14986 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14989 if(this.labelxs > 0){
14990 labelCfg.cls += ' col-xs-' + this.labelxs;
14991 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14995 } else if ( this.fieldLabel.length) {
14999 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15000 tooltip : 'This field is required'
15004 cls : 'control-label',
15005 html : this.fieldLabel
15016 if(this.indicatorpos == 'right'){
15020 cls : 'control-label',
15021 html : this.fieldLabel,
15025 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15026 tooltip : 'This field is required'
15043 var settings = this;
15045 ['xs','sm','md','lg'].map(function(size){
15046 if (settings[size]) {
15047 cfg.cls += ' col-' + size + '-' + settings[size];
15054 initTouchView : function()
15056 this.renderTouchView();
15058 this.touchViewEl.on('scroll', function(){
15059 this.el.dom.scrollTop = 0;
15062 this.originalValue = this.getValue();
15064 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15066 this.inputEl().on("click", this.showTouchView, this);
15067 if (this.triggerEl) {
15068 this.triggerEl.on("click", this.showTouchView, this);
15072 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15073 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15075 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15077 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15078 this.store.on('load', this.onTouchViewLoad, this);
15079 this.store.on('loadexception', this.onTouchViewLoadException, this);
15081 if(this.hiddenName){
15083 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15085 this.hiddenField.dom.value =
15086 this.hiddenValue !== undefined ? this.hiddenValue :
15087 this.value !== undefined ? this.value : '';
15089 this.el.dom.removeAttribute('name');
15090 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15094 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15095 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15098 if(this.removable && !this.multiple){
15099 var close = this.closeTriggerEl();
15101 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15102 close.on('click', this.removeBtnClick, this, close);
15106 * fix the bug in Safari iOS8
15108 this.inputEl().on("focus", function(e){
15109 document.activeElement.blur();
15117 renderTouchView : function()
15119 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15120 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15122 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15123 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15125 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15126 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15127 this.touchViewBodyEl.setStyle('overflow', 'auto');
15129 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15130 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15132 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15133 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15137 showTouchView : function()
15143 this.touchViewHeaderEl.hide();
15145 if(this.modalTitle.length){
15146 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15147 this.touchViewHeaderEl.show();
15150 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15151 this.touchViewEl.show();
15153 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15155 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15156 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15158 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15160 if(this.modalTitle.length){
15161 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15164 this.touchViewBodyEl.setHeight(bodyHeight);
15168 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15170 this.touchViewEl.addClass('in');
15173 this.doTouchViewQuery();
15177 hideTouchView : function()
15179 this.touchViewEl.removeClass('in');
15183 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15185 this.touchViewEl.setStyle('display', 'none');
15190 setTouchViewValue : function()
15197 Roo.each(this.tickItems, function(o){
15202 this.hideTouchView();
15205 doTouchViewQuery : function()
15214 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15218 if(!this.alwaysQuery || this.mode == 'local'){
15219 this.onTouchViewLoad();
15226 onTouchViewBeforeLoad : function(combo,opts)
15232 onTouchViewLoad : function()
15234 if(this.store.getCount() < 1){
15235 this.onTouchViewEmptyResults();
15239 this.clearTouchView();
15241 var rawValue = this.getRawValue();
15243 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15245 this.tickItems = [];
15247 this.store.data.each(function(d, rowIndex){
15248 var row = this.touchViewListGroup.createChild(template);
15250 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15251 row.addClass(d.data.cls);
15254 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15257 html : d.data[this.displayField]
15260 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15261 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15264 row.removeClass('selected');
15265 if(!this.multiple && this.valueField &&
15266 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15269 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15270 row.addClass('selected');
15273 if(this.multiple && this.valueField &&
15274 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15278 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15279 this.tickItems.push(d.data);
15282 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15286 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15288 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15290 if(this.modalTitle.length){
15291 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15294 var listHeight = this.touchViewListGroup.getHeight();
15298 if(firstChecked && listHeight > bodyHeight){
15299 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15304 onTouchViewLoadException : function()
15306 this.hideTouchView();
15309 onTouchViewEmptyResults : function()
15311 this.clearTouchView();
15313 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15315 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15319 clearTouchView : function()
15321 this.touchViewListGroup.dom.innerHTML = '';
15324 onTouchViewClick : function(e, el, o)
15326 e.preventDefault();
15329 var rowIndex = o.rowIndex;
15331 var r = this.store.getAt(rowIndex);
15333 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15335 if(!this.multiple){
15336 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15337 c.dom.removeAttribute('checked');
15340 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15342 this.setFromData(r.data);
15344 var close = this.closeTriggerEl();
15350 this.hideTouchView();
15352 this.fireEvent('select', this, r, rowIndex);
15357 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15358 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15359 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15363 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15364 this.addItem(r.data);
15365 this.tickItems.push(r.data);
15369 getAutoCreateNativeIOS : function()
15372 cls: 'form-group' //input-group,
15377 cls : 'roo-ios-select'
15381 combobox.name = this.name;
15384 if (this.disabled) {
15385 combobox.disabled = true;
15388 var settings = this;
15390 ['xs','sm','md','lg'].map(function(size){
15391 if (settings[size]) {
15392 cfg.cls += ' col-' + size + '-' + settings[size];
15402 initIOSView : function()
15404 this.store.on('load', this.onIOSViewLoad, this);
15409 onIOSViewLoad : function()
15411 if(this.store.getCount() < 1){
15415 this.clearIOSView();
15417 if(this.allowBlank) {
15419 var default_text = '-- SELECT --';
15421 if(this.placeholder.length){
15422 default_text = this.placeholder;
15425 if(this.emptyTitle.length){
15426 default_text += ' - ' + this.emptyTitle + ' -';
15429 var opt = this.inputEl().createChild({
15432 html : default_text
15436 o[this.valueField] = 0;
15437 o[this.displayField] = default_text;
15439 this.ios_options.push({
15446 this.store.data.each(function(d, rowIndex){
15450 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15451 html = d.data[this.displayField];
15456 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15457 value = d.data[this.valueField];
15466 if(this.value == d.data[this.valueField]){
15467 option['selected'] = true;
15470 var opt = this.inputEl().createChild(option);
15472 this.ios_options.push({
15479 this.inputEl().on('change', function(){
15480 this.fireEvent('select', this);
15485 clearIOSView: function()
15487 this.inputEl().dom.innerHTML = '';
15489 this.ios_options = [];
15492 setIOSValue: function(v)
15496 if(!this.ios_options){
15500 Roo.each(this.ios_options, function(opts){
15502 opts.el.dom.removeAttribute('selected');
15504 if(opts.data[this.valueField] != v){
15508 opts.el.dom.setAttribute('selected', true);
15514 * @cfg {Boolean} grow
15518 * @cfg {Number} growMin
15522 * @cfg {Number} growMax
15531 Roo.apply(Roo.bootstrap.ComboBox, {
15535 cls: 'modal-header',
15557 cls: 'list-group-item',
15561 cls: 'roo-combobox-list-group-item-value'
15565 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15579 listItemCheckbox : {
15581 cls: 'list-group-item',
15585 cls: 'roo-combobox-list-group-item-value'
15589 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15605 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15610 cls: 'modal-footer',
15618 cls: 'col-xs-6 text-left',
15621 cls: 'btn btn-danger roo-touch-view-cancel',
15627 cls: 'col-xs-6 text-right',
15630 cls: 'btn btn-success roo-touch-view-ok',
15641 Roo.apply(Roo.bootstrap.ComboBox, {
15643 touchViewTemplate : {
15645 cls: 'modal fade roo-combobox-touch-view',
15649 cls: 'modal-dialog',
15650 style : 'position:fixed', // we have to fix position....
15654 cls: 'modal-content',
15656 Roo.bootstrap.ComboBox.header,
15657 Roo.bootstrap.ComboBox.body,
15658 Roo.bootstrap.ComboBox.footer
15667 * Ext JS Library 1.1.1
15668 * Copyright(c) 2006-2007, Ext JS, LLC.
15670 * Originally Released Under LGPL - original licence link has changed is not relivant.
15673 * <script type="text/javascript">
15678 * @extends Roo.util.Observable
15679 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15680 * This class also supports single and multi selection modes. <br>
15681 * Create a data model bound view:
15683 var store = new Roo.data.Store(...);
15685 var view = new Roo.View({
15687 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15689 singleSelect: true,
15690 selectedClass: "ydataview-selected",
15694 // listen for node click?
15695 view.on("click", function(vw, index, node, e){
15696 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15700 dataModel.load("foobar.xml");
15702 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15704 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15705 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15707 * Note: old style constructor is still suported (container, template, config)
15710 * Create a new View
15711 * @param {Object} config The config object
15714 Roo.View = function(config, depreciated_tpl, depreciated_config){
15716 this.parent = false;
15718 if (typeof(depreciated_tpl) == 'undefined') {
15719 // new way.. - universal constructor.
15720 Roo.apply(this, config);
15721 this.el = Roo.get(this.el);
15724 this.el = Roo.get(config);
15725 this.tpl = depreciated_tpl;
15726 Roo.apply(this, depreciated_config);
15728 this.wrapEl = this.el.wrap().wrap();
15729 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15732 if(typeof(this.tpl) == "string"){
15733 this.tpl = new Roo.Template(this.tpl);
15735 // support xtype ctors..
15736 this.tpl = new Roo.factory(this.tpl, Roo);
15740 this.tpl.compile();
15745 * @event beforeclick
15746 * Fires before a click is processed. Returns false to cancel the default action.
15747 * @param {Roo.View} this
15748 * @param {Number} index The index of the target node
15749 * @param {HTMLElement} node The target node
15750 * @param {Roo.EventObject} e The raw event object
15752 "beforeclick" : true,
15755 * Fires when a template node is clicked.
15756 * @param {Roo.View} this
15757 * @param {Number} index The index of the target node
15758 * @param {HTMLElement} node The target node
15759 * @param {Roo.EventObject} e The raw event object
15764 * Fires when a template node is double clicked.
15765 * @param {Roo.View} this
15766 * @param {Number} index The index of the target node
15767 * @param {HTMLElement} node The target node
15768 * @param {Roo.EventObject} e The raw event object
15772 * @event contextmenu
15773 * Fires when a template node is right clicked.
15774 * @param {Roo.View} this
15775 * @param {Number} index The index of the target node
15776 * @param {HTMLElement} node The target node
15777 * @param {Roo.EventObject} e The raw event object
15779 "contextmenu" : true,
15781 * @event selectionchange
15782 * Fires when the selected nodes change.
15783 * @param {Roo.View} this
15784 * @param {Array} selections Array of the selected nodes
15786 "selectionchange" : true,
15789 * @event beforeselect
15790 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15791 * @param {Roo.View} this
15792 * @param {HTMLElement} node The node to be selected
15793 * @param {Array} selections Array of currently selected nodes
15795 "beforeselect" : true,
15797 * @event preparedata
15798 * Fires on every row to render, to allow you to change the data.
15799 * @param {Roo.View} this
15800 * @param {Object} data to be rendered (change this)
15802 "preparedata" : true
15810 "click": this.onClick,
15811 "dblclick": this.onDblClick,
15812 "contextmenu": this.onContextMenu,
15816 this.selections = [];
15818 this.cmp = new Roo.CompositeElementLite([]);
15820 this.store = Roo.factory(this.store, Roo.data);
15821 this.setStore(this.store, true);
15824 if ( this.footer && this.footer.xtype) {
15826 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15828 this.footer.dataSource = this.store;
15829 this.footer.container = fctr;
15830 this.footer = Roo.factory(this.footer, Roo);
15831 fctr.insertFirst(this.el);
15833 // this is a bit insane - as the paging toolbar seems to detach the el..
15834 // dom.parentNode.parentNode.parentNode
15835 // they get detached?
15839 Roo.View.superclass.constructor.call(this);
15844 Roo.extend(Roo.View, Roo.util.Observable, {
15847 * @cfg {Roo.data.Store} store Data store to load data from.
15852 * @cfg {String|Roo.Element} el The container element.
15857 * @cfg {String|Roo.Template} tpl The template used by this View
15861 * @cfg {String} dataName the named area of the template to use as the data area
15862 * Works with domtemplates roo-name="name"
15866 * @cfg {String} selectedClass The css class to add to selected nodes
15868 selectedClass : "x-view-selected",
15870 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15875 * @cfg {String} text to display on mask (default Loading)
15879 * @cfg {Boolean} multiSelect Allow multiple selection
15881 multiSelect : false,
15883 * @cfg {Boolean} singleSelect Allow single selection
15885 singleSelect: false,
15888 * @cfg {Boolean} toggleSelect - selecting
15890 toggleSelect : false,
15893 * @cfg {Boolean} tickable - selecting
15898 * Returns the element this view is bound to.
15899 * @return {Roo.Element}
15901 getEl : function(){
15902 return this.wrapEl;
15908 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15910 refresh : function(){
15911 //Roo.log('refresh');
15914 // if we are using something like 'domtemplate', then
15915 // the what gets used is:
15916 // t.applySubtemplate(NAME, data, wrapping data..)
15917 // the outer template then get' applied with
15918 // the store 'extra data'
15919 // and the body get's added to the
15920 // roo-name="data" node?
15921 // <span class='roo-tpl-{name}'></span> ?????
15925 this.clearSelections();
15926 this.el.update("");
15928 var records = this.store.getRange();
15929 if(records.length < 1) {
15931 // is this valid?? = should it render a template??
15933 this.el.update(this.emptyText);
15937 if (this.dataName) {
15938 this.el.update(t.apply(this.store.meta)); //????
15939 el = this.el.child('.roo-tpl-' + this.dataName);
15942 for(var i = 0, len = records.length; i < len; i++){
15943 var data = this.prepareData(records[i].data, i, records[i]);
15944 this.fireEvent("preparedata", this, data, i, records[i]);
15946 var d = Roo.apply({}, data);
15949 Roo.apply(d, {'roo-id' : Roo.id()});
15953 Roo.each(this.parent.item, function(item){
15954 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15957 Roo.apply(d, {'roo-data-checked' : 'checked'});
15961 html[html.length] = Roo.util.Format.trim(
15963 t.applySubtemplate(this.dataName, d, this.store.meta) :
15970 el.update(html.join(""));
15971 this.nodes = el.dom.childNodes;
15972 this.updateIndexes(0);
15977 * Function to override to reformat the data that is sent to
15978 * the template for each node.
15979 * DEPRICATED - use the preparedata event handler.
15980 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15981 * a JSON object for an UpdateManager bound view).
15983 prepareData : function(data, index, record)
15985 this.fireEvent("preparedata", this, data, index, record);
15989 onUpdate : function(ds, record){
15990 // Roo.log('on update');
15991 this.clearSelections();
15992 var index = this.store.indexOf(record);
15993 var n = this.nodes[index];
15994 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15995 n.parentNode.removeChild(n);
15996 this.updateIndexes(index, index);
16002 onAdd : function(ds, records, index)
16004 //Roo.log(['on Add', ds, records, index] );
16005 this.clearSelections();
16006 if(this.nodes.length == 0){
16010 var n = this.nodes[index];
16011 for(var i = 0, len = records.length; i < len; i++){
16012 var d = this.prepareData(records[i].data, i, records[i]);
16014 this.tpl.insertBefore(n, d);
16017 this.tpl.append(this.el, d);
16020 this.updateIndexes(index);
16023 onRemove : function(ds, record, index){
16024 // Roo.log('onRemove');
16025 this.clearSelections();
16026 var el = this.dataName ?
16027 this.el.child('.roo-tpl-' + this.dataName) :
16030 el.dom.removeChild(this.nodes[index]);
16031 this.updateIndexes(index);
16035 * Refresh an individual node.
16036 * @param {Number} index
16038 refreshNode : function(index){
16039 this.onUpdate(this.store, this.store.getAt(index));
16042 updateIndexes : function(startIndex, endIndex){
16043 var ns = this.nodes;
16044 startIndex = startIndex || 0;
16045 endIndex = endIndex || ns.length - 1;
16046 for(var i = startIndex; i <= endIndex; i++){
16047 ns[i].nodeIndex = i;
16052 * Changes the data store this view uses and refresh the view.
16053 * @param {Store} store
16055 setStore : function(store, initial){
16056 if(!initial && this.store){
16057 this.store.un("datachanged", this.refresh);
16058 this.store.un("add", this.onAdd);
16059 this.store.un("remove", this.onRemove);
16060 this.store.un("update", this.onUpdate);
16061 this.store.un("clear", this.refresh);
16062 this.store.un("beforeload", this.onBeforeLoad);
16063 this.store.un("load", this.onLoad);
16064 this.store.un("loadexception", this.onLoad);
16068 store.on("datachanged", this.refresh, this);
16069 store.on("add", this.onAdd, this);
16070 store.on("remove", this.onRemove, this);
16071 store.on("update", this.onUpdate, this);
16072 store.on("clear", this.refresh, this);
16073 store.on("beforeload", this.onBeforeLoad, this);
16074 store.on("load", this.onLoad, this);
16075 store.on("loadexception", this.onLoad, this);
16083 * onbeforeLoad - masks the loading area.
16086 onBeforeLoad : function(store,opts)
16088 //Roo.log('onBeforeLoad');
16090 this.el.update("");
16092 this.el.mask(this.mask ? this.mask : "Loading" );
16094 onLoad : function ()
16101 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16102 * @param {HTMLElement} node
16103 * @return {HTMLElement} The template node
16105 findItemFromChild : function(node){
16106 var el = this.dataName ?
16107 this.el.child('.roo-tpl-' + this.dataName,true) :
16110 if(!node || node.parentNode == el){
16113 var p = node.parentNode;
16114 while(p && p != el){
16115 if(p.parentNode == el){
16124 onClick : function(e){
16125 var item = this.findItemFromChild(e.getTarget());
16127 var index = this.indexOf(item);
16128 if(this.onItemClick(item, index, e) !== false){
16129 this.fireEvent("click", this, index, item, e);
16132 this.clearSelections();
16137 onContextMenu : function(e){
16138 var item = this.findItemFromChild(e.getTarget());
16140 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16145 onDblClick : function(e){
16146 var item = this.findItemFromChild(e.getTarget());
16148 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16152 onItemClick : function(item, index, e)
16154 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16157 if (this.toggleSelect) {
16158 var m = this.isSelected(item) ? 'unselect' : 'select';
16161 _t[m](item, true, false);
16164 if(this.multiSelect || this.singleSelect){
16165 if(this.multiSelect && e.shiftKey && this.lastSelection){
16166 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16168 this.select(item, this.multiSelect && e.ctrlKey);
16169 this.lastSelection = item;
16172 if(!this.tickable){
16173 e.preventDefault();
16181 * Get the number of selected nodes.
16184 getSelectionCount : function(){
16185 return this.selections.length;
16189 * Get the currently selected nodes.
16190 * @return {Array} An array of HTMLElements
16192 getSelectedNodes : function(){
16193 return this.selections;
16197 * Get the indexes of the selected nodes.
16200 getSelectedIndexes : function(){
16201 var indexes = [], s = this.selections;
16202 for(var i = 0, len = s.length; i < len; i++){
16203 indexes.push(s[i].nodeIndex);
16209 * Clear all selections
16210 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16212 clearSelections : function(suppressEvent){
16213 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16214 this.cmp.elements = this.selections;
16215 this.cmp.removeClass(this.selectedClass);
16216 this.selections = [];
16217 if(!suppressEvent){
16218 this.fireEvent("selectionchange", this, this.selections);
16224 * Returns true if the passed node is selected
16225 * @param {HTMLElement/Number} node The node or node index
16226 * @return {Boolean}
16228 isSelected : function(node){
16229 var s = this.selections;
16233 node = this.getNode(node);
16234 return s.indexOf(node) !== -1;
16239 * @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
16240 * @param {Boolean} keepExisting (optional) true to keep existing selections
16241 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16243 select : function(nodeInfo, keepExisting, suppressEvent){
16244 if(nodeInfo instanceof Array){
16246 this.clearSelections(true);
16248 for(var i = 0, len = nodeInfo.length; i < len; i++){
16249 this.select(nodeInfo[i], true, true);
16253 var node = this.getNode(nodeInfo);
16254 if(!node || this.isSelected(node)){
16255 return; // already selected.
16258 this.clearSelections(true);
16261 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16262 Roo.fly(node).addClass(this.selectedClass);
16263 this.selections.push(node);
16264 if(!suppressEvent){
16265 this.fireEvent("selectionchange", this, this.selections);
16273 * @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
16274 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16275 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16277 unselect : function(nodeInfo, keepExisting, suppressEvent)
16279 if(nodeInfo instanceof Array){
16280 Roo.each(this.selections, function(s) {
16281 this.unselect(s, nodeInfo);
16285 var node = this.getNode(nodeInfo);
16286 if(!node || !this.isSelected(node)){
16287 //Roo.log("not selected");
16288 return; // not selected.
16292 Roo.each(this.selections, function(s) {
16294 Roo.fly(node).removeClass(this.selectedClass);
16301 this.selections= ns;
16302 this.fireEvent("selectionchange", this, this.selections);
16306 * Gets a template node.
16307 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16308 * @return {HTMLElement} The node or null if it wasn't found
16310 getNode : function(nodeInfo){
16311 if(typeof nodeInfo == "string"){
16312 return document.getElementById(nodeInfo);
16313 }else if(typeof nodeInfo == "number"){
16314 return this.nodes[nodeInfo];
16320 * Gets a range template nodes.
16321 * @param {Number} startIndex
16322 * @param {Number} endIndex
16323 * @return {Array} An array of nodes
16325 getNodes : function(start, end){
16326 var ns = this.nodes;
16327 start = start || 0;
16328 end = typeof end == "undefined" ? ns.length - 1 : end;
16331 for(var i = start; i <= end; i++){
16335 for(var i = start; i >= end; i--){
16343 * Finds the index of the passed node
16344 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16345 * @return {Number} The index of the node or -1
16347 indexOf : function(node){
16348 node = this.getNode(node);
16349 if(typeof node.nodeIndex == "number"){
16350 return node.nodeIndex;
16352 var ns = this.nodes;
16353 for(var i = 0, len = ns.length; i < len; i++){
16364 * based on jquery fullcalendar
16368 Roo.bootstrap = Roo.bootstrap || {};
16370 * @class Roo.bootstrap.Calendar
16371 * @extends Roo.bootstrap.Component
16372 * Bootstrap Calendar class
16373 * @cfg {Boolean} loadMask (true|false) default false
16374 * @cfg {Object} header generate the user specific header of the calendar, default false
16377 * Create a new Container
16378 * @param {Object} config The config object
16383 Roo.bootstrap.Calendar = function(config){
16384 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16388 * Fires when a date is selected
16389 * @param {DatePicker} this
16390 * @param {Date} date The selected date
16394 * @event monthchange
16395 * Fires when the displayed month changes
16396 * @param {DatePicker} this
16397 * @param {Date} date The selected month
16399 'monthchange': true,
16401 * @event evententer
16402 * Fires when mouse over an event
16403 * @param {Calendar} this
16404 * @param {event} Event
16406 'evententer': true,
16408 * @event eventleave
16409 * Fires when the mouse leaves an
16410 * @param {Calendar} this
16413 'eventleave': true,
16415 * @event eventclick
16416 * Fires when the mouse click an
16417 * @param {Calendar} this
16426 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16429 * @cfg {Number} startDay
16430 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16438 getAutoCreate : function(){
16441 var fc_button = function(name, corner, style, content ) {
16442 return Roo.apply({},{
16444 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16446 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16449 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16460 style : 'width:100%',
16467 cls : 'fc-header-left',
16469 fc_button('prev', 'left', 'arrow', '‹' ),
16470 fc_button('next', 'right', 'arrow', '›' ),
16471 { tag: 'span', cls: 'fc-header-space' },
16472 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16480 cls : 'fc-header-center',
16484 cls: 'fc-header-title',
16487 html : 'month / year'
16495 cls : 'fc-header-right',
16497 /* fc_button('month', 'left', '', 'month' ),
16498 fc_button('week', '', '', 'week' ),
16499 fc_button('day', 'right', '', 'day' )
16511 header = this.header;
16514 var cal_heads = function() {
16516 // fixme - handle this.
16518 for (var i =0; i < Date.dayNames.length; i++) {
16519 var d = Date.dayNames[i];
16522 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16523 html : d.substring(0,3)
16527 ret[0].cls += ' fc-first';
16528 ret[6].cls += ' fc-last';
16531 var cal_cell = function(n) {
16534 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16539 cls: 'fc-day-number',
16543 cls: 'fc-day-content',
16547 style: 'position: relative;' // height: 17px;
16559 var cal_rows = function() {
16562 for (var r = 0; r < 6; r++) {
16569 for (var i =0; i < Date.dayNames.length; i++) {
16570 var d = Date.dayNames[i];
16571 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16574 row.cn[0].cls+=' fc-first';
16575 row.cn[0].cn[0].style = 'min-height:90px';
16576 row.cn[6].cls+=' fc-last';
16580 ret[0].cls += ' fc-first';
16581 ret[4].cls += ' fc-prev-last';
16582 ret[5].cls += ' fc-last';
16589 cls: 'fc-border-separate',
16590 style : 'width:100%',
16598 cls : 'fc-first fc-last',
16616 cls : 'fc-content',
16617 style : "position: relative;",
16620 cls : 'fc-view fc-view-month fc-grid',
16621 style : 'position: relative',
16622 unselectable : 'on',
16625 cls : 'fc-event-container',
16626 style : 'position:absolute;z-index:8;top:0;left:0;'
16644 initEvents : function()
16647 throw "can not find store for calendar";
16653 style: "text-align:center",
16657 style: "background-color:white;width:50%;margin:250 auto",
16661 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16672 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16674 var size = this.el.select('.fc-content', true).first().getSize();
16675 this.maskEl.setSize(size.width, size.height);
16676 this.maskEl.enableDisplayMode("block");
16677 if(!this.loadMask){
16678 this.maskEl.hide();
16681 this.store = Roo.factory(this.store, Roo.data);
16682 this.store.on('load', this.onLoad, this);
16683 this.store.on('beforeload', this.onBeforeLoad, this);
16687 this.cells = this.el.select('.fc-day',true);
16688 //Roo.log(this.cells);
16689 this.textNodes = this.el.query('.fc-day-number');
16690 this.cells.addClassOnOver('fc-state-hover');
16692 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16693 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16694 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16695 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16697 this.on('monthchange', this.onMonthChange, this);
16699 this.update(new Date().clearTime());
16702 resize : function() {
16703 var sz = this.el.getSize();
16705 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16706 this.el.select('.fc-day-content div',true).setHeight(34);
16711 showPrevMonth : function(e){
16712 this.update(this.activeDate.add("mo", -1));
16714 showToday : function(e){
16715 this.update(new Date().clearTime());
16718 showNextMonth : function(e){
16719 this.update(this.activeDate.add("mo", 1));
16723 showPrevYear : function(){
16724 this.update(this.activeDate.add("y", -1));
16728 showNextYear : function(){
16729 this.update(this.activeDate.add("y", 1));
16734 update : function(date)
16736 var vd = this.activeDate;
16737 this.activeDate = date;
16738 // if(vd && this.el){
16739 // var t = date.getTime();
16740 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16741 // Roo.log('using add remove');
16743 // this.fireEvent('monthchange', this, date);
16745 // this.cells.removeClass("fc-state-highlight");
16746 // this.cells.each(function(c){
16747 // if(c.dateValue == t){
16748 // c.addClass("fc-state-highlight");
16749 // setTimeout(function(){
16750 // try{c.dom.firstChild.focus();}catch(e){}
16760 var days = date.getDaysInMonth();
16762 var firstOfMonth = date.getFirstDateOfMonth();
16763 var startingPos = firstOfMonth.getDay()-this.startDay;
16765 if(startingPos < this.startDay){
16769 var pm = date.add(Date.MONTH, -1);
16770 var prevStart = pm.getDaysInMonth()-startingPos;
16772 this.cells = this.el.select('.fc-day',true);
16773 this.textNodes = this.el.query('.fc-day-number');
16774 this.cells.addClassOnOver('fc-state-hover');
16776 var cells = this.cells.elements;
16777 var textEls = this.textNodes;
16779 Roo.each(cells, function(cell){
16780 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16783 days += startingPos;
16785 // convert everything to numbers so it's fast
16786 var day = 86400000;
16787 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16790 //Roo.log(prevStart);
16792 var today = new Date().clearTime().getTime();
16793 var sel = date.clearTime().getTime();
16794 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16795 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16796 var ddMatch = this.disabledDatesRE;
16797 var ddText = this.disabledDatesText;
16798 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16799 var ddaysText = this.disabledDaysText;
16800 var format = this.format;
16802 var setCellClass = function(cal, cell){
16806 //Roo.log('set Cell Class');
16808 var t = d.getTime();
16812 cell.dateValue = t;
16814 cell.className += " fc-today";
16815 cell.className += " fc-state-highlight";
16816 cell.title = cal.todayText;
16819 // disable highlight in other month..
16820 //cell.className += " fc-state-highlight";
16825 cell.className = " fc-state-disabled";
16826 cell.title = cal.minText;
16830 cell.className = " fc-state-disabled";
16831 cell.title = cal.maxText;
16835 if(ddays.indexOf(d.getDay()) != -1){
16836 cell.title = ddaysText;
16837 cell.className = " fc-state-disabled";
16840 if(ddMatch && format){
16841 var fvalue = d.dateFormat(format);
16842 if(ddMatch.test(fvalue)){
16843 cell.title = ddText.replace("%0", fvalue);
16844 cell.className = " fc-state-disabled";
16848 if (!cell.initialClassName) {
16849 cell.initialClassName = cell.dom.className;
16852 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16857 for(; i < startingPos; i++) {
16858 textEls[i].innerHTML = (++prevStart);
16859 d.setDate(d.getDate()+1);
16861 cells[i].className = "fc-past fc-other-month";
16862 setCellClass(this, cells[i]);
16867 for(; i < days; i++){
16868 intDay = i - startingPos + 1;
16869 textEls[i].innerHTML = (intDay);
16870 d.setDate(d.getDate()+1);
16872 cells[i].className = ''; // "x-date-active";
16873 setCellClass(this, cells[i]);
16877 for(; i < 42; i++) {
16878 textEls[i].innerHTML = (++extraDays);
16879 d.setDate(d.getDate()+1);
16881 cells[i].className = "fc-future fc-other-month";
16882 setCellClass(this, cells[i]);
16885 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16887 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16889 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16890 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16892 if(totalRows != 6){
16893 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16894 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16897 this.fireEvent('monthchange', this, date);
16901 if(!this.internalRender){
16902 var main = this.el.dom.firstChild;
16903 var w = main.offsetWidth;
16904 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16905 Roo.fly(main).setWidth(w);
16906 this.internalRender = true;
16907 // opera does not respect the auto grow header center column
16908 // then, after it gets a width opera refuses to recalculate
16909 // without a second pass
16910 if(Roo.isOpera && !this.secondPass){
16911 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16912 this.secondPass = true;
16913 this.update.defer(10, this, [date]);
16920 findCell : function(dt) {
16921 dt = dt.clearTime().getTime();
16923 this.cells.each(function(c){
16924 //Roo.log("check " +c.dateValue + '?=' + dt);
16925 if(c.dateValue == dt){
16935 findCells : function(ev) {
16936 var s = ev.start.clone().clearTime().getTime();
16938 var e= ev.end.clone().clearTime().getTime();
16941 this.cells.each(function(c){
16942 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16944 if(c.dateValue > e){
16947 if(c.dateValue < s){
16956 // findBestRow: function(cells)
16960 // for (var i =0 ; i < cells.length;i++) {
16961 // ret = Math.max(cells[i].rows || 0,ret);
16968 addItem : function(ev)
16970 // look for vertical location slot in
16971 var cells = this.findCells(ev);
16973 // ev.row = this.findBestRow(cells);
16975 // work out the location.
16979 for(var i =0; i < cells.length; i++) {
16981 cells[i].row = cells[0].row;
16984 cells[i].row = cells[i].row + 1;
16994 if (crow.start.getY() == cells[i].getY()) {
16996 crow.end = cells[i];
17013 cells[0].events.push(ev);
17015 this.calevents.push(ev);
17018 clearEvents: function() {
17020 if(!this.calevents){
17024 Roo.each(this.cells.elements, function(c){
17030 Roo.each(this.calevents, function(e) {
17031 Roo.each(e.els, function(el) {
17032 el.un('mouseenter' ,this.onEventEnter, this);
17033 el.un('mouseleave' ,this.onEventLeave, this);
17038 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17044 renderEvents: function()
17048 this.cells.each(function(c) {
17057 if(c.row != c.events.length){
17058 r = 4 - (4 - (c.row - c.events.length));
17061 c.events = ev.slice(0, r);
17062 c.more = ev.slice(r);
17064 if(c.more.length && c.more.length == 1){
17065 c.events.push(c.more.pop());
17068 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17072 this.cells.each(function(c) {
17074 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17077 for (var e = 0; e < c.events.length; e++){
17078 var ev = c.events[e];
17079 var rows = ev.rows;
17081 for(var i = 0; i < rows.length; i++) {
17083 // how many rows should it span..
17086 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17087 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17089 unselectable : "on",
17092 cls: 'fc-event-inner',
17096 // cls: 'fc-event-time',
17097 // html : cells.length > 1 ? '' : ev.time
17101 cls: 'fc-event-title',
17102 html : String.format('{0}', ev.title)
17109 cls: 'ui-resizable-handle ui-resizable-e',
17110 html : '  '
17117 cfg.cls += ' fc-event-start';
17119 if ((i+1) == rows.length) {
17120 cfg.cls += ' fc-event-end';
17123 var ctr = _this.el.select('.fc-event-container',true).first();
17124 var cg = ctr.createChild(cfg);
17126 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17127 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17129 var r = (c.more.length) ? 1 : 0;
17130 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17131 cg.setWidth(ebox.right - sbox.x -2);
17133 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17134 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17135 cg.on('click', _this.onEventClick, _this, ev);
17146 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17147 style : 'position: absolute',
17148 unselectable : "on",
17151 cls: 'fc-event-inner',
17155 cls: 'fc-event-title',
17163 cls: 'ui-resizable-handle ui-resizable-e',
17164 html : '  '
17170 var ctr = _this.el.select('.fc-event-container',true).first();
17171 var cg = ctr.createChild(cfg);
17173 var sbox = c.select('.fc-day-content',true).first().getBox();
17174 var ebox = c.select('.fc-day-content',true).first().getBox();
17176 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17177 cg.setWidth(ebox.right - sbox.x -2);
17179 cg.on('click', _this.onMoreEventClick, _this, c.more);
17189 onEventEnter: function (e, el,event,d) {
17190 this.fireEvent('evententer', this, el, event);
17193 onEventLeave: function (e, el,event,d) {
17194 this.fireEvent('eventleave', this, el, event);
17197 onEventClick: function (e, el,event,d) {
17198 this.fireEvent('eventclick', this, el, event);
17201 onMonthChange: function () {
17205 onMoreEventClick: function(e, el, more)
17209 this.calpopover.placement = 'right';
17210 this.calpopover.setTitle('More');
17212 this.calpopover.setContent('');
17214 var ctr = this.calpopover.el.select('.popover-content', true).first();
17216 Roo.each(more, function(m){
17218 cls : 'fc-event-hori fc-event-draggable',
17221 var cg = ctr.createChild(cfg);
17223 cg.on('click', _this.onEventClick, _this, m);
17226 this.calpopover.show(el);
17231 onLoad: function ()
17233 this.calevents = [];
17236 if(this.store.getCount() > 0){
17237 this.store.data.each(function(d){
17240 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17241 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17242 time : d.data.start_time,
17243 title : d.data.title,
17244 description : d.data.description,
17245 venue : d.data.venue
17250 this.renderEvents();
17252 if(this.calevents.length && this.loadMask){
17253 this.maskEl.hide();
17257 onBeforeLoad: function()
17259 this.clearEvents();
17261 this.maskEl.show();
17275 * @class Roo.bootstrap.Popover
17276 * @extends Roo.bootstrap.Component
17277 * Bootstrap Popover class
17278 * @cfg {String} html contents of the popover (or false to use children..)
17279 * @cfg {String} title of popover (or false to hide)
17280 * @cfg {String} placement how it is placed
17281 * @cfg {String} trigger click || hover (or false to trigger manually)
17282 * @cfg {String} over what (parent or false to trigger manually.)
17283 * @cfg {Number} delay - delay before showing
17286 * Create a new Popover
17287 * @param {Object} config The config object
17290 Roo.bootstrap.Popover = function(config){
17291 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17297 * After the popover show
17299 * @param {Roo.bootstrap.Popover} this
17304 * After the popover hide
17306 * @param {Roo.bootstrap.Popover} this
17312 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17314 title: 'Fill in a title',
17317 placement : 'right',
17318 trigger : 'hover', // hover
17324 can_build_overlaid : false,
17326 getChildContainer : function()
17328 return this.el.select('.popover-content',true).first();
17331 getAutoCreate : function(){
17334 cls : 'popover roo-dynamic',
17335 style: 'display:block',
17341 cls : 'popover-inner',
17345 cls: 'popover-title',
17349 cls : 'popover-content',
17360 setTitle: function(str)
17363 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17365 setContent: function(str)
17368 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17370 // as it get's added to the bottom of the page.
17371 onRender : function(ct, position)
17373 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17375 var cfg = Roo.apply({}, this.getAutoCreate());
17379 cfg.cls += ' ' + this.cls;
17382 cfg.style = this.style;
17384 //Roo.log("adding to ");
17385 this.el = Roo.get(document.body).createChild(cfg, position);
17386 // Roo.log(this.el);
17391 initEvents : function()
17393 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17394 this.el.enableDisplayMode('block');
17396 if (this.over === false) {
17399 if (this.triggers === false) {
17402 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17403 var triggers = this.trigger ? this.trigger.split(' ') : [];
17404 Roo.each(triggers, function(trigger) {
17406 if (trigger == 'click') {
17407 on_el.on('click', this.toggle, this);
17408 } else if (trigger != 'manual') {
17409 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17410 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17412 on_el.on(eventIn ,this.enter, this);
17413 on_el.on(eventOut, this.leave, this);
17424 toggle : function () {
17425 this.hoverState == 'in' ? this.leave() : this.enter();
17428 enter : function () {
17430 clearTimeout(this.timeout);
17432 this.hoverState = 'in';
17434 if (!this.delay || !this.delay.show) {
17439 this.timeout = setTimeout(function () {
17440 if (_t.hoverState == 'in') {
17443 }, this.delay.show)
17446 leave : function() {
17447 clearTimeout(this.timeout);
17449 this.hoverState = 'out';
17451 if (!this.delay || !this.delay.hide) {
17456 this.timeout = setTimeout(function () {
17457 if (_t.hoverState == 'out') {
17460 }, this.delay.hide)
17463 show : function (on_el)
17466 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17470 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17471 if (this.html !== false) {
17472 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17474 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17475 if (!this.title.length) {
17476 this.el.select('.popover-title',true).hide();
17479 var placement = typeof this.placement == 'function' ?
17480 this.placement.call(this, this.el, on_el) :
17483 var autoToken = /\s?auto?\s?/i;
17484 var autoPlace = autoToken.test(placement);
17486 placement = placement.replace(autoToken, '') || 'top';
17490 //this.el.setXY([0,0]);
17492 this.el.dom.style.display='block';
17493 this.el.addClass(placement);
17495 //this.el.appendTo(on_el);
17497 var p = this.getPosition();
17498 var box = this.el.getBox();
17503 var align = Roo.bootstrap.Popover.alignment[placement];
17506 this.el.alignTo(on_el, align[0],align[1]);
17507 //var arrow = this.el.select('.arrow',true).first();
17508 //arrow.set(align[2],
17510 this.el.addClass('in');
17513 if (this.el.hasClass('fade')) {
17517 this.hoverState = 'in';
17519 this.fireEvent('show', this);
17524 this.el.setXY([0,0]);
17525 this.el.removeClass('in');
17527 this.hoverState = null;
17529 this.fireEvent('hide', this);
17534 Roo.bootstrap.Popover.alignment = {
17535 'left' : ['r-l', [-10,0], 'right'],
17536 'right' : ['l-r', [10,0], 'left'],
17537 'bottom' : ['t-b', [0,10], 'top'],
17538 'top' : [ 'b-t', [0,-10], 'bottom']
17549 * @class Roo.bootstrap.Progress
17550 * @extends Roo.bootstrap.Component
17551 * Bootstrap Progress class
17552 * @cfg {Boolean} striped striped of the progress bar
17553 * @cfg {Boolean} active animated of the progress bar
17557 * Create a new Progress
17558 * @param {Object} config The config object
17561 Roo.bootstrap.Progress = function(config){
17562 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17565 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17570 getAutoCreate : function(){
17578 cfg.cls += ' progress-striped';
17582 cfg.cls += ' active';
17601 * @class Roo.bootstrap.ProgressBar
17602 * @extends Roo.bootstrap.Component
17603 * Bootstrap ProgressBar class
17604 * @cfg {Number} aria_valuenow aria-value now
17605 * @cfg {Number} aria_valuemin aria-value min
17606 * @cfg {Number} aria_valuemax aria-value max
17607 * @cfg {String} label label for the progress bar
17608 * @cfg {String} panel (success | info | warning | danger )
17609 * @cfg {String} role role of the progress bar
17610 * @cfg {String} sr_only text
17614 * Create a new ProgressBar
17615 * @param {Object} config The config object
17618 Roo.bootstrap.ProgressBar = function(config){
17619 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17622 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17626 aria_valuemax : 100,
17632 getAutoCreate : function()
17637 cls: 'progress-bar',
17638 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17650 cfg.role = this.role;
17653 if(this.aria_valuenow){
17654 cfg['aria-valuenow'] = this.aria_valuenow;
17657 if(this.aria_valuemin){
17658 cfg['aria-valuemin'] = this.aria_valuemin;
17661 if(this.aria_valuemax){
17662 cfg['aria-valuemax'] = this.aria_valuemax;
17665 if(this.label && !this.sr_only){
17666 cfg.html = this.label;
17670 cfg.cls += ' progress-bar-' + this.panel;
17676 update : function(aria_valuenow)
17678 this.aria_valuenow = aria_valuenow;
17680 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17695 * @class Roo.bootstrap.TabGroup
17696 * @extends Roo.bootstrap.Column
17697 * Bootstrap Column class
17698 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17699 * @cfg {Boolean} carousel true to make the group behave like a carousel
17700 * @cfg {Boolean} bullets show bullets for the panels
17701 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17702 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17703 * @cfg {Boolean} showarrow (true|false) show arrow default true
17706 * Create a new TabGroup
17707 * @param {Object} config The config object
17710 Roo.bootstrap.TabGroup = function(config){
17711 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17713 this.navId = Roo.id();
17716 Roo.bootstrap.TabGroup.register(this);
17720 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17723 transition : false,
17728 slideOnTouch : false,
17731 getAutoCreate : function()
17733 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17735 cfg.cls += ' tab-content';
17737 if (this.carousel) {
17738 cfg.cls += ' carousel slide';
17741 cls : 'carousel-inner',
17745 if(this.bullets && !Roo.isTouch){
17748 cls : 'carousel-bullets',
17752 if(this.bullets_cls){
17753 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17760 cfg.cn[0].cn.push(bullets);
17763 if(this.showarrow){
17764 cfg.cn[0].cn.push({
17766 class : 'carousel-arrow',
17770 class : 'carousel-prev',
17774 class : 'fa fa-chevron-left'
17780 class : 'carousel-next',
17784 class : 'fa fa-chevron-right'
17797 initEvents: function()
17799 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17800 // this.el.on("touchstart", this.onTouchStart, this);
17803 if(this.autoslide){
17806 this.slideFn = window.setInterval(function() {
17807 _this.showPanelNext();
17811 if(this.showarrow){
17812 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17813 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17819 // onTouchStart : function(e, el, o)
17821 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17825 // this.showPanelNext();
17829 getChildContainer : function()
17831 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17835 * register a Navigation item
17836 * @param {Roo.bootstrap.NavItem} the navitem to add
17838 register : function(item)
17840 this.tabs.push( item);
17841 item.navId = this.navId; // not really needed..
17846 getActivePanel : function()
17849 Roo.each(this.tabs, function(t) {
17859 getPanelByName : function(n)
17862 Roo.each(this.tabs, function(t) {
17863 if (t.tabId == n) {
17871 indexOfPanel : function(p)
17874 Roo.each(this.tabs, function(t,i) {
17875 if (t.tabId == p.tabId) {
17884 * show a specific panel
17885 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17886 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17888 showPanel : function (pan)
17890 if(this.transition || typeof(pan) == 'undefined'){
17891 Roo.log("waiting for the transitionend");
17895 if (typeof(pan) == 'number') {
17896 pan = this.tabs[pan];
17899 if (typeof(pan) == 'string') {
17900 pan = this.getPanelByName(pan);
17903 var cur = this.getActivePanel();
17906 Roo.log('pan or acitve pan is undefined');
17910 if (pan.tabId == this.getActivePanel().tabId) {
17914 if (false === cur.fireEvent('beforedeactivate')) {
17918 if(this.bullets > 0 && !Roo.isTouch){
17919 this.setActiveBullet(this.indexOfPanel(pan));
17922 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17924 this.transition = true;
17925 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17926 var lr = dir == 'next' ? 'left' : 'right';
17927 pan.el.addClass(dir); // or prev
17928 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17929 cur.el.addClass(lr); // or right
17930 pan.el.addClass(lr);
17933 cur.el.on('transitionend', function() {
17934 Roo.log("trans end?");
17936 pan.el.removeClass([lr,dir]);
17937 pan.setActive(true);
17939 cur.el.removeClass([lr]);
17940 cur.setActive(false);
17942 _this.transition = false;
17944 }, this, { single: true } );
17949 cur.setActive(false);
17950 pan.setActive(true);
17955 showPanelNext : function()
17957 var i = this.indexOfPanel(this.getActivePanel());
17959 if (i >= this.tabs.length - 1 && !this.autoslide) {
17963 if (i >= this.tabs.length - 1 && this.autoslide) {
17967 this.showPanel(this.tabs[i+1]);
17970 showPanelPrev : function()
17972 var i = this.indexOfPanel(this.getActivePanel());
17974 if (i < 1 && !this.autoslide) {
17978 if (i < 1 && this.autoslide) {
17979 i = this.tabs.length;
17982 this.showPanel(this.tabs[i-1]);
17986 addBullet: function()
17988 if(!this.bullets || Roo.isTouch){
17991 var ctr = this.el.select('.carousel-bullets',true).first();
17992 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17993 var bullet = ctr.createChild({
17994 cls : 'bullet bullet-' + i
17995 },ctr.dom.lastChild);
18000 bullet.on('click', (function(e, el, o, ii, t){
18002 e.preventDefault();
18004 this.showPanel(ii);
18006 if(this.autoslide && this.slideFn){
18007 clearInterval(this.slideFn);
18008 this.slideFn = window.setInterval(function() {
18009 _this.showPanelNext();
18013 }).createDelegate(this, [i, bullet], true));
18018 setActiveBullet : function(i)
18024 Roo.each(this.el.select('.bullet', true).elements, function(el){
18025 el.removeClass('selected');
18028 var bullet = this.el.select('.bullet-' + i, true).first();
18034 bullet.addClass('selected');
18045 Roo.apply(Roo.bootstrap.TabGroup, {
18049 * register a Navigation Group
18050 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18052 register : function(navgrp)
18054 this.groups[navgrp.navId] = navgrp;
18058 * fetch a Navigation Group based on the navigation ID
18059 * if one does not exist , it will get created.
18060 * @param {string} the navgroup to add
18061 * @returns {Roo.bootstrap.NavGroup} the navgroup
18063 get: function(navId) {
18064 if (typeof(this.groups[navId]) == 'undefined') {
18065 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18067 return this.groups[navId] ;
18082 * @class Roo.bootstrap.TabPanel
18083 * @extends Roo.bootstrap.Component
18084 * Bootstrap TabPanel class
18085 * @cfg {Boolean} active panel active
18086 * @cfg {String} html panel content
18087 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18088 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18089 * @cfg {String} href click to link..
18093 * Create a new TabPanel
18094 * @param {Object} config The config object
18097 Roo.bootstrap.TabPanel = function(config){
18098 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18102 * Fires when the active status changes
18103 * @param {Roo.bootstrap.TabPanel} this
18104 * @param {Boolean} state the new state
18109 * @event beforedeactivate
18110 * Fires before a tab is de-activated - can be used to do validation on a form.
18111 * @param {Roo.bootstrap.TabPanel} this
18112 * @return {Boolean} false if there is an error
18115 'beforedeactivate': true
18118 this.tabId = this.tabId || Roo.id();
18122 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18130 getAutoCreate : function(){
18133 // item is needed for carousel - not sure if it has any effect otherwise
18134 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18135 html: this.html || ''
18139 cfg.cls += ' active';
18143 cfg.tabId = this.tabId;
18150 initEvents: function()
18152 var p = this.parent();
18154 this.navId = this.navId || p.navId;
18156 if (typeof(this.navId) != 'undefined') {
18157 // not really needed.. but just in case.. parent should be a NavGroup.
18158 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18162 var i = tg.tabs.length - 1;
18164 if(this.active && tg.bullets > 0 && i < tg.bullets){
18165 tg.setActiveBullet(i);
18169 this.el.on('click', this.onClick, this);
18172 this.el.on("touchstart", this.onTouchStart, this);
18173 this.el.on("touchmove", this.onTouchMove, this);
18174 this.el.on("touchend", this.onTouchEnd, this);
18179 onRender : function(ct, position)
18181 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18184 setActive : function(state)
18186 Roo.log("panel - set active " + this.tabId + "=" + state);
18188 this.active = state;
18190 this.el.removeClass('active');
18192 } else if (!this.el.hasClass('active')) {
18193 this.el.addClass('active');
18196 this.fireEvent('changed', this, state);
18199 onClick : function(e)
18201 e.preventDefault();
18203 if(!this.href.length){
18207 window.location.href = this.href;
18216 onTouchStart : function(e)
18218 this.swiping = false;
18220 this.startX = e.browserEvent.touches[0].clientX;
18221 this.startY = e.browserEvent.touches[0].clientY;
18224 onTouchMove : function(e)
18226 this.swiping = true;
18228 this.endX = e.browserEvent.touches[0].clientX;
18229 this.endY = e.browserEvent.touches[0].clientY;
18232 onTouchEnd : function(e)
18239 var tabGroup = this.parent();
18241 if(this.endX > this.startX){ // swiping right
18242 tabGroup.showPanelPrev();
18246 if(this.startX > this.endX){ // swiping left
18247 tabGroup.showPanelNext();
18266 * @class Roo.bootstrap.DateField
18267 * @extends Roo.bootstrap.Input
18268 * Bootstrap DateField class
18269 * @cfg {Number} weekStart default 0
18270 * @cfg {String} viewMode default empty, (months|years)
18271 * @cfg {String} minViewMode default empty, (months|years)
18272 * @cfg {Number} startDate default -Infinity
18273 * @cfg {Number} endDate default Infinity
18274 * @cfg {Boolean} todayHighlight default false
18275 * @cfg {Boolean} todayBtn default false
18276 * @cfg {Boolean} calendarWeeks default false
18277 * @cfg {Object} daysOfWeekDisabled default empty
18278 * @cfg {Boolean} singleMode default false (true | false)
18280 * @cfg {Boolean} keyboardNavigation default true
18281 * @cfg {String} language default en
18284 * Create a new DateField
18285 * @param {Object} config The config object
18288 Roo.bootstrap.DateField = function(config){
18289 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18293 * Fires when this field show.
18294 * @param {Roo.bootstrap.DateField} this
18295 * @param {Mixed} date The date value
18300 * Fires when this field hide.
18301 * @param {Roo.bootstrap.DateField} this
18302 * @param {Mixed} date The date value
18307 * Fires when select a date.
18308 * @param {Roo.bootstrap.DateField} this
18309 * @param {Mixed} date The date value
18313 * @event beforeselect
18314 * Fires when before select a date.
18315 * @param {Roo.bootstrap.DateField} this
18316 * @param {Mixed} date The date value
18318 beforeselect : true
18322 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18325 * @cfg {String} format
18326 * The default date format string which can be overriden for localization support. The format must be
18327 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18331 * @cfg {String} altFormats
18332 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18333 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18335 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18343 todayHighlight : false,
18349 keyboardNavigation: true,
18351 calendarWeeks: false,
18353 startDate: -Infinity,
18357 daysOfWeekDisabled: [],
18361 singleMode : false,
18363 UTCDate: function()
18365 return new Date(Date.UTC.apply(Date, arguments));
18368 UTCToday: function()
18370 var today = new Date();
18371 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18374 getDate: function() {
18375 var d = this.getUTCDate();
18376 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18379 getUTCDate: function() {
18383 setDate: function(d) {
18384 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18387 setUTCDate: function(d) {
18389 this.setValue(this.formatDate(this.date));
18392 onRender: function(ct, position)
18395 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18397 this.language = this.language || 'en';
18398 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18399 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18401 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18402 this.format = this.format || 'm/d/y';
18403 this.isInline = false;
18404 this.isInput = true;
18405 this.component = this.el.select('.add-on', true).first() || false;
18406 this.component = (this.component && this.component.length === 0) ? false : this.component;
18407 this.hasInput = this.component && this.inputEl().length;
18409 if (typeof(this.minViewMode === 'string')) {
18410 switch (this.minViewMode) {
18412 this.minViewMode = 1;
18415 this.minViewMode = 2;
18418 this.minViewMode = 0;
18423 if (typeof(this.viewMode === 'string')) {
18424 switch (this.viewMode) {
18437 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18439 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18441 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18443 this.picker().on('mousedown', this.onMousedown, this);
18444 this.picker().on('click', this.onClick, this);
18446 this.picker().addClass('datepicker-dropdown');
18448 this.startViewMode = this.viewMode;
18450 if(this.singleMode){
18451 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18452 v.setVisibilityMode(Roo.Element.DISPLAY);
18456 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18457 v.setStyle('width', '189px');
18461 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18462 if(!this.calendarWeeks){
18467 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18468 v.attr('colspan', function(i, val){
18469 return parseInt(val) + 1;
18474 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18476 this.setStartDate(this.startDate);
18477 this.setEndDate(this.endDate);
18479 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18486 if(this.isInline) {
18491 picker : function()
18493 return this.pickerEl;
18494 // return this.el.select('.datepicker', true).first();
18497 fillDow: function()
18499 var dowCnt = this.weekStart;
18508 if(this.calendarWeeks){
18516 while (dowCnt < this.weekStart + 7) {
18520 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18524 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18527 fillMonths: function()
18530 var months = this.picker().select('>.datepicker-months td', true).first();
18532 months.dom.innerHTML = '';
18538 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18541 months.createChild(month);
18548 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;
18550 if (this.date < this.startDate) {
18551 this.viewDate = new Date(this.startDate);
18552 } else if (this.date > this.endDate) {
18553 this.viewDate = new Date(this.endDate);
18555 this.viewDate = new Date(this.date);
18563 var d = new Date(this.viewDate),
18564 year = d.getUTCFullYear(),
18565 month = d.getUTCMonth(),
18566 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18567 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18568 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18569 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18570 currentDate = this.date && this.date.valueOf(),
18571 today = this.UTCToday();
18573 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18575 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18577 // this.picker.select('>tfoot th.today').
18578 // .text(dates[this.language].today)
18579 // .toggle(this.todayBtn !== false);
18581 this.updateNavArrows();
18584 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18586 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18588 prevMonth.setUTCDate(day);
18590 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18592 var nextMonth = new Date(prevMonth);
18594 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18596 nextMonth = nextMonth.valueOf();
18598 var fillMonths = false;
18600 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18602 while(prevMonth.valueOf() < nextMonth) {
18605 if (prevMonth.getUTCDay() === this.weekStart) {
18607 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18615 if(this.calendarWeeks){
18616 // ISO 8601: First week contains first thursday.
18617 // ISO also states week starts on Monday, but we can be more abstract here.
18619 // Start of current week: based on weekstart/current date
18620 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18621 // Thursday of this week
18622 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18623 // First Thursday of year, year from thursday
18624 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18625 // Calendar week: ms between thursdays, div ms per day, div 7 days
18626 calWeek = (th - yth) / 864e5 / 7 + 1;
18628 fillMonths.cn.push({
18636 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18638 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18641 if (this.todayHighlight &&
18642 prevMonth.getUTCFullYear() == today.getFullYear() &&
18643 prevMonth.getUTCMonth() == today.getMonth() &&
18644 prevMonth.getUTCDate() == today.getDate()) {
18645 clsName += ' today';
18648 if (currentDate && prevMonth.valueOf() === currentDate) {
18649 clsName += ' active';
18652 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18653 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18654 clsName += ' disabled';
18657 fillMonths.cn.push({
18659 cls: 'day ' + clsName,
18660 html: prevMonth.getDate()
18663 prevMonth.setDate(prevMonth.getDate()+1);
18666 var currentYear = this.date && this.date.getUTCFullYear();
18667 var currentMonth = this.date && this.date.getUTCMonth();
18669 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18671 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18672 v.removeClass('active');
18674 if(currentYear === year && k === currentMonth){
18675 v.addClass('active');
18678 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18679 v.addClass('disabled');
18685 year = parseInt(year/10, 10) * 10;
18687 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18689 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18692 for (var i = -1; i < 11; i++) {
18693 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18695 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18703 showMode: function(dir)
18706 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18709 Roo.each(this.picker().select('>div',true).elements, function(v){
18710 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18713 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18718 if(this.isInline) {
18722 this.picker().removeClass(['bottom', 'top']);
18724 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18726 * place to the top of element!
18730 this.picker().addClass('top');
18731 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18736 this.picker().addClass('bottom');
18738 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18741 parseDate : function(value)
18743 if(!value || value instanceof Date){
18746 var v = Date.parseDate(value, this.format);
18747 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18748 v = Date.parseDate(value, 'Y-m-d');
18750 if(!v && this.altFormats){
18751 if(!this.altFormatsArray){
18752 this.altFormatsArray = this.altFormats.split("|");
18754 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18755 v = Date.parseDate(value, this.altFormatsArray[i]);
18761 formatDate : function(date, fmt)
18763 return (!date || !(date instanceof Date)) ?
18764 date : date.dateFormat(fmt || this.format);
18767 onFocus : function()
18769 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18773 onBlur : function()
18775 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18777 var d = this.inputEl().getValue();
18786 this.picker().show();
18790 this.fireEvent('show', this, this.date);
18795 if(this.isInline) {
18798 this.picker().hide();
18799 this.viewMode = this.startViewMode;
18802 this.fireEvent('hide', this, this.date);
18806 onMousedown: function(e)
18808 e.stopPropagation();
18809 e.preventDefault();
18814 Roo.bootstrap.DateField.superclass.keyup.call(this);
18818 setValue: function(v)
18820 if(this.fireEvent('beforeselect', this, v) !== false){
18821 var d = new Date(this.parseDate(v) ).clearTime();
18823 if(isNaN(d.getTime())){
18824 this.date = this.viewDate = '';
18825 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18829 v = this.formatDate(d);
18831 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18833 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18837 this.fireEvent('select', this, this.date);
18841 getValue: function()
18843 return this.formatDate(this.date);
18846 fireKey: function(e)
18848 if (!this.picker().isVisible()){
18849 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18855 var dateChanged = false,
18857 newDate, newViewDate;
18862 e.preventDefault();
18866 if (!this.keyboardNavigation) {
18869 dir = e.keyCode == 37 ? -1 : 1;
18872 newDate = this.moveYear(this.date, dir);
18873 newViewDate = this.moveYear(this.viewDate, dir);
18874 } else if (e.shiftKey){
18875 newDate = this.moveMonth(this.date, dir);
18876 newViewDate = this.moveMonth(this.viewDate, dir);
18878 newDate = new Date(this.date);
18879 newDate.setUTCDate(this.date.getUTCDate() + dir);
18880 newViewDate = new Date(this.viewDate);
18881 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18883 if (this.dateWithinRange(newDate)){
18884 this.date = newDate;
18885 this.viewDate = newViewDate;
18886 this.setValue(this.formatDate(this.date));
18888 e.preventDefault();
18889 dateChanged = true;
18894 if (!this.keyboardNavigation) {
18897 dir = e.keyCode == 38 ? -1 : 1;
18899 newDate = this.moveYear(this.date, dir);
18900 newViewDate = this.moveYear(this.viewDate, dir);
18901 } else if (e.shiftKey){
18902 newDate = this.moveMonth(this.date, dir);
18903 newViewDate = this.moveMonth(this.viewDate, dir);
18905 newDate = new Date(this.date);
18906 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18907 newViewDate = new Date(this.viewDate);
18908 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18910 if (this.dateWithinRange(newDate)){
18911 this.date = newDate;
18912 this.viewDate = newViewDate;
18913 this.setValue(this.formatDate(this.date));
18915 e.preventDefault();
18916 dateChanged = true;
18920 this.setValue(this.formatDate(this.date));
18922 e.preventDefault();
18925 this.setValue(this.formatDate(this.date));
18939 onClick: function(e)
18941 e.stopPropagation();
18942 e.preventDefault();
18944 var target = e.getTarget();
18946 if(target.nodeName.toLowerCase() === 'i'){
18947 target = Roo.get(target).dom.parentNode;
18950 var nodeName = target.nodeName;
18951 var className = target.className;
18952 var html = target.innerHTML;
18953 //Roo.log(nodeName);
18955 switch(nodeName.toLowerCase()) {
18957 switch(className) {
18963 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18964 switch(this.viewMode){
18966 this.viewDate = this.moveMonth(this.viewDate, dir);
18970 this.viewDate = this.moveYear(this.viewDate, dir);
18976 var date = new Date();
18977 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18979 this.setValue(this.formatDate(this.date));
18986 if (className.indexOf('disabled') < 0) {
18987 this.viewDate.setUTCDate(1);
18988 if (className.indexOf('month') > -1) {
18989 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18991 var year = parseInt(html, 10) || 0;
18992 this.viewDate.setUTCFullYear(year);
18996 if(this.singleMode){
18997 this.setValue(this.formatDate(this.viewDate));
19008 //Roo.log(className);
19009 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19010 var day = parseInt(html, 10) || 1;
19011 var year = this.viewDate.getUTCFullYear(),
19012 month = this.viewDate.getUTCMonth();
19014 if (className.indexOf('old') > -1) {
19021 } else if (className.indexOf('new') > -1) {
19029 //Roo.log([year,month,day]);
19030 this.date = this.UTCDate(year, month, day,0,0,0,0);
19031 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19033 //Roo.log(this.formatDate(this.date));
19034 this.setValue(this.formatDate(this.date));
19041 setStartDate: function(startDate)
19043 this.startDate = startDate || -Infinity;
19044 if (this.startDate !== -Infinity) {
19045 this.startDate = this.parseDate(this.startDate);
19048 this.updateNavArrows();
19051 setEndDate: function(endDate)
19053 this.endDate = endDate || Infinity;
19054 if (this.endDate !== Infinity) {
19055 this.endDate = this.parseDate(this.endDate);
19058 this.updateNavArrows();
19061 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19063 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19064 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19065 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19067 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19068 return parseInt(d, 10);
19071 this.updateNavArrows();
19074 updateNavArrows: function()
19076 if(this.singleMode){
19080 var d = new Date(this.viewDate),
19081 year = d.getUTCFullYear(),
19082 month = d.getUTCMonth();
19084 Roo.each(this.picker().select('.prev', true).elements, function(v){
19086 switch (this.viewMode) {
19089 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19095 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19102 Roo.each(this.picker().select('.next', true).elements, function(v){
19104 switch (this.viewMode) {
19107 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19113 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19121 moveMonth: function(date, dir)
19126 var new_date = new Date(date.valueOf()),
19127 day = new_date.getUTCDate(),
19128 month = new_date.getUTCMonth(),
19129 mag = Math.abs(dir),
19131 dir = dir > 0 ? 1 : -1;
19134 // If going back one month, make sure month is not current month
19135 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19137 return new_date.getUTCMonth() == month;
19139 // If going forward one month, make sure month is as expected
19140 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19142 return new_date.getUTCMonth() != new_month;
19144 new_month = month + dir;
19145 new_date.setUTCMonth(new_month);
19146 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19147 if (new_month < 0 || new_month > 11) {
19148 new_month = (new_month + 12) % 12;
19151 // For magnitudes >1, move one month at a time...
19152 for (var i=0; i<mag; i++) {
19153 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19154 new_date = this.moveMonth(new_date, dir);
19156 // ...then reset the day, keeping it in the new month
19157 new_month = new_date.getUTCMonth();
19158 new_date.setUTCDate(day);
19160 return new_month != new_date.getUTCMonth();
19163 // Common date-resetting loop -- if date is beyond end of month, make it
19166 new_date.setUTCDate(--day);
19167 new_date.setUTCMonth(new_month);
19172 moveYear: function(date, dir)
19174 return this.moveMonth(date, dir*12);
19177 dateWithinRange: function(date)
19179 return date >= this.startDate && date <= this.endDate;
19185 this.picker().remove();
19188 validateValue : function(value)
19190 if(this.getEl().hasClass('hidden')){
19194 if(value.length < 1) {
19195 if(this.allowBlank){
19201 if(value.length < this.minLength){
19204 if(value.length > this.maxLength){
19208 var vt = Roo.form.VTypes;
19209 if(!vt[this.vtype](value, this)){
19213 if(typeof this.validator == "function"){
19214 var msg = this.validator(value);
19220 if(this.regex && !this.regex.test(value)){
19224 if(typeof(this.parseDate(value)) == 'undefined'){
19228 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19232 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19240 setVisible : function(visible)
19246 this.getEl().removeClass('hidden');
19252 this.getEl().addClass('hidden');
19257 Roo.apply(Roo.bootstrap.DateField, {
19268 html: '<i class="fa fa-arrow-left"/>'
19278 html: '<i class="fa fa-arrow-right"/>'
19320 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19321 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19322 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19323 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19324 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19337 navFnc: 'FullYear',
19342 navFnc: 'FullYear',
19347 Roo.apply(Roo.bootstrap.DateField, {
19351 cls: 'datepicker dropdown-menu roo-dynamic',
19355 cls: 'datepicker-days',
19359 cls: 'table-condensed',
19361 Roo.bootstrap.DateField.head,
19365 Roo.bootstrap.DateField.footer
19372 cls: 'datepicker-months',
19376 cls: 'table-condensed',
19378 Roo.bootstrap.DateField.head,
19379 Roo.bootstrap.DateField.content,
19380 Roo.bootstrap.DateField.footer
19387 cls: 'datepicker-years',
19391 cls: 'table-condensed',
19393 Roo.bootstrap.DateField.head,
19394 Roo.bootstrap.DateField.content,
19395 Roo.bootstrap.DateField.footer
19414 * @class Roo.bootstrap.TimeField
19415 * @extends Roo.bootstrap.Input
19416 * Bootstrap DateField class
19420 * Create a new TimeField
19421 * @param {Object} config The config object
19424 Roo.bootstrap.TimeField = function(config){
19425 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19429 * Fires when this field show.
19430 * @param {Roo.bootstrap.DateField} thisthis
19431 * @param {Mixed} date The date value
19436 * Fires when this field hide.
19437 * @param {Roo.bootstrap.DateField} this
19438 * @param {Mixed} date The date value
19443 * Fires when select a date.
19444 * @param {Roo.bootstrap.DateField} this
19445 * @param {Mixed} date The date value
19451 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19454 * @cfg {String} format
19455 * The default time format string which can be overriden for localization support. The format must be
19456 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19460 onRender: function(ct, position)
19463 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19465 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19467 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19469 this.pop = this.picker().select('>.datepicker-time',true).first();
19470 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19472 this.picker().on('mousedown', this.onMousedown, this);
19473 this.picker().on('click', this.onClick, this);
19475 this.picker().addClass('datepicker-dropdown');
19480 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19481 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19482 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19483 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19484 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19485 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19489 fireKey: function(e){
19490 if (!this.picker().isVisible()){
19491 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19497 e.preventDefault();
19505 this.onTogglePeriod();
19508 this.onIncrementMinutes();
19511 this.onDecrementMinutes();
19520 onClick: function(e) {
19521 e.stopPropagation();
19522 e.preventDefault();
19525 picker : function()
19527 return this.el.select('.datepicker', true).first();
19530 fillTime: function()
19532 var time = this.pop.select('tbody', true).first();
19534 time.dom.innerHTML = '';
19549 cls: 'hours-up glyphicon glyphicon-chevron-up'
19569 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19590 cls: 'timepicker-hour',
19605 cls: 'timepicker-minute',
19620 cls: 'btn btn-primary period',
19642 cls: 'hours-down glyphicon glyphicon-chevron-down'
19662 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19680 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19687 var hours = this.time.getHours();
19688 var minutes = this.time.getMinutes();
19701 hours = hours - 12;
19705 hours = '0' + hours;
19709 minutes = '0' + minutes;
19712 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19713 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19714 this.pop.select('button', true).first().dom.innerHTML = period;
19720 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19722 var cls = ['bottom'];
19724 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19731 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19736 this.picker().addClass(cls.join('-'));
19740 Roo.each(cls, function(c){
19742 _this.picker().setTop(_this.inputEl().getHeight());
19746 _this.picker().setTop(0 - _this.picker().getHeight());
19751 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19755 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19762 onFocus : function()
19764 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19768 onBlur : function()
19770 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19776 this.picker().show();
19781 this.fireEvent('show', this, this.date);
19786 this.picker().hide();
19789 this.fireEvent('hide', this, this.date);
19792 setTime : function()
19795 this.setValue(this.time.format(this.format));
19797 this.fireEvent('select', this, this.date);
19802 onMousedown: function(e){
19803 e.stopPropagation();
19804 e.preventDefault();
19807 onIncrementHours: function()
19809 Roo.log('onIncrementHours');
19810 this.time = this.time.add(Date.HOUR, 1);
19815 onDecrementHours: function()
19817 Roo.log('onDecrementHours');
19818 this.time = this.time.add(Date.HOUR, -1);
19822 onIncrementMinutes: function()
19824 Roo.log('onIncrementMinutes');
19825 this.time = this.time.add(Date.MINUTE, 1);
19829 onDecrementMinutes: function()
19831 Roo.log('onDecrementMinutes');
19832 this.time = this.time.add(Date.MINUTE, -1);
19836 onTogglePeriod: function()
19838 Roo.log('onTogglePeriod');
19839 this.time = this.time.add(Date.HOUR, 12);
19846 Roo.apply(Roo.bootstrap.TimeField, {
19876 cls: 'btn btn-info ok',
19888 Roo.apply(Roo.bootstrap.TimeField, {
19892 cls: 'datepicker dropdown-menu',
19896 cls: 'datepicker-time',
19900 cls: 'table-condensed',
19902 Roo.bootstrap.TimeField.content,
19903 Roo.bootstrap.TimeField.footer
19922 * @class Roo.bootstrap.MonthField
19923 * @extends Roo.bootstrap.Input
19924 * Bootstrap MonthField class
19926 * @cfg {String} language default en
19929 * Create a new MonthField
19930 * @param {Object} config The config object
19933 Roo.bootstrap.MonthField = function(config){
19934 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19939 * Fires when this field show.
19940 * @param {Roo.bootstrap.MonthField} this
19941 * @param {Mixed} date The date value
19946 * Fires when this field hide.
19947 * @param {Roo.bootstrap.MonthField} this
19948 * @param {Mixed} date The date value
19953 * Fires when select a date.
19954 * @param {Roo.bootstrap.MonthField} this
19955 * @param {String} oldvalue The old value
19956 * @param {String} newvalue The new value
19962 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19964 onRender: function(ct, position)
19967 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19969 this.language = this.language || 'en';
19970 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19971 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19973 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19974 this.isInline = false;
19975 this.isInput = true;
19976 this.component = this.el.select('.add-on', true).first() || false;
19977 this.component = (this.component && this.component.length === 0) ? false : this.component;
19978 this.hasInput = this.component && this.inputEL().length;
19980 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19982 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19984 this.picker().on('mousedown', this.onMousedown, this);
19985 this.picker().on('click', this.onClick, this);
19987 this.picker().addClass('datepicker-dropdown');
19989 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19990 v.setStyle('width', '189px');
19997 if(this.isInline) {
20003 setValue: function(v, suppressEvent)
20005 var o = this.getValue();
20007 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20011 if(suppressEvent !== true){
20012 this.fireEvent('select', this, o, v);
20017 getValue: function()
20022 onClick: function(e)
20024 e.stopPropagation();
20025 e.preventDefault();
20027 var target = e.getTarget();
20029 if(target.nodeName.toLowerCase() === 'i'){
20030 target = Roo.get(target).dom.parentNode;
20033 var nodeName = target.nodeName;
20034 var className = target.className;
20035 var html = target.innerHTML;
20037 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20041 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20043 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20049 picker : function()
20051 return this.pickerEl;
20054 fillMonths: function()
20057 var months = this.picker().select('>.datepicker-months td', true).first();
20059 months.dom.innerHTML = '';
20065 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20068 months.createChild(month);
20077 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20078 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20081 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20082 e.removeClass('active');
20084 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20085 e.addClass('active');
20092 if(this.isInline) {
20096 this.picker().removeClass(['bottom', 'top']);
20098 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20100 * place to the top of element!
20104 this.picker().addClass('top');
20105 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20110 this.picker().addClass('bottom');
20112 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20115 onFocus : function()
20117 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20121 onBlur : function()
20123 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20125 var d = this.inputEl().getValue();
20134 this.picker().show();
20135 this.picker().select('>.datepicker-months', true).first().show();
20139 this.fireEvent('show', this, this.date);
20144 if(this.isInline) {
20147 this.picker().hide();
20148 this.fireEvent('hide', this, this.date);
20152 onMousedown: function(e)
20154 e.stopPropagation();
20155 e.preventDefault();
20160 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20164 fireKey: function(e)
20166 if (!this.picker().isVisible()){
20167 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20178 e.preventDefault();
20182 dir = e.keyCode == 37 ? -1 : 1;
20184 this.vIndex = this.vIndex + dir;
20186 if(this.vIndex < 0){
20190 if(this.vIndex > 11){
20194 if(isNaN(this.vIndex)){
20198 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20204 dir = e.keyCode == 38 ? -1 : 1;
20206 this.vIndex = this.vIndex + dir * 4;
20208 if(this.vIndex < 0){
20212 if(this.vIndex > 11){
20216 if(isNaN(this.vIndex)){
20220 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20225 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20226 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20230 e.preventDefault();
20233 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20234 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20250 this.picker().remove();
20255 Roo.apply(Roo.bootstrap.MonthField, {
20274 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20275 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20280 Roo.apply(Roo.bootstrap.MonthField, {
20284 cls: 'datepicker dropdown-menu roo-dynamic',
20288 cls: 'datepicker-months',
20292 cls: 'table-condensed',
20294 Roo.bootstrap.DateField.content
20314 * @class Roo.bootstrap.CheckBox
20315 * @extends Roo.bootstrap.Input
20316 * Bootstrap CheckBox class
20318 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20319 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20320 * @cfg {String} boxLabel The text that appears beside the checkbox
20321 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20322 * @cfg {Boolean} checked initnal the element
20323 * @cfg {Boolean} inline inline the element (default false)
20324 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20325 * @cfg {String} tooltip label tooltip
20328 * Create a new CheckBox
20329 * @param {Object} config The config object
20332 Roo.bootstrap.CheckBox = function(config){
20333 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20338 * Fires when the element is checked or unchecked.
20339 * @param {Roo.bootstrap.CheckBox} this This input
20340 * @param {Boolean} checked The new checked value
20345 * Fires when the element is click.
20346 * @param {Roo.bootstrap.CheckBox} this This input
20353 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20355 inputType: 'checkbox',
20364 getAutoCreate : function()
20366 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20372 cfg.cls = 'form-group ' + this.inputType; //input-group
20375 cfg.cls += ' ' + this.inputType + '-inline';
20381 type : this.inputType,
20382 value : this.inputValue,
20383 cls : 'roo-' + this.inputType, //'form-box',
20384 placeholder : this.placeholder || ''
20388 if(this.inputType != 'radio'){
20392 cls : 'roo-hidden-value',
20393 value : this.checked ? this.inputValue : this.valueOff
20398 if (this.weight) { // Validity check?
20399 cfg.cls += " " + this.inputType + "-" + this.weight;
20402 if (this.disabled) {
20403 input.disabled=true;
20407 input.checked = this.checked;
20412 input.name = this.name;
20414 if(this.inputType != 'radio'){
20415 hidden.name = this.name;
20416 input.name = '_hidden_' + this.name;
20421 input.cls += ' input-' + this.size;
20426 ['xs','sm','md','lg'].map(function(size){
20427 if (settings[size]) {
20428 cfg.cls += ' col-' + size + '-' + settings[size];
20432 var inputblock = input;
20434 if (this.before || this.after) {
20437 cls : 'input-group',
20442 inputblock.cn.push({
20444 cls : 'input-group-addon',
20449 inputblock.cn.push(input);
20451 if(this.inputType != 'radio'){
20452 inputblock.cn.push(hidden);
20456 inputblock.cn.push({
20458 cls : 'input-group-addon',
20465 if (align ==='left' && this.fieldLabel.length) {
20466 // Roo.log("left and has label");
20471 cls : 'control-label',
20472 html : this.fieldLabel
20482 if(this.labelWidth > 12){
20483 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20486 if(this.labelWidth < 13 && this.labelmd == 0){
20487 this.labelmd = this.labelWidth;
20490 if(this.labellg > 0){
20491 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20492 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20495 if(this.labelmd > 0){
20496 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20497 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20500 if(this.labelsm > 0){
20501 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20502 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20505 if(this.labelxs > 0){
20506 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20507 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20510 } else if ( this.fieldLabel.length) {
20511 // Roo.log(" label");
20515 tag: this.boxLabel ? 'span' : 'label',
20517 cls: 'control-label box-input-label',
20518 //cls : 'input-group-addon',
20519 html : this.fieldLabel
20528 // Roo.log(" no label && no align");
20529 cfg.cn = [ inputblock ] ;
20535 var boxLabelCfg = {
20537 //'for': id, // box label is handled by onclick - so no for...
20539 html: this.boxLabel
20543 boxLabelCfg.tooltip = this.tooltip;
20546 cfg.cn.push(boxLabelCfg);
20549 if(this.inputType != 'radio'){
20550 cfg.cn.push(hidden);
20558 * return the real input element.
20560 inputEl: function ()
20562 return this.el.select('input.roo-' + this.inputType,true).first();
20564 hiddenEl: function ()
20566 return this.el.select('input.roo-hidden-value',true).first();
20569 labelEl: function()
20571 return this.el.select('label.control-label',true).first();
20573 /* depricated... */
20577 return this.labelEl();
20580 boxLabelEl: function()
20582 return this.el.select('label.box-label',true).first();
20585 initEvents : function()
20587 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20589 this.inputEl().on('click', this.onClick, this);
20591 if (this.boxLabel) {
20592 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20595 this.startValue = this.getValue();
20598 Roo.bootstrap.CheckBox.register(this);
20602 onClick : function(e)
20604 if(this.fireEvent('click', this, e) !== false){
20605 this.setChecked(!this.checked);
20610 setChecked : function(state,suppressEvent)
20612 this.startValue = this.getValue();
20614 if(this.inputType == 'radio'){
20616 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20617 e.dom.checked = false;
20620 this.inputEl().dom.checked = true;
20622 this.inputEl().dom.value = this.inputValue;
20624 if(suppressEvent !== true){
20625 this.fireEvent('check', this, true);
20633 this.checked = state;
20635 this.inputEl().dom.checked = state;
20638 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20640 if(suppressEvent !== true){
20641 this.fireEvent('check', this, state);
20647 getValue : function()
20649 if(this.inputType == 'radio'){
20650 return this.getGroupValue();
20653 return this.hiddenEl().dom.value;
20657 getGroupValue : function()
20659 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20663 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20666 setValue : function(v,suppressEvent)
20668 if(this.inputType == 'radio'){
20669 this.setGroupValue(v, suppressEvent);
20673 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20678 setGroupValue : function(v, suppressEvent)
20680 this.startValue = this.getValue();
20682 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20683 e.dom.checked = false;
20685 if(e.dom.value == v){
20686 e.dom.checked = true;
20690 if(suppressEvent !== true){
20691 this.fireEvent('check', this, true);
20699 validate : function()
20701 if(this.getEl().hasClass('hidden')){
20707 (this.inputType == 'radio' && this.validateRadio()) ||
20708 (this.inputType == 'checkbox' && this.validateCheckbox())
20714 this.markInvalid();
20718 validateRadio : function()
20720 if(this.getEl().hasClass('hidden')){
20724 if(this.allowBlank){
20730 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20731 if(!e.dom.checked){
20743 validateCheckbox : function()
20746 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20747 //return (this.getValue() == this.inputValue) ? true : false;
20750 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20758 for(var i in group){
20759 if(group[i].el.isVisible(true)){
20767 for(var i in group){
20772 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20779 * Mark this field as valid
20781 markValid : function()
20785 this.fireEvent('valid', this);
20787 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20790 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20797 if(this.inputType == 'radio'){
20798 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20799 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20800 e.findParent('.form-group', false, true).addClass(_this.validClass);
20807 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20808 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20812 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20818 for(var i in group){
20819 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20820 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20825 * Mark this field as invalid
20826 * @param {String} msg The validation message
20828 markInvalid : function(msg)
20830 if(this.allowBlank){
20836 this.fireEvent('invalid', this, msg);
20838 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20841 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20845 label.markInvalid();
20848 if(this.inputType == 'radio'){
20849 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20850 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20851 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20858 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20859 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20863 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20869 for(var i in group){
20870 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20871 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20876 clearInvalid : function()
20878 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20880 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20882 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20884 if (label && label.iconEl) {
20885 label.iconEl.removeClass(label.validClass);
20886 label.iconEl.removeClass(label.invalidClass);
20890 disable : function()
20892 if(this.inputType != 'radio'){
20893 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20900 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20901 _this.getActionEl().addClass(this.disabledClass);
20902 e.dom.disabled = true;
20906 this.disabled = true;
20907 this.fireEvent("disable", this);
20911 enable : function()
20913 if(this.inputType != 'radio'){
20914 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20921 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20922 _this.getActionEl().removeClass(this.disabledClass);
20923 e.dom.disabled = false;
20927 this.disabled = false;
20928 this.fireEvent("enable", this);
20932 setBoxLabel : function(v)
20937 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
20943 Roo.apply(Roo.bootstrap.CheckBox, {
20948 * register a CheckBox Group
20949 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20951 register : function(checkbox)
20953 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20954 this.groups[checkbox.groupId] = {};
20957 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20961 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20965 * fetch a CheckBox Group based on the group ID
20966 * @param {string} the group ID
20967 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20969 get: function(groupId) {
20970 if (typeof(this.groups[groupId]) == 'undefined') {
20974 return this.groups[groupId] ;
20987 * @class Roo.bootstrap.Radio
20988 * @extends Roo.bootstrap.Component
20989 * Bootstrap Radio class
20990 * @cfg {String} boxLabel - the label associated
20991 * @cfg {String} value - the value of radio
20994 * Create a new Radio
20995 * @param {Object} config The config object
20997 Roo.bootstrap.Radio = function(config){
20998 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21002 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21008 getAutoCreate : function()
21012 cls : 'form-group radio',
21017 html : this.boxLabel
21025 initEvents : function()
21027 this.parent().register(this);
21029 this.el.on('click', this.onClick, this);
21033 onClick : function(e)
21035 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21036 this.setChecked(true);
21040 setChecked : function(state, suppressEvent)
21042 this.parent().setValue(this.value, suppressEvent);
21046 setBoxLabel : function(v)
21051 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21066 * @class Roo.bootstrap.SecurePass
21067 * @extends Roo.bootstrap.Input
21068 * Bootstrap SecurePass class
21072 * Create a new SecurePass
21073 * @param {Object} config The config object
21076 Roo.bootstrap.SecurePass = function (config) {
21077 // these go here, so the translation tool can replace them..
21079 PwdEmpty: "Please type a password, and then retype it to confirm.",
21080 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21081 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21082 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21083 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21084 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21085 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21086 TooWeak: "Your password is Too Weak."
21088 this.meterLabel = "Password strength:";
21089 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21090 this.meterClass = [
21091 "roo-password-meter-tooweak",
21092 "roo-password-meter-weak",
21093 "roo-password-meter-medium",
21094 "roo-password-meter-strong",
21095 "roo-password-meter-grey"
21100 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21103 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21105 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21107 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21108 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21109 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21110 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21111 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21112 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21113 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21123 * @cfg {String/Object} Label for the strength meter (defaults to
21124 * 'Password strength:')
21129 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21130 * ['Weak', 'Medium', 'Strong'])
21133 pwdStrengths: false,
21146 initEvents: function ()
21148 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21150 if (this.el.is('input[type=password]') && Roo.isSafari) {
21151 this.el.on('keydown', this.SafariOnKeyDown, this);
21154 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21157 onRender: function (ct, position)
21159 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21160 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21161 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21163 this.trigger.createChild({
21168 cls: 'roo-password-meter-grey col-xs-12',
21171 //width: this.meterWidth + 'px'
21175 cls: 'roo-password-meter-text'
21181 if (this.hideTrigger) {
21182 this.trigger.setDisplayed(false);
21184 this.setSize(this.width || '', this.height || '');
21187 onDestroy: function ()
21189 if (this.trigger) {
21190 this.trigger.removeAllListeners();
21191 this.trigger.remove();
21194 this.wrap.remove();
21196 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21199 checkStrength: function ()
21201 var pwd = this.inputEl().getValue();
21202 if (pwd == this._lastPwd) {
21207 if (this.ClientSideStrongPassword(pwd)) {
21209 } else if (this.ClientSideMediumPassword(pwd)) {
21211 } else if (this.ClientSideWeakPassword(pwd)) {
21217 Roo.log('strength1: ' + strength);
21219 //var pm = this.trigger.child('div/div/div').dom;
21220 var pm = this.trigger.child('div/div');
21221 pm.removeClass(this.meterClass);
21222 pm.addClass(this.meterClass[strength]);
21225 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21227 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21229 this._lastPwd = pwd;
21233 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21235 this._lastPwd = '';
21237 var pm = this.trigger.child('div/div');
21238 pm.removeClass(this.meterClass);
21239 pm.addClass('roo-password-meter-grey');
21242 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21245 this.inputEl().dom.type='password';
21248 validateValue: function (value)
21251 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21254 if (value.length == 0) {
21255 if (this.allowBlank) {
21256 this.clearInvalid();
21260 this.markInvalid(this.errors.PwdEmpty);
21261 this.errorMsg = this.errors.PwdEmpty;
21269 if ('[\x21-\x7e]*'.match(value)) {
21270 this.markInvalid(this.errors.PwdBadChar);
21271 this.errorMsg = this.errors.PwdBadChar;
21274 if (value.length < 6) {
21275 this.markInvalid(this.errors.PwdShort);
21276 this.errorMsg = this.errors.PwdShort;
21279 if (value.length > 16) {
21280 this.markInvalid(this.errors.PwdLong);
21281 this.errorMsg = this.errors.PwdLong;
21285 if (this.ClientSideStrongPassword(value)) {
21287 } else if (this.ClientSideMediumPassword(value)) {
21289 } else if (this.ClientSideWeakPassword(value)) {
21296 if (strength < 2) {
21297 //this.markInvalid(this.errors.TooWeak);
21298 this.errorMsg = this.errors.TooWeak;
21303 console.log('strength2: ' + strength);
21305 //var pm = this.trigger.child('div/div/div').dom;
21307 var pm = this.trigger.child('div/div');
21308 pm.removeClass(this.meterClass);
21309 pm.addClass(this.meterClass[strength]);
21311 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21313 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21315 this.errorMsg = '';
21319 CharacterSetChecks: function (type)
21322 this.fResult = false;
21325 isctype: function (character, type)
21328 case this.kCapitalLetter:
21329 if (character >= 'A' && character <= 'Z') {
21334 case this.kSmallLetter:
21335 if (character >= 'a' && character <= 'z') {
21341 if (character >= '0' && character <= '9') {
21346 case this.kPunctuation:
21347 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21358 IsLongEnough: function (pwd, size)
21360 return !(pwd == null || isNaN(size) || pwd.length < size);
21363 SpansEnoughCharacterSets: function (word, nb)
21365 if (!this.IsLongEnough(word, nb))
21370 var characterSetChecks = new Array(
21371 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21372 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21375 for (var index = 0; index < word.length; ++index) {
21376 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21377 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21378 characterSetChecks[nCharSet].fResult = true;
21385 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21386 if (characterSetChecks[nCharSet].fResult) {
21391 if (nCharSets < nb) {
21397 ClientSideStrongPassword: function (pwd)
21399 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21402 ClientSideMediumPassword: function (pwd)
21404 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21407 ClientSideWeakPassword: function (pwd)
21409 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21412 })//<script type="text/javascript">
21415 * Based Ext JS Library 1.1.1
21416 * Copyright(c) 2006-2007, Ext JS, LLC.
21422 * @class Roo.HtmlEditorCore
21423 * @extends Roo.Component
21424 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21426 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21429 Roo.HtmlEditorCore = function(config){
21432 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21437 * @event initialize
21438 * Fires when the editor is fully initialized (including the iframe)
21439 * @param {Roo.HtmlEditorCore} this
21444 * Fires when the editor is first receives the focus. Any insertion must wait
21445 * until after this event.
21446 * @param {Roo.HtmlEditorCore} this
21450 * @event beforesync
21451 * Fires before the textarea is updated with content from the editor iframe. Return false
21452 * to cancel the sync.
21453 * @param {Roo.HtmlEditorCore} this
21454 * @param {String} html
21458 * @event beforepush
21459 * Fires before the iframe editor is updated with content from the textarea. Return false
21460 * to cancel the push.
21461 * @param {Roo.HtmlEditorCore} this
21462 * @param {String} html
21467 * Fires when the textarea is updated with content from the editor iframe.
21468 * @param {Roo.HtmlEditorCore} this
21469 * @param {String} html
21474 * Fires when the iframe editor is updated with content from the textarea.
21475 * @param {Roo.HtmlEditorCore} this
21476 * @param {String} html
21481 * @event editorevent
21482 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21483 * @param {Roo.HtmlEditorCore} this
21489 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21491 // defaults : white / black...
21492 this.applyBlacklists();
21499 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21503 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21509 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21514 * @cfg {Number} height (in pixels)
21518 * @cfg {Number} width (in pixels)
21523 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21526 stylesheets: false,
21531 // private properties
21532 validationEvent : false,
21534 initialized : false,
21536 sourceEditMode : false,
21537 onFocus : Roo.emptyFn,
21539 hideMode:'offsets',
21543 // blacklist + whitelisted elements..
21550 * Protected method that will not generally be called directly. It
21551 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21552 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21554 getDocMarkup : function(){
21558 // inherit styels from page...??
21559 if (this.stylesheets === false) {
21561 Roo.get(document.head).select('style').each(function(node) {
21562 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21565 Roo.get(document.head).select('link').each(function(node) {
21566 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21569 } else if (!this.stylesheets.length) {
21571 st = '<style type="text/css">' +
21572 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21575 st = '<style type="text/css">' +
21580 st += '<style type="text/css">' +
21581 'IMG { cursor: pointer } ' +
21584 var cls = 'roo-htmleditor-body';
21586 if(this.bodyCls.length){
21587 cls += ' ' + this.bodyCls;
21590 return '<html><head>' + st +
21591 //<style type="text/css">' +
21592 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21594 ' </head><body class="' + cls + '"></body></html>';
21598 onRender : function(ct, position)
21601 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21602 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21605 this.el.dom.style.border = '0 none';
21606 this.el.dom.setAttribute('tabIndex', -1);
21607 this.el.addClass('x-hidden hide');
21611 if(Roo.isIE){ // fix IE 1px bogus margin
21612 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21616 this.frameId = Roo.id();
21620 var iframe = this.owner.wrap.createChild({
21622 cls: 'form-control', // bootstrap..
21624 name: this.frameId,
21625 frameBorder : 'no',
21626 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21631 this.iframe = iframe.dom;
21633 this.assignDocWin();
21635 this.doc.designMode = 'on';
21638 this.doc.write(this.getDocMarkup());
21642 var task = { // must defer to wait for browser to be ready
21644 //console.log("run task?" + this.doc.readyState);
21645 this.assignDocWin();
21646 if(this.doc.body || this.doc.readyState == 'complete'){
21648 this.doc.designMode="on";
21652 Roo.TaskMgr.stop(task);
21653 this.initEditor.defer(10, this);
21660 Roo.TaskMgr.start(task);
21665 onResize : function(w, h)
21667 Roo.log('resize: ' +w + ',' + h );
21668 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21672 if(typeof w == 'number'){
21674 this.iframe.style.width = w + 'px';
21676 if(typeof h == 'number'){
21678 this.iframe.style.height = h + 'px';
21680 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21687 * Toggles the editor between standard and source edit mode.
21688 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21690 toggleSourceEdit : function(sourceEditMode){
21692 this.sourceEditMode = sourceEditMode === true;
21694 if(this.sourceEditMode){
21696 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21699 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21700 //this.iframe.className = '';
21703 //this.setSize(this.owner.wrap.getSize());
21704 //this.fireEvent('editmodechange', this, this.sourceEditMode);
21711 * Protected method that will not generally be called directly. If you need/want
21712 * custom HTML cleanup, this is the method you should override.
21713 * @param {String} html The HTML to be cleaned
21714 * return {String} The cleaned HTML
21716 cleanHtml : function(html){
21717 html = String(html);
21718 if(html.length > 5){
21719 if(Roo.isSafari){ // strip safari nonsense
21720 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
21723 if(html == ' '){
21730 * HTML Editor -> Textarea
21731 * Protected method that will not generally be called directly. Syncs the contents
21732 * of the editor iframe with the textarea.
21734 syncValue : function(){
21735 if(this.initialized){
21736 var bd = (this.doc.body || this.doc.documentElement);
21737 //this.cleanUpPaste(); -- this is done else where and causes havoc..
21738 var html = bd.innerHTML;
21740 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
21741 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
21743 html = '<div style="'+m[0]+'">' + html + '</div>';
21746 html = this.cleanHtml(html);
21747 // fix up the special chars.. normaly like back quotes in word...
21748 // however we do not want to do this with chinese..
21749 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21750 var cc = b.charCodeAt();
21752 (cc >= 0x4E00 && cc < 0xA000 ) ||
21753 (cc >= 0x3400 && cc < 0x4E00 ) ||
21754 (cc >= 0xf900 && cc < 0xfb00 )
21760 if(this.owner.fireEvent('beforesync', this, html) !== false){
21761 this.el.dom.value = html;
21762 this.owner.fireEvent('sync', this, html);
21768 * Protected method that will not generally be called directly. Pushes the value of the textarea
21769 * into the iframe editor.
21771 pushValue : function(){
21772 if(this.initialized){
21773 var v = this.el.dom.value.trim();
21775 // if(v.length < 1){
21779 if(this.owner.fireEvent('beforepush', this, v) !== false){
21780 var d = (this.doc.body || this.doc.documentElement);
21782 this.cleanUpPaste();
21783 this.el.dom.value = d.innerHTML;
21784 this.owner.fireEvent('push', this, v);
21790 deferFocus : function(){
21791 this.focus.defer(10, this);
21795 focus : function(){
21796 if(this.win && !this.sourceEditMode){
21803 assignDocWin: function()
21805 var iframe = this.iframe;
21808 this.doc = iframe.contentWindow.document;
21809 this.win = iframe.contentWindow;
21811 // if (!Roo.get(this.frameId)) {
21814 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21815 // this.win = Roo.get(this.frameId).dom.contentWindow;
21817 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21821 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21822 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21827 initEditor : function(){
21828 //console.log("INIT EDITOR");
21829 this.assignDocWin();
21833 this.doc.designMode="on";
21835 this.doc.write(this.getDocMarkup());
21838 var dbody = (this.doc.body || this.doc.documentElement);
21839 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21840 // this copies styles from the containing element into thsi one..
21841 // not sure why we need all of this..
21842 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21844 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21845 //ss['background-attachment'] = 'fixed'; // w3c
21846 dbody.bgProperties = 'fixed'; // ie
21847 //Roo.DomHelper.applyStyles(dbody, ss);
21848 Roo.EventManager.on(this.doc, {
21849 //'mousedown': this.onEditorEvent,
21850 'mouseup': this.onEditorEvent,
21851 'dblclick': this.onEditorEvent,
21852 'click': this.onEditorEvent,
21853 'keyup': this.onEditorEvent,
21858 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21860 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21861 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21863 this.initialized = true;
21865 this.owner.fireEvent('initialize', this);
21870 onDestroy : function(){
21876 //for (var i =0; i < this.toolbars.length;i++) {
21877 // // fixme - ask toolbars for heights?
21878 // this.toolbars[i].onDestroy();
21881 //this.wrap.dom.innerHTML = '';
21882 //this.wrap.remove();
21887 onFirstFocus : function(){
21889 this.assignDocWin();
21892 this.activated = true;
21895 if(Roo.isGecko){ // prevent silly gecko errors
21897 var s = this.win.getSelection();
21898 if(!s.focusNode || s.focusNode.nodeType != 3){
21899 var r = s.getRangeAt(0);
21900 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21905 this.execCmd('useCSS', true);
21906 this.execCmd('styleWithCSS', false);
21909 this.owner.fireEvent('activate', this);
21913 adjustFont: function(btn){
21914 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21915 //if(Roo.isSafari){ // safari
21918 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21919 if(Roo.isSafari){ // safari
21920 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21921 v = (v < 10) ? 10 : v;
21922 v = (v > 48) ? 48 : v;
21923 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21928 v = Math.max(1, v+adjust);
21930 this.execCmd('FontSize', v );
21933 onEditorEvent : function(e)
21935 this.owner.fireEvent('editorevent', this, e);
21936 // this.updateToolbar();
21937 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21940 insertTag : function(tg)
21942 // could be a bit smarter... -> wrap the current selected tRoo..
21943 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21945 range = this.createRange(this.getSelection());
21946 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21947 wrappingNode.appendChild(range.extractContents());
21948 range.insertNode(wrappingNode);
21955 this.execCmd("formatblock", tg);
21959 insertText : function(txt)
21963 var range = this.createRange();
21964 range.deleteContents();
21965 //alert(Sender.getAttribute('label'));
21967 range.insertNode(this.doc.createTextNode(txt));
21973 * Executes a Midas editor command on the editor document and performs necessary focus and
21974 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21975 * @param {String} cmd The Midas command
21976 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21978 relayCmd : function(cmd, value){
21980 this.execCmd(cmd, value);
21981 this.owner.fireEvent('editorevent', this);
21982 //this.updateToolbar();
21983 this.owner.deferFocus();
21987 * Executes a Midas editor command directly on the editor document.
21988 * For visual commands, you should use {@link #relayCmd} instead.
21989 * <b>This should only be called after the editor is initialized.</b>
21990 * @param {String} cmd The Midas command
21991 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21993 execCmd : function(cmd, value){
21994 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22001 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22003 * @param {String} text | dom node..
22005 insertAtCursor : function(text)
22008 if(!this.activated){
22014 var r = this.doc.selection.createRange();
22025 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22029 // from jquery ui (MIT licenced)
22031 var win = this.win;
22033 if (win.getSelection && win.getSelection().getRangeAt) {
22034 range = win.getSelection().getRangeAt(0);
22035 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22036 range.insertNode(node);
22037 } else if (win.document.selection && win.document.selection.createRange) {
22038 // no firefox support
22039 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22040 win.document.selection.createRange().pasteHTML(txt);
22042 // no firefox support
22043 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22044 this.execCmd('InsertHTML', txt);
22053 mozKeyPress : function(e){
22055 var c = e.getCharCode(), cmd;
22058 c = String.fromCharCode(c).toLowerCase();
22072 this.cleanUpPaste.defer(100, this);
22080 e.preventDefault();
22088 fixKeys : function(){ // load time branching for fastest keydown performance
22090 return function(e){
22091 var k = e.getKey(), r;
22094 r = this.doc.selection.createRange();
22097 r.pasteHTML('    ');
22104 r = this.doc.selection.createRange();
22106 var target = r.parentElement();
22107 if(!target || target.tagName.toLowerCase() != 'li'){
22109 r.pasteHTML('<br />');
22115 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22116 this.cleanUpPaste.defer(100, this);
22122 }else if(Roo.isOpera){
22123 return function(e){
22124 var k = e.getKey();
22128 this.execCmd('InsertHTML','    ');
22131 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22132 this.cleanUpPaste.defer(100, this);
22137 }else if(Roo.isSafari){
22138 return function(e){
22139 var k = e.getKey();
22143 this.execCmd('InsertText','\t');
22147 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22148 this.cleanUpPaste.defer(100, this);
22156 getAllAncestors: function()
22158 var p = this.getSelectedNode();
22161 a.push(p); // push blank onto stack..
22162 p = this.getParentElement();
22166 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22170 a.push(this.doc.body);
22174 lastSelNode : false,
22177 getSelection : function()
22179 this.assignDocWin();
22180 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22183 getSelectedNode: function()
22185 // this may only work on Gecko!!!
22187 // should we cache this!!!!
22192 var range = this.createRange(this.getSelection()).cloneRange();
22195 var parent = range.parentElement();
22197 var testRange = range.duplicate();
22198 testRange.moveToElementText(parent);
22199 if (testRange.inRange(range)) {
22202 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22205 parent = parent.parentElement;
22210 // is ancestor a text element.
22211 var ac = range.commonAncestorContainer;
22212 if (ac.nodeType == 3) {
22213 ac = ac.parentNode;
22216 var ar = ac.childNodes;
22219 var other_nodes = [];
22220 var has_other_nodes = false;
22221 for (var i=0;i<ar.length;i++) {
22222 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22225 // fullly contained node.
22227 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22232 // probably selected..
22233 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22234 other_nodes.push(ar[i]);
22238 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22243 has_other_nodes = true;
22245 if (!nodes.length && other_nodes.length) {
22246 nodes= other_nodes;
22248 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22254 createRange: function(sel)
22256 // this has strange effects when using with
22257 // top toolbar - not sure if it's a great idea.
22258 //this.editor.contentWindow.focus();
22259 if (typeof sel != "undefined") {
22261 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22263 return this.doc.createRange();
22266 return this.doc.createRange();
22269 getParentElement: function()
22272 this.assignDocWin();
22273 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22275 var range = this.createRange(sel);
22278 var p = range.commonAncestorContainer;
22279 while (p.nodeType == 3) { // text node
22290 * Range intersection.. the hard stuff...
22294 * [ -- selected range --- ]
22298 * if end is before start or hits it. fail.
22299 * if start is after end or hits it fail.
22301 * if either hits (but other is outside. - then it's not
22307 // @see http://www.thismuchiknow.co.uk/?p=64.
22308 rangeIntersectsNode : function(range, node)
22310 var nodeRange = node.ownerDocument.createRange();
22312 nodeRange.selectNode(node);
22314 nodeRange.selectNodeContents(node);
22317 var rangeStartRange = range.cloneRange();
22318 rangeStartRange.collapse(true);
22320 var rangeEndRange = range.cloneRange();
22321 rangeEndRange.collapse(false);
22323 var nodeStartRange = nodeRange.cloneRange();
22324 nodeStartRange.collapse(true);
22326 var nodeEndRange = nodeRange.cloneRange();
22327 nodeEndRange.collapse(false);
22329 return rangeStartRange.compareBoundaryPoints(
22330 Range.START_TO_START, nodeEndRange) == -1 &&
22331 rangeEndRange.compareBoundaryPoints(
22332 Range.START_TO_START, nodeStartRange) == 1;
22336 rangeCompareNode : function(range, node)
22338 var nodeRange = node.ownerDocument.createRange();
22340 nodeRange.selectNode(node);
22342 nodeRange.selectNodeContents(node);
22346 range.collapse(true);
22348 nodeRange.collapse(true);
22350 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22351 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22353 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22355 var nodeIsBefore = ss == 1;
22356 var nodeIsAfter = ee == -1;
22358 if (nodeIsBefore && nodeIsAfter) {
22361 if (!nodeIsBefore && nodeIsAfter) {
22362 return 1; //right trailed.
22365 if (nodeIsBefore && !nodeIsAfter) {
22366 return 2; // left trailed.
22372 // private? - in a new class?
22373 cleanUpPaste : function()
22375 // cleans up the whole document..
22376 Roo.log('cleanuppaste');
22378 this.cleanUpChildren(this.doc.body);
22379 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22380 if (clean != this.doc.body.innerHTML) {
22381 this.doc.body.innerHTML = clean;
22386 cleanWordChars : function(input) {// change the chars to hex code
22387 var he = Roo.HtmlEditorCore;
22389 var output = input;
22390 Roo.each(he.swapCodes, function(sw) {
22391 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22393 output = output.replace(swapper, sw[1]);
22400 cleanUpChildren : function (n)
22402 if (!n.childNodes.length) {
22405 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22406 this.cleanUpChild(n.childNodes[i]);
22413 cleanUpChild : function (node)
22416 //console.log(node);
22417 if (node.nodeName == "#text") {
22418 // clean up silly Windows -- stuff?
22421 if (node.nodeName == "#comment") {
22422 node.parentNode.removeChild(node);
22423 // clean up silly Windows -- stuff?
22426 var lcname = node.tagName.toLowerCase();
22427 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22428 // whitelist of tags..
22430 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22432 node.parentNode.removeChild(node);
22437 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22439 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22440 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22442 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22443 // remove_keep_children = true;
22446 if (remove_keep_children) {
22447 this.cleanUpChildren(node);
22448 // inserts everything just before this node...
22449 while (node.childNodes.length) {
22450 var cn = node.childNodes[0];
22451 node.removeChild(cn);
22452 node.parentNode.insertBefore(cn, node);
22454 node.parentNode.removeChild(node);
22458 if (!node.attributes || !node.attributes.length) {
22459 this.cleanUpChildren(node);
22463 function cleanAttr(n,v)
22466 if (v.match(/^\./) || v.match(/^\//)) {
22469 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
22472 if (v.match(/^#/)) {
22475 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22476 node.removeAttribute(n);
22480 var cwhite = this.cwhite;
22481 var cblack = this.cblack;
22483 function cleanStyle(n,v)
22485 if (v.match(/expression/)) { //XSS?? should we even bother..
22486 node.removeAttribute(n);
22490 var parts = v.split(/;/);
22493 Roo.each(parts, function(p) {
22494 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22498 var l = p.split(':').shift().replace(/\s+/g,'');
22499 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22501 if ( cwhite.length && cblack.indexOf(l) > -1) {
22502 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22503 //node.removeAttribute(n);
22507 // only allow 'c whitelisted system attributes'
22508 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22509 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22510 //node.removeAttribute(n);
22520 if (clean.length) {
22521 node.setAttribute(n, clean.join(';'));
22523 node.removeAttribute(n);
22529 for (var i = node.attributes.length-1; i > -1 ; i--) {
22530 var a = node.attributes[i];
22533 if (a.name.toLowerCase().substr(0,2)=='on') {
22534 node.removeAttribute(a.name);
22537 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22538 node.removeAttribute(a.name);
22541 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22542 cleanAttr(a.name,a.value); // fixme..
22545 if (a.name == 'style') {
22546 cleanStyle(a.name,a.value);
22549 /// clean up MS crap..
22550 // tecnically this should be a list of valid class'es..
22553 if (a.name == 'class') {
22554 if (a.value.match(/^Mso/)) {
22555 node.className = '';
22558 if (a.value.match(/^body$/)) {
22559 node.className = '';
22570 this.cleanUpChildren(node);
22576 * Clean up MS wordisms...
22578 cleanWord : function(node)
22583 this.cleanWord(this.doc.body);
22586 if (node.nodeName == "#text") {
22587 // clean up silly Windows -- stuff?
22590 if (node.nodeName == "#comment") {
22591 node.parentNode.removeChild(node);
22592 // clean up silly Windows -- stuff?
22596 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22597 node.parentNode.removeChild(node);
22601 // remove - but keep children..
22602 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22603 while (node.childNodes.length) {
22604 var cn = node.childNodes[0];
22605 node.removeChild(cn);
22606 node.parentNode.insertBefore(cn, node);
22608 node.parentNode.removeChild(node);
22609 this.iterateChildren(node, this.cleanWord);
22613 if (node.className.length) {
22615 var cn = node.className.split(/\W+/);
22617 Roo.each(cn, function(cls) {
22618 if (cls.match(/Mso[a-zA-Z]+/)) {
22623 node.className = cna.length ? cna.join(' ') : '';
22625 node.removeAttribute("class");
22629 if (node.hasAttribute("lang")) {
22630 node.removeAttribute("lang");
22633 if (node.hasAttribute("style")) {
22635 var styles = node.getAttribute("style").split(";");
22637 Roo.each(styles, function(s) {
22638 if (!s.match(/:/)) {
22641 var kv = s.split(":");
22642 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22645 // what ever is left... we allow.
22648 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22649 if (!nstyle.length) {
22650 node.removeAttribute('style');
22653 this.iterateChildren(node, this.cleanWord);
22659 * iterateChildren of a Node, calling fn each time, using this as the scole..
22660 * @param {DomNode} node node to iterate children of.
22661 * @param {Function} fn method of this class to call on each item.
22663 iterateChildren : function(node, fn)
22665 if (!node.childNodes.length) {
22668 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22669 fn.call(this, node.childNodes[i])
22675 * cleanTableWidths.
22677 * Quite often pasting from word etc.. results in tables with column and widths.
22678 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22681 cleanTableWidths : function(node)
22686 this.cleanTableWidths(this.doc.body);
22691 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22694 Roo.log(node.tagName);
22695 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22696 this.iterateChildren(node, this.cleanTableWidths);
22699 if (node.hasAttribute('width')) {
22700 node.removeAttribute('width');
22704 if (node.hasAttribute("style")) {
22707 var styles = node.getAttribute("style").split(";");
22709 Roo.each(styles, function(s) {
22710 if (!s.match(/:/)) {
22713 var kv = s.split(":");
22714 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
22717 // what ever is left... we allow.
22720 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22721 if (!nstyle.length) {
22722 node.removeAttribute('style');
22726 this.iterateChildren(node, this.cleanTableWidths);
22734 domToHTML : function(currentElement, depth, nopadtext) {
22736 depth = depth || 0;
22737 nopadtext = nopadtext || false;
22739 if (!currentElement) {
22740 return this.domToHTML(this.doc.body);
22743 //Roo.log(currentElement);
22745 var allText = false;
22746 var nodeName = currentElement.nodeName;
22747 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22749 if (nodeName == '#text') {
22751 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22756 if (nodeName != 'BODY') {
22759 // Prints the node tagName, such as <A>, <IMG>, etc
22762 for(i = 0; i < currentElement.attributes.length;i++) {
22764 var aname = currentElement.attributes.item(i).name;
22765 if (!currentElement.attributes.item(i).value.length) {
22768 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22771 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22780 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22783 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22788 // Traverse the tree
22790 var currentElementChild = currentElement.childNodes.item(i);
22791 var allText = true;
22792 var innerHTML = '';
22794 while (currentElementChild) {
22795 // Formatting code (indent the tree so it looks nice on the screen)
22796 var nopad = nopadtext;
22797 if (lastnode == 'SPAN') {
22801 if (currentElementChild.nodeName == '#text') {
22802 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22803 toadd = nopadtext ? toadd : toadd.trim();
22804 if (!nopad && toadd.length > 80) {
22805 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22807 innerHTML += toadd;
22810 currentElementChild = currentElement.childNodes.item(i);
22816 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22818 // Recursively traverse the tree structure of the child node
22819 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22820 lastnode = currentElementChild.nodeName;
22822 currentElementChild=currentElement.childNodes.item(i);
22828 // The remaining code is mostly for formatting the tree
22829 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22834 ret+= "</"+tagName+">";
22840 applyBlacklists : function()
22842 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22843 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22847 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22848 if (b.indexOf(tag) > -1) {
22851 this.white.push(tag);
22855 Roo.each(w, function(tag) {
22856 if (b.indexOf(tag) > -1) {
22859 if (this.white.indexOf(tag) > -1) {
22862 this.white.push(tag);
22867 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22868 if (w.indexOf(tag) > -1) {
22871 this.black.push(tag);
22875 Roo.each(b, function(tag) {
22876 if (w.indexOf(tag) > -1) {
22879 if (this.black.indexOf(tag) > -1) {
22882 this.black.push(tag);
22887 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22888 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22892 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22893 if (b.indexOf(tag) > -1) {
22896 this.cwhite.push(tag);
22900 Roo.each(w, function(tag) {
22901 if (b.indexOf(tag) > -1) {
22904 if (this.cwhite.indexOf(tag) > -1) {
22907 this.cwhite.push(tag);
22912 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22913 if (w.indexOf(tag) > -1) {
22916 this.cblack.push(tag);
22920 Roo.each(b, function(tag) {
22921 if (w.indexOf(tag) > -1) {
22924 if (this.cblack.indexOf(tag) > -1) {
22927 this.cblack.push(tag);
22932 setStylesheets : function(stylesheets)
22934 if(typeof(stylesheets) == 'string'){
22935 Roo.get(this.iframe.contentDocument.head).createChild({
22937 rel : 'stylesheet',
22946 Roo.each(stylesheets, function(s) {
22951 Roo.get(_this.iframe.contentDocument.head).createChild({
22953 rel : 'stylesheet',
22962 removeStylesheets : function()
22966 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22971 setStyle : function(style)
22973 Roo.get(this.iframe.contentDocument.head).createChild({
22982 // hide stuff that is not compatible
22996 * @event specialkey
23000 * @cfg {String} fieldClass @hide
23003 * @cfg {String} focusClass @hide
23006 * @cfg {String} autoCreate @hide
23009 * @cfg {String} inputType @hide
23012 * @cfg {String} invalidClass @hide
23015 * @cfg {String} invalidText @hide
23018 * @cfg {String} msgFx @hide
23021 * @cfg {String} validateOnBlur @hide
23025 Roo.HtmlEditorCore.white = [
23026 'area', 'br', 'img', 'input', 'hr', 'wbr',
23028 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23029 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23030 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23031 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23032 'table', 'ul', 'xmp',
23034 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23037 'dir', 'menu', 'ol', 'ul', 'dl',
23043 Roo.HtmlEditorCore.black = [
23044 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23046 'base', 'basefont', 'bgsound', 'blink', 'body',
23047 'frame', 'frameset', 'head', 'html', 'ilayer',
23048 'iframe', 'layer', 'link', 'meta', 'object',
23049 'script', 'style' ,'title', 'xml' // clean later..
23051 Roo.HtmlEditorCore.clean = [
23052 'script', 'style', 'title', 'xml'
23054 Roo.HtmlEditorCore.remove = [
23059 Roo.HtmlEditorCore.ablack = [
23063 Roo.HtmlEditorCore.aclean = [
23064 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23068 Roo.HtmlEditorCore.pwhite= [
23069 'http', 'https', 'mailto'
23072 // white listed style attributes.
23073 Roo.HtmlEditorCore.cwhite= [
23074 // 'text-align', /// default is to allow most things..
23080 // black listed style attributes.
23081 Roo.HtmlEditorCore.cblack= [
23082 // 'font-size' -- this can be set by the project
23086 Roo.HtmlEditorCore.swapCodes =[
23105 * @class Roo.bootstrap.HtmlEditor
23106 * @extends Roo.bootstrap.TextArea
23107 * Bootstrap HtmlEditor class
23110 * Create a new HtmlEditor
23111 * @param {Object} config The config object
23114 Roo.bootstrap.HtmlEditor = function(config){
23115 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23116 if (!this.toolbars) {
23117 this.toolbars = [];
23120 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23123 * @event initialize
23124 * Fires when the editor is fully initialized (including the iframe)
23125 * @param {HtmlEditor} this
23130 * Fires when the editor is first receives the focus. Any insertion must wait
23131 * until after this event.
23132 * @param {HtmlEditor} this
23136 * @event beforesync
23137 * Fires before the textarea is updated with content from the editor iframe. Return false
23138 * to cancel the sync.
23139 * @param {HtmlEditor} this
23140 * @param {String} html
23144 * @event beforepush
23145 * Fires before the iframe editor is updated with content from the textarea. Return false
23146 * to cancel the push.
23147 * @param {HtmlEditor} this
23148 * @param {String} html
23153 * Fires when the textarea is updated with content from the editor iframe.
23154 * @param {HtmlEditor} this
23155 * @param {String} html
23160 * Fires when the iframe editor is updated with content from the textarea.
23161 * @param {HtmlEditor} this
23162 * @param {String} html
23166 * @event editmodechange
23167 * Fires when the editor switches edit modes
23168 * @param {HtmlEditor} this
23169 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23171 editmodechange: true,
23173 * @event editorevent
23174 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23175 * @param {HtmlEditor} this
23179 * @event firstfocus
23180 * Fires when on first focus - needed by toolbars..
23181 * @param {HtmlEditor} this
23186 * Auto save the htmlEditor value as a file into Events
23187 * @param {HtmlEditor} this
23191 * @event savedpreview
23192 * preview the saved version of htmlEditor
23193 * @param {HtmlEditor} this
23200 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23204 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23209 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23214 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23219 * @cfg {Number} height (in pixels)
23223 * @cfg {Number} width (in pixels)
23228 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23231 stylesheets: false,
23236 // private properties
23237 validationEvent : false,
23239 initialized : false,
23242 onFocus : Roo.emptyFn,
23244 hideMode:'offsets',
23246 tbContainer : false,
23250 toolbarContainer :function() {
23251 return this.wrap.select('.x-html-editor-tb',true).first();
23255 * Protected method that will not generally be called directly. It
23256 * is called when the editor creates its toolbar. Override this method if you need to
23257 * add custom toolbar buttons.
23258 * @param {HtmlEditor} editor
23260 createToolbar : function(){
23261 Roo.log('renewing');
23262 Roo.log("create toolbars");
23264 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23265 this.toolbars[0].render(this.toolbarContainer());
23269 // if (!editor.toolbars || !editor.toolbars.length) {
23270 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23273 // for (var i =0 ; i < editor.toolbars.length;i++) {
23274 // editor.toolbars[i] = Roo.factory(
23275 // typeof(editor.toolbars[i]) == 'string' ?
23276 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23277 // Roo.bootstrap.HtmlEditor);
23278 // editor.toolbars[i].init(editor);
23284 onRender : function(ct, position)
23286 // Roo.log("Call onRender: " + this.xtype);
23288 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23290 this.wrap = this.inputEl().wrap({
23291 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23294 this.editorcore.onRender(ct, position);
23296 if (this.resizable) {
23297 this.resizeEl = new Roo.Resizable(this.wrap, {
23301 minHeight : this.height,
23302 height: this.height,
23303 handles : this.resizable,
23306 resize : function(r, w, h) {
23307 _t.onResize(w,h); // -something
23313 this.createToolbar(this);
23316 if(!this.width && this.resizable){
23317 this.setSize(this.wrap.getSize());
23319 if (this.resizeEl) {
23320 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23321 // should trigger onReize..
23327 onResize : function(w, h)
23329 Roo.log('resize: ' +w + ',' + h );
23330 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23334 if(this.inputEl() ){
23335 if(typeof w == 'number'){
23336 var aw = w - this.wrap.getFrameWidth('lr');
23337 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23340 if(typeof h == 'number'){
23341 var tbh = -11; // fixme it needs to tool bar size!
23342 for (var i =0; i < this.toolbars.length;i++) {
23343 // fixme - ask toolbars for heights?
23344 tbh += this.toolbars[i].el.getHeight();
23345 //if (this.toolbars[i].footer) {
23346 // tbh += this.toolbars[i].footer.el.getHeight();
23354 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23355 ah -= 5; // knock a few pixes off for look..
23356 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23360 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23361 this.editorcore.onResize(ew,eh);
23366 * Toggles the editor between standard and source edit mode.
23367 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23369 toggleSourceEdit : function(sourceEditMode)
23371 this.editorcore.toggleSourceEdit(sourceEditMode);
23373 if(this.editorcore.sourceEditMode){
23374 Roo.log('editor - showing textarea');
23377 // Roo.log(this.syncValue());
23379 this.inputEl().removeClass(['hide', 'x-hidden']);
23380 this.inputEl().dom.removeAttribute('tabIndex');
23381 this.inputEl().focus();
23383 Roo.log('editor - hiding textarea');
23385 // Roo.log(this.pushValue());
23388 this.inputEl().addClass(['hide', 'x-hidden']);
23389 this.inputEl().dom.setAttribute('tabIndex', -1);
23390 //this.deferFocus();
23393 if(this.resizable){
23394 this.setSize(this.wrap.getSize());
23397 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23400 // private (for BoxComponent)
23401 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23403 // private (for BoxComponent)
23404 getResizeEl : function(){
23408 // private (for BoxComponent)
23409 getPositionEl : function(){
23414 initEvents : function(){
23415 this.originalValue = this.getValue();
23419 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23422 // markInvalid : Roo.emptyFn,
23424 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23427 // clearInvalid : Roo.emptyFn,
23429 setValue : function(v){
23430 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23431 this.editorcore.pushValue();
23436 deferFocus : function(){
23437 this.focus.defer(10, this);
23441 focus : function(){
23442 this.editorcore.focus();
23448 onDestroy : function(){
23454 for (var i =0; i < this.toolbars.length;i++) {
23455 // fixme - ask toolbars for heights?
23456 this.toolbars[i].onDestroy();
23459 this.wrap.dom.innerHTML = '';
23460 this.wrap.remove();
23465 onFirstFocus : function(){
23466 //Roo.log("onFirstFocus");
23467 this.editorcore.onFirstFocus();
23468 for (var i =0; i < this.toolbars.length;i++) {
23469 this.toolbars[i].onFirstFocus();
23475 syncValue : function()
23477 this.editorcore.syncValue();
23480 pushValue : function()
23482 this.editorcore.pushValue();
23486 // hide stuff that is not compatible
23500 * @event specialkey
23504 * @cfg {String} fieldClass @hide
23507 * @cfg {String} focusClass @hide
23510 * @cfg {String} autoCreate @hide
23513 * @cfg {String} inputType @hide
23516 * @cfg {String} invalidClass @hide
23519 * @cfg {String} invalidText @hide
23522 * @cfg {String} msgFx @hide
23525 * @cfg {String} validateOnBlur @hide
23534 Roo.namespace('Roo.bootstrap.htmleditor');
23536 * @class Roo.bootstrap.HtmlEditorToolbar1
23541 new Roo.bootstrap.HtmlEditor({
23544 new Roo.bootstrap.HtmlEditorToolbar1({
23545 disable : { fonts: 1 , format: 1, ..., ... , ...],
23551 * @cfg {Object} disable List of elements to disable..
23552 * @cfg {Array} btns List of additional buttons.
23556 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23559 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23562 Roo.apply(this, config);
23564 // default disabled, based on 'good practice'..
23565 this.disable = this.disable || {};
23566 Roo.applyIf(this.disable, {
23569 specialElements : true
23571 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23573 this.editor = config.editor;
23574 this.editorcore = config.editor.editorcore;
23576 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23578 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23579 // dont call parent... till later.
23581 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23586 editorcore : false,
23591 "h1","h2","h3","h4","h5","h6",
23593 "abbr", "acronym", "address", "cite", "samp", "var",
23597 onRender : function(ct, position)
23599 // Roo.log("Call onRender: " + this.xtype);
23601 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23603 this.el.dom.style.marginBottom = '0';
23605 var editorcore = this.editorcore;
23606 var editor= this.editor;
23609 var btn = function(id,cmd , toggle, handler, html){
23611 var event = toggle ? 'toggle' : 'click';
23616 xns: Roo.bootstrap,
23619 enableToggle:toggle !== false,
23621 pressed : toggle ? false : null,
23624 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23625 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23631 // var cb_box = function...
23636 xns: Roo.bootstrap,
23637 glyphicon : 'font',
23641 xns: Roo.bootstrap,
23645 Roo.each(this.formats, function(f) {
23646 style.menu.items.push({
23648 xns: Roo.bootstrap,
23649 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23654 editorcore.insertTag(this.tagname);
23661 children.push(style);
23663 btn('bold',false,true);
23664 btn('italic',false,true);
23665 btn('align-left', 'justifyleft',true);
23666 btn('align-center', 'justifycenter',true);
23667 btn('align-right' , 'justifyright',true);
23668 btn('link', false, false, function(btn) {
23669 //Roo.log("create link?");
23670 var url = prompt(this.createLinkText, this.defaultLinkValue);
23671 if(url && url != 'http:/'+'/'){
23672 this.editorcore.relayCmd('createlink', url);
23675 btn('list','insertunorderedlist',true);
23676 btn('pencil', false,true, function(btn){
23678 this.toggleSourceEdit(btn.pressed);
23681 if (this.editor.btns.length > 0) {
23682 for (var i = 0; i<this.editor.btns.length; i++) {
23683 children.push(this.editor.btns[i]);
23691 xns: Roo.bootstrap,
23696 xns: Roo.bootstrap,
23701 cog.menu.items.push({
23703 xns: Roo.bootstrap,
23704 html : Clean styles,
23709 editorcore.insertTag(this.tagname);
23718 this.xtype = 'NavSimplebar';
23720 for(var i=0;i< children.length;i++) {
23722 this.buttons.add(this.addxtypeChild(children[i]));
23726 editor.on('editorevent', this.updateToolbar, this);
23728 onBtnClick : function(id)
23730 this.editorcore.relayCmd(id);
23731 this.editorcore.focus();
23735 * Protected method that will not generally be called directly. It triggers
23736 * a toolbar update by reading the markup state of the current selection in the editor.
23738 updateToolbar: function(){
23740 if(!this.editorcore.activated){
23741 this.editor.onFirstFocus(); // is this neeed?
23745 var btns = this.buttons;
23746 var doc = this.editorcore.doc;
23747 btns.get('bold').setActive(doc.queryCommandState('bold'));
23748 btns.get('italic').setActive(doc.queryCommandState('italic'));
23749 //btns.get('underline').setActive(doc.queryCommandState('underline'));
23751 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
23752 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
23753 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
23755 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
23756 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
23759 var ans = this.editorcore.getAllAncestors();
23760 if (this.formatCombo) {
23763 var store = this.formatCombo.store;
23764 this.formatCombo.setValue("");
23765 for (var i =0; i < ans.length;i++) {
23766 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23768 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23776 // hides menus... - so this cant be on a menu...
23777 Roo.bootstrap.MenuMgr.hideAll();
23779 Roo.bootstrap.MenuMgr.hideAll();
23780 //this.editorsyncValue();
23782 onFirstFocus: function() {
23783 this.buttons.each(function(item){
23787 toggleSourceEdit : function(sourceEditMode){
23790 if(sourceEditMode){
23791 Roo.log("disabling buttons");
23792 this.buttons.each( function(item){
23793 if(item.cmd != 'pencil'){
23799 Roo.log("enabling buttons");
23800 if(this.editorcore.initialized){
23801 this.buttons.each( function(item){
23807 Roo.log("calling toggole on editor");
23808 // tell the editor that it's been pressed..
23809 this.editor.toggleSourceEdit(sourceEditMode);
23819 * @class Roo.bootstrap.Table.AbstractSelectionModel
23820 * @extends Roo.util.Observable
23821 * Abstract base class for grid SelectionModels. It provides the interface that should be
23822 * implemented by descendant classes. This class should not be directly instantiated.
23825 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23826 this.locked = false;
23827 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23831 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23832 /** @ignore Called by the grid automatically. Do not call directly. */
23833 init : function(grid){
23839 * Locks the selections.
23842 this.locked = true;
23846 * Unlocks the selections.
23848 unlock : function(){
23849 this.locked = false;
23853 * Returns true if the selections are locked.
23854 * @return {Boolean}
23856 isLocked : function(){
23857 return this.locked;
23861 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23862 * @class Roo.bootstrap.Table.RowSelectionModel
23863 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23864 * It supports multiple selections and keyboard selection/navigation.
23866 * @param {Object} config
23869 Roo.bootstrap.Table.RowSelectionModel = function(config){
23870 Roo.apply(this, config);
23871 this.selections = new Roo.util.MixedCollection(false, function(o){
23876 this.lastActive = false;
23880 * @event selectionchange
23881 * Fires when the selection changes
23882 * @param {SelectionModel} this
23884 "selectionchange" : true,
23886 * @event afterselectionchange
23887 * Fires after the selection changes (eg. by key press or clicking)
23888 * @param {SelectionModel} this
23890 "afterselectionchange" : true,
23892 * @event beforerowselect
23893 * Fires when a row is selected being selected, return false to cancel.
23894 * @param {SelectionModel} this
23895 * @param {Number} rowIndex The selected index
23896 * @param {Boolean} keepExisting False if other selections will be cleared
23898 "beforerowselect" : true,
23901 * Fires when a row is selected.
23902 * @param {SelectionModel} this
23903 * @param {Number} rowIndex The selected index
23904 * @param {Roo.data.Record} r The record
23906 "rowselect" : true,
23908 * @event rowdeselect
23909 * Fires when a row is deselected.
23910 * @param {SelectionModel} this
23911 * @param {Number} rowIndex The selected index
23913 "rowdeselect" : true
23915 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23916 this.locked = false;
23919 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23921 * @cfg {Boolean} singleSelect
23922 * True to allow selection of only one row at a time (defaults to false)
23924 singleSelect : false,
23927 initEvents : function()
23930 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23931 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23932 //}else{ // allow click to work like normal
23933 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23935 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23936 this.grid.on("rowclick", this.handleMouseDown, this);
23938 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23939 "up" : function(e){
23941 this.selectPrevious(e.shiftKey);
23942 }else if(this.last !== false && this.lastActive !== false){
23943 var last = this.last;
23944 this.selectRange(this.last, this.lastActive-1);
23945 this.grid.getView().focusRow(this.lastActive);
23946 if(last !== false){
23950 this.selectFirstRow();
23952 this.fireEvent("afterselectionchange", this);
23954 "down" : function(e){
23956 this.selectNext(e.shiftKey);
23957 }else if(this.last !== false && this.lastActive !== false){
23958 var last = this.last;
23959 this.selectRange(this.last, this.lastActive+1);
23960 this.grid.getView().focusRow(this.lastActive);
23961 if(last !== false){
23965 this.selectFirstRow();
23967 this.fireEvent("afterselectionchange", this);
23971 this.grid.store.on('load', function(){
23972 this.selections.clear();
23975 var view = this.grid.view;
23976 view.on("refresh", this.onRefresh, this);
23977 view.on("rowupdated", this.onRowUpdated, this);
23978 view.on("rowremoved", this.onRemove, this);
23983 onRefresh : function()
23985 var ds = this.grid.store, i, v = this.grid.view;
23986 var s = this.selections;
23987 s.each(function(r){
23988 if((i = ds.indexOfId(r.id)) != -1){
23997 onRemove : function(v, index, r){
23998 this.selections.remove(r);
24002 onRowUpdated : function(v, index, r){
24003 if(this.isSelected(r)){
24004 v.onRowSelect(index);
24010 * @param {Array} records The records to select
24011 * @param {Boolean} keepExisting (optional) True to keep existing selections
24013 selectRecords : function(records, keepExisting)
24016 this.clearSelections();
24018 var ds = this.grid.store;
24019 for(var i = 0, len = records.length; i < len; i++){
24020 this.selectRow(ds.indexOf(records[i]), true);
24025 * Gets the number of selected rows.
24028 getCount : function(){
24029 return this.selections.length;
24033 * Selects the first row in the grid.
24035 selectFirstRow : function(){
24040 * Select the last row.
24041 * @param {Boolean} keepExisting (optional) True to keep existing selections
24043 selectLastRow : function(keepExisting){
24044 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24045 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24049 * Selects the row immediately following the last selected row.
24050 * @param {Boolean} keepExisting (optional) True to keep existing selections
24052 selectNext : function(keepExisting)
24054 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24055 this.selectRow(this.last+1, keepExisting);
24056 this.grid.getView().focusRow(this.last);
24061 * Selects the row that precedes the last selected row.
24062 * @param {Boolean} keepExisting (optional) True to keep existing selections
24064 selectPrevious : function(keepExisting){
24066 this.selectRow(this.last-1, keepExisting);
24067 this.grid.getView().focusRow(this.last);
24072 * Returns the selected records
24073 * @return {Array} Array of selected records
24075 getSelections : function(){
24076 return [].concat(this.selections.items);
24080 * Returns the first selected record.
24083 getSelected : function(){
24084 return this.selections.itemAt(0);
24089 * Clears all selections.
24091 clearSelections : function(fast)
24097 var ds = this.grid.store;
24098 var s = this.selections;
24099 s.each(function(r){
24100 this.deselectRow(ds.indexOfId(r.id));
24104 this.selections.clear();
24111 * Selects all rows.
24113 selectAll : function(){
24117 this.selections.clear();
24118 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24119 this.selectRow(i, true);
24124 * Returns True if there is a selection.
24125 * @return {Boolean}
24127 hasSelection : function(){
24128 return this.selections.length > 0;
24132 * Returns True if the specified row is selected.
24133 * @param {Number/Record} record The record or index of the record to check
24134 * @return {Boolean}
24136 isSelected : function(index){
24137 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24138 return (r && this.selections.key(r.id) ? true : false);
24142 * Returns True if the specified record id is selected.
24143 * @param {String} id The id of record to check
24144 * @return {Boolean}
24146 isIdSelected : function(id){
24147 return (this.selections.key(id) ? true : false);
24152 handleMouseDBClick : function(e, t){
24156 handleMouseDown : function(e, t)
24158 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24159 if(this.isLocked() || rowIndex < 0 ){
24162 if(e.shiftKey && this.last !== false){
24163 var last = this.last;
24164 this.selectRange(last, rowIndex, e.ctrlKey);
24165 this.last = last; // reset the last
24169 var isSelected = this.isSelected(rowIndex);
24170 //Roo.log("select row:" + rowIndex);
24172 this.deselectRow(rowIndex);
24174 this.selectRow(rowIndex, true);
24178 if(e.button !== 0 && isSelected){
24179 alert('rowIndex 2: ' + rowIndex);
24180 view.focusRow(rowIndex);
24181 }else if(e.ctrlKey && isSelected){
24182 this.deselectRow(rowIndex);
24183 }else if(!isSelected){
24184 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24185 view.focusRow(rowIndex);
24189 this.fireEvent("afterselectionchange", this);
24192 handleDragableRowClick : function(grid, rowIndex, e)
24194 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24195 this.selectRow(rowIndex, false);
24196 grid.view.focusRow(rowIndex);
24197 this.fireEvent("afterselectionchange", this);
24202 * Selects multiple rows.
24203 * @param {Array} rows Array of the indexes of the row to select
24204 * @param {Boolean} keepExisting (optional) True to keep existing selections
24206 selectRows : function(rows, keepExisting){
24208 this.clearSelections();
24210 for(var i = 0, len = rows.length; i < len; i++){
24211 this.selectRow(rows[i], true);
24216 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24217 * @param {Number} startRow The index of the first row in the range
24218 * @param {Number} endRow The index of the last row in the range
24219 * @param {Boolean} keepExisting (optional) True to retain existing selections
24221 selectRange : function(startRow, endRow, keepExisting){
24226 this.clearSelections();
24228 if(startRow <= endRow){
24229 for(var i = startRow; i <= endRow; i++){
24230 this.selectRow(i, true);
24233 for(var i = startRow; i >= endRow; i--){
24234 this.selectRow(i, true);
24240 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24241 * @param {Number} startRow The index of the first row in the range
24242 * @param {Number} endRow The index of the last row in the range
24244 deselectRange : function(startRow, endRow, preventViewNotify){
24248 for(var i = startRow; i <= endRow; i++){
24249 this.deselectRow(i, preventViewNotify);
24255 * @param {Number} row The index of the row to select
24256 * @param {Boolean} keepExisting (optional) True to keep existing selections
24258 selectRow : function(index, keepExisting, preventViewNotify)
24260 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24263 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24264 if(!keepExisting || this.singleSelect){
24265 this.clearSelections();
24268 var r = this.grid.store.getAt(index);
24269 //console.log('selectRow - record id :' + r.id);
24271 this.selections.add(r);
24272 this.last = this.lastActive = index;
24273 if(!preventViewNotify){
24274 var proxy = new Roo.Element(
24275 this.grid.getRowDom(index)
24277 proxy.addClass('bg-info info');
24279 this.fireEvent("rowselect", this, index, r);
24280 this.fireEvent("selectionchange", this);
24286 * @param {Number} row The index of the row to deselect
24288 deselectRow : function(index, preventViewNotify)
24293 if(this.last == index){
24296 if(this.lastActive == index){
24297 this.lastActive = false;
24300 var r = this.grid.store.getAt(index);
24305 this.selections.remove(r);
24306 //.console.log('deselectRow - record id :' + r.id);
24307 if(!preventViewNotify){
24309 var proxy = new Roo.Element(
24310 this.grid.getRowDom(index)
24312 proxy.removeClass('bg-info info');
24314 this.fireEvent("rowdeselect", this, index);
24315 this.fireEvent("selectionchange", this);
24319 restoreLast : function(){
24321 this.last = this._last;
24326 acceptsNav : function(row, col, cm){
24327 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24331 onEditorKey : function(field, e){
24332 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24337 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24339 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24341 }else if(k == e.ENTER && !e.ctrlKey){
24345 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24347 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24349 }else if(k == e.ESC){
24353 g.startEditing(newCell[0], newCell[1]);
24359 * Ext JS Library 1.1.1
24360 * Copyright(c) 2006-2007, Ext JS, LLC.
24362 * Originally Released Under LGPL - original licence link has changed is not relivant.
24365 * <script type="text/javascript">
24369 * @class Roo.bootstrap.PagingToolbar
24370 * @extends Roo.bootstrap.NavSimplebar
24371 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24373 * Create a new PagingToolbar
24374 * @param {Object} config The config object
24375 * @param {Roo.data.Store} store
24377 Roo.bootstrap.PagingToolbar = function(config)
24379 // old args format still supported... - xtype is prefered..
24380 // created from xtype...
24382 this.ds = config.dataSource;
24384 if (config.store && !this.ds) {
24385 this.store= Roo.factory(config.store, Roo.data);
24386 this.ds = this.store;
24387 this.ds.xmodule = this.xmodule || false;
24390 this.toolbarItems = [];
24391 if (config.items) {
24392 this.toolbarItems = config.items;
24395 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24400 this.bind(this.ds);
24403 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24407 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24409 * @cfg {Roo.data.Store} dataSource
24410 * The underlying data store providing the paged data
24413 * @cfg {String/HTMLElement/Element} container
24414 * container The id or element that will contain the toolbar
24417 * @cfg {Boolean} displayInfo
24418 * True to display the displayMsg (defaults to false)
24421 * @cfg {Number} pageSize
24422 * The number of records to display per page (defaults to 20)
24426 * @cfg {String} displayMsg
24427 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24429 displayMsg : 'Displaying {0} - {1} of {2}',
24431 * @cfg {String} emptyMsg
24432 * The message to display when no records are found (defaults to "No data to display")
24434 emptyMsg : 'No data to display',
24436 * Customizable piece of the default paging text (defaults to "Page")
24439 beforePageText : "Page",
24441 * Customizable piece of the default paging text (defaults to "of %0")
24444 afterPageText : "of {0}",
24446 * Customizable piece of the default paging text (defaults to "First Page")
24449 firstText : "First Page",
24451 * Customizable piece of the default paging text (defaults to "Previous Page")
24454 prevText : "Previous Page",
24456 * Customizable piece of the default paging text (defaults to "Next Page")
24459 nextText : "Next Page",
24461 * Customizable piece of the default paging text (defaults to "Last Page")
24464 lastText : "Last Page",
24466 * Customizable piece of the default paging text (defaults to "Refresh")
24469 refreshText : "Refresh",
24473 onRender : function(ct, position)
24475 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24476 this.navgroup.parentId = this.id;
24477 this.navgroup.onRender(this.el, null);
24478 // add the buttons to the navgroup
24480 if(this.displayInfo){
24481 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24482 this.displayEl = this.el.select('.x-paging-info', true).first();
24483 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24484 // this.displayEl = navel.el.select('span',true).first();
24490 Roo.each(_this.buttons, function(e){ // this might need to use render????
24491 Roo.factory(e).onRender(_this.el, null);
24495 Roo.each(_this.toolbarItems, function(e) {
24496 _this.navgroup.addItem(e);
24500 this.first = this.navgroup.addItem({
24501 tooltip: this.firstText,
24503 icon : 'fa fa-backward',
24505 preventDefault: true,
24506 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24509 this.prev = this.navgroup.addItem({
24510 tooltip: this.prevText,
24512 icon : 'fa fa-step-backward',
24514 preventDefault: true,
24515 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24517 //this.addSeparator();
24520 var field = this.navgroup.addItem( {
24522 cls : 'x-paging-position',
24524 html : this.beforePageText +
24525 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24526 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24529 this.field = field.el.select('input', true).first();
24530 this.field.on("keydown", this.onPagingKeydown, this);
24531 this.field.on("focus", function(){this.dom.select();});
24534 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24535 //this.field.setHeight(18);
24536 //this.addSeparator();
24537 this.next = this.navgroup.addItem({
24538 tooltip: this.nextText,
24540 html : ' <i class="fa fa-step-forward">',
24542 preventDefault: true,
24543 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24545 this.last = this.navgroup.addItem({
24546 tooltip: this.lastText,
24547 icon : 'fa fa-forward',
24550 preventDefault: true,
24551 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24553 //this.addSeparator();
24554 this.loading = this.navgroup.addItem({
24555 tooltip: this.refreshText,
24556 icon: 'fa fa-refresh',
24557 preventDefault: true,
24558 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24564 updateInfo : function(){
24565 if(this.displayEl){
24566 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24567 var msg = count == 0 ?
24571 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24573 this.displayEl.update(msg);
24578 onLoad : function(ds, r, o)
24580 this.cursor = o.params.start ? o.params.start : 0;
24582 var d = this.getPageData(),
24587 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24588 this.field.dom.value = ap;
24589 this.first.setDisabled(ap == 1);
24590 this.prev.setDisabled(ap == 1);
24591 this.next.setDisabled(ap == ps);
24592 this.last.setDisabled(ap == ps);
24593 this.loading.enable();
24598 getPageData : function(){
24599 var total = this.ds.getTotalCount();
24602 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24603 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24608 onLoadError : function(){
24609 this.loading.enable();
24613 onPagingKeydown : function(e){
24614 var k = e.getKey();
24615 var d = this.getPageData();
24617 var v = this.field.dom.value, pageNum;
24618 if(!v || isNaN(pageNum = parseInt(v, 10))){
24619 this.field.dom.value = d.activePage;
24622 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24623 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24626 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))
24628 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24629 this.field.dom.value = pageNum;
24630 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24633 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24635 var v = this.field.dom.value, pageNum;
24636 var increment = (e.shiftKey) ? 10 : 1;
24637 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24640 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24641 this.field.dom.value = d.activePage;
24644 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24646 this.field.dom.value = parseInt(v, 10) + increment;
24647 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24648 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24655 beforeLoad : function(){
24657 this.loading.disable();
24662 onClick : function(which){
24671 ds.load({params:{start: 0, limit: this.pageSize}});
24674 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24677 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24680 var total = ds.getTotalCount();
24681 var extra = total % this.pageSize;
24682 var lastStart = extra ? (total - extra) : total-this.pageSize;
24683 ds.load({params:{start: lastStart, limit: this.pageSize}});
24686 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24692 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24693 * @param {Roo.data.Store} store The data store to unbind
24695 unbind : function(ds){
24696 ds.un("beforeload", this.beforeLoad, this);
24697 ds.un("load", this.onLoad, this);
24698 ds.un("loadexception", this.onLoadError, this);
24699 ds.un("remove", this.updateInfo, this);
24700 ds.un("add", this.updateInfo, this);
24701 this.ds = undefined;
24705 * Binds the paging toolbar to the specified {@link Roo.data.Store}
24706 * @param {Roo.data.Store} store The data store to bind
24708 bind : function(ds){
24709 ds.on("beforeload", this.beforeLoad, this);
24710 ds.on("load", this.onLoad, this);
24711 ds.on("loadexception", this.onLoadError, this);
24712 ds.on("remove", this.updateInfo, this);
24713 ds.on("add", this.updateInfo, this);
24724 * @class Roo.bootstrap.MessageBar
24725 * @extends Roo.bootstrap.Component
24726 * Bootstrap MessageBar class
24727 * @cfg {String} html contents of the MessageBar
24728 * @cfg {String} weight (info | success | warning | danger) default info
24729 * @cfg {String} beforeClass insert the bar before the given class
24730 * @cfg {Boolean} closable (true | false) default false
24731 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
24734 * Create a new Element
24735 * @param {Object} config The config object
24738 Roo.bootstrap.MessageBar = function(config){
24739 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
24742 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
24748 beforeClass: 'bootstrap-sticky-wrap',
24750 getAutoCreate : function(){
24754 cls: 'alert alert-dismissable alert-' + this.weight,
24759 html: this.html || ''
24765 cfg.cls += ' alert-messages-fixed';
24779 onRender : function(ct, position)
24781 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24784 var cfg = Roo.apply({}, this.getAutoCreate());
24788 cfg.cls += ' ' + this.cls;
24791 cfg.style = this.style;
24793 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24795 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24798 this.el.select('>button.close').on('click', this.hide, this);
24804 if (!this.rendered) {
24810 this.fireEvent('show', this);
24816 if (!this.rendered) {
24822 this.fireEvent('hide', this);
24825 update : function()
24827 // var e = this.el.dom.firstChild;
24829 // if(this.closable){
24830 // e = e.nextSibling;
24833 // e.data = this.html || '';
24835 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24851 * @class Roo.bootstrap.Graph
24852 * @extends Roo.bootstrap.Component
24853 * Bootstrap Graph class
24857 @cfg {String} graphtype bar | vbar | pie
24858 @cfg {number} g_x coodinator | centre x (pie)
24859 @cfg {number} g_y coodinator | centre y (pie)
24860 @cfg {number} g_r radius (pie)
24861 @cfg {number} g_height height of the chart (respected by all elements in the set)
24862 @cfg {number} g_width width of the chart (respected by all elements in the set)
24863 @cfg {Object} title The title of the chart
24866 -opts (object) options for the chart
24868 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24869 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24871 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.
24872 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24874 o stretch (boolean)
24876 -opts (object) options for the pie
24879 o startAngle (number)
24880 o endAngle (number)
24884 * Create a new Input
24885 * @param {Object} config The config object
24888 Roo.bootstrap.Graph = function(config){
24889 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24895 * The img click event for the img.
24896 * @param {Roo.EventObject} e
24902 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24913 //g_colors: this.colors,
24920 getAutoCreate : function(){
24931 onRender : function(ct,position){
24934 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24936 if (typeof(Raphael) == 'undefined') {
24937 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24941 this.raphael = Raphael(this.el.dom);
24943 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24944 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24945 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24946 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24948 r.text(160, 10, "Single Series Chart").attr(txtattr);
24949 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24950 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24951 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24953 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24954 r.barchart(330, 10, 300, 220, data1);
24955 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24956 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24959 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24960 // r.barchart(30, 30, 560, 250, xdata, {
24961 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24962 // axis : "0 0 1 1",
24963 // axisxlabels : xdata
24964 // //yvalues : cols,
24967 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24969 // this.load(null,xdata,{
24970 // axis : "0 0 1 1",
24971 // axisxlabels : xdata
24976 load : function(graphtype,xdata,opts)
24978 this.raphael.clear();
24980 graphtype = this.graphtype;
24985 var r = this.raphael,
24986 fin = function () {
24987 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24989 fout = function () {
24990 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24992 pfin = function() {
24993 this.sector.stop();
24994 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24997 this.label[0].stop();
24998 this.label[0].attr({ r: 7.5 });
24999 this.label[1].attr({ "font-weight": 800 });
25002 pfout = function() {
25003 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25006 this.label[0].animate({ r: 5 }, 500, "bounce");
25007 this.label[1].attr({ "font-weight": 400 });
25013 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25016 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25019 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25020 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25022 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25029 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25034 setTitle: function(o)
25039 initEvents: function() {
25042 this.el.on('click', this.onClick, this);
25046 onClick : function(e)
25048 Roo.log('img onclick');
25049 this.fireEvent('click', this, e);
25061 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25064 * @class Roo.bootstrap.dash.NumberBox
25065 * @extends Roo.bootstrap.Component
25066 * Bootstrap NumberBox class
25067 * @cfg {String} headline Box headline
25068 * @cfg {String} content Box content
25069 * @cfg {String} icon Box icon
25070 * @cfg {String} footer Footer text
25071 * @cfg {String} fhref Footer href
25074 * Create a new NumberBox
25075 * @param {Object} config The config object
25079 Roo.bootstrap.dash.NumberBox = function(config){
25080 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25084 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25093 getAutoCreate : function(){
25097 cls : 'small-box ',
25105 cls : 'roo-headline',
25106 html : this.headline
25110 cls : 'roo-content',
25111 html : this.content
25125 cls : 'ion ' + this.icon
25134 cls : 'small-box-footer',
25135 href : this.fhref || '#',
25139 cfg.cn.push(footer);
25146 onRender : function(ct,position){
25147 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25154 setHeadline: function (value)
25156 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25159 setFooter: function (value, href)
25161 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25164 this.el.select('a.small-box-footer',true).first().attr('href', href);
25169 setContent: function (value)
25171 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25174 initEvents: function()
25188 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25191 * @class Roo.bootstrap.dash.TabBox
25192 * @extends Roo.bootstrap.Component
25193 * Bootstrap TabBox class
25194 * @cfg {String} title Title of the TabBox
25195 * @cfg {String} icon Icon of the TabBox
25196 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25197 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25200 * Create a new TabBox
25201 * @param {Object} config The config object
25205 Roo.bootstrap.dash.TabBox = function(config){
25206 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25211 * When a pane is added
25212 * @param {Roo.bootstrap.dash.TabPane} pane
25216 * @event activatepane
25217 * When a pane is activated
25218 * @param {Roo.bootstrap.dash.TabPane} pane
25220 "activatepane" : true
25228 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25233 tabScrollable : false,
25235 getChildContainer : function()
25237 return this.el.select('.tab-content', true).first();
25240 getAutoCreate : function(){
25244 cls: 'pull-left header',
25252 cls: 'fa ' + this.icon
25258 cls: 'nav nav-tabs pull-right',
25264 if(this.tabScrollable){
25271 cls: 'nav nav-tabs pull-right',
25282 cls: 'nav-tabs-custom',
25287 cls: 'tab-content no-padding',
25295 initEvents : function()
25297 //Roo.log('add add pane handler');
25298 this.on('addpane', this.onAddPane, this);
25301 * Updates the box title
25302 * @param {String} html to set the title to.
25304 setTitle : function(value)
25306 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25308 onAddPane : function(pane)
25310 this.panes.push(pane);
25311 //Roo.log('addpane');
25313 // tabs are rendere left to right..
25314 if(!this.showtabs){
25318 var ctr = this.el.select('.nav-tabs', true).first();
25321 var existing = ctr.select('.nav-tab',true);
25322 var qty = existing.getCount();;
25325 var tab = ctr.createChild({
25327 cls : 'nav-tab' + (qty ? '' : ' active'),
25335 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25338 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25340 pane.el.addClass('active');
25345 onTabClick : function(ev,un,ob,pane)
25347 //Roo.log('tab - prev default');
25348 ev.preventDefault();
25351 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25352 pane.tab.addClass('active');
25353 //Roo.log(pane.title);
25354 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25355 // technically we should have a deactivate event.. but maybe add later.
25356 // and it should not de-activate the selected tab...
25357 this.fireEvent('activatepane', pane);
25358 pane.el.addClass('active');
25359 pane.fireEvent('activate');
25364 getActivePane : function()
25367 Roo.each(this.panes, function(p) {
25368 if(p.el.hasClass('active')){
25389 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25391 * @class Roo.bootstrap.TabPane
25392 * @extends Roo.bootstrap.Component
25393 * Bootstrap TabPane class
25394 * @cfg {Boolean} active (false | true) Default false
25395 * @cfg {String} title title of panel
25399 * Create a new TabPane
25400 * @param {Object} config The config object
25403 Roo.bootstrap.dash.TabPane = function(config){
25404 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25410 * When a pane is activated
25411 * @param {Roo.bootstrap.dash.TabPane} pane
25418 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25423 // the tabBox that this is attached to.
25426 getAutoCreate : function()
25434 cfg.cls += ' active';
25439 initEvents : function()
25441 //Roo.log('trigger add pane handler');
25442 this.parent().fireEvent('addpane', this)
25446 * Updates the tab title
25447 * @param {String} html to set the title to.
25449 setTitle: function(str)
25455 this.tab.select('a', true).first().dom.innerHTML = str;
25472 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25475 * @class Roo.bootstrap.menu.Menu
25476 * @extends Roo.bootstrap.Component
25477 * Bootstrap Menu class - container for Menu
25478 * @cfg {String} html Text of the menu
25479 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25480 * @cfg {String} icon Font awesome icon
25481 * @cfg {String} pos Menu align to (top | bottom) default bottom
25485 * Create a new Menu
25486 * @param {Object} config The config object
25490 Roo.bootstrap.menu.Menu = function(config){
25491 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25495 * @event beforeshow
25496 * Fires before this menu is displayed
25497 * @param {Roo.bootstrap.menu.Menu} this
25501 * @event beforehide
25502 * Fires before this menu is hidden
25503 * @param {Roo.bootstrap.menu.Menu} this
25508 * Fires after this menu is displayed
25509 * @param {Roo.bootstrap.menu.Menu} this
25514 * Fires after this menu is hidden
25515 * @param {Roo.bootstrap.menu.Menu} this
25520 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25521 * @param {Roo.bootstrap.menu.Menu} this
25522 * @param {Roo.EventObject} e
25529 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25533 weight : 'default',
25538 getChildContainer : function() {
25539 if(this.isSubMenu){
25543 return this.el.select('ul.dropdown-menu', true).first();
25546 getAutoCreate : function()
25551 cls : 'roo-menu-text',
25559 cls : 'fa ' + this.icon
25570 cls : 'dropdown-button btn btn-' + this.weight,
25575 cls : 'dropdown-toggle btn btn-' + this.weight,
25585 cls : 'dropdown-menu'
25591 if(this.pos == 'top'){
25592 cfg.cls += ' dropup';
25595 if(this.isSubMenu){
25598 cls : 'dropdown-menu'
25605 onRender : function(ct, position)
25607 this.isSubMenu = ct.hasClass('dropdown-submenu');
25609 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25612 initEvents : function()
25614 if(this.isSubMenu){
25618 this.hidden = true;
25620 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25621 this.triggerEl.on('click', this.onTriggerPress, this);
25623 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25624 this.buttonEl.on('click', this.onClick, this);
25630 if(this.isSubMenu){
25634 return this.el.select('ul.dropdown-menu', true).first();
25637 onClick : function(e)
25639 this.fireEvent("click", this, e);
25642 onTriggerPress : function(e)
25644 if (this.isVisible()) {
25651 isVisible : function(){
25652 return !this.hidden;
25657 this.fireEvent("beforeshow", this);
25659 this.hidden = false;
25660 this.el.addClass('open');
25662 Roo.get(document).on("mouseup", this.onMouseUp, this);
25664 this.fireEvent("show", this);
25671 this.fireEvent("beforehide", this);
25673 this.hidden = true;
25674 this.el.removeClass('open');
25676 Roo.get(document).un("mouseup", this.onMouseUp);
25678 this.fireEvent("hide", this);
25681 onMouseUp : function()
25695 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25698 * @class Roo.bootstrap.menu.Item
25699 * @extends Roo.bootstrap.Component
25700 * Bootstrap MenuItem class
25701 * @cfg {Boolean} submenu (true | false) default false
25702 * @cfg {String} html text of the item
25703 * @cfg {String} href the link
25704 * @cfg {Boolean} disable (true | false) default false
25705 * @cfg {Boolean} preventDefault (true | false) default true
25706 * @cfg {String} icon Font awesome icon
25707 * @cfg {String} pos Submenu align to (left | right) default right
25711 * Create a new Item
25712 * @param {Object} config The config object
25716 Roo.bootstrap.menu.Item = function(config){
25717 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
25721 * Fires when the mouse is hovering over this menu
25722 * @param {Roo.bootstrap.menu.Item} this
25723 * @param {Roo.EventObject} e
25728 * Fires when the mouse exits this menu
25729 * @param {Roo.bootstrap.menu.Item} this
25730 * @param {Roo.EventObject} e
25736 * The raw click event for the entire grid.
25737 * @param {Roo.EventObject} e
25743 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
25748 preventDefault: true,
25753 getAutoCreate : function()
25758 cls : 'roo-menu-item-text',
25766 cls : 'fa ' + this.icon
25775 href : this.href || '#',
25782 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25786 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25788 if(this.pos == 'left'){
25789 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25796 initEvents : function()
25798 this.el.on('mouseover', this.onMouseOver, this);
25799 this.el.on('mouseout', this.onMouseOut, this);
25801 this.el.select('a', true).first().on('click', this.onClick, this);
25805 onClick : function(e)
25807 if(this.preventDefault){
25808 e.preventDefault();
25811 this.fireEvent("click", this, e);
25814 onMouseOver : function(e)
25816 if(this.submenu && this.pos == 'left'){
25817 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25820 this.fireEvent("mouseover", this, e);
25823 onMouseOut : function(e)
25825 this.fireEvent("mouseout", this, e);
25837 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25840 * @class Roo.bootstrap.menu.Separator
25841 * @extends Roo.bootstrap.Component
25842 * Bootstrap Separator class
25845 * Create a new Separator
25846 * @param {Object} config The config object
25850 Roo.bootstrap.menu.Separator = function(config){
25851 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25854 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25856 getAutoCreate : function(){
25877 * @class Roo.bootstrap.Tooltip
25878 * Bootstrap Tooltip class
25879 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25880 * to determine which dom element triggers the tooltip.
25882 * It needs to add support for additional attributes like tooltip-position
25885 * Create a new Toolti
25886 * @param {Object} config The config object
25889 Roo.bootstrap.Tooltip = function(config){
25890 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25892 this.alignment = Roo.bootstrap.Tooltip.alignment;
25894 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25895 this.alignment = config.alignment;
25900 Roo.apply(Roo.bootstrap.Tooltip, {
25902 * @function init initialize tooltip monitoring.
25906 currentTip : false,
25907 currentRegion : false,
25913 Roo.get(document).on('mouseover', this.enter ,this);
25914 Roo.get(document).on('mouseout', this.leave, this);
25917 this.currentTip = new Roo.bootstrap.Tooltip();
25920 enter : function(ev)
25922 var dom = ev.getTarget();
25924 //Roo.log(['enter',dom]);
25925 var el = Roo.fly(dom);
25926 if (this.currentEl) {
25928 //Roo.log(this.currentEl);
25929 //Roo.log(this.currentEl.contains(dom));
25930 if (this.currentEl == el) {
25933 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25939 if (this.currentTip.el) {
25940 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25944 if(!el || el.dom == document){
25950 // you can not look for children, as if el is the body.. then everythign is the child..
25951 if (!el.attr('tooltip')) { //
25952 if (!el.select("[tooltip]").elements.length) {
25955 // is the mouse over this child...?
25956 bindEl = el.select("[tooltip]").first();
25957 var xy = ev.getXY();
25958 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25959 //Roo.log("not in region.");
25962 //Roo.log("child element over..");
25965 this.currentEl = bindEl;
25966 this.currentTip.bind(bindEl);
25967 this.currentRegion = Roo.lib.Region.getRegion(dom);
25968 this.currentTip.enter();
25971 leave : function(ev)
25973 var dom = ev.getTarget();
25974 //Roo.log(['leave',dom]);
25975 if (!this.currentEl) {
25980 if (dom != this.currentEl.dom) {
25983 var xy = ev.getXY();
25984 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25987 // only activate leave if mouse cursor is outside... bounding box..
25992 if (this.currentTip) {
25993 this.currentTip.leave();
25995 //Roo.log('clear currentEl');
25996 this.currentEl = false;
26001 'left' : ['r-l', [-2,0], 'right'],
26002 'right' : ['l-r', [2,0], 'left'],
26003 'bottom' : ['t-b', [0,2], 'top'],
26004 'top' : [ 'b-t', [0,-2], 'bottom']
26010 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26015 delay : null, // can be { show : 300 , hide: 500}
26019 hoverState : null, //???
26021 placement : 'bottom',
26025 getAutoCreate : function(){
26032 cls : 'tooltip-arrow'
26035 cls : 'tooltip-inner'
26042 bind : function(el)
26048 enter : function () {
26050 if (this.timeout != null) {
26051 clearTimeout(this.timeout);
26054 this.hoverState = 'in';
26055 //Roo.log("enter - show");
26056 if (!this.delay || !this.delay.show) {
26061 this.timeout = setTimeout(function () {
26062 if (_t.hoverState == 'in') {
26065 }, this.delay.show);
26069 clearTimeout(this.timeout);
26071 this.hoverState = 'out';
26072 if (!this.delay || !this.delay.hide) {
26078 this.timeout = setTimeout(function () {
26079 //Roo.log("leave - timeout");
26081 if (_t.hoverState == 'out') {
26083 Roo.bootstrap.Tooltip.currentEl = false;
26088 show : function (msg)
26091 this.render(document.body);
26094 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26096 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26098 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26100 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26102 var placement = typeof this.placement == 'function' ?
26103 this.placement.call(this, this.el, on_el) :
26106 var autoToken = /\s?auto?\s?/i;
26107 var autoPlace = autoToken.test(placement);
26109 placement = placement.replace(autoToken, '') || 'top';
26113 //this.el.setXY([0,0]);
26115 //this.el.dom.style.display='block';
26117 //this.el.appendTo(on_el);
26119 var p = this.getPosition();
26120 var box = this.el.getBox();
26126 var align = this.alignment[placement];
26128 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26130 if(placement == 'top' || placement == 'bottom'){
26132 placement = 'right';
26135 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26136 placement = 'left';
26139 var scroll = Roo.select('body', true).first().getScroll();
26141 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26147 this.el.alignTo(this.bindEl, align[0],align[1]);
26148 //var arrow = this.el.select('.arrow',true).first();
26149 //arrow.set(align[2],
26151 this.el.addClass(placement);
26153 this.el.addClass('in fade');
26155 this.hoverState = null;
26157 if (this.el.hasClass('fade')) {
26168 //this.el.setXY([0,0]);
26169 this.el.removeClass('in');
26185 * @class Roo.bootstrap.LocationPicker
26186 * @extends Roo.bootstrap.Component
26187 * Bootstrap LocationPicker class
26188 * @cfg {Number} latitude Position when init default 0
26189 * @cfg {Number} longitude Position when init default 0
26190 * @cfg {Number} zoom default 15
26191 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26192 * @cfg {Boolean} mapTypeControl default false
26193 * @cfg {Boolean} disableDoubleClickZoom default false
26194 * @cfg {Boolean} scrollwheel default true
26195 * @cfg {Boolean} streetViewControl default false
26196 * @cfg {Number} radius default 0
26197 * @cfg {String} locationName
26198 * @cfg {Boolean} draggable default true
26199 * @cfg {Boolean} enableAutocomplete default false
26200 * @cfg {Boolean} enableReverseGeocode default true
26201 * @cfg {String} markerTitle
26204 * Create a new LocationPicker
26205 * @param {Object} config The config object
26209 Roo.bootstrap.LocationPicker = function(config){
26211 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26216 * Fires when the picker initialized.
26217 * @param {Roo.bootstrap.LocationPicker} this
26218 * @param {Google Location} location
26222 * @event positionchanged
26223 * Fires when the picker position changed.
26224 * @param {Roo.bootstrap.LocationPicker} this
26225 * @param {Google Location} location
26227 positionchanged : true,
26230 * Fires when the map resize.
26231 * @param {Roo.bootstrap.LocationPicker} this
26236 * Fires when the map show.
26237 * @param {Roo.bootstrap.LocationPicker} this
26242 * Fires when the map hide.
26243 * @param {Roo.bootstrap.LocationPicker} this
26248 * Fires when click the map.
26249 * @param {Roo.bootstrap.LocationPicker} this
26250 * @param {Map event} e
26254 * @event mapRightClick
26255 * Fires when right click the map.
26256 * @param {Roo.bootstrap.LocationPicker} this
26257 * @param {Map event} e
26259 mapRightClick : true,
26261 * @event markerClick
26262 * Fires when click the marker.
26263 * @param {Roo.bootstrap.LocationPicker} this
26264 * @param {Map event} e
26266 markerClick : true,
26268 * @event markerRightClick
26269 * Fires when right click the marker.
26270 * @param {Roo.bootstrap.LocationPicker} this
26271 * @param {Map event} e
26273 markerRightClick : true,
26275 * @event OverlayViewDraw
26276 * Fires when OverlayView Draw
26277 * @param {Roo.bootstrap.LocationPicker} this
26279 OverlayViewDraw : true,
26281 * @event OverlayViewOnAdd
26282 * Fires when OverlayView Draw
26283 * @param {Roo.bootstrap.LocationPicker} this
26285 OverlayViewOnAdd : true,
26287 * @event OverlayViewOnRemove
26288 * Fires when OverlayView Draw
26289 * @param {Roo.bootstrap.LocationPicker} this
26291 OverlayViewOnRemove : true,
26293 * @event OverlayViewShow
26294 * Fires when OverlayView Draw
26295 * @param {Roo.bootstrap.LocationPicker} this
26296 * @param {Pixel} cpx
26298 OverlayViewShow : true,
26300 * @event OverlayViewHide
26301 * Fires when OverlayView Draw
26302 * @param {Roo.bootstrap.LocationPicker} this
26304 OverlayViewHide : true,
26306 * @event loadexception
26307 * Fires when load google lib failed.
26308 * @param {Roo.bootstrap.LocationPicker} this
26310 loadexception : true
26315 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26317 gMapContext: false,
26323 mapTypeControl: false,
26324 disableDoubleClickZoom: false,
26326 streetViewControl: false,
26330 enableAutocomplete: false,
26331 enableReverseGeocode: true,
26334 getAutoCreate: function()
26339 cls: 'roo-location-picker'
26345 initEvents: function(ct, position)
26347 if(!this.el.getWidth() || this.isApplied()){
26351 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26356 initial: function()
26358 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26359 this.fireEvent('loadexception', this);
26363 if(!this.mapTypeId){
26364 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26367 this.gMapContext = this.GMapContext();
26369 this.initOverlayView();
26371 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26375 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26376 _this.setPosition(_this.gMapContext.marker.position);
26379 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26380 _this.fireEvent('mapClick', this, event);
26384 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26385 _this.fireEvent('mapRightClick', this, event);
26389 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26390 _this.fireEvent('markerClick', this, event);
26394 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26395 _this.fireEvent('markerRightClick', this, event);
26399 this.setPosition(this.gMapContext.location);
26401 this.fireEvent('initial', this, this.gMapContext.location);
26404 initOverlayView: function()
26408 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26412 _this.fireEvent('OverlayViewDraw', _this);
26417 _this.fireEvent('OverlayViewOnAdd', _this);
26420 onRemove: function()
26422 _this.fireEvent('OverlayViewOnRemove', _this);
26425 show: function(cpx)
26427 _this.fireEvent('OverlayViewShow', _this, cpx);
26432 _this.fireEvent('OverlayViewHide', _this);
26438 fromLatLngToContainerPixel: function(event)
26440 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26443 isApplied: function()
26445 return this.getGmapContext() == false ? false : true;
26448 getGmapContext: function()
26450 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26453 GMapContext: function()
26455 var position = new google.maps.LatLng(this.latitude, this.longitude);
26457 var _map = new google.maps.Map(this.el.dom, {
26460 mapTypeId: this.mapTypeId,
26461 mapTypeControl: this.mapTypeControl,
26462 disableDoubleClickZoom: this.disableDoubleClickZoom,
26463 scrollwheel: this.scrollwheel,
26464 streetViewControl: this.streetViewControl,
26465 locationName: this.locationName,
26466 draggable: this.draggable,
26467 enableAutocomplete: this.enableAutocomplete,
26468 enableReverseGeocode: this.enableReverseGeocode
26471 var _marker = new google.maps.Marker({
26472 position: position,
26474 title: this.markerTitle,
26475 draggable: this.draggable
26482 location: position,
26483 radius: this.radius,
26484 locationName: this.locationName,
26485 addressComponents: {
26486 formatted_address: null,
26487 addressLine1: null,
26488 addressLine2: null,
26490 streetNumber: null,
26494 stateOrProvince: null
26497 domContainer: this.el.dom,
26498 geodecoder: new google.maps.Geocoder()
26502 drawCircle: function(center, radius, options)
26504 if (this.gMapContext.circle != null) {
26505 this.gMapContext.circle.setMap(null);
26509 options = Roo.apply({}, options, {
26510 strokeColor: "#0000FF",
26511 strokeOpacity: .35,
26513 fillColor: "#0000FF",
26517 options.map = this.gMapContext.map;
26518 options.radius = radius;
26519 options.center = center;
26520 this.gMapContext.circle = new google.maps.Circle(options);
26521 return this.gMapContext.circle;
26527 setPosition: function(location)
26529 this.gMapContext.location = location;
26530 this.gMapContext.marker.setPosition(location);
26531 this.gMapContext.map.panTo(location);
26532 this.drawCircle(location, this.gMapContext.radius, {});
26536 if (this.gMapContext.settings.enableReverseGeocode) {
26537 this.gMapContext.geodecoder.geocode({
26538 latLng: this.gMapContext.location
26539 }, function(results, status) {
26541 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26542 _this.gMapContext.locationName = results[0].formatted_address;
26543 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26545 _this.fireEvent('positionchanged', this, location);
26552 this.fireEvent('positionchanged', this, location);
26557 google.maps.event.trigger(this.gMapContext.map, "resize");
26559 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26561 this.fireEvent('resize', this);
26564 setPositionByLatLng: function(latitude, longitude)
26566 this.setPosition(new google.maps.LatLng(latitude, longitude));
26569 getCurrentPosition: function()
26572 latitude: this.gMapContext.location.lat(),
26573 longitude: this.gMapContext.location.lng()
26577 getAddressName: function()
26579 return this.gMapContext.locationName;
26582 getAddressComponents: function()
26584 return this.gMapContext.addressComponents;
26587 address_component_from_google_geocode: function(address_components)
26591 for (var i = 0; i < address_components.length; i++) {
26592 var component = address_components[i];
26593 if (component.types.indexOf("postal_code") >= 0) {
26594 result.postalCode = component.short_name;
26595 } else if (component.types.indexOf("street_number") >= 0) {
26596 result.streetNumber = component.short_name;
26597 } else if (component.types.indexOf("route") >= 0) {
26598 result.streetName = component.short_name;
26599 } else if (component.types.indexOf("neighborhood") >= 0) {
26600 result.city = component.short_name;
26601 } else if (component.types.indexOf("locality") >= 0) {
26602 result.city = component.short_name;
26603 } else if (component.types.indexOf("sublocality") >= 0) {
26604 result.district = component.short_name;
26605 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26606 result.stateOrProvince = component.short_name;
26607 } else if (component.types.indexOf("country") >= 0) {
26608 result.country = component.short_name;
26612 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26613 result.addressLine2 = "";
26617 setZoomLevel: function(zoom)
26619 this.gMapContext.map.setZoom(zoom);
26632 this.fireEvent('show', this);
26643 this.fireEvent('hide', this);
26648 Roo.apply(Roo.bootstrap.LocationPicker, {
26650 OverlayView : function(map, options)
26652 options = options || {};
26666 * @class Roo.bootstrap.Alert
26667 * @extends Roo.bootstrap.Component
26668 * Bootstrap Alert class
26669 * @cfg {String} title The title of alert
26670 * @cfg {String} html The content of alert
26671 * @cfg {String} weight ( success | info | warning | danger )
26672 * @cfg {String} faicon font-awesomeicon
26675 * Create a new alert
26676 * @param {Object} config The config object
26680 Roo.bootstrap.Alert = function(config){
26681 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26685 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26692 getAutoCreate : function()
26701 cls : 'roo-alert-icon'
26706 cls : 'roo-alert-title',
26711 cls : 'roo-alert-text',
26718 cfg.cn[0].cls += ' fa ' + this.faicon;
26722 cfg.cls += ' alert-' + this.weight;
26728 initEvents: function()
26730 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26733 setTitle : function(str)
26735 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
26738 setText : function(str)
26740 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
26743 setWeight : function(weight)
26746 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
26749 this.weight = weight;
26751 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
26754 setIcon : function(icon)
26757 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
26760 this.faicon = icon;
26762 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26783 * @class Roo.bootstrap.UploadCropbox
26784 * @extends Roo.bootstrap.Component
26785 * Bootstrap UploadCropbox class
26786 * @cfg {String} emptyText show when image has been loaded
26787 * @cfg {String} rotateNotify show when image too small to rotate
26788 * @cfg {Number} errorTimeout default 3000
26789 * @cfg {Number} minWidth default 300
26790 * @cfg {Number} minHeight default 300
26791 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26792 * @cfg {Boolean} isDocument (true|false) default false
26793 * @cfg {String} url action url
26794 * @cfg {String} paramName default 'imageUpload'
26795 * @cfg {String} method default POST
26796 * @cfg {Boolean} loadMask (true|false) default true
26797 * @cfg {Boolean} loadingText default 'Loading...'
26800 * Create a new UploadCropbox
26801 * @param {Object} config The config object
26804 Roo.bootstrap.UploadCropbox = function(config){
26805 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26809 * @event beforeselectfile
26810 * Fire before select file
26811 * @param {Roo.bootstrap.UploadCropbox} this
26813 "beforeselectfile" : true,
26816 * Fire after initEvent
26817 * @param {Roo.bootstrap.UploadCropbox} this
26822 * Fire after initEvent
26823 * @param {Roo.bootstrap.UploadCropbox} this
26824 * @param {String} data
26829 * Fire when preparing the file data
26830 * @param {Roo.bootstrap.UploadCropbox} this
26831 * @param {Object} file
26836 * Fire when get exception
26837 * @param {Roo.bootstrap.UploadCropbox} this
26838 * @param {XMLHttpRequest} xhr
26840 "exception" : true,
26842 * @event beforeloadcanvas
26843 * Fire before load the canvas
26844 * @param {Roo.bootstrap.UploadCropbox} this
26845 * @param {String} src
26847 "beforeloadcanvas" : true,
26850 * Fire when trash image
26851 * @param {Roo.bootstrap.UploadCropbox} this
26856 * Fire when download the image
26857 * @param {Roo.bootstrap.UploadCropbox} this
26861 * @event footerbuttonclick
26862 * Fire when footerbuttonclick
26863 * @param {Roo.bootstrap.UploadCropbox} this
26864 * @param {String} type
26866 "footerbuttonclick" : true,
26870 * @param {Roo.bootstrap.UploadCropbox} this
26875 * Fire when rotate the image
26876 * @param {Roo.bootstrap.UploadCropbox} this
26877 * @param {String} pos
26882 * Fire when inspect the file
26883 * @param {Roo.bootstrap.UploadCropbox} this
26884 * @param {Object} file
26889 * Fire when xhr upload the file
26890 * @param {Roo.bootstrap.UploadCropbox} this
26891 * @param {Object} data
26896 * Fire when arrange the file data
26897 * @param {Roo.bootstrap.UploadCropbox} this
26898 * @param {Object} formData
26903 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26906 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26908 emptyText : 'Click to upload image',
26909 rotateNotify : 'Image is too small to rotate',
26910 errorTimeout : 3000,
26924 cropType : 'image/jpeg',
26926 canvasLoaded : false,
26927 isDocument : false,
26929 paramName : 'imageUpload',
26931 loadingText : 'Loading...',
26934 getAutoCreate : function()
26938 cls : 'roo-upload-cropbox',
26942 cls : 'roo-upload-cropbox-selector',
26947 cls : 'roo-upload-cropbox-body',
26948 style : 'cursor:pointer',
26952 cls : 'roo-upload-cropbox-preview'
26956 cls : 'roo-upload-cropbox-thumb'
26960 cls : 'roo-upload-cropbox-empty-notify',
26961 html : this.emptyText
26965 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26966 html : this.rotateNotify
26972 cls : 'roo-upload-cropbox-footer',
26975 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26985 onRender : function(ct, position)
26987 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26989 if (this.buttons.length) {
26991 Roo.each(this.buttons, function(bb) {
26993 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26995 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27001 this.maskEl = this.el;
27005 initEvents : function()
27007 this.urlAPI = (window.createObjectURL && window) ||
27008 (window.URL && URL.revokeObjectURL && URL) ||
27009 (window.webkitURL && webkitURL);
27011 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27012 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27014 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27015 this.selectorEl.hide();
27017 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27018 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27020 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27021 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27022 this.thumbEl.hide();
27024 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27025 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27027 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27028 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27029 this.errorEl.hide();
27031 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27032 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27033 this.footerEl.hide();
27035 this.setThumbBoxSize();
27041 this.fireEvent('initial', this);
27048 window.addEventListener("resize", function() { _this.resize(); } );
27050 this.bodyEl.on('click', this.beforeSelectFile, this);
27053 this.bodyEl.on('touchstart', this.onTouchStart, this);
27054 this.bodyEl.on('touchmove', this.onTouchMove, this);
27055 this.bodyEl.on('touchend', this.onTouchEnd, this);
27059 this.bodyEl.on('mousedown', this.onMouseDown, this);
27060 this.bodyEl.on('mousemove', this.onMouseMove, this);
27061 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27062 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27063 Roo.get(document).on('mouseup', this.onMouseUp, this);
27066 this.selectorEl.on('change', this.onFileSelected, this);
27072 this.baseScale = 1;
27074 this.baseRotate = 1;
27075 this.dragable = false;
27076 this.pinching = false;
27079 this.cropData = false;
27080 this.notifyEl.dom.innerHTML = this.emptyText;
27082 this.selectorEl.dom.value = '';
27086 resize : function()
27088 if(this.fireEvent('resize', this) != false){
27089 this.setThumbBoxPosition();
27090 this.setCanvasPosition();
27094 onFooterButtonClick : function(e, el, o, type)
27097 case 'rotate-left' :
27098 this.onRotateLeft(e);
27100 case 'rotate-right' :
27101 this.onRotateRight(e);
27104 this.beforeSelectFile(e);
27119 this.fireEvent('footerbuttonclick', this, type);
27122 beforeSelectFile : function(e)
27124 e.preventDefault();
27126 if(this.fireEvent('beforeselectfile', this) != false){
27127 this.selectorEl.dom.click();
27131 onFileSelected : function(e)
27133 e.preventDefault();
27135 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27139 var file = this.selectorEl.dom.files[0];
27141 if(this.fireEvent('inspect', this, file) != false){
27142 this.prepare(file);
27147 trash : function(e)
27149 this.fireEvent('trash', this);
27152 download : function(e)
27154 this.fireEvent('download', this);
27157 loadCanvas : function(src)
27159 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27163 this.imageEl = document.createElement('img');
27167 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27169 this.imageEl.src = src;
27173 onLoadCanvas : function()
27175 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27176 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27178 this.bodyEl.un('click', this.beforeSelectFile, this);
27180 this.notifyEl.hide();
27181 this.thumbEl.show();
27182 this.footerEl.show();
27184 this.baseRotateLevel();
27186 if(this.isDocument){
27187 this.setThumbBoxSize();
27190 this.setThumbBoxPosition();
27192 this.baseScaleLevel();
27198 this.canvasLoaded = true;
27201 this.maskEl.unmask();
27206 setCanvasPosition : function()
27208 if(!this.canvasEl){
27212 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27213 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27215 this.previewEl.setLeft(pw);
27216 this.previewEl.setTop(ph);
27220 onMouseDown : function(e)
27224 this.dragable = true;
27225 this.pinching = false;
27227 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27228 this.dragable = false;
27232 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27233 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27237 onMouseMove : function(e)
27241 if(!this.canvasLoaded){
27245 if (!this.dragable){
27249 var minX = Math.ceil(this.thumbEl.getLeft(true));
27250 var minY = Math.ceil(this.thumbEl.getTop(true));
27252 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27253 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27255 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27256 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27258 x = x - this.mouseX;
27259 y = y - this.mouseY;
27261 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27262 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27264 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27265 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27267 this.previewEl.setLeft(bgX);
27268 this.previewEl.setTop(bgY);
27270 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27271 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27274 onMouseUp : function(e)
27278 this.dragable = false;
27281 onMouseWheel : function(e)
27285 this.startScale = this.scale;
27287 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27289 if(!this.zoomable()){
27290 this.scale = this.startScale;
27299 zoomable : function()
27301 var minScale = this.thumbEl.getWidth() / this.minWidth;
27303 if(this.minWidth < this.minHeight){
27304 minScale = this.thumbEl.getHeight() / this.minHeight;
27307 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27308 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27312 (this.rotate == 0 || this.rotate == 180) &&
27314 width > this.imageEl.OriginWidth ||
27315 height > this.imageEl.OriginHeight ||
27316 (width < this.minWidth && height < this.minHeight)
27324 (this.rotate == 90 || this.rotate == 270) &&
27326 width > this.imageEl.OriginWidth ||
27327 height > this.imageEl.OriginHeight ||
27328 (width < this.minHeight && height < this.minWidth)
27335 !this.isDocument &&
27336 (this.rotate == 0 || this.rotate == 180) &&
27338 width < this.minWidth ||
27339 width > this.imageEl.OriginWidth ||
27340 height < this.minHeight ||
27341 height > this.imageEl.OriginHeight
27348 !this.isDocument &&
27349 (this.rotate == 90 || this.rotate == 270) &&
27351 width < this.minHeight ||
27352 width > this.imageEl.OriginWidth ||
27353 height < this.minWidth ||
27354 height > this.imageEl.OriginHeight
27364 onRotateLeft : function(e)
27366 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27368 var minScale = this.thumbEl.getWidth() / this.minWidth;
27370 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27371 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27373 this.startScale = this.scale;
27375 while (this.getScaleLevel() < minScale){
27377 this.scale = this.scale + 1;
27379 if(!this.zoomable()){
27384 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27385 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27390 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27397 this.scale = this.startScale;
27399 this.onRotateFail();
27404 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27406 if(this.isDocument){
27407 this.setThumbBoxSize();
27408 this.setThumbBoxPosition();
27409 this.setCanvasPosition();
27414 this.fireEvent('rotate', this, 'left');
27418 onRotateRight : function(e)
27420 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27422 var minScale = this.thumbEl.getWidth() / this.minWidth;
27424 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27425 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27427 this.startScale = this.scale;
27429 while (this.getScaleLevel() < minScale){
27431 this.scale = this.scale + 1;
27433 if(!this.zoomable()){
27438 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27439 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27444 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27451 this.scale = this.startScale;
27453 this.onRotateFail();
27458 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27460 if(this.isDocument){
27461 this.setThumbBoxSize();
27462 this.setThumbBoxPosition();
27463 this.setCanvasPosition();
27468 this.fireEvent('rotate', this, 'right');
27471 onRotateFail : function()
27473 this.errorEl.show(true);
27477 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27482 this.previewEl.dom.innerHTML = '';
27484 var canvasEl = document.createElement("canvas");
27486 var contextEl = canvasEl.getContext("2d");
27488 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27489 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27490 var center = this.imageEl.OriginWidth / 2;
27492 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27493 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27494 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27495 center = this.imageEl.OriginHeight / 2;
27498 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27500 contextEl.translate(center, center);
27501 contextEl.rotate(this.rotate * Math.PI / 180);
27503 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27505 this.canvasEl = document.createElement("canvas");
27507 this.contextEl = this.canvasEl.getContext("2d");
27509 switch (this.rotate) {
27512 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27513 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27515 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27520 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27521 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27523 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27524 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);
27528 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27533 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27534 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27536 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27537 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);
27541 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);
27546 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27547 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27549 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27550 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27554 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);
27561 this.previewEl.appendChild(this.canvasEl);
27563 this.setCanvasPosition();
27568 if(!this.canvasLoaded){
27572 var imageCanvas = document.createElement("canvas");
27574 var imageContext = imageCanvas.getContext("2d");
27576 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27577 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27579 var center = imageCanvas.width / 2;
27581 imageContext.translate(center, center);
27583 imageContext.rotate(this.rotate * Math.PI / 180);
27585 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27587 var canvas = document.createElement("canvas");
27589 var context = canvas.getContext("2d");
27591 canvas.width = this.minWidth;
27592 canvas.height = this.minHeight;
27594 switch (this.rotate) {
27597 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27598 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27600 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27601 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27603 var targetWidth = this.minWidth - 2 * x;
27604 var targetHeight = this.minHeight - 2 * y;
27608 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27609 scale = targetWidth / width;
27612 if(x > 0 && y == 0){
27613 scale = targetHeight / height;
27616 if(x > 0 && y > 0){
27617 scale = targetWidth / width;
27619 if(width < height){
27620 scale = targetHeight / height;
27624 context.scale(scale, scale);
27626 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27627 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27629 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27630 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27632 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27637 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27638 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27640 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27641 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27643 var targetWidth = this.minWidth - 2 * x;
27644 var targetHeight = this.minHeight - 2 * y;
27648 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27649 scale = targetWidth / width;
27652 if(x > 0 && y == 0){
27653 scale = targetHeight / height;
27656 if(x > 0 && y > 0){
27657 scale = targetWidth / width;
27659 if(width < height){
27660 scale = targetHeight / height;
27664 context.scale(scale, scale);
27666 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27667 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27669 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27670 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27672 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27674 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27679 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27680 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27682 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27683 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27685 var targetWidth = this.minWidth - 2 * x;
27686 var targetHeight = this.minHeight - 2 * y;
27690 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27691 scale = targetWidth / width;
27694 if(x > 0 && y == 0){
27695 scale = targetHeight / height;
27698 if(x > 0 && y > 0){
27699 scale = targetWidth / width;
27701 if(width < height){
27702 scale = targetHeight / height;
27706 context.scale(scale, scale);
27708 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27709 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27711 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27712 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27714 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27715 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27717 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27722 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27723 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27725 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27726 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27728 var targetWidth = this.minWidth - 2 * x;
27729 var targetHeight = this.minHeight - 2 * y;
27733 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27734 scale = targetWidth / width;
27737 if(x > 0 && y == 0){
27738 scale = targetHeight / height;
27741 if(x > 0 && y > 0){
27742 scale = targetWidth / width;
27744 if(width < height){
27745 scale = targetHeight / height;
27749 context.scale(scale, scale);
27751 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27752 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27754 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27755 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27757 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
27759 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27766 this.cropData = canvas.toDataURL(this.cropType);
27768 if(this.fireEvent('crop', this, this.cropData) !== false){
27769 this.process(this.file, this.cropData);
27776 setThumbBoxSize : function()
27780 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27781 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27782 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27784 this.minWidth = width;
27785 this.minHeight = height;
27787 if(this.rotate == 90 || this.rotate == 270){
27788 this.minWidth = height;
27789 this.minHeight = width;
27794 width = Math.ceil(this.minWidth * height / this.minHeight);
27796 if(this.minWidth > this.minHeight){
27798 height = Math.ceil(this.minHeight * width / this.minWidth);
27801 this.thumbEl.setStyle({
27802 width : width + 'px',
27803 height : height + 'px'
27810 setThumbBoxPosition : function()
27812 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27813 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27815 this.thumbEl.setLeft(x);
27816 this.thumbEl.setTop(y);
27820 baseRotateLevel : function()
27822 this.baseRotate = 1;
27825 typeof(this.exif) != 'undefined' &&
27826 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27827 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27829 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27832 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27836 baseScaleLevel : function()
27840 if(this.isDocument){
27842 if(this.baseRotate == 6 || this.baseRotate == 8){
27844 height = this.thumbEl.getHeight();
27845 this.baseScale = height / this.imageEl.OriginWidth;
27847 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27848 width = this.thumbEl.getWidth();
27849 this.baseScale = width / this.imageEl.OriginHeight;
27855 height = this.thumbEl.getHeight();
27856 this.baseScale = height / this.imageEl.OriginHeight;
27858 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27859 width = this.thumbEl.getWidth();
27860 this.baseScale = width / this.imageEl.OriginWidth;
27866 if(this.baseRotate == 6 || this.baseRotate == 8){
27868 width = this.thumbEl.getHeight();
27869 this.baseScale = width / this.imageEl.OriginHeight;
27871 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27872 height = this.thumbEl.getWidth();
27873 this.baseScale = height / this.imageEl.OriginHeight;
27876 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27877 height = this.thumbEl.getWidth();
27878 this.baseScale = height / this.imageEl.OriginHeight;
27880 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27881 width = this.thumbEl.getHeight();
27882 this.baseScale = width / this.imageEl.OriginWidth;
27889 width = this.thumbEl.getWidth();
27890 this.baseScale = width / this.imageEl.OriginWidth;
27892 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27893 height = this.thumbEl.getHeight();
27894 this.baseScale = height / this.imageEl.OriginHeight;
27897 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27899 height = this.thumbEl.getHeight();
27900 this.baseScale = height / this.imageEl.OriginHeight;
27902 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27903 width = this.thumbEl.getWidth();
27904 this.baseScale = width / this.imageEl.OriginWidth;
27912 getScaleLevel : function()
27914 return this.baseScale * Math.pow(1.1, this.scale);
27917 onTouchStart : function(e)
27919 if(!this.canvasLoaded){
27920 this.beforeSelectFile(e);
27924 var touches = e.browserEvent.touches;
27930 if(touches.length == 1){
27931 this.onMouseDown(e);
27935 if(touches.length != 2){
27941 for(var i = 0, finger; finger = touches[i]; i++){
27942 coords.push(finger.pageX, finger.pageY);
27945 var x = Math.pow(coords[0] - coords[2], 2);
27946 var y = Math.pow(coords[1] - coords[3], 2);
27948 this.startDistance = Math.sqrt(x + y);
27950 this.startScale = this.scale;
27952 this.pinching = true;
27953 this.dragable = false;
27957 onTouchMove : function(e)
27959 if(!this.pinching && !this.dragable){
27963 var touches = e.browserEvent.touches;
27970 this.onMouseMove(e);
27976 for(var i = 0, finger; finger = touches[i]; i++){
27977 coords.push(finger.pageX, finger.pageY);
27980 var x = Math.pow(coords[0] - coords[2], 2);
27981 var y = Math.pow(coords[1] - coords[3], 2);
27983 this.endDistance = Math.sqrt(x + y);
27985 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27987 if(!this.zoomable()){
27988 this.scale = this.startScale;
27996 onTouchEnd : function(e)
27998 this.pinching = false;
27999 this.dragable = false;
28003 process : function(file, crop)
28006 this.maskEl.mask(this.loadingText);
28009 this.xhr = new XMLHttpRequest();
28011 file.xhr = this.xhr;
28013 this.xhr.open(this.method, this.url, true);
28016 "Accept": "application/json",
28017 "Cache-Control": "no-cache",
28018 "X-Requested-With": "XMLHttpRequest"
28021 for (var headerName in headers) {
28022 var headerValue = headers[headerName];
28024 this.xhr.setRequestHeader(headerName, headerValue);
28030 this.xhr.onload = function()
28032 _this.xhrOnLoad(_this.xhr);
28035 this.xhr.onerror = function()
28037 _this.xhrOnError(_this.xhr);
28040 var formData = new FormData();
28042 formData.append('returnHTML', 'NO');
28045 formData.append('crop', crop);
28048 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28049 formData.append(this.paramName, file, file.name);
28052 if(typeof(file.filename) != 'undefined'){
28053 formData.append('filename', file.filename);
28056 if(typeof(file.mimetype) != 'undefined'){
28057 formData.append('mimetype', file.mimetype);
28060 if(this.fireEvent('arrange', this, formData) != false){
28061 this.xhr.send(formData);
28065 xhrOnLoad : function(xhr)
28068 this.maskEl.unmask();
28071 if (xhr.readyState !== 4) {
28072 this.fireEvent('exception', this, xhr);
28076 var response = Roo.decode(xhr.responseText);
28078 if(!response.success){
28079 this.fireEvent('exception', this, xhr);
28083 var response = Roo.decode(xhr.responseText);
28085 this.fireEvent('upload', this, response);
28089 xhrOnError : function()
28092 this.maskEl.unmask();
28095 Roo.log('xhr on error');
28097 var response = Roo.decode(xhr.responseText);
28103 prepare : function(file)
28106 this.maskEl.mask(this.loadingText);
28112 if(typeof(file) === 'string'){
28113 this.loadCanvas(file);
28117 if(!file || !this.urlAPI){
28122 this.cropType = file.type;
28126 if(this.fireEvent('prepare', this, this.file) != false){
28128 var reader = new FileReader();
28130 reader.onload = function (e) {
28131 if (e.target.error) {
28132 Roo.log(e.target.error);
28136 var buffer = e.target.result,
28137 dataView = new DataView(buffer),
28139 maxOffset = dataView.byteLength - 4,
28143 if (dataView.getUint16(0) === 0xffd8) {
28144 while (offset < maxOffset) {
28145 markerBytes = dataView.getUint16(offset);
28147 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28148 markerLength = dataView.getUint16(offset + 2) + 2;
28149 if (offset + markerLength > dataView.byteLength) {
28150 Roo.log('Invalid meta data: Invalid segment size.');
28154 if(markerBytes == 0xffe1){
28155 _this.parseExifData(
28162 offset += markerLength;
28172 var url = _this.urlAPI.createObjectURL(_this.file);
28174 _this.loadCanvas(url);
28179 reader.readAsArrayBuffer(this.file);
28185 parseExifData : function(dataView, offset, length)
28187 var tiffOffset = offset + 10,
28191 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28192 // No Exif data, might be XMP data instead
28196 // Check for the ASCII code for "Exif" (0x45786966):
28197 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28198 // No Exif data, might be XMP data instead
28201 if (tiffOffset + 8 > dataView.byteLength) {
28202 Roo.log('Invalid Exif data: Invalid segment size.');
28205 // Check for the two null bytes:
28206 if (dataView.getUint16(offset + 8) !== 0x0000) {
28207 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28210 // Check the byte alignment:
28211 switch (dataView.getUint16(tiffOffset)) {
28213 littleEndian = true;
28216 littleEndian = false;
28219 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28222 // Check for the TIFF tag marker (0x002A):
28223 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28224 Roo.log('Invalid Exif data: Missing TIFF marker.');
28227 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28228 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28230 this.parseExifTags(
28233 tiffOffset + dirOffset,
28238 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28243 if (dirOffset + 6 > dataView.byteLength) {
28244 Roo.log('Invalid Exif data: Invalid directory offset.');
28247 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28248 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28249 if (dirEndOffset + 4 > dataView.byteLength) {
28250 Roo.log('Invalid Exif data: Invalid directory size.');
28253 for (i = 0; i < tagsNumber; i += 1) {
28257 dirOffset + 2 + 12 * i, // tag offset
28261 // Return the offset to the next directory:
28262 return dataView.getUint32(dirEndOffset, littleEndian);
28265 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28267 var tag = dataView.getUint16(offset, littleEndian);
28269 this.exif[tag] = this.getExifValue(
28273 dataView.getUint16(offset + 2, littleEndian), // tag type
28274 dataView.getUint32(offset + 4, littleEndian), // tag length
28279 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28281 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28290 Roo.log('Invalid Exif data: Invalid tag type.');
28294 tagSize = tagType.size * length;
28295 // Determine if the value is contained in the dataOffset bytes,
28296 // or if the value at the dataOffset is a pointer to the actual data:
28297 dataOffset = tagSize > 4 ?
28298 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28299 if (dataOffset + tagSize > dataView.byteLength) {
28300 Roo.log('Invalid Exif data: Invalid data offset.');
28303 if (length === 1) {
28304 return tagType.getValue(dataView, dataOffset, littleEndian);
28307 for (i = 0; i < length; i += 1) {
28308 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28311 if (tagType.ascii) {
28313 // Concatenate the chars:
28314 for (i = 0; i < values.length; i += 1) {
28316 // Ignore the terminating NULL byte(s):
28317 if (c === '\u0000') {
28329 Roo.apply(Roo.bootstrap.UploadCropbox, {
28331 'Orientation': 0x0112
28335 1: 0, //'top-left',
28337 3: 180, //'bottom-right',
28338 // 4: 'bottom-left',
28340 6: 90, //'right-top',
28341 // 7: 'right-bottom',
28342 8: 270 //'left-bottom'
28346 // byte, 8-bit unsigned int:
28348 getValue: function (dataView, dataOffset) {
28349 return dataView.getUint8(dataOffset);
28353 // ascii, 8-bit byte:
28355 getValue: function (dataView, dataOffset) {
28356 return String.fromCharCode(dataView.getUint8(dataOffset));
28361 // short, 16 bit int:
28363 getValue: function (dataView, dataOffset, littleEndian) {
28364 return dataView.getUint16(dataOffset, littleEndian);
28368 // long, 32 bit int:
28370 getValue: function (dataView, dataOffset, littleEndian) {
28371 return dataView.getUint32(dataOffset, littleEndian);
28375 // rational = two long values, first is numerator, second is denominator:
28377 getValue: function (dataView, dataOffset, littleEndian) {
28378 return dataView.getUint32(dataOffset, littleEndian) /
28379 dataView.getUint32(dataOffset + 4, littleEndian);
28383 // slong, 32 bit signed int:
28385 getValue: function (dataView, dataOffset, littleEndian) {
28386 return dataView.getInt32(dataOffset, littleEndian);
28390 // srational, two slongs, first is numerator, second is denominator:
28392 getValue: function (dataView, dataOffset, littleEndian) {
28393 return dataView.getInt32(dataOffset, littleEndian) /
28394 dataView.getInt32(dataOffset + 4, littleEndian);
28404 cls : 'btn-group roo-upload-cropbox-rotate-left',
28405 action : 'rotate-left',
28409 cls : 'btn btn-default',
28410 html : '<i class="fa fa-undo"></i>'
28416 cls : 'btn-group roo-upload-cropbox-picture',
28417 action : 'picture',
28421 cls : 'btn btn-default',
28422 html : '<i class="fa fa-picture-o"></i>'
28428 cls : 'btn-group roo-upload-cropbox-rotate-right',
28429 action : 'rotate-right',
28433 cls : 'btn btn-default',
28434 html : '<i class="fa fa-repeat"></i>'
28442 cls : 'btn-group roo-upload-cropbox-rotate-left',
28443 action : 'rotate-left',
28447 cls : 'btn btn-default',
28448 html : '<i class="fa fa-undo"></i>'
28454 cls : 'btn-group roo-upload-cropbox-download',
28455 action : 'download',
28459 cls : 'btn btn-default',
28460 html : '<i class="fa fa-download"></i>'
28466 cls : 'btn-group roo-upload-cropbox-crop',
28471 cls : 'btn btn-default',
28472 html : '<i class="fa fa-crop"></i>'
28478 cls : 'btn-group roo-upload-cropbox-trash',
28483 cls : 'btn btn-default',
28484 html : '<i class="fa fa-trash"></i>'
28490 cls : 'btn-group roo-upload-cropbox-rotate-right',
28491 action : 'rotate-right',
28495 cls : 'btn btn-default',
28496 html : '<i class="fa fa-repeat"></i>'
28504 cls : 'btn-group roo-upload-cropbox-rotate-left',
28505 action : 'rotate-left',
28509 cls : 'btn btn-default',
28510 html : '<i class="fa fa-undo"></i>'
28516 cls : 'btn-group roo-upload-cropbox-rotate-right',
28517 action : 'rotate-right',
28521 cls : 'btn btn-default',
28522 html : '<i class="fa fa-repeat"></i>'
28535 * @class Roo.bootstrap.DocumentManager
28536 * @extends Roo.bootstrap.Component
28537 * Bootstrap DocumentManager class
28538 * @cfg {String} paramName default 'imageUpload'
28539 * @cfg {String} toolTipName default 'filename'
28540 * @cfg {String} method default POST
28541 * @cfg {String} url action url
28542 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28543 * @cfg {Boolean} multiple multiple upload default true
28544 * @cfg {Number} thumbSize default 300
28545 * @cfg {String} fieldLabel
28546 * @cfg {Number} labelWidth default 4
28547 * @cfg {String} labelAlign (left|top) default left
28548 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28549 * @cfg {Number} labellg set the width of label (1-12)
28550 * @cfg {Number} labelmd set the width of label (1-12)
28551 * @cfg {Number} labelsm set the width of label (1-12)
28552 * @cfg {Number} labelxs set the width of label (1-12)
28555 * Create a new DocumentManager
28556 * @param {Object} config The config object
28559 Roo.bootstrap.DocumentManager = function(config){
28560 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28563 this.delegates = [];
28568 * Fire when initial the DocumentManager
28569 * @param {Roo.bootstrap.DocumentManager} this
28574 * inspect selected file
28575 * @param {Roo.bootstrap.DocumentManager} this
28576 * @param {File} file
28581 * Fire when xhr load exception
28582 * @param {Roo.bootstrap.DocumentManager} this
28583 * @param {XMLHttpRequest} xhr
28585 "exception" : true,
28587 * @event afterupload
28588 * Fire when xhr load exception
28589 * @param {Roo.bootstrap.DocumentManager} this
28590 * @param {XMLHttpRequest} xhr
28592 "afterupload" : true,
28595 * prepare the form data
28596 * @param {Roo.bootstrap.DocumentManager} this
28597 * @param {Object} formData
28602 * Fire when remove the file
28603 * @param {Roo.bootstrap.DocumentManager} this
28604 * @param {Object} file
28609 * Fire after refresh the file
28610 * @param {Roo.bootstrap.DocumentManager} this
28615 * Fire after click the image
28616 * @param {Roo.bootstrap.DocumentManager} this
28617 * @param {Object} file
28622 * Fire when upload a image and editable set to true
28623 * @param {Roo.bootstrap.DocumentManager} this
28624 * @param {Object} file
28628 * @event beforeselectfile
28629 * Fire before select file
28630 * @param {Roo.bootstrap.DocumentManager} this
28632 "beforeselectfile" : true,
28635 * Fire before process file
28636 * @param {Roo.bootstrap.DocumentManager} this
28637 * @param {Object} file
28641 * @event previewrendered
28642 * Fire when preview rendered
28643 * @param {Roo.bootstrap.DocumentManager} this
28644 * @param {Object} file
28646 "previewrendered" : true
28651 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28660 paramName : 'imageUpload',
28661 toolTipName : 'filename',
28664 labelAlign : 'left',
28674 getAutoCreate : function()
28676 var managerWidget = {
28678 cls : 'roo-document-manager',
28682 cls : 'roo-document-manager-selector',
28687 cls : 'roo-document-manager-uploader',
28691 cls : 'roo-document-manager-upload-btn',
28692 html : '<i class="fa fa-plus"></i>'
28703 cls : 'column col-md-12',
28708 if(this.fieldLabel.length){
28713 cls : 'column col-md-12',
28714 html : this.fieldLabel
28718 cls : 'column col-md-12',
28723 if(this.labelAlign == 'left'){
28728 html : this.fieldLabel
28737 if(this.labelWidth > 12){
28738 content[0].style = "width: " + this.labelWidth + 'px';
28741 if(this.labelWidth < 13 && this.labelmd == 0){
28742 this.labelmd = this.labelWidth;
28745 if(this.labellg > 0){
28746 content[0].cls += ' col-lg-' + this.labellg;
28747 content[1].cls += ' col-lg-' + (12 - this.labellg);
28750 if(this.labelmd > 0){
28751 content[0].cls += ' col-md-' + this.labelmd;
28752 content[1].cls += ' col-md-' + (12 - this.labelmd);
28755 if(this.labelsm > 0){
28756 content[0].cls += ' col-sm-' + this.labelsm;
28757 content[1].cls += ' col-sm-' + (12 - this.labelsm);
28760 if(this.labelxs > 0){
28761 content[0].cls += ' col-xs-' + this.labelxs;
28762 content[1].cls += ' col-xs-' + (12 - this.labelxs);
28770 cls : 'row clearfix',
28778 initEvents : function()
28780 this.managerEl = this.el.select('.roo-document-manager', true).first();
28781 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28783 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28784 this.selectorEl.hide();
28787 this.selectorEl.attr('multiple', 'multiple');
28790 this.selectorEl.on('change', this.onFileSelected, this);
28792 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28793 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28795 this.uploader.on('click', this.onUploaderClick, this);
28797 this.renderProgressDialog();
28801 window.addEventListener("resize", function() { _this.refresh(); } );
28803 this.fireEvent('initial', this);
28806 renderProgressDialog : function()
28810 this.progressDialog = new Roo.bootstrap.Modal({
28811 cls : 'roo-document-manager-progress-dialog',
28812 allow_close : false,
28822 btnclick : function() {
28823 _this.uploadCancel();
28829 this.progressDialog.render(Roo.get(document.body));
28831 this.progress = new Roo.bootstrap.Progress({
28832 cls : 'roo-document-manager-progress',
28837 this.progress.render(this.progressDialog.getChildContainer());
28839 this.progressBar = new Roo.bootstrap.ProgressBar({
28840 cls : 'roo-document-manager-progress-bar',
28843 aria_valuemax : 12,
28847 this.progressBar.render(this.progress.getChildContainer());
28850 onUploaderClick : function(e)
28852 e.preventDefault();
28854 if(this.fireEvent('beforeselectfile', this) != false){
28855 this.selectorEl.dom.click();
28860 onFileSelected : function(e)
28862 e.preventDefault();
28864 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28868 Roo.each(this.selectorEl.dom.files, function(file){
28869 if(this.fireEvent('inspect', this, file) != false){
28870 this.files.push(file);
28880 this.selectorEl.dom.value = '';
28882 if(!this.files || !this.files.length){
28886 if(this.boxes > 0 && this.files.length > this.boxes){
28887 this.files = this.files.slice(0, this.boxes);
28890 this.uploader.show();
28892 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28893 this.uploader.hide();
28902 Roo.each(this.files, function(file){
28904 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28905 var f = this.renderPreview(file);
28910 if(file.type.indexOf('image') != -1){
28911 this.delegates.push(
28913 _this.process(file);
28914 }).createDelegate(this)
28922 _this.process(file);
28923 }).createDelegate(this)
28928 this.files = files;
28930 this.delegates = this.delegates.concat(docs);
28932 if(!this.delegates.length){
28937 this.progressBar.aria_valuemax = this.delegates.length;
28944 arrange : function()
28946 if(!this.delegates.length){
28947 this.progressDialog.hide();
28952 var delegate = this.delegates.shift();
28954 this.progressDialog.show();
28956 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28958 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28963 refresh : function()
28965 this.uploader.show();
28967 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28968 this.uploader.hide();
28971 Roo.isTouch ? this.closable(false) : this.closable(true);
28973 this.fireEvent('refresh', this);
28976 onRemove : function(e, el, o)
28978 e.preventDefault();
28980 this.fireEvent('remove', this, o);
28984 remove : function(o)
28988 Roo.each(this.files, function(file){
28989 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28998 this.files = files;
29005 Roo.each(this.files, function(file){
29010 file.target.remove();
29019 onClick : function(e, el, o)
29021 e.preventDefault();
29023 this.fireEvent('click', this, o);
29027 closable : function(closable)
29029 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29031 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29043 xhrOnLoad : function(xhr)
29045 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29049 if (xhr.readyState !== 4) {
29051 this.fireEvent('exception', this, xhr);
29055 var response = Roo.decode(xhr.responseText);
29057 if(!response.success){
29059 this.fireEvent('exception', this, xhr);
29063 var file = this.renderPreview(response.data);
29065 this.files.push(file);
29069 this.fireEvent('afterupload', this, xhr);
29073 xhrOnError : function(xhr)
29075 Roo.log('xhr on error');
29077 var response = Roo.decode(xhr.responseText);
29084 process : function(file)
29086 if(this.fireEvent('process', this, file) !== false){
29087 if(this.editable && file.type.indexOf('image') != -1){
29088 this.fireEvent('edit', this, file);
29092 this.uploadStart(file, false);
29099 uploadStart : function(file, crop)
29101 this.xhr = new XMLHttpRequest();
29103 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29108 file.xhr = this.xhr;
29110 this.managerEl.createChild({
29112 cls : 'roo-document-manager-loading',
29116 tooltip : file.name,
29117 cls : 'roo-document-manager-thumb',
29118 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29124 this.xhr.open(this.method, this.url, true);
29127 "Accept": "application/json",
29128 "Cache-Control": "no-cache",
29129 "X-Requested-With": "XMLHttpRequest"
29132 for (var headerName in headers) {
29133 var headerValue = headers[headerName];
29135 this.xhr.setRequestHeader(headerName, headerValue);
29141 this.xhr.onload = function()
29143 _this.xhrOnLoad(_this.xhr);
29146 this.xhr.onerror = function()
29148 _this.xhrOnError(_this.xhr);
29151 var formData = new FormData();
29153 formData.append('returnHTML', 'NO');
29156 formData.append('crop', crop);
29159 formData.append(this.paramName, file, file.name);
29166 if(this.fireEvent('prepare', this, formData, options) != false){
29168 if(options.manually){
29172 this.xhr.send(formData);
29176 this.uploadCancel();
29179 uploadCancel : function()
29185 this.delegates = [];
29187 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29194 renderPreview : function(file)
29196 if(typeof(file.target) != 'undefined' && file.target){
29200 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29202 var previewEl = this.managerEl.createChild({
29204 cls : 'roo-document-manager-preview',
29208 tooltip : file[this.toolTipName],
29209 cls : 'roo-document-manager-thumb',
29210 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29215 html : '<i class="fa fa-times-circle"></i>'
29220 var close = previewEl.select('button.close', true).first();
29222 close.on('click', this.onRemove, this, file);
29224 file.target = previewEl;
29226 var image = previewEl.select('img', true).first();
29230 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29232 image.on('click', this.onClick, this, file);
29234 this.fireEvent('previewrendered', this, file);
29240 onPreviewLoad : function(file, image)
29242 if(typeof(file.target) == 'undefined' || !file.target){
29246 var width = image.dom.naturalWidth || image.dom.width;
29247 var height = image.dom.naturalHeight || image.dom.height;
29249 if(width > height){
29250 file.target.addClass('wide');
29254 file.target.addClass('tall');
29259 uploadFromSource : function(file, crop)
29261 this.xhr = new XMLHttpRequest();
29263 this.managerEl.createChild({
29265 cls : 'roo-document-manager-loading',
29269 tooltip : file.name,
29270 cls : 'roo-document-manager-thumb',
29271 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29277 this.xhr.open(this.method, this.url, true);
29280 "Accept": "application/json",
29281 "Cache-Control": "no-cache",
29282 "X-Requested-With": "XMLHttpRequest"
29285 for (var headerName in headers) {
29286 var headerValue = headers[headerName];
29288 this.xhr.setRequestHeader(headerName, headerValue);
29294 this.xhr.onload = function()
29296 _this.xhrOnLoad(_this.xhr);
29299 this.xhr.onerror = function()
29301 _this.xhrOnError(_this.xhr);
29304 var formData = new FormData();
29306 formData.append('returnHTML', 'NO');
29308 formData.append('crop', crop);
29310 if(typeof(file.filename) != 'undefined'){
29311 formData.append('filename', file.filename);
29314 if(typeof(file.mimetype) != 'undefined'){
29315 formData.append('mimetype', file.mimetype);
29320 if(this.fireEvent('prepare', this, formData) != false){
29321 this.xhr.send(formData);
29331 * @class Roo.bootstrap.DocumentViewer
29332 * @extends Roo.bootstrap.Component
29333 * Bootstrap DocumentViewer class
29334 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29335 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29338 * Create a new DocumentViewer
29339 * @param {Object} config The config object
29342 Roo.bootstrap.DocumentViewer = function(config){
29343 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29348 * Fire after initEvent
29349 * @param {Roo.bootstrap.DocumentViewer} this
29355 * @param {Roo.bootstrap.DocumentViewer} this
29360 * Fire after download button
29361 * @param {Roo.bootstrap.DocumentViewer} this
29366 * Fire after trash button
29367 * @param {Roo.bootstrap.DocumentViewer} this
29374 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29376 showDownload : true,
29380 getAutoCreate : function()
29384 cls : 'roo-document-viewer',
29388 cls : 'roo-document-viewer-body',
29392 cls : 'roo-document-viewer-thumb',
29396 cls : 'roo-document-viewer-image'
29404 cls : 'roo-document-viewer-footer',
29407 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29411 cls : 'btn-group roo-document-viewer-download',
29415 cls : 'btn btn-default',
29416 html : '<i class="fa fa-download"></i>'
29422 cls : 'btn-group roo-document-viewer-trash',
29426 cls : 'btn btn-default',
29427 html : '<i class="fa fa-trash"></i>'
29440 initEvents : function()
29442 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29443 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29445 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29446 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29448 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29449 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29451 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29452 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29454 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29455 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29457 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29458 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29460 this.bodyEl.on('click', this.onClick, this);
29461 this.downloadBtn.on('click', this.onDownload, this);
29462 this.trashBtn.on('click', this.onTrash, this);
29464 this.downloadBtn.hide();
29465 this.trashBtn.hide();
29467 if(this.showDownload){
29468 this.downloadBtn.show();
29471 if(this.showTrash){
29472 this.trashBtn.show();
29475 if(!this.showDownload && !this.showTrash) {
29476 this.footerEl.hide();
29481 initial : function()
29483 this.fireEvent('initial', this);
29487 onClick : function(e)
29489 e.preventDefault();
29491 this.fireEvent('click', this);
29494 onDownload : function(e)
29496 e.preventDefault();
29498 this.fireEvent('download', this);
29501 onTrash : function(e)
29503 e.preventDefault();
29505 this.fireEvent('trash', this);
29517 * @class Roo.bootstrap.NavProgressBar
29518 * @extends Roo.bootstrap.Component
29519 * Bootstrap NavProgressBar class
29522 * Create a new nav progress bar
29523 * @param {Object} config The config object
29526 Roo.bootstrap.NavProgressBar = function(config){
29527 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29529 this.bullets = this.bullets || [];
29531 // Roo.bootstrap.NavProgressBar.register(this);
29535 * Fires when the active item changes
29536 * @param {Roo.bootstrap.NavProgressBar} this
29537 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29538 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29545 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29550 getAutoCreate : function()
29552 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29556 cls : 'roo-navigation-bar-group',
29560 cls : 'roo-navigation-top-bar'
29564 cls : 'roo-navigation-bullets-bar',
29568 cls : 'roo-navigation-bar'
29575 cls : 'roo-navigation-bottom-bar'
29585 initEvents: function()
29590 onRender : function(ct, position)
29592 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29594 if(this.bullets.length){
29595 Roo.each(this.bullets, function(b){
29604 addItem : function(cfg)
29606 var item = new Roo.bootstrap.NavProgressItem(cfg);
29608 item.parentId = this.id;
29609 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29612 var top = new Roo.bootstrap.Element({
29614 cls : 'roo-navigation-bar-text'
29617 var bottom = new Roo.bootstrap.Element({
29619 cls : 'roo-navigation-bar-text'
29622 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29623 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29625 var topText = new Roo.bootstrap.Element({
29627 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29630 var bottomText = new Roo.bootstrap.Element({
29632 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29635 topText.onRender(top.el, null);
29636 bottomText.onRender(bottom.el, null);
29639 item.bottomEl = bottom;
29642 this.barItems.push(item);
29647 getActive : function()
29649 var active = false;
29651 Roo.each(this.barItems, function(v){
29653 if (!v.isActive()) {
29665 setActiveItem : function(item)
29669 Roo.each(this.barItems, function(v){
29670 if (v.rid == item.rid) {
29674 if (v.isActive()) {
29675 v.setActive(false);
29680 item.setActive(true);
29682 this.fireEvent('changed', this, item, prev);
29685 getBarItem: function(rid)
29689 Roo.each(this.barItems, function(e) {
29690 if (e.rid != rid) {
29701 indexOfItem : function(item)
29705 Roo.each(this.barItems, function(v, i){
29707 if (v.rid != item.rid) {
29718 setActiveNext : function()
29720 var i = this.indexOfItem(this.getActive());
29722 if (i > this.barItems.length) {
29726 this.setActiveItem(this.barItems[i+1]);
29729 setActivePrev : function()
29731 var i = this.indexOfItem(this.getActive());
29737 this.setActiveItem(this.barItems[i-1]);
29740 format : function()
29742 if(!this.barItems.length){
29746 var width = 100 / this.barItems.length;
29748 Roo.each(this.barItems, function(i){
29749 i.el.setStyle('width', width + '%');
29750 i.topEl.el.setStyle('width', width + '%');
29751 i.bottomEl.el.setStyle('width', width + '%');
29760 * Nav Progress Item
29765 * @class Roo.bootstrap.NavProgressItem
29766 * @extends Roo.bootstrap.Component
29767 * Bootstrap NavProgressItem class
29768 * @cfg {String} rid the reference id
29769 * @cfg {Boolean} active (true|false) Is item active default false
29770 * @cfg {Boolean} disabled (true|false) Is item active default false
29771 * @cfg {String} html
29772 * @cfg {String} position (top|bottom) text position default bottom
29773 * @cfg {String} icon show icon instead of number
29776 * Create a new NavProgressItem
29777 * @param {Object} config The config object
29779 Roo.bootstrap.NavProgressItem = function(config){
29780 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29785 * The raw click event for the entire grid.
29786 * @param {Roo.bootstrap.NavProgressItem} this
29787 * @param {Roo.EventObject} e
29794 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29800 position : 'bottom',
29803 getAutoCreate : function()
29805 var iconCls = 'roo-navigation-bar-item-icon';
29807 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29811 cls: 'roo-navigation-bar-item',
29821 cfg.cls += ' active';
29824 cfg.cls += ' disabled';
29830 disable : function()
29832 this.setDisabled(true);
29835 enable : function()
29837 this.setDisabled(false);
29840 initEvents: function()
29842 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29844 this.iconEl.on('click', this.onClick, this);
29847 onClick : function(e)
29849 e.preventDefault();
29855 if(this.fireEvent('click', this, e) === false){
29859 this.parent().setActiveItem(this);
29862 isActive: function ()
29864 return this.active;
29867 setActive : function(state)
29869 if(this.active == state){
29873 this.active = state;
29876 this.el.addClass('active');
29880 this.el.removeClass('active');
29885 setDisabled : function(state)
29887 if(this.disabled == state){
29891 this.disabled = state;
29894 this.el.addClass('disabled');
29898 this.el.removeClass('disabled');
29901 tooltipEl : function()
29903 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29916 * @class Roo.bootstrap.FieldLabel
29917 * @extends Roo.bootstrap.Component
29918 * Bootstrap FieldLabel class
29919 * @cfg {String} html contents of the element
29920 * @cfg {String} tag tag of the element default label
29921 * @cfg {String} cls class of the element
29922 * @cfg {String} target label target
29923 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29924 * @cfg {String} invalidClass default "text-warning"
29925 * @cfg {String} validClass default "text-success"
29926 * @cfg {String} iconTooltip default "This field is required"
29927 * @cfg {String} indicatorpos (left|right) default left
29930 * Create a new FieldLabel
29931 * @param {Object} config The config object
29934 Roo.bootstrap.FieldLabel = function(config){
29935 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29940 * Fires after the field has been marked as invalid.
29941 * @param {Roo.form.FieldLabel} this
29942 * @param {String} msg The validation message
29947 * Fires after the field has been validated with no errors.
29948 * @param {Roo.form.FieldLabel} this
29954 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29961 invalidClass : 'has-warning',
29962 validClass : 'has-success',
29963 iconTooltip : 'This field is required',
29964 indicatorpos : 'left',
29966 getAutoCreate : function(){
29970 cls : 'roo-bootstrap-field-label ' + this.cls,
29975 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
29976 tooltip : this.iconTooltip
29985 if(this.indicatorpos == 'right'){
29988 cls : 'roo-bootstrap-field-label ' + this.cls,
29997 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
29998 tooltip : this.iconTooltip
30007 initEvents: function()
30009 Roo.bootstrap.Element.superclass.initEvents.call(this);
30011 this.indicator = this.indicatorEl();
30013 if(this.indicator){
30014 this.indicator.removeClass('visible');
30015 this.indicator.addClass('invisible');
30018 Roo.bootstrap.FieldLabel.register(this);
30021 indicatorEl : function()
30023 var indicator = this.el.select('i.roo-required-indicator',true).first();
30034 * Mark this field as valid
30036 markValid : function()
30038 if(this.indicator){
30039 this.indicator.removeClass('visible');
30040 this.indicator.addClass('invisible');
30043 this.el.removeClass(this.invalidClass);
30045 this.el.addClass(this.validClass);
30047 this.fireEvent('valid', this);
30051 * Mark this field as invalid
30052 * @param {String} msg The validation message
30054 markInvalid : function(msg)
30056 if(this.indicator){
30057 this.indicator.removeClass('invisible');
30058 this.indicator.addClass('visible');
30061 this.el.removeClass(this.validClass);
30063 this.el.addClass(this.invalidClass);
30065 this.fireEvent('invalid', this, msg);
30071 Roo.apply(Roo.bootstrap.FieldLabel, {
30076 * register a FieldLabel Group
30077 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30079 register : function(label)
30081 if(this.groups.hasOwnProperty(label.target)){
30085 this.groups[label.target] = label;
30089 * fetch a FieldLabel Group based on the target
30090 * @param {string} target
30091 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30093 get: function(target) {
30094 if (typeof(this.groups[target]) == 'undefined') {
30098 return this.groups[target] ;
30107 * page DateSplitField.
30113 * @class Roo.bootstrap.DateSplitField
30114 * @extends Roo.bootstrap.Component
30115 * Bootstrap DateSplitField class
30116 * @cfg {string} fieldLabel - the label associated
30117 * @cfg {Number} labelWidth set the width of label (0-12)
30118 * @cfg {String} labelAlign (top|left)
30119 * @cfg {Boolean} dayAllowBlank (true|false) default false
30120 * @cfg {Boolean} monthAllowBlank (true|false) default false
30121 * @cfg {Boolean} yearAllowBlank (true|false) default false
30122 * @cfg {string} dayPlaceholder
30123 * @cfg {string} monthPlaceholder
30124 * @cfg {string} yearPlaceholder
30125 * @cfg {string} dayFormat default 'd'
30126 * @cfg {string} monthFormat default 'm'
30127 * @cfg {string} yearFormat default 'Y'
30128 * @cfg {Number} labellg set the width of label (1-12)
30129 * @cfg {Number} labelmd set the width of label (1-12)
30130 * @cfg {Number} labelsm set the width of label (1-12)
30131 * @cfg {Number} labelxs set the width of label (1-12)
30135 * Create a new DateSplitField
30136 * @param {Object} config The config object
30139 Roo.bootstrap.DateSplitField = function(config){
30140 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30146 * getting the data of years
30147 * @param {Roo.bootstrap.DateSplitField} this
30148 * @param {Object} years
30153 * getting the data of days
30154 * @param {Roo.bootstrap.DateSplitField} this
30155 * @param {Object} days
30160 * Fires after the field has been marked as invalid.
30161 * @param {Roo.form.Field} this
30162 * @param {String} msg The validation message
30167 * Fires after the field has been validated with no errors.
30168 * @param {Roo.form.Field} this
30174 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30177 labelAlign : 'top',
30179 dayAllowBlank : false,
30180 monthAllowBlank : false,
30181 yearAllowBlank : false,
30182 dayPlaceholder : '',
30183 monthPlaceholder : '',
30184 yearPlaceholder : '',
30188 isFormField : true,
30194 getAutoCreate : function()
30198 cls : 'row roo-date-split-field-group',
30203 cls : 'form-hidden-field roo-date-split-field-group-value',
30209 var labelCls = 'col-md-12';
30210 var contentCls = 'col-md-4';
30212 if(this.fieldLabel){
30216 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30220 html : this.fieldLabel
30225 if(this.labelAlign == 'left'){
30227 if(this.labelWidth > 12){
30228 label.style = "width: " + this.labelWidth + 'px';
30231 if(this.labelWidth < 13 && this.labelmd == 0){
30232 this.labelmd = this.labelWidth;
30235 if(this.labellg > 0){
30236 labelCls = ' col-lg-' + this.labellg;
30237 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30240 if(this.labelmd > 0){
30241 labelCls = ' col-md-' + this.labelmd;
30242 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30245 if(this.labelsm > 0){
30246 labelCls = ' col-sm-' + this.labelsm;
30247 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30250 if(this.labelxs > 0){
30251 labelCls = ' col-xs-' + this.labelxs;
30252 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30256 label.cls += ' ' + labelCls;
30258 cfg.cn.push(label);
30261 Roo.each(['day', 'month', 'year'], function(t){
30264 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30271 inputEl: function ()
30273 return this.el.select('.roo-date-split-field-group-value', true).first();
30276 onRender : function(ct, position)
30280 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30282 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30284 this.dayField = new Roo.bootstrap.ComboBox({
30285 allowBlank : this.dayAllowBlank,
30286 alwaysQuery : true,
30287 displayField : 'value',
30290 forceSelection : true,
30292 placeholder : this.dayPlaceholder,
30293 selectOnFocus : true,
30294 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30295 triggerAction : 'all',
30297 valueField : 'value',
30298 store : new Roo.data.SimpleStore({
30299 data : (function() {
30301 _this.fireEvent('days', _this, days);
30304 fields : [ 'value' ]
30307 select : function (_self, record, index)
30309 _this.setValue(_this.getValue());
30314 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30316 this.monthField = new Roo.bootstrap.MonthField({
30317 after : '<i class=\"fa fa-calendar\"></i>',
30318 allowBlank : this.monthAllowBlank,
30319 placeholder : this.monthPlaceholder,
30322 render : function (_self)
30324 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30325 e.preventDefault();
30329 select : function (_self, oldvalue, newvalue)
30331 _this.setValue(_this.getValue());
30336 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30338 this.yearField = new Roo.bootstrap.ComboBox({
30339 allowBlank : this.yearAllowBlank,
30340 alwaysQuery : true,
30341 displayField : 'value',
30344 forceSelection : true,
30346 placeholder : this.yearPlaceholder,
30347 selectOnFocus : true,
30348 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30349 triggerAction : 'all',
30351 valueField : 'value',
30352 store : new Roo.data.SimpleStore({
30353 data : (function() {
30355 _this.fireEvent('years', _this, years);
30358 fields : [ 'value' ]
30361 select : function (_self, record, index)
30363 _this.setValue(_this.getValue());
30368 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30371 setValue : function(v, format)
30373 this.inputEl.dom.value = v;
30375 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30377 var d = Date.parseDate(v, f);
30384 this.setDay(d.format(this.dayFormat));
30385 this.setMonth(d.format(this.monthFormat));
30386 this.setYear(d.format(this.yearFormat));
30393 setDay : function(v)
30395 this.dayField.setValue(v);
30396 this.inputEl.dom.value = this.getValue();
30401 setMonth : function(v)
30403 this.monthField.setValue(v, true);
30404 this.inputEl.dom.value = this.getValue();
30409 setYear : function(v)
30411 this.yearField.setValue(v);
30412 this.inputEl.dom.value = this.getValue();
30417 getDay : function()
30419 return this.dayField.getValue();
30422 getMonth : function()
30424 return this.monthField.getValue();
30427 getYear : function()
30429 return this.yearField.getValue();
30432 getValue : function()
30434 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30436 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30446 this.inputEl.dom.value = '';
30451 validate : function()
30453 var d = this.dayField.validate();
30454 var m = this.monthField.validate();
30455 var y = this.yearField.validate();
30460 (!this.dayAllowBlank && !d) ||
30461 (!this.monthAllowBlank && !m) ||
30462 (!this.yearAllowBlank && !y)
30467 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30476 this.markInvalid();
30481 markValid : function()
30484 var label = this.el.select('label', true).first();
30485 var icon = this.el.select('i.fa-star', true).first();
30491 this.fireEvent('valid', this);
30495 * Mark this field as invalid
30496 * @param {String} msg The validation message
30498 markInvalid : function(msg)
30501 var label = this.el.select('label', true).first();
30502 var icon = this.el.select('i.fa-star', true).first();
30504 if(label && !icon){
30505 this.el.select('.roo-date-split-field-label', true).createChild({
30507 cls : 'text-danger fa fa-lg fa-star',
30508 tooltip : 'This field is required',
30509 style : 'margin-right:5px;'
30513 this.fireEvent('invalid', this, msg);
30516 clearInvalid : function()
30518 var label = this.el.select('label', true).first();
30519 var icon = this.el.select('i.fa-star', true).first();
30525 this.fireEvent('valid', this);
30528 getName: function()
30538 * http://masonry.desandro.com
30540 * The idea is to render all the bricks based on vertical width...
30542 * The original code extends 'outlayer' - we might need to use that....
30548 * @class Roo.bootstrap.LayoutMasonry
30549 * @extends Roo.bootstrap.Component
30550 * Bootstrap Layout Masonry class
30553 * Create a new Element
30554 * @param {Object} config The config object
30557 Roo.bootstrap.LayoutMasonry = function(config){
30559 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30563 Roo.bootstrap.LayoutMasonry.register(this);
30569 * Fire after layout the items
30570 * @param {Roo.bootstrap.LayoutMasonry} this
30571 * @param {Roo.EventObject} e
30578 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30581 * @cfg {Boolean} isLayoutInstant = no animation?
30583 isLayoutInstant : false, // needed?
30586 * @cfg {Number} boxWidth width of the columns
30591 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30596 * @cfg {Number} padWidth padding below box..
30601 * @cfg {Number} gutter gutter width..
30606 * @cfg {Number} maxCols maximum number of columns
30612 * @cfg {Boolean} isAutoInitial defalut true
30614 isAutoInitial : true,
30619 * @cfg {Boolean} isHorizontal defalut false
30621 isHorizontal : false,
30623 currentSize : null,
30629 bricks: null, //CompositeElement
30633 _isLayoutInited : false,
30635 // isAlternative : false, // only use for vertical layout...
30638 * @cfg {Number} alternativePadWidth padding below box..
30640 alternativePadWidth : 50,
30642 selectedBrick : [],
30644 getAutoCreate : function(){
30646 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30650 cls: 'blog-masonary-wrapper ' + this.cls,
30652 cls : 'mas-boxes masonary'
30659 getChildContainer: function( )
30661 if (this.boxesEl) {
30662 return this.boxesEl;
30665 this.boxesEl = this.el.select('.mas-boxes').first();
30667 return this.boxesEl;
30671 initEvents : function()
30675 if(this.isAutoInitial){
30676 Roo.log('hook children rendered');
30677 this.on('childrenrendered', function() {
30678 Roo.log('children rendered');
30684 initial : function()
30686 this.selectedBrick = [];
30688 this.currentSize = this.el.getBox(true);
30690 Roo.EventManager.onWindowResize(this.resize, this);
30692 if(!this.isAutoInitial){
30700 //this.layout.defer(500,this);
30704 resize : function()
30706 var cs = this.el.getBox(true);
30709 this.currentSize.width == cs.width &&
30710 this.currentSize.x == cs.x &&
30711 this.currentSize.height == cs.height &&
30712 this.currentSize.y == cs.y
30714 Roo.log("no change in with or X or Y");
30718 this.currentSize = cs;
30724 layout : function()
30726 this._resetLayout();
30728 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
30730 this.layoutItems( isInstant );
30732 this._isLayoutInited = true;
30734 this.fireEvent('layout', this);
30738 _resetLayout : function()
30740 if(this.isHorizontal){
30741 this.horizontalMeasureColumns();
30745 this.verticalMeasureColumns();
30749 verticalMeasureColumns : function()
30751 this.getContainerWidth();
30753 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30754 // this.colWidth = Math.floor(this.containerWidth * 0.8);
30758 var boxWidth = this.boxWidth + this.padWidth;
30760 if(this.containerWidth < this.boxWidth){
30761 boxWidth = this.containerWidth
30764 var containerWidth = this.containerWidth;
30766 var cols = Math.floor(containerWidth / boxWidth);
30768 this.cols = Math.max( cols, 1 );
30770 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
30772 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
30774 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
30776 this.colWidth = boxWidth + avail - this.padWidth;
30778 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
30779 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
30782 horizontalMeasureColumns : function()
30784 this.getContainerWidth();
30786 var boxWidth = this.boxWidth;
30788 if(this.containerWidth < boxWidth){
30789 boxWidth = this.containerWidth;
30792 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
30794 this.el.setHeight(boxWidth);
30798 getContainerWidth : function()
30800 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
30803 layoutItems : function( isInstant )
30805 Roo.log(this.bricks);
30807 var items = Roo.apply([], this.bricks);
30809 if(this.isHorizontal){
30810 this._horizontalLayoutItems( items , isInstant );
30814 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
30815 // this._verticalAlternativeLayoutItems( items , isInstant );
30819 this._verticalLayoutItems( items , isInstant );
30823 _verticalLayoutItems : function ( items , isInstant)
30825 if ( !items || !items.length ) {
30830 ['xs', 'xs', 'xs', 'tall'],
30831 ['xs', 'xs', 'tall'],
30832 ['xs', 'xs', 'sm'],
30833 ['xs', 'xs', 'xs'],
30839 ['sm', 'xs', 'xs'],
30843 ['tall', 'xs', 'xs', 'xs'],
30844 ['tall', 'xs', 'xs'],
30856 Roo.each(items, function(item, k){
30858 switch (item.size) {
30859 // these layouts take up a full box,
30870 boxes.push([item]);
30893 var filterPattern = function(box, length)
30901 var pattern = box.slice(0, length);
30905 Roo.each(pattern, function(i){
30906 format.push(i.size);
30909 Roo.each(standard, function(s){
30911 if(String(s) != String(format)){
30920 if(!match && length == 1){
30925 filterPattern(box, length - 1);
30929 queue.push(pattern);
30931 box = box.slice(length, box.length);
30933 filterPattern(box, 4);
30939 Roo.each(boxes, function(box, k){
30945 if(box.length == 1){
30950 filterPattern(box, 4);
30954 this._processVerticalLayoutQueue( queue, isInstant );
30958 // _verticalAlternativeLayoutItems : function( items , isInstant )
30960 // if ( !items || !items.length ) {
30964 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30968 _horizontalLayoutItems : function ( items , isInstant)
30970 if ( !items || !items.length || items.length < 3) {
30976 var eItems = items.slice(0, 3);
30978 items = items.slice(3, items.length);
30981 ['xs', 'xs', 'xs', 'wide'],
30982 ['xs', 'xs', 'wide'],
30983 ['xs', 'xs', 'sm'],
30984 ['xs', 'xs', 'xs'],
30990 ['sm', 'xs', 'xs'],
30994 ['wide', 'xs', 'xs', 'xs'],
30995 ['wide', 'xs', 'xs'],
31008 Roo.each(items, function(item, k){
31010 switch (item.size) {
31021 boxes.push([item]);
31045 var filterPattern = function(box, length)
31053 var pattern = box.slice(0, length);
31057 Roo.each(pattern, function(i){
31058 format.push(i.size);
31061 Roo.each(standard, function(s){
31063 if(String(s) != String(format)){
31072 if(!match && length == 1){
31077 filterPattern(box, length - 1);
31081 queue.push(pattern);
31083 box = box.slice(length, box.length);
31085 filterPattern(box, 4);
31091 Roo.each(boxes, function(box, k){
31097 if(box.length == 1){
31102 filterPattern(box, 4);
31109 var pos = this.el.getBox(true);
31113 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31115 var hit_end = false;
31117 Roo.each(queue, function(box){
31121 Roo.each(box, function(b){
31123 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31133 Roo.each(box, function(b){
31135 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31138 mx = Math.max(mx, b.x);
31142 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31146 Roo.each(box, function(b){
31148 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31162 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31165 /** Sets position of item in DOM
31166 * @param {Element} item
31167 * @param {Number} x - horizontal position
31168 * @param {Number} y - vertical position
31169 * @param {Boolean} isInstant - disables transitions
31171 _processVerticalLayoutQueue : function( queue, isInstant )
31173 var pos = this.el.getBox(true);
31178 for (var i = 0; i < this.cols; i++){
31182 Roo.each(queue, function(box, k){
31184 var col = k % this.cols;
31186 Roo.each(box, function(b,kk){
31188 b.el.position('absolute');
31190 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31191 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31193 if(b.size == 'md-left' || b.size == 'md-right'){
31194 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31195 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31198 b.el.setWidth(width);
31199 b.el.setHeight(height);
31201 b.el.select('iframe',true).setSize(width,height);
31205 for (var i = 0; i < this.cols; i++){
31207 if(maxY[i] < maxY[col]){
31212 col = Math.min(col, i);
31216 x = pos.x + col * (this.colWidth + this.padWidth);
31220 var positions = [];
31222 switch (box.length){
31224 positions = this.getVerticalOneBoxColPositions(x, y, box);
31227 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31230 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31233 positions = this.getVerticalFourBoxColPositions(x, y, box);
31239 Roo.each(box, function(b,kk){
31241 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31243 var sz = b.el.getSize();
31245 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31253 for (var i = 0; i < this.cols; i++){
31254 mY = Math.max(mY, maxY[i]);
31257 this.el.setHeight(mY - pos.y);
31261 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31263 // var pos = this.el.getBox(true);
31266 // var maxX = pos.right;
31268 // var maxHeight = 0;
31270 // Roo.each(items, function(item, k){
31274 // item.el.position('absolute');
31276 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31278 // item.el.setWidth(width);
31280 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31282 // item.el.setHeight(height);
31285 // item.el.setXY([x, y], isInstant ? false : true);
31287 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31290 // y = y + height + this.alternativePadWidth;
31292 // maxHeight = maxHeight + height + this.alternativePadWidth;
31296 // this.el.setHeight(maxHeight);
31300 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31302 var pos = this.el.getBox(true);
31307 var maxX = pos.right;
31309 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31311 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31313 Roo.each(queue, function(box, k){
31315 Roo.each(box, function(b, kk){
31317 b.el.position('absolute');
31319 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31320 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31322 if(b.size == 'md-left' || b.size == 'md-right'){
31323 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31324 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31327 b.el.setWidth(width);
31328 b.el.setHeight(height);
31336 var positions = [];
31338 switch (box.length){
31340 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31343 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31346 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31349 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31355 Roo.each(box, function(b,kk){
31357 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31359 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31367 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31369 Roo.each(eItems, function(b,k){
31371 b.size = (k == 0) ? 'sm' : 'xs';
31372 b.x = (k == 0) ? 2 : 1;
31373 b.y = (k == 0) ? 2 : 1;
31375 b.el.position('absolute');
31377 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31379 b.el.setWidth(width);
31381 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31383 b.el.setHeight(height);
31387 var positions = [];
31390 x : maxX - this.unitWidth * 2 - this.gutter,
31395 x : maxX - this.unitWidth,
31396 y : minY + (this.unitWidth + this.gutter) * 2
31400 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31404 Roo.each(eItems, function(b,k){
31406 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31412 getVerticalOneBoxColPositions : function(x, y, box)
31416 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31418 if(box[0].size == 'md-left'){
31422 if(box[0].size == 'md-right'){
31427 x : x + (this.unitWidth + this.gutter) * rand,
31434 getVerticalTwoBoxColPositions : function(x, y, box)
31438 if(box[0].size == 'xs'){
31442 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31446 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31460 x : x + (this.unitWidth + this.gutter) * 2,
31461 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31468 getVerticalThreeBoxColPositions : function(x, y, box)
31472 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31480 x : x + (this.unitWidth + this.gutter) * 1,
31485 x : x + (this.unitWidth + this.gutter) * 2,
31493 if(box[0].size == 'xs' && box[1].size == 'xs'){
31502 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31506 x : x + (this.unitWidth + this.gutter) * 1,
31520 x : x + (this.unitWidth + this.gutter) * 2,
31525 x : x + (this.unitWidth + this.gutter) * 2,
31526 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31533 getVerticalFourBoxColPositions : function(x, y, box)
31537 if(box[0].size == 'xs'){
31546 y : y + (this.unitHeight + this.gutter) * 1
31551 y : y + (this.unitHeight + this.gutter) * 2
31555 x : x + (this.unitWidth + this.gutter) * 1,
31569 x : x + (this.unitWidth + this.gutter) * 2,
31574 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31575 y : y + (this.unitHeight + this.gutter) * 1
31579 x : x + (this.unitWidth + this.gutter) * 2,
31580 y : y + (this.unitWidth + this.gutter) * 2
31587 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31591 if(box[0].size == 'md-left'){
31593 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31600 if(box[0].size == 'md-right'){
31602 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31603 y : minY + (this.unitWidth + this.gutter) * 1
31609 var rand = Math.floor(Math.random() * (4 - box[0].y));
31612 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31613 y : minY + (this.unitWidth + this.gutter) * rand
31620 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31624 if(box[0].size == 'xs'){
31627 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31632 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31633 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31641 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31646 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31647 y : minY + (this.unitWidth + this.gutter) * 2
31654 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31658 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31661 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31666 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31667 y : minY + (this.unitWidth + this.gutter) * 1
31671 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31672 y : minY + (this.unitWidth + this.gutter) * 2
31679 if(box[0].size == 'xs' && box[1].size == 'xs'){
31682 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31687 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31692 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31693 y : minY + (this.unitWidth + this.gutter) * 1
31701 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31706 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31707 y : minY + (this.unitWidth + this.gutter) * 2
31711 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31712 y : minY + (this.unitWidth + this.gutter) * 2
31719 getHorizontalFourBoxColPositions : function(maxX, minY, box)
31723 if(box[0].size == 'xs'){
31726 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31731 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31736 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),
31741 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
31742 y : minY + (this.unitWidth + this.gutter) * 1
31750 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31755 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31756 y : minY + (this.unitWidth + this.gutter) * 2
31760 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31761 y : minY + (this.unitWidth + this.gutter) * 2
31765 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),
31766 y : minY + (this.unitWidth + this.gutter) * 2
31774 * remove a Masonry Brick
31775 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
31777 removeBrick : function(brick_id)
31783 for (var i = 0; i<this.bricks.length; i++) {
31784 if (this.bricks[i].id == brick_id) {
31785 this.bricks.splice(i,1);
31786 this.el.dom.removeChild(Roo.get(brick_id).dom);
31793 * adds a Masonry Brick
31794 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31796 addBrick : function(cfg)
31798 var cn = new Roo.bootstrap.MasonryBrick(cfg);
31799 //this.register(cn);
31800 cn.parentId = this.id;
31801 cn.onRender(this.el, null);
31806 * register a Masonry Brick
31807 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
31810 register : function(brick)
31812 this.bricks.push(brick);
31813 brick.masonryId = this.id;
31817 * clear all the Masonry Brick
31819 clearAll : function()
31822 //this.getChildContainer().dom.innerHTML = "";
31823 this.el.dom.innerHTML = '';
31826 getSelected : function()
31828 if (!this.selectedBrick) {
31832 return this.selectedBrick;
31836 Roo.apply(Roo.bootstrap.LayoutMasonry, {
31840 * register a Masonry Layout
31841 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
31844 register : function(layout)
31846 this.groups[layout.id] = layout;
31849 * fetch a Masonry Layout based on the masonry layout ID
31850 * @param {string} the masonry layout to add
31851 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
31854 get: function(layout_id) {
31855 if (typeof(this.groups[layout_id]) == 'undefined') {
31858 return this.groups[layout_id] ;
31870 * http://masonry.desandro.com
31872 * The idea is to render all the bricks based on vertical width...
31874 * The original code extends 'outlayer' - we might need to use that....
31880 * @class Roo.bootstrap.LayoutMasonryAuto
31881 * @extends Roo.bootstrap.Component
31882 * Bootstrap Layout Masonry class
31885 * Create a new Element
31886 * @param {Object} config The config object
31889 Roo.bootstrap.LayoutMasonryAuto = function(config){
31890 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
31893 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
31896 * @cfg {Boolean} isFitWidth - resize the width..
31898 isFitWidth : false, // options..
31900 * @cfg {Boolean} isOriginLeft = left align?
31902 isOriginLeft : true,
31904 * @cfg {Boolean} isOriginTop = top align?
31906 isOriginTop : false,
31908 * @cfg {Boolean} isLayoutInstant = no animation?
31910 isLayoutInstant : false, // needed?
31912 * @cfg {Boolean} isResizingContainer = not sure if this is used..
31914 isResizingContainer : true,
31916 * @cfg {Number} columnWidth width of the columns
31922 * @cfg {Number} maxCols maximum number of columns
31927 * @cfg {Number} padHeight padding below box..
31933 * @cfg {Boolean} isAutoInitial defalut true
31936 isAutoInitial : true,
31942 initialColumnWidth : 0,
31943 currentSize : null,
31945 colYs : null, // array.
31952 bricks: null, //CompositeElement
31953 cols : 0, // array?
31954 // element : null, // wrapped now this.el
31955 _isLayoutInited : null,
31958 getAutoCreate : function(){
31962 cls: 'blog-masonary-wrapper ' + this.cls,
31964 cls : 'mas-boxes masonary'
31971 getChildContainer: function( )
31973 if (this.boxesEl) {
31974 return this.boxesEl;
31977 this.boxesEl = this.el.select('.mas-boxes').first();
31979 return this.boxesEl;
31983 initEvents : function()
31987 if(this.isAutoInitial){
31988 Roo.log('hook children rendered');
31989 this.on('childrenrendered', function() {
31990 Roo.log('children rendered');
31997 initial : function()
31999 this.reloadItems();
32001 this.currentSize = this.el.getBox(true);
32003 /// was window resize... - let's see if this works..
32004 Roo.EventManager.onWindowResize(this.resize, this);
32006 if(!this.isAutoInitial){
32011 this.layout.defer(500,this);
32014 reloadItems: function()
32016 this.bricks = this.el.select('.masonry-brick', true);
32018 this.bricks.each(function(b) {
32019 //Roo.log(b.getSize());
32020 if (!b.attr('originalwidth')) {
32021 b.attr('originalwidth', b.getSize().width);
32026 Roo.log(this.bricks.elements.length);
32029 resize : function()
32032 var cs = this.el.getBox(true);
32034 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32035 Roo.log("no change in with or X");
32038 this.currentSize = cs;
32042 layout : function()
32045 this._resetLayout();
32046 //this._manageStamps();
32048 // don't animate first layout
32049 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32050 this.layoutItems( isInstant );
32052 // flag for initalized
32053 this._isLayoutInited = true;
32056 layoutItems : function( isInstant )
32058 //var items = this._getItemsForLayout( this.items );
32059 // original code supports filtering layout items.. we just ignore it..
32061 this._layoutItems( this.bricks , isInstant );
32063 this._postLayout();
32065 _layoutItems : function ( items , isInstant)
32067 //this.fireEvent( 'layout', this, items );
32070 if ( !items || !items.elements.length ) {
32071 // no items, emit event with empty array
32076 items.each(function(item) {
32077 Roo.log("layout item");
32079 // get x/y object from method
32080 var position = this._getItemLayoutPosition( item );
32082 position.item = item;
32083 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32084 queue.push( position );
32087 this._processLayoutQueue( queue );
32089 /** Sets position of item in DOM
32090 * @param {Element} item
32091 * @param {Number} x - horizontal position
32092 * @param {Number} y - vertical position
32093 * @param {Boolean} isInstant - disables transitions
32095 _processLayoutQueue : function( queue )
32097 for ( var i=0, len = queue.length; i < len; i++ ) {
32098 var obj = queue[i];
32099 obj.item.position('absolute');
32100 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32106 * Any logic you want to do after each layout,
32107 * i.e. size the container
32109 _postLayout : function()
32111 this.resizeContainer();
32114 resizeContainer : function()
32116 if ( !this.isResizingContainer ) {
32119 var size = this._getContainerSize();
32121 this.el.setSize(size.width,size.height);
32122 this.boxesEl.setSize(size.width,size.height);
32128 _resetLayout : function()
32130 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32131 this.colWidth = this.el.getWidth();
32132 //this.gutter = this.el.getWidth();
32134 this.measureColumns();
32140 this.colYs.push( 0 );
32146 measureColumns : function()
32148 this.getContainerWidth();
32149 // if columnWidth is 0, default to outerWidth of first item
32150 if ( !this.columnWidth ) {
32151 var firstItem = this.bricks.first();
32152 Roo.log(firstItem);
32153 this.columnWidth = this.containerWidth;
32154 if (firstItem && firstItem.attr('originalwidth') ) {
32155 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32157 // columnWidth fall back to item of first element
32158 Roo.log("set column width?");
32159 this.initialColumnWidth = this.columnWidth ;
32161 // if first elem has no width, default to size of container
32166 if (this.initialColumnWidth) {
32167 this.columnWidth = this.initialColumnWidth;
32172 // column width is fixed at the top - however if container width get's smaller we should
32175 // this bit calcs how man columns..
32177 var columnWidth = this.columnWidth += this.gutter;
32179 // calculate columns
32180 var containerWidth = this.containerWidth + this.gutter;
32182 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32183 // fix rounding errors, typically with gutters
32184 var excess = columnWidth - containerWidth % columnWidth;
32187 // if overshoot is less than a pixel, round up, otherwise floor it
32188 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32189 cols = Math[ mathMethod ]( cols );
32190 this.cols = Math.max( cols, 1 );
32191 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32193 // padding positioning..
32194 var totalColWidth = this.cols * this.columnWidth;
32195 var padavail = this.containerWidth - totalColWidth;
32196 // so for 2 columns - we need 3 'pads'
32198 var padNeeded = (1+this.cols) * this.padWidth;
32200 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32202 this.columnWidth += padExtra
32203 //this.padWidth = Math.floor(padavail / ( this.cols));
32205 // adjust colum width so that padding is fixed??
32207 // we have 3 columns ... total = width * 3
32208 // we have X left over... that should be used by
32210 //if (this.expandC) {
32218 getContainerWidth : function()
32220 /* // container is parent if fit width
32221 var container = this.isFitWidth ? this.element.parentNode : this.element;
32222 // check that this.size and size are there
32223 // IE8 triggers resize on body size change, so they might not be
32225 var size = getSize( container ); //FIXME
32226 this.containerWidth = size && size.innerWidth; //FIXME
32229 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32233 _getItemLayoutPosition : function( item ) // what is item?
32235 // we resize the item to our columnWidth..
32237 item.setWidth(this.columnWidth);
32238 item.autoBoxAdjust = false;
32240 var sz = item.getSize();
32242 // how many columns does this brick span
32243 var remainder = this.containerWidth % this.columnWidth;
32245 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32246 // round if off by 1 pixel, otherwise use ceil
32247 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32248 colSpan = Math.min( colSpan, this.cols );
32250 // normally this should be '1' as we dont' currently allow multi width columns..
32252 var colGroup = this._getColGroup( colSpan );
32253 // get the minimum Y value from the columns
32254 var minimumY = Math.min.apply( Math, colGroup );
32255 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32257 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32259 // position the brick
32261 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32262 y: this.currentSize.y + minimumY + this.padHeight
32266 // apply setHeight to necessary columns
32267 var setHeight = minimumY + sz.height + this.padHeight;
32268 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32270 var setSpan = this.cols + 1 - colGroup.length;
32271 for ( var i = 0; i < setSpan; i++ ) {
32272 this.colYs[ shortColIndex + i ] = setHeight ;
32279 * @param {Number} colSpan - number of columns the element spans
32280 * @returns {Array} colGroup
32282 _getColGroup : function( colSpan )
32284 if ( colSpan < 2 ) {
32285 // if brick spans only one column, use all the column Ys
32290 // how many different places could this brick fit horizontally
32291 var groupCount = this.cols + 1 - colSpan;
32292 // for each group potential horizontal position
32293 for ( var i = 0; i < groupCount; i++ ) {
32294 // make an array of colY values for that one group
32295 var groupColYs = this.colYs.slice( i, i + colSpan );
32296 // and get the max value of the array
32297 colGroup[i] = Math.max.apply( Math, groupColYs );
32302 _manageStamp : function( stamp )
32304 var stampSize = stamp.getSize();
32305 var offset = stamp.getBox();
32306 // get the columns that this stamp affects
32307 var firstX = this.isOriginLeft ? offset.x : offset.right;
32308 var lastX = firstX + stampSize.width;
32309 var firstCol = Math.floor( firstX / this.columnWidth );
32310 firstCol = Math.max( 0, firstCol );
32312 var lastCol = Math.floor( lastX / this.columnWidth );
32313 // lastCol should not go over if multiple of columnWidth #425
32314 lastCol -= lastX % this.columnWidth ? 0 : 1;
32315 lastCol = Math.min( this.cols - 1, lastCol );
32317 // set colYs to bottom of the stamp
32318 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32321 for ( var i = firstCol; i <= lastCol; i++ ) {
32322 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32327 _getContainerSize : function()
32329 this.maxY = Math.max.apply( Math, this.colYs );
32334 if ( this.isFitWidth ) {
32335 size.width = this._getContainerFitWidth();
32341 _getContainerFitWidth : function()
32343 var unusedCols = 0;
32344 // count unused columns
32347 if ( this.colYs[i] !== 0 ) {
32352 // fit container to columns that have been used
32353 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32356 needsResizeLayout : function()
32358 var previousWidth = this.containerWidth;
32359 this.getContainerWidth();
32360 return previousWidth !== this.containerWidth;
32375 * @class Roo.bootstrap.MasonryBrick
32376 * @extends Roo.bootstrap.Component
32377 * Bootstrap MasonryBrick class
32380 * Create a new MasonryBrick
32381 * @param {Object} config The config object
32384 Roo.bootstrap.MasonryBrick = function(config){
32386 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32388 Roo.bootstrap.MasonryBrick.register(this);
32394 * When a MasonryBrick is clcik
32395 * @param {Roo.bootstrap.MasonryBrick} this
32396 * @param {Roo.EventObject} e
32402 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32405 * @cfg {String} title
32409 * @cfg {String} html
32413 * @cfg {String} bgimage
32417 * @cfg {String} videourl
32421 * @cfg {String} cls
32425 * @cfg {String} href
32429 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32434 * @cfg {String} placetitle (center|bottom)
32439 * @cfg {Boolean} isFitContainer defalut true
32441 isFitContainer : true,
32444 * @cfg {Boolean} preventDefault defalut false
32446 preventDefault : false,
32449 * @cfg {Boolean} inverse defalut false
32451 maskInverse : false,
32453 getAutoCreate : function()
32455 if(!this.isFitContainer){
32456 return this.getSplitAutoCreate();
32459 var cls = 'masonry-brick masonry-brick-full';
32461 if(this.href.length){
32462 cls += ' masonry-brick-link';
32465 if(this.bgimage.length){
32466 cls += ' masonry-brick-image';
32469 if(this.maskInverse){
32470 cls += ' mask-inverse';
32473 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32474 cls += ' enable-mask';
32478 cls += ' masonry-' + this.size + '-brick';
32481 if(this.placetitle.length){
32483 switch (this.placetitle) {
32485 cls += ' masonry-center-title';
32488 cls += ' masonry-bottom-title';
32495 if(!this.html.length && !this.bgimage.length){
32496 cls += ' masonry-center-title';
32499 if(!this.html.length && this.bgimage.length){
32500 cls += ' masonry-bottom-title';
32505 cls += ' ' + this.cls;
32509 tag: (this.href.length) ? 'a' : 'div',
32514 cls: 'masonry-brick-mask'
32518 cls: 'masonry-brick-paragraph',
32524 if(this.href.length){
32525 cfg.href = this.href;
32528 var cn = cfg.cn[1].cn;
32530 if(this.title.length){
32533 cls: 'masonry-brick-title',
32538 if(this.html.length){
32541 cls: 'masonry-brick-text',
32546 if (!this.title.length && !this.html.length) {
32547 cfg.cn[1].cls += ' hide';
32550 if(this.bgimage.length){
32553 cls: 'masonry-brick-image-view',
32558 if(this.videourl.length){
32559 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32560 // youtube support only?
32563 cls: 'masonry-brick-image-view',
32566 allowfullscreen : true
32574 getSplitAutoCreate : function()
32576 var cls = 'masonry-brick masonry-brick-split';
32578 if(this.href.length){
32579 cls += ' masonry-brick-link';
32582 if(this.bgimage.length){
32583 cls += ' masonry-brick-image';
32587 cls += ' masonry-' + this.size + '-brick';
32590 switch (this.placetitle) {
32592 cls += ' masonry-center-title';
32595 cls += ' masonry-bottom-title';
32598 if(!this.bgimage.length){
32599 cls += ' masonry-center-title';
32602 if(this.bgimage.length){
32603 cls += ' masonry-bottom-title';
32609 cls += ' ' + this.cls;
32613 tag: (this.href.length) ? 'a' : 'div',
32618 cls: 'masonry-brick-split-head',
32622 cls: 'masonry-brick-paragraph',
32629 cls: 'masonry-brick-split-body',
32635 if(this.href.length){
32636 cfg.href = this.href;
32639 if(this.title.length){
32640 cfg.cn[0].cn[0].cn.push({
32642 cls: 'masonry-brick-title',
32647 if(this.html.length){
32648 cfg.cn[1].cn.push({
32650 cls: 'masonry-brick-text',
32655 if(this.bgimage.length){
32656 cfg.cn[0].cn.push({
32658 cls: 'masonry-brick-image-view',
32663 if(this.videourl.length){
32664 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32665 // youtube support only?
32666 cfg.cn[0].cn.cn.push({
32668 cls: 'masonry-brick-image-view',
32671 allowfullscreen : true
32678 initEvents: function()
32680 switch (this.size) {
32713 this.el.on('touchstart', this.onTouchStart, this);
32714 this.el.on('touchmove', this.onTouchMove, this);
32715 this.el.on('touchend', this.onTouchEnd, this);
32716 this.el.on('contextmenu', this.onContextMenu, this);
32718 this.el.on('mouseenter' ,this.enter, this);
32719 this.el.on('mouseleave', this.leave, this);
32720 this.el.on('click', this.onClick, this);
32723 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
32724 this.parent().bricks.push(this);
32729 onClick: function(e, el)
32731 var time = this.endTimer - this.startTimer;
32732 // Roo.log(e.preventDefault());
32735 e.preventDefault();
32740 if(!this.preventDefault){
32744 e.preventDefault();
32746 if (this.activcClass != '') {
32747 this.selectBrick();
32750 this.fireEvent('click', this);
32753 enter: function(e, el)
32755 e.preventDefault();
32757 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32761 if(this.bgimage.length && this.html.length){
32762 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32766 leave: function(e, el)
32768 e.preventDefault();
32770 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
32774 if(this.bgimage.length && this.html.length){
32775 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32779 onTouchStart: function(e, el)
32781 // e.preventDefault();
32783 this.touchmoved = false;
32785 if(!this.isFitContainer){
32789 if(!this.bgimage.length || !this.html.length){
32793 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
32795 this.timer = new Date().getTime();
32799 onTouchMove: function(e, el)
32801 this.touchmoved = true;
32804 onContextMenu : function(e,el)
32806 e.preventDefault();
32807 e.stopPropagation();
32811 onTouchEnd: function(e, el)
32813 // e.preventDefault();
32815 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
32822 if(!this.bgimage.length || !this.html.length){
32824 if(this.href.length){
32825 window.location.href = this.href;
32831 if(!this.isFitContainer){
32835 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
32837 window.location.href = this.href;
32840 //selection on single brick only
32841 selectBrick : function() {
32843 if (!this.parentId) {
32847 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
32848 var index = m.selectedBrick.indexOf(this.id);
32851 m.selectedBrick.splice(index,1);
32852 this.el.removeClass(this.activeClass);
32856 for(var i = 0; i < m.selectedBrick.length; i++) {
32857 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
32858 b.el.removeClass(b.activeClass);
32861 m.selectedBrick = [];
32863 m.selectedBrick.push(this.id);
32864 this.el.addClass(this.activeClass);
32870 Roo.apply(Roo.bootstrap.MasonryBrick, {
32873 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
32875 * register a Masonry Brick
32876 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32879 register : function(brick)
32881 //this.groups[brick.id] = brick;
32882 this.groups.add(brick.id, brick);
32885 * fetch a masonry brick based on the masonry brick ID
32886 * @param {string} the masonry brick to add
32887 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
32890 get: function(brick_id)
32892 // if (typeof(this.groups[brick_id]) == 'undefined') {
32895 // return this.groups[brick_id] ;
32897 if(this.groups.key(brick_id)) {
32898 return this.groups.key(brick_id);
32916 * @class Roo.bootstrap.Brick
32917 * @extends Roo.bootstrap.Component
32918 * Bootstrap Brick class
32921 * Create a new Brick
32922 * @param {Object} config The config object
32925 Roo.bootstrap.Brick = function(config){
32926 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
32932 * When a Brick is click
32933 * @param {Roo.bootstrap.Brick} this
32934 * @param {Roo.EventObject} e
32940 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
32943 * @cfg {String} title
32947 * @cfg {String} html
32951 * @cfg {String} bgimage
32955 * @cfg {String} cls
32959 * @cfg {String} href
32963 * @cfg {String} video
32967 * @cfg {Boolean} square
32971 getAutoCreate : function()
32973 var cls = 'roo-brick';
32975 if(this.href.length){
32976 cls += ' roo-brick-link';
32979 if(this.bgimage.length){
32980 cls += ' roo-brick-image';
32983 if(!this.html.length && !this.bgimage.length){
32984 cls += ' roo-brick-center-title';
32987 if(!this.html.length && this.bgimage.length){
32988 cls += ' roo-brick-bottom-title';
32992 cls += ' ' + this.cls;
32996 tag: (this.href.length) ? 'a' : 'div',
33001 cls: 'roo-brick-paragraph',
33007 if(this.href.length){
33008 cfg.href = this.href;
33011 var cn = cfg.cn[0].cn;
33013 if(this.title.length){
33016 cls: 'roo-brick-title',
33021 if(this.html.length){
33024 cls: 'roo-brick-text',
33031 if(this.bgimage.length){
33034 cls: 'roo-brick-image-view',
33042 initEvents: function()
33044 if(this.title.length || this.html.length){
33045 this.el.on('mouseenter' ,this.enter, this);
33046 this.el.on('mouseleave', this.leave, this);
33049 Roo.EventManager.onWindowResize(this.resize, this);
33051 if(this.bgimage.length){
33052 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33053 this.imageEl.on('load', this.onImageLoad, this);
33060 onImageLoad : function()
33065 resize : function()
33067 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33069 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33071 if(this.bgimage.length){
33072 var image = this.el.select('.roo-brick-image-view', true).first();
33074 image.setWidth(paragraph.getWidth());
33077 image.setHeight(paragraph.getWidth());
33080 this.el.setHeight(image.getHeight());
33081 paragraph.setHeight(image.getHeight());
33087 enter: function(e, el)
33089 e.preventDefault();
33091 if(this.bgimage.length){
33092 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33093 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33097 leave: function(e, el)
33099 e.preventDefault();
33101 if(this.bgimage.length){
33102 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33103 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33118 * @class Roo.bootstrap.NumberField
33119 * @extends Roo.bootstrap.Input
33120 * Bootstrap NumberField class
33126 * Create a new NumberField
33127 * @param {Object} config The config object
33130 Roo.bootstrap.NumberField = function(config){
33131 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33134 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33137 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33139 allowDecimals : true,
33141 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33143 decimalSeparator : ".",
33145 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33147 decimalPrecision : 2,
33149 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33151 allowNegative : true,
33154 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33158 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33160 minValue : Number.NEGATIVE_INFINITY,
33162 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33164 maxValue : Number.MAX_VALUE,
33166 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33168 minText : "The minimum value for this field is {0}",
33170 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33172 maxText : "The maximum value for this field is {0}",
33174 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33175 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33177 nanText : "{0} is not a valid number",
33179 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
33183 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33185 thousandsDelimiter : false,
33187 * @cfg {String} valueAlign alignment of value
33189 valueAlign : "left",
33191 getAutoCreate : function()
33193 var hiddenInput = {
33197 cls: 'hidden-number-input'
33201 hiddenInput.name = this.name;
33206 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33208 this.name = hiddenInput.name;
33210 if(cfg.cn.length > 0) {
33211 cfg.cn.push(hiddenInput);
33218 initEvents : function()
33220 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33222 var allowed = "0123456789";
33224 if(this.allowDecimals){
33225 allowed += this.decimalSeparator;
33228 if(this.allowNegative){
33232 if(this.thousandsDelimiter) {
33236 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33238 var keyPress = function(e){
33240 var k = e.getKey();
33242 var c = e.getCharCode();
33245 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33246 allowed.indexOf(String.fromCharCode(c)) === -1
33252 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33256 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33261 this.el.on("keypress", keyPress, this);
33264 validateValue : function(value)
33267 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33271 var num = this.parseValue(value);
33274 this.markInvalid(String.format(this.nanText, value));
33278 if(num < this.minValue){
33279 this.markInvalid(String.format(this.minText, this.minValue));
33283 if(num > this.maxValue){
33284 this.markInvalid(String.format(this.maxText, this.maxValue));
33291 getValue : function()
33293 var v = this.hiddenEl().getValue();
33295 return this.fixPrecision(this.parseValue(v));
33298 parseValue : function(value)
33300 if(this.thousandsDelimiter) {
33302 r = new RegExp(",", "g");
33303 value = value.replace(r, "");
33306 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33307 return isNaN(value) ? '' : value;
33310 fixPrecision : function(value)
33312 if(this.thousandsDelimiter) {
33314 r = new RegExp(",", "g");
33315 value = value.replace(r, "");
33318 var nan = isNaN(value);
33320 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33321 return nan ? '' : value;
33323 return parseFloat(value).toFixed(this.decimalPrecision);
33326 setValue : function(v)
33328 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33334 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33336 this.inputEl().dom.value = (v == '') ? '' :
33337 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33339 if(!this.allowZero && v === '0') {
33340 this.hiddenEl().dom.value = '';
33341 this.inputEl().dom.value = '';
33348 decimalPrecisionFcn : function(v)
33350 return Math.floor(v);
33353 beforeBlur : function()
33359 var v = this.parseValue(this.getRawValue());
33366 hiddenEl : function()
33368 return this.el.select('input.hidden-number-input',true).first();
33380 * @class Roo.bootstrap.DocumentSlider
33381 * @extends Roo.bootstrap.Component
33382 * Bootstrap DocumentSlider class
33385 * Create a new DocumentViewer
33386 * @param {Object} config The config object
33389 Roo.bootstrap.DocumentSlider = function(config){
33390 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33397 * Fire after initEvent
33398 * @param {Roo.bootstrap.DocumentSlider} this
33403 * Fire after update
33404 * @param {Roo.bootstrap.DocumentSlider} this
33410 * @param {Roo.bootstrap.DocumentSlider} this
33416 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33422 getAutoCreate : function()
33426 cls : 'roo-document-slider',
33430 cls : 'roo-document-slider-header',
33434 cls : 'roo-document-slider-header-title'
33440 cls : 'roo-document-slider-body',
33444 cls : 'roo-document-slider-prev',
33448 cls : 'fa fa-chevron-left'
33454 cls : 'roo-document-slider-thumb',
33458 cls : 'roo-document-slider-image'
33464 cls : 'roo-document-slider-next',
33468 cls : 'fa fa-chevron-right'
33480 initEvents : function()
33482 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33483 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33485 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33486 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33488 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33489 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33491 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33492 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33494 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33495 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33497 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33498 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33500 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33501 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33503 this.thumbEl.on('click', this.onClick, this);
33505 this.prevIndicator.on('click', this.prev, this);
33507 this.nextIndicator.on('click', this.next, this);
33511 initial : function()
33513 if(this.files.length){
33514 this.indicator = 1;
33518 this.fireEvent('initial', this);
33521 update : function()
33523 this.imageEl.attr('src', this.files[this.indicator - 1]);
33525 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33527 this.prevIndicator.show();
33529 if(this.indicator == 1){
33530 this.prevIndicator.hide();
33533 this.nextIndicator.show();
33535 if(this.indicator == this.files.length){
33536 this.nextIndicator.hide();
33539 this.thumbEl.scrollTo('top');
33541 this.fireEvent('update', this);
33544 onClick : function(e)
33546 e.preventDefault();
33548 this.fireEvent('click', this);
33553 e.preventDefault();
33555 this.indicator = Math.max(1, this.indicator - 1);
33562 e.preventDefault();
33564 this.indicator = Math.min(this.files.length, this.indicator + 1);
33578 * @class Roo.bootstrap.RadioSet
33579 * @extends Roo.bootstrap.Input
33580 * Bootstrap RadioSet class
33581 * @cfg {String} indicatorpos (left|right) default left
33582 * @cfg {Boolean} inline (true|false) inline the element (default true)
33583 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33585 * Create a new RadioSet
33586 * @param {Object} config The config object
33589 Roo.bootstrap.RadioSet = function(config){
33591 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33595 Roo.bootstrap.RadioSet.register(this);
33600 * Fires when the element is checked or unchecked.
33601 * @param {Roo.bootstrap.RadioSet} this This radio
33602 * @param {Roo.bootstrap.Radio} item The checked item
33607 * Fires when the element is click.
33608 * @param {Roo.bootstrap.RadioSet} this This radio set
33609 * @param {Roo.bootstrap.Radio} item The checked item
33610 * @param {Roo.EventObject} e The event object
33617 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33625 indicatorpos : 'left',
33627 getAutoCreate : function()
33631 cls : 'roo-radio-set-label',
33635 html : this.fieldLabel
33640 if(this.indicatorpos == 'left'){
33643 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33644 tooltip : 'This field is required'
33649 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33650 tooltip : 'This field is required'
33656 cls : 'roo-radio-set-items'
33659 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33661 if (align === 'left' && this.fieldLabel.length) {
33664 cls : "roo-radio-set-right",
33670 if(this.labelWidth > 12){
33671 label.style = "width: " + this.labelWidth + 'px';
33674 if(this.labelWidth < 13 && this.labelmd == 0){
33675 this.labelmd = this.labelWidth;
33678 if(this.labellg > 0){
33679 label.cls += ' col-lg-' + this.labellg;
33680 items.cls += ' col-lg-' + (12 - this.labellg);
33683 if(this.labelmd > 0){
33684 label.cls += ' col-md-' + this.labelmd;
33685 items.cls += ' col-md-' + (12 - this.labelmd);
33688 if(this.labelsm > 0){
33689 label.cls += ' col-sm-' + this.labelsm;
33690 items.cls += ' col-sm-' + (12 - this.labelsm);
33693 if(this.labelxs > 0){
33694 label.cls += ' col-xs-' + this.labelxs;
33695 items.cls += ' col-xs-' + (12 - this.labelxs);
33701 cls : 'roo-radio-set',
33705 cls : 'roo-radio-set-input',
33708 value : this.value ? this.value : ''
33715 if(this.weight.length){
33716 cfg.cls += ' roo-radio-' + this.weight;
33720 cfg.cls += ' roo-radio-set-inline';
33724 ['xs','sm','md','lg'].map(function(size){
33725 if (settings[size]) {
33726 cfg.cls += ' col-' + size + '-' + settings[size];
33734 initEvents : function()
33736 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
33737 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
33739 if(!this.fieldLabel.length){
33740 this.labelEl.hide();
33743 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
33744 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
33746 this.indicatorEl().addClass('invisible');
33748 this.originalValue = this.getValue();
33752 inputEl: function ()
33754 return this.el.select('.roo-radio-set-input', true).first();
33757 getChildContainer : function()
33759 return this.itemsEl;
33762 register : function(item)
33764 this.radioes.push(item);
33768 validate : function()
33770 if(this.getEl().hasClass('hidden')){
33776 Roo.each(this.radioes, function(i){
33785 if(this.allowBlank) {
33789 if(this.disabled || valid){
33794 this.markInvalid();
33799 markValid : function()
33801 if(this.labelEl.isVisible(true)){
33802 this.indicatorEl().removeClass('visible');
33803 this.indicatorEl().addClass('invisible');
33806 this.el.removeClass([this.invalidClass, this.validClass]);
33807 this.el.addClass(this.validClass);
33809 this.fireEvent('valid', this);
33812 markInvalid : function(msg)
33814 if(this.allowBlank || this.disabled){
33818 if(this.labelEl.isVisible(true)){
33819 this.indicatorEl().removeClass('invisible');
33820 this.indicatorEl().addClass('visible');
33823 this.el.removeClass([this.invalidClass, this.validClass]);
33824 this.el.addClass(this.invalidClass);
33826 this.fireEvent('invalid', this, msg);
33830 setValue : function(v, suppressEvent)
33832 if(this.value === v){
33839 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
33842 Roo.each(this.radioes, function(i){
33844 i.el.removeClass('checked');
33847 Roo.each(this.radioes, function(i){
33849 if(i.value === v || i.value.toString() === v.toString()){
33851 i.el.addClass('checked');
33853 if(suppressEvent !== true){
33854 this.fireEvent('check', this, i);
33865 clearInvalid : function(){
33867 if(!this.el || this.preventMark){
33871 this.el.removeClass([this.invalidClass]);
33873 this.fireEvent('valid', this);
33878 Roo.apply(Roo.bootstrap.RadioSet, {
33882 register : function(set)
33884 this.groups[set.name] = set;
33887 get: function(name)
33889 if (typeof(this.groups[name]) == 'undefined') {
33893 return this.groups[name] ;
33899 * Ext JS Library 1.1.1
33900 * Copyright(c) 2006-2007, Ext JS, LLC.
33902 * Originally Released Under LGPL - original licence link has changed is not relivant.
33905 * <script type="text/javascript">
33910 * @class Roo.bootstrap.SplitBar
33911 * @extends Roo.util.Observable
33912 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
33916 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
33917 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
33918 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
33919 split.minSize = 100;
33920 split.maxSize = 600;
33921 split.animate = true;
33922 split.on('moved', splitterMoved);
33925 * Create a new SplitBar
33926 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
33927 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
33928 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33929 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
33930 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
33931 position of the SplitBar).
33933 Roo.bootstrap.SplitBar = function(cfg){
33938 // dragElement : elm
33939 // resizingElement: el,
33941 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
33942 // placement : Roo.bootstrap.SplitBar.LEFT ,
33943 // existingProxy ???
33946 this.el = Roo.get(cfg.dragElement, true);
33947 this.el.dom.unselectable = "on";
33949 this.resizingEl = Roo.get(cfg.resizingElement, true);
33953 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
33954 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
33957 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
33960 * The minimum size of the resizing element. (Defaults to 0)
33966 * The maximum size of the resizing element. (Defaults to 2000)
33969 this.maxSize = 2000;
33972 * Whether to animate the transition to the new size
33975 this.animate = false;
33978 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
33981 this.useShim = false;
33986 if(!cfg.existingProxy){
33988 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
33990 this.proxy = Roo.get(cfg.existingProxy).dom;
33993 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
33996 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
33999 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34002 this.dragSpecs = {};
34005 * @private The adapter to use to positon and resize elements
34007 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34008 this.adapter.init(this);
34010 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34012 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34013 this.el.addClass("roo-splitbar-h");
34016 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34017 this.el.addClass("roo-splitbar-v");
34023 * Fires when the splitter is moved (alias for {@link #event-moved})
34024 * @param {Roo.bootstrap.SplitBar} this
34025 * @param {Number} newSize the new width or height
34030 * Fires when the splitter is moved
34031 * @param {Roo.bootstrap.SplitBar} this
34032 * @param {Number} newSize the new width or height
34036 * @event beforeresize
34037 * Fires before the splitter is dragged
34038 * @param {Roo.bootstrap.SplitBar} this
34040 "beforeresize" : true,
34042 "beforeapply" : true
34045 Roo.util.Observable.call(this);
34048 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34049 onStartProxyDrag : function(x, y){
34050 this.fireEvent("beforeresize", this);
34052 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34054 o.enableDisplayMode("block");
34055 // all splitbars share the same overlay
34056 Roo.bootstrap.SplitBar.prototype.overlay = o;
34058 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34059 this.overlay.show();
34060 Roo.get(this.proxy).setDisplayed("block");
34061 var size = this.adapter.getElementSize(this);
34062 this.activeMinSize = this.getMinimumSize();;
34063 this.activeMaxSize = this.getMaximumSize();;
34064 var c1 = size - this.activeMinSize;
34065 var c2 = Math.max(this.activeMaxSize - size, 0);
34066 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34067 this.dd.resetConstraints();
34068 this.dd.setXConstraint(
34069 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34070 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34072 this.dd.setYConstraint(0, 0);
34074 this.dd.resetConstraints();
34075 this.dd.setXConstraint(0, 0);
34076 this.dd.setYConstraint(
34077 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34078 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34081 this.dragSpecs.startSize = size;
34082 this.dragSpecs.startPoint = [x, y];
34083 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34087 * @private Called after the drag operation by the DDProxy
34089 onEndProxyDrag : function(e){
34090 Roo.get(this.proxy).setDisplayed(false);
34091 var endPoint = Roo.lib.Event.getXY(e);
34093 this.overlay.hide();
34096 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34097 newSize = this.dragSpecs.startSize +
34098 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34099 endPoint[0] - this.dragSpecs.startPoint[0] :
34100 this.dragSpecs.startPoint[0] - endPoint[0]
34103 newSize = this.dragSpecs.startSize +
34104 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34105 endPoint[1] - this.dragSpecs.startPoint[1] :
34106 this.dragSpecs.startPoint[1] - endPoint[1]
34109 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34110 if(newSize != this.dragSpecs.startSize){
34111 if(this.fireEvent('beforeapply', this, newSize) !== false){
34112 this.adapter.setElementSize(this, newSize);
34113 this.fireEvent("moved", this, newSize);
34114 this.fireEvent("resize", this, newSize);
34120 * Get the adapter this SplitBar uses
34121 * @return The adapter object
34123 getAdapter : function(){
34124 return this.adapter;
34128 * Set the adapter this SplitBar uses
34129 * @param {Object} adapter A SplitBar adapter object
34131 setAdapter : function(adapter){
34132 this.adapter = adapter;
34133 this.adapter.init(this);
34137 * Gets the minimum size for the resizing element
34138 * @return {Number} The minimum size
34140 getMinimumSize : function(){
34141 return this.minSize;
34145 * Sets the minimum size for the resizing element
34146 * @param {Number} minSize The minimum size
34148 setMinimumSize : function(minSize){
34149 this.minSize = minSize;
34153 * Gets the maximum size for the resizing element
34154 * @return {Number} The maximum size
34156 getMaximumSize : function(){
34157 return this.maxSize;
34161 * Sets the maximum size for the resizing element
34162 * @param {Number} maxSize The maximum size
34164 setMaximumSize : function(maxSize){
34165 this.maxSize = maxSize;
34169 * Sets the initialize size for the resizing element
34170 * @param {Number} size The initial size
34172 setCurrentSize : function(size){
34173 var oldAnimate = this.animate;
34174 this.animate = false;
34175 this.adapter.setElementSize(this, size);
34176 this.animate = oldAnimate;
34180 * Destroy this splitbar.
34181 * @param {Boolean} removeEl True to remove the element
34183 destroy : function(removeEl){
34185 this.shim.remove();
34188 this.proxy.parentNode.removeChild(this.proxy);
34196 * @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.
34198 Roo.bootstrap.SplitBar.createProxy = function(dir){
34199 var proxy = new Roo.Element(document.createElement("div"));
34200 proxy.unselectable();
34201 var cls = 'roo-splitbar-proxy';
34202 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34203 document.body.appendChild(proxy.dom);
34208 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34209 * Default Adapter. It assumes the splitter and resizing element are not positioned
34210 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34212 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34215 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34216 // do nothing for now
34217 init : function(s){
34221 * Called before drag operations to get the current size of the resizing element.
34222 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34224 getElementSize : function(s){
34225 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34226 return s.resizingEl.getWidth();
34228 return s.resizingEl.getHeight();
34233 * Called after drag operations to set the size of the resizing element.
34234 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34235 * @param {Number} newSize The new size to set
34236 * @param {Function} onComplete A function to be invoked when resizing is complete
34238 setElementSize : function(s, newSize, onComplete){
34239 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34241 s.resizingEl.setWidth(newSize);
34243 onComplete(s, newSize);
34246 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34251 s.resizingEl.setHeight(newSize);
34253 onComplete(s, newSize);
34256 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34263 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34264 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34265 * Adapter that moves the splitter element to align with the resized sizing element.
34266 * Used with an absolute positioned SplitBar.
34267 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34268 * document.body, make sure you assign an id to the body element.
34270 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34271 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34272 this.container = Roo.get(container);
34275 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34276 init : function(s){
34277 this.basic.init(s);
34280 getElementSize : function(s){
34281 return this.basic.getElementSize(s);
34284 setElementSize : function(s, newSize, onComplete){
34285 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34288 moveSplitter : function(s){
34289 var yes = Roo.bootstrap.SplitBar;
34290 switch(s.placement){
34292 s.el.setX(s.resizingEl.getRight());
34295 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34298 s.el.setY(s.resizingEl.getBottom());
34301 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34308 * Orientation constant - Create a vertical SplitBar
34312 Roo.bootstrap.SplitBar.VERTICAL = 1;
34315 * Orientation constant - Create a horizontal SplitBar
34319 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34322 * Placement constant - The resizing element is to the left of the splitter element
34326 Roo.bootstrap.SplitBar.LEFT = 1;
34329 * Placement constant - The resizing element is to the right of the splitter element
34333 Roo.bootstrap.SplitBar.RIGHT = 2;
34336 * Placement constant - The resizing element is positioned above the splitter element
34340 Roo.bootstrap.SplitBar.TOP = 3;
34343 * Placement constant - The resizing element is positioned under splitter element
34347 Roo.bootstrap.SplitBar.BOTTOM = 4;
34348 Roo.namespace("Roo.bootstrap.layout");/*
34350 * Ext JS Library 1.1.1
34351 * Copyright(c) 2006-2007, Ext JS, LLC.
34353 * Originally Released Under LGPL - original licence link has changed is not relivant.
34356 * <script type="text/javascript">
34360 * @class Roo.bootstrap.layout.Manager
34361 * @extends Roo.bootstrap.Component
34362 * Base class for layout managers.
34364 Roo.bootstrap.layout.Manager = function(config)
34366 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34372 /** false to disable window resize monitoring @type Boolean */
34373 this.monitorWindowResize = true;
34378 * Fires when a layout is performed.
34379 * @param {Roo.LayoutManager} this
34383 * @event regionresized
34384 * Fires when the user resizes a region.
34385 * @param {Roo.LayoutRegion} region The resized region
34386 * @param {Number} newSize The new size (width for east/west, height for north/south)
34388 "regionresized" : true,
34390 * @event regioncollapsed
34391 * Fires when a region is collapsed.
34392 * @param {Roo.LayoutRegion} region The collapsed region
34394 "regioncollapsed" : true,
34396 * @event regionexpanded
34397 * Fires when a region is expanded.
34398 * @param {Roo.LayoutRegion} region The expanded region
34400 "regionexpanded" : true
34402 this.updating = false;
34405 this.el = Roo.get(config.el);
34411 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34416 monitorWindowResize : true,
34422 onRender : function(ct, position)
34425 this.el = Roo.get(ct);
34428 //this.fireEvent('render',this);
34432 initEvents: function()
34436 // ie scrollbar fix
34437 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34438 document.body.scroll = "no";
34439 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34440 this.el.position('relative');
34442 this.id = this.el.id;
34443 this.el.addClass("roo-layout-container");
34444 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34445 if(this.el.dom != document.body ) {
34446 this.el.on('resize', this.layout,this);
34447 this.el.on('show', this.layout,this);
34453 * Returns true if this layout is currently being updated
34454 * @return {Boolean}
34456 isUpdating : function(){
34457 return this.updating;
34461 * Suspend the LayoutManager from doing auto-layouts while
34462 * making multiple add or remove calls
34464 beginUpdate : function(){
34465 this.updating = true;
34469 * Restore auto-layouts and optionally disable the manager from performing a layout
34470 * @param {Boolean} noLayout true to disable a layout update
34472 endUpdate : function(noLayout){
34473 this.updating = false;
34479 layout: function(){
34483 onRegionResized : function(region, newSize){
34484 this.fireEvent("regionresized", region, newSize);
34488 onRegionCollapsed : function(region){
34489 this.fireEvent("regioncollapsed", region);
34492 onRegionExpanded : function(region){
34493 this.fireEvent("regionexpanded", region);
34497 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34498 * performs box-model adjustments.
34499 * @return {Object} The size as an object {width: (the width), height: (the height)}
34501 getViewSize : function()
34504 if(this.el.dom != document.body){
34505 size = this.el.getSize();
34507 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34509 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34510 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34515 * Returns the Element this layout is bound to.
34516 * @return {Roo.Element}
34518 getEl : function(){
34523 * Returns the specified region.
34524 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34525 * @return {Roo.LayoutRegion}
34527 getRegion : function(target){
34528 return this.regions[target.toLowerCase()];
34531 onWindowResize : function(){
34532 if(this.monitorWindowResize){
34539 * Ext JS Library 1.1.1
34540 * Copyright(c) 2006-2007, Ext JS, LLC.
34542 * Originally Released Under LGPL - original licence link has changed is not relivant.
34545 * <script type="text/javascript">
34548 * @class Roo.bootstrap.layout.Border
34549 * @extends Roo.bootstrap.layout.Manager
34550 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34551 * please see: examples/bootstrap/nested.html<br><br>
34553 <b>The container the layout is rendered into can be either the body element or any other element.
34554 If it is not the body element, the container needs to either be an absolute positioned element,
34555 or you will need to add "position:relative" to the css of the container. You will also need to specify
34556 the container size if it is not the body element.</b>
34559 * Create a new Border
34560 * @param {Object} config Configuration options
34562 Roo.bootstrap.layout.Border = function(config){
34563 config = config || {};
34564 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34568 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34569 if(config[region]){
34570 config[region].region = region;
34571 this.addRegion(config[region]);
34577 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34579 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34581 * Creates and adds a new region if it doesn't already exist.
34582 * @param {String} target The target region key (north, south, east, west or center).
34583 * @param {Object} config The regions config object
34584 * @return {BorderLayoutRegion} The new region
34586 addRegion : function(config)
34588 if(!this.regions[config.region]){
34589 var r = this.factory(config);
34590 this.bindRegion(r);
34592 return this.regions[config.region];
34596 bindRegion : function(r){
34597 this.regions[r.config.region] = r;
34599 r.on("visibilitychange", this.layout, this);
34600 r.on("paneladded", this.layout, this);
34601 r.on("panelremoved", this.layout, this);
34602 r.on("invalidated", this.layout, this);
34603 r.on("resized", this.onRegionResized, this);
34604 r.on("collapsed", this.onRegionCollapsed, this);
34605 r.on("expanded", this.onRegionExpanded, this);
34609 * Performs a layout update.
34611 layout : function()
34613 if(this.updating) {
34617 // render all the rebions if they have not been done alreayd?
34618 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34619 if(this.regions[region] && !this.regions[region].bodyEl){
34620 this.regions[region].onRender(this.el)
34624 var size = this.getViewSize();
34625 var w = size.width;
34626 var h = size.height;
34631 //var x = 0, y = 0;
34633 var rs = this.regions;
34634 var north = rs["north"];
34635 var south = rs["south"];
34636 var west = rs["west"];
34637 var east = rs["east"];
34638 var center = rs["center"];
34639 //if(this.hideOnLayout){ // not supported anymore
34640 //c.el.setStyle("display", "none");
34642 if(north && north.isVisible()){
34643 var b = north.getBox();
34644 var m = north.getMargins();
34645 b.width = w - (m.left+m.right);
34648 centerY = b.height + b.y + m.bottom;
34649 centerH -= centerY;
34650 north.updateBox(this.safeBox(b));
34652 if(south && south.isVisible()){
34653 var b = south.getBox();
34654 var m = south.getMargins();
34655 b.width = w - (m.left+m.right);
34657 var totalHeight = (b.height + m.top + m.bottom);
34658 b.y = h - totalHeight + m.top;
34659 centerH -= totalHeight;
34660 south.updateBox(this.safeBox(b));
34662 if(west && west.isVisible()){
34663 var b = west.getBox();
34664 var m = west.getMargins();
34665 b.height = centerH - (m.top+m.bottom);
34667 b.y = centerY + m.top;
34668 var totalWidth = (b.width + m.left + m.right);
34669 centerX += totalWidth;
34670 centerW -= totalWidth;
34671 west.updateBox(this.safeBox(b));
34673 if(east && east.isVisible()){
34674 var b = east.getBox();
34675 var m = east.getMargins();
34676 b.height = centerH - (m.top+m.bottom);
34677 var totalWidth = (b.width + m.left + m.right);
34678 b.x = w - totalWidth + m.left;
34679 b.y = centerY + m.top;
34680 centerW -= totalWidth;
34681 east.updateBox(this.safeBox(b));
34684 var m = center.getMargins();
34686 x: centerX + m.left,
34687 y: centerY + m.top,
34688 width: centerW - (m.left+m.right),
34689 height: centerH - (m.top+m.bottom)
34691 //if(this.hideOnLayout){
34692 //center.el.setStyle("display", "block");
34694 center.updateBox(this.safeBox(centerBox));
34697 this.fireEvent("layout", this);
34701 safeBox : function(box){
34702 box.width = Math.max(0, box.width);
34703 box.height = Math.max(0, box.height);
34708 * Adds a ContentPanel (or subclass) to this layout.
34709 * @param {String} target The target region key (north, south, east, west or center).
34710 * @param {Roo.ContentPanel} panel The panel to add
34711 * @return {Roo.ContentPanel} The added panel
34713 add : function(target, panel){
34715 target = target.toLowerCase();
34716 return this.regions[target].add(panel);
34720 * Remove a ContentPanel (or subclass) to this layout.
34721 * @param {String} target The target region key (north, south, east, west or center).
34722 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
34723 * @return {Roo.ContentPanel} The removed panel
34725 remove : function(target, panel){
34726 target = target.toLowerCase();
34727 return this.regions[target].remove(panel);
34731 * Searches all regions for a panel with the specified id
34732 * @param {String} panelId
34733 * @return {Roo.ContentPanel} The panel or null if it wasn't found
34735 findPanel : function(panelId){
34736 var rs = this.regions;
34737 for(var target in rs){
34738 if(typeof rs[target] != "function"){
34739 var p = rs[target].getPanel(panelId);
34749 * Searches all regions for a panel with the specified id and activates (shows) it.
34750 * @param {String/ContentPanel} panelId The panels id or the panel itself
34751 * @return {Roo.ContentPanel} The shown panel or null
34753 showPanel : function(panelId) {
34754 var rs = this.regions;
34755 for(var target in rs){
34756 var r = rs[target];
34757 if(typeof r != "function"){
34758 if(r.hasPanel(panelId)){
34759 return r.showPanel(panelId);
34767 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
34768 * @param {Roo.state.Provider} provider (optional) An alternate state provider
34771 restoreState : function(provider){
34773 provider = Roo.state.Manager;
34775 var sm = new Roo.LayoutStateManager();
34776 sm.init(this, provider);
34782 * Adds a xtype elements to the layout.
34786 xtype : 'ContentPanel',
34793 xtype : 'NestedLayoutPanel',
34799 items : [ ... list of content panels or nested layout panels.. ]
34803 * @param {Object} cfg Xtype definition of item to add.
34805 addxtype : function(cfg)
34807 // basically accepts a pannel...
34808 // can accept a layout region..!?!?
34809 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
34812 // theory? children can only be panels??
34814 //if (!cfg.xtype.match(/Panel$/)) {
34819 if (typeof(cfg.region) == 'undefined') {
34820 Roo.log("Failed to add Panel, region was not set");
34824 var region = cfg.region;
34830 xitems = cfg.items;
34837 case 'Content': // ContentPanel (el, cfg)
34838 case 'Scroll': // ContentPanel (el, cfg)
34840 cfg.autoCreate = true;
34841 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34843 // var el = this.el.createChild();
34844 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
34847 this.add(region, ret);
34851 case 'TreePanel': // our new panel!
34852 cfg.el = this.el.createChild();
34853 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34854 this.add(region, ret);
34859 // create a new Layout (which is a Border Layout...
34861 var clayout = cfg.layout;
34862 clayout.el = this.el.createChild();
34863 clayout.items = clayout.items || [];
34867 // replace this exitems with the clayout ones..
34868 xitems = clayout.items;
34870 // force background off if it's in center...
34871 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
34872 cfg.background = false;
34874 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
34877 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34878 //console.log('adding nested layout panel ' + cfg.toSource());
34879 this.add(region, ret);
34880 nb = {}; /// find first...
34885 // needs grid and region
34887 //var el = this.getRegion(region).el.createChild();
34889 *var el = this.el.createChild();
34890 // create the grid first...
34891 cfg.grid.container = el;
34892 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
34895 if (region == 'center' && this.active ) {
34896 cfg.background = false;
34899 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
34901 this.add(region, ret);
34903 if (cfg.background) {
34904 // render grid on panel activation (if panel background)
34905 ret.on('activate', function(gp) {
34906 if (!gp.grid.rendered) {
34907 // gp.grid.render(el);
34911 // cfg.grid.render(el);
34917 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
34918 // it was the old xcomponent building that caused this before.
34919 // espeically if border is the top element in the tree.
34929 if (typeof(Roo[cfg.xtype]) != 'undefined') {
34931 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
34932 this.add(region, ret);
34936 throw "Can not add '" + cfg.xtype + "' to Border";
34942 this.beginUpdate();
34946 Roo.each(xitems, function(i) {
34947 region = nb && i.region ? i.region : false;
34949 var add = ret.addxtype(i);
34952 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
34953 if (!i.background) {
34954 abn[region] = nb[region] ;
34961 // make the last non-background panel active..
34962 //if (nb) { Roo.log(abn); }
34965 for(var r in abn) {
34966 region = this.getRegion(r);
34968 // tried using nb[r], but it does not work..
34970 region.showPanel(abn[r]);
34981 factory : function(cfg)
34984 var validRegions = Roo.bootstrap.layout.Border.regions;
34986 var target = cfg.region;
34989 var r = Roo.bootstrap.layout;
34993 return new r.North(cfg);
34995 return new r.South(cfg);
34997 return new r.East(cfg);
34999 return new r.West(cfg);
35001 return new r.Center(cfg);
35003 throw 'Layout region "'+target+'" not supported.';
35010 * Ext JS Library 1.1.1
35011 * Copyright(c) 2006-2007, Ext JS, LLC.
35013 * Originally Released Under LGPL - original licence link has changed is not relivant.
35016 * <script type="text/javascript">
35020 * @class Roo.bootstrap.layout.Basic
35021 * @extends Roo.util.Observable
35022 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35023 * and does not have a titlebar, tabs or any other features. All it does is size and position
35024 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35025 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35026 * @cfg {string} region the region that it inhabits..
35027 * @cfg {bool} skipConfig skip config?
35031 Roo.bootstrap.layout.Basic = function(config){
35033 this.mgr = config.mgr;
35035 this.position = config.region;
35037 var skipConfig = config.skipConfig;
35041 * @scope Roo.BasicLayoutRegion
35045 * @event beforeremove
35046 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35047 * @param {Roo.LayoutRegion} this
35048 * @param {Roo.ContentPanel} panel The panel
35049 * @param {Object} e The cancel event object
35051 "beforeremove" : true,
35053 * @event invalidated
35054 * Fires when the layout for this region is changed.
35055 * @param {Roo.LayoutRegion} this
35057 "invalidated" : true,
35059 * @event visibilitychange
35060 * Fires when this region is shown or hidden
35061 * @param {Roo.LayoutRegion} this
35062 * @param {Boolean} visibility true or false
35064 "visibilitychange" : true,
35066 * @event paneladded
35067 * Fires when a panel is added.
35068 * @param {Roo.LayoutRegion} this
35069 * @param {Roo.ContentPanel} panel The panel
35071 "paneladded" : true,
35073 * @event panelremoved
35074 * Fires when a panel is removed.
35075 * @param {Roo.LayoutRegion} this
35076 * @param {Roo.ContentPanel} panel The panel
35078 "panelremoved" : true,
35080 * @event beforecollapse
35081 * Fires when this region before collapse.
35082 * @param {Roo.LayoutRegion} this
35084 "beforecollapse" : true,
35087 * Fires when this region is collapsed.
35088 * @param {Roo.LayoutRegion} this
35090 "collapsed" : true,
35093 * Fires when this region is expanded.
35094 * @param {Roo.LayoutRegion} this
35099 * Fires when this region is slid into view.
35100 * @param {Roo.LayoutRegion} this
35102 "slideshow" : true,
35105 * Fires when this region slides out of view.
35106 * @param {Roo.LayoutRegion} this
35108 "slidehide" : true,
35110 * @event panelactivated
35111 * Fires when a panel is activated.
35112 * @param {Roo.LayoutRegion} this
35113 * @param {Roo.ContentPanel} panel The activated panel
35115 "panelactivated" : true,
35118 * Fires when the user resizes this region.
35119 * @param {Roo.LayoutRegion} this
35120 * @param {Number} newSize The new size (width for east/west, height for north/south)
35124 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35125 this.panels = new Roo.util.MixedCollection();
35126 this.panels.getKey = this.getPanelId.createDelegate(this);
35128 this.activePanel = null;
35129 // ensure listeners are added...
35131 if (config.listeners || config.events) {
35132 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35133 listeners : config.listeners || {},
35134 events : config.events || {}
35138 if(skipConfig !== true){
35139 this.applyConfig(config);
35143 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35145 getPanelId : function(p){
35149 applyConfig : function(config){
35150 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35151 this.config = config;
35156 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35157 * the width, for horizontal (north, south) the height.
35158 * @param {Number} newSize The new width or height
35160 resizeTo : function(newSize){
35161 var el = this.el ? this.el :
35162 (this.activePanel ? this.activePanel.getEl() : null);
35164 switch(this.position){
35167 el.setWidth(newSize);
35168 this.fireEvent("resized", this, newSize);
35172 el.setHeight(newSize);
35173 this.fireEvent("resized", this, newSize);
35179 getBox : function(){
35180 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35183 getMargins : function(){
35184 return this.margins;
35187 updateBox : function(box){
35189 var el = this.activePanel.getEl();
35190 el.dom.style.left = box.x + "px";
35191 el.dom.style.top = box.y + "px";
35192 this.activePanel.setSize(box.width, box.height);
35196 * Returns the container element for this region.
35197 * @return {Roo.Element}
35199 getEl : function(){
35200 return this.activePanel;
35204 * Returns true if this region is currently visible.
35205 * @return {Boolean}
35207 isVisible : function(){
35208 return this.activePanel ? true : false;
35211 setActivePanel : function(panel){
35212 panel = this.getPanel(panel);
35213 if(this.activePanel && this.activePanel != panel){
35214 this.activePanel.setActiveState(false);
35215 this.activePanel.getEl().setLeftTop(-10000,-10000);
35217 this.activePanel = panel;
35218 panel.setActiveState(true);
35220 panel.setSize(this.box.width, this.box.height);
35222 this.fireEvent("panelactivated", this, panel);
35223 this.fireEvent("invalidated");
35227 * Show the specified panel.
35228 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35229 * @return {Roo.ContentPanel} The shown panel or null
35231 showPanel : function(panel){
35232 panel = this.getPanel(panel);
35234 this.setActivePanel(panel);
35240 * Get the active panel for this region.
35241 * @return {Roo.ContentPanel} The active panel or null
35243 getActivePanel : function(){
35244 return this.activePanel;
35248 * Add the passed ContentPanel(s)
35249 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35250 * @return {Roo.ContentPanel} The panel added (if only one was added)
35252 add : function(panel){
35253 if(arguments.length > 1){
35254 for(var i = 0, len = arguments.length; i < len; i++) {
35255 this.add(arguments[i]);
35259 if(this.hasPanel(panel)){
35260 this.showPanel(panel);
35263 var el = panel.getEl();
35264 if(el.dom.parentNode != this.mgr.el.dom){
35265 this.mgr.el.dom.appendChild(el.dom);
35267 if(panel.setRegion){
35268 panel.setRegion(this);
35270 this.panels.add(panel);
35271 el.setStyle("position", "absolute");
35272 if(!panel.background){
35273 this.setActivePanel(panel);
35274 if(this.config.initialSize && this.panels.getCount()==1){
35275 this.resizeTo(this.config.initialSize);
35278 this.fireEvent("paneladded", this, panel);
35283 * Returns true if the panel is in this region.
35284 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35285 * @return {Boolean}
35287 hasPanel : function(panel){
35288 if(typeof panel == "object"){ // must be panel obj
35289 panel = panel.getId();
35291 return this.getPanel(panel) ? true : false;
35295 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35296 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35297 * @param {Boolean} preservePanel Overrides the config preservePanel option
35298 * @return {Roo.ContentPanel} The panel that was removed
35300 remove : function(panel, preservePanel){
35301 panel = this.getPanel(panel);
35306 this.fireEvent("beforeremove", this, panel, e);
35307 if(e.cancel === true){
35310 var panelId = panel.getId();
35311 this.panels.removeKey(panelId);
35316 * Returns the panel specified or null if it's not in this region.
35317 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35318 * @return {Roo.ContentPanel}
35320 getPanel : function(id){
35321 if(typeof id == "object"){ // must be panel obj
35324 return this.panels.get(id);
35328 * Returns this regions position (north/south/east/west/center).
35331 getPosition: function(){
35332 return this.position;
35336 * Ext JS Library 1.1.1
35337 * Copyright(c) 2006-2007, Ext JS, LLC.
35339 * Originally Released Under LGPL - original licence link has changed is not relivant.
35342 * <script type="text/javascript">
35346 * @class Roo.bootstrap.layout.Region
35347 * @extends Roo.bootstrap.layout.Basic
35348 * This class represents a region in a layout manager.
35350 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35351 * @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})
35352 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35353 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35354 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35355 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35356 * @cfg {String} title The title for the region (overrides panel titles)
35357 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35358 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35359 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35360 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35361 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35362 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35363 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35364 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35365 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35366 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35368 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35369 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35370 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35371 * @cfg {Number} width For East/West panels
35372 * @cfg {Number} height For North/South panels
35373 * @cfg {Boolean} split To show the splitter
35374 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35376 * @cfg {string} cls Extra CSS classes to add to region
35378 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35379 * @cfg {string} region the region that it inhabits..
35382 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35383 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35385 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35386 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35387 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35389 Roo.bootstrap.layout.Region = function(config)
35391 this.applyConfig(config);
35393 var mgr = config.mgr;
35394 var pos = config.region;
35395 config.skipConfig = true;
35396 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35399 this.onRender(mgr.el);
35402 this.visible = true;
35403 this.collapsed = false;
35404 this.unrendered_panels = [];
35407 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35409 position: '', // set by wrapper (eg. north/south etc..)
35410 unrendered_panels : null, // unrendered panels.
35411 createBody : function(){
35412 /** This region's body element
35413 * @type Roo.Element */
35414 this.bodyEl = this.el.createChild({
35416 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35420 onRender: function(ctr, pos)
35422 var dh = Roo.DomHelper;
35423 /** This region's container element
35424 * @type Roo.Element */
35425 this.el = dh.append(ctr.dom, {
35427 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35429 /** This region's title element
35430 * @type Roo.Element */
35432 this.titleEl = dh.append(this.el.dom,
35435 unselectable: "on",
35436 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35438 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35439 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35442 this.titleEl.enableDisplayMode();
35443 /** This region's title text element
35444 * @type HTMLElement */
35445 this.titleTextEl = this.titleEl.dom.firstChild;
35446 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35448 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35449 this.closeBtn.enableDisplayMode();
35450 this.closeBtn.on("click", this.closeClicked, this);
35451 this.closeBtn.hide();
35453 this.createBody(this.config);
35454 if(this.config.hideWhenEmpty){
35456 this.on("paneladded", this.validateVisibility, this);
35457 this.on("panelremoved", this.validateVisibility, this);
35459 if(this.autoScroll){
35460 this.bodyEl.setStyle("overflow", "auto");
35462 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35464 //if(c.titlebar !== false){
35465 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35466 this.titleEl.hide();
35468 this.titleEl.show();
35469 if(this.config.title){
35470 this.titleTextEl.innerHTML = this.config.title;
35474 if(this.config.collapsed){
35475 this.collapse(true);
35477 if(this.config.hidden){
35481 if (this.unrendered_panels && this.unrendered_panels.length) {
35482 for (var i =0;i< this.unrendered_panels.length; i++) {
35483 this.add(this.unrendered_panels[i]);
35485 this.unrendered_panels = null;
35491 applyConfig : function(c)
35494 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35495 var dh = Roo.DomHelper;
35496 if(c.titlebar !== false){
35497 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35498 this.collapseBtn.on("click", this.collapse, this);
35499 this.collapseBtn.enableDisplayMode();
35501 if(c.showPin === true || this.showPin){
35502 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35503 this.stickBtn.enableDisplayMode();
35504 this.stickBtn.on("click", this.expand, this);
35505 this.stickBtn.hide();
35510 /** This region's collapsed element
35511 * @type Roo.Element */
35514 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35515 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35518 if(c.floatable !== false){
35519 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35520 this.collapsedEl.on("click", this.collapseClick, this);
35523 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35524 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35525 id: "message", unselectable: "on", style:{"float":"left"}});
35526 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35528 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35529 this.expandBtn.on("click", this.expand, this);
35533 if(this.collapseBtn){
35534 this.collapseBtn.setVisible(c.collapsible == true);
35537 this.cmargins = c.cmargins || this.cmargins ||
35538 (this.position == "west" || this.position == "east" ?
35539 {top: 0, left: 2, right:2, bottom: 0} :
35540 {top: 2, left: 0, right:0, bottom: 2});
35542 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35545 this.bottomTabs = c.tabPosition != "top";
35547 this.autoScroll = c.autoScroll || false;
35552 this.duration = c.duration || .30;
35553 this.slideDuration = c.slideDuration || .45;
35558 * Returns true if this region is currently visible.
35559 * @return {Boolean}
35561 isVisible : function(){
35562 return this.visible;
35566 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35567 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35569 //setCollapsedTitle : function(title){
35570 // title = title || " ";
35571 // if(this.collapsedTitleTextEl){
35572 // this.collapsedTitleTextEl.innerHTML = title;
35576 getBox : function(){
35578 // if(!this.collapsed){
35579 b = this.el.getBox(false, true);
35581 // b = this.collapsedEl.getBox(false, true);
35586 getMargins : function(){
35587 return this.margins;
35588 //return this.collapsed ? this.cmargins : this.margins;
35591 highlight : function(){
35592 this.el.addClass("x-layout-panel-dragover");
35595 unhighlight : function(){
35596 this.el.removeClass("x-layout-panel-dragover");
35599 updateBox : function(box)
35601 if (!this.bodyEl) {
35602 return; // not rendered yet..
35606 if(!this.collapsed){
35607 this.el.dom.style.left = box.x + "px";
35608 this.el.dom.style.top = box.y + "px";
35609 this.updateBody(box.width, box.height);
35611 this.collapsedEl.dom.style.left = box.x + "px";
35612 this.collapsedEl.dom.style.top = box.y + "px";
35613 this.collapsedEl.setSize(box.width, box.height);
35616 this.tabs.autoSizeTabs();
35620 updateBody : function(w, h)
35623 this.el.setWidth(w);
35624 w -= this.el.getBorderWidth("rl");
35625 if(this.config.adjustments){
35626 w += this.config.adjustments[0];
35629 if(h !== null && h > 0){
35630 this.el.setHeight(h);
35631 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35632 h -= this.el.getBorderWidth("tb");
35633 if(this.config.adjustments){
35634 h += this.config.adjustments[1];
35636 this.bodyEl.setHeight(h);
35638 h = this.tabs.syncHeight(h);
35641 if(this.panelSize){
35642 w = w !== null ? w : this.panelSize.width;
35643 h = h !== null ? h : this.panelSize.height;
35645 if(this.activePanel){
35646 var el = this.activePanel.getEl();
35647 w = w !== null ? w : el.getWidth();
35648 h = h !== null ? h : el.getHeight();
35649 this.panelSize = {width: w, height: h};
35650 this.activePanel.setSize(w, h);
35652 if(Roo.isIE && this.tabs){
35653 this.tabs.el.repaint();
35658 * Returns the container element for this region.
35659 * @return {Roo.Element}
35661 getEl : function(){
35666 * Hides this region.
35669 //if(!this.collapsed){
35670 this.el.dom.style.left = "-2000px";
35673 // this.collapsedEl.dom.style.left = "-2000px";
35674 // this.collapsedEl.hide();
35676 this.visible = false;
35677 this.fireEvent("visibilitychange", this, false);
35681 * Shows this region if it was previously hidden.
35684 //if(!this.collapsed){
35687 // this.collapsedEl.show();
35689 this.visible = true;
35690 this.fireEvent("visibilitychange", this, true);
35693 closeClicked : function(){
35694 if(this.activePanel){
35695 this.remove(this.activePanel);
35699 collapseClick : function(e){
35701 e.stopPropagation();
35704 e.stopPropagation();
35710 * Collapses this region.
35711 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
35714 collapse : function(skipAnim, skipCheck = false){
35715 if(this.collapsed) {
35719 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
35721 this.collapsed = true;
35723 this.split.el.hide();
35725 if(this.config.animate && skipAnim !== true){
35726 this.fireEvent("invalidated", this);
35727 this.animateCollapse();
35729 this.el.setLocation(-20000,-20000);
35731 this.collapsedEl.show();
35732 this.fireEvent("collapsed", this);
35733 this.fireEvent("invalidated", this);
35739 animateCollapse : function(){
35744 * Expands this region if it was previously collapsed.
35745 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
35746 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
35749 expand : function(e, skipAnim){
35751 e.stopPropagation();
35753 if(!this.collapsed || this.el.hasActiveFx()) {
35757 this.afterSlideIn();
35760 this.collapsed = false;
35761 if(this.config.animate && skipAnim !== true){
35762 this.animateExpand();
35766 this.split.el.show();
35768 this.collapsedEl.setLocation(-2000,-2000);
35769 this.collapsedEl.hide();
35770 this.fireEvent("invalidated", this);
35771 this.fireEvent("expanded", this);
35775 animateExpand : function(){
35779 initTabs : function()
35781 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
35783 var ts = new Roo.bootstrap.panel.Tabs({
35784 el: this.bodyEl.dom,
35785 tabPosition: this.bottomTabs ? 'bottom' : 'top',
35786 disableTooltips: this.config.disableTabTips,
35787 toolbar : this.config.toolbar
35790 if(this.config.hideTabs){
35791 ts.stripWrap.setDisplayed(false);
35794 ts.resizeTabs = this.config.resizeTabs === true;
35795 ts.minTabWidth = this.config.minTabWidth || 40;
35796 ts.maxTabWidth = this.config.maxTabWidth || 250;
35797 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
35798 ts.monitorResize = false;
35799 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
35800 ts.bodyEl.addClass('roo-layout-tabs-body');
35801 this.panels.each(this.initPanelAsTab, this);
35804 initPanelAsTab : function(panel){
35805 var ti = this.tabs.addTab(
35809 this.config.closeOnTab && panel.isClosable(),
35812 if(panel.tabTip !== undefined){
35813 ti.setTooltip(panel.tabTip);
35815 ti.on("activate", function(){
35816 this.setActivePanel(panel);
35819 if(this.config.closeOnTab){
35820 ti.on("beforeclose", function(t, e){
35822 this.remove(panel);
35826 panel.tabItem = ti;
35831 updatePanelTitle : function(panel, title)
35833 if(this.activePanel == panel){
35834 this.updateTitle(title);
35837 var ti = this.tabs.getTab(panel.getEl().id);
35839 if(panel.tabTip !== undefined){
35840 ti.setTooltip(panel.tabTip);
35845 updateTitle : function(title){
35846 if(this.titleTextEl && !this.config.title){
35847 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
35851 setActivePanel : function(panel)
35853 panel = this.getPanel(panel);
35854 if(this.activePanel && this.activePanel != panel){
35855 if(this.activePanel.setActiveState(false) === false){
35859 this.activePanel = panel;
35860 panel.setActiveState(true);
35861 if(this.panelSize){
35862 panel.setSize(this.panelSize.width, this.panelSize.height);
35865 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
35867 this.updateTitle(panel.getTitle());
35869 this.fireEvent("invalidated", this);
35871 this.fireEvent("panelactivated", this, panel);
35875 * Shows the specified panel.
35876 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
35877 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
35879 showPanel : function(panel)
35881 panel = this.getPanel(panel);
35884 var tab = this.tabs.getTab(panel.getEl().id);
35885 if(tab.isHidden()){
35886 this.tabs.unhideTab(tab.id);
35890 this.setActivePanel(panel);
35897 * Get the active panel for this region.
35898 * @return {Roo.ContentPanel} The active panel or null
35900 getActivePanel : function(){
35901 return this.activePanel;
35904 validateVisibility : function(){
35905 if(this.panels.getCount() < 1){
35906 this.updateTitle(" ");
35907 this.closeBtn.hide();
35910 if(!this.isVisible()){
35917 * Adds the passed ContentPanel(s) to this region.
35918 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35919 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
35921 add : function(panel)
35923 if(arguments.length > 1){
35924 for(var i = 0, len = arguments.length; i < len; i++) {
35925 this.add(arguments[i]);
35930 // if we have not been rendered yet, then we can not really do much of this..
35931 if (!this.bodyEl) {
35932 this.unrendered_panels.push(panel);
35939 if(this.hasPanel(panel)){
35940 this.showPanel(panel);
35943 panel.setRegion(this);
35944 this.panels.add(panel);
35945 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
35946 // sinle panel - no tab...?? would it not be better to render it with the tabs,
35947 // and hide them... ???
35948 this.bodyEl.dom.appendChild(panel.getEl().dom);
35949 if(panel.background !== true){
35950 this.setActivePanel(panel);
35952 this.fireEvent("paneladded", this, panel);
35959 this.initPanelAsTab(panel);
35963 if(panel.background !== true){
35964 this.tabs.activate(panel.getEl().id);
35966 this.fireEvent("paneladded", this, panel);
35971 * Hides the tab for the specified panel.
35972 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35974 hidePanel : function(panel){
35975 if(this.tabs && (panel = this.getPanel(panel))){
35976 this.tabs.hideTab(panel.getEl().id);
35981 * Unhides the tab for a previously hidden panel.
35982 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35984 unhidePanel : function(panel){
35985 if(this.tabs && (panel = this.getPanel(panel))){
35986 this.tabs.unhideTab(panel.getEl().id);
35990 clearPanels : function(){
35991 while(this.panels.getCount() > 0){
35992 this.remove(this.panels.first());
35997 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35998 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
35999 * @param {Boolean} preservePanel Overrides the config preservePanel option
36000 * @return {Roo.ContentPanel} The panel that was removed
36002 remove : function(panel, preservePanel)
36004 panel = this.getPanel(panel);
36009 this.fireEvent("beforeremove", this, panel, e);
36010 if(e.cancel === true){
36013 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36014 var panelId = panel.getId();
36015 this.panels.removeKey(panelId);
36017 document.body.appendChild(panel.getEl().dom);
36020 this.tabs.removeTab(panel.getEl().id);
36021 }else if (!preservePanel){
36022 this.bodyEl.dom.removeChild(panel.getEl().dom);
36024 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36025 var p = this.panels.first();
36026 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36027 tempEl.appendChild(p.getEl().dom);
36028 this.bodyEl.update("");
36029 this.bodyEl.dom.appendChild(p.getEl().dom);
36031 this.updateTitle(p.getTitle());
36033 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36034 this.setActivePanel(p);
36036 panel.setRegion(null);
36037 if(this.activePanel == panel){
36038 this.activePanel = null;
36040 if(this.config.autoDestroy !== false && preservePanel !== true){
36041 try{panel.destroy();}catch(e){}
36043 this.fireEvent("panelremoved", this, panel);
36048 * Returns the TabPanel component used by this region
36049 * @return {Roo.TabPanel}
36051 getTabs : function(){
36055 createTool : function(parentEl, className){
36056 var btn = Roo.DomHelper.append(parentEl, {
36058 cls: "x-layout-tools-button",
36061 cls: "roo-layout-tools-button-inner " + className,
36065 btn.addClassOnOver("roo-layout-tools-button-over");
36070 * Ext JS Library 1.1.1
36071 * Copyright(c) 2006-2007, Ext JS, LLC.
36073 * Originally Released Under LGPL - original licence link has changed is not relivant.
36076 * <script type="text/javascript">
36082 * @class Roo.SplitLayoutRegion
36083 * @extends Roo.LayoutRegion
36084 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36086 Roo.bootstrap.layout.Split = function(config){
36087 this.cursor = config.cursor;
36088 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36091 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36093 splitTip : "Drag to resize.",
36094 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36095 useSplitTips : false,
36097 applyConfig : function(config){
36098 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36101 onRender : function(ctr,pos) {
36103 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36104 if(!this.config.split){
36109 var splitEl = Roo.DomHelper.append(ctr.dom, {
36111 id: this.el.id + "-split",
36112 cls: "roo-layout-split roo-layout-split-"+this.position,
36115 /** The SplitBar for this region
36116 * @type Roo.SplitBar */
36117 // does not exist yet...
36118 Roo.log([this.position, this.orientation]);
36120 this.split = new Roo.bootstrap.SplitBar({
36121 dragElement : splitEl,
36122 resizingElement: this.el,
36123 orientation : this.orientation
36126 this.split.on("moved", this.onSplitMove, this);
36127 this.split.useShim = this.config.useShim === true;
36128 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36129 if(this.useSplitTips){
36130 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36132 //if(config.collapsible){
36133 // this.split.el.on("dblclick", this.collapse, this);
36136 if(typeof this.config.minSize != "undefined"){
36137 this.split.minSize = this.config.minSize;
36139 if(typeof this.config.maxSize != "undefined"){
36140 this.split.maxSize = this.config.maxSize;
36142 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36143 this.hideSplitter();
36148 getHMaxSize : function(){
36149 var cmax = this.config.maxSize || 10000;
36150 var center = this.mgr.getRegion("center");
36151 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36154 getVMaxSize : function(){
36155 var cmax = this.config.maxSize || 10000;
36156 var center = this.mgr.getRegion("center");
36157 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36160 onSplitMove : function(split, newSize){
36161 this.fireEvent("resized", this, newSize);
36165 * Returns the {@link Roo.SplitBar} for this region.
36166 * @return {Roo.SplitBar}
36168 getSplitBar : function(){
36173 this.hideSplitter();
36174 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36177 hideSplitter : function(){
36179 this.split.el.setLocation(-2000,-2000);
36180 this.split.el.hide();
36186 this.split.el.show();
36188 Roo.bootstrap.layout.Split.superclass.show.call(this);
36191 beforeSlide: function(){
36192 if(Roo.isGecko){// firefox overflow auto bug workaround
36193 this.bodyEl.clip();
36195 this.tabs.bodyEl.clip();
36197 if(this.activePanel){
36198 this.activePanel.getEl().clip();
36200 if(this.activePanel.beforeSlide){
36201 this.activePanel.beforeSlide();
36207 afterSlide : function(){
36208 if(Roo.isGecko){// firefox overflow auto bug workaround
36209 this.bodyEl.unclip();
36211 this.tabs.bodyEl.unclip();
36213 if(this.activePanel){
36214 this.activePanel.getEl().unclip();
36215 if(this.activePanel.afterSlide){
36216 this.activePanel.afterSlide();
36222 initAutoHide : function(){
36223 if(this.autoHide !== false){
36224 if(!this.autoHideHd){
36225 var st = new Roo.util.DelayedTask(this.slideIn, this);
36226 this.autoHideHd = {
36227 "mouseout": function(e){
36228 if(!e.within(this.el, true)){
36232 "mouseover" : function(e){
36238 this.el.on(this.autoHideHd);
36242 clearAutoHide : function(){
36243 if(this.autoHide !== false){
36244 this.el.un("mouseout", this.autoHideHd.mouseout);
36245 this.el.un("mouseover", this.autoHideHd.mouseover);
36249 clearMonitor : function(){
36250 Roo.get(document).un("click", this.slideInIf, this);
36253 // these names are backwards but not changed for compat
36254 slideOut : function(){
36255 if(this.isSlid || this.el.hasActiveFx()){
36258 this.isSlid = true;
36259 if(this.collapseBtn){
36260 this.collapseBtn.hide();
36262 this.closeBtnState = this.closeBtn.getStyle('display');
36263 this.closeBtn.hide();
36265 this.stickBtn.show();
36268 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36269 this.beforeSlide();
36270 this.el.setStyle("z-index", 10001);
36271 this.el.slideIn(this.getSlideAnchor(), {
36272 callback: function(){
36274 this.initAutoHide();
36275 Roo.get(document).on("click", this.slideInIf, this);
36276 this.fireEvent("slideshow", this);
36283 afterSlideIn : function(){
36284 this.clearAutoHide();
36285 this.isSlid = false;
36286 this.clearMonitor();
36287 this.el.setStyle("z-index", "");
36288 if(this.collapseBtn){
36289 this.collapseBtn.show();
36291 this.closeBtn.setStyle('display', this.closeBtnState);
36293 this.stickBtn.hide();
36295 this.fireEvent("slidehide", this);
36298 slideIn : function(cb){
36299 if(!this.isSlid || this.el.hasActiveFx()){
36303 this.isSlid = false;
36304 this.beforeSlide();
36305 this.el.slideOut(this.getSlideAnchor(), {
36306 callback: function(){
36307 this.el.setLeftTop(-10000, -10000);
36309 this.afterSlideIn();
36317 slideInIf : function(e){
36318 if(!e.within(this.el)){
36323 animateCollapse : function(){
36324 this.beforeSlide();
36325 this.el.setStyle("z-index", 20000);
36326 var anchor = this.getSlideAnchor();
36327 this.el.slideOut(anchor, {
36328 callback : function(){
36329 this.el.setStyle("z-index", "");
36330 this.collapsedEl.slideIn(anchor, {duration:.3});
36332 this.el.setLocation(-10000,-10000);
36334 this.fireEvent("collapsed", this);
36341 animateExpand : function(){
36342 this.beforeSlide();
36343 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36344 this.el.setStyle("z-index", 20000);
36345 this.collapsedEl.hide({
36348 this.el.slideIn(this.getSlideAnchor(), {
36349 callback : function(){
36350 this.el.setStyle("z-index", "");
36353 this.split.el.show();
36355 this.fireEvent("invalidated", this);
36356 this.fireEvent("expanded", this);
36384 getAnchor : function(){
36385 return this.anchors[this.position];
36388 getCollapseAnchor : function(){
36389 return this.canchors[this.position];
36392 getSlideAnchor : function(){
36393 return this.sanchors[this.position];
36396 getAlignAdj : function(){
36397 var cm = this.cmargins;
36398 switch(this.position){
36414 getExpandAdj : function(){
36415 var c = this.collapsedEl, cm = this.cmargins;
36416 switch(this.position){
36418 return [-(cm.right+c.getWidth()+cm.left), 0];
36421 return [cm.right+c.getWidth()+cm.left, 0];
36424 return [0, -(cm.top+cm.bottom+c.getHeight())];
36427 return [0, cm.top+cm.bottom+c.getHeight()];
36433 * Ext JS Library 1.1.1
36434 * Copyright(c) 2006-2007, Ext JS, LLC.
36436 * Originally Released Under LGPL - original licence link has changed is not relivant.
36439 * <script type="text/javascript">
36442 * These classes are private internal classes
36444 Roo.bootstrap.layout.Center = function(config){
36445 config.region = "center";
36446 Roo.bootstrap.layout.Region.call(this, config);
36447 this.visible = true;
36448 this.minWidth = config.minWidth || 20;
36449 this.minHeight = config.minHeight || 20;
36452 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36454 // center panel can't be hidden
36458 // center panel can't be hidden
36461 getMinWidth: function(){
36462 return this.minWidth;
36465 getMinHeight: function(){
36466 return this.minHeight;
36479 Roo.bootstrap.layout.North = function(config)
36481 config.region = 'north';
36482 config.cursor = 'n-resize';
36484 Roo.bootstrap.layout.Split.call(this, config);
36488 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36489 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36490 this.split.el.addClass("roo-layout-split-v");
36492 var size = config.initialSize || config.height;
36493 if(typeof size != "undefined"){
36494 this.el.setHeight(size);
36497 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36499 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36503 getBox : function(){
36504 if(this.collapsed){
36505 return this.collapsedEl.getBox();
36507 var box = this.el.getBox();
36509 box.height += this.split.el.getHeight();
36514 updateBox : function(box){
36515 if(this.split && !this.collapsed){
36516 box.height -= this.split.el.getHeight();
36517 this.split.el.setLeft(box.x);
36518 this.split.el.setTop(box.y+box.height);
36519 this.split.el.setWidth(box.width);
36521 if(this.collapsed){
36522 this.updateBody(box.width, null);
36524 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36532 Roo.bootstrap.layout.South = function(config){
36533 config.region = 'south';
36534 config.cursor = 's-resize';
36535 Roo.bootstrap.layout.Split.call(this, config);
36537 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36538 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36539 this.split.el.addClass("roo-layout-split-v");
36541 var size = config.initialSize || config.height;
36542 if(typeof size != "undefined"){
36543 this.el.setHeight(size);
36547 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36548 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36549 getBox : function(){
36550 if(this.collapsed){
36551 return this.collapsedEl.getBox();
36553 var box = this.el.getBox();
36555 var sh = this.split.el.getHeight();
36562 updateBox : function(box){
36563 if(this.split && !this.collapsed){
36564 var sh = this.split.el.getHeight();
36567 this.split.el.setLeft(box.x);
36568 this.split.el.setTop(box.y-sh);
36569 this.split.el.setWidth(box.width);
36571 if(this.collapsed){
36572 this.updateBody(box.width, null);
36574 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36578 Roo.bootstrap.layout.East = function(config){
36579 config.region = "east";
36580 config.cursor = "e-resize";
36581 Roo.bootstrap.layout.Split.call(this, config);
36583 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36584 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36585 this.split.el.addClass("roo-layout-split-h");
36587 var size = config.initialSize || config.width;
36588 if(typeof size != "undefined"){
36589 this.el.setWidth(size);
36592 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36593 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36594 getBox : function(){
36595 if(this.collapsed){
36596 return this.collapsedEl.getBox();
36598 var box = this.el.getBox();
36600 var sw = this.split.el.getWidth();
36607 updateBox : function(box){
36608 if(this.split && !this.collapsed){
36609 var sw = this.split.el.getWidth();
36611 this.split.el.setLeft(box.x);
36612 this.split.el.setTop(box.y);
36613 this.split.el.setHeight(box.height);
36616 if(this.collapsed){
36617 this.updateBody(null, box.height);
36619 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36623 Roo.bootstrap.layout.West = function(config){
36624 config.region = "west";
36625 config.cursor = "w-resize";
36627 Roo.bootstrap.layout.Split.call(this, config);
36629 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36630 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36631 this.split.el.addClass("roo-layout-split-h");
36635 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36636 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36638 onRender: function(ctr, pos)
36640 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36641 var size = this.config.initialSize || this.config.width;
36642 if(typeof size != "undefined"){
36643 this.el.setWidth(size);
36647 getBox : function(){
36648 if(this.collapsed){
36649 return this.collapsedEl.getBox();
36651 var box = this.el.getBox();
36653 box.width += this.split.el.getWidth();
36658 updateBox : function(box){
36659 if(this.split && !this.collapsed){
36660 var sw = this.split.el.getWidth();
36662 this.split.el.setLeft(box.x+box.width);
36663 this.split.el.setTop(box.y);
36664 this.split.el.setHeight(box.height);
36666 if(this.collapsed){
36667 this.updateBody(null, box.height);
36669 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36672 Roo.namespace("Roo.bootstrap.panel");/*
36674 * Ext JS Library 1.1.1
36675 * Copyright(c) 2006-2007, Ext JS, LLC.
36677 * Originally Released Under LGPL - original licence link has changed is not relivant.
36680 * <script type="text/javascript">
36683 * @class Roo.ContentPanel
36684 * @extends Roo.util.Observable
36685 * A basic ContentPanel element.
36686 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
36687 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
36688 * @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
36689 * @cfg {Boolean} closable True if the panel can be closed/removed
36690 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
36691 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
36692 * @cfg {Toolbar} toolbar A toolbar for this panel
36693 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
36694 * @cfg {String} title The title for this panel
36695 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
36696 * @cfg {String} url Calls {@link #setUrl} with this value
36697 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
36698 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
36699 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
36700 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
36701 * @cfg {Boolean} badges render the badges
36704 * Create a new ContentPanel.
36705 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
36706 * @param {String/Object} config A string to set only the title or a config object
36707 * @param {String} content (optional) Set the HTML content for this panel
36708 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
36710 Roo.bootstrap.panel.Content = function( config){
36712 this.tpl = config.tpl || false;
36714 var el = config.el;
36715 var content = config.content;
36717 if(config.autoCreate){ // xtype is available if this is called from factory
36720 this.el = Roo.get(el);
36721 if(!this.el && config && config.autoCreate){
36722 if(typeof config.autoCreate == "object"){
36723 if(!config.autoCreate.id){
36724 config.autoCreate.id = config.id||el;
36726 this.el = Roo.DomHelper.append(document.body,
36727 config.autoCreate, true);
36729 var elcfg = { tag: "div",
36730 cls: "roo-layout-inactive-content",
36734 elcfg.html = config.html;
36738 this.el = Roo.DomHelper.append(document.body, elcfg , true);
36741 this.closable = false;
36742 this.loaded = false;
36743 this.active = false;
36746 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
36748 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
36750 this.wrapEl = this.el; //this.el.wrap();
36752 if (config.toolbar.items) {
36753 ti = config.toolbar.items ;
36754 delete config.toolbar.items ;
36758 this.toolbar.render(this.wrapEl, 'before');
36759 for(var i =0;i < ti.length;i++) {
36760 // Roo.log(['add child', items[i]]);
36761 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36763 this.toolbar.items = nitems;
36764 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
36765 delete config.toolbar;
36769 // xtype created footer. - not sure if will work as we normally have to render first..
36770 if (this.footer && !this.footer.el && this.footer.xtype) {
36771 if (!this.wrapEl) {
36772 this.wrapEl = this.el.wrap();
36775 this.footer.container = this.wrapEl.createChild();
36777 this.footer = Roo.factory(this.footer, Roo);
36782 if(typeof config == "string"){
36783 this.title = config;
36785 Roo.apply(this, config);
36789 this.resizeEl = Roo.get(this.resizeEl, true);
36791 this.resizeEl = this.el;
36793 // handle view.xtype
36801 * Fires when this panel is activated.
36802 * @param {Roo.ContentPanel} this
36806 * @event deactivate
36807 * Fires when this panel is activated.
36808 * @param {Roo.ContentPanel} this
36810 "deactivate" : true,
36814 * Fires when this panel is resized if fitToFrame is true.
36815 * @param {Roo.ContentPanel} this
36816 * @param {Number} width The width after any component adjustments
36817 * @param {Number} height The height after any component adjustments
36823 * Fires when this tab is created
36824 * @param {Roo.ContentPanel} this
36835 if(this.autoScroll){
36836 this.resizeEl.setStyle("overflow", "auto");
36838 // fix randome scrolling
36839 //this.el.on('scroll', function() {
36840 // Roo.log('fix random scolling');
36841 // this.scrollTo('top',0);
36844 content = content || this.content;
36846 this.setContent(content);
36848 if(config && config.url){
36849 this.setUrl(this.url, this.params, this.loadOnce);
36854 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
36856 if (this.view && typeof(this.view.xtype) != 'undefined') {
36857 this.view.el = this.el.appendChild(document.createElement("div"));
36858 this.view = Roo.factory(this.view);
36859 this.view.render && this.view.render(false, '');
36863 this.fireEvent('render', this);
36866 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
36870 setRegion : function(region){
36871 this.region = region;
36872 this.setActiveClass(region && !this.background);
36876 setActiveClass: function(state)
36879 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
36880 this.el.setStyle('position','relative');
36882 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
36883 this.el.setStyle('position', 'absolute');
36888 * Returns the toolbar for this Panel if one was configured.
36889 * @return {Roo.Toolbar}
36891 getToolbar : function(){
36892 return this.toolbar;
36895 setActiveState : function(active)
36897 this.active = active;
36898 this.setActiveClass(active);
36900 if(this.fireEvent("deactivate", this) === false){
36905 this.fireEvent("activate", this);
36909 * Updates this panel's element
36910 * @param {String} content The new content
36911 * @param {Boolean} loadScripts (optional) true to look for and process scripts
36913 setContent : function(content, loadScripts){
36914 this.el.update(content, loadScripts);
36917 ignoreResize : function(w, h){
36918 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
36921 this.lastSize = {width: w, height: h};
36926 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
36927 * @return {Roo.UpdateManager} The UpdateManager
36929 getUpdateManager : function(){
36930 return this.el.getUpdateManager();
36933 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
36934 * @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:
36937 url: "your-url.php",
36938 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
36939 callback: yourFunction,
36940 scope: yourObject, //(optional scope)
36943 text: "Loading...",
36948 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
36949 * 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.
36950 * @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}
36951 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
36952 * @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.
36953 * @return {Roo.ContentPanel} this
36956 var um = this.el.getUpdateManager();
36957 um.update.apply(um, arguments);
36963 * 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.
36964 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
36965 * @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)
36966 * @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)
36967 * @return {Roo.UpdateManager} The UpdateManager
36969 setUrl : function(url, params, loadOnce){
36970 if(this.refreshDelegate){
36971 this.removeListener("activate", this.refreshDelegate);
36973 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
36974 this.on("activate", this.refreshDelegate);
36975 return this.el.getUpdateManager();
36978 _handleRefresh : function(url, params, loadOnce){
36979 if(!loadOnce || !this.loaded){
36980 var updater = this.el.getUpdateManager();
36981 updater.update(url, params, this._setLoaded.createDelegate(this));
36985 _setLoaded : function(){
36986 this.loaded = true;
36990 * Returns this panel's id
36993 getId : function(){
36998 * Returns this panel's element - used by regiosn to add.
36999 * @return {Roo.Element}
37001 getEl : function(){
37002 return this.wrapEl || this.el;
37007 adjustForComponents : function(width, height)
37009 //Roo.log('adjustForComponents ');
37010 if(this.resizeEl != this.el){
37011 width -= this.el.getFrameWidth('lr');
37012 height -= this.el.getFrameWidth('tb');
37015 var te = this.toolbar.getEl();
37016 te.setWidth(width);
37017 height -= te.getHeight();
37020 var te = this.footer.getEl();
37021 te.setWidth(width);
37022 height -= te.getHeight();
37026 if(this.adjustments){
37027 width += this.adjustments[0];
37028 height += this.adjustments[1];
37030 return {"width": width, "height": height};
37033 setSize : function(width, height){
37034 if(this.fitToFrame && !this.ignoreResize(width, height)){
37035 if(this.fitContainer && this.resizeEl != this.el){
37036 this.el.setSize(width, height);
37038 var size = this.adjustForComponents(width, height);
37039 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37040 this.fireEvent('resize', this, size.width, size.height);
37045 * Returns this panel's title
37048 getTitle : function(){
37050 if (typeof(this.title) != 'object') {
37055 for (var k in this.title) {
37056 if (!this.title.hasOwnProperty(k)) {
37060 if (k.indexOf('-') >= 0) {
37061 var s = k.split('-');
37062 for (var i = 0; i<s.length; i++) {
37063 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37066 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37073 * Set this panel's title
37074 * @param {String} title
37076 setTitle : function(title){
37077 this.title = title;
37079 this.region.updatePanelTitle(this, title);
37084 * Returns true is this panel was configured to be closable
37085 * @return {Boolean}
37087 isClosable : function(){
37088 return this.closable;
37091 beforeSlide : function(){
37093 this.resizeEl.clip();
37096 afterSlide : function(){
37098 this.resizeEl.unclip();
37102 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37103 * Will fail silently if the {@link #setUrl} method has not been called.
37104 * This does not activate the panel, just updates its content.
37106 refresh : function(){
37107 if(this.refreshDelegate){
37108 this.loaded = false;
37109 this.refreshDelegate();
37114 * Destroys this panel
37116 destroy : function(){
37117 this.el.removeAllListeners();
37118 var tempEl = document.createElement("span");
37119 tempEl.appendChild(this.el.dom);
37120 tempEl.innerHTML = "";
37126 * form - if the content panel contains a form - this is a reference to it.
37127 * @type {Roo.form.Form}
37131 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37132 * This contains a reference to it.
37138 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37148 * @param {Object} cfg Xtype definition of item to add.
37152 getChildContainer: function () {
37153 return this.getEl();
37158 var ret = new Roo.factory(cfg);
37163 if (cfg.xtype.match(/^Form$/)) {
37166 //if (this.footer) {
37167 // el = this.footer.container.insertSibling(false, 'before');
37169 el = this.el.createChild();
37172 this.form = new Roo.form.Form(cfg);
37175 if ( this.form.allItems.length) {
37176 this.form.render(el.dom);
37180 // should only have one of theses..
37181 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37182 // views.. should not be just added - used named prop 'view''
37184 cfg.el = this.el.appendChild(document.createElement("div"));
37187 var ret = new Roo.factory(cfg);
37189 ret.render && ret.render(false, ''); // render blank..
37199 * @class Roo.bootstrap.panel.Grid
37200 * @extends Roo.bootstrap.panel.Content
37202 * Create a new GridPanel.
37203 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37204 * @param {Object} config A the config object
37210 Roo.bootstrap.panel.Grid = function(config)
37214 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37215 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37217 config.el = this.wrapper;
37218 //this.el = this.wrapper;
37220 if (config.container) {
37221 // ctor'ed from a Border/panel.grid
37224 this.wrapper.setStyle("overflow", "hidden");
37225 this.wrapper.addClass('roo-grid-container');
37230 if(config.toolbar){
37231 var tool_el = this.wrapper.createChild();
37232 this.toolbar = Roo.factory(config.toolbar);
37234 if (config.toolbar.items) {
37235 ti = config.toolbar.items ;
37236 delete config.toolbar.items ;
37240 this.toolbar.render(tool_el);
37241 for(var i =0;i < ti.length;i++) {
37242 // Roo.log(['add child', items[i]]);
37243 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37245 this.toolbar.items = nitems;
37247 delete config.toolbar;
37250 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37251 config.grid.scrollBody = true;;
37252 config.grid.monitorWindowResize = false; // turn off autosizing
37253 config.grid.autoHeight = false;
37254 config.grid.autoWidth = false;
37256 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37258 if (config.background) {
37259 // render grid on panel activation (if panel background)
37260 this.on('activate', function(gp) {
37261 if (!gp.grid.rendered) {
37262 gp.grid.render(this.wrapper);
37263 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37268 this.grid.render(this.wrapper);
37269 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37272 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37273 // ??? needed ??? config.el = this.wrapper;
37278 // xtype created footer. - not sure if will work as we normally have to render first..
37279 if (this.footer && !this.footer.el && this.footer.xtype) {
37281 var ctr = this.grid.getView().getFooterPanel(true);
37282 this.footer.dataSource = this.grid.dataSource;
37283 this.footer = Roo.factory(this.footer, Roo);
37284 this.footer.render(ctr);
37294 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37295 getId : function(){
37296 return this.grid.id;
37300 * Returns the grid for this panel
37301 * @return {Roo.bootstrap.Table}
37303 getGrid : function(){
37307 setSize : function(width, height){
37308 if(!this.ignoreResize(width, height)){
37309 var grid = this.grid;
37310 var size = this.adjustForComponents(width, height);
37311 var gridel = grid.getGridEl();
37312 gridel.setSize(size.width, size.height);
37314 var thd = grid.getGridEl().select('thead',true).first();
37315 var tbd = grid.getGridEl().select('tbody', true).first();
37317 tbd.setSize(width, height - thd.getHeight());
37326 beforeSlide : function(){
37327 this.grid.getView().scroller.clip();
37330 afterSlide : function(){
37331 this.grid.getView().scroller.unclip();
37334 destroy : function(){
37335 this.grid.destroy();
37337 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37342 * @class Roo.bootstrap.panel.Nest
37343 * @extends Roo.bootstrap.panel.Content
37345 * Create a new Panel, that can contain a layout.Border.
37348 * @param {Roo.BorderLayout} layout The layout for this panel
37349 * @param {String/Object} config A string to set only the title or a config object
37351 Roo.bootstrap.panel.Nest = function(config)
37353 // construct with only one argument..
37354 /* FIXME - implement nicer consturctors
37355 if (layout.layout) {
37357 layout = config.layout;
37358 delete config.layout;
37360 if (layout.xtype && !layout.getEl) {
37361 // then layout needs constructing..
37362 layout = Roo.factory(layout, Roo);
37366 config.el = config.layout.getEl();
37368 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37370 config.layout.monitorWindowResize = false; // turn off autosizing
37371 this.layout = config.layout;
37372 this.layout.getEl().addClass("roo-layout-nested-layout");
37379 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37381 setSize : function(width, height){
37382 if(!this.ignoreResize(width, height)){
37383 var size = this.adjustForComponents(width, height);
37384 var el = this.layout.getEl();
37385 if (size.height < 1) {
37386 el.setWidth(size.width);
37388 el.setSize(size.width, size.height);
37390 var touch = el.dom.offsetWidth;
37391 this.layout.layout();
37392 // ie requires a double layout on the first pass
37393 if(Roo.isIE && !this.initialized){
37394 this.initialized = true;
37395 this.layout.layout();
37400 // activate all subpanels if not currently active..
37402 setActiveState : function(active){
37403 this.active = active;
37404 this.setActiveClass(active);
37407 this.fireEvent("deactivate", this);
37411 this.fireEvent("activate", this);
37412 // not sure if this should happen before or after..
37413 if (!this.layout) {
37414 return; // should not happen..
37417 for (var r in this.layout.regions) {
37418 reg = this.layout.getRegion(r);
37419 if (reg.getActivePanel()) {
37420 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37421 reg.setActivePanel(reg.getActivePanel());
37424 if (!reg.panels.length) {
37427 reg.showPanel(reg.getPanel(0));
37436 * Returns the nested BorderLayout for this panel
37437 * @return {Roo.BorderLayout}
37439 getLayout : function(){
37440 return this.layout;
37444 * Adds a xtype elements to the layout of the nested panel
37448 xtype : 'ContentPanel',
37455 xtype : 'NestedLayoutPanel',
37461 items : [ ... list of content panels or nested layout panels.. ]
37465 * @param {Object} cfg Xtype definition of item to add.
37467 addxtype : function(cfg) {
37468 return this.layout.addxtype(cfg);
37473 * Ext JS Library 1.1.1
37474 * Copyright(c) 2006-2007, Ext JS, LLC.
37476 * Originally Released Under LGPL - original licence link has changed is not relivant.
37479 * <script type="text/javascript">
37482 * @class Roo.TabPanel
37483 * @extends Roo.util.Observable
37484 * A lightweight tab container.
37488 // basic tabs 1, built from existing content
37489 var tabs = new Roo.TabPanel("tabs1");
37490 tabs.addTab("script", "View Script");
37491 tabs.addTab("markup", "View Markup");
37492 tabs.activate("script");
37494 // more advanced tabs, built from javascript
37495 var jtabs = new Roo.TabPanel("jtabs");
37496 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37498 // set up the UpdateManager
37499 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37500 var updater = tab2.getUpdateManager();
37501 updater.setDefaultUrl("ajax1.htm");
37502 tab2.on('activate', updater.refresh, updater, true);
37504 // Use setUrl for Ajax loading
37505 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37506 tab3.setUrl("ajax2.htm", null, true);
37509 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37512 jtabs.activate("jtabs-1");
37515 * Create a new TabPanel.
37516 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37517 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37519 Roo.bootstrap.panel.Tabs = function(config){
37521 * The container element for this TabPanel.
37522 * @type Roo.Element
37524 this.el = Roo.get(config.el);
37527 if(typeof config == "boolean"){
37528 this.tabPosition = config ? "bottom" : "top";
37530 Roo.apply(this, config);
37534 if(this.tabPosition == "bottom"){
37535 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37536 this.el.addClass("roo-tabs-bottom");
37538 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37539 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37540 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37542 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37544 if(this.tabPosition != "bottom"){
37545 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37546 * @type Roo.Element
37548 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37549 this.el.addClass("roo-tabs-top");
37553 this.bodyEl.setStyle("position", "relative");
37555 this.active = null;
37556 this.activateDelegate = this.activate.createDelegate(this);
37561 * Fires when the active tab changes
37562 * @param {Roo.TabPanel} this
37563 * @param {Roo.TabPanelItem} activePanel The new active tab
37567 * @event beforetabchange
37568 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37569 * @param {Roo.TabPanel} this
37570 * @param {Object} e Set cancel to true on this object to cancel the tab change
37571 * @param {Roo.TabPanelItem} tab The tab being changed to
37573 "beforetabchange" : true
37576 Roo.EventManager.onWindowResize(this.onResize, this);
37577 this.cpad = this.el.getPadding("lr");
37578 this.hiddenCount = 0;
37581 // toolbar on the tabbar support...
37582 if (this.toolbar) {
37583 alert("no toolbar support yet");
37584 this.toolbar = false;
37586 var tcfg = this.toolbar;
37587 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37588 this.toolbar = new Roo.Toolbar(tcfg);
37589 if (Roo.isSafari) {
37590 var tbl = tcfg.container.child('table', true);
37591 tbl.setAttribute('width', '100%');
37599 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37602 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37604 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37606 tabPosition : "top",
37608 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37610 currentTabWidth : 0,
37612 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37616 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37620 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37622 preferredTabWidth : 175,
37624 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37626 resizeTabs : false,
37628 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37630 monitorResize : true,
37632 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37637 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37638 * @param {String} id The id of the div to use <b>or create</b>
37639 * @param {String} text The text for the tab
37640 * @param {String} content (optional) Content to put in the TabPanelItem body
37641 * @param {Boolean} closable (optional) True to create a close icon on the tab
37642 * @return {Roo.TabPanelItem} The created TabPanelItem
37644 addTab : function(id, text, content, closable, tpl)
37646 var item = new Roo.bootstrap.panel.TabItem({
37650 closable : closable,
37653 this.addTabItem(item);
37655 item.setContent(content);
37661 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37662 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37663 * @return {Roo.TabPanelItem}
37665 getTab : function(id){
37666 return this.items[id];
37670 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37671 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37673 hideTab : function(id){
37674 var t = this.items[id];
37677 this.hiddenCount++;
37678 this.autoSizeTabs();
37683 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37684 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37686 unhideTab : function(id){
37687 var t = this.items[id];
37689 t.setHidden(false);
37690 this.hiddenCount--;
37691 this.autoSizeTabs();
37696 * Adds an existing {@link Roo.TabPanelItem}.
37697 * @param {Roo.TabPanelItem} item The TabPanelItem to add
37699 addTabItem : function(item){
37700 this.items[item.id] = item;
37701 this.items.push(item);
37702 // if(this.resizeTabs){
37703 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
37704 // this.autoSizeTabs();
37706 // item.autoSize();
37711 * Removes a {@link Roo.TabPanelItem}.
37712 * @param {String/Number} id The id or index of the TabPanelItem to remove.
37714 removeTab : function(id){
37715 var items = this.items;
37716 var tab = items[id];
37717 if(!tab) { return; }
37718 var index = items.indexOf(tab);
37719 if(this.active == tab && items.length > 1){
37720 var newTab = this.getNextAvailable(index);
37725 this.stripEl.dom.removeChild(tab.pnode.dom);
37726 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
37727 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
37729 items.splice(index, 1);
37730 delete this.items[tab.id];
37731 tab.fireEvent("close", tab);
37732 tab.purgeListeners();
37733 this.autoSizeTabs();
37736 getNextAvailable : function(start){
37737 var items = this.items;
37739 // look for a next tab that will slide over to
37740 // replace the one being removed
37741 while(index < items.length){
37742 var item = items[++index];
37743 if(item && !item.isHidden()){
37747 // if one isn't found select the previous tab (on the left)
37750 var item = items[--index];
37751 if(item && !item.isHidden()){
37759 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
37760 * @param {String/Number} id The id or index of the TabPanelItem to disable.
37762 disableTab : function(id){
37763 var tab = this.items[id];
37764 if(tab && this.active != tab){
37770 * Enables a {@link Roo.TabPanelItem} that is disabled.
37771 * @param {String/Number} id The id or index of the TabPanelItem to enable.
37773 enableTab : function(id){
37774 var tab = this.items[id];
37779 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
37780 * @param {String/Number} id The id or index of the TabPanelItem to activate.
37781 * @return {Roo.TabPanelItem} The TabPanelItem.
37783 activate : function(id){
37784 var tab = this.items[id];
37788 if(tab == this.active || tab.disabled){
37792 this.fireEvent("beforetabchange", this, e, tab);
37793 if(e.cancel !== true && !tab.disabled){
37795 this.active.hide();
37797 this.active = this.items[id];
37798 this.active.show();
37799 this.fireEvent("tabchange", this, this.active);
37805 * Gets the active {@link Roo.TabPanelItem}.
37806 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
37808 getActiveTab : function(){
37809 return this.active;
37813 * Updates the tab body element to fit the height of the container element
37814 * for overflow scrolling
37815 * @param {Number} targetHeight (optional) Override the starting height from the elements height
37817 syncHeight : function(targetHeight){
37818 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37819 var bm = this.bodyEl.getMargins();
37820 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
37821 this.bodyEl.setHeight(newHeight);
37825 onResize : function(){
37826 if(this.monitorResize){
37827 this.autoSizeTabs();
37832 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
37834 beginUpdate : function(){
37835 this.updating = true;
37839 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
37841 endUpdate : function(){
37842 this.updating = false;
37843 this.autoSizeTabs();
37847 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
37849 autoSizeTabs : function(){
37850 var count = this.items.length;
37851 var vcount = count - this.hiddenCount;
37852 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
37855 var w = Math.max(this.el.getWidth() - this.cpad, 10);
37856 var availWidth = Math.floor(w / vcount);
37857 var b = this.stripBody;
37858 if(b.getWidth() > w){
37859 var tabs = this.items;
37860 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
37861 if(availWidth < this.minTabWidth){
37862 /*if(!this.sleft){ // incomplete scrolling code
37863 this.createScrollButtons();
37866 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
37869 if(this.currentTabWidth < this.preferredTabWidth){
37870 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
37876 * Returns the number of tabs in this TabPanel.
37879 getCount : function(){
37880 return this.items.length;
37884 * Resizes all the tabs to the passed width
37885 * @param {Number} The new width
37887 setTabWidth : function(width){
37888 this.currentTabWidth = width;
37889 for(var i = 0, len = this.items.length; i < len; i++) {
37890 if(!this.items[i].isHidden()) {
37891 this.items[i].setWidth(width);
37897 * Destroys this TabPanel
37898 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
37900 destroy : function(removeEl){
37901 Roo.EventManager.removeResizeListener(this.onResize, this);
37902 for(var i = 0, len = this.items.length; i < len; i++){
37903 this.items[i].purgeListeners();
37905 if(removeEl === true){
37906 this.el.update("");
37911 createStrip : function(container)
37913 var strip = document.createElement("nav");
37914 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
37915 container.appendChild(strip);
37919 createStripList : function(strip)
37921 // div wrapper for retard IE
37922 // returns the "tr" element.
37923 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
37924 //'<div class="x-tabs-strip-wrap">'+
37925 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
37926 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
37927 return strip.firstChild; //.firstChild.firstChild.firstChild;
37929 createBody : function(container)
37931 var body = document.createElement("div");
37932 Roo.id(body, "tab-body");
37933 //Roo.fly(body).addClass("x-tabs-body");
37934 Roo.fly(body).addClass("tab-content");
37935 container.appendChild(body);
37938 createItemBody :function(bodyEl, id){
37939 var body = Roo.getDom(id);
37941 body = document.createElement("div");
37944 //Roo.fly(body).addClass("x-tabs-item-body");
37945 Roo.fly(body).addClass("tab-pane");
37946 bodyEl.insertBefore(body, bodyEl.firstChild);
37950 createStripElements : function(stripEl, text, closable, tpl)
37952 var td = document.createElement("li"); // was td..
37955 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
37958 stripEl.appendChild(td);
37960 td.className = "x-tabs-closable";
37961 if(!this.closeTpl){
37962 this.closeTpl = new Roo.Template(
37963 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37964 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
37965 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
37968 var el = this.closeTpl.overwrite(td, {"text": text});
37969 var close = el.getElementsByTagName("div")[0];
37970 var inner = el.getElementsByTagName("em")[0];
37971 return {"el": el, "close": close, "inner": inner};
37974 // not sure what this is..
37975 // if(!this.tabTpl){
37976 //this.tabTpl = new Roo.Template(
37977 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
37978 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
37980 // this.tabTpl = new Roo.Template(
37981 // '<a href="#">' +
37982 // '<span unselectable="on"' +
37983 // (this.disableTooltips ? '' : ' title="{text}"') +
37984 // ' >{text}</span></a>'
37990 var template = tpl || this.tabTpl || false;
37994 template = new Roo.Template(
37996 '<span unselectable="on"' +
37997 (this.disableTooltips ? '' : ' title="{text}"') +
37998 ' >{text}</span></a>'
38002 switch (typeof(template)) {
38006 template = new Roo.Template(template);
38012 var el = template.overwrite(td, {"text": text});
38014 var inner = el.getElementsByTagName("span")[0];
38016 return {"el": el, "inner": inner};
38024 * @class Roo.TabPanelItem
38025 * @extends Roo.util.Observable
38026 * Represents an individual item (tab plus body) in a TabPanel.
38027 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38028 * @param {String} id The id of this TabPanelItem
38029 * @param {String} text The text for the tab of this TabPanelItem
38030 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38032 Roo.bootstrap.panel.TabItem = function(config){
38034 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38035 * @type Roo.TabPanel
38037 this.tabPanel = config.panel;
38039 * The id for this TabPanelItem
38042 this.id = config.id;
38044 this.disabled = false;
38046 this.text = config.text;
38048 this.loaded = false;
38049 this.closable = config.closable;
38052 * The body element for this TabPanelItem.
38053 * @type Roo.Element
38055 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38056 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38057 this.bodyEl.setStyle("display", "block");
38058 this.bodyEl.setStyle("zoom", "1");
38059 //this.hideAction();
38061 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38063 this.el = Roo.get(els.el);
38064 this.inner = Roo.get(els.inner, true);
38065 this.textEl = Roo.get(this.el.dom.firstChild, true);
38066 this.pnode = Roo.get(els.el.parentNode, true);
38067 // this.el.on("mousedown", this.onTabMouseDown, this);
38068 this.el.on("click", this.onTabClick, this);
38070 if(config.closable){
38071 var c = Roo.get(els.close, true);
38072 c.dom.title = this.closeText;
38073 c.addClassOnOver("close-over");
38074 c.on("click", this.closeClick, this);
38080 * Fires when this tab becomes the active tab.
38081 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38082 * @param {Roo.TabPanelItem} this
38086 * @event beforeclose
38087 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38088 * @param {Roo.TabPanelItem} this
38089 * @param {Object} e Set cancel to true on this object to cancel the close.
38091 "beforeclose": true,
38094 * Fires when this tab is closed.
38095 * @param {Roo.TabPanelItem} this
38099 * @event deactivate
38100 * Fires when this tab is no longer the active tab.
38101 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38102 * @param {Roo.TabPanelItem} this
38104 "deactivate" : true
38106 this.hidden = false;
38108 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38111 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38113 purgeListeners : function(){
38114 Roo.util.Observable.prototype.purgeListeners.call(this);
38115 this.el.removeAllListeners();
38118 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38121 this.pnode.addClass("active");
38124 this.tabPanel.stripWrap.repaint();
38126 this.fireEvent("activate", this.tabPanel, this);
38130 * Returns true if this tab is the active tab.
38131 * @return {Boolean}
38133 isActive : function(){
38134 return this.tabPanel.getActiveTab() == this;
38138 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38141 this.pnode.removeClass("active");
38143 this.fireEvent("deactivate", this.tabPanel, this);
38146 hideAction : function(){
38147 this.bodyEl.hide();
38148 this.bodyEl.setStyle("position", "absolute");
38149 this.bodyEl.setLeft("-20000px");
38150 this.bodyEl.setTop("-20000px");
38153 showAction : function(){
38154 this.bodyEl.setStyle("position", "relative");
38155 this.bodyEl.setTop("");
38156 this.bodyEl.setLeft("");
38157 this.bodyEl.show();
38161 * Set the tooltip for the tab.
38162 * @param {String} tooltip The tab's tooltip
38164 setTooltip : function(text){
38165 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38166 this.textEl.dom.qtip = text;
38167 this.textEl.dom.removeAttribute('title');
38169 this.textEl.dom.title = text;
38173 onTabClick : function(e){
38174 e.preventDefault();
38175 this.tabPanel.activate(this.id);
38178 onTabMouseDown : function(e){
38179 e.preventDefault();
38180 this.tabPanel.activate(this.id);
38183 getWidth : function(){
38184 return this.inner.getWidth();
38187 setWidth : function(width){
38188 var iwidth = width - this.pnode.getPadding("lr");
38189 this.inner.setWidth(iwidth);
38190 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38191 this.pnode.setWidth(width);
38195 * Show or hide the tab
38196 * @param {Boolean} hidden True to hide or false to show.
38198 setHidden : function(hidden){
38199 this.hidden = hidden;
38200 this.pnode.setStyle("display", hidden ? "none" : "");
38204 * Returns true if this tab is "hidden"
38205 * @return {Boolean}
38207 isHidden : function(){
38208 return this.hidden;
38212 * Returns the text for this tab
38215 getText : function(){
38219 autoSize : function(){
38220 //this.el.beginMeasure();
38221 this.textEl.setWidth(1);
38223 * #2804 [new] Tabs in Roojs
38224 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38226 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38227 //this.el.endMeasure();
38231 * Sets the text for the tab (Note: this also sets the tooltip text)
38232 * @param {String} text The tab's text and tooltip
38234 setText : function(text){
38236 this.textEl.update(text);
38237 this.setTooltip(text);
38238 //if(!this.tabPanel.resizeTabs){
38239 // this.autoSize();
38243 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38245 activate : function(){
38246 this.tabPanel.activate(this.id);
38250 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38252 disable : function(){
38253 if(this.tabPanel.active != this){
38254 this.disabled = true;
38255 this.pnode.addClass("disabled");
38260 * Enables this TabPanelItem if it was previously disabled.
38262 enable : function(){
38263 this.disabled = false;
38264 this.pnode.removeClass("disabled");
38268 * Sets the content for this TabPanelItem.
38269 * @param {String} content The content
38270 * @param {Boolean} loadScripts true to look for and load scripts
38272 setContent : function(content, loadScripts){
38273 this.bodyEl.update(content, loadScripts);
38277 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38278 * @return {Roo.UpdateManager} The UpdateManager
38280 getUpdateManager : function(){
38281 return this.bodyEl.getUpdateManager();
38285 * Set a URL to be used to load the content for this TabPanelItem.
38286 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38287 * @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)
38288 * @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)
38289 * @return {Roo.UpdateManager} The UpdateManager
38291 setUrl : function(url, params, loadOnce){
38292 if(this.refreshDelegate){
38293 this.un('activate', this.refreshDelegate);
38295 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38296 this.on("activate", this.refreshDelegate);
38297 return this.bodyEl.getUpdateManager();
38301 _handleRefresh : function(url, params, loadOnce){
38302 if(!loadOnce || !this.loaded){
38303 var updater = this.bodyEl.getUpdateManager();
38304 updater.update(url, params, this._setLoaded.createDelegate(this));
38309 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38310 * Will fail silently if the setUrl method has not been called.
38311 * This does not activate the panel, just updates its content.
38313 refresh : function(){
38314 if(this.refreshDelegate){
38315 this.loaded = false;
38316 this.refreshDelegate();
38321 _setLoaded : function(){
38322 this.loaded = true;
38326 closeClick : function(e){
38329 this.fireEvent("beforeclose", this, o);
38330 if(o.cancel !== true){
38331 this.tabPanel.removeTab(this.id);
38335 * The text displayed in the tooltip for the close icon.
38338 closeText : "Close this tab"
38341 * This script refer to:
38342 * Title: International Telephone Input
38343 * Author: Jack O'Connor
38344 * Code version: v12.1.12
38345 * Availability: https://github.com/jackocnr/intl-tel-input.git
38348 Roo.bootstrap.PhoneInputData = function() {
38351 "Afghanistan (افغانستان)",
38356 "Albania (Shqipëri)",
38361 "Algeria (الجزائر)",
38386 "Antigua and Barbuda",
38396 "Armenia (Հայաստան)",
38412 "Austria (Österreich)",
38417 "Azerbaijan (Azərbaycan)",
38427 "Bahrain (البحرين)",
38432 "Bangladesh (বাংলাদেশ)",
38442 "Belarus (Беларусь)",
38447 "Belgium (België)",
38477 "Bosnia and Herzegovina (Босна и Херцеговина)",
38492 "British Indian Ocean Territory",
38497 "British Virgin Islands",
38507 "Bulgaria (България)",
38517 "Burundi (Uburundi)",
38522 "Cambodia (កម្ពុជា)",
38527 "Cameroon (Cameroun)",
38536 ["204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905"]
38539 "Cape Verde (Kabu Verdi)",
38544 "Caribbean Netherlands",
38555 "Central African Republic (République centrafricaine)",
38575 "Christmas Island",
38581 "Cocos (Keeling) Islands",
38592 "Comoros (جزر القمر)",
38597 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38602 "Congo (Republic) (Congo-Brazzaville)",
38622 "Croatia (Hrvatska)",
38643 "Czech Republic (Česká republika)",
38648 "Denmark (Danmark)",
38663 "Dominican Republic (República Dominicana)",
38667 ["809", "829", "849"]
38685 "Equatorial Guinea (Guinea Ecuatorial)",
38705 "Falkland Islands (Islas Malvinas)",
38710 "Faroe Islands (Føroyar)",
38731 "French Guiana (Guyane française)",
38736 "French Polynesia (Polynésie française)",
38751 "Georgia (საქართველო)",
38756 "Germany (Deutschland)",
38776 "Greenland (Kalaallit Nunaat)",
38813 "Guinea-Bissau (Guiné Bissau)",
38838 "Hungary (Magyarország)",
38843 "Iceland (Ísland)",
38863 "Iraq (العراق)",
38879 "Israel (ישראל)",
38906 "Jordan (الأردن)",
38911 "Kazakhstan (Казахстан)",
38932 "Kuwait (الكويت)",
38937 "Kyrgyzstan (Кыргызстан)",
38947 "Latvia (Latvija)",
38952 "Lebanon (لبنان)",
38967 "Libya (ليبيا)",
38977 "Lithuania (Lietuva)",
38992 "Macedonia (FYROM) (Македонија)",
38997 "Madagascar (Madagasikara)",
39027 "Marshall Islands",
39037 "Mauritania (موريتانيا)",
39042 "Mauritius (Moris)",
39063 "Moldova (Republica Moldova)",
39073 "Mongolia (Монгол)",
39078 "Montenegro (Crna Gora)",
39088 "Morocco (المغرب)",
39094 "Mozambique (Moçambique)",
39099 "Myanmar (Burma) (မြန်မာ)",
39104 "Namibia (Namibië)",
39119 "Netherlands (Nederland)",
39124 "New Caledonia (Nouvelle-Calédonie)",
39159 "North Korea (조선 민주주의 인민 공화국)",
39164 "Northern Mariana Islands",
39180 "Pakistan (پاکستان)",
39190 "Palestine (فلسطين)",
39200 "Papua New Guinea",
39242 "Réunion (La Réunion)",
39248 "Romania (România)",
39264 "Saint Barthélemy",
39275 "Saint Kitts and Nevis",
39285 "Saint Martin (Saint-Martin (partie française))",
39291 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39296 "Saint Vincent and the Grenadines",
39311 "São Tomé and Príncipe (São Tomé e Príncipe)",
39316 "Saudi Arabia (المملكة العربية السعودية)",
39321 "Senegal (Sénégal)",
39351 "Slovakia (Slovensko)",
39356 "Slovenia (Slovenija)",
39366 "Somalia (Soomaaliya)",
39376 "South Korea (대한민국)",
39381 "South Sudan (جنوب السودان)",
39391 "Sri Lanka (ශ්රී ලංකාව)",
39396 "Sudan (السودان)",
39406 "Svalbard and Jan Mayen",
39417 "Sweden (Sverige)",
39422 "Switzerland (Schweiz)",
39427 "Syria (سوريا)",
39472 "Trinidad and Tobago",
39477 "Tunisia (تونس)",
39482 "Turkey (Türkiye)",
39492 "Turks and Caicos Islands",
39502 "U.S. Virgin Islands",
39512 "Ukraine (Україна)",
39517 "United Arab Emirates (الإمارات العربية المتحدة)",
39539 "Uzbekistan (Oʻzbekiston)",
39549 "Vatican City (Città del Vaticano)",
39560 "Vietnam (Việt Nam)",
39565 "Wallis and Futuna (Wallis-et-Futuna)",
39570 "Western Sahara (الصحراء الغربية)",
39576 "Yemen (اليمن)",
39600 * This script refer to:
39601 * Title: International Telephone Input
39602 * Author: Jack O'Connor
39603 * Code version: v12.1.12
39604 * Availability: https://github.com/jackocnr/intl-tel-input.git
39608 * @class Roo.bootstrap.PhoneInput
39609 * @extends Roo.bootstrap.TriggerField
39610 * An input with International dial-code selection
39612 * @cfg {String} defaultDialCode default '+852'
39613 * @cfg {Array} preferedCountries default []
39616 * Create a new PhoneInput.
39617 * @param {Object} config Configuration options
39620 Roo.bootstrap.PhoneInput = function(config) {
39621 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39624 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39626 listWidth: undefined,
39628 selectedClass: 'active',
39630 invalidClass : "has-warning",
39632 validClass: 'has-success',
39634 allowed: '0123456789',
39637 * @cfg {String} defaultDialCode The default dial code when initializing the input
39639 defaultDialCode: '+852',
39642 * @cfg {Array} preferedCountries A list of iso2 in array (e.g. ['hk','us']). Those related countries will show at the top of the input's choices
39644 preferedCountries: false,
39646 getAutoCreate : function()
39648 var data = Roo.bootstrap.PhoneInputData();
39649 var align = this.labelAlign || this.parentLabelAlign();
39652 this.allCountries = [];
39653 this.dialCodeMapping = [];
39655 for (var i = 0; i < data.length; i++) {
39657 this.allCountries[i] = {
39661 priority: c[3] || 0,
39662 areaCodes: c[4] || null
39664 this.dialCodeMapping[c[2]] = {
39667 priority: c[3] || 0,
39668 areaCodes: c[4] || null
39680 cls : 'form-control tel-input',
39681 autocomplete: 'new-password'
39684 var hiddenInput = {
39687 cls: 'hidden-tel-input'
39691 hiddenInput.name = this.name;
39694 if (this.disabled) {
39695 input.disabled = true;
39698 var flag_container = {
39715 cls: this.hasFeedback ? 'has-feedback' : '',
39721 cls: 'dial-code-holder',
39728 cls: 'roo-select2-container input-group',
39735 if (this.fieldLabel.length) {
39738 tooltip: 'This field is required'
39744 cls: 'control-label',
39750 html: this.fieldLabel
39753 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
39759 if(this.indicatorpos == 'right') {
39760 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
39767 if(align == 'left') {
39775 if(this.labelWidth > 12){
39776 label.style = "width: " + this.labelWidth + 'px';
39778 if(this.labelWidth < 13 && this.labelmd == 0){
39779 this.labelmd = this.labelWidth;
39781 if(this.labellg > 0){
39782 label.cls += ' col-lg-' + this.labellg;
39783 input.cls += ' col-lg-' + (12 - this.labellg);
39785 if(this.labelmd > 0){
39786 label.cls += ' col-md-' + this.labelmd;
39787 container.cls += ' col-md-' + (12 - this.labelmd);
39789 if(this.labelsm > 0){
39790 label.cls += ' col-sm-' + this.labelsm;
39791 container.cls += ' col-sm-' + (12 - this.labelsm);
39793 if(this.labelxs > 0){
39794 label.cls += ' col-xs-' + this.labelxs;
39795 container.cls += ' col-xs-' + (12 - this.labelxs);
39805 var settings = this;
39807 ['xs','sm','md','lg'].map(function(size){
39808 if (settings[size]) {
39809 cfg.cls += ' col-' + size + '-' + settings[size];
39813 this.store = new Roo.data.Store({
39814 proxy : new Roo.data.MemoryProxy({}),
39815 reader : new Roo.data.JsonReader({
39826 'name' : 'dialCode',
39830 'name' : 'priority',
39834 'name' : 'areaCodes',
39841 if(!this.preferedCountries) {
39842 this.preferedCountries = [
39849 var p = this.preferedCountries.reverse();
39852 for (var i = 0; i < p.length; i++) {
39853 for (var j = 0; j < this.allCountries.length; j++) {
39854 if(this.allCountries[j].iso2 == p[i]) {
39855 var t = this.allCountries[j];
39856 this.allCountries.splice(j,1);
39857 this.allCountries.unshift(t);
39863 this.store.proxy.data = {
39865 data: this.allCountries
39871 initEvents : function()
39874 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
39876 this.indicator = this.indicatorEl();
39877 this.flag = this.flagEl();
39878 this.dialCodeHolder = this.dialCodeHolderEl();
39880 this.trigger = this.el.select('div.flag-box',true).first();
39881 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
39886 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
39887 _this.list.setWidth(lw);
39890 this.list.on('mouseover', this.onViewOver, this);
39891 this.list.on('mousemove', this.onViewMove, this);
39892 this.inputEl().on("keyup", this.onKeyUp, this);
39894 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
39896 this.view = new Roo.View(this.list, this.tpl, {
39897 singleSelect:true, store: this.store, selectedClass: this.selectedClass
39900 this.view.on('click', this.onViewClick, this);
39901 this.setValue(this.defaultDialCode);
39904 onTriggerClick : function(e)
39906 Roo.log('trigger click');
39911 if(this.isExpanded()){
39913 this.hasFocus = false;
39915 this.store.load({});
39916 this.hasFocus = true;
39921 isExpanded : function()
39923 return this.list.isVisible();
39926 collapse : function()
39928 if(!this.isExpanded()){
39932 Roo.get(document).un('mousedown', this.collapseIf, this);
39933 Roo.get(document).un('mousewheel', this.collapseIf, this);
39934 this.fireEvent('collapse', this);
39938 expand : function()
39942 if(this.isExpanded() || !this.hasFocus){
39946 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
39947 this.list.setWidth(lw);
39950 this.restrictHeight();
39952 Roo.get(document).on('mousedown', this.collapseIf, this);
39953 Roo.get(document).on('mousewheel', this.collapseIf, this);
39955 this.fireEvent('expand', this);
39958 restrictHeight : function()
39960 this.list.alignTo(this.inputEl(), this.listAlign);
39961 this.list.alignTo(this.inputEl(), this.listAlign);
39964 onViewOver : function(e, t)
39966 if(this.inKeyMode){
39969 var item = this.view.findItemFromChild(t);
39972 var index = this.view.indexOf(item);
39973 this.select(index, false);
39978 onViewClick : function(view, doFocus, el, e)
39980 var index = this.view.getSelectedIndexes()[0];
39982 var r = this.store.getAt(index);
39985 this.onSelect(r, index);
39987 if(doFocus !== false && !this.blockFocus){
39988 this.inputEl().focus();
39992 onViewMove : function(e, t)
39994 this.inKeyMode = false;
39997 select : function(index, scrollIntoView)
39999 this.selectedIndex = index;
40000 this.view.select(index);
40001 if(scrollIntoView !== false){
40002 var el = this.view.getNode(index);
40004 this.list.scrollChildIntoView(el, false);
40009 createList : function()
40011 this.list = Roo.get(document.body).createChild({
40013 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40014 style: 'display:none'
40016 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
40019 collapseIf : function(e)
40021 var in_combo = e.within(this.el);
40022 var in_list = e.within(this.list);
40023 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40025 if (in_combo || in_list || is_list) {
40031 onSelect : function(record, index)
40033 if(this.fireEvent('beforeselect', this, record, index) !== false){
40035 this.setFlagClass(record.data.iso2);
40036 this.setDialCode(record.data.dialCode);
40037 this.hasFocus = false;
40039 this.fireEvent('select', this, record, index);
40043 flagEl : function()
40045 var flag = this.el.select('div.flag',true).first();
40052 dialCodeHolderEl : function()
40054 var d = this.el.select('input.dial-code-holder',true).first();
40061 setDialCode : function(v)
40063 this.dialCodeHolder.dom.value = '+'+v;
40066 setFlagClass : function(n)
40068 this.flag.dom.className = 'flag '+n;
40071 getValue : function()
40073 var v = this.inputEl().getValue();
40074 if(this.dialCodeHolder) {
40075 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40080 setValue : function(v)
40082 var d = this.getDialCode(v);
40084 //invalid dial code
40085 if(v.length == 0 || !d || d.length == 0) {
40087 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40088 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40094 this.setFlagClass(this.dialCodeMapping[d].iso2);
40095 this.setDialCode(d);
40096 this.inputEl().dom.value = v.replace('+'+d,'');
40097 this.hiddenEl().dom.value = this.getValue();
40102 getDialCode : function(v = '')
40104 if (v.length == 0) {
40105 return this.dialCodeHolder.dom.value;
40109 if (v.charAt(0) != "+") {
40112 var numericChars = "";
40113 for (var i = 1; i < v.length; i++) {
40114 var c = v.charAt(i);
40117 if (this.dialCodeMapping[numericChars]) {
40118 dialCode = v.substr(1, i);
40120 if (numericChars.length == 4) {
40130 this.setValue(this.defaultDialCode);
40134 hiddenEl : function()
40136 return this.el.select('input.hidden-tel-input',true).first();
40139 onKeyUp : function(e){
40141 var k = e.getKey();
40142 var c = e.getCharCode();
40145 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40146 this.allowed.indexOf(String.fromCharCode(c)) === -1
40151 // if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40154 if(this.allowed.indexOf(String.fromCharCode(c)) === -1){
40158 this.setValue(this.getValue());
40163 * @class Roo.bootstrap.MoneyField
40164 * @extends Roo.bootstrap.ComboBox
40165 * Bootstrap MoneyField class
40168 * Create a new MoneyField.
40169 * @param {Object} config Configuration options
40172 Roo.bootstrap.MoneyField = function(config) {
40174 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40178 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40181 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40183 allowDecimals : true,
40185 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40187 decimalSeparator : ".",
40189 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40191 decimalPrecision : 0,
40193 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40195 allowNegative : true,
40197 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40199 minValue : Number.NEGATIVE_INFINITY,
40201 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40203 maxValue : Number.MAX_VALUE,
40205 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40207 minText : "The minimum value for this field is {0}",
40209 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40211 maxText : "The maximum value for this field is {0}",
40213 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40214 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40216 nanText : "{0} is not a valid number",
40218 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40222 * @cfg {String} defaults currency of the MoneyField
40223 * value should be in lkey
40225 defaultCurrency : false,
40227 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40229 thousandsDelimiter : false,
40239 getAutoCreate : function()
40241 var align = this.labelAlign || this.parentLabelAlign();
40253 cls : 'form-control roo-money-amount-input',
40254 autocomplete: 'new-password'
40257 var hiddenInput = {
40261 cls: 'hidden-number-input'
40265 hiddenInput.name = this.name;
40268 if (this.disabled) {
40269 input.disabled = true;
40272 var clg = 12 - this.inputlg;
40273 var cmd = 12 - this.inputmd;
40274 var csm = 12 - this.inputsm;
40275 var cxs = 12 - this.inputxs;
40279 cls : 'row roo-money-field',
40283 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40287 cls: 'roo-select2-container input-group',
40291 cls : 'form-control roo-money-currency-input',
40292 autocomplete: 'new-password',
40294 name : this.currencyName
40298 cls : 'input-group-addon',
40312 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40316 cls: this.hasFeedback ? 'has-feedback' : '',
40327 if (this.fieldLabel.length) {
40330 tooltip: 'This field is required'
40336 cls: 'control-label',
40342 html: this.fieldLabel
40345 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40351 if(this.indicatorpos == 'right') {
40352 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40359 if(align == 'left') {
40367 if(this.labelWidth > 12){
40368 label.style = "width: " + this.labelWidth + 'px';
40370 if(this.labelWidth < 13 && this.labelmd == 0){
40371 this.labelmd = this.labelWidth;
40373 if(this.labellg > 0){
40374 label.cls += ' col-lg-' + this.labellg;
40375 input.cls += ' col-lg-' + (12 - this.labellg);
40377 if(this.labelmd > 0){
40378 label.cls += ' col-md-' + this.labelmd;
40379 container.cls += ' col-md-' + (12 - this.labelmd);
40381 if(this.labelsm > 0){
40382 label.cls += ' col-sm-' + this.labelsm;
40383 container.cls += ' col-sm-' + (12 - this.labelsm);
40385 if(this.labelxs > 0){
40386 label.cls += ' col-xs-' + this.labelxs;
40387 container.cls += ' col-xs-' + (12 - this.labelxs);
40398 var settings = this;
40400 ['xs','sm','md','lg'].map(function(size){
40401 if (settings[size]) {
40402 cfg.cls += ' col-' + size + '-' + settings[size];
40409 initEvents : function()
40411 this.indicator = this.indicatorEl();
40413 this.initCurrencyEvent();
40415 this.initNumberEvent();
40418 initCurrencyEvent : function()
40421 throw "can not find store for combo";
40424 this.store = Roo.factory(this.store, Roo.data);
40425 this.store.parent = this;
40429 this.triggerEl = this.el.select('.input-group-addon', true).first();
40431 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40436 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40437 _this.list.setWidth(lw);
40440 this.list.on('mouseover', this.onViewOver, this);
40441 this.list.on('mousemove', this.onViewMove, this);
40442 this.list.on('scroll', this.onViewScroll, this);
40445 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40448 this.view = new Roo.View(this.list, this.tpl, {
40449 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40452 this.view.on('click', this.onViewClick, this);
40454 this.store.on('beforeload', this.onBeforeLoad, this);
40455 this.store.on('load', this.onLoad, this);
40456 this.store.on('loadexception', this.onLoadException, this);
40458 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40459 "up" : function(e){
40460 this.inKeyMode = true;
40464 "down" : function(e){
40465 if(!this.isExpanded()){
40466 this.onTriggerClick();
40468 this.inKeyMode = true;
40473 "enter" : function(e){
40476 if(this.fireEvent("specialkey", this, e)){
40477 this.onViewClick(false);
40483 "esc" : function(e){
40487 "tab" : function(e){
40490 if(this.fireEvent("specialkey", this, e)){
40491 this.onViewClick(false);
40499 doRelay : function(foo, bar, hname){
40500 if(hname == 'down' || this.scope.isExpanded()){
40501 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40509 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40513 initNumberEvent : function(e)
40515 this.inputEl().on("keydown" , this.fireKey, this);
40516 this.inputEl().on("focus", this.onFocus, this);
40517 this.inputEl().on("blur", this.onBlur, this);
40519 this.inputEl().relayEvent('keyup', this);
40521 if(this.indicator){
40522 this.indicator.addClass('invisible');
40525 this.originalValue = this.getValue();
40527 if(this.validationEvent == 'keyup'){
40528 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40529 this.inputEl().on('keyup', this.filterValidation, this);
40531 else if(this.validationEvent !== false){
40532 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40535 if(this.selectOnFocus){
40536 this.on("focus", this.preFocus, this);
40539 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40540 this.inputEl().on("keypress", this.filterKeys, this);
40542 this.inputEl().relayEvent('keypress', this);
40545 var allowed = "0123456789";
40547 if(this.allowDecimals){
40548 allowed += this.decimalSeparator;
40551 if(this.allowNegative){
40555 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40557 var keyPress = function(e){
40559 var k = e.getKey();
40561 var c = e.getCharCode();
40564 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40565 allowed.indexOf(String.fromCharCode(c)) === -1
40571 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40575 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40580 this.inputEl().on("keypress", keyPress, this);
40584 onTriggerClick : function(e)
40591 this.loadNext = false;
40593 if(this.isExpanded()){
40598 this.hasFocus = true;
40600 if(this.triggerAction == 'all') {
40601 this.doQuery(this.allQuery, true);
40605 this.doQuery(this.getRawValue());
40608 getCurrency : function()
40610 var v = this.currencyEl().getValue();
40615 restrictHeight : function()
40617 this.list.alignTo(this.currencyEl(), this.listAlign);
40618 this.list.alignTo(this.currencyEl(), this.listAlign);
40621 onViewClick : function(view, doFocus, el, e)
40623 var index = this.view.getSelectedIndexes()[0];
40625 var r = this.store.getAt(index);
40628 this.onSelect(r, index);
40632 onSelect : function(record, index){
40634 if(this.fireEvent('beforeselect', this, record, index) !== false){
40636 this.setFromCurrencyData(index > -1 ? record.data : false);
40640 this.fireEvent('select', this, record, index);
40644 setFromCurrencyData : function(o)
40648 this.lastCurrency = o;
40650 if (this.currencyField) {
40651 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40653 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40656 this.lastSelectionText = currency;
40658 //setting default currency
40659 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40660 this.setCurrency(this.defaultCurrency);
40664 this.setCurrency(currency);
40667 setFromData : function(o)
40671 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40673 this.setFromCurrencyData(c);
40678 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
40680 Roo.log('no value set for '+ (this.name ? this.name : this.id));
40683 this.setValue(value);
40687 setCurrency : function(v)
40689 this.currencyValue = v;
40692 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
40697 setValue : function(v)
40699 v = this.fixPrecision(v);
40701 v = String(v).replace(".", this.decimalSeparator);
40707 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40709 this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision,
40710 this.thousandsDelimiter || ','
40713 if(this.allowBlank && !v) {
40714 this.inputEl().dom.value = '';
40721 getRawValue : function()
40723 var v = this.inputEl().getValue();
40728 getValue : function()
40730 return this.fixPrecision(this.parseValue(this.getRawValue()));
40733 parseValue : function(value)
40735 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
40736 return isNaN(value) ? '' : value;
40739 fixPrecision : function(value)
40741 var nan = isNaN(value);
40743 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
40744 return nan ? '' : value;
40747 return parseFloat(value).toFixed(this.decimalPrecision);
40750 decimalPrecisionFcn : function(v)
40752 return Math.floor(v);
40755 validateValue : function(value)
40757 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
40761 var num = this.parseValue(value);
40764 this.markInvalid(String.format(this.nanText, value));
40768 if(num < this.minValue){
40769 this.markInvalid(String.format(this.minText, this.minValue));
40773 if(num > this.maxValue){
40774 this.markInvalid(String.format(this.maxText, this.maxValue));
40781 validate : function()
40783 if(this.disabled || this.allowBlank){
40788 var currency = this.getCurrency();
40790 if(this.validateValue(this.getRawValue()) && currency.length){
40795 this.markInvalid();
40799 getName: function()
40804 beforeBlur : function()
40810 var v = this.parseValue(this.getRawValue());
40817 onBlur : function()
40821 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
40822 //this.el.removeClass(this.focusClass);
40825 this.hasFocus = false;
40827 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
40831 var v = this.getValue();
40833 if(String(v) !== String(this.startValue)){
40834 this.fireEvent('change', this, v, this.startValue);
40837 this.fireEvent("blur", this);
40840 inputEl : function()
40842 return this.el.select('.roo-money-amount-input', true).first();
40845 currencyEl : function()
40847 return this.el.select('.roo-money-currency-input', true).first();
40850 hiddenEl : function()
40852 return this.el.select('input.hidden-number-input',true).first();