send feedback on buttons

pull/1/head
ansuz 8 years ago
parent d5c7eb49a4
commit 295f9c00a6

@ -149,7 +149,6 @@ define([
} }
var href = '/common/feedback.html?' + action + '=' + (+new Date()); var href = '/common/feedback.html?' + action + '=' + (+new Date());
console.log('[feedback] %s', href);
$.ajax({ $.ajax({
type: "HEAD", type: "HEAD",
url: href, url: href,
@ -884,6 +883,21 @@ define([
common.getPinnedUsage(todo); common.getPinnedUsage(todo);
}; };
var getAppSuffix = function () {
var parts = window.location.pathname.split('/')
.filter(function (x) { return x; });
if (!parts[0]) { return ''; }
return '_' + parts[0].toUpperCase();
};
var prepareFeedback = function (key) {
if (typeof(key) !== 'string') { return $.noop; }
return function () {
feedback(key.toUpperCase() + getAppSuffix());
};
};
common.createButton = function (type, rightside, data, callback) { common.createButton = function (type, rightside, data, callback) {
var button; var button;
var size = "17px"; var size = "17px";
@ -893,7 +907,7 @@ define([
title: Messages.exportButtonTitle, title: Messages.exportButtonTitle,
}).append($('<span>', {'class':'fa fa-download', style: 'font:'+size+' FontAwesome'})); }).append($('<span>', {'class':'fa fa-download', style: 'font:'+size+' FontAwesome'}));
if (callback) { if (callback) {
button.click(callback); button.click(prepareFeedback(type)).click(callback);
} }
break; break;
case 'import': case 'import':
@ -901,7 +915,9 @@ define([
title: Messages.importButtonTitle, title: Messages.importButtonTitle,
}).append($('<span>', {'class':'fa fa-upload', style: 'font:'+size+' FontAwesome'})); }).append($('<span>', {'class':'fa fa-upload', style: 'font:'+size+' FontAwesome'}));
if (callback) { if (callback) {
button.click(UI.importContent('text/plain', function (content, file) { button
.click(prepareFeedback(type))
.click(UI.importContent('text/plain', function (content, file) {
callback(content, file); callback(content, file);
})); }));
} }
@ -912,7 +928,8 @@ define([
title: Messages.saveTemplateButton, title: Messages.saveTemplateButton,
}).append($('<span>', {'class':'fa fa-bookmark', style: 'font:'+size+' FontAwesome'})); }).append($('<span>', {'class':'fa fa-bookmark', style: 'font:'+size+' FontAwesome'}));
if (data.rt && data.Crypt) { if (data.rt && data.Crypt) {
button.click(function () { button
.click(function () {
var title = data.getTitle() || document.title; var title = data.getTitle() || document.title;
var todo = function (val) { var todo = function (val) {
if (typeof(val) !== "string") { return; } if (typeof(val) !== "string") { return; }
@ -970,7 +987,9 @@ define([
} }
}); });
if (callback) { if (callback) {
button.click(function() { button
.click(prepareFeedback(type))
.click(function() {
var href = window.location.href; var href = window.location.href;
var msg = isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog; var msg = isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog;
common.confirm(msg, function (yes) { common.confirm(msg, function (yes) {
@ -1026,7 +1045,9 @@ define([
style: 'font:'+size+' FontAwesome' style: 'font:'+size+' FontAwesome'
}); });
if (data.histConfig) { if (data.histConfig) {
button.click(function () { button
.click(prepareFeedback(type))
.click(function () {
common.getHistory(data.histConfig); common.getHistory(data.histConfig);
}); });
} }
@ -1035,7 +1056,8 @@ define([
button = $('<button>', { button = $('<button>', {
'class': "fa fa-question", 'class': "fa fa-question",
style: 'font:'+size+' FontAwesome' style: 'font:'+size+' FontAwesome'
}); })
.click(prepareFeedback(type));
} }
if (rightside) { if (rightside) {
button.addClass('rightside-button'); button.addClass('rightside-button');

Loading…
Cancel
Save