newui: kinda wiring up the create button

Change-Id: Ib114da06c89543fda71104eef49433c100f60112
This commit is contained in:
Brad Fitzpatrick 2012-12-23 15:59:01 -08:00
parent eaa22b2dbc
commit 2766e2d60f
2 changed files with 17 additions and 3 deletions

View File

@ -12,7 +12,7 @@ goog.require('goog.events.EventHandler');
goog.require('goog.events.EventType');
goog.require('goog.ui.Container');
goog.require('camlistore.BlobItem');
goog.require('camlistore.CreateItem');
/**
@ -41,6 +41,13 @@ camlistore.BlobItemContainer = function(connection, opt_domHelper) {
goog.inherits(camlistore.BlobItemContainer, goog.ui.Container);
camlistore.BlobItemContainer.prototype.hasCreateItem_ = false;
camlistore.BlobItemContainer.prototype.setHasCreateItem = function(v) {
this.hasCreateItem_ = v;
};
/**
* @enum {string}
*/
@ -82,6 +89,7 @@ camlistore.BlobItemContainer.prototype.disposeInternal = function() {
camlistore.BlobItemContainer.prototype.enterDocument = function() {
camlistore.BlobItemContainer.superClass_.enterDocument.call(this);
this.resetChildren_();
this.eh_.listen(
this, camlistore.BlobItemContainer.EventType.SHOW_RECENT,
this.showRecent_);
@ -107,13 +115,18 @@ camlistore.BlobItemContainer.prototype.showRecent_ = function() {
100); // TODO(bslatkin): Use instance variable for thumbnail size
};
camlistore.BlobItemContainer.prototype.resetChildren_ = function(result) {
this.removeChildren(true);
if (this.hasCreateItem_) {
this.addChild(new camlistore.CreateItem(), true);
}
}
/**
* @param {Object} result JSON response to this request.
*/
camlistore.BlobItemContainer.prototype.showRecentDone_ = function(result) {
this.removeChildren(true);
this.resetChildren_();
for (var i = 0, n = result.recent.length; i < n; i++) {
var blobRef = result.recent[i].blobref;
var item = new camlistore.BlobItem(blobRef, result);

View File

@ -43,6 +43,7 @@ camlistore.IndexPage = function(config, opt_domHelper) {
*/
this.blobItemContainer_ = new camlistore.BlobItemContainer(
this.connection_);
this.blobItemContainer_.setHasCreateItem(true);
/**
* @type {goog.events.EventHandler}