[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / porte_plume / javascript / jquery.markitup_pour_spip.js
index 0a4ab63..3386459 100644 (file)
@@ -1,6 +1,6 @@
 // ----------------------------------------------------------------------------
 // markItUp! Universal MarkUp Engine, JQuery plugin
-// v 1.1.14 ( c014800b - 02/06/2014 )
+// v 1.1.15 ( e147ca3 - 16/08/2018 )
 // Dual licensed under the MIT and GPL licenses.
 // ----------------------------------------------------------------------------
 // Copyright (C) 2007-2012 Jay Salvat
@@ -26,7 +26,7 @@
 // ----------------------------------------------------------------------------
 
 /*
- *   Le code original de markitup 1.1.14
+ *   Le code original de markitup 1.1.15
  *   a ete modifie pour prendre en compte
  * 
  *   1) la langue utilisee dans les textarea :
@@ -89,7 +89,7 @@
                // compute markItUp! path
                if (!options.root) {
                        $('script').each(function(a, tag) {
-                               miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
+                               var miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
                                if (miuScript !== null) {
                                        options.root = miuScript[1];
                                }
                                                        }).on('click.markItUp', function(e) {
                                                                e.preventDefault();
                                                        }).on("focusin.markItUp", function(){
-                                                               $$.focus();
+                                                               setTimeout(function(){
+                                                                       $$.focus();
+                                                               }, 0);
                                                        }).on('mouseup', function(e) {
                                                                if (button.call) {
                                                                        eval(button.call)(e); // Pass the mouseup event to custom delegate
 
                        function renderPreview() {
                                var phtml;
+                               var parsedData = $$.val();
+                               if (options.previewParser && typeof options.previewParser === 'function') {
+                                       parsedData = options.previewParser(parsedData); 
+                               }
                                if (options.previewHandler && typeof options.previewHandler === 'function') {
-                                       options.previewHandler( $$.val() );
-                               } else if (options.previewParser && typeof options.previewParser === 'function') {
-                                       var data = options.previewParser( $$.val() );
-                                       writeInPreview(localize(data, 1) ); 
+                                       options.previewHandler(parsedData);
                                } else if (options.previewParserPath !== '') {
                                        $.ajax({
                                                type: options.previewParserAjaxType,
                                                dataType: 'text',
                                                global: false,
                                                url: options.previewParserPath,
-                                               data: options.previewParserVar+'='+encodeURIComponent($$.val()),
+                                               data: options.previewParserVar+'='+encodeURIComponent(parsedData),
                                                success: function(data) {
                                                        writeInPreview( localize(data, 1) ); 
                                                }
                        $('textarea').trigger('insertion', [options]);
                }
        };
-       
 })(jQuery);