newui: Adds ServerConnection; basic plumbing through to BlobItemContainer

Change-Id: I86f50c860bbebc1dc1790378cd23b7ae4b286398
This commit is contained in:
Brett Slatkin 2012-12-23 14:36:59 -08:00
parent 31baa0c212
commit 0e24b6b25b
5 changed files with 62 additions and 6 deletions

View File

@ -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();
};

View File

@ -0,0 +1,3 @@
.cam-index-page {
font: 16px/1.4 normal Arial, sans-serif;
}

View File

@ -8,11 +8,12 @@
goog.require('camlistore.IndexPage');
</script>
<link rel="stylesheet" href="blob_item.css" type="text/css">
<link rel="stylesheet" href="index.css" type="text/css">
</head>
<body>
<script>
var page = new camlistore.IndexPage(window.CAMLISTORE_CONFIG);
page.render(document.body);
page.decorate(document.body);
</script>
</body>
</html>

View File

@ -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);
};

View File

@ -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';
};