]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/baggy/js/saveLink.js
clean & lint stuff
[github/wallabag/wallabag.git] / app / Resources / static / themes / baggy / js / saveLink.js
index 91cc2c3fab58d2909eef681ea08099e8eca6faab..5c72088629e5657371705f98a14b951e7e17eaea 100755 (executable)
@@ -1,60 +1,60 @@
-$.fn.ready(function() {
+var $ = global.jquery = require('jquery');
 
-  var $bagit = $('#bagit'),
-      $bagitForm = $('#bagit-form'),
-      $bagitFormForm = $('#bagit-form-form');
+$.fn.ready(function () {
+  var $bagit = $('#bagit');
+  var $bagitForm = $('#bagit-form');
+  var $bagitFormForm = $('#bagit-form-form');
 
   /* ==========================================================================
    bag it link and close button
    ========================================================================== */
 
   function toggleSaveLinkForm(url, event) {
-    $("#add-link-result").empty();
+    $('#add-link-result').empty();
 
-    $bagit.toggleClass("active-current");
+    $bagit.toggleClass('active-current');
 
-    //only if bag-it link is not presented on page
-    if ( $bagit.length === 0 ) {
-      if ( event !== 'undefined' && event ) {
-        $bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200});
-      }
-      else {
-        $bagitForm.css( {position:"relative", top:"auto", left:"auto"});
+    // only if bag-it link is not presented on page
+    if ($bagit.length === 0) {
+      if (event !== 'undefined' && event) {
+        $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
+      } else {
+        $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
       }
     }
 
-    if ($("#search-form").length != 0) {
-       $("#search").removeClass("current");
-       $("#search-arrow").removeClass("arrow-down");
-       $("#search-form").hide();
+    if ($('#search-form').length !== 0) {
+      $('#search').removeClass('current');
+      $('#search-arrow').removeClass('arrow-down');
+      $('#search-form').hide();
     }
     $bagitForm.toggle();
-    $('#content').toggleClass("opacity03");
+    $('#content').toggleClass('opacity03');
     if (url !== 'undefined' && url) {
       $('#plainurl').val(url);
     }
     $('#plainurl').focus();
   }
 
-  //send "bag it link" form request via ajax
-  $bagitFormForm.submit( function(event) {
-    $("body").css("cursor", "wait");
-    $("#add-link-result").empty();
+  // send 'bag it link' form request via ajax
+  $bagitFormForm.submit(function (event) {
+    $('body').css('cursor', 'wait');
+    $('#add-link-result').empty();
 
     $.ajax({
       type: $bagitFormForm.attr('method'),
       url: $bagitFormForm.attr('action'),
       data: $bagitFormForm.serialize(),
-      success: function(data) {
-        $('#add-link-result').html("Done!");
+      success: function (data) {
+        $('#add-link-result').html('Done!');
         $('#plainurl').val('');
         $('#plainurl').blur('');
-        $("body").css("cursor", "auto");
+        $('body').css('cursor', 'auto');
+      },
+      error: function (data) {
+        $('#add-link-result').html('Failed!');
+        $('body').css('cursor', 'auto');
       },
-      error: function(data) {
-        $('#add-link-result').html("Failed!");
-        $("body").css("cursor", "auto");
-      }
     });
 
     event.preventDefault();
@@ -64,15 +64,12 @@ $.fn.ready(function() {
    Process all links inside an article
    ========================================================================== */
 
-  $("article a[href^='http']").after(function() {
-    return " <a href=\"" + $(this).attr('href') + "\" class=\"add-to-wallabag-link-after\" alt=\"add to wallabag\" title=\"add to wallabag\"></a> ";
+  $('article a[href^="http"]').after(function () {
+    return ' <a href="' + $(this).attr('href') + '" class="add-to-wallabag-link-after" alt="add to wallabag" title="add to wallabag"></a> ';
   });
 
-  $(".add-to-wallabag-link-after").click(function(event){
+  $('.add-to-wallabag-link-after').click(function (event) {
     toggleSaveLinkForm($(this).attr('href'), event);
     event.preventDefault();
   });
-
 });
-
-