diff --git a/.github/workflows/assets_validation.yml b/.github/workflows/assets_validation.yml index 709311002f9..867e2a59a73 100644 --- a/.github/workflows/assets_validation.yml +++ b/.github/workflows/assets_validation.yml @@ -2,6 +2,17 @@ name: Frontend Assets Build Validation on: # Manual trigger. workflow_dispatch: + push: + paths-ignore: + - '**/*.md' + - 'mkdocs.yml' + - 'src/docs/**/*' + branches: [ main ] + pull_request: + branches: [ main, release/** ] +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: test-npm-build: name: Test building assets diff --git a/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/trumbowyg-plugins.js b/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/trumbowyg-plugins.js index 8666068348f..a2e906fb0d7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/trumbowyg-plugins.js +++ b/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/trumbowyg-plugins.js @@ -1586,6 +1586,1084 @@ } }); }(jQuery); +(function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + fontsize: 'Font size', + fontsizes: { + 'x-small': 'Extra small', + 'small': 'Small', + 'medium': 'Regular', + 'large': 'Large', + 'x-large': 'Extra large', + 'custom': 'Custom' + }, + fontCustomSize: { + title: 'Custom Font Size', + label: 'Font Size', + value: '48px' + } + }, + az: { + fontsize: 'Şrift həcmi', + fontsizes: { + 'x-small': 'Daha kiçik', + 'small': 'Kiçik', + 'medium': 'Normal', + 'large': 'Böyük', + 'x-large': 'Daha böyük', + 'custom': 'Fərdi həcm' + }, + fontCustomSize: { + title: 'Fərdi şrift həcmi', + label: 'Şrift həcmi', + value: '48px' + } + }, + by: { + fontsize: 'Памер шрыфта', + fontsizes: { + 'x-small': 'Вельмі маленькі', + 'small': 'Маленькі', + 'medium': 'Звычайны', + 'large': 'Вялікі', + 'x-large': 'Вельмі вялікі', + 'custom': 'Карыстальніцкі' + }, + fontCustomSize: { + title: 'Карыстальніцкі Памер Шрыфта', + label: 'Памер Шрыфта', + value: '48px' + } + }, + ca: { + fontsize: 'Mida de la lletra', + fontsizes: { + 'x-small': 'Molt petita', + 'small': 'Petita', + 'medium': 'Normal', + 'large': 'Gran', + 'x-large': 'Molt Gran', + 'custom': 'Personalitzada' + }, + fontCustomSize: { + title: 'Mida de lletra personalitzada', + label: 'Mida de lletra', + value: '48px' + } + }, + da: { + fontsize: 'Skriftstørrelse', + fontsizes: { + 'x-small': 'Ekstra lille', + 'small': 'Lille', + 'medium': 'Normal', + 'large': 'Stor', + 'x-large': 'Ekstra stor', + 'custom': 'Brugerdefineret' + } + }, + de: { + fontsize: 'Schriftgröße', + fontsizes: { + 'x-small': 'Sehr klein', + 'small': 'Klein', + 'medium': 'Normal', + 'large': 'Groß', + 'x-large': 'Sehr groß', + 'custom': 'Benutzerdefiniert' + }, + fontCustomSize: { + title: 'Benutzerdefinierte Schriftgröße', + label: 'Schriftgröße', + value: '48px' + } + }, + es: { + fontsize: 'Tamaño de Fuente', + fontsizes: { + 'x-small': 'Extra pequeña', + 'small': 'Pegueña', + 'medium': 'Regular', + 'large': 'Grande', + 'x-large': 'Extra Grande', + 'custom': 'Customizada' + }, + fontCustomSize: { + title: 'Tamaño de Fuente Customizada', + label: 'Tamaño de Fuente', + value: '48px' + } + }, + et: { + fontsize: 'Teksti suurus', + fontsizes: { + 'x-small': 'Väga väike', + 'small': 'Väike', + 'medium': 'Tavaline', + 'large': 'Suur', + 'x-large': 'Väga suur', + 'custom': 'Määra ise' + }, + fontCustomSize: { + title: 'Kohandatud teksti suurus', + label: 'Teksti suurus', + value: '48px' + } + }, + fr: { + fontsize: 'Taille de la police', + fontsizes: { + 'x-small': 'Très petit', + 'small': 'Petit', + 'medium': 'Normal', + 'large': 'Grand', + 'x-large': 'Très grand', + 'custom': 'Taille personnalisée' + }, + fontCustomSize: { + title: 'Taille de police personnalisée', + label: 'Taille de la police', + value: '48px' + } + }, + hu: { + fontsize: 'Betű méret', + fontsizes: { + 'x-small': 'Extra kicsi', + 'small': 'Kicsi', + 'medium': 'Normális', + 'large': 'Nagy', + 'x-large': 'Extra nagy', + 'custom': 'Egyedi' + }, + fontCustomSize: { + title: 'Egyedi betű méret', + label: 'Betű méret', + value: '48px' + } + }, + it: { + fontsize: 'Dimensioni del testo', + fontsizes: { + 'x-small': 'Molto piccolo', + 'small': 'piccolo', + 'regular': 'normale', + 'large': 'grande', + 'x-large': 'Molto grande', + 'custom': 'Personalizzato' + }, + fontCustomSize: { + title: 'Dimensioni del testo personalizzato', + label: 'Dimensioni del testo', + value: '48px' + } + }, + ko: { + fontsize: '글꼴 크기', + fontsizes: { + 'x-small': '아주 작게', + 'small': '작게', + 'medium': '보통', + 'large': '크게', + 'x-large': '아주 크게', + 'custom': '사용자 지정' + }, + fontCustomSize: { + title: '사용자 지정 글꼴 크기', + label: '글꼴 크기', + value: '48px' + } + }, + nl: { + fontsize: 'Lettergrootte', + fontsizes: { + 'x-small': 'Extra klein', + 'small': 'Klein', + 'medium': 'Normaal', + 'large': 'Groot', + 'x-large': 'Extra groot', + 'custom': 'Handmatig' + }, + fontCustomSize: { + title: 'Handmatige lettergrootte', + label: 'Lettergrootte', + value: '48px' + } + }, + pt_br: { + fontsize: 'Tamanho da fonte', + fontsizes: { + 'x-small': 'Extra pequeno', + 'small': 'Pequeno', + 'regular': 'Médio', + 'large': 'Grande', + 'x-large': 'Extra grande', + 'custom': 'Personalizado' + }, + fontCustomSize: { + title: 'Tamanho de Fonte Personalizado', + label: 'Tamanho de Fonte', + value: '48px' + } + }, + ru: { + fontsize: 'Размер шрифта', + fontsizes: { + 'x-small': 'Очень маленький', + 'small': 'Маленький', + 'medium': 'Обычный', + 'large': 'Большой', + 'x-large': 'Очень большой', + 'custom': 'Пользовательский' + }, + fontCustomSize: { + title: 'Пользовательский Размер Шрифта', + label: 'Размер Шрифта', + value: '48px' + } + }, + sl: { + fontsize: 'Velikost pisave', + fontsizes: { + 'x-small': 'Ekstra majhna', + 'small': 'Majhna', + 'medium': 'Navadno', + 'large': 'Velika', + 'x-large': 'Ekstra velika', + 'custom': 'Poljubna' + }, + fontCustomSize: { + title: 'Poljubna velikost pisave', + label: 'Velikost pisave', + value: '48px' + } + }, + tr: { + fontsize: 'Yazı boyutu', + fontsizes: { + 'x-small': 'Çok küçük', + 'small': 'Küçük', + 'medium': 'Normal', + 'large': 'Büyük', + 'x-large': 'Çok büyük', + 'custom': 'Özel' + }, + fontCustomSize: { + title: 'Özel Yazı Boyutu', + label: 'Yazı Boyutu', + value: '48px' + } + }, + zh_tw: { + fontsize: '字體大小', + fontsizes: { + 'x-small': '最小', + 'small': '小', + 'medium': '中', + 'large': '大', + 'x-large': '最大', + 'custom': '自訂大小' + }, + fontCustomSize: { + title: '自訂義字體大小', + label: '字體大小', + value: '48px' + } + } + } + }); + // jshint camelcase:true + + var defaultOptions = { + sizeList: ['x-small', 'small', 'medium', 'large', 'x-large'], + allowCustomSize: true + }; + + // Add dropdown with font sizes + $.extend(true, $.trumbowyg, { + plugins: { + fontsize: { + init: function init(trumbowyg) { + trumbowyg.o.plugins.fontsize = $.extend({}, defaultOptions, trumbowyg.o.plugins.fontsize || {}); + trumbowyg.addBtnDef('fontsize', { + dropdown: buildDropdown(trumbowyg) + }); + } + } + } + }); + function setFontSize(trumbowyg, size) { + trumbowyg.$ed.focus(); + trumbowyg.saveRange(); + + // Temporary size + trumbowyg.execCmd('fontSize', '1'); + var fontElements = trumbowyg.$ed.find('font[size="1"]'); + + // Remove previous font-size span tags. Needed to prevent Firefox from + // nesting multiple spans on font-size changes. + // (see https://github.com/Alex-D/Trumbowyg/issues/1252) + fontElements.find('span[style*="font-size"]').contents().unwrap(); + + // Find elements that were added and change to with chosen size + fontElements.replaceWith(function () { + return $('', { + css: { + 'font-size': size + }, + html: this.innerHTML + }); + }); + + // Remove and leftover elements + $(trumbowyg.range.startContainer.parentElement).find('span[style=""]').contents().unwrap(); + trumbowyg.restoreRange(); + trumbowyg.syncCode(); + trumbowyg.$c.trigger('tbwchange'); + } + function buildDropdown(trumbowyg) { + var dropdown = []; + $.each(trumbowyg.o.plugins.fontsize.sizeList, function (index, size) { + trumbowyg.addBtnDef('fontsize_' + size, { + text: '' + (trumbowyg.lang.fontsizes[size] || size) + '', + hasIcon: false, + fn: function fn() { + setFontSize(trumbowyg, size); + } + }); + dropdown.push('fontsize_' + size); + }); + if (trumbowyg.o.plugins.fontsize.allowCustomSize) { + var customSizeButtonName = 'fontsize_custom'; + var customSizeBtnDef = { + fn: function fn() { + trumbowyg.openModalInsert(trumbowyg.lang.fontCustomSize.title, { + size: { + label: trumbowyg.lang.fontCustomSize.label, + value: trumbowyg.lang.fontCustomSize.value + } + }, function (form) { + setFontSize(trumbowyg, form.size); + return true; + }); + }, + text: '' + trumbowyg.lang.fontsizes.custom + '', + hasIcon: false + }; + trumbowyg.addBtnDef(customSizeButtonName, customSizeBtnDef); + dropdown.push(customSizeButtonName); + } + return dropdown; + } +})(jQuery); +!function (e) { + "use strict"; + + e.extend(!0, e.trumbowyg, { + langs: { + en: { + fontsize: "Font size", + fontsizes: { + "x-small": "Extra small", + small: "Small", + medium: "Regular", + large: "Large", + "x-large": "Extra large", + custom: "Custom" + }, + fontCustomSize: { + title: "Custom Font Size", + label: "Font Size", + value: "48px" + } + }, + az: { + fontsize: "Şrift həcmi", + fontsizes: { + "x-small": "Daha kiçik", + small: "Kiçik", + medium: "Normal", + large: "Böyük", + "x-large": "Daha böyük", + custom: "Fərdi həcm" + }, + fontCustomSize: { + title: "Fərdi şrift həcmi", + label: "Şrift həcmi", + value: "48px" + } + }, + by: { + fontsize: "Памер шрыфта", + fontsizes: { + "x-small": "Вельмі маленькі", + small: "Маленькі", + medium: "Звычайны", + large: "Вялікі", + "x-large": "Вельмі вялікі", + custom: "Карыстальніцкі" + }, + fontCustomSize: { + title: "Карыстальніцкі Памер Шрыфта", + label: "Памер Шрыфта", + value: "48px" + } + }, + ca: { + fontsize: "Mida de la lletra", + fontsizes: { + "x-small": "Molt petita", + small: "Petita", + medium: "Normal", + large: "Gran", + "x-large": "Molt Gran", + custom: "Personalitzada" + }, + fontCustomSize: { + title: "Mida de lletra personalitzada", + label: "Mida de lletra", + value: "48px" + } + }, + da: { + fontsize: "Skriftstørrelse", + fontsizes: { + "x-small": "Ekstra lille", + small: "Lille", + medium: "Normal", + large: "Stor", + "x-large": "Ekstra stor", + custom: "Brugerdefineret" + } + }, + de: { + fontsize: "Schriftgröße", + fontsizes: { + "x-small": "Sehr klein", + small: "Klein", + medium: "Normal", + large: "Groß", + "x-large": "Sehr groß", + custom: "Benutzerdefiniert" + }, + fontCustomSize: { + title: "Benutzerdefinierte Schriftgröße", + label: "Schriftgröße", + value: "48px" + } + }, + es: { + fontsize: "Tamaño de Fuente", + fontsizes: { + "x-small": "Extra pequeña", + small: "Pegueña", + medium: "Regular", + large: "Grande", + "x-large": "Extra Grande", + custom: "Customizada" + }, + fontCustomSize: { + title: "Tamaño de Fuente Customizada", + label: "Tamaño de Fuente", + value: "48px" + } + }, + et: { + fontsize: "Teksti suurus", + fontsizes: { + "x-small": "Väga väike", + small: "Väike", + medium: "Tavaline", + large: "Suur", + "x-large": "Väga suur", + custom: "Määra ise" + }, + fontCustomSize: { + title: "Kohandatud teksti suurus", + label: "Teksti suurus", + value: "48px" + } + }, + fr: { + fontsize: "Taille de la police", + fontsizes: { + "x-small": "Très petit", + small: "Petit", + medium: "Normal", + large: "Grand", + "x-large": "Très grand", + custom: "Taille personnalisée" + }, + fontCustomSize: { + title: "Taille de police personnalisée", + label: "Taille de la police", + value: "48px" + } + }, + hu: { + fontsize: "Betű méret", + fontsizes: { + "x-small": "Extra kicsi", + small: "Kicsi", + medium: "Normális", + large: "Nagy", + "x-large": "Extra nagy", + custom: "Egyedi" + }, + fontCustomSize: { + title: "Egyedi betű méret", + label: "Betű méret", + value: "48px" + } + }, + it: { + fontsize: "Dimensioni del testo", + fontsizes: { + "x-small": "Molto piccolo", + small: "piccolo", + regular: "normale", + large: "grande", + "x-large": "Molto grande", + custom: "Personalizzato" + }, + fontCustomSize: { + title: "Dimensioni del testo personalizzato", + label: "Dimensioni del testo", + value: "48px" + } + }, + ko: { + fontsize: "글꼴 크기", + fontsizes: { + "x-small": "아주 작게", + small: "작게", + medium: "보통", + large: "크게", + "x-large": "아주 크게", + custom: "사용자 지정" + }, + fontCustomSize: { + title: "사용자 지정 글꼴 크기", + label: "글꼴 크기", + value: "48px" + } + }, + nl: { + fontsize: "Lettergrootte", + fontsizes: { + "x-small": "Extra klein", + small: "Klein", + medium: "Normaal", + large: "Groot", + "x-large": "Extra groot", + custom: "Handmatig" + }, + fontCustomSize: { + title: "Handmatige lettergrootte", + label: "Lettergrootte", + value: "48px" + } + }, + pt_br: { + fontsize: "Tamanho da fonte", + fontsizes: { + "x-small": "Extra pequeno", + small: "Pequeno", + regular: "Médio", + large: "Grande", + "x-large": "Extra grande", + custom: "Personalizado" + }, + fontCustomSize: { + title: "Tamanho de Fonte Personalizado", + label: "Tamanho de Fonte", + value: "48px" + } + }, + ru: { + fontsize: "Размер шрифта", + fontsizes: { + "x-small": "Очень маленький", + small: "Маленький", + medium: "Обычный", + large: "Большой", + "x-large": "Очень большой", + custom: "Пользовательский" + }, + fontCustomSize: { + title: "Пользовательский Размер Шрифта", + label: "Размер Шрифта", + value: "48px" + } + }, + sl: { + fontsize: "Velikost pisave", + fontsizes: { + "x-small": "Ekstra majhna", + small: "Majhna", + medium: "Navadno", + large: "Velika", + "x-large": "Ekstra velika", + custom: "Poljubna" + }, + fontCustomSize: { + title: "Poljubna velikost pisave", + label: "Velikost pisave", + value: "48px" + } + }, + tr: { + fontsize: "Yazı boyutu", + fontsizes: { + "x-small": "Çok küçük", + small: "Küçük", + medium: "Normal", + large: "Büyük", + "x-large": "Çok büyük", + custom: "Özel" + }, + fontCustomSize: { + title: "Özel Yazı Boyutu", + label: "Yazı Boyutu", + value: "48px" + } + }, + zh_tw: { + fontsize: "字體大小", + fontsizes: { + "x-small": "最小", + small: "小", + medium: "中", + large: "大", + "x-large": "最大", + custom: "自訂大小" + }, + fontCustomSize: { + title: "自訂義字體大小", + label: "字體大小", + value: "48px" + } + } + } + }); + var t = { + sizeList: ["x-small", "small", "medium", "large", "x-large"], + allowCustomSize: !0 + }; + function l(t, l) { + t.$ed.focus(), t.saveRange(), t.execCmd("fontSize", "1"); + var a = t.$ed.find('font[size="1"]'); + a.find('span[style*="font-size"]').contents().unwrap(), a.replaceWith(function () { + return e("", { + css: { + "font-size": l + }, + html: this.innerHTML + }); + }), e(t.range.startContainer.parentElement).find('span[style=""]').contents().unwrap(), t.restoreRange(), t.syncCode(), t.$c.trigger("tbwchange"); + } + function a(t) { + var a = []; + if (e.each(t.o.plugins.fontsize.sizeList, function (e, s) { + t.addBtnDef("fontsize_" + s, { + text: '' + (t.lang.fontsizes[s] || s) + "", + hasIcon: !1, + fn: function fn() { + l(t, s); + } + }), a.push("fontsize_" + s); + }), t.o.plugins.fontsize.allowCustomSize) { + var s = "fontsize_custom", + i = { + fn: function fn() { + t.openModalInsert(t.lang.fontCustomSize.title, { + size: { + label: t.lang.fontCustomSize.label, + value: t.lang.fontCustomSize.value + } + }, function (e) { + return l(t, e.size), !0; + }); + }, + text: '' + t.lang.fontsizes.custom + "", + hasIcon: !1 + }; + t.addBtnDef(s, i), a.push(s); + } + return a; + } + e.extend(!0, e.trumbowyg, { + plugins: { + fontsize: { + init: function init(l) { + l.o.plugins.fontsize = e.extend({}, t, l.o.plugins.fontsize || {}), l.addBtnDef("fontsize", { + dropdown: a(l) + }); + } + } + } + }); +}(jQuery); +(function ($) { + 'use strict'; + + $.extend(true, $.trumbowyg, { + langs: { + // jshint camelcase:false + en: { + giphy: 'Insert GIF' + }, + az: { + giphy: 'GIF yerləşdir' + }, + by: { + giphy: 'Уставіць GIF' + }, + et: { + giphy: 'Sisesta GIF' + }, + fr: { + giphy: 'Insérer un GIF' + }, + hu: { + giphy: 'GIF beszúrás' + }, + ru: { + giphy: 'Вставить GIF' + }, + sl: { + giphy: 'Vstavi GIF' + }, + tr: { + giphy: 'GIF ekle' + } + // jshint camelcase:true + } + }); + + var giphyLogo = ''; // jshint ignore:line + + var CANCEL_EVENT = 'tbwcancel'; + + // Throttle helper + function trumbowygThrottle(callback, delay) { + var last; + var timer; + return function () { + var context = this; + var now = +new Date(); + var args = arguments; + if (last && now < last + delay) { + clearTimeout(timer); + timer = setTimeout(function () { + last = now; + callback.apply(context, args); + }, delay); + } else { + last = now; + callback.apply(context, args); + } + }; + } + + // Fills modal with response gifs + function renderGifs(response, $giphyModal, trumbowyg, mustEmpty) { + var width = ($giphyModal.width() - 20) / 3; + var html = response.data.filter(function (gifData) { + // jshint camelcase:false + var downsized = gifData.images.downsized || gifData.images.downsized_medium; + // jshint camelcase:true + return !!downsized.url; + }).map(function (gifData) { + // jshint camelcase:false + var downsized = gifData.images.downsized || gifData.images.downsized_medium; + // jshint camelcase:true + var image = downsized, + imageRatio = image.height / image.width, + altText = gifData.title; + var imgHtml = '' + altText + ''; + return '
' + imgHtml + '
'; + }).join(''); + if (mustEmpty === true) { + if (html.length === 0) { + if ($('.' + trumbowyg.o.prefix + 'giphy-no-result', $giphyModal).length > 0) { + return; + } + html = ''; + } + $giphyModal.empty(); + } + $giphyModal.append(html); + + // Remove gray overlay on image load + // moved here from inline callback definition due to CSP issue + // Note: this is being done post-factum because load event doesn't bubble up and so can't be delegated + var addLoadedClass = function addLoadedClass(img) { + img.classList.add('tbw-loaded'); + }; + $('img', $giphyModal).each(function () { + var img = this; + if (img.complete) { + // images load instantly when cached and esp. when loaded in previous modal open + addLoadedClass(img); + } else { + img.addEventListener('load', function () { + addLoadedClass(this); + }); + } + }); + $('img', $giphyModal).on('click', function () { + var src = $(this).attr('src'), + alt = $(this).attr('alt'); + trumbowyg.restoreRange(); + trumbowyg.execCmd('insertImage', src, false, true); + + // relay alt tag into inserted image + if (alt) { + var $img = $('img[src="' + src + '"]:not([alt])', trumbowyg.$box); + $img.attr('alt', alt); + // Note: This seems to fire relatively early and could be wrapped in a setTimeout if needed + trumbowyg.syncCode(); + } + $('img', $giphyModal).off(); + trumbowyg.closeModal(); + }); + } + var defaultOptions = { + rating: 'g', + apiKey: null, + throttleDelay: 300, + noResultGifUrl: 'https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif' + }; + + // Add dropdown with font sizes + $.extend(true, $.trumbowyg, { + plugins: { + giphy: { + init: function init(trumbowyg) { + trumbowyg.o.plugins.giphy = $.extend({}, defaultOptions, trumbowyg.o.plugins.giphy || {}); + trumbowyg.addBtnDef('giphy', { + fn: function fn() { + if (trumbowyg.o.plugins.giphy.apiKey === null) { + throw new Error('You must set a Giphy API Key'); + } + var BASE_URL = 'https://api.giphy.com/v1/gifs/search?api_key=' + trumbowyg.o.plugins.giphy.apiKey + '&rating=' + trumbowyg.o.plugins.giphy.rating, + DEFAULT_URL = BASE_URL.replace('/search', '/trending'); + var previousAjaxCall = { + abort: function abort() {} + }; + var prefix = trumbowyg.o.prefix; + + // Create and open the modal + var searchInput = '', + closeButton = '', + poweredByGiphy = '
Powered by' + giphyLogo + '
', + giphyModalHtml = searchInput + closeButton + poweredByGiphy + '
'; + trumbowyg.openModal(null, giphyModalHtml, false).one(CANCEL_EVENT, function () { + try { + previousAjaxCall.abort(); + } catch (e) {} + trumbowyg.closeModal(); + }); + var $giphyInput = $('.' + prefix + 'giphy-search'), + $giphyClose = $('.' + prefix + 'giphy-close'), + $giphyModal = $('.' + prefix + 'giphy-modal'); + var ajaxError = function ajaxError() { + if (!navigator.onLine && !$('.' + prefix + 'giphy-offline', $giphyModal).length) { + $giphyModal.empty(); + $giphyModal.append('

You are offline

'); + } + }; + + // Load trending gifs as default + $.ajax({ + url: DEFAULT_URL, + dataType: 'json', + success: function success(response) { + renderGifs(response, $giphyModal, trumbowyg, true); + }, + error: ajaxError + }); + var searchGifsOnInput = function searchGifsOnInput() { + var query = $giphyInput.val(); + if (query.length === 0) { + return; + } + try { + previousAjaxCall.abort(); + } catch (e) {} + previousAjaxCall = $.ajax({ + url: BASE_URL + '&q=' + encodeURIComponent(query), + dataType: 'json', + success: function success(response) { + renderGifs(response, $giphyModal, trumbowyg, true); + }, + error: ajaxError + }); + }; + var throttledInputRequest = trumbowygThrottle(searchGifsOnInput, trumbowyg.o.plugins.giphy.throttleDelay); + $giphyInput.on('input', throttledInputRequest); + $giphyInput.focus(); + $giphyClose.one('click', function () { + $giphyModal.trigger(CANCEL_EVENT); + }); + } + }); + } + } + } + }); +})(jQuery); +!function (i) { + "use strict"; + + i.extend(!0, i.trumbowyg, { + langs: { + en: { + giphy: "Insert GIF" + }, + az: { + giphy: "GIF yerləşdir" + }, + by: { + giphy: "Уставіць GIF" + }, + et: { + giphy: "Sisesta GIF" + }, + fr: { + giphy: "Insérer un GIF" + }, + hu: { + giphy: "GIF beszúrás" + }, + ru: { + giphy: "Вставить GIF" + }, + sl: { + giphy: "Vstavi GIF" + }, + tr: { + giphy: "GIF ekle" + } + } + }); + var e = "tbwcancel"; + function t(e, t, n, l) { + var a = (t.width() - 20) / 3, + o = e.data.filter(function (i) { + return !!(i.images.downsized || i.images.downsized_medium).url; + }).map(function (i) { + var e = i.images.downsized || i.images.downsized_medium, + t = e.height / e.width, + n = i.title; + return '
' + ("' + n + '') + "
"; + }).join(""); + if (!0 === l) { + if (0 === o.length) { + if (i("." + n.o.prefix + "giphy-no-result", t).length > 0) return; + o = ''; + } + t.empty(); + } + t.append(o); + var c = function c(i) { + i.classList.add("tbw-loaded"); + }; + i("img", t).each(function () { + var i = this; + i.complete ? c(i) : i.addEventListener("load", function () { + c(this); + }); + }), i("img", t).on("click", function () { + var e = i(this).attr("src"), + l = i(this).attr("alt"); + (n.restoreRange(), n.execCmd("insertImage", e, !1, !0), l) && (i('img[src="' + e + '"]:not([alt])', n.$box).attr("alt", l), n.syncCode()); + i("img", t).off(), n.closeModal(); + }); + } + var n = { + rating: "g", + apiKey: null, + throttleDelay: 300, + noResultGifUrl: "https://media.giphy.com/media/2Faz9FbRzmwxY0pZS/giphy.gif" + }; + i.extend(!0, i.trumbowyg, { + plugins: { + giphy: { + init: function init(l) { + l.o.plugins.giphy = i.extend({}, n, l.o.plugins.giphy || {}), l.addBtnDef("giphy", { + fn: function fn() { + if (null === l.o.plugins.giphy.apiKey) throw new Error("You must set a Giphy API Key"); + var n = "https://api.giphy.com/v1/gifs/search?api_key=" + l.o.plugins.giphy.apiKey + "&rating=" + l.o.plugins.giphy.rating, + a = n.replace("/search", "/trending"), + o = { + abort: function abort() {} + }, + c = l.o.prefix, + r = '' + ('') + ('
Powered by
') + '
'; + l.openModal(null, r, !1).one(e, function () { + try { + o.abort(); + } catch (i) {} + l.closeModal(); + }); + var s = i("." + c + "giphy-search"), + g = i("." + c + "giphy-close"), + p = i("." + c + "giphy-modal"), + h = function h() { + navigator.onLine || i("." + c + "giphy-offline", p).length || (p.empty(), p.append('

You are offline

')); + }; + i.ajax({ + url: a, + dataType: "json", + success: function success(i) { + t(i, p, l, !0); + }, + error: h + }); + var u, + d, + y, + f, + m = (u = function u() { + var e = s.val(); + if (0 !== e.length) { + try { + o.abort(); + } catch (i) {} + o = i.ajax({ + url: n + "&q=" + encodeURIComponent(e), + dataType: "json", + success: function success(i) { + t(i, p, l, !0); + }, + error: h + }); + } + }, d = l.o.plugins.giphy.throttleDelay, function () { + var i = this, + e = +new Date(), + t = arguments; + y && e < y + d ? (clearTimeout(f), f = setTimeout(function () { + y = e, u.apply(i, t); + }, d)) : (y = e, u.apply(i, t)); + }); + s.on("input", m), s.focus(), g.one("click", function () { + p.trigger(e); + }); + } + }); + } + } + } + }); +}(jQuery); /*/* =========================================================== * trumbowyg.history.js v1.0 * history plugin for Trumbowyg @@ -1986,724 +3064,216 @@ } }); }(jQuery); +/*/* =========================================================== + * trumbowyg.insertaudio.js v1.0 + * InsertAudio plugin for Trumbowyg + * http://alex-d.github.com/Trumbowyg + * =========================================================== + * Author : Adam Hess (AdamHess) + */ + (function ($) { 'use strict'; + var insertAudioOptions = { + src: { + label: 'URL', + required: true + }, + autoplay: { + label: 'AutoPlay', + required: false, + type: 'checkbox' + }, + muted: { + label: 'Muted', + required: false, + type: 'checkbox' + }, + preload: { + label: 'preload options', + required: false + } + }; $.extend(true, $.trumbowyg, { langs: { // jshint camelcase:false en: { - fontsize: 'Font size', - fontsizes: { - 'x-small': 'Extra small', - 'small': 'Small', - 'medium': 'Regular', - 'large': 'Large', - 'x-large': 'Extra large', - 'custom': 'Custom' - }, - fontCustomSize: { - title: 'Custom Font Size', - label: 'Font Size', - value: '48px' - } + insertAudio: 'Insert Audio' }, az: { - fontsize: 'Şrift həcmi', - fontsizes: { - 'x-small': 'Daha kiçik', - 'small': 'Kiçik', - 'medium': 'Normal', - 'large': 'Böyük', - 'x-large': 'Daha böyük', - 'custom': 'Fərdi həcm' - }, - fontCustomSize: { - title: 'Fərdi şrift həcmi', - label: 'Şrift həcmi', - value: '48px' - } + insertAudio: 'Səs yerləşdir' }, by: { - fontsize: 'Памер шрыфта', - fontsizes: { - 'x-small': 'Вельмі маленькі', - 'small': 'Маленькі', - 'medium': 'Звычайны', - 'large': 'Вялікі', - 'x-large': 'Вельмі вялікі', - 'custom': 'Карыстальніцкі' - }, - fontCustomSize: { - title: 'Карыстальніцкі Памер Шрыфта', - label: 'Памер Шрыфта', - value: '48px' - } - }, - ca: { - fontsize: 'Mida de la lletra', - fontsizes: { - 'x-small': 'Molt petita', - 'small': 'Petita', - 'medium': 'Normal', - 'large': 'Gran', - 'x-large': 'Molt Gran', - 'custom': 'Personalitzada' - }, - fontCustomSize: { - title: 'Mida de lletra personalitzada', - label: 'Mida de lletra', - value: '48px' - } + insertAudio: 'Уставіць аўдыё' }, - da: { - fontsize: 'Skriftstørrelse', - fontsizes: { - 'x-small': 'Ekstra lille', - 'small': 'Lille', - 'medium': 'Normal', - 'large': 'Stor', - 'x-large': 'Ekstra stor', - 'custom': 'Brugerdefineret' - } + ca: { + insertAudio: 'Inserir Audio' }, - de: { - fontsize: 'Schriftgröße', - fontsizes: { - 'x-small': 'Sehr klein', - 'small': 'Klein', - 'medium': 'Normal', - 'large': 'Groß', - 'x-large': 'Sehr groß', - 'custom': 'Benutzerdefiniert' - }, - fontCustomSize: { - title: 'Benutzerdefinierte Schriftgröße', - label: 'Schriftgröße', - value: '48px' - } + da: { + insertAudio: 'Indsæt lyd' }, es: { - fontsize: 'Tamaño de Fuente', - fontsizes: { - 'x-small': 'Extra pequeña', - 'small': 'Pegueña', - 'medium': 'Regular', - 'large': 'Grande', - 'x-large': 'Extra Grande', - 'custom': 'Customizada' - }, - fontCustomSize: { - title: 'Tamaño de Fuente Customizada', - label: 'Tamaño de Fuente', - value: '48px' - } + insertAudio: 'Insertar Audio' }, et: { - fontsize: 'Teksti suurus', - fontsizes: { - 'x-small': 'Väga väike', - 'small': 'Väike', - 'medium': 'Tavaline', - 'large': 'Suur', - 'x-large': 'Väga suur', - 'custom': 'Määra ise' - }, - fontCustomSize: { - title: 'Kohandatud teksti suurus', - label: 'Teksti suurus', - value: '48px' - } + insertAudio: 'Lisa helifail' }, fr: { - fontsize: 'Taille de la police', - fontsizes: { - 'x-small': 'Très petit', - 'small': 'Petit', - 'medium': 'Normal', - 'large': 'Grand', - 'x-large': 'Très grand', - 'custom': 'Taille personnalisée' - }, - fontCustomSize: { - title: 'Taille de police personnalisée', - label: 'Taille de la police', - value: '48px' - } + insertAudio: 'Insérer un son' }, hu: { - fontsize: 'Betű méret', - fontsizes: { - 'x-small': 'Extra kicsi', - 'small': 'Kicsi', - 'medium': 'Normális', - 'large': 'Nagy', - 'x-large': 'Extra nagy', - 'custom': 'Egyedi' - }, - fontCustomSize: { - title: 'Egyedi betű méret', - label: 'Betű méret', - value: '48px' - } + insertAudio: 'Audio beszúrás' }, - it: { - fontsize: 'Dimensioni del testo', - fontsizes: { - 'x-small': 'Molto piccolo', - 'small': 'piccolo', - 'regular': 'normale', - 'large': 'grande', - 'x-large': 'Molto grande', - 'custom': 'Personalizzato' - }, - fontCustomSize: { - title: 'Dimensioni del testo personalizzato', - label: 'Dimensioni del testo', - value: '48px' - } + ja: { + insertAudio: '音声の挿入' }, ko: { - fontsize: '글꼴 크기', - fontsizes: { - 'x-small': '아주 작게', - 'small': '작게', - 'medium': '보통', - 'large': '크게', - 'x-large': '아주 크게', - 'custom': '사용자 지정' - }, - fontCustomSize: { - title: '사용자 지정 글꼴 크기', - label: '글꼴 크기', - value: '48px' - } - }, - nl: { - fontsize: 'Lettergrootte', - fontsizes: { - 'x-small': 'Extra klein', - 'small': 'Klein', - 'medium': 'Normaal', - 'large': 'Groot', - 'x-large': 'Extra groot', - 'custom': 'Handmatig' - }, - fontCustomSize: { - title: 'Handmatige lettergrootte', - label: 'Lettergrootte', - value: '48px' - } + insertAudio: '소리 넣기' }, pt_br: { - fontsize: 'Tamanho da fonte', - fontsizes: { - 'x-small': 'Extra pequeno', - 'small': 'Pequeno', - 'regular': 'Médio', - 'large': 'Grande', - 'x-large': 'Extra grande', - 'custom': 'Personalizado' - }, - fontCustomSize: { - title: 'Tamanho de Fonte Personalizado', - label: 'Tamanho de Fonte', - value: '48px' - } + insertAudio: 'Inserir áudio' }, ru: { - fontsize: 'Размер шрифта', - fontsizes: { - 'x-small': 'Очень маленький', - 'small': 'Маленький', - 'medium': 'Обычный', - 'large': 'Большой', - 'x-large': 'Очень большой', - 'custom': 'Пользовательский' - }, - fontCustomSize: { - title: 'Пользовательский Размер Шрифта', - label: 'Размер Шрифта', - value: '48px' - } + insertAudio: 'Вставить аудио' }, sl: { - fontsize: 'Velikost pisave', - fontsizes: { - 'x-small': 'Ekstra majhna', - 'small': 'Majhna', - 'medium': 'Navadno', - 'large': 'Velika', - 'x-large': 'Ekstra velika', - 'custom': 'Poljubna' - }, - fontCustomSize: { - title: 'Poljubna velikost pisave', - label: 'Velikost pisave', - value: '48px' - } + insertAudio: 'Vstavi zvočno datoteko' }, tr: { - fontsize: 'Yazı boyutu', - fontsizes: { - 'x-small': 'Çok küçük', - 'small': 'Küçük', - 'medium': 'Normal', - 'large': 'Büyük', - 'x-large': 'Çok büyük', - 'custom': 'Özel' - }, - fontCustomSize: { - title: 'Özel Yazı Boyutu', - label: 'Yazı Boyutu', - value: '48px' - } - }, - zh_tw: { - fontsize: '字體大小', - fontsizes: { - 'x-small': '最小', - 'small': '小', - 'medium': '中', - 'large': '大', - 'x-large': '最大', - 'custom': '自訂大小' - }, - fontCustomSize: { - title: '自訂義字體大小', - label: '字體大小', - value: '48px' - } + insertAudio: 'Ses Ekle' } - } - }); - // jshint camelcase:true - - var defaultOptions = { - sizeList: ['x-small', 'small', 'medium', 'large', 'x-large'], - allowCustomSize: true - }; + // jshint camelcase:true + }, - // Add dropdown with font sizes - $.extend(true, $.trumbowyg, { plugins: { - fontsize: { + insertAudio: { init: function init(trumbowyg) { - trumbowyg.o.plugins.fontsize = $.extend({}, defaultOptions, trumbowyg.o.plugins.fontsize || {}); - trumbowyg.addBtnDef('fontsize', { - dropdown: buildDropdown(trumbowyg) - }); + var btnDef = { + fn: function fn() { + var insertAudioCallback = function insertAudioCallback(v) { + // controls should always be show otherwise the audio will + // be invisible defeating the point of a wysiwyg + var html = '