Sha256: dfa0af5cc0a09498b74e505cdc5406e9259c98a50e0dd15ad1d1b25a6eb9a528

Contents?: true

Size: 792 Bytes

Versions: 12

Compression:

Stored size: 792 Bytes

Contents

(function() {
  "use strict";
  
  App.PostsShowController = Ember.ObjectController.extend({
    needs: ['posts'],
    
    actions: {      
      togglePublished: function(defer) {
        var post = this.get('content');
        
        if (Ember.isNone(post.get('publishedAt'))) {
          post.set('publishedAt', new Date());
        } else {
          post.set('publishedAt', null);
        }
        
        if (Ember.isNone(defer)) {
          post.save();
          return post;
        }
        
        if (!post.get('isDirty')) {
          defer.resolve();
        } else {
          post.save().then(function() {
            defer.resolve();
          }, function() {
            defer.reject();
          });
        }
        
        return post;
      }
    }
  });

})();

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
blogelator-0.2.5 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.2.4 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.2.3 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.2.2 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.2.1 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.6 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.5 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.4 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.3 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.2 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.1 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js
blogelator-0.1.0 app/assets/javascripts/blogelator/controllers/posts/posts_show_controller.js