日期:2014-05-16 浏览次数:20358 次
(function (window) { var floatMenu = function (settings) { return new floatMenu.fn.init(settings); }; floatMenu.fn = floatMenu.prototype = { version: "1.0", init: function (settings) { this.settings = {}; util.extends(this.settings, settings); }, load: function () { return this.settings.hello; } } floatMenu.fn.init.prototype = floatMenu.fn; var util = { extends: function (collection, collectionOverride) { if (collectionOverride && collection) { for (var key in collectionOverride) { collection[key] = collectionOverride[key]; } } } }; if (window) { window.$fm = window.floatMenu = floatMenu; } })(window); var fm1 = $fm({ "hello": "world2" }); var fm2 = $fm({ "hello": "world3" }); alert(fm1.load()); alert(fm2.load()); alert(fm1.load()); alert(fm2.load());
function (settings) { this.settings = {}; util.extends(this.settings, settings); }