\r
// Now actually show the current settings\r
this.loadSettings();\r
+\r
+\r
},\r
\r
\r
\r
\r
\r
- _kiwi.applets.Settings = Backbone.Model.extend({\r
+ var Applet = Backbone.Model.extend({\r
initialize: function () {\r
this.set('title', 'Settings');\r
this.view = new View();\r
}\r
});\r
+\r
+\r
+ _kiwi.model.Applet.register('kiwi_settings', Applet);\r
})();
\ No newline at end of file
this.loaded_applet = null;\r
},\r
\r
+\r
// Load an applet within this panel\r
load: function (applet_object, applet_name) {\r
if (typeof applet_object === 'object') {\r
return this;\r
},\r
\r
+\r
loadFromUrl: function(applet_url, applet_name) {\r
var that = this;\r
\r
});\r
},\r
\r
+\r
close: function () {\r
this.view.$el.remove();\r
this.destroy();\r
\r
this.closePanel();\r
}\r
+},\r
+\r
+\r
+{\r
+ // Load an applet type once only. If it already exists, return that\r
+ loadOnce: function (applet_name) {\r
+\r
+ // See if we have an instance loaded already\r
+ var applet = _.find(_kiwi.app.panels.models, function(panel) {\r
+ // Ignore if it's not an applet\r
+ if (!panel.isApplet()) return;\r
+\r
+ // Ignore if it doesn't have an applet loaded\r
+ if (!panel.loaded_applet) return;\r
+\r
+ if (panel.loaded_applet.get('_applet_name') === applet_name) {\r
+ return true;\r
+ }\r
+ });\r
+\r
+ if (applet) return applet;\r
+\r
+\r
+ // If we didn't find an instance, load a new one up\r
+ return this.load(applet_name);\r
+ },\r
+\r
+\r
+ load: function (applet_name) {\r
+ var applet;\r
+\r
+ // Find the applet within the registered applets\r
+ if (!_kiwi.applets[applet_name]) return;\r
+\r
+ // Create the applet and load the content\r
+ applet = new _kiwi.model.Applet();\r
+ applet.load(new _kiwi.applets[applet_name]({_applet_name: applet_name}));\r
+\r
+ // Add it into the tab list\r
+ _kiwi.app.panels.add(applet);\r
+\r
+\r
+ return applet;\r
+ },\r
+\r
+\r
+ register: function (applet_name, applet) {\r
+ _kiwi.applets[applet_name] = applet;\r
+ }\r
});
\ No newline at end of file
member.set('away', !(!event.trailing));\r
}\r
});\r
- });
+ });\r
\r
\r
gw.on('onlist_start', function (data) {\r
}\r
\r
function settingsCommand (ev) {\r
- var panel = new _kiwi.model.Applet();\r
- panel.load(new _kiwi.applets.Settings());\r
- \r
- _kiwi.app.panels.add(panel);\r
- panel.view.show();\r
+ var settings = _kiwi.model.Applet.loadOnce('kiwi_settings');\r
+ settings.view.show();\r
}\r
\r
function appletCommand (ev) {\r