From 65d76a78c78a5330abfc682a7fca0635987a65f8 Mon Sep 17 00:00:00 2001 From: Mike Cantelon Date: Mon, 9 Jul 2012 12:02:16 -0700 Subject: [PATCH] Added support for entry click handler. --- lib/backbone-file-browser.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/backbone-file-browser.js b/lib/backbone-file-browser.js index 0dadf5d..8086493 100644 --- a/lib/backbone-file-browser.js +++ b/lib/backbone-file-browser.js @@ -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; }, @@ -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() { @@ -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; }, @@ -168,6 +176,7 @@ explorer: self.explorer, entry: child, template: self.entryTemplate, + entryClickHandler: self.entryClickHandler, nameClickHandler: self.nameClickHandler, actionHandlers: self.actionHandlers }); @@ -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 });