[Pkg-mozext-commits] [wot] 75/226: #33 FBL: Support longer question and "dismiss" action-link

David Prévot taffit at moszumanska.debian.org
Fri May 1 00:35:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository wot.

commit ee2cd63237dfb71bbaeccf6adfdf55c77ff996fd
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date:   Mon Apr 1 22:35:20 2013 +0300

    #33 FBL: Support longer question and "dismiss" action-link
---
 content/cache.js                      | 10 +++++++-
 content/config.js                     |  1 +
 content/injections/surveys.widgets.js | 45 +++++++++++++++++++++++++----------
 content/surveys.js                    |  4 +++-
 4 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/content/cache.js b/content/cache.js
index 8168624..bb57e90 100644
--- a/content/cache.js
+++ b/content/cache.js
@@ -397,11 +397,18 @@ var wot_cache =
 				var doc = target_node.ownerDocument;
 				var id_node = doc.getElementsByTagName(WOT_SERVICE_XML_QUERY_QUESTION_ID).item(0),
 					text_node = doc.getElementsByTagName(WOT_SERVICE_XML_QUERY_QUESTION_TEXT).item(0),
+                    dismiss_node = doc.getElementsByTagName(WOT_SERVICE_XML_QUERY_DISMISS_TEXT).item(0),
 					choices_nodes = doc.getElementsByTagName(WOT_SERVICE_XML_QUERY_CHOICE_TEXT);
 
 				if (id_node && id_node.firstChild && text_node && text_node.firstChild) {
 					var id = String(id_node.firstChild.nodeValue),
-						text = String(text_node.firstChild.nodeValue);
+						text = String(text_node.firstChild.nodeValue),
+                        dismiss_text = "";
+
+                    if (dismiss_node && dismiss_node.firstChild) {
+                        dismiss_text = String(dismiss_node.firstChild.nodeValue);
+                    }
+
 
 					if (id && text) {
 
@@ -424,6 +431,7 @@ var wot_cache =
 						if (choices.length) {
 							this.set(hostname, "question_id", id);
 							this.set(hostname, "question_text", text);
+                            this.set(hostname, "dismiss_text", dismiss_text);
 							this.set(hostname, "choices_number", Number(choices.length));
 							for(var j=0; j < choices.length; j++) {
 								this.set(hostname, "choice_value_" + String(j), choices[j]['value']);
diff --git a/content/config.js b/content/config.js
index d7232f8..495b12a 100644
--- a/content/config.js
+++ b/content/config.js
@@ -90,6 +90,7 @@ const WOT_SERVICE_XML_QUERY_QUESTION			= "question";
 const WOT_SERVICE_XML_QUERY_QUESTION_ID			= "questionId";
 const WOT_SERVICE_XML_QUERY_QUESTION_TEXT		= "questionText";
 const WOT_SERVICE_XML_QUERY_CHOICE_TEXT 		= "choiceText";
+const WOT_SERVICE_XML_QUERY_DISMISS_TEXT 		= "dismiss";
 const WOT_SERVICE_XML_QUERY_MSG					= "message";
 const WOT_SERVICE_XML_QUERY_MSG_ID				= "id";
 const WOT_SERVICE_XML_QUERY_MSG_ID_MAINT		= "downtime";
diff --git a/content/injections/surveys.widgets.js b/content/injections/surveys.widgets.js
index 1e4b086..395cca3 100644
--- a/content/injections/surveys.widgets.js
+++ b/content/injections/surveys.widgets.js
@@ -1,6 +1,6 @@
 /*
  surveys.widgets.js
- Copyright © 2012 -   WOT Services Oy <info at mywot.com>
+ Copyright © 2012 - 2013  WOT Services Oy <info at mywot.com>
 
  This file is part of WOT.
 
@@ -268,13 +268,13 @@ var surveys = {
 		},
 
 		on_logo: function (e) {
-
+//			wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_logo);
+//			surveys.report("logo", {});
 		},
 
 		on_close: function (e) {
 			var _this = surveys;
 			wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_closed, _this.target);
-
 			// give small time for GA to send event
 			surveys.report("close", {});
 		},
@@ -287,7 +287,7 @@ var surveys = {
 			_this.is_whatisthis_shown = false;
 
 			if(_this.is_optout_shown) {
-				surveys.ui.hide_bottom_section();
+				_this.hide_bottom_section();
 				_this.hide_optout();
 
 			} else {
@@ -296,18 +296,18 @@ var surveys = {
 				$tab.show();
 
 				$(".button-yes", $tab).click(function () {
-					wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_yes, _this.target);
+					wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_yes, surveys.target);
 					surveys.report("optout", {});
 				});
 
 				$(".button-no", $tab).click(function () {
 					_this.hide_optout();
 					_this.hide_bottom_section();
-					wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_no, _this.target);
+					wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_no, surveys.target);
 				});
 
 				_this.is_optout_shown = true;
-				wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_shown, _this.target);
+				wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_optout_shown, surveys.target);
 			}
 		},
 
@@ -319,13 +319,13 @@ var surveys = {
 			_this.hide_optout();
 
 			if (_this.is_whatisthis_shown) {
-				surveys.ui.hide_bottom_section();
+				_this.hide_bottom_section();
 				$btab.hide();
 			} else {
-				surveys.ui.show_bottom_section();
+				_this.show_bottom_section();
 				$btab.show();
 				_this.is_whatisthis_shown = true;
-				wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_whatisthis, _this.target);
+				wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_whatisthis, surveys.target);
 			}
 		},
 
@@ -342,14 +342,33 @@ var surveys = {
 			}
 		},
 
+        on_dismiss: function (e) {
+            var _this = surveys;
+            wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_dismiss, _this.stats.get_impressions());
+            surveys.report("close", {});
+        },
+
 		update_texts: function () {
 			var _this = surveys;
 
+            var $question = $(".surveys-question");
+
+            var visible_host = _this.decodedtarget.length < 35 ? _this.decodedtarget : (wot.i18n("fbl", "this_website") || "this website");
+
 			// sanitize the questions (to avoid XSS with addon) and replace placeholder %site% with target name
 			var text = wot.utils.htmlescape(_this.question.text).replace(/%site%/,
-				"<span class='domainname'>" + _this.decodedtarget + "</span>");
+				"<span class='domainname'>" + visible_host + "</span>");
+
+            if (text.length > 100) {
+                $question.addClass("long");
+            }
 
-			$(".surveys-question").html(text);  // should be safe since we sanitized the question
+            $question.html(text);  // should be safe since we sanitized the question
+
+            if (_this.question.dismiss_text) {
+                $(".action-dismiss").text(_this.question.dismiss_text);
+            }
+            $(".surveys-action").toggleClass("hidden", !_this.question.dismiss_text);
 		},
 
 		update_submit_status: function () {
@@ -389,13 +408,13 @@ var surveys = {
 		$(".surveys-optout").click(_this.ui.on_optout);
 		$(".close-button").click(_this.ui.on_close);
 		$(".surveys-whatsthis").click(_this.ui.on_whatisthis);
+        $(".action-dismiss").click(_this.ui.on_dismiss);
 		$(".wot-logo").click(_this.ui.on_logo);
 
 		$(".close-button-secondary").click(function (event) {
 			_this.ui.hide_bottom_section();
 			wot.ga.fire_event(wot.ga.categories.FBL, wot.ga.actions.FBL_bottom_close);
 		});
-
 	}
 };
 
diff --git a/content/surveys.js b/content/surveys.js
index 05841b7..7fae6a0 100644
--- a/content/surveys.js
+++ b/content/surveys.js
@@ -30,7 +30,7 @@ var wot_surveys = {
 	fbl_form_uri:       "api.mywot.com/feedback/1/surveys.html",    // don't forget to change version!
 	re_fbl_uri:         null,
 	wrapper_id:         "wot_surveys_wrapper",
-	pheight:            350,
+	pheight:            400,
 	pwidth:             392,
 	px:                 10,
 	py:                 10,
@@ -294,6 +294,7 @@ var wot_surveys = {
 		try {
 			var question_id = wot_cache.get(hostname, "question_id");
 			var question_text = wot_cache.get(hostname, "question_text");
+            var dismiss_text = wot_cache.get(hostname, "dismiss_text");
 			var choices_number = wot_cache.get(hostname, "choices_number");
 
 			if (choices_number > 0) {
@@ -303,6 +304,7 @@ var wot_surveys = {
 					question: {
 						id: question_id,
 						text: question_text,
+                        dismiss_text: dismiss_text,
 						choices: []
 					}
 				};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git



More information about the Pkg-mozext-commits mailing list