(function(window, $){ var PathvisioJs = function (element, options) { this._init(element, options) } var PathvisioJs_counter = 0; PathvisioJs.prototype._defaults = {} PathvisioJs.prototype._init = function(element, options) { this.$element = $(element).empty(); this.options = $.extend(true, {}, this._defaults, options) // Make this instance unique this.instanceId = ++PathvisioJs_counter; // TEST this.$element.append('Instance id: '+this.instanceId+'') // Init render this._initRender() return this; } PathvisioJs.prototype._initRender = function() { var renderer = require('./renderer.js') renderer.init(this) } // Plugin entry point $.fn.pathvisiojs = function (option) { var _arguments = arguments return this.each(function () { var $this = $(this) , data = $this.data('pathvisiojs') , options = typeof option == 'object' && option if (!data) { $this.data('pathvisiojs', (data = new PathvisioJs(this, options))) } if (typeof option == 'string') { if (data[option] === undefined) { $.error("PathvisioJs has no such method") } else if (typeof data[option] !== typeof function(){}) { $.error("PathvisioJs." + option + " is not a function") } else if (option.charAt(0) == '_') { $.error("PathvisioJs." + option + " is a private function") } else { data[option].call(data, Array.prototype.slice.call(_arguments, 1)) } } }) } })(window, jQuery)