');
- }
-
- $el.keyup(function () {
- var $lastChild = $el.children(':last'),
- i;
-
- // Fix #39
- // After deleting all content (ctrl+A and delete) in Firefox, all content is deleted and only appears
- // To force placeholder to appear, set
as content of the $el
- if ($el.html() === '' || $el.html() === ' ') {
- $el.html('
');
- }
-
- // Fix not deleting placeholder in Firefox
- // by removing all empty placeholders
- if (this.isFirefox){
- $('.mediumInsert .mediumInsert-placeholder:empty', $el).each(function () {
- $(this).parent().remove();
- });
- }
-
- i = that.getMaxId() +1;
-
- var blocks = 'p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote';
- $el.children(blocks).each(function () {
- if ($(this).next().hasClass('mediumInsert') === false) {
- $(this).after(insertBlock);
- $(this).next('.mediumInsert').attr('id', 'mediumInsert-'+ i);
- }
- i++;
- });
-
- }).keyup();
- },
-
-
- /**
- * Set events on placeholders
- *
- * @return {void}
- */
-
- setEvents: function () {
- var that = this,
- $el = $.fn.mediumInsert.insert.$el;
-
- $el.on('selectstart', '.mediumInsert', function (e) {
- e.preventDefault();
- return false;
- });
-
- $el.on('blur', function () {
- var $clone = $(this).clone(),
- cloneHtml;
-
- $clone.find('.mediumInsert').remove();
- cloneHtml = $clone.html().replace(/^\s+|\s+$/g, '');
-
- if (cloneHtml === '' || cloneHtml === '
') {
- $(this).addClass('medium-editor-placeholder');
- }
- });
-
-
- // Fix #29
- // Sometimes in Firefox when you hit enter, appears instead of
- // If it happens, force to wrap the into a paragraph
- $el.on('keypress', function (e) {
- if (that.isFirefox) {
- if (e.keyCode === 13) {
- //wrap content text in p to avoid firefox problems
- $el.contents().each((function() {
- return function(index, field) {
- if (field.nodeName === '#text') {
- document.execCommand('insertHTML', false, "
" + field.data + "
");
- return field.remove();
- }
- };
- })(this));
- //Firefox add extra br tag inside p tag
- var latestPTag = $el.find('p').last();
- if (latestPTag.text().length > 0) {
- latestPTag.find('br').remove();
- }
- }
- }
- });
-
- // Fix #39
- // For some reason Chrome doesn't "select-all", when the last placeholder is visible.
- // So it's needed to hide it when the user "selects all", and show it again when they presses any other key.
- $el.on('keydown', function (e) {
- // Fix Select-all using (ctrl + a) in chrome
- if (navigator.userAgent.match(/chrome/i)) {
- $el.children().last().removeClass('hide');
- if ( (e.ctrlKey || e.metaKey) && e.which === 65) {
- e.preventDefault();
- if($el.find('p').text().trim().length === 0) {
- return false;
- }
-
- $el.children().last().addClass('hide');
- return document.execCommand('selectAll', false, null);
- }
- }
- });
-
- $el.on('click', '.mediumInsert-buttons a.mediumInsert-buttonsShow', function () {
- var $options = $(this).siblings('.mediumInsert-buttonsOptions'),
- $placeholder = $(this).parent().siblings('.mediumInsert-placeholder');
-
- if ($(this).hasClass('active')) {
- $(this).removeClass('active');
- $options.hide();
-
- $('a', $options).show();
- } else {
- $(this).addClass('active');
- $options.show();
-
- $('a', $options).each(function () {
- var aClass = $(this).attr('class').split('action-')[1],
- plugin = aClass.split('-')[0];
- if ($('.mediumInsert-'+ plugin, $placeholder).length > 0) {
- $('a:not(.action-'+ aClass +')', $options).hide();
- }
- });
- }
-
- that.deselect();
- });
-
- $el.on('mouseleave', '.mediumInsert', function () {
- $('a.mediumInsert-buttonsShow', this).removeClass('active');
- $('.mediumInsert-buttonsOptions', this).hide();
- });
-
- $el.on('click', '.mediumInsert-buttons .mediumInsert-action', function (e) {
- e.preventDefault();
-
- var addon = $(this).data('addon'),
- action = $(this).data('action'),
- $placeholder = $(this).parents('.mediumInsert-buttons').siblings('.mediumInsert-placeholder');
-
- if (addons[addon] && addons[addon][action]) {
- addons[addon][action]($placeholder);
- }
-
- $(this).parents('.mediumInsert').mouseleave();
- });
- }
-
- };
-
-}(jQuery));
diff --git a/dist/js/addons/medium-editor-insert-plugin.min.js b/dist/js/addons/medium-editor-insert-plugin.min.js
index 076f34809..c8efdf19f 100644
--- a/dist/js/addons/medium-editor-insert-plugin.min.js
+++ b/dist/js/addons/medium-editor-insert-plugin.min.js
@@ -1,11 +1,10 @@
-/*!
- * medium-editor-insert-plugin v0.2.6 - jQuery insert plugin for MediumEditor
- *
- * Addon Initialization
+/*!
+ * medium-editor-insert-plugin v0.2.7 - jQuery insert plugin for MediumEditor
*
* https://github.com/orthes/medium-editor-insert-plugin
- *
- * Copyright (c) 2013 Pavel Linkesch (http://linkesch.sk)
+ *
+ * Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
* Released under the MIT license
*/
+
!function(a){var b={};MediumEditor&&"function"==typeof MediumEditor&&(MediumEditor.prototype.serialize=function(){var b,c,d,e,f,g,h,i,j={};for(b=0;bb&&(b=c)}),b},getButtons:function(c){var d=a.fn.mediumInsert.settings.editor,e=d&&d.options?d.options.buttonLabels:"",f='
');
- }
-
- $el.keyup(function () {
- var $lastChild = $el.children(':last'),
- i;
-
- // Fix #39
- // After deleting all content (ctrl+A and delete) in Firefox, all content is deleted and only appears
- // To force placeholder to appear, set
as content of the $el
- if ($el.html() === '' || $el.html() === ' ') {
- $el.html('
');
- }
-
- // Fix not deleting placeholder in Firefox
- // by removing all empty placeholders
- if (this.isFirefox){
- $('.mediumInsert .mediumInsert-placeholder:empty', $el).each(function () {
- $(this).parent().remove();
- });
- }
-
- i = that.getMaxId() +1;
-
- var blocks = 'p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote';
- $el.children(blocks).each(function () {
- if ($(this).next().hasClass('mediumInsert') === false) {
- $(this).after(insertBlock);
- $(this).next('.mediumInsert').attr('id', 'mediumInsert-'+ i);
- }
- i++;
- });
-
- }).keyup();
- },
-
-
- /**
- * Set events on placeholders
- *
- * @return {void}
- */
-
- setEvents: function () {
- var that = this,
- $el = $.fn.mediumInsert.insert.$el;
-
- $el.on('selectstart', '.mediumInsert', function (e) {
- e.preventDefault();
- return false;
- });
-
- $el.on('blur', function () {
- var $clone = $(this).clone(),
- cloneHtml;
-
- $clone.find('.mediumInsert').remove();
- cloneHtml = $clone.html().replace(/^\s+|\s+$/g, '');
-
- if (cloneHtml === '' || cloneHtml === '
') {
- $(this).addClass('medium-editor-placeholder');
- }
- });
-
-
- // Fix #29
- // Sometimes in Firefox when you hit enter, appears instead of
- // If it happens, force to wrap the into a paragraph
- $el.on('keypress', function (e) {
- if (that.isFirefox) {
- if (e.keyCode === 13) {
- //wrap content text in p to avoid firefox problems
- $el.contents().each((function() {
- return function(index, field) {
- if (field.nodeName === '#text') {
- document.execCommand('insertHTML', false, "
" + field.data + "
");
- return field.remove();
- }
- };
- })(this));
- //Firefox add extra br tag inside p tag
- var latestPTag = $el.find('p').last();
- if (latestPTag.text().length > 0) {
- latestPTag.find('br').remove();
- }
- }
- }
- });
-
- // Fix #39
- // For some reason Chrome doesn't "select-all", when the last placeholder is visible.
- // So it's needed to hide it when the user "selects all", and show it again when they presses any other key.
- $el.on('keydown', function (e) {
- // Fix Select-all using (ctrl + a) in chrome
- if (navigator.userAgent.match(/chrome/i)) {
- $el.children().last().removeClass('hide');
- if ( (e.ctrlKey || e.metaKey) && e.which === 65) {
- e.preventDefault();
- if($el.find('p').text().trim().length === 0) {
- return false;
- }
-
- $el.children().last().addClass('hide');
- return document.execCommand('selectAll', false, null);
- }
- }
- });
-
- $el.on('click', '.mediumInsert-buttons a.mediumInsert-buttonsShow', function () {
- var $options = $(this).siblings('.mediumInsert-buttonsOptions'),
- $placeholder = $(this).parent().siblings('.mediumInsert-placeholder');
-
- if ($(this).hasClass('active')) {
- $(this).removeClass('active');
- $options.hide();
-
- $('a', $options).show();
- } else {
- $(this).addClass('active');
- $options.show();
-
- $('a', $options).each(function () {
- var aClass = $(this).attr('class').split('action-')[1],
- plugin = aClass.split('-')[0];
- if ($('.mediumInsert-'+ plugin, $placeholder).length > 0) {
- $('a:not(.action-'+ aClass +')', $options).hide();
- }
- });
- }
-
- that.deselect();
- });
-
- $el.on('mouseleave', '.mediumInsert', function () {
- $('a.mediumInsert-buttonsShow', this).removeClass('active');
- $('.mediumInsert-buttonsOptions', this).hide();
- });
-
- $el.on('click', '.mediumInsert-buttons .mediumInsert-action', function (e) {
- e.preventDefault();
-
- var addon = $(this).data('addon'),
- action = $(this).data('action'),
- $placeholder = $(this).parents('.mediumInsert-buttons').siblings('.mediumInsert-placeholder');
-
- if (addons[addon] && addons[addon][action]) {
- addons[addon][action]($placeholder);
- }
-
- $(this).parents('.mediumInsert').mouseleave();
- });
- }
-
- };
-
-}(jQuery));
-
-/*!
- * medium-editor-insert-plugin v0.2.6 - jQuery insert plugin for MediumEditor
- *
- * Images Addon
- *
- * https://github.com/orthes/medium-editor-insert-plugin
- *
- * Copyright (c) 2013 Pavel Linkesch (http://linkesch.sk)
- * Released under the MIT license
- */
-
-(function ($) {
-
- $.fn.mediumInsert.registerAddon('images', {
-
- /**
- * Images default options
- */
-
- default: {
- /**
- * Active or inactive image's drag and drop
- */
- useDragAndDrop: true,
-
- /**
- * Relative path to a script that handles file uploads
- */
- imagesUploadScript: 'upload.php',
-
- /**
- * Relative path to a script that handles file deleting
- */
- imagesDeleteScript: 'delete.php',
-
- /**
- * Format data before sending them to server while uploading an image
- *
- * @param {File} file File to upload
- * @return {object} formData FormData instance
- */
- formatData: function (file) {
- var formData = new FormData();
- formData.append('file', file);
- return formData;
- },
-
- /**
- * Upload single file
- *
- * @param {element} $placeholder Placeholder to add image to
- * @param {File} file File to upload
- * @param {object} that Context
- * @param {void}
- */
- uploadFile: function ($placeholder, file, that) {
- $.ajax({
- type: "post",
- url: that.options.imagesUploadScript,
- xhr: function () {
- var xhr = new XMLHttpRequest();
- xhr.upload.onprogress = that.updateProgressBar;
- return xhr;
- },
- cache: false,
- contentType: false,
- complete: function (jqxhr) {
- that.uploadCompleted(jqxhr, $placeholder);
- },
- processData: false,
- data: that.options.formatData(file)
- });
- },
-
- /**
- * Makes ajax call for deleting a file on a server
- *
- * @param {string} file File name
- * @param {object} that Context
- * @return {void}
- */
- deleteFile: function (file, that) {
- $.ajax({
- type: "post",
- url: that.options.imagesDeleteScript,
- data: {
- file: file
- }
- });
- }
- },
-
-
- /**
- * Images initial function
- *
- * @param {object} options Options to overide defaults
- * @return {void}
- */
-
- init: function (options) {
- if (options && options.$el) {
- this.$el = options.$el;
- }
- this.options = $.extend(this.default, options);
-
- this.setImageEvents();
-
- if (this.options.useDragAndDrop === true){
- this.setDragAndDropEvents();
- }
-
- this.preparePreviousImages();
-
- },
-
-
- /**
- * Returns insert button
- *
- * @param {string} buttonLabels
- * @return {string}
- */
-
- insertButton: function(buttonLabels){
- var label = 'Img';
- if (buttonLabels == 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
- label = '';
- }
- return '';
- },
-
- /**
- * Make existing images interactive
- *
- * @return {void}
- */
-
- preparePreviousImages: function () {
- this.$el.find('.mediumInsert-images').each(function() {
- var $parent = $(this).parent();
- $parent.html($.fn.mediumInsert.insert.getButtons('images') +
- '