Skip to content

Commit

Permalink
Made drag-and-drop work with files too.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed Jul 8, 2012
1 parent 793249c commit fd65c4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion css/backbone-file-explorer.css
Expand Up @@ -16,12 +16,15 @@
background-image: url(''); background-image: url('');
} }


.backbone-file-explorer-entry {
position: relative;
}

.backbone-file-explorer-entry-odd { .backbone-file-explorer-entry-odd {
background-color: #eee; background-color: #eee;
} }


.backbone-file-explorer-directory { .backbone-file-explorer-directory {
position: relative;
background-image: url('../img/folder.png'); background-image: url('../img/folder.png');
background-repeat: no-repeat; background-repeat: no-repeat;
} }
Expand Down
8 changes: 4 additions & 4 deletions lib/backbone-file-browser.js
Expand Up @@ -8,9 +8,9 @@


exports.File = Backbone.Model.extend({ exports.File = Backbone.Model.extend({


// generate id without slashes // generate id without slashes and replacing periods
id: function() { id: function() {
return this.path().replace(/\//g, '_'); return this.path().replace(/\//g, '_').replace('.', '__');
}, },


path: function() { path: function() {
Expand Down Expand Up @@ -304,13 +304,13 @@


// exclude top-level directory from being dragged // exclude top-level directory from being dragged
$(this.el) $(this.el)
.find('.backbone-file-explorer-directory:not(:first)') .find('.backbone-file-explorer-entry:not(:first)')
.unbind('drag') .unbind('drag')
.bind('drag', {'self': self}, self.dragHandler); .bind('drag', {'self': self}, self.dragHandler);


// allow top-level directory to be dragged into // allow top-level directory to be dragged into
$(this.el) $(this.el)
.find('.backbone-file-explorer-directory') .find('.backbone-file-explorer-entry')
.unbind('drop') .unbind('drop')
.bind('drop', {'self': self}, self.dropHandler); .bind('drop', {'self': self}, self.dropHandler);
} }
Expand Down

0 comments on commit fd65c4b

Please sign in to comment.