Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. /**
  2. *
  3. */
  4.  
  5. (function ($) {
  6. PluginName = function () {
  7. this.init.apply(this, arguments);
  8. };
  9.  
  10.  
  11. PluginName.prototype = {
  12. constructor: PluginName.prototype.constructor,
  13. options: {
  14.  
  15. },
  16.  
  17. init: function (element, options) {
  18. //main element
  19. this.$element = element;
  20.  
  21. //set options
  22. this.options = this.setOptions(options);
  23. this.setElements();
  24. this.setEvents();
  25. },
  26.  
  27. setElements: function () {
  28. console.log('setElements');
  29. },
  30.  
  31. setEvents: function () {
  32. console.log('setEvents');
  33. },
  34.  
  35. setOptions:function(options) {
  36. var options = $.extend(true, {}, this.options, options);
  37. //check options on the node
  38. var pluginnameRe = new RegExp('^pluginName');
  39. var data = this.$element.data();
  40. for (var i in data) {
  41. if(i.indexOf('pluginName')==0 && data.hasOwnProperty(i)) {
  42.  
  43. }
  44. }
  45. }
  46. };
  47.  
  48.  
  49. //jquery plugin implementation
  50. $.fn.pluginName = function(options) {
  51. return this.each(function() {
  52. if(!$(this).data('PluginName'))
  53. $(this).data('PluginName', new PluginName(this, options));
  54. });
  55. };
  56. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement