app/assets/javascripts/peeker.js in peeker-0.1.4 vs app/assets/javascripts/peeker.js in peeker-0.1.5
- old
+ new
@@ -1,17 +1,16 @@
(function (window, document, undefined) {
// Find peek element
var peekElement = document.querySelector("#peek");
- var socialPlugins = document.querySelectorAll(".social-plugin");
+
// Check existence of peek element
if (!peekElement)
return false;
- // Initialize social-plugin style with localStorage
- var display = localStorage.getItem("peekStatus");
- setSocialPluginStyleInBlogIndex(socialPlugins, display);
+ // Build event
+ var event = new Event('peek');
// Listener Class
var Listener = function (target, handler) {
this.target = new RegExp(target, "i");
this.queue = "";
@@ -27,14 +26,13 @@
// Target
var target = "peek";
// Handler
var handler = function () {
- var display = getPeekStatusFromLocalStorage();
- peekElement.style.display = display;
- setSocialPluginStyleInBlogIndex(socialPlugins, display);
+ peekElement.style.display = (localStorage.getItem("peekStatus") == "none") ? "block" : "none";
localStorage.setItem("peekStatus", peekElement.style.display);
+ window.dispatchEvent(event);
};
// Set peekStatus with localStorage
if (!localStorage.getItem("peekStatus"))
localStorage.setItem("peekStatus", "none");
@@ -48,18 +46,5 @@
peekListener.queue = peekListener.queue.concat(String.fromCharCode(e.keyCode));
peekListener.compare();
});
})(window, document);
-
-
-function setSocialPluginStyleInBlogIndex(socialPlugins, display) {
- if (!!socialPlugins.length) {
- for(var i = 0; i < socialPlugins.length; i++) {
- socialPlugins[i].style.display = display;
- }
- }
-}
-
-function getPeekStatusFromLocalStorage() {
- return (localStorage.getItem("peekStatus") == "none") ? "block" : "none";
-}