Sha256: 396f355fb91fc90af20de4bb6c24206ee051d203cae172f51edcbf2d5ded0d15
Contents?: true
Size: 1.93 KB
Versions: 13
Compression:
Stored size: 1.93 KB
Contents
pageflow.FileStage = Backbone.Model.extend({ initialize: function(attributes, options) { this.file = options.file; this.activeStates = options.activeStates || []; this.finishedStates = options.finishedStates || []; this.failedStates = options.failedStates || []; this.actionRequiredStates = options.actionRequiredStates || []; this.nonFinishedStates = this.activeStates.concat(this.failedStates, this.actionRequiredStates); this.update(); this.listenTo(this.file, 'change:state', this.update); this.listenTo(this.file, 'change:' + this.get('name') + '_progress', this.update); this.listenTo(this.file, 'change:' + this.get('name') + '_error_message', this.update); }, update: function() { this.updateState(); this.updateProgress(); this.updateErrorMessage(); }, updateState: function() { var state = this.file.get('state'); this.set('active', this.activeStates.indexOf(state) >= 0); this.set('finished', this.finishedStates.indexOf(state) >= 0); this.set('failed', this.failedStates.indexOf(state) >= 0); this.set('action_required', this.actionRequiredStates.indexOf(state) >= 0); if (this.get('active')) { this.set('state', 'active'); } else if (this.get('finished')) { this.set('state', 'finished'); } else if (this.get('failed')) { this.set('state', 'failed'); } else if (this.get('action_required')) { this.set('state', 'action_required'); } else { this.set('state', 'pending'); } }, updateProgress: function() { this.set('progress', this.file.get(this.get('name') + '_progress')); }, updateErrorMessage: function() { var errorMessageAttribute = this.get('name') + '_error_message'; this.set('error_message', this.file.get(errorMessageAttribute)); }, localizedDescription: function() { return I18n.t('pageflow.editor.files.stages.' + this.get('name') + '.' + this.get('state')); } });
Version data entries
13 entries across 13 versions & 1 rubygems