Advertisement
Beee

lightbox.js

Oct 23rd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     console.log('-= reject image lightbox');
  2.  
  3.     // Place this inside footer.php or into a JS file and use enqueue_script to load it in the more wp'ish way
  4.     jQuery(function($){
  5.         // this one creates a click function for every object that has the CSS class .popup-remove-image
  6.         $(".popup-remove-image").click(function(e){
  7.             // we disable the default click action of the clicked element
  8.             e.preventDefault();
  9.             // we save the data attributes of the clicked element into variables (not a must, you could call the directly)
  10.             // Call the lightbox function and pass the arguments
  11.             var reject_image;
  12.             reject_image = $(this).data('reject-image');
  13.             console.log(reject_image);
  14.             lightbox_open(reject_image);
  15.         });
  16.     });
  17.  
  18.     window.document.onkeydown = function (e)
  19.     {
  20.         if (!e){
  21.             e = event;
  22.         }
  23.         if (e.keyCode == 27){
  24.             lightbox_close();
  25.         }
  26.     }
  27.     function lightbox_open(){
  28.         window.scrollTo(0,0);
  29.         document.getElementById('light').style.display='block';
  30.         document.getElementById('fade').style.display='block';
  31.     }
  32.     function lightbox_close(){
  33.         document.getElementById('light').style.display='none';
  34.         document.getElementById('fade').style.display='none';
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement