Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. ;(function ($, window, document, undefined) {
  2.  
  3. var defaults = {
  4. type: 'standard',
  5. };
  6. var methods = {
  7. init: function(options){
  8. console.log('IN - INIT()');
  9. if(options){
  10. $.extend(defaults, options);
  11. }
  12. },
  13. show: function(arg){
  14. console.log('IN - SHOW()');
  15. var $this = this; // Here might be the problem
  16. this.addClass(arg.type);
  17. this.find('.close-button').on('click', function(){
  18. $this.hide(); // Here might be the problem
  19. });
  20. },
  21. hide: function(){
  22. console.log('IN - HIDE()');
  23. }
  24. };
  25.  
  26. $.fn.plugin = function(method){
  27. var args = arguments;
  28. var $this = this;
  29. return this.each(function(){
  30. if(methods[method]){
  31. return methods[method].apply($this, Array.prototype.slice.call(args, 1));
  32. }else if (typeof method === 'object' || ! method){
  33. return methods.init.apply($this, Array.prototype.slice.call(args, 0));
  34. }else{
  35. $.error('Method ' + method + ' does not exist on jQuery.plugin');
  36. }
  37. });
  38. };
  39.  
  40. }(jQuery, window, document));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement