{I"
class:ETI"BundledAsset; FI"logical_path; TI"storytime/media.js; FI"
pathname; TI"[/Users/ben/flyover/projects/storytime/app/assets/javascripts/storytime/media.js.coffee; FI"content_type; TI"application/javascript; TI"
mtime; Tl+daZTI"length; TiÎI"digest; TI"%70b07f2c3bfde994b8f84b5930007a89; FI"source; TI"Î(function() {
Storytime.Dashboard.Media = (function() {
function Media() {}
Media.prototype.initIndex = function() {
this.initUpload();
this.initPagination();
};
Media.prototype.initPagination = function() {
$(document).on('ajax:success', '#media_gallery .pagination a', function(e, data, status, xhr) {
$("#media_gallery").html(data);
});
};
Media.prototype.initUpload = function() {
var _ref;
if (!this.uploadInitialized) {
$('#media_file').fileupload({
dataType: 'json',
done: function(e, data) {
$(".media_container").prepend(data.result.html);
},
progressall: function(e, data) {
var progress;
progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .progress-bar').css('width', progress + '%');
}
}).prop('disabled', !$.support.fileInput).parent().addClass((_ref = $.support.fileInput) != null ? _ref : {
undefined: 'disabled'
});
this.uploadInitialized = true;
return;
}
};
Media.prototype.initInsert = function() {
var self;
self = this;
$(document).on("click", ".insert-image-button", function(e) {
var featured_media, image_tag, node, secondary_media;
e.preventDefault();
if (self.selectingFeatured) {
featured_media = $("#featured_media_id");
featured_media.val($(this).data("media-id"));
if ($("#featured_media_image").length > 0) {
$("#featured_media_image").attr("src", $(this).data("thumb-url"));
} else {
$("#featured_media_container").html("");
}
featured_media.parent().parent().find(".select_featured_image").hide();
featured_media.parent().parent().find(".remove_featured_image").show();
$("#insertMediaModal").modal("hide");
} else if (self.selectingSecondary) {
secondary_media = $("#secondary_media_id");
secondary_media.val($(this).data("media-id"));
if ($("#secondary_media_image").length > 0) {
$("#secondary_media_image").attr("src", $(this).data("thumb-url"));
} else {
$("#secondary_media_container").html("");
}
secondary_media.parent().parent().find(".select_featured_image").hide();
secondary_media.parent().parent().find(".remove_featured_image").show();
$("#insertMediaModal").modal("hide");
} else if (self.selectingSecondary) {
$("#secondary_media_id").val($(this).data("media-id"));
if ($("#secondary_media_image").length > 0) {
$("#secondary_media_image").attr("src", $(this).data("thumb-url"));
} else {
$("#secondary_media_container").html("");
}
$("#insertMediaModal").modal("hide");
} else {
image_tag = "";
node = $(".summernote").data("range").createContextualFragment(image_tag);
$(".summernote").data("range").insertNode(node);
$(".note-image-dialog").modal("hide");
}
});
$(document).on("click", "button.remove_featured_image", function(e) {
e.preventDefault();
$(this).parent().find("input").val("");
$(this).parent().find(".image_container").html("");
$(this).parent().find(".select_featured_image").show();
$(this).parent().find(".remove_featured_image").hide();
});
};
Media.prototype.initFeaturedImageSelector = function() {
var self;
self = this;
$(document).on("click", "#featured_media_button", function(e) {
e.preventDefault();
self.selectingFeatured = true;
self.selectingSecondary = false;
$("#insertMediaModal").modal("show");
});
$(document).on('hidden.bs.modal', function() {
self.selectingFeatured = false;
self.selectingSecondary = false;
});
};
Media.prototype.initSecondaryImageSelector = function() {
var self;
self = this;
$(document).on("click", "#secondary_media_button", function(e) {
e.preventDefault();
self.selectingFeatured = false;
self.selectingSecondary = true;
$("#insertMediaModal").modal("show");
});
$(document).on('hidden.bs.modal', function() {
self.selectingFeatured = false;
self.selectingSecondary = false;
});
};
return Media;
})();
}).call(this);
; TI"required_assets_digest; TI"%13ad76d8e8faf0697ef92e4c5ff03dc5; FI"
_version; TI"%37d9e9317b7fde5d2addbefd4177a12b; F