Sha256: 5bcc0618c96ddffc043fdc0d8732cec240580db52fb1dd1103f9f1eb0000e49f

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 Bytes

Contents

/**
 * Message Block JavaScript Interface
 * 
 * Allows for updating a message block with JSON errors
 **/

var MessageBlock = Class.create({
  initialize: function(message_block) {
    this.message_block = $(message_block ? message_block : "message_block");
  },
  
  clear: function() {
    this.message_block.update("");
    new Effect.Fade(this.message_block);
  },
  
  update: function(errors) {
    if (!errors || Object.keys(errors).size() == 0) {
      new Effect.Fade(this.message_block);
      return;
    }
    
    this.message_block.update("");
    
    for (error_type in errors) {
      $(this.message_block).appendChild(
        Builder.node('ul', { 'class': error_type },
          $A(errors[error_type]).map(function(error) {
            return Builder.node('li', error);
          })
        )
      );
    }
    
    new Effect.Appear(this.message_block);
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_block-1.0.4 assets/javascripts/message_block.js
message_block-1.0.3 assets/javascripts/message_block.js