return;
}
this.setActiveItem(this.navItems[i-1]);
+ },
+ clearWasActive : function(except) {
+ Roo.each(this.navItems, function(e) {
+ if (e.tabId != except.tabId && e.was_active) {
+ e.was_active = false;
+ return false;
+ }
+ return true;
+
+ });
+ },
+ getWasActive : function ()
+ {
+ var r = false;
+ Roo.each(this.navItems, function(e) {
+ if (e.was_active) {
+ r = e;
+ return false;
+ }
+ return true;
+
+ });
+ return r;
}
tagtype : 'a',
disabled : false,
+ was_active : false,
+
getAutoCreate : function(){
var cfg = {
if (typeof(this.parent().setActiveItem) !== 'undefined') {
this.parent().setActiveItem(this);
}
-
-
-
}
},
isActive: function () {
return this.active
},
- setActive : function(state, fire)
+ setActive : function(state, fire, is_was_active)
{
+ if (this.active && !state & this.navId) {
+ this.was_active = true;
+ var nv = Roo.bootstrap.NavGroup.get(this.navId);
+ if (nv) {
+ nv.clearWasActive(this);
+ }
+
+ }
this.active = state;
+
if (!state ) {
this.el.removeClass('active');
} else if (!this.el.hasClass('active')) {
// show a panel if it's registered and related..
- if (!this.navId || !this.tabId || !state) {
+ if (!this.navId || !this.tabId || !state || is_was_active) {
return;
}
if (!pan) {
return;
}
- tg.showPanel(pan);
+ // if we can not flip to new panel - go back to old nav highlight..
+ if (false == tg.showPanel(pan)) {
+ var nv = Roo.bootstrap.NavGroup.get(this.navId);
+ if (nv) {
+ var onav = nv.getWasActive();
+ if (onav) {
+ onav.setActive(true, false, true);
+ }
+ }
+
+ }
c.cls = 'sortable';
}
-// if(typeof(config.align) != 'undefined' && config.align.length){
-// c.style += ' text-align:' + config.align + ';';
-// }
+ if(typeof(config.align) != 'undefined' && config.align.length){
+ c.style += ' text-align:' + config.align + ';';
+ }
if(typeof(config.width) != 'undefined'){
c.style += ' width:' + config.width + 'px;';
* @cfg {Boolean} append (true|false) default false
* @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
* @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
+ * @cfg {Boolean} editNotList allow text type,but not show pull down, default false
* @cfg {String} btnPosition set the position of the trigger button (left | right) default right
* @constructor
* Create a new ComboBox.
autoFocus : true,
tickable : false,
btnPosition : 'right',
-
+ editNotList : false,
// element that contains real text value.. (when hidden is used..)
getAutoCreate : function()
this.choices = this.el.select('ul.select2-choices', true).first();
this.searchField = this.el.select('ul li.select2-search-field', true).first();
-
- this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
+ if(this.editNotList){
+ this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
+ }
this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
{
Roo.log('trigger click');
- if(this.disabled){
+ if(this.disabled || this.editNotList){
return;
}
});
return r;
},
+ /**
+ * show a specific panel
+ * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
+ * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
+ */
showPanel : function (pan)
{
+
+
+
if (typeof(pan) == 'number') {
pan = this.tabs[pan];
}
pan = this.getPanelByName(pan);
}
if (pan.tabId == this.getActivePanel().tabId) {
- return;
+ return true;
}
var cur = this.getActivePanel();
+
+ if (false === cur.fireEvent('beforedeactivate')) {
+ return false;
+ }
+
+
+
if (this.carousel) {
var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
var lr = dir == 'next' ? 'left' : 'right';
}, this, { single: true } );
- return;
+ return true;
}
cur.setActive(false);
pan.setActive(true);
+ return true;
},
showPanelNext : function()
Roo.bootstrap.TabPanel = function(config){
Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
- this.addEvents({
+ this.addEvents({
/**
* @event changed
* Fires when the active status changes
* @param {Boolean} state the new state
*/
- 'changed': true
+ 'changed': true,
+ /**
+ * @event beforedeactivate
+ * Fires before a tab is de-activated - can be used to do validation on a form.
+ * @param {Roo.bootstrap.TabPanel} this
+ * @return {Boolean} false if there is an error
+
+ */
+ 'beforedeactivate': true
});
+
this.tabId = this.tabId || Roo.id();
};
getAutoCreate : function(){
var cfg = {
tag: 'div',
- cls: 'tab-pane',
+ // item is needed for carousel - not sure if it has any effect otherwise
+ cls: 'tab-pane item',
html: this.html || ''
};
cfg.tabId = this.tabId;
}
+
return cfg;
},
if (typeof(this.navId) != 'undefined') {
// not really needed.. but just in case.. parent should be a NavGroup.
var tg = Roo.bootstrap.TabGroup.get(this.navId);
- Roo.log(['register', tg, this]);
+ Roo.log(['register', tg, this]);
tg.register(this);
}
},
},
+
setActive: function(state)
{
Roo.log("panel - set active " + this.tabId + "=" + state);