summaryrefslogtreecommitdiffstats
path: root/theme/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'theme/javascript')
-rwxr-xr-xtheme/javascript/app.js6
-rwxr-xr-xtheme/javascript/core/exercise.js6
-rw-r--r--theme/javascript/core/global.js8
-rwxr-xr-xtheme/javascript/core/navigation.js6
-rw-r--r--theme/javascript/core/quiz.js6
-rw-r--r--theme/javascript/utils/analytic.js36
6 files changed, 21 insertions, 47 deletions
diff --git a/theme/javascript/app.js b/theme/javascript/app.js
index 3829a42..10ce21e 100755
--- a/theme/javascript/app.js
+++ b/theme/javascript/app.js
@@ -1,16 +1,16 @@
require([
"jQuery",
"utils/storage",
- "utils/analytic",
"utils/sharing",
+ "core/global",
"core/state",
"core/keyboard",
"core/navigation",
"core/progress",
"core/sidebar",
"core/search"
-], function($, storage, analytic, sharing, state, keyboard, navigation, progress, sidebar, search){
+], function($, storage, sharing, global, state, keyboard, navigation, progress, sidebar, search){
$(document).ready(function() {
var $book;
$book = state.$book;
@@ -34,5 +34,7 @@ require([
// Init navigation
navigation.init();
+
+ global.trigger("init");
});
});
diff --git a/theme/javascript/core/exercise.js b/theme/javascript/core/exercise.js
index e24ae0a..8765685 100755
--- a/theme/javascript/core/exercise.js
+++ b/theme/javascript/core/exercise.js
@@ -1,9 +1,9 @@
define([
"jQuery",
"utils/execute",
- "utils/analytic",
+ "core/global",
"core/state"
-], function($, execute, analytic, state){
+], function($, execute, global, state){
// Bind an exercise
var prepareExercise = function($exercise) {
var codeSolution = $exercise.find(".code-solution").text();
@@ -19,7 +19,7 @@ define([
$exercise.find(".action-submit").click(function(e) {
e.preventDefault();
- analytic.track("exercise.submit", {type: "code"});
+ global.trigger("exercise.submit", {type: "code"});
execute("javascript", editor.getValue(), codeValidation, codeContext, function(err, result) {
$exercise.toggleClass("return-error", err != null);
diff --git a/theme/javascript/core/global.js b/theme/javascript/core/global.js
new file mode 100644
index 0000000..0c75cdc
--- /dev/null
+++ b/theme/javascript/core/global.js
@@ -0,0 +1,8 @@
+define([
+ "jQuery"
+], function($) {
+ // Interface for plugins
+ window.gitbook = $({});
+
+ return window.gitbook;
+}); \ No newline at end of file
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js
index 1796fc1..88d4379 100755
--- a/theme/javascript/core/navigation.js
+++ b/theme/javascript/core/navigation.js
@@ -1,12 +1,12 @@
define([
"jQuery",
- "utils/analytic",
+ "core/global",
"core/state",
"core/search",
"core/progress",
"core/exercise",
"core/quiz"
-], function($, analytic, state, search, progress, exercises, quiz) {
+], function($, global, state, search, progress, exercises, quiz) {
var prev, next;
var githubCountStars, githubCountWatch;
@@ -110,7 +110,7 @@ define([
}
// Send to mixpanel
- analytic.track("page.view");
+ global.trigger("page.change");
};
var handlePagination = function (e) {
diff --git a/theme/javascript/core/quiz.js b/theme/javascript/core/quiz.js
index 4e30fea..239d546 100644
--- a/theme/javascript/core/quiz.js
+++ b/theme/javascript/core/quiz.js
@@ -1,9 +1,9 @@
define([
"jQuery",
"utils/execute",
- "utils/analytic",
+ "core/global",
"core/state"
-], function($, execute, analytic, state){
+], function($, execute, global, state){
// Bind an exercise
var prepareQuiz = function($quiz) {
@@ -14,7 +14,7 @@ define([
// Submit: test code
$quiz.find(".action-submit").click(function(e) {
e.preventDefault();
- analytic.track("exercise.submit", {type: "quiz"});
+ global.trigger("exercise.submit", {type: "quiz"});
$quiz.find("tr.alert-danger,li.alert-danger").removeClass("alert-danger");
$quiz.find(".alert-success,.alert-danger").addClass("hidden");
diff --git a/theme/javascript/utils/analytic.js b/theme/javascript/utils/analytic.js
deleted file mode 100644
index f90dd95..0000000
--- a/theme/javascript/utils/analytic.js
+++ /dev/null
@@ -1,36 +0,0 @@
-define([
- "lodash"
-], function(_) {
- var isAvailable = function() {
- return (
- typeof mixpanel !== "undefined" &&
- typeof mixpanel.track === "function"
- );
- };
-
- var track = function(e, data, t) {
- if (!isAvailable()) {
- console.warn("tracking not available!");
- t = t || 500;
- setTimeout(function() {
- console.log(" -> retest tracking");
- track(e, data, t*2);
- }, t);
- return;
- }
- console.log("track", e);
- mixpanel.track(e, _.extend(data || {}, {
- 'domain': window.location.host
- }));
- };
-
- setTimeout(function() {
- mixpanel.init("01eb2b950ae09a5fdb15a98dcc5ff20e");
- track("page.start");
- }, 0);
-
- return {
- isAvailable: isAvailable,
- track: track
- };
-}); \ No newline at end of file