relocate variable declaration

pull/2/head
Leopoldthecoder 2016-08-11 11:11:59 +08:00
parent dcffbbbe0d
commit 4fcfa04a9b
1 changed files with 12 additions and 10 deletions

View File

@ -1,14 +1,14 @@
import Vue from 'vue';
var NotificationConstructor = Vue.extend(require('./main.vue'));
let NotificationConstructor = Vue.extend(require('./main.vue'));
var instance;
var instances = [];
var seed = 1;
let instance;
let instances = [];
let seed = 1;
var Notification = function(options) {
options = options || {};
var userOnClose = options.onClose;
var id = 'notification_' + seed++;
let userOnClose = options.onClose;
let id = 'notification_' + seed++;
options.onClose = function() {
Notification.close(id, userOnClose);
@ -23,8 +23,8 @@ var Notification = function(options) {
instance.vm.visible = true;
instance.dom = instance.vm.$el;
var topDist = 0;
for (var i = 0, len = instances.length; i < len; i++) {
let topDist = 0;
for (let i = 0, len = instances.length; i < len; i++) {
topDist += instances[i].$el.offsetHeight + 16;
}
topDist += 16;
@ -33,13 +33,15 @@ var Notification = function(options) {
};
Notification.close = function(id, userOnClose) {
let index;
let removedHeight;
for (var i = 0, len = instances.length; i < len; i++) {
if (id === instances[i].id) {
if (typeof userOnClose === 'function') {
userOnClose(instances[i]);
}
var index = i;
var removedHeight = instances[i].dom.offsetHeight;
index = i;
removedHeight = instances[i].dom.offsetHeight;
instances.splice(i, 1);
break;
}