signal selecting file
authorMaciej Tronowski <mtro@man.poznan.pl>
Mon, 23 Mar 2015 09:33:12 +0000 (10:33 +0100)
committerMaciej Tronowski <mtro@man.poznan.pl>
Mon, 23 Mar 2015 09:33:12 +0000 (10:33 +0100)
filex/static/filex/filex.js
filex/templates/filex/source.js.html

index 3aed569..e1dc50f 100644 (file)
@@ -148,10 +148,8 @@ $(function(){
         },
 
         selected: function(e) {
-            if (this.model.isDir()) {
-                e.preventDefault();
-                this.model.trigger('selected:dir', this.model);
-            }
+            e.preventDefault();
+            this.model.trigger(this.model.isDir() ? 'selected:dir' : 'selected:file', this.model);
         }
     });
 
@@ -212,6 +210,7 @@ $(function(){
             this.listenTo(this.path, 'selected', this.selectedPath);
             this.listenTo(this.files, 'reset', this.resetFiles);
             this.listenTo(this.files, 'selected:dir', this.selectedDir);
+            this.listenTo(this.files, 'selected:file', this.selectedFile);
 
             // used in selectize callbacks
             var view = this,
@@ -334,6 +333,10 @@ $(function(){
             this.path.add({'text': dir.get('name'), 'path': dir.get('name')});
         },
 
+        selectedFile: function(file) {
+            this.trigger('selected:file', this.host + this.path.full() + '/' + file.get('name'));
+        },
+
         selectedPath: function(bit) {
             var newPath = this.path.slice(0, this.path.indexOf(bit) + 1);
             this.path.set(newPath);
index db1a91b..4942015 100644 (file)
@@ -6,9 +6,9 @@
 <script src="{% static 'filex/filex.js' %}"></script>
 
 <script>
-    var app;
+    var filex;
     $(function() {
-        app = new Filex.FilexView({
+        filex = new Filex.FilexView({
             host: 'qcg.man.poznan.pl',
             hostOptions: [
                 {host: 'qcg.man.poznan.pl', path: '/home/plgrid/{{ request.user.username }}/reef'},
 <script type="text/template" id="file-template">
     <td class="text-center"><span class="glyphicon glyphicon-file" aria-hidden="true"></span></td>
     <td>
-        <a href="{% url 'filex:download' %}?<%= url_params %>" class="btn btn-default btn-xs pull-right link" title="Pobierz plik">
+        <a href="{% url 'filex:download' %}?<%= url_params %>"
+           class="btn btn-default btn-xs pull-right" title="Pobierz plik">
             <span class="glyphicon glyphicon-cloud-download" aria-hidden="true"></span>
         </a>
-        <%= name %>
+        <a class="link" href="#"><%= name %></a>
     </td>
     <td class="text-right"><%= size %></td>
     <td><%= date %></td>