redo gridftp navbar
[qcg-portal.git] / filex / static / filex / filex.js
index 81b401c..10dc6bc 100644 (file)
@@ -67,7 +67,7 @@ $(function(){
                 case 'file':
                     return new Filex.File(attrs, options);
                 default:
-                    console.log('Unknown model type:', attrs['type']);
+                    console.error('Unknown model type:', attrs['type']);
             }
         },
 
@@ -121,8 +121,7 @@ $(function(){
         tagName:  'tr',
 
         events: {
-            'click .link': 'selected',
-            'click input[type=checkbox]': 'toggle'
+            'click': 'click'
         },
 
         initialize: function(options) {
@@ -158,18 +157,16 @@ $(function(){
             this.$el.toggleClass('hidden', this.model.isHidden() && !this.view.showHidden());
         },
 
-        selected: function(e) {
-            e.preventDefault();
-            if (this.model.isDir()) {
-                this.model.trigger('selected:dir', this.model);
-            }
-            else {
-                this.model.trigger('selected:file', this.model);
-                this.toggle();
+        click: function(e) {
+            if (e.target.className == 'link') {
+                if (this.model.isDir()) {
+                    e.preventDefault();
+                    this.model.trigger('selected:dir', this.model);
+                }
+
+                return;
             }
-        },
 
-        toggle: function() {
             this.model.toggle();
         }
     });
@@ -212,15 +209,14 @@ $(function(){
 
         events: {
             'change #show-hidden': 'toggleHidden',
-            'click #host-controls .view': 'hostEdit',
-            'click #select-all': 'selectAll'
+            'click #select-all': 'selectAll',
+            'click #btn-refresh': 'reloadFiles'
         },
 
         initialize: function(options) {
             this.$noItems = $('#no-items');
             this.$error = $('#error');
             this.$showHidden = $('#show-hidden');
-            this.$host = $('#host-controls');
             this.$selectAll = $('#select-all');
 
             this.host = options.host;
@@ -233,7 +229,6 @@ $(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);
             this.listenTo(this.files, 'change:checked', this.updateSelectAll);
 
             // used in selectize callbacks
@@ -259,8 +254,6 @@ $(function(){
                     this.blur();
                 },
                 onBlur: function() {
-                    view.$host.toggleClass('editing');
-
                     var value = this.getValue();
                     if (!value) {
                         this.addItem(view.host, true);
@@ -283,7 +276,6 @@ $(function(){
 
         render: function() {
             this.updateSelectAll();
-            this.$host.find('.view').text(this.host);
             this.$noItems.toggle(!Boolean(this.visibleFiles().length));
             this.$error.hide();
         },
@@ -358,10 +350,6 @@ $(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);
@@ -372,11 +360,6 @@ $(function(){
             return this.$showHidden[0].checked;
         },
 
-        hostEdit: function() {
-            this.$host.toggleClass('editing');
-            this.hostSelectize.focus();
-        },
-
         busy: function() {
             this.$el.addClass('busy');
         },
@@ -405,6 +388,14 @@ $(function(){
 
         updateSelectAll: function() {
             this.$selectAll.prop('checked', this.selectedFiles().length == this.visibleFiles().length);
+        },
+
+        clearSelection: function() {
+            _.each(this.visibleFiles(), function(item) {
+                item.set('checked', false);
+            });
+
+            this.updateSelectAll();
         }
     });
 });