UNPKG

nyx_server

Version:

Node内容发布

73 lines (68 loc) 1.88 kB
(function ($, lib) { 'use strict'; var win = window; var mask = { timer: null, status: 'show', showTime: new Date().valueOf(), minShowTime: 1000, init: function () { this.layout = $('#t-topic-mask'); this.msg = this.layout.find('span'); // this.animStart(); }, show: function (elm) { if (elm) { var r = elm.getBoundingClientRect(); var scrollTop = $(win).scrollTop(); var scrollLeft = $(win).scrollLeft(); this.layout.css({ top: r.top + scrollTop + 'px', right: r.right + scrollLeft + 'px', left: r.left + scrollLeft + 'px', bottom: r.bottom + scrollTop + 'px', height: r.height + 'px', width: r.width + 'px', position: 'absolute' }); } else { this.layout.css({ top: '', right: '', left: '', bottom: '', height: '', width: '', position: '' }); } this.layout.show(); this.status = 'show'; this.showTime = new Date().valueOf(); }, hide: function () { var now = new Date().valueOf(); var interval = 0; var _this = this; if (now - this.showTime < this.minShowTime) { interval = this.minShowTime - now + this.showTime; } setTimeout(function () { _this.status = 'hide'; _this.layout.fadeOut(); }, interval); }, changeMsg: function (value) { this.msg.html(value); }, animStart: function () { clearInterval(this.timer); this.timer = setInterval(function () { }, 1000); }, animStop: function () { clearInterval(this.timer); } }; lib.ns('topic').mask = mask; }(topicJquery, topic.utils));