diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index 4ed9e0f1..84e53966 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -161,7 +161,6 @@ impl HtmlHandlebars { self.write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; self.write_file(destination, "highlight.js", &theme.highlight_js)?; self.write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; - self.write_file(destination, "store.js", &theme.store_js)?; self.write_file( destination, "_FontAwesome/css/font-awesome.css", diff --git a/src/theme/book.js b/src/theme/book.js index 1710d920..dccdc4f6 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -331,13 +331,14 @@ function playpen_text(playpen) { }); } - store.set('mdbook-theme', theme); + try { localStorage.setItem('mdbook-theme', theme); } catch (e) { } document.body.className = theme; } // Set theme - var theme = store.get('mdbook-theme'); + var theme; + try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } if (theme === null || theme === undefined) { theme = 'light'; } set_theme(theme); @@ -387,7 +388,7 @@ function playpen_text(playpen) { }); sidebarToggleButton.setAttribute('aria-expanded', true); sidebar.setAttribute('aria-hidden', false); - store.set('mdbook-sidebar', 'visible'); + try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { } } function hideSidebar() { @@ -398,7 +399,7 @@ function playpen_text(playpen) { }); sidebarToggleButton.setAttribute('aria-expanded', false); sidebar.setAttribute('aria-hidden', true); - store.set('mdbook-sidebar', 'hidden'); + try { localStorage.setItem('mdbook-sidebar', 'hidden'); } catch (e) { } } // Toggle sidebar diff --git a/src/theme/index.hbs b/src/theme/index.hbs index cbba70ef..e7c97c8a 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -41,14 +41,12 @@ } - - - @@ -56,8 +54,10 @@ diff --git a/src/theme/mod.rs b/src/theme/mod.rs index 68bb4411..0633be34 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -17,7 +17,6 @@ pub static TOMORROW_NIGHT_CSS: &'static [u8] = include_bytes!("tomorrow-night.cs pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css"); pub static AYU_HIGHLIGHT_CSS: &'static [u8] = include_bytes!("ayu-highlight.css"); pub static CLIPBOARD_JS: &'static [u8] = include_bytes!("clipboard.min.js"); -pub static STORE_JS: &'static [u8] = include_bytes!("store.js"); pub static FONT_AWESOME: &'static [u8] = include_bytes!("_FontAwesome/css/font-awesome.min.css"); pub static FONT_AWESOME_EOT: &'static [u8] = include_bytes!("_FontAwesome/fonts/fontawesome-webfont.eot"); @@ -50,7 +49,6 @@ pub struct Theme { pub ayu_highlight_css: Vec, pub highlight_js: Vec, pub clipboard_js: Vec, - pub store_js: Vec, } impl Theme { @@ -73,7 +71,6 @@ impl Theme { (theme_dir.join("favicon.png"), &mut theme.favicon), (theme_dir.join("highlight.js"), &mut theme.highlight_js), (theme_dir.join("clipboard.min.js"), &mut theme.clipboard_js), - (theme_dir.join("store.js"), &mut theme.store_js), (theme_dir.join("highlight.css"), &mut theme.highlight_css), (theme_dir.join("tomorrow-night.css"), &mut theme.tomorrow_night_css), (theme_dir.join("ayu-highlight.css"), &mut theme.ayu_highlight_css), @@ -107,7 +104,6 @@ impl Default for Theme { ayu_highlight_css: AYU_HIGHLIGHT_CSS.to_owned(), highlight_js: HIGHLIGHT_JS.to_owned(), clipboard_js: CLIPBOARD_JS.to_owned(), - store_js: STORE_JS.to_owned(), } } } @@ -178,7 +174,6 @@ mod tests { ayu_highlight_css: Vec::new(), highlight_js: Vec::new(), clipboard_js: Vec::new(), - store_js: Vec::new(), }; assert_eq!(got, empty); diff --git a/src/theme/store.js b/src/theme/store.js deleted file mode 100644 index cbeb367c..00000000 --- a/src/theme/store.js +++ /dev/null @@ -1,2 +0,0 @@ -/* store.js - Copyright (c) 2010-2017 Marcus Westin */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.store=e()}}(function(){var define,module,exports;return function e(t,n,r){function o(u,a){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u=0;n--)if(l(t[n])){var r=t[n].split("="),o=unescape(r[0]),i=unescape(r[1]);e(i,o)}}function i(e,t){e&&(p.cookie=escape(e)+"="+escape(t)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/")}function u(e){e&&s(e)&&(p.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function a(){o(function(e,t){u(t)})}function s(e){return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(p.cookie)}var c=e("../src/util"),f=c.Global,l=c.trim;t.exports={name:"cookieStorage",read:r,write:i,each:o,remove:u,clearAll:a};var p=f.document},{"../src/util":14}],17:[function(e,t,n){"use strict";function r(){return f.localStorage}function o(e){return r().getItem(e)}function i(e,t){return r().setItem(e,t)}function u(e){for(var t=r().length-1;t>=0;t--){var n=r().key(t);e(o(n),n)}}function a(e){return r().removeItem(e)}function s(){return r().clear()}var c=e("../src/util"),f=c.Global;t.exports={name:"localStorage",read:o,write:i,each:u,remove:a,clearAll:s}},{"../src/util":14}],18:[function(e,t,n){"use strict";function r(e){return s[e]}function o(e,t){s[e]=t}function i(e){for(var t in s)s.hasOwnProperty(t)&&e(s[t],t)}function u(e){delete s[e]}function a(e){s={}}t.exports={name:"memoryStorage",read:r,write:o,each:i,remove:u,clearAll:a};var s={}},{}],19:[function(e,t,n){"use strict";function r(e){return f[e]}function o(e,t){f[e]=t}function i(e){for(var t=f.length-1;t>=0;t--){var n=f.key(t);e(f[n],n)}}function u(e){return f.removeItem(e)}function a(){i(function(e,t){delete f[e]})}var s=e("../src/util"),c=s.Global;t.exports={name:"oldFF-globalStorage",read:r,write:o,each:i,remove:u,clearAll:a};var f=c.globalStorage},{"../src/util":14}],20:[function(e,t,n){"use strict";function r(e,t){if(!h){var n=s(e);g(function(e){e.setAttribute(n,t),e.save(p)})}}function o(e){if(!h){var t=s(e),n=null;return g(function(e){n=e.getAttribute(t)}),n}}function i(e){g(function(t){for(var n=t.XMLDocument.documentElement.attributes,r=n.length-1;r>=0;r--){var o=n[r];e(t.getAttribute(o.name),o.name)}})}function u(e){var t=s(e);g(function(e){e.removeAttribute(t),e.save(p)})}function a(){g(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(p);for(var n=t.length-1;n>=0;n--)e.removeAttribute(t[n].name);e.save(p)})}function s(e){return e.replace(/^d/,"___$&").replace(v,"___")}function c(){if(!d||!d.documentElement||!d.documentElement.addBehavior)return null;var e,t,n,r="script";try{t=new ActiveXObject("htmlfile"),t.open(),t.write("<"+r+">document.w=window'),t.close(),e=t.w.frames[0].document,n=e.createElement("div")}catch(o){n=d.createElement("div"),e=d.body}return function(t){var r=[].slice.call(arguments,0);r.unshift(n),e.appendChild(n),n.addBehavior("#default#userData"),n.load(p),t.apply(this,r),e.removeChild(n)}}var f=e("../src/util"),l=f.Global;t.exports={name:"oldIE-userDataStorage",write:r,read:o,each:i,remove:u,clearAll:a};var p="storejs",d=l.document,g=c(),h=(l.navigator?l.navigator.userAgent:"").match(/ (MSIE 8|MSIE 9|MSIE 10)\./),v=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g")},{"../src/util":14}],21:[function(e,t,n){"use strict";function r(){return f.sessionStorage}function o(e){return r().getItem(e)}function i(e,t){return r().setItem(e,t)}function u(e){for(var t=r().length-1;t>=0;t--){var n=r().key(t);e(o(n),n)}}function a(e){return r().removeItem(e)}function s(){return r().clear()}var c=e("../src/util"),f=c.Global;t.exports={name:"sessionStorage",read:o,write:i,each:u,remove:a,clearAll:s}},{"../src/util":14}]},{},[1])(1)}); \ No newline at end of file