Guest User

Untitled

a guest
Jan 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. (function(window.$) {
  2.  
  3. window.$.fn.tabbs = function(options) {
  4. var settings = {
  5. dir: 'top',
  6. trigger: 'a',
  7. target: '.tab-section',
  8. selected: 'selected'
  9. },
  10. html = $('html');
  11.  
  12. window.alert('jquery object: ' + window.$);
  13.  
  14. if (html.hasClass('no-js')) {
  15. html.removeClass('no-js').addClass('js');
  16. } else {
  17. html.addClass('js');
  18. }
  19.  
  20. var classAction = function(obj, action, cls) {
  21. window.$(obj)[action](cls);
  22. };
  23.  
  24. window.$.extend(settings, options);
  25.  
  26. return this.each(function() {
  27. var tabs = window.$(this),
  28. tab = tabs.find(settings.trigger),
  29. tabSection = window.$(settings.target),
  30. tabsSystemContainer = tabs.closest('div');
  31.  
  32. switch(settings.dir) {
  33. case 'left':
  34. tabsSystemContainer.removeClass(settings.dir || 'top').addClass('left' || settings.dir);
  35. break;
  36. default:
  37. tabsSystemContainer.removeClass('left' || settings.dir).addClass(settings.dir || 'top');
  38. }
  39. //this where I'm having problems
  40. tab.click(function(e) {
  41. var self = window.$(this);
  42.  
  43. e.preventDefault();
  44.  
  45. window.alert('Hello, inside tab click event...');
  46. });
  47. });
  48. };
  49. }(window.jQuery));
  50.  
  51. window.$('.tabs').tabbs();
Add Comment
Please, Sign In to add comment