Added:
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/_package.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/application.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/AccountController.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/PreferencesController.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/RosterController.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/_package.js.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/AccountModel.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/RosterModel.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/_package.js.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/LoginView.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RegistrationView.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RosterView.js
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/_package.js.js
Removed:
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/soashable.js
Modified:
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
Log:
broke up mamoth and added pseudo-package loader code to assembly
Modified: branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
==============================================================================
---
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml (original)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/assembler/soashable-web.xml
Mon Aug 4 22:13:08 2008
@@ -1,6 +1,21 @@
<?xml version="1.0"?>
<assembler>
<scripts>
-
+ <script>
+ <fileName>soashable.js</fileName>
+ <includes>
+ <include>_package.js</include>
+ <include>*.js</include>
+
+ <include>model/_package.js</include>
+ <include>model/*.js</include>
+
+ <include>view/_package.js</include>
+ <include>view/*.js</include>
+
+ <include>controller/_package.js</include>
+ <include>controller/*.js</include>
+ </includes>
+ </script>
</scripts>
</assembler>
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/_package.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/_package.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1 @@
+Xmpp4Js.Lang.namespace("soashable");
\ No newline at end of file
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/application.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/application.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,62 @@
+Xmpp4Js.Lang.namespace("soashable");
+
+/**
+ * The main class for the Soashable application. Holds and manages controllers.
+ */
+soashable.Application = function() {
+ this.controllers = {};
+
+ this.addEvents({
+ /**
+ * @event controller_added
+ * @param name {String} the name of the controller
+ * @param controller {Object} the controller
+ */
+ controller_added: true,
+
+ /**
+ * @event controller_removed
+ * @param name {String} the name of the controller
+ * @param controller {Object} the controller
+ */
+ controller_removed: true
+ });
+}
+
+soashable.Application.prototype = {
+ createControllers: function() {
+ this.controllers = {
+ //chat: new soashable.controller.ChatController(this),
+ roster: new soashable.controller.RosterController(this),
+ account: new soashable.controller.AccountController(this),
+ prefernces: new soashable.controller.PreferencesController(this)
+ //gateway: new soashable.controller.GatewayController(this)
+ //presence: new soashable.controller.PresenceController(this)
+ }
+
+ // run events after all controllers are added so that they can all
+ // have a chance to know when the others have been added.
+ // - how can new controllers be informed when an existing one
is added?
+ // fire events for all current ones when it is added?
+ for( var k in this.controllers ) {
+ this.fireEvent( "controller_added", k, this.controllers[k] );
+ }
+
+ },
+
+ start: function() {
+ this.createControllers();
+
+ // TODO should there be a start event that controllers listen for?
+ this.getController("account").showLoginScreen();
+ },
+
+ getController: function(name) {
+ return this.controllers[name];
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.Application,
Xmpp4Js.Event.EventProvider, soashable.Application.prototype );
+
+
+
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/AccountController.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/AccountController.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,78 @@
+
+
+/**
+ * Manages account registration and login; handles interaction with server.
+ */
+soashable.controller.AccountController = function(application) {
+ this.application = application;
+
+ this.accountModel = new soashable.model.AccountModel();
+
+ // create views
+ this.loginView = new soashable.view.LoginView(application, this.accountModel);
+ this.registrationView = new
soashable.view.RegistrationView(application, this.accountModel);
+
+
+ this.addEvents({
+ login_success: true,
+ login_failure: true,
+ registration_success: true,
+ registration_failure: true,
+ logged_out: true
+ })
+
+
+ // setup event listeners
+ application.on( "controller_added", this.controllerAdded, this);
+
+ this.loginView.on( "login_clicked", this.loginClicked, this );
+ this.loginView.on( "register_clicked", this.loginRegisterClicked,
this );
+ this.registrationView.on( "register_clicked",
this.registerClicked, this );
+}
+
+soashable.controller.AccountController.prototype = {
+
+ showLoginScreen: function() {
+ this.loginView.render();
+ },
+
+
+
+
+ controllerAdded: function(name, controller) {
+ if( controller instanceof
soashable.controller.PreferencesController ) {
+ this.accountModel.domain = controller.get( "domain" );
+ }
+ },
+
+ loginClicked: function() {
+ alert("Going to login: "+this.accountModel.node+", password="+this.accountModel.password);
+
+ var self = this;
+ setTimeout(function() {
+
+ self.loginSuccess();
+ }, 250);
+ },
+
+ loginSuccess: function() {
+ this.loginView.destroy();
+ this.fireEvent("login_success");
+ },
+
+ loggedOut: function() {
+ this.loginView.render();
+ this.fireEvent("logged_out");
+ },
+
+ loginRegisterClicked: function() {
+ this.registrationView.render();
+ //this.loginView.destroy();
+ },
+
+ registerClicked: function() {
+ alert("Going to register account: "+this.accountModel.node+", password="+this.accountModel.password);
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.AccountController,
Xmpp4Js.Event.EventProvider,
soashable.controller.AccountController.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/PreferencesController.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/PreferencesController.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,21 @@
+
+/**
+ * Holds and manages preferences for use by other controllers.
+ */
+soashable.controller.PreferencesController = function(application) {
+ this.application = application;
+ this.map = {
+ domain: "soashable.com"
+ };
+}
+
+soashable.controller.PreferencesController.prototype = {
+ get: function(key) {
+ return this.map[key];
+ },
+ set: function(key, value) {
+ this.map[key] = value;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.PreferencesController,
Xmpp4Js.Event.EventProvider,
soashable.controller.PreferencesController.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/RosterController.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/RosterController.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,35 @@
+
+/**
+ * Responsible for managing the roster.
+ */
+soashable.controller.RosterController = function(application) {
+ this.application = application;
+ this.rosterModel = new soashable.model.RosterModel();
+
+ this.rosterView = new soashable.view.RosterView(application, this.rosterModel);
+
+ this.application.on("controller_added", this.controllerAdded, this);
+}
+
+soashable.controller.RosterController.prototype = {
+ controllerAdded: function(name, controller) {
+ if( controller instanceof
soashable.controller.AccountController ) {
+ // FIXME tightly coupled
+ this.accountModel = controller.accountModel;
+ controller.on( "login_success", this.loginSuccess, this );
+ controller.on( "logged_out", this.loggedOut, this );
+ }
+ },
+
+ loginSuccess: function() {
+ this.rosterView.render();
+ },
+
+ loggedOut: function() {
+ this.rosterView.destroy();
+ }
+
+}
+
+Xmpp4Js.Lang.extend( soashable.controller.RosterController,
Xmpp4Js.Event.EventProvider,
soashable.controller.RosterController.prototype );
+
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/_package.js.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/controller/_package.js.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1 @@
+Xmpp4Js.Lang.namespace("soashable.controller");
\ No newline at end of file
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/AccountModel.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/AccountModel.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,22 @@
+
+/**
+ * The model for registration and login information.
+ */
+soashable.model.AccountModel = function() {
+ this.domain = "";
+ this.node = "";
+ this.resource = "";
+ this.password = "";
+ this.priority = 5;
+ this.email = "";
+
+ this.addEvents({
+ update: true
+ });
+}
+
+soashable.model.AccountModel.prototype = {
+
+}
+
+Xmpp4Js.Lang.extend( soashable.model.AccountModel,
Xmpp4Js.Event.EventProvider, soashable.model.AccountModel.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/RosterModel.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/RosterModel.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,14 @@
+
+
+/**
+ * The model that represents a users' roster
+ */
+soashable.model.RosterModel = function() {
+
+}
+
+soashable.model.RosterModel.prototype = {
+
+}
+
+Xmpp4Js.Lang.extend( soashable.model.RosterModel,
Xmpp4Js.Event.EventProvider, soashable.model.RosterModel.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/_package.js.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/model/_package.js.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1 @@
+Xmpp4Js.Lang.namespace("soashable.model");
\ No newline at end of file
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/LoginView.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/LoginView.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,65 @@
+
+/**
+ * Responsible for rendering a login screen. Updates AccountModel.
+ */
+soashable.view.LoginView = function(application, accountModel) {
+ this.application = application;
+ this.accountModel = accountModel;
+
+ this.addEvents({
+ login_clicked: true,
+ register_clicked: true
+ });
+
+ this.accountModel.on("update", this.accountModelUpdated, this );
+}
+
+soashable.view.LoginView.prototype = {
+ render: function() {
+ jQuery("<div id=\"login\"><dl>"
+ + "<dt>username</dt><dd><input type=\"text\" id=\"login-node\"/></dd>"
+ + "<dt>password</dt><dd><input type=\"text\" id=\"login-password\"/></dd>"
+ + "<dt></dt><dd><button id=\"login-button\">Login</button></dd>"
+ + "<dt></dt><dd><button
id=\"login-register-button\">Registration Form</button></dd>"
+ + "</dl></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("login");
+ this.nodeEl = document.getElementById("login-node");
+ this.passwordEl = document.getElementById("login-password");
+ this.buttonEl = document.getElementById("login-button");
+ this.registerButtonEl = document.getElementById("login-register-button");
+
+ var self = this;
+ this.buttonEl.addEventListener("click", function() {
self.loginClicked(); }, false);
+ this.registerButtonEl.addEventListener("click", function() {
self.registerClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+
+
+
+ loginClicked: function() {
+ this.accountModel.node = this.nodeEl.value;
+ this.accountModel.password = this.passwordEl.value;
+ this.accountModel.resource = "xmpp4js";
+ this.accountModel.priority = 5;
+
+ // TODO should this happen in account model
+ this.accountModel.fireEvent("update");
+
+ this.fireEvent("login_clicked");
+ },
+ registerClicked: function() {
+ this.fireEvent("register_clicked");
+ },
+ accountModelUpdated: function() {
+ this.nodeEl.value = this.accountModel.node;
+ this.passwordEl.value = this.accountModel.password;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.LoginView,
Xmpp4Js.Event.EventProvider, soashable.view.LoginView.prototype );
+
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RegistrationView.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RegistrationView.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,56 @@
+
+/**
+ * Responsible for rendering a registration screen. Updates AccountModel.
+ */
+soashable.view.RegistrationView = function(application, accountModel) {
+ this.application = application;
+ this.accountModel = accountModel;
+
+ this.addEvents({
+ register_clicked: true
+ });
+
+ this.accountModel.on("update", this.accountModelUpdated, this );
+}
+
+soashable.view.RegistrationView.prototype = {
+ render: function() {
+ jQuery("<div id=\"registration\"><dl>"
+ + "<dt>username</dt><dd><input type=\"text\" id=\"register-node\"/></dd>"
+ + "<dt>password</dt><dd><input type=\"text\" id=\"register-password\"/></dd>"
+ + "<dt></dt><dd><button id=\"register-button\">Register</button></dd>"
+ + "</dl></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("registration");
+ this.nodeEl = document.getElementById("register-node");
+ this.passwordEl = document.getElementById("register-password");
+ this.buttonEl = document.getElementById("register-button");
+
+ var self = this;
+ this.buttonEl.addEventListener("click", function() {
self.registerClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+
+
+ registerClicked: function() {
+
+ this.accountModel.node = this.nodeEl.value;
+ this.accountModel.password = this.passwordEl.value;
+
+ this.accountModel.fireEvent("update");
+
+ this.fireEvent("register_clicked");
+ },
+
+ accountModelUpdated: function() {
+ this.nodeEl.value = this.accountModel.node;
+ this.passwordEl.value = this.accountModel.password;
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.RegistrationView,
Xmpp4Js.Event.EventProvider, soashable.view.RegistrationView.prototype );
+
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RosterView.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/RosterView.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1,39 @@
+
+/**
+ * Responsible for rendering a roster and its list
+ */
+soashable.view.RosterView = function(application, rosterModel) {
+ this.application = application;
+ this.rosterModel = rosterModel;
+}
+
+soashable.view.RosterView.prototype = {
+ addContact: function(jid, alias, group) {
+ jQuery(this.listEl).append("<li><a
href=\"#"+jid+"\">"+alias+"</a></li>" );
+ },
+
+ render: function() {
+ jQuery("<div id=\"roster\"><ul id=\"roster-list\"></ul>"
+ + "<div id=\"roster-toolbar\">"
+ + "<button id=\"roster-toolbar-im\">Send IM</button>"
+ + "</div></div>").appendTo(jQuery("body"));
+
+ this.mainEl = document.getElementById("roster");
+ this.listEl = document.getElementById("roster-list");
+ this.toolbarEl = document.getElementById("register-toolbar");
+ this.imEl = document.getElementById("roster-toolbar-im");
+
+ var self = this;
+ this.imEl.addEventListener("click", function() {
self.sendImClicked(); }, false);
+ },
+ destroy: function() {
+ jQuery(this.mainEl).remove();
+ this.mainEl = null;
+ },
+
+ sendImClicked: function() {
+ alert( "Send IM" );
+ }
+}
+
+Xmpp4Js.Lang.extend( soashable.view.RosterView,
Xmpp4Js.Event.EventProvider, soashable.view.RosterView.prototype );
Added: branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/_package.js.js
==============================================================================
--- (empty file)
+++
branches/soashable_web_2_0_mvc/soashable-web/src/main/javascript/view/_package.js.js
Mon Aug 4 22:13:08 2008
@@ -0,0 +1 @@
+Xmpp4Js.Lang.namespace("soashable.view");
\ No newline at end of file