Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

refactor: 修改内部初始化流程 #13

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ 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

for own name, Plugin of Plugins
@registerPlugin Plugin

@delegateEvents()
Common.removeElement $el

registerProperty: (key, value)->
Expand Down Expand Up @@ -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
Expand Down