From c7eec69fce8ef72ccd09335355b84ebb58b0d714 Mon Sep 17 00:00:00 2001 From: Saviio Date: Fri, 1 Jun 2018 14:59:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=88=9D=E5=A7=8B=E5=8C=96=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.coffee b/src/index.coffee index e347c0a..5732609 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -13,6 +13,11 @@ class GTA constructor: -> $el = document.getElementById 'gta-main' return unless $el + @delegateEvents() + + init: -> + $el = document.getElementById 'gta-main' + return unless $el for own name, Provider of Providers @registerProvider name, Provider, $el @@ -20,7 +25,6 @@ class GTA for own name, Plugin of Plugins @registerPlugin Plugin - @delegateEvents() Common.removeElement $el registerProperty: (key, value)-> @@ -55,8 +59,11 @@ class GTA setCurrentPage: (page) -> @registerProperty('page', page) - setUser: (id, user) -> + setUser: (id, user, turnOff) -> + return this if turnOff + try + @init() for provider in @providers formattedUser = Common.formatUser provider, user if @debug or window._gta_debug