Henry Oswald 11 лет назад
Родитель
Сommit
9a72667e91

+ 1 - 1
services/web/app/coffee/Features/Compile/CompileController.coffee

@@ -109,4 +109,4 @@ module.exports = CompileController =
 		CompileManager.wordCount project_id, file, (error, body) ->
 			return next(error) if error?
 			res.contentType("application/json")
-			res.send 200, body
+			res.send body

+ 47 - 1
services/web/app/views/project/editor/left-menu.jade

@@ -22,7 +22,7 @@ aside#left-menu.full-size(
 				i.fa.fa-file-pdf-o.fa-2x
 				br
 				| PDF
-			div.pdf-disabled(
+			div.link-disabled(
 				ng-if="!pdf.url"
 				tooltip="#{translate('please_compile_pdf_before_download')}"
 				tooltip-placement="bottom"
@@ -41,7 +41,15 @@ aside#left-menu.full-size(
 				)
 					i.fa.fa-fw.fa-copy
 					|    #{translate("copy_project")}
+
 			!= moduleIncludes("editorLeftMenu:actions", locals)
+			li(ng-controller="WordCountController")
+				a(href, ng-if="pdf.url" ,ng-click="openWordCountModal()")
+					i.fa.fa-fw.fa-eye
+					span    #{translate("word_count")}
+				a.link-disabled(href, ng-if="!pdf.url" , tooltip="#{translate('please_compile_pdf_before_word_count')}")
+					i.fa.fa-fw.fa-eye
+					span.link-disabled    #{translate("word_count")}	
 
 	if (moduleIncludesAvailable("editorLeftMenu:sync"))
 		div(ng-show="!anonymous")
@@ -173,3 +181,41 @@ script(type='text/ng-template', id='cloneProjectModalTemplate')
 		)
 			span(ng-hide="state.inflight") #{translate("copy")}
 			span(ng-show="state.inflight") #{translate("copying")}...
+
+script(type='text/ng-template', id='wordCountModalTemplate')
+	.modal-header
+		h3 #{translate("word_count")}
+	.modal-body
+		div(ng-if="status.loading")
+			.loading(ng-show="!status.error && status.loading")
+				i.fa.fa-refresh.fa-spin.fa-fw 
+				span   #{translate("loading")}...  
+			div.pdf-disabled(
+				ng-if="!pdf.url"
+				tooltip="#{translate('please_compile_pdf_before_word_count')}"
+				tooltip-placement="bottom"
+			)
+		div(ng-if="!status.loading")
+			.container-fluid
+				.row
+					.col-md-4
+						.pull-right #{translate("total_words")} :
+					.col-md-6 {{data.textWords}}
+				.row 
+					.col-md-4
+						.pull-right #{translate("headers")} :
+					.col-md-6 {{data.headers}}
+				.row 
+					.col-md-4 
+						.pull-right #{translate("math_inline")} :
+					.col-md-6 {{data.mathInline}}
+				.row 
+					.col-md-4 
+						.pull-right #{translate("math_display")} :
+					.col-md-6 {{data.mathDisplay}}
+	.modal-footer
+		button.btn.btn-default(
+			ng-disabled="state.inflight"
+			ng-click="cancel()"
+		) #{translate("done")}
+

+ 1 - 0
services/web/public/coffee/ide.coffee

@@ -13,6 +13,7 @@ define [
 	"ide/chat/index"
 	"ide/clone/index"
 	"ide/hotkeys/index"
+	"ide/wordcount/index"
 	"ide/directives/layout"
 	"ide/services/ide"
 	"__IDE_CLIENTSIDE_INCLUDES__"

+ 9 - 0
services/web/public/coffee/ide/wordcount/controllers/WordCountController.coffee

@@ -0,0 +1,9 @@
+define [
+	"base"
+], (App) ->
+	App.controller 'WordCountController', ($scope, $modal) ->
+		$scope.openWordCountModal = () ->
+			$modal.open {
+				templateUrl: "wordCountModalTemplate"
+				controller:  "WordCountModalController"
+			}

+ 17 - 0
services/web/public/coffee/ide/wordcount/controllers/WordCountModalController.coffee

@@ -0,0 +1,17 @@
+define [
+	"base"
+], (App) ->
+	App.controller 'WordCountModalController', ($scope, $modalInstance, ide, $http) ->
+		$scope.status = 
+			loading:true
+			
+		$http.get("/project/#{ide.project_id}/wordcount")
+			.success (data) ->
+				$scope.status.loading = false
+				$scope.data = data.texcount
+				console.log $scope.data
+			.error () ->
+				$scope.status.error = true
+
+		$scope.cancel = () ->
+			$modalInstance.dismiss('cancel')

+ 4 - 0
services/web/public/coffee/ide/wordcount/index.coffee

@@ -0,0 +1,4 @@
+define [
+	"ide/wordcount/controllers/WordCountController"
+	"ide/wordcount/controllers/WordCountModalController"
+], () ->

+ 3 - 3
services/web/public/stylesheets/app/editor/left-menu.less

@@ -47,6 +47,9 @@
 			padding: (@line-height-computed / 4);
 			font-weight: 700;
 		}
+		.link-disabled {
+				color: @gray-light;
+		}
 	}
 
 	ul.nav-downloads {
@@ -57,9 +60,6 @@
 			a {
 				color: @gray-dark;
 			}
-			.pdf-disabled {
-				color: @gray-light;
-			}
 			i {
 				margin: (@line-height-computed / 4) 0;
 			}