{I" class:EFI"BundledAsset;FI"logical_path;FI"2roroacms/vendor/ghostdown/jquery.ghostdown.js;TI" pathname;FI"m/Applications/Ruby/engines/roroacms/app/assets/javascripts/roroacms/vendor/ghostdown/jquery.ghostdown.js;TI"content_type;FI"application/javascript;FI" mtime;Fl+°£ÖSI" length;FibI" digest;F"%d6a9241ccbb8b06d20a05084a3883e02I" source;FI"b(function ($, ShowDown, CodeMirror) { "use strict"; $.widget( "b4m.ghostDown", { editor: null, markdown: null, html: null, converter: null, _create: function() { if(typeof this.element.find('textarea')[0] != 'undefined') { this.converter = new ShowDown.converter(); this.editor = CodeMirror.fromTextArea(this.element.find('textarea')[0], { mode: 'markdown', tabMode: 'indent', lineWrapping: true }); this.editor.on("change", $.proxy(function () { this._updatePreview(); }, this)); $('.entry-markdown header, .entry-preview header', this.element).click(function (e) { $('.entry-markdown, .entry-preview', this.element).removeClass('active'); $(e.target, this.element).closest('section').addClass('active'); }); $('.CodeMirror-scroll', this.element).on('scroll', $.proxy(function (e) { this._syncScroll(e); }, this)); // Shadow on Markdown if scrolled $('.CodeMirror-scroll', this.element).scroll(function(e) { if ($(e.target).scrollTop() > 10) { $('.entry-markdown', this.element).addClass('scrolling'); } else { $('.entry-markdown', this.element).removeClass('scrolling'); } }); // Shadow on Preview if scrolled $('.entry-preview-content', this.element).scroll(function(e) { if ($('.entry-preview-content', $(e.target).scrollTop()).scrollTop() > 10) { $('.entry-preview', this.element).addClass('scrolling'); } else { $('.entry-preview', this.element).removeClass('scrolling'); } }); this._updatePreview(); } }, _updatePreview: function() { var preview = this.element.find('.rendered-markdown'); this.markdown = this.editor.getValue(); this.html = this.converter.makeHtml(this.markdown); preview.html(this.html); this._updateWordCount(); }, getHtml: function () { return this.html; }, getMarkdown: function () { return this.markdown; }, _syncScroll: function (e) { // vars var $codeViewport = $(e.target), $previewViewport = $('.entry-preview-content'), $codeContent = $('.CodeMirror-sizer'), $previewContent = $('.rendered-markdown'), // calc position codeHeight = $codeContent.height() - $codeViewport.height(), previewHeight = $previewContent.height() - $previewViewport.height(), ratio = previewHeight / codeHeight, previewPostition = $codeViewport.scrollTop() * ratio; // apply new scroll $previewViewport.scrollTop(previewPostition); }, _updateWordCount: function() { var wordCount = this.element.find('.entry-word-count'), editorValue = this.markdown; if (editorValue.length) { wordCount.html(editorValue.match(/\S+/g).length + ' words'); } } }); }(jQuery, Showdown, CodeMirror)); ;TI"required_assets_digest;F"%201ccfc3de85f1399de55b4d6f90081aI" _version;F"%134d714864361d96664b8e1779275370