]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - themes/baggy/js/init.js
bagit link + overlay save link + listmode
[github/wallabag/wallabag.git] / themes / baggy / js / init.js
index 4a843548c92e9256de2e24a466c353c278311b75..99bffd09b20b30840c07cac757ba787a60120850 100755 (executable)
@@ -1,36 +1,75 @@
-$(document).ready(function() {
+$.fn.ready(function() {
+
+  var $listmode = $('#listmode'),
+      $listentries = $("#list-entries"),
+      $bagit = $('#bagit'),
+      $bagitForm = $('#bagit-form');
+
+  /* ==========================================================================
+     Menu
+     ========================================================================== */
 
   $("#menu").click(function(){
     $("#links").toggle();
   });
 
+  /* ==========================================================================
+     List mode or Table Mode
+     ========================================================================== */
 
-  $("#listmode").click(function(){
+  $listmode.click(function(){
     if ( $.cookie("listmode") == 1 ) {
-      $(".entrie").css("width", "");
-      $(".entrie").css("margin-left", "");
-
+      // Cookie
       $.removeCookie("listmode");
-      $("#listmode").removeClass("tablemode");
-      $("#listmode").addClass("listmode");
+
+      $listentries.removeClass("listmode");
+      $listmode.removeClass("tablemode");
+      $listmode.addClass("listmode");
     }
     else {
+      // Cookie
       $.cookie("listmode", 1, {expires: 365});
 
-      $(".entrie").css("width", "100%");
-      $(".entrie").css("margin-left", "0");
-      $("#listmode").removeClass("listmode");
-      $("#listmode").addClass("tablemode");
+      $listentries.addClass("listmode");
+      $listmode.removeClass("listmode");
+      $listmode.addClass("tablemode");
     }
 
   });
 
+  /* ==========================================================================
+     Cookie listmode
+     ========================================================================== */
+
   if ( $.cookie("listmode") == 1 ) {
-    $(".entrie").css("width", "100%");
-    $(".entrie").css("margin-left", "0");
-    $("#listmode").removeClass("listmode");
-    $("#listmode").addClass("tablemode");
+    $listentries.addClass("listmode");
+    $listmode.removeClass("listmode");
+    $listmode.addClass("tablemode");
   }
 
+  /* ==========================================================================
+     bag it link
+     ========================================================================== */
+
+  $bagit.click(function(){
+    $bagitForm.toggle();
+  });
+
+  /* ==========================================================================
+     Keyboard gestion
+     ========================================================================== */
+
+  $(window).keydown(function(e){
+    switch (e.keyCode) {
+      // s letter
+      case 83:
+        $bagitForm.toggle();
+      break;
+      case 27:
+        $bagitForm.hide();
+      break;
+    }
+  })
+
 
-});
+});
\ No newline at end of file