finished contact us with groove

for settings file:

<a ng-controller="ContactModal", ng-click="contactUsModal()", href>Contact</a>
This commit is contained in:
Henry Oswald 2016-03-21 11:41:05 +00:00
parent 882297c353
commit 4e78e34cdf
7 changed files with 101 additions and 15 deletions

View file

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

View file

@ -6,9 +6,8 @@ script(type='text/ng-template', id='supportModalTemplate')
ng-click="close()"
) &times;
h3 Contact Us
.modal-body
.modal-body.contact-us-modal
span(ng-show="sent == false")
.form-group
label
| Subject
.form-group
@ -16,7 +15,7 @@ script(type='text/ng-template', id='supportModalTemplate')
label.desc
| Email
.form-group
input.field.text.medium.span8.form-control(ng-model="form.email", type='email', spellcheck='false', value='', maxlength='255', tabindex='2')
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

View file

@ -82,8 +82,6 @@ html(itemscope, itemtype='http://schema.org/Product')
}
body
div(ng-controller="ContactModal")
a(ng-click="contactUsModal()") contact us
- if(typeof(suppressSystemMessages) == "undefined")
.system-messages(
@ -130,11 +128,6 @@ html(itemscope, itemtype='http://schema.org/Product')
src=jsPath+'libs/require.js?fingerprint='+fingerprint(jsPath + 'libs/require.js')
)
script(type='text/javascript').
(function() {var s=document.createElement('script'); s.type='text/javascript';s.async=true;
s.src=('https:'==document.location.protocol?'https':'http') + '://sharelatex-accounts.groovehq.com/widgets/f5ad3b09-7d99-431b-8af5-c5725e3760ce/ticket/api.js';
var q = document.getElementsByTagName('script')[0];q.parentNode.insertBefore(s, q);})();
include contact-us-modal

View file

@ -11,7 +11,6 @@ define [
)
App.controller 'SupportModalController', ($scope, $modal) ->
$scope.form = {}
$scope.sent = false
$scope.sending = false
@ -26,6 +25,7 @@ define [
message: $scope.form.message
subject: $scope.form.subject + " - [#{ticketNumber}]"
about : $scope.form.project_url
labels: "support"
Groove.createTicket params, (err, json)->
$scope.sent = true
@ -36,8 +36,6 @@ define [
$modalInstance.close()
App.controller 'UniverstiesContactController', ($scope, $modal) ->
$scope.form = {}
@ -52,11 +50,10 @@ define [
params =
name: $scope.form.name || $scope.form.email
email: $scope.form.email
labels: $scope.form.source
labels: "#{$scope.form.source} accounts"
message: "Please contact me with more details"
subject: $scope.form.subject + " - [#{ticketNumber}]"
about : "#{$scope.form.position || ''} #{$scope.form.university || ''}"
to: "support@sharelatex.com"
Groove.createTicket params, (err, json)->
$scope.sent = true

View file

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

View file

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

View file

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