mirror of https://github.com/perkeep/perkeep.git
Merge "Add a 'clear selection' button per Brad request."
This commit is contained in:
commit
a574697b7d
|
@ -144,8 +144,7 @@ camlistore.BlobItemContainer.prototype.dragActiveElement_ = null;
|
|||
* @enum {string}
|
||||
*/
|
||||
camlistore.BlobItemContainer.EventType = {
|
||||
BLOB_ITEMS_CHOSEN: 'Camlistore_BlobItemContainer_BlobItems_Chosen',
|
||||
SINGLE_NODE_CHOSEN: 'Camlistore_BlobItemContainer_SingleNode_Chosen'
|
||||
SELECTION_CHANGED: 'Camlistore_BlobItemContainer_SelectionChanged',
|
||||
};
|
||||
|
||||
|
||||
|
@ -441,7 +440,6 @@ camlistore.BlobItemContainer.prototype.handleBlobItemChecked_ = function(e) {
|
|||
this.checkedBlobItems_.push(item);
|
||||
}
|
||||
}
|
||||
this.dispatchEvent(camlistore.BlobItemContainer.EventType.BLOB_ITEMS_CHOSEN);
|
||||
} else if (isCtrlMultiSelect) {
|
||||
if (isCheckingItem) {
|
||||
blobItem.setState(goog.ui.Component.State.CHECKED, true);
|
||||
|
@ -469,7 +467,6 @@ camlistore.BlobItemContainer.prototype.handleBlobItemChecked_ = function(e) {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.dispatchEvent(camlistore.BlobItemContainer.EventType.BLOB_ITEMS_CHOSEN);
|
||||
} else {
|
||||
blobItem.setState(goog.ui.Component.State.CHECKED, isCheckingItem);
|
||||
if (isCheckingItem) {
|
||||
|
@ -477,8 +474,8 @@ camlistore.BlobItemContainer.prototype.handleBlobItemChecked_ = function(e) {
|
|||
} else {
|
||||
goog.array.remove(this.checkedBlobItems_, blobItem);
|
||||
}
|
||||
this.dispatchEvent(camlistore.BlobItemContainer.EventType.SINGLE_NODE_CHOSEN);
|
||||
}
|
||||
this.dispatchEvent(camlistore.BlobItemContainer.EventType.SELECTION_CHANGED);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -488,6 +485,7 @@ camlistore.BlobItemContainer.prototype.unselectAll = function() {
|
|||
item.setState(goog.ui.Component.State.CHECKED, false);
|
||||
});
|
||||
this.checkedBlobItems_ = [];
|
||||
this.dispatchEvent(camlistore.BlobItemContainer.EventType.SELECTION_CHANGED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -154,6 +154,10 @@ camlistore.IndexPage.prototype.enterDocument = function() {
|
|||
this.createNewSetWithItems_(blobItems);
|
||||
});
|
||||
|
||||
this.eh_.listen(
|
||||
this.toolbar_, camlistore.Toolbar.EventType.CLEAR_SELECTION,
|
||||
this.blobItemContainer_.unselectAll.bind(this.blobItemContainer_));
|
||||
|
||||
this.eh_.listen(
|
||||
this.toolbar_, camlistore.Toolbar.EventType.CREATE_PERMANODE,
|
||||
function() {
|
||||
|
@ -193,28 +197,9 @@ camlistore.IndexPage.prototype.enterDocument = function() {
|
|||
this.blobItemContainer_.showRoots.bind(
|
||||
this.blobItemContainer_, this.config_.signing));
|
||||
|
||||
// TODO(mpl): those are getting large. make dedicated funcs.
|
||||
this.eh_.listen(
|
||||
this.blobItemContainer_,
|
||||
camlistore.BlobItemContainer.EventType.BLOB_ITEMS_CHOSEN,
|
||||
function() {
|
||||
var blobItems = this.blobItemContainer_.getCheckedBlobItems();
|
||||
this.toolbar_.setCheckedBlobItemCount(blobItems.length);
|
||||
// set checkedItemsAddToSetButton_
|
||||
if (this.blobItemContainer_.currentCollec_ &&
|
||||
this.blobItemContainer_.currentCollec_ != "" &&
|
||||
blobItems.length > 0) {
|
||||
this.toolbar_.toggleAddToSetButton(true);
|
||||
} else {
|
||||
this.toolbar_.toggleAddToSetButton(false);
|
||||
}
|
||||
// set setAsCollecButton_
|
||||
this.toolbar_.toggleCollecButton(false);
|
||||
});
|
||||
|
||||
this.eh_.listen(
|
||||
this.blobItemContainer_,
|
||||
camlistore.BlobItemContainer.EventType.SINGLE_NODE_CHOSEN,
|
||||
camlistore.BlobItemContainer.EventType.SELECTION_CHANGED,
|
||||
function() {
|
||||
var blobItems = this.blobItemContainer_.getCheckedBlobItems();
|
||||
this.toolbar_.setCheckedBlobItemCount(blobItems.length);
|
||||
|
|
|
@ -53,6 +53,13 @@ camlistore.Toolbar = function(opt_domHelper) {
|
|||
this.checkedItemsCreateSetButton_.addClassName('cam-checked-items');
|
||||
this.checkedItemsCreateSetButton_.setVisible(false);
|
||||
|
||||
/**
|
||||
* @type {goog.ui.Button}
|
||||
* @private
|
||||
* /
|
||||
this.clearSelectionButton_ = new goog.ui.Button('Clear Selection');
|
||||
this.clearSelectionButton_.setVisible(false);
|
||||
|
||||
/**
|
||||
* @type {goog.ui.Button}
|
||||
* @private
|
||||
|
@ -108,6 +115,7 @@ camlistore.Toolbar.EventType = {
|
|||
SMALLER: 'Camlistore_Toolbar_Smaller',
|
||||
ROOTS: 'Camlistore_Toolbar_SearchRoots',
|
||||
CHECKED_ITEMS_ADDTO_SET: 'Camlistore_Toolbar_Checked_Items_Addto_set',
|
||||
CLEAR_SELECTION: 'Clear_Selection',
|
||||
SELECT_COLLEC: 'Camlistore_Toolbar_Select_collec',
|
||||
CHECKED_ITEMS_CREATE_SET: 'Camlistore_Toolbar_Checked_Items_Create_set',
|
||||
CREATE_PERMANODE: 'Camlistore_Toolbar_Create_Permanode',
|
||||
|
@ -152,6 +160,7 @@ camlistore.Toolbar.prototype.decorateInternal = function(el) {
|
|||
this.addChild(this.smallerButton_, true);
|
||||
this.addChild(this.biggerButton_, true);
|
||||
this.addChild(this.checkedItemsCreateSetButton_, true);
|
||||
this.addChild(this.clearSelectionButton_, true);
|
||||
this.addChild(this.createPermanodeButton_, true);
|
||||
this.addChild(this.setAsCollecButton_, true);
|
||||
this.addChild(this.checkedItemsAddToSetButton_, true);
|
||||
|
@ -206,6 +215,12 @@ camlistore.Toolbar.prototype.enterDocument = function() {
|
|||
goog.bind(this.dispatch_, this,
|
||||
camlistore.Toolbar.EventType.CHECKED_ITEMS_CREATE_SET));
|
||||
|
||||
this.eh_.listen(
|
||||
this.clearSelectionButton_.getElement(),
|
||||
goog.events.EventType.CLICK,
|
||||
goog.bind(this.dispatch_, this,
|
||||
camlistore.Toolbar.EventType.CLEAR_SELECTION));
|
||||
|
||||
this.eh_.listen(
|
||||
this.createPermanodeButton_.getElement(),
|
||||
goog.events.EventType.CLICK,
|
||||
|
@ -254,9 +269,11 @@ camlistore.Toolbar.prototype.setCheckedBlobItemCount = function(count) {
|
|||
var txt = 'Create set w/ ' + count + ' item' + (count > 1 ? 's' : '');
|
||||
this.checkedItemsCreateSetButton_.setContent(txt);
|
||||
this.checkedItemsCreateSetButton_.setVisible(true);
|
||||
this.clearSelectionButton_.setVisible(true);
|
||||
} else {
|
||||
this.checkedItemsCreateSetButton_.setContent('');
|
||||
this.checkedItemsCreateSetButton_.setVisible(false);
|
||||
this.clearSelectionButton_.setVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue