added word count UI feature.

This commit is contained in:
Henry Oswald 2015-09-14 15:28:19 +01:00
parent 507e8d13a6
commit 9a72667e91
7 changed files with 82 additions and 5 deletions

View file

@ -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

View file

@ -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")}

View file

@ -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__"

View file

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

View file

@ -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')

View file

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

View file

@ -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;
}