Sha256: 1b272e53622d02c7ac0ca2330b5e0c5a88769735e7342e33bc000f7c6f086bf7

Contents?: true

Size: 1.3 KB

Versions: 79

Compression:

Stored size: 1.3 KB

Contents

pageflow.filesCountWatcher = {
  watchFileCollection: function(name, collection) {
    this.watchedFileCollectionNames = this.watchedFileCollectionNames || [];
    this.watchedFileCollectionNames.push(name);

    this.listenTo(collection, 'change:state', function(model) {
      this.updateFilesCounts(name, collection);
    });

    this.listenTo(collection, 'add', function() {
      this.updateFilesCounts(name, collection);
    });

    this.listenTo(collection, 'remove', function() {
      this.updateFilesCounts(name, collection);
    });

    this.updateFilesCounts(name, collection);
  },

  updateFilesCounts: function(name, collection) {
    this.updateFilesCount('uploading', name, collection, function(file) {
      return file.isUploading();
    });

    this.updateFilesCount('confirmable', name, collection, function(file) {
      return file.isConfirmable();
    });

    this.updateFilesCount('pending', name, collection, function(file) {
      return file.isPending();
    });
  },

  updateFilesCount: function(trait, name, collection, filter) {
    this.set(trait + '_' + name + '_count', collection.filter(filter).length);

    this.set(trait + '_files_count', _.reduce(this.watchedFileCollectionNames, function(sum, name) {
      return sum + this.get(trait + '_' + name + '_count');
    }, 0, this));
  }
};

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
pageflow-14.0.0.rc1 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-14.0.0.beta3 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-14.0.0.beta2 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-14.0.0.beta1 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.6.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.5.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.4.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.3.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.2.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-12.6.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.1.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-12.5.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-12.4.1 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.0.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.0.0.rc1 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-12.4.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-12.3.0 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.0.0.beta7 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.0.0.beta6 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js
pageflow-13.0.0.beta5 app/assets/javascripts/pageflow/editor/models/mixins/files_count_watcher.js