Browse Source

tab和navigation加入single属性

es6
guy 8 years ago
parent
commit
7e1b8c1514
  1. 44
      bi/base.js
  2. 2
      bi/core.js
  3. 44
      dist/base.js
  4. 2
      dist/core.js
  5. 29
      src/base/combination/navigation.js
  6. 15
      src/base/combination/tab.js
  7. 2
      src/core/wrapper/layout/layout.card.js

44
bi/base.js

@ -3920,6 +3920,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
logic: {
dynamic: false
},
single: false,
defaultShowIndex: 0,
tab: {
type: "bi.button_group",
@ -3973,6 +3974,18 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
afterCardCreated: function (v) {
var self = this;
this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
@ -3980,12 +3993,13 @@ BI.Navigation = BI.inherit(BI.Widget, {
if (type === BI.Events.CLICK) {
self.fireEvent(BI.Navigation.EVENT_CHANGE, obj);
}
})
});
this.options.afterCardCreated.apply(this, arguments);
},
afterCardShow: function (v) {
this.showIndex = v;
this._deleteOtherCards(v);
this.options.afterCardShow.apply(this, arguments);
},
@ -3996,16 +4010,23 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
setSelect: function (v) {
this.showIndex = v;
_assertCard: function () {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
this.cardMap[v] = card;
this.layout.addCardByName(v, card);
this.afterCardCreated(v);
}
},
setSelect: function (v) {
this._assertCard();
this.layout.showCardByName(v);
BI.nextTick(BI.bind(this.afterCardShow, this, v));
this._deleteOtherCards(v);
if (this.showIndex !== v) {
this.showIndex = v;
BI.nextTick(BI.bind(this.afterCardShow, this, v));
}
},
getSelect: function () {
@ -4636,6 +4657,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tab",
direction: "top",//top, bottom, left, right, custom
single: false, //是不是单页面
logic: {
dynamic: false
},
@ -4675,6 +4697,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return card;
},
afterCardShow: function (v) {
self._deleteOtherCards(v);
self.curr = v;
}
});
@ -4683,6 +4706,18 @@ BI.Tab = BI.inherit(BI.Widget, {
});
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
_assertCard: function (v) {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
@ -4702,6 +4737,7 @@ BI.Tab = BI.inherit(BI.Widget, {
this.tab && this.tab.setValue(v);
this._assertCard(v);
this.layout.showCardByName(v);
this._deleteOtherCards(v);
if (this.curr !== v) {
this.curr = v;
}

2
bi/core.js

@ -13289,7 +13289,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
isCardExisted: function (cardName) {
return BI.some(this.options.items, function (i, item) {
return item.cardName === cardName && item.el;
return item.cardName == cardName && item.el;
});
},

44
dist/base.js vendored

@ -3920,6 +3920,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
logic: {
dynamic: false
},
single: false,
defaultShowIndex: 0,
tab: {
type: "bi.button_group",
@ -3973,6 +3974,18 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
afterCardCreated: function (v) {
var self = this;
this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
@ -3980,12 +3993,13 @@ BI.Navigation = BI.inherit(BI.Widget, {
if (type === BI.Events.CLICK) {
self.fireEvent(BI.Navigation.EVENT_CHANGE, obj);
}
})
});
this.options.afterCardCreated.apply(this, arguments);
},
afterCardShow: function (v) {
this.showIndex = v;
this._deleteOtherCards(v);
this.options.afterCardShow.apply(this, arguments);
},
@ -3996,16 +4010,23 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
setSelect: function (v) {
this.showIndex = v;
_assertCard: function () {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
this.cardMap[v] = card;
this.layout.addCardByName(v, card);
this.afterCardCreated(v);
}
},
setSelect: function (v) {
this._assertCard();
this.layout.showCardByName(v);
BI.nextTick(BI.bind(this.afterCardShow, this, v));
this._deleteOtherCards(v);
if (this.showIndex !== v) {
this.showIndex = v;
BI.nextTick(BI.bind(this.afterCardShow, this, v));
}
},
getSelect: function () {
@ -4636,6 +4657,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tab",
direction: "top",//top, bottom, left, right, custom
single: false, //是不是单页面
logic: {
dynamic: false
},
@ -4675,6 +4697,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return card;
},
afterCardShow: function (v) {
self._deleteOtherCards(v);
self.curr = v;
}
});
@ -4683,6 +4706,18 @@ BI.Tab = BI.inherit(BI.Widget, {
});
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
_assertCard: function (v) {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
@ -4702,6 +4737,7 @@ BI.Tab = BI.inherit(BI.Widget, {
this.tab && this.tab.setValue(v);
this._assertCard(v);
this.layout.showCardByName(v);
this._deleteOtherCards(v);
if (this.curr !== v) {
this.curr = v;
}

2
dist/core.js vendored

@ -26842,7 +26842,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
isCardExisted: function (cardName) {
return BI.some(this.options.items, function (i, item) {
return item.cardName === cardName && item.el;
return item.cardName == cardName && item.el;
});
},

29
src/base/combination/navigation.js

@ -9,6 +9,7 @@ BI.Navigation = BI.inherit(BI.Widget, {
logic: {
dynamic: false
},
single: false,
defaultShowIndex: 0,
tab: {
type: "bi.button_group",
@ -62,6 +63,18 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
afterCardCreated: function (v) {
var self = this;
this.cardMap[v].on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
@ -69,12 +82,13 @@ BI.Navigation = BI.inherit(BI.Widget, {
if (type === BI.Events.CLICK) {
self.fireEvent(BI.Navigation.EVENT_CHANGE, obj);
}
})
});
this.options.afterCardCreated.apply(this, arguments);
},
afterCardShow: function (v) {
this.showIndex = v;
this._deleteOtherCards(v);
this.options.afterCardShow.apply(this, arguments);
},
@ -85,16 +99,23 @@ BI.Navigation = BI.inherit(BI.Widget, {
}
},
setSelect: function (v) {
this.showIndex = v;
_assertCard: function () {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
this.cardMap[v] = card;
this.layout.addCardByName(v, card);
this.afterCardCreated(v);
}
},
setSelect: function (v) {
this._assertCard();
this.layout.showCardByName(v);
BI.nextTick(BI.bind(this.afterCardShow, this, v));
this._deleteOtherCards(v);
if (this.showIndex !== v) {
this.showIndex = v;
BI.nextTick(BI.bind(this.afterCardShow, this, v));
}
},
getSelect: function () {

15
src/base/combination/tab.js

@ -7,6 +7,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return BI.extend(BI.Tab.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tab",
direction: "top",//top, bottom, left, right, custom
single: false, //是不是单页面
logic: {
dynamic: false
},
@ -46,6 +47,7 @@ BI.Tab = BI.inherit(BI.Widget, {
return card;
},
afterCardShow: function (v) {
self._deleteOtherCards(v);
self.curr = v;
}
});
@ -54,6 +56,18 @@ BI.Tab = BI.inherit(BI.Widget, {
});
},
_deleteOtherCards: function (currCardName) {
var self = this, o = this.options;
if (o.single === true) {
BI.each(this.cardMap, function (name, card) {
if (name !== (currCardName + "")) {
self.layout.deleteCardByName(name);
delete self.cardMap[name];
}
});
}
},
_assertCard: function (v) {
if (!this.layout.isCardExisted(v)) {
var card = this.options.cardCreator(v);
@ -73,6 +87,7 @@ BI.Tab = BI.inherit(BI.Widget, {
this.tab && this.tab.setValue(v);
this._assertCard(v);
this.layout.showCardByName(v);
this._deleteOtherCards(v);
if (this.curr !== v) {
this.curr = v;
}

2
src/core/wrapper/layout/layout.card.js

@ -63,7 +63,7 @@ BI.CardLayout = BI.inherit(BI.Layout, {
isCardExisted: function (cardName) {
return BI.some(this.options.items, function (i, item) {
return item.cardName === cardName && item.el;
return item.cardName == cardName && item.el;
});
},

Loading…
Cancel
Save