define(function(require) { var eo = require("../platform/EventObject.js"); var $ = require("jquery"); function ProfileList(imptlist) { var __ = this; this.list = []; this.add = function (p) { if (!p || !(p instanceof Profile)) return; p.on("requireSave", function () { __.save(); }); __.list.push(p); __.fireEvent("added", [p]); __.save(); }; this.remove = function (p) { var idx = __.list.indexOf(p); if (idx == -1) return; __.list.splice(idx, 1); __.fireEvent("removed", [p]); __.save(); }; this.save = function () { __.fireEvent("requireSave"); }; this.find = function (name) { return _.find(__.list, function (e) { return e.name == name; }); }; if (imptlist) { $.each(imptlist, function () { __.list.push(new Profile(this)); }); } return this; } ProfileList.prototype = Object.create(eo); ProfileList.constructor = ProfileList; return ProfileList; });