Просмотр исходного кода

Restructure public/coffee/app folders slightly

James Allen 12 лет назад
Родитель
Сommit
84f998ba4a

+ 4 - 24
services/web/public/coffee/app/ide.coffee

@@ -1,6 +1,7 @@
 define [
 	"base"
 	"ide/file-tree/FileTreeManager"
+	"ide/connection/ConnectionManager"
 	"ide/directives/layout"
 	"ide/services/ide"
 	"directives/focus"
@@ -9,6 +10,7 @@ define [
 ], (
 	App
 	FileTreeManager
+	ConnectionManager
 ) ->
 	App.controller "IdeController", ["$scope", "$timeout", "ide", ($scope, $timeout, ide) ->
 		$scope.state = {
@@ -20,31 +22,9 @@ define [
 
 		ide.project_id = $scope.project_id = window.project_id
 		ide.$scope = $scope
-		ide.socket = io.connect null,
-				reconnect: false
-				"force new connection": true
 
+		ide.connectionManager = new ConnectionManager(ide, $scope)
 		ide.fileTreeManager = new FileTreeManager(ide, $scope)
-
-		ide.socket.on "connect", () ->
-			$scope.$apply () ->
-				$scope.state.load_progress = 80
-
-			joinProject = () =>
-				ide.socket.emit 'joinProject', {
-					project_id: ide.project_id
-				}, (err, project, permissionsLevel, protocolVersion) =>
-					if $scope.protocolVersion? and $scope.protocolVersion != protocolVersion
-						location.reload(true)
-
-					$scope.$apply () ->
-						$scope.protocolVersion = protocolVersion
-						$scope.project = project
-						$scope.state.load_progress = 100
-						$scope.state.loading = false
-
-						$scope.$emit "project:joined"
-
-			setTimeout(joinProject, 100)	]
+	]
 
 	angular.bootstrap(document.body, ["SharelatexApp"])

+ 27 - 0
services/web/public/coffee/app/ide/connection/ConnectionManager.coffee

@@ -0,0 +1,27 @@
+define [], () ->
+	class ConnectionManager
+		constructor: (@ide, @$scope) ->
+			@ide.socket = io.connect null,
+				reconnect: false
+				"force new connection": true
+
+			@ide.socket.on "connect", () =>
+				@$scope.$apply () =>
+					@$scope.state.load_progress = 80
+
+				joinProject = () =>
+					@ide.socket.emit 'joinProject', {
+						project_id: @ide.project_id
+					}, (err, project, permissionsLevel, protocolVersion) =>
+						if @$scope.protocolVersion? and @$scope.protocolVersion != protocolVersion
+							location.reload(true)
+
+						@$scope.$apply () =>
+							@$scope.protocolVersion = protocolVersion
+							@$scope.project = project
+							@$scope.state.load_progress = 100
+							@$scope.state.loading = false
+
+							@$scope.$emit "project:joined"
+
+				setTimeout(joinProject, 100)

+ 3 - 3
services/web/public/coffee/app/main.coffee

@@ -1,7 +1,7 @@
 define [
-	"project-list"
-	"user-details"
-	"account-settings"
+	"main/project-list"
+	"main/user-details"
+	"main/account-settings"
 	"directives/asyncForm"
 	"directives/stopPropagation"
 	"directives/focusInput"

+ 0 - 0
services/web/public/coffee/app/account-settings.coffee → services/web/public/coffee/app/main/account-settings.coffee


+ 0 - 0
services/web/public/coffee/app/project-list.coffee → services/web/public/coffee/app/main/project-list.coffee


+ 0 - 0
services/web/public/coffee/app/user-details.coffee → services/web/public/coffee/app/main/user-details.coffee