File modules/editor/trumbowyg/plugins/noembed/trumbowyg.noembed.js
Last commit: Tue Aug 28 00:33:27 2018 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.
1 /* =========================================================== 2 * trumbowyg.noembed.js v1.0 3 * noEmbed plugin for Trumbowyg 4 * http://alex-d.github.com/Trumbowyg 5 * =========================================================== 6 * Author : Jake Johns (jakejohns) 7 */ 8 9 (function ($) { 10 'use strict'; 11 12 var defaultOptions = { 13 proxy: 'https://noembed.com/embed?nowrap=on', 14 urlFiled: 'url', 15 data: [], 16 success: undefined, 17 error: undefined 18 }; 19 20 $.extend(true, $.trumbowyg, { 21 langs: { 22 en: { 23 noembed: 'Noembed', 24 noembedError: 'Error' 25 }, 26 sk: { 27 noembedError: 'Chyba' 28 }, 29 fr: { 30 noembedError: 'Erreur' 31 }, 32 cs: { 33 noembedError: 'Chyba' 34 }, 35 ru: { 36 noembedError: 'Ошибка' 37 }, 38 ja: { 39 noembedError: 'エラー' 40 }, 41 tr: { 42 noembedError: 'Hata' 43 } 44 }, 45 46 plugins: { 47 noembed: { 48 init: function (trumbowyg) { 49 trumbowyg.o.plugins.noembed = $.extend(true, {}, defaultOptions, trumbowyg.o.plugins.noembed || {}); 50 51 var btnDef = { 52 fn: function () { 53 var $modal = trumbowyg.openModalInsert( 54 // Title 55 trumbowyg.lang.noembed, 56 57 // Fields 58 { 59 url: { 60 label: 'URL', 61 required: true 62 } 63 }, 64 65 // Callback 66 function (data) { 67 $.ajax({ 68 url: trumbowyg.o.plugins.noembed.proxy, 69 type: 'GET', 70 data: data, 71 cache: false, 72 dataType: 'json', 73 74 success: trumbowyg.o.plugins.noembed.success || function (data) { 75 if (data.html) { 76 trumbowyg.execCmd('insertHTML', data.html); 77 setTimeout(function () { 78 trumbowyg.closeModal(); 79 }, 250); 80 } else { 81 trumbowyg.addErrorOnModalField( 82 $('input[type=text]', $modal), 83 data.error 84 ); 85 } 86 }, 87 error: trumbowyg.o.plugins.noembed.error || function () { 88 trumbowyg.addErrorOnModalField( 89 $('input[type=text]', $modal), 90 trumbowyg.lang.noembedError 91 ); 92 } 93 }); 94 } 95 ); 96 } 97 }; 98 99 trumbowyg.addBtnDef('noembed', btnDef); 100 } 101 } 102 } 103 }); 104 })(jQuery);
Downloadmodules/editor/trumbowyg/plugins/noembed/trumbowyg.noembed.js
History Tue, 28 Aug 2018 00:33:27 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.