Skip to content

Commit

Permalink
Added support for entry click handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed Jul 9, 2012
1 parent fcf5e34 commit 65d76a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/backbone-file-browser.js
Expand Up @@ -60,6 +60,7 @@
? 'backbone-file-explorer-directory'
: 'directory-file';
this.template = this.options.template;
this.entryClickHandler = this.options.entryClickHandler;
this.nameClickHandler = this.options.nameClickHandler;
this.actionHandlers = this.options.actionHandlers;
},
Expand All @@ -86,7 +87,13 @@
var id = (this.explorer) ? this.explorer.id + '_' : '';
$(this.el).attr('id', id + this.model.id());

// add click handler if specified
// add entry click handler if specified
if (this.entryClickHandler) {
var self = this;
$(this.el).click({self: this}, this.entryClickHandler);
}

// add name click handler if specified
if (this.nameClickHandler) {
var self = this;
$(this.el).children('.backbone-file-explorer-directory_entry_name').click(function() {
Expand Down Expand Up @@ -144,6 +151,7 @@
this.entryTemplate = _.template(this.options.entryTemplate);
this.closeDirsByDefault = this.options.closeDirsByDefault;
this.hideFiles = this.options.hideFiles;
this.entryClickHandler = this.options.entryClickHandler;
this.nameClickHandler = this.options.nameClickHandler;
this.actionHandlers = this.options.actionHandlers;
},
Expand All @@ -168,6 +176,7 @@
explorer: self.explorer,
entry: child,
template: self.entryTemplate,
entryClickHandler: self.entryClickHandler,
nameClickHandler: self.nameClickHandler,
actionHandlers: self.actionHandlers
});
Expand Down Expand Up @@ -446,6 +455,7 @@
entryTemplate: this.options.entryTemplate,
closeDirsByDefault: this.options.closeDirsByDefault,
hideFiles: this.options.hideFiles,
entryClickHandler: this.options.entryClickHandler,
nameClickHandler: this.options.nameClickHandler,
actionHandlers: this.options.actionHandlers
});
Expand Down

0 comments on commit 65d76a7

Please sign in to comment.