Last active
December 10, 2015 07:08
-
-
Save MartijnR/4398882 to your computer and use it in GitHub Desktop.
jQuery plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
"use strict"; | |
var MyWidget = function(element, options) { | |
this.init(); | |
}; | |
GeopointWidget.prototype = { | |
constructor: GeopointWidget, | |
init: function(){} | |
}; | |
$.fn.myWidget = function(option) { | |
return this.each(function() { | |
var $this = $(this), | |
data = $(this).data('mywidget'), | |
options = typeof option == 'object' && option; | |
if (!data){ | |
$this.data('mywidget', (data = new myWidget(this, options))); | |
} | |
if (typeof option == 'string') { | |
data[option](); | |
} | |
}); | |
}; | |
$.fn.geopointWidget.Constructor = MyWidget; | |
})(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment