Browse Source

toast一个个往下堆叠

master
qcc 6 years ago
parent
commit
156ac98583
  1. 8
      dist/base.css
  2. 32
      dist/base.js
  3. 8
      dist/bundle.css
  4. 36
      dist/bundle.ie.js
  5. 36
      dist/bundle.js
  6. 4
      dist/case.js
  7. 1
      dist/demo.js
  8. 8
      dist/fineui.css
  9. 36
      dist/fineui.ie.js
  10. 36
      dist/fineui.js
  11. 32
      dist/fineui_without_jquery_polyfill.js
  12. 26
      src/base/foundation/message.js
  13. 6
      src/base/single/tip/tip.toast.js
  14. 8
      src/css/base/foundation/bi.css
  15. 2
      src/less/base/foundation/bi.message.less

8
dist/base.css vendored

@ -615,10 +615,10 @@
font-size: 16px; font-size: 16px;
} }
.bi-message-animate { .bi-message-animate {
-webkit-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -webkit-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-moz-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -moz-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-o-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -o-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
} }
.bi-message-enter { .bi-message-enter {
opacity: 1; opacity: 1;

32
dist/base.js vendored

@ -5176,6 +5176,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -5196,7 +5198,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -5204,17 +5221,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -11502,9 +11518,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *

8
dist/bundle.css vendored

@ -2587,10 +2587,10 @@ textarea {
font-size: 16px; font-size: 16px;
} }
.bi-message-animate { .bi-message-animate {
-webkit-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -webkit-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-moz-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -moz-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-o-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -o-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
} }
.bi-message-enter { .bi-message-enter {
opacity: 1; opacity: 1;

36
dist/bundle.ie.js vendored

@ -40262,6 +40262,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -40282,7 +40284,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -40290,17 +40307,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -46588,9 +46604,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *
@ -51803,6 +51823,8 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, {
element: this, element: this,
container: o.container, container: o.container,
value: o.value, value: o.value,
width: o.width,
height: o.height,
popup: { popup: {
type: "bi.simple_color_chooser_popup" type: "bi.simple_color_chooser_popup"
} }
@ -52584,7 +52606,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
})); }));
} }
}); });
BI.SimpleColorPickerEditor.EVENT_CHANGE = "SimpleColorPickerEditor.EVENT_CHANGE"; BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/** BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/**
* 选色控件 * 选色控件
* *

36
dist/bundle.js vendored

@ -40666,6 +40666,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -40686,7 +40688,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -40694,17 +40711,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -46992,9 +47008,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *
@ -52207,6 +52227,8 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, {
element: this, element: this,
container: o.container, container: o.container,
value: o.value, value: o.value,
width: o.width,
height: o.height,
popup: { popup: {
type: "bi.simple_color_chooser_popup" type: "bi.simple_color_chooser_popup"
} }
@ -52988,7 +53010,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
})); }));
} }
}); });
BI.SimpleColorPickerEditor.EVENT_CHANGE = "SimpleColorPickerEditor.EVENT_CHANGE"; BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/** BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/**
* 选色控件 * 选色控件
* *

4
dist/case.js vendored

@ -2611,6 +2611,8 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, {
element: this, element: this,
container: o.container, container: o.container,
value: o.value, value: o.value,
width: o.width,
height: o.height,
popup: { popup: {
type: "bi.simple_color_chooser_popup" type: "bi.simple_color_chooser_popup"
} }
@ -3392,7 +3394,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
})); }));
} }
}); });
BI.SimpleColorPickerEditor.EVENT_CHANGE = "SimpleColorPickerEditor.EVENT_CHANGE"; BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/** BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/**
* 选色控件 * 选色控件
* *

1
dist/demo.js vendored

@ -726,7 +726,6 @@ BI.shortcut("demo.editor", Demo.Editor);Demo.CodeEditor = BI.inherit(BI.Widget,
cls: "layout-bg1", cls: "layout-bg1",
items: [{ items: [{
type: "bi.multifile_editor", type: "bi.multifile_editor",
accept: "*.zip;",
width: 400, width: 400,
height: 300 height: 300
}], }],

8
dist/fineui.css vendored

@ -2587,10 +2587,10 @@ textarea {
font-size: 16px; font-size: 16px;
} }
.bi-message-animate { .bi-message-animate {
-webkit-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -webkit-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-moz-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -moz-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-o-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -o-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
} }
.bi-message-enter { .bi-message-enter {
opacity: 1; opacity: 1;

36
dist/fineui.ie.js vendored

@ -40504,6 +40504,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -40524,7 +40526,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -40532,17 +40549,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -46830,9 +46846,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *
@ -52045,6 +52065,8 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, {
element: this, element: this,
container: o.container, container: o.container,
value: o.value, value: o.value,
width: o.width,
height: o.height,
popup: { popup: {
type: "bi.simple_color_chooser_popup" type: "bi.simple_color_chooser_popup"
} }
@ -52826,7 +52848,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
})); }));
} }
}); });
BI.SimpleColorPickerEditor.EVENT_CHANGE = "SimpleColorPickerEditor.EVENT_CHANGE"; BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/** BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/**
* 选色控件 * 选色控件
* *

36
dist/fineui.js vendored

@ -40908,6 +40908,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -40928,7 +40930,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -40936,17 +40953,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -47234,9 +47250,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *
@ -52449,6 +52469,8 @@ BI.SimpleColorChooser = BI.inherit(BI.Widget, {
element: this, element: this,
container: o.container, container: o.container,
value: o.value, value: o.value,
width: o.width,
height: o.height,
popup: { popup: {
type: "bi.simple_color_chooser_popup" type: "bi.simple_color_chooser_popup"
} }
@ -53230,7 +53252,7 @@ BI.SimpleColorPickerEditor = BI.inherit(BI.Widget, {
})); }));
} }
}); });
BI.SimpleColorPickerEditor.EVENT_CHANGE = "SimpleColorPickerEditor.EVENT_CHANGE"; BI.SimpleColorPickerEditor.EVENT_CHANGE = "ColorPickerEditor.EVENT_CHANGE";
BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/** BI.shortcut("bi.simple_color_picker_editor", BI.SimpleColorPickerEditor);/**
* 选色控件 * 选色控件
* *

32
dist/fineui_without_jquery_polyfill.js vendored

@ -28517,6 +28517,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -28537,7 +28539,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -28545,17 +28562,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {
@ -34222,9 +34238,13 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast);/** BI.shortcut("bi.toast", BI.Toast);/**
* toast提示 * toast提示
* *

26
src/base/foundation/message.js

@ -7,6 +7,8 @@ BI.Msg = function () {
var messageShow, $mask, $pop; var messageShow, $mask, $pop;
var toastStack = [];
return { return {
alert: function (title, message, callback) { alert: function (title, message, callback) {
this._show(false, title, message, callback); this._show(false, title, message, callback);
@ -27,7 +29,22 @@ BI.Msg = function () {
cls: "bi-message-animate bi-message-leave", cls: "bi-message-animate bi-message-leave",
level: level, level: level,
autoClose: autoClose, autoClose: autoClose,
text: message text: message,
listeners: [{
eventName: BI.Toast.EVENT_DESTORY,
action: function () {
BI.remove(toastStack, toast.element);
var _height = 10;
BI.each(toastStack, function (i, element) {
element.css({"top": _height});
_height += element.outerHeight() + 10;
});
}
}]
});
var height = 10;
BI.each(toastStack, function (i, element) {
height += element.outerHeight() + 10;
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
@ -35,17 +52,16 @@ BI.Msg = function () {
items: [{ items: [{
el: toast, el: toast,
left: "50%", left: "50%",
top: 10 top: height
}] }]
}); });
toastStack.push(toast.element);
toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2}); toast.element.css({"margin-left": -1 * toast.element.outerWidth() / 2});
toast.element.removeClass("bi-message-leave").addClass("bi-message-enter"); toast.element.removeClass("bi-message-leave").addClass("bi-message-enter");
autoClose && BI.delay(function () { autoClose && BI.delay(function () {
toast.element.removeClass("bi-message-enter").addClass("bi-message-leave"); toast.element.removeClass("bi-message-enter").addClass("bi-message-leave");
BI.delay(function () { toast.destroy();
toast.destroy();
}, 1000);
}, 5000); }, 5000);
}, },
_show: function (hasCancel, title, message, callback) { _show: function (hasCancel, title, message, callback) {

6
src/base/single/tip/tip.toast.js

@ -88,7 +88,11 @@ BI.Toast = BI.inherit(BI.Tip, {
setText: function (text) { setText: function (text) {
this.text.setText(text); this.text.setText(text);
},
beforeDestroy: function () {
this.fireEvent(BI.Toast.EVENT_DESTORY);
} }
}); });
BI.Toast.EVENT_DESTORY = "EVENT_DESTORY";
BI.shortcut("bi.toast", BI.Toast); BI.shortcut("bi.toast", BI.Toast);

8
src/css/base/foundation/bi.css

@ -18,10 +18,10 @@
font-size: 16px; font-size: 16px;
} }
.bi-message-animate { .bi-message-animate {
-webkit-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -webkit-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-moz-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -moz-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
-o-transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; -o-transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
transition: opacity 0.3s, transform 0.4s, -webkit-transform 0.4s; transition: opacity 0.3s, transform 0.3s, left 0.3s, right 0.3s, top 0.4s, bottom 0.3s;
} }
.bi-message-enter { .bi-message-enter {
opacity: 1; opacity: 1;

2
src/less/base/foundation/bi.message.less

@ -19,7 +19,7 @@
} }
.bi-message-animate { .bi-message-animate {
@val: opacity .3s, transform .4s, -webkit-transform .4s; @val: opacity .3s,transform .3s,left .3s,right .3s,top .4s,bottom .3s;;
.transition(@val); .transition(@val);
} }

Loading…
Cancel
Save