From 721ad945107406325000fe828be91a2e047a5dfa Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 16 Sep 2012 12:22:50 +0100 Subject: [PATCH] Global objects started --- client_backbone/dev/app.js | 8 +++-- client_backbone/dev/applet_nickserv.js | 38 ++++++++++++++++++++++++ client_backbone/dev/build.js | 1 + client_backbone/dev/model_application.js | 9 +++++- client_backbone/index.html | 5 +++- 5 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 client_backbone/dev/applet_nickserv.js diff --git a/client_backbone/dev/app.js b/client_backbone/dev/app.js index 329b3a0..c680b41 100644 --- a/client_backbone/dev/app.js +++ b/client_backbone/dev/app.js @@ -15,9 +15,13 @@ kiwi.applets = {}; * and data (think: plugins) */ kiwi.global = { + utils: undefined, // Re-usable methods gateway: undefined, user: undefined, server: undefined, + command: undefined, // The control box + + // TODO: think of a better term for this as it will also refer to queries channels: undefined, // Entry point to start the kiwi application @@ -33,9 +37,7 @@ kiwi.global = { kiwi.app.start(); return true; - }, - - utils: undefined // Re-usable methods + } }; diff --git a/client_backbone/dev/applet_nickserv.js b/client_backbone/dev/applet_nickserv.js new file mode 100644 index 0000000..0244d1d --- /dev/null +++ b/client_backbone/dev/applet_nickserv.js @@ -0,0 +1,38 @@ +(function () { + var View = Backbone.View.extend({ + events: { + 'click .save': 'saveSettings' + }, + + initialize: function (options) { + this.$el = $($('#tmpl_applet_settings').html()); + }, + + saveSettings: function () { + var theme = $('.theme', this.$el).val(), + containers = $('#panels > .panel_container'); + + // Clear any current theme + containers.removeClass(function (i, css) { + return (css.match (/\btheme_\S+/g) || []).join(' '); + }); + + if (theme) containers.addClass('theme_' + theme); + } + }); + + + + kiwi.applets.nickserv = Backbone.Model.extend({ + initialize: function () { + this.set('title', 'Nickserv Login'); + //this.view = new View(); + + kiwi.global.control.on('command_login', this.loginCommand, this); + }, + + loginCommand: function (event) { + console.log('waheeyy'); + } + }); +})(); \ No newline at end of file diff --git a/client_backbone/dev/build.js b/client_backbone/dev/build.js index 8ec86d4..58b4c5f 100644 --- a/client_backbone/dev/build.js +++ b/client_backbone/dev/build.js @@ -27,6 +27,7 @@ var src = concat([ __dirname + '/model_applet.js', __dirname + '/applet_settings.js', + __dirname + '/applet_nickserv.js', __dirname + '/utils.js', __dirname + '/view.js' diff --git a/client_backbone/dev/model_application.js b/client_backbone/dev/model_application.js index a33e910..d78da3c 100644 --- a/client_backbone/dev/model_application.js +++ b/client_backbone/dev/model_application.js @@ -37,6 +37,8 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { this.bindGatewayCommands(kiwi.gateway); this.initializeClient(); + this.initializeGlobals(); + this.view.barsHide(true); this.panels.server.server_login.bind('server_connect', function (event) { @@ -115,6 +117,11 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { }; + this.initializeGlobals = function () { + kiwi.global.control = this.controlbox; + }; + + this.bindGatewayCommands = function (gw) { gw.on('onmotd', function (event) { @@ -644,7 +651,7 @@ kiwi.model.Application = Backbone.Model.extend(new (function () { } else { // Load a pre-loaded applet if (kiwi.applets[ev.params[0]]) { - panel.load(new kiwi.applets[ev.params[0]]); + panel.load(new kiwi.applets[ev.params[0]]()); } else { kiwi.app.panels.server.addMsg('', 'Applet "' + ev.params[0] + '" does not exist'); return; diff --git a/client_backbone/index.html b/client_backbone/index.html index a73c661..d390366 100644 --- a/client_backbone/index.html +++ b/client_backbone/index.html @@ -133,7 +133,10 @@ 'dev/model_applet.js' ], - ['dev/applet_settings.js'], + [ + 'dev/applet_settings.js', + 'dev/applet_nickserv.js' + ], [ 'dev/utils.js', -- 2.25.1