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

Merge branch 'master' of github.com:sharelatex/web-sharelatex

James Allen 10 лет назад
Родитель
Сommit
7637c858c8

+ 6 - 0
services/web/app/coffee/infrastructure/ExpressLocals.coffee

@@ -64,6 +64,12 @@ module.exports = (app, webRouter, apiRouter)->
 			Settings.siteUrl.substring(Settings.siteUrl.indexOf("//")+2)
 		next()
 
+	webRouter.use (req, res, next)->
+		res.locals.getUserEmail = ->
+			email = req?.session?.user?.email or ""
+			return email
+		next()
+
 	webRouter.use (req, res, next)->
 		res.locals.formatProjectPublicAccessLevel = (privilegeLevel)->
 			formatedPrivileges = private:"Private", readOnly:"Public: Read Only", readAndWrite:"Public: Read and Write"

+ 30 - 0
services/web/app/views/contact-us-modal.jade

@@ -0,0 +1,30 @@
+script(type='text/ng-template', id='supportModalTemplate')
+	.modal-header
+		button.close(
+			type="button"
+			data-dismiss="modal"
+			ng-click="close()"
+		) ×
+		h3 Contact Us
+	.modal-body.contact-us-modal
+		span(ng-show="sent == false")
+			label
+				| Subject
+			.form-group
+				input.field.text.medium.span8.form-control(ng-model="form.subject", maxlength='255', tabindex='1', onkeyup='')
+			label.desc
+				| 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)
+			.form-group
+				input.field.text.medium.span8.form-control(ng-model="form.project_url", tabindex='3', onkeyup='')
+			label.desc
+				| Message
+			.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')
+		span(ng-show="sent")
+			p Request Sent, Thank you.

+ 7 - 11
services/web/app/views/layout.jade

@@ -7,6 +7,7 @@ html(itemscope, itemtype='http://schema.org/Product')
 			// Stop superfish from loading
 			window.similarproducts = true
 		style [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak  {display: none !important; display: none; }
+		style #groove-button { display:none;}
 
 		-if (typeof(gaExperiments) != "undefined")
 			|!{gaExperiments}
@@ -25,6 +26,7 @@ html(itemscope, itemtype='http://schema.org/Product')
 			each subdomainDetails in settings.i18n.subdomainLang
 				link(rel="alternate", href=subdomainDetails.url+currentUrl, hreflang=subdomainDetails.lngCode)
 
+
 		meta(itemprop="name", content="ShareLaTeX, the Online LaTeX Editor")
 		
 		-if (typeof(meta) == "undefined")
@@ -60,8 +62,8 @@ html(itemscope, itemtype='http://schema.org/Product')
 				sixpackDomain: '#{settings.sixpack.domain}'
 			};
 			window.systemMessages = !{JSON.stringify(systemMessages).replace(/\//g, '\\/')};
-			window.ab = {}
-			window.user_id = '#{getLoggedInUserId()}'
+			window.ab = {};
+			window.user_id = '#{getLoggedInUserId()}';
 
 		- if (typeof(settings.algolia) != "undefined")
 			script.
@@ -80,6 +82,7 @@ html(itemscope, itemtype='http://schema.org/Product')
 				}
 				
 	body
+
 		- if(typeof(suppressSystemMessages) == "undefined")
 			.system-messages(
 				ng-cloak
@@ -118,21 +121,14 @@ html(itemscope, itemtype='http://schema.org/Product')
 					"paths" : {
 						"moment": "libs/moment-2.7.0"
 					}
-				};	
+				};
 			script(
 				data-main=jsPath+'main.js',
 				baseurl=jsPath,
 				src=jsPath+'libs/require.js?fingerprint='+fingerprint(jsPath + 'libs/require.js')
 			)
 
-		- if (typeof(tenderUrl) != "undefined")
-			script(src="https://#{tenderUrl}/tender_widget.js" )
-			script(type="text/javascript").
-				Tender = {
-					hideToggle: true,
-					widgetToggles: $(".js-tender-widget"),
-					category: "questions"
-				};
+		include contact-us-modal
 
 
 

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

@@ -12,6 +12,7 @@ define [
 	"libs/angular-cookies"
 	"libs/passfield"
 	"libs/sixpack"
+	"libs/groove"
 	"libs/angular-sixpack"
 	"libs/ng-tags-input-3.0.0"
 ], () ->

+ 4 - 1
services/web/public/coffee/main.coffee

@@ -15,7 +15,7 @@ define [
 	"main/annual-upgrade"
 	"main/register-users"
 	"main/subscription/group-subscription-invite-controller"
-	"main/universties-site"
+	"main/contact-us"
 	"analytics/AbTestingManager"
 	"directives/asyncForm"
 	"directives/stopPropagation"
@@ -30,3 +30,6 @@ define [
 	"__MAIN_CLIENTSIDE_INCLUDES__"
 ], () ->
 	angular.bootstrap(document.body, ["SharelatexApp"])
+
+	
+

+ 60 - 0
services/web/public/coffee/main/contact-us.coffee

@@ -0,0 +1,60 @@
+define [
+	"base"
+], (App) ->
+
+
+	App.controller 'ContactModal', ($scope, $modal) ->
+		$scope.contactUsModal = () ->
+			modalInstance = $modal.open(
+				templateUrl: "supportModalTemplate"
+				controller: "SupportModalController"
+			)
+
+	App.controller 'SupportModalController', ($scope, $modal) ->
+		$scope.form = {}
+		$scope.sent = false
+		$scope.sending = false
+		$scope.contactUs = ->
+			if !$scope.form.email?
+				console.log "email not set"
+				return
+			$scope.sending = true
+			ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32)
+			params =
+				email: $scope.form.email
+				message: $scope.form.message
+				subject: $scope.form.subject + " - [#{ticketNumber}]"
+				about : $scope.form.project_url
+				labels: "support"
+
+			Groove.createTicket params, (err, json)->
+				$scope.sent = true
+				$scope.$apply()
+
+
+		$scope.close = () ->
+			$modalInstance.close()
+
+
+	App.controller 'UniverstiesContactController', ($scope, $modal) ->
+
+		$scope.form = {}
+		$scope.sent = false
+		$scope.sending = false
+		$scope.contactUs = ->
+			if !$scope.form.email?
+				console.log "email not set"
+				return
+			$scope.sending = true
+			ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32)
+			params =
+				name: $scope.form.name || $scope.form.email
+				email: $scope.form.email
+				labels: "#{$scope.form.source} accounts"
+				message: "Please contact me with more details"
+				subject: $scope.form.subject + " - [#{ticketNumber}]"
+				about : "#{$scope.form.position || ''} #{$scope.form.university || ''}"
+
+			Groove.createTicket params, (err, json)->
+				$scope.sent = true
+				$scope.$apply()

+ 0 - 26
services/web/public/coffee/main/universties-site.coffee

@@ -1,26 +0,0 @@
-define [
-	"base"
-], (App) ->
-
-	App.controller 'UniverstiesContactController', ($scope, $modal) ->
-
-		$scope.form = {}
-		$scope.sent = false
-		$scope.sending = false
-		$scope.contactUs = ->
-			if !$scope.form.email?
-				console.log "email not set"
-				return
-			$scope.sending = true
-			ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32)
-			params = 
-				name: $scope.form.name || $scope.form.email
-				email: $scope.form.email
-				labels: $scope.form.source
-				message: "Please contact me with more details"
-				subject: $scope.form.subject + " - [#{ticketNumber}]"
-				about : "#{$scope.form.position || ''} #{$scope.form.university || ''}"
-
-			Groove.createTicket params, (err, json)->
-				$scope.sent = true
-				$scope.$apply()

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

@@ -16,6 +16,7 @@ define [
 				_csrf : window.csrfToken
 
 		$scope.showForm = ->
+			GrooveWidget.toggle()
 			$scope.formVisable = true
 
 		$scope.getPercentComplete = ->

+ 84 - 0
services/web/public/js/libs/groove.js

@@ -0,0 +1,84 @@
+!function(window) {
+
+  window.Groove = {
+
+    init: function(options) {
+      this._options = options;
+      if (typeof grooveOnReady != 'undefined') {grooveOnReady();}
+    },
+
+    createTicket: function(params, callback) {
+      var postData = serialize({
+        "ticket[enduser_name]": params["name"],
+        "ticket[enduser_email]": params["email"],
+        "ticket[title]": params["subject"],
+        "ticket[enduser_about]": params["about"],
+        "ticket[label_string]": params["labels"],
+        "ticket[comments_attributes][0][body]": params["message"]
+      });
+
+      sendRequest(this._options.widget_ticket_url, function(req) {
+        if (callback) {callback(req);}
+      }, postData);
+    }
+  };
+
+  // http://www.quirksmode.org/js/xmlhttp.html
+  function sendRequest(url, callback, postData) {
+    var req = createXMLHTTPObject();
+    if (!req) return;
+    var method = (postData) ? "POST" : "GET";
+    req.open(method, url, true);
+    if (postData){
+      try {
+        req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
+      }
+      catch(e) {
+        req.contentType = 'application/x-www-form-urlencoded';
+      };
+    };
+    req.onreadystatechange = function () {
+      if (req.readyState != 4) return;
+      callback(req);
+    }
+    if (req.readyState == 4) return;
+    req.send(postData);
+  }
+
+  var XMLHttpFactories = [
+    function () {return new XDomainRequest()},
+    function () {return new XMLHttpRequest()},
+    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
+    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
+    function () {return new ActiveXObject("Microsoft.XMLHTTP")}
+  ];
+
+  function createXMLHTTPObject() {
+    var xmlhttp = false;
+    for (var i = 0; i < XMLHttpFactories.length; i++) {
+      try {
+        xmlhttp = XMLHttpFactories[i]();
+      }
+      catch (e) {
+        continue;
+      }
+      break;
+    }
+    return xmlhttp;
+  }
+
+  function serialize(obj) {
+    var str = [];
+    for(var p in obj) {
+      if (obj[p]) {
+        str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+      }
+    }
+    return str.join("&");
+}
+
+if (typeof grooveOnLoad != 'undefined') {grooveOnLoad();}
+}(window);
+
+Groove.init({"widget_ticket_url":"https://sharelatex-accounts.groovehq.com/widgets/f5ad3b09-7d99-431b-8af5-c5725e3760ce/ticket.json"});
+

+ 6 - 0
services/web/public/stylesheets/app/contact-us.less

@@ -0,0 +1,6 @@
+.contact-us-modal {
+
+	textarea {
+		height: 120px;
+	}
+}

+ 1 - 0
services/web/public/stylesheets/style.less

@@ -71,3 +71,4 @@
 @import "app/templates.less";
 @import "app/wiki.less";
 @import "app/translations.less";
+@import "app/contact-us.less";