Advertisement
YellowShark

Untitled

Nov 26th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*socialFeed plugin*/
  2. (function ($) {
  3. //$.fn.socialFeed = function( method ) {
  4.     var plugin_prototype = {
  5.         status: { facebook: null,
  6.             twitter: null},
  7.         ids: { facebook: null,
  8.             twitter: null},
  9.         name: '',
  10.         feed: [],
  11.         options: {},
  12.         //instance: null,
  13.         element: false,
  14.         _init:function(){
  15.             var instance = this;
  16.             var $el = $(instance.element);
  17.             $el.data('something',$el.attr('class'));
  18.            
  19.             instance.name += $el.attr('class');
  20.            
  21.            
  22.         }
  23.        
  24.  
  25.     }, defaults = {};
  26.  
  27.  
  28.     var pluginName = 'derpyDerp3';
  29.     // The actual plugin constructor
  30.     function Plugin(element, options) {
  31.         this.element = element;
  32.         this.options = $.extend({}, defaults, options);
  33.  
  34.         this._init();
  35.     } // Plugin()
  36.  
  37.     // extend that object into Plugin.prototype
  38.     $.extend(Plugin.prototype, plugin_prototype);
  39.  
  40.     // -------------------------------------------------------
  41.     // attach it to $.fn, and make the plugin voodoo happen:
  42.     $.fn[pluginName] = function (options) {
  43.         if ($(this).length === 0) {
  44.             return false;
  45.         }
  46.         var isMethodCall = (typeof options === 'string'),
  47.             args = Array.prototype.slice.call(arguments, 1);
  48.         // prevent calls to internal methods
  49.         if (isMethodCall && options.substring(0, 1) === '_') {
  50.             return this;
  51.         }
  52.         // handle initialization and non-getter methods
  53.         return this.each(function (z,el) {
  54.             console.log("mmm");
  55.             var instance = $(this).data(pluginName),
  56.             // constructor
  57.                 a = (!instance && !isMethodCall && $(this).data(pluginName, new Plugin(el, options))),
  58.             // method call
  59.                 b = (instance && isMethodCall && $.isFunction(instance[options]) && instance[options].apply(instance, args));
  60.         });
  61.     };
  62.  
  63.  
  64. })(jQuery);
  65.  
  66.  
  67.  
  68. var $el = $('.socialFeed')
  69.  
  70. $el.derpyDerp3();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement