From 0e24b6b25bed3fde0dfb606c13755aff83f816f2 Mon Sep 17 00:00:00 2001 From: Brett Slatkin Date: Sun, 23 Dec 2012 14:36:59 -0800 Subject: [PATCH] newui: Adds ServerConnection; basic plumbing through to BlobItemContainer Change-Id: I86f50c860bbebc1dc1790378cd23b7ae4b286398 --- .../camlistored/newui/blob_item_container.js | 18 ++++++++++--- server/camlistored/newui/index.css | 3 +++ server/camlistored/newui/index.html | 3 ++- server/camlistored/newui/index.js | 19 ++++++++++++-- server/camlistored/newui/server_connection.js | 25 +++++++++++++++++++ 5 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 server/camlistored/newui/index.css create mode 100644 server/camlistored/newui/server_connection.js diff --git a/server/camlistored/newui/blob_item_container.js b/server/camlistored/newui/blob_item_container.js index 0d77f4f47..bd5a13dde 100644 --- a/server/camlistored/newui/blob_item_container.js +++ b/server/camlistored/newui/blob_item_container.js @@ -14,13 +14,22 @@ goog.require('camlistore.BlobItem'); /** + * @param {camlistore.ServerConnection} connection Connection to the server + * for fetching blobrefs and other queries. * @param {goog.dom.DomHelper=} opt_domHelper DOM helper to use. * * @extends {goog.ui.Container} * @constructor */ -camlistore.BlobItemContainer = function(opt_domHelper) { +camlistore.BlobItemContainer = function(connection, opt_domHelper) { goog.base(this, opt_domHelper); + + /** + * @type {camlistore.ServerConnection} + * @private + */ + this.connection_ = connection; + /** * @type {goog.events.EventHandler} * @private @@ -63,7 +72,10 @@ camlistore.BlobItemContainer.prototype.disposeInternal = function() { */ camlistore.BlobItemContainer.prototype.enterDocument = function() { camlistore.BlobItemContainer.superClass_.enterDocument.call(this); - // Add event handlers here + + this.eh_.listen(this.getElement(), goog.events.EventType.CLICK, function() { + console.log('Printing from connection: ' + this.connection_.stupidHello()); + }); }; @@ -73,5 +85,5 @@ camlistore.BlobItemContainer.prototype.enterDocument = function() { */ camlistore.BlobItemContainer.prototype.exitDocument = function() { camlistore.BlobItemContainer.superClass_.exitDocument.call(this); - // Clear event handlers here + this.eh_.removeAll(); }; diff --git a/server/camlistored/newui/index.css b/server/camlistored/newui/index.css new file mode 100644 index 000000000..5c5c347e9 --- /dev/null +++ b/server/camlistored/newui/index.css @@ -0,0 +1,3 @@ +.cam-index-page { + font: 16px/1.4 normal Arial, sans-serif; +} diff --git a/server/camlistored/newui/index.html b/server/camlistored/newui/index.html index 60bfc5c54..c85c3930d 100644 --- a/server/camlistored/newui/index.html +++ b/server/camlistored/newui/index.html @@ -8,11 +8,12 @@ goog.require('camlistore.IndexPage'); + diff --git a/server/camlistored/newui/index.js b/server/camlistored/newui/index.js index e7bcc9132..6d0db0b98 100644 --- a/server/camlistored/newui/index.js +++ b/server/camlistored/newui/index.js @@ -9,7 +9,8 @@ goog.require('goog.dom.classes'); goog.require('goog.events.EventHandler'); goog.require('goog.events.EventType'); goog.require('goog.ui.Component'); - +goog.require('camlistore.BlobItemContainer'); +goog.require('camlistore.ServerConnection'); /** @@ -29,6 +30,19 @@ camlistore.IndexPage = function(config, opt_domHelper) { */ this.config_ = config; + /** + * @type {camlistore.ServerConnection} + * @private + */ + this.connection_ = new camlistore.ServerConnection(config); + + /** + * @type {camlistore.BlobItemContainer} + * @private + */ + this.blobItemContainer_ = new camlistore.BlobItemContainer( + this.connection_); + /** * @type {goog.events.EventHandler} * @private @@ -59,8 +73,9 @@ camlistore.IndexPage.prototype.decorateInternal = function(element) { var titleEl = this.dom_.createDom('h1', 'cam-index-page-title'); this.dom_.setTextContent(titleEl, this.config_.ownerName + '\'s Vault'); - this.dom_.appendChild(el, titleEl); + + this.addChild(this.blobItemContainer_, true); }; diff --git a/server/camlistored/newui/server_connection.js b/server/camlistored/newui/server_connection.js new file mode 100644 index 000000000..d490f376f --- /dev/null +++ b/server/camlistored/newui/server_connection.js @@ -0,0 +1,25 @@ +/** + * @fileoverview TODO + * + */ +goog.provide('camlistore.ServerConnection'); + + + +/** + * @param {camlistore.ServerType.DiscoveryDocument} config Discovery document + * for the current server. + * @constructor + */ +camlistore.ServerConnection = function(config) { + /** + * @type {camlistore.ServerType.DiscoveryDocument} + * @private + */ + this.config_ = config; +}; + + +camlistore.ServerConnection.prototype.stupidHello = function() { + return 'Hello'; +}; \ No newline at end of file