Guest User

Untitled

a guest
Jul 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. (function($) {
  2.  
  3. // jQuery plugin definition
  4. $.fn.pushLayers = function(params) {
  5. //alert($(this).css('z-index'));
  6. var numElems = $(this).parent().children().length; //get number of DOM nodes in the continer DIV
  7. var removed_index = $(this).css('z-index');
  8.  
  9. // merge default and user parameters
  10. params = $.extend( {numElements: numElems, removedZ: removed_index}, params);
  11.  
  12. // traverse all nodes
  13. $(this).parent().children().each(function() /*this is an anonymous function*/{
  14.  
  15. // express a single node as a jQuery object
  16. //var $t = $(this);
  17.  
  18. // if z-index is greater than the z-index of removed card, decrease z-index by 1.
  19. if ($(this).css('z-index') > removedZ) {
  20.  
  21. //decrease z-index
  22. $(this).css('z-index', parseInt($(this).css('z-index'))-1);
  23. }
  24. // remove card and place it at front
  25. if ($(this).css('z-index') == removed_index){
  26. $(this).css('z-index', numElems);
  27.  
  28. }
  29.  
  30. });
  31.  
  32. // allow jQuery chaining
  33. return this;
  34. };
  35.  
  36. })(jQuery);
Add Comment
Please, Sign In to add comment