diff --git a/Gemfile b/Gemfile index a7d8548f..dd0a01da 100644 --- a/Gemfile +++ b/Gemfile @@ -82,6 +82,10 @@ source 'https://rails-assets.org' do gem 'rails-assets-waypoints' # for displaying maps gem 'rails-assets-leaflet' + # for markdown editors + gem 'rails-assets-bootstrap-markdown' + gem 'rails-assets-to-markdown' + gem 'rails-assets-markdown' end # as date picker diff --git a/Gemfile.lock b/Gemfile.lock index 995bf235..f9ad33e9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -331,16 +331,22 @@ GEM bundler (>= 1.3.0, < 2.0) railties (= 4.2.5.2) sprockets-rails + rails-assets-bootstrap (3.3.6) + rails-assets-jquery (>= 1.9.1, < 3) + rails-assets-bootstrap-markdown (2.10.0) + rails-assets-bootstrap (~> 3) rails-assets-date.format (1.2.3) rails-assets-holderjs (2.9.1) rails-assets-jquery (2.2.0) rails-assets-jquery-smooth-scroll (1.7.2) rails-assets-jquery (>= 1.4.2) rails-assets-leaflet (0.7.7) + rails-assets-markdown (0.5.0) rails-assets-momentjs (2.11.2) rails-assets-spectrum (1.8.0) rails-assets-jquery (>= 1.7.2) rails-assets-tinycolor (1.3.0) + rails-assets-to-markdown (1.3.0) rails-assets-trianglify (0.4.0) rails-assets-waypoints (4.0.0) rails-deprecated_sanitizer (1.0.3) @@ -540,13 +546,16 @@ DEPENDENCIES prawn_rails quiet_assets rails (~> 4.2) + rails-assets-bootstrap-markdown! rails-assets-date.format! rails-assets-holderjs! rails-assets-jquery-smooth-scroll! rails-assets-leaflet! + rails-assets-markdown! rails-assets-momentjs! rails-assets-spectrum! rails-assets-tinycolor! + rails-assets-to-markdown! rails-assets-trianglify! rails-assets-waypoints! rails-observers diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9a771225..d0447354 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,7 +10,7 @@ *= require osem-splash *= require font-awesome *= require osem-fonts - *= require bootstrap-markdown.min + *= require bootstrap-markdown *= require bootstrap-datetimepicker *= require leaflet *= require bootstrap3-switch diff --git a/app/assets/stylesheets/bootstrap-markdown.min.css b/app/assets/stylesheets/bootstrap-markdown.min.css deleted file mode 100644 index ac71e895..00000000 --- a/app/assets/stylesheets/bootstrap-markdown.min.css +++ /dev/null @@ -1 +0,0 @@ -.md-editor{display:block;border:1px solid #ddd}.md-editor>.md-header,.md-editor .md-footer{display:block;padding:6px 4px;background:#fff}.md-editor>.md-header{margin: 0;}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:14px;outline:0;outline:thin dotted \9;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6)} \ No newline at end of file diff --git a/vendor/assets/javascripts/bootstrap-markdown.js b/vendor/assets/javascripts/bootstrap-markdown.js deleted file mode 100644 index 2256df64..00000000 --- a/vendor/assets/javascripts/bootstrap-markdown.js +++ /dev/null @@ -1,1293 +0,0 @@ -/* =================================================== - * bootstrap-markdown.js v2.5.0 - * http://github.com/toopay/bootstrap-markdown - * =================================================== - * Copyright 2013 Taufan Aditya - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================================================== */ - -!function ($) { - - "use strict"; // jshint ;_; - - - /* MARKDOWN CLASS DEFINITION - * ========================== */ - - var Markdown = function (element, options) { - // Class Properties - this.$ns = 'bootstrap-markdown' - this.$element = $(element) - this.$editable = {el:null, type:null,attrKeys:[], attrValues:[], content:null} - this.$options = $.extend(true, {}, $.fn.markdown.defaults, options, this.$element.data(), this.$element.data('options')) - this.$oldContent = null - this.$isPreview = false - this.$editor = null - this.$textarea = null - this.$handler = [] - this.$callback = [] - this.$nextTab = [] - - this.showEditor() - } - - Markdown.prototype = { - - constructor: Markdown - - , __alterButtons: function(name,alter) { - var handler = this.$handler, isAll = (name == 'all'),that = this - - $.each(handler,function(k,v) { - var halt = true - if (isAll) { - halt = false - } else { - halt = v.indexOf(name) < 0 - } - - if (halt == false) { - alter(that.$editor.find('button[data-handler="'+v+'"]')) - } - }) - } - - , __buildButtons: function(buttonsArray, container) { - var i, - ns = this.$ns, - handler = this.$handler, - callback = this.$callback - - for (i=0;i', { - 'class': 'btn-group' - }) - - for (z=0;z ' - +this.__localize(btnText) - +'') - - // Register handler and callback - handler.push(buttonHandler) - callback.push(button.callback) - } - - // Attach the button group into container dom - container.append(btnGroupContainer) - } - } - - return container - } - , __setListener: function() { - // Set size and resizable Properties - var hasRows = typeof this.$textarea.attr('rows') != 'undefined', - maxRows = this.$textarea.val().split("\n").length > 5 ? this.$textarea.val().split("\n").length : '5', - rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows - - this.$textarea.attr('rows',rowsVal) - if (this.$options.resize) { - this.$textarea.css('resize',this.$options.resize) - } - - this.$textarea - .on('focus', $.proxy(this.focus, this)) - .on('keypress', $.proxy(this.keypress, this)) - .on('keyup', $.proxy(this.keyup, this)) - .on('change', $.proxy(this.change, this)) - - if (this.eventSupported('keydown')) { - this.$textarea.on('keydown', $.proxy(this.keydown, this)) - } - - // Re-attach markdown data - this.$textarea.data('markdown',this) - } - - , __handle: function(e) { - var target = $(e.currentTarget), - handler = this.$handler, - callback = this.$callback, - handlerName = target.attr('data-handler'), - callbackIndex = handler.indexOf(handlerName), - callbackHandler = callback[callbackIndex] - - // Trigger the focusin - $(e.currentTarget).focus() - - callbackHandler(this) - - // Trigger onChange for each button handle - this.change(this); - - // Unless it was the save handler, - // focusin the textarea - if (handlerName.indexOf('cmdSave') < 0) { - this.$textarea.focus() - } - - e.preventDefault() - } - - , __localize: function(string) { - var messages = $.fn.markdown.messages, - language = this.$options.language - if ( - typeof messages !== 'undefined' && - typeof messages[language] !== 'undefined' && - typeof messages[language][string] !== 'undefined' - ) { - return messages[language][string]; - } - return string; - } - - , showEditor: function() { - var instance = this, - textarea, - ns = this.$ns, - container = this.$element, - originalHeigth = container.css('height'), - originalWidth = container.css('width'), - editable = this.$editable, - handler = this.$handler, - callback = this.$callback, - options = this.$options, - editor = $( '
', { - 'class': 'md-editor', - click: function() { - instance.focus() - } - }) - - // Prepare the editor - if (this.$editor == null) { - // Create the panel - var editorHeader = $('
', { - 'class': 'md-header btn-toolbar' - }) - - // Merge the main & additional button groups together - var allBtnGroups = [] - if (options.buttons.length > 0) allBtnGroups = allBtnGroups.concat(options.buttons[0]) - if (options.additionalButtons.length > 0) allBtnGroups = allBtnGroups.concat(options.additionalButtons[0]) - - // Reduce and/or reorder the button groups - if (options.reorderButtonGroups.length > 0) { - allBtnGroups = allBtnGroups - .filter(function(btnGroup) { - return options.reorderButtonGroups.indexOf(btnGroup.name) > -1 - }) - .sort(function(a, b) { - if (options.reorderButtonGroups.indexOf(a.name) < options.reorderButtonGroups.indexOf(b.name)) return -1 - if (options.reorderButtonGroups.indexOf(a.name) > options.reorderButtonGroups.indexOf(b.name)) return 1 - return 0 - }) - } - - // Build the buttons - if (allBtnGroups.length > 0) { - editorHeader = this.__buildButtons([allBtnGroups], editorHeader) - } - - editor.append(editorHeader) - - // Wrap the textarea - if (container.is('textarea')) { - container.before(editor) - textarea = container - textarea.addClass('md-input') - editor.append(textarea) - } else { - var rawContent = (typeof toMarkdown == 'function') ? toMarkdown(container.html()) : container.html(), - currentContent = $.trim(rawContent) - - // This is some arbitrary content that could be edited - textarea = $('