diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-10-05 16:47:19 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-10-05 16:47:19 +0200 |
commit | 3d1f057373836092623766809bbe0551b56b50b6 (patch) | |
tree | fa6ccf99f6c7611e0b9ecbdf045a280f68795dd6 /theme/javascript/core/progress.js | |
parent | 0679807517f2b53954b24434bbf7a847fe833c01 (diff) | |
download | gitbook-3d1f057373836092623766809bbe0551b56b50b6.zip gitbook-3d1f057373836092623766809bbe0551b56b50b6.tar.gz gitbook-3d1f057373836092623766809bbe0551b56b50b6.tar.bz2 |
Switch to gulp/browserify
Diffstat (limited to 'theme/javascript/core/progress.js')
-rwxr-xr-x | theme/javascript/core/progress.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/theme/javascript/core/progress.js b/theme/javascript/core/progress.js deleted file mode 100755 index a409a11..0000000 --- a/theme/javascript/core/progress.js +++ /dev/null @@ -1,73 +0,0 @@ -define([ - "lodash", - "jQuery", - "utils/storage", - "core/state" -], function(_, $, storage, state) { - // Get current level - var getCurrentLevel = function() { - return state.level; - }; - - // Return all levels - var getLevels = function () { - var levels = $(".book-summary li[data-level]"); - - return _.map(levels, function(level) { - return $(level).data("level").toString(); - }); - }; - - // Return a map chapter -> number (timestamp) - var getProgress = function () { - // Current level - var progress = storage.get("progress", {}); - - // Levels - var levels = getLevels(); - - _.each(levels, function(level) { - progress[level] = progress[level] || 0; - }); - - return progress; - }; - - // Change value of progress for a level - var markProgress = function (level, state) { - var progress = getProgress(); - - if (state == null) { - state = true; - } - - progress[level] = state - ? Date.now() - : 0; - - storage.set("progress", progress); - }; - - // Show progress - var showProgress = function () { - var progress = getProgress(); - var $summary = $(".book-summary"); - - _.each(progress, function (value, level) { - $summary.find("li[data-level='"+level+"']").toggleClass("done", value > 0); - }); - - // Mark current progress if we have not already - if (!progress[getCurrentLevel()]) { - markProgress(getCurrentLevel(), true); - } - }; - - return { - 'current': getCurrentLevel, - 'levels': getLevels, - 'get': getProgress, - 'mark': markProgress, - 'show': showProgress - }; -});
\ No newline at end of file |