Sha256: 4d1f33c249352e0f662015659b48be4fb95cff9611fd71757b9eff04ed3c27bf

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

$( document ).ready(function() {
  $('#upload-image-field').change(function() {
      var output = document.getElementById('post-image');
      var removeLink = document.getElementById('remove-image');

      var fr = new FileReader();
      fr.onload = function() {
          var img = new Image;
          img.onload = function() {
          };
          img.src = fr.result;
      };
      output.src = URL.createObjectURL(this.files[0]);
      output.style.display = 'block';
      removeLink.style.display = 'inline-block';

      fr.readAsDataURL(this.files[0]);
  });

});


var deleteFile = function(value) {
  var inputField = document.getElementById('upload-image-field');
  var output = document.getElementById('post-image');
  var removeLink = document.getElementById('remove-image');
  var rmValue = document.getElementById('remove-value');

  if(value === 'edit' && output.style.display !== 'none') {
    rmValue.value = true;
  }

  inputField.value = '';
  output.src = '#';
  output.style.display = 'none';
  removeLink.style.display = 'none';
};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cms9-0.2.1 app/assets/javascripts/cms9/posts.js
cms9-0.2.0 app/assets/javascripts/cms9/posts.js