{I" class:ETI"ProcessedAsset; FI"logical_path; TI"storytime/editor.js; FI" pathname; TI"\/Users/ben/flyover/projects/storytime/app/assets/javascripts/storytime/editor.js.coffee; FI"content_type; TI"application/javascript; TI" mtime; Tl+#FTI"length; TiI"digest; TI"%043288640af529b69a932a642fac2b97; FI"source; TI"(function() { Storytime.Dashboard.Editor = (function() { var addUnloadHandler; function Editor() {} Editor.prototype.init = function() { var excerpt_character_limit, form, self, title_character_limit; self = this; this.initMedia(); this.initWysiwyg(); title_character_limit = $("#title_character_limit").data("limit"); $("#title_character_limit").html(title_character_limit - $("#post_title").val().length); $("#post_title").keypress(function(e) { if ((e.which === 32 || e.which > 0x20) && ($("#post_title").val().length > title_character_limit - 1)) { e.preventDefault(); } }).keyup(function() { $("#title_character_limit").html(title_character_limit - $("#post_title").val().length); }); excerpt_character_limit = $("#excerpt_character_limit").data("limit"); $("#excerpt_character_limit").html(excerpt_character_limit - $("#post_excerpt").val().length); $("#post_excerpt").keypress(function(e) { if ((e.which === 32 || e.which > 0x20) && ($("#post_excerpt").val().length > excerpt_character_limit - 1)) { e.preventDefault(); } }).keyup(function() { $("#excerpt_character_limit").html(excerpt_character_limit - $("#post_excerpt").val().length); }); if ($(".edit_post").length) { form = $(".edit_post").last(); $("#preview_post").click(function() { self.autosavePostForm(); }); if ($("#main").data("preview")) { $("#preview_post").trigger("click"); window.open($("#preview_post").attr("href")); } } else { form = $(".new_post").last(); $("#preview_new_post").click(function() { $("").insertAfter($(".new_post").children().first()); $(".new_post").submit(); }); } $(".datepicker").datepicker({ dateFormat: "MM d, yy" }); $(".timepicker").timepicker({ showPeriod: true }); addUnloadHandler(form); }; Editor.prototype.initMedia = function() { var mediaInstance; mediaInstance = new Storytime.Dashboard.Media(); mediaInstance.initPagination(); mediaInstance.initInsert(); mediaInstance.initFeaturedImageSelector(); return $(document).on('shown.bs.modal', function() { mediaInstance.initUpload(); }); }; Editor.prototype.initWysiwyg = function() { $(".summernote").summernote({ codemirror: { htmlMode: true, lineNumbers: true, lineWrapping: true, mode: 'text/html', theme: 'monokai' }, height: 300, minHeight: null, maxHeight: null, toolbar: [['style', ['style']], ['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture', 'video', 'hr']], ['view', ['fullscreen', 'codeview']], ['editing', ['undo', 'redo']], ['help', ['help']]], onblur: function() { $(".summernote").data("range", document.getSelection().getRangeAt(0)); }, onfocus: function() { if ($(".edit_post").length) { self.updateLater(1000); } }, onkeyup: function() { form.data("unsaved-changes", true); }, onImageUpload: function(files, editor, $editable) { $("#media_file").fileupload('send', { files: files }).success(function(result, textStatus, jqXHR) { editor.insertImage($editable, result.file_url); }); } }); $(".note-image-dialog").on('shown.bs.modal', function() { $(".note-image-dialog").find(".row-fluid").append("