mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
wired up modal for learn and added translations
This commit is contained in:
parent
63c183402c
commit
6662d4c2cd
4 changed files with 131 additions and 10 deletions
|
@ -5,26 +5,26 @@ script(type='text/ng-template', id='supportModalTemplate')
|
|||
data-dismiss="modal"
|
||||
ng-click="close()"
|
||||
) ×
|
||||
h3 Contact Us
|
||||
h3 #{translate("contact_us")}
|
||||
.modal-body.contact-us-modal
|
||||
span(ng-show="sent == false")
|
||||
label
|
||||
| Subject
|
||||
| #{translate("subject")}
|
||||
.form-group
|
||||
input.field.text.medium.span8.form-control(ng-model="form.subject", maxlength='255', tabindex='1', onkeyup='')
|
||||
label.desc
|
||||
| Email
|
||||
| #{translate("email")}
|
||||
.form-group
|
||||
input.field.text.medium.span8.form-control(ng-model="form.email", ng-init="form.email = '#{getUserEmail()}'", type='email', spellcheck='false', value='', maxlength='255', tabindex='2')
|
||||
label#title12.desc
|
||||
| Project URL (optional)
|
||||
| #{translate("project_url")} (#{translate("optional")})
|
||||
.form-group
|
||||
input.field.text.medium.span8.form-control(ng-model="form.project_url", tabindex='3', onkeyup='')
|
||||
label.desc
|
||||
| Message
|
||||
| #{translate("suggestion")}
|
||||
.form-group
|
||||
textarea.field.text.medium.span8.form-control(ng-model="form.message",type='text', value='', maxlength='255', tabindex='4', onkeyup='')
|
||||
.form-group.text-center
|
||||
input.btn-success.btn.btn-lg(type='submit', ng-disabled="sending", ng-click="contactUs()" value='Get in Touch')
|
||||
input.btn-success.btn.btn-lg(type='submit', ng-disabled="sending", ng-click="contactUs()" value='#{translate("contact_us")}')
|
||||
span(ng-show="sent")
|
||||
p Request Sent, Thank you.
|
||||
p #{translate("request_sent_thank_you")}
|
|
@ -24,7 +24,7 @@ block content
|
|||
ng-show="searchQueryText.length > 0"
|
||||
)
|
||||
.col-md-3.text-right
|
||||
a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("missing_page")}
|
||||
a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("suggest_new_doc")}
|
||||
|
||||
.row
|
||||
.col-md-12(ng-cloak)
|
||||
|
@ -36,4 +36,33 @@ block content
|
|||
.page-header
|
||||
h1 #{title}
|
||||
|
||||
| !{page.content}
|
||||
| !{page.content}
|
||||
|
||||
|
||||
|
||||
|
||||
script(type="text/ng-template", id="missingWikiPageModal")
|
||||
.modal-header
|
||||
button.close(
|
||||
type="button"
|
||||
data-dismiss="modal"
|
||||
ng-click="close()"
|
||||
) ×
|
||||
h3 #{translate("suggest_new_doc")}
|
||||
.modal-body.contact-us-modal
|
||||
span(ng-show="sent == false")
|
||||
label.desc
|
||||
| #{translate("email")} (#{translate("optional")})
|
||||
.form-group
|
||||
input.field.text.medium.span8.form-control(ng-model="form.email", ng-init="form.email = '#{getUserEmail()}'", type='email', spellcheck='false', value='', maxlength='255', tabindex='2')
|
||||
label.desc
|
||||
| #{translate("suggestion")}
|
||||
.form-group
|
||||
textarea.field.text.medium.span8.form-control(ng-model="form.message",type='text', value='', maxlength='255', tabindex='4', onkeyup='')
|
||||
span(ng-show="sent")
|
||||
p #{translate("request_sent_thank_you")}
|
||||
.modal-footer
|
||||
button.btn.btn-default(ng-click="close()")
|
||||
span #{translate("dismiss")}
|
||||
button.btn-success.btn(type='submit', ng-disabled="sending", ng-click="contactUs()") #{translate("contact_us")}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ define [
|
|||
"main/register-users"
|
||||
"main/subscription/group-subscription-invite-controller"
|
||||
"main/contact-us"
|
||||
"main/templates"
|
||||
"main/learn"
|
||||
"analytics/AbTestingManager"
|
||||
"directives/asyncForm"
|
||||
"directives/stopPropagation"
|
||||
|
|
92
services/web/public/coffee/main/learn.coffee
Normal file
92
services/web/public/coffee/main/learn.coffee
Normal file
|
@ -0,0 +1,92 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
|
||||
App.factory "algoliawiki", ->
|
||||
if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki?
|
||||
client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key)
|
||||
index = client.initIndex(window.sharelatex.algolia?.indexes?.wiki)
|
||||
return index
|
||||
|
||||
App.controller "SearchWikiController", ($scope, algoliawiki, _, $modal) ->
|
||||
algolia = algoliawiki
|
||||
$scope.hits = []
|
||||
|
||||
$scope.clearSearchText = ->
|
||||
$scope.searchQueryText = ""
|
||||
updateHits []
|
||||
|
||||
$scope.safeApply = (fn)->
|
||||
phase = $scope.$root.$$phase
|
||||
if(phase == '$apply' || phase == '$digest')
|
||||
$scope.$eval(fn)
|
||||
else
|
||||
$scope.$apply(fn)
|
||||
|
||||
buildHitViewModel = (hit)->
|
||||
page_underscored = hit.pageName.replace(/\s/g,'_')
|
||||
section_underscored = hit.sectionName.replace(/\s/g,'_')
|
||||
content = hit._highlightResult.content.value
|
||||
# Replace many new lines
|
||||
content = content.replace(/\n\n+/g, "\n\n")
|
||||
lines = content.split("\n")
|
||||
# Only show the lines that have a highlighted match
|
||||
matching_lines = []
|
||||
for line in lines
|
||||
if !line.match(/^\[edit\]/)
|
||||
content += line + "\n"
|
||||
if line.match(/<em>/)
|
||||
matching_lines.push line
|
||||
content = matching_lines.join("\n...\n")
|
||||
result =
|
||||
name : hit._highlightResult.pageName.value + " - " + hit._highlightResult.sectionName.value
|
||||
url :"/learn/#{page_underscored}##{section_underscored}"
|
||||
content: content
|
||||
return result
|
||||
|
||||
updateHits = (hits)->
|
||||
$scope.safeApply ->
|
||||
$scope.hits = hits
|
||||
|
||||
$scope.search = ->
|
||||
query = $scope.searchQueryText
|
||||
if !query? or query.length == 0
|
||||
updateHits []
|
||||
return
|
||||
|
||||
algolia.search query, (err, response)->
|
||||
if response.hits.length == 0
|
||||
updateHits []
|
||||
else
|
||||
hits = _.map response.hits, buildHitViewModel
|
||||
updateHits hits
|
||||
|
||||
$scope.showMissingTemplateModal = () ->
|
||||
modalInstance = $modal.open(
|
||||
templateUrl: "missingWikiPageModal"
|
||||
controller: "MissingWikiPageController"
|
||||
)
|
||||
|
||||
|
||||
App.controller 'MissingWikiPageController', ($scope, $modalInstance) ->
|
||||
$scope.form = {}
|
||||
$scope.sent = false
|
||||
$scope.sending = false
|
||||
$scope.contactUs = ->
|
||||
if !$scope.form.message?
|
||||
console.log "message not set"
|
||||
return
|
||||
$scope.sending = true
|
||||
ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32)
|
||||
params =
|
||||
email: $scope.form.email or "support@sharelatex.com"
|
||||
message: $scope.form.message or ""
|
||||
subject: "new wiki page sujection - [#{ticketNumber}]"
|
||||
labels: "support wiki"
|
||||
|
||||
Groove.createTicket params, (err, json)->
|
||||
$scope.sent = true
|
||||
$scope.$apply()
|
||||
|
||||
$scope.close = () ->
|
||||
$modalInstance.close()
|
Loading…
Reference in a new issue