j1-template 2021.2.7 → 2021.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/blocks/footer/boxes/contacts_box.proc +1 -1
- data/_includes/themes/j1/layouts/content_generator_article_navigator.html +2 -2
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +2 -2
- data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +2 -2
- data/_includes/themes/j1/modules/boards/news_pin_board.html +10 -10
- data/_includes/themes/j1/modules/connectors/translators/google-translator.html +20 -4
- data/_includes/themes/j1/modules/navigator/generator.html +6 -6
- data/_includes/themes/j1/procedures/posts/collate_calendar.proc +3 -3
- data/_includes/themes/j1/procedures/posts/create_series_header.proc +1 -1
- data/_includes/themes/j1/procedures/posts/pager.proc +1 -1
- data/assets/data/gallery_customizer.html +1 -1
- data/assets/data/menu.html +17 -17
- data/assets/data/mmenu.html +17 -17
- data/assets/data/quicklinks.html +3 -3
- data/assets/data/translator.html +2 -2
- data/assets/themes/j1/adapter/js/cookieConsent.js +4 -3
- data/assets/themes/j1/adapter/js/j1.js +1 -1
- data/assets/themes/j1/adapter/js/translator.js +84 -125
- data/assets/themes/j1/modules/backstretch/js/backstretch.min.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.full.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.js +1 -1
- data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.min.js +1 -1
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +70 -10
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +1 -1
- data/assets/themes/j1/modules/datatables/js/datatables.js +1 -1
- data/assets/themes/j1/modules/datatables/js/datatables.min.js +5 -5
- data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +3 -3
- data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +6 -6
- data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +2 -2
- data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.js +1 -1
- data/assets/themes/j1/modules/iframeResizer/js/client/iframeResizer.contentWindow.min.js +1 -1
- data/assets/themes/j1/modules/iframeResizer/js/resizer.min.js +1 -1
- data/assets/themes/j1/modules/j1Deepl/js/j1deepl.min.js +1 -1
- data/assets/themes/j1/modules/j1Scroll/js/j1scroll.js +1 -1
- data/assets/themes/j1/modules/j1Scroll/js/j1scroll.min.js +1 -1
- data/assets/themes/j1/modules/jquery/js/jquery.js +2 -2
- data/assets/themes/j1/modules/jquery/js/jquery.min.js +1 -1
- data/assets/themes/j1/modules/jquery/js/jqueryUI.js +7 -7
- data/assets/themes/j1/modules/jquery/js/jqueryUI.min.js +3 -3
- data/assets/themes/j1/modules/lightGallery/js/core/j1/lightgallery-x.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/core/lightgallery.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-video.min.js +1 -1
- data/assets/themes/j1/modules/lightGallery/js/modules/j1/j1-x-video.min.js +1 -1
- data/assets/themes/j1/modules/lightbox/js/lightbox.js +1 -1
- data/assets/themes/j1/modules/lightbox/js/lightbox.min.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/mustache.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/mustache.min.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/uri.js +1 -1
- data/assets/themes/j1/modules/lunrSearch/js/uri.min.js +7 -7
- data/assets/themes/j1/modules/mdiPreviewer/js/previewer.min.js +1 -1
- data/assets/themes/j1/modules/mdilPreviewer/js/previewer.min.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.js +1 -1
- data/assets/themes/j1/modules/themeSwitcher/js/switcher.min.js +1 -1
- data/assets/themes/j1/modules/translator/js/translator.js +14 -9
- data/assets/themes/j1/modules/translator/js/translator.min.js +1 -1
- data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.js +1 -1
- data/assets/themes/j1/modules/twemoji/js/picker/twemoji-picker.min.js +1 -1
- data/assets/themes/j1/modules/videojs/js/video.min.js +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/apps/carousel.yml +4 -4
- data/lib/starter_web/_data/blocks/defaults/footer.yml +2 -2
- data/lib/starter_web/_data/blocks/footer.yml +2 -2
- data/lib/starter_web/_data/modules/attics.yml +1 -1
- data/lib/starter_web/_data/modules/cookieconsent.yml +0 -1
- data/lib/starter_web/_data/modules/defaults/attics.yml +2 -2
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +3 -1
- data/lib/starter_web/_data/modules/defaults/translator.yml +2 -1
- data/lib/starter_web/_data/modules/translator.yml +3 -0
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +2 -2
- data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +3 -3
- data/lib/starter_web/pages/public/previewer/preview_bootstrap_theme.adoc +85 -85
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +2 -2
@@ -317,8 +317,10 @@ function Translator(props) {
|
|
317
317
|
} else {
|
318
318
|
// set translation language for auto detection
|
319
319
|
if (self.props.translationLanguage === 'auto') {
|
320
|
-
navigator_language
|
321
|
-
translation_language
|
320
|
+
navigator_language = navigator.language || navigator.userLanguage;
|
321
|
+
translation_language = navigator_language.split('-')[0];
|
322
|
+
} else {
|
323
|
+
translation_language = self.props.translationLanguage;
|
322
324
|
}
|
323
325
|
|
324
326
|
// set translation language for the dropdown
|
@@ -467,16 +469,17 @@ function Translator(props) {
|
|
467
469
|
|
468
470
|
// ---------------------------------------------------------------------------
|
469
471
|
// agreeAll()
|
470
|
-
// process current settings from checkboxes for button
|
472
|
+
// process current settings from checkboxes for button 'agreeAll'
|
473
|
+
// On 'agreeAll', enable ALL settings required for translation
|
471
474
|
// ---------------------------------------------------------------------------
|
472
475
|
function agreeAll() {
|
473
|
-
var
|
474
|
-
var consentSettings
|
476
|
+
var translationSettings = gatherOptions(true);
|
477
|
+
var consentSettings = {};
|
475
478
|
|
476
|
-
settings
|
479
|
+
// enable and write all settings required for translation (consent cookie)
|
477
480
|
consentSettings = JSON.parse(Cookie.get(self.props.cookieConsentName));
|
478
|
-
consentSettings.analysis =
|
479
|
-
consentSettings.personalization =
|
481
|
+
consentSettings.analysis = translationSettings.analysis;
|
482
|
+
consentSettings.personalization = translationSettings.personalization;
|
480
483
|
|
481
484
|
Cookie.set(
|
482
485
|
self.props.cookieConsentName,
|
@@ -485,9 +488,11 @@ function Translator(props) {
|
|
485
488
|
self.props.sameSite,
|
486
489
|
self.props.secure
|
487
490
|
);
|
491
|
+
|
492
|
+
// enable and write all settings required for translation (translation cookie)
|
488
493
|
Cookie.set(
|
489
494
|
self.props.cookieName,
|
490
|
-
JSON.stringify(
|
495
|
+
JSON.stringify(translationSettings),
|
491
496
|
self.props.cookieStorageDays,
|
492
497
|
self.props.sameSite,
|
493
498
|
self.props.secure
|
@@ -12,4 +12,4 @@
|
|
12
12
|
# See: https://github.com/jekyll-one/J1 Template/blob/master/LICENSE
|
13
13
|
# -----------------------------------------------------------------------------
|
14
14
|
*/
|
15
|
-
function Translator(
|
15
|
+
function Translator(o){function e(){var o={},t=!1,n=0,a=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);for(var i=function(n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t&&"[object Object]"===Object.prototype.toString.call(n[a])?o[a]=e(!0,o[a],n[a]):o[a]=n[a])};a>n;n++){var s=arguments[n];i(s)}return o}function t(o,e){for(var t=Array.prototype.slice.call(arguments,2),n=o.split("."),a=n.pop(),i=0;i<n.length;i++)e=e[n[i]];return e[a].apply(e,t)}function n(o){var t,n=e({size:0,width:250,multiple:!1,selectedIndex:1,enableAutoFilter:!1,visibleRows:null},o);t="#"+n.selector,$.ajax({url:n.url,dataType:"json",success:function(o){var e=[];if(u.props.translationLanguages.includes("all"))e=o[n.elm];else for(var a=0;a<o[n.elm].length;a++)u.props.translationLanguages.includes(o[n.elm][a].value)&&e.push(o[n.elm][a]);n.visibleRows>e.length&&(n.visibleRows=e.length),MsDropdown.make(t,{byJson:{data:e,name:n.name,size:n.size,width:n.width,multiple:n.multiple},enableAutoFilter:n.enableAutoFilter,visibleRows:n.visibleRows})},error:function(o,e,t){m.error("\nfailed to retrieve JSON data from: "+n.url)}})}function a(){k.documentReady(function(){if(u.modal=document.getElementById(u.props.dialogContainerID),u.modal)u.$modal.modal("show");else{m.info("\nload consent modal"),u.modal=document.createElement("div"),u.modal.id=u.props.dialogContainerID,u.modal.setAttribute("class","modal fade"),u.modal.setAttribute("tabindex","-1"),u.modal.setAttribute("role","dialog"),u.modal.setAttribute("aria-labelledby",u.props.dialogContainerID),document.body.append(u.modal),u.$modal=$(u.modal),u.$modal.on("show.bs.modal",function(){m.info("\nshow.bs.modal: entered"),$.when(n({url:"/assets/data/iso-639-language-codes-flags.json",elm:"iso-639-languages",selector:"dropdownJSON",width:400,visibleRows:8})).then(function(o){m.info("\ncreating msDropdown from JSON data: finished")})}),u.$modal.on("shown.bs.modal",function(){var o=document.getElementById("dropdownJSON").msDropdown;o.length?("auto"===u.props.translationLanguage?(p=navigator.language||navigator.userLanguage,g=p.split("-")[0]):g=u.props.translationLanguage,o.selectedIndex=$("#dropdownJSON option[value="+g+"]").index(),u.props.disableLanguageSelector&&(o.disabled=!0),$("#dropdownJSON").show(),$("body").addClass("stop-scrolling")):(m.error("\nno msDropdown found in translation dialog"),u.$modal.hide())}),u.$modal.on("hidden.bs.modal",function(){$("body").removeClass("stop-scrolling"),t(u.props.postSelectionCallback,window)});var o=u.props.contentURL+"/index.html";$.get(o).done(function(o){m.info("\nloading consent modal: successfully"),u.modal.innerHTML=o,u.modal.innerHTML=$("#"+u.props.xhrDataElement).eq(0).html(),$(u.modal).modal({backdrop:"static",keyboard:!1}),u.$buttonDoNotAgree=$("#translator-buttonDoNotAgree"),u.$buttonAgree=$("#translator-buttonAgree"),u.$buttonSave=$("#translator-buttonSave"),u.$buttonAgreeAll=$("#translator-buttonAgreeAll"),m.info("\nload/initialze options from cookie"),s(),i(),$("#google-options").on("hide.bs.collapse",function(){b=!1,s()}).on("show.bs.collapse",function(){b=!0,s()}),m.info("\ninitialze button event handler"),u.$buttonDoNotAgree.click(function(){d()}),u.$buttonAgree.click(function(){l()}),u.$buttonSave.click(function(){$("#google-options").collapse("hide"),c(),i()}),u.$buttonAgreeAll.click(function(){$("#google-options").collapse("hide"),l()})}).fail(function(){m.error("\nloading translator dialog (modal): failed"),m.warn("\nprobably no|wrong `contentURL` set")})}}.bind(this))}function i(){var o=u.getSettings();if(o)for(var e in o){var t=u.$modal.find("#google-options .translator-option[data-name="+e+'] input[type="checkbox"]');t.prop("checked",o[e])}}function s(){b?(u.$buttonDoNotAgree.hide(),u.$buttonAgree.hide(),u.$buttonSave.show(),u.$buttonAgreeAll.show()):(u.$buttonDoNotAgree.show(),u.$buttonAgree.show(),u.$buttonSave.hide(),u.$buttonAgreeAll.hide())}function r(o){for(var e=u.$modal.find("#google-options .translator-option"),t={},n=0;n<e.length;n++){var a=e[n],i=a.getAttribute("data-name");if("necessary"===i)t[i]=!0;else if(void 0===o){var s=$(a).find('input[type="checkbox"]');t[i]=s.prop("checked")}else t[i]=!!o}return t}function l(){var o=r(!0),e={};e=JSON.parse(v.get(u.props.cookieConsentName)),e.analysis=o.analysis,e.personalization=o.personalization,v.set(u.props.cookieConsentName,JSON.stringify(e),u.props.cookieStorageDays,u.props.sameSite,u.props.secure),v.set(u.props.cookieName,JSON.stringify(o),u.props.cookieStorageDays,u.props.sameSite,u.props.secure),u.$modal.modal("hide")}function d(){var o=r();o.translationEnabled=!1,v.set(u.props.cookieName,JSON.stringify(o),u.props.cookieStorageDays,u.props.sameSite,u.props.secure),u.$modal.modal("hide")}function c(){var o,e={};o=r(),e=JSON.parse(v.get(u.props.cookieConsentName)),e.analysis=o.analysis,e.personalization=o.personalization,v.set(u.props.cookieConsentName,JSON.stringify(e),u.props.cookieStorageDays,u.props.sameSite,u.props.secure),v.set(u.props.cookieName,JSON.stringify(r()),u.props.cookieStorageDays,u.props.sameSite,u.props.secure),u.$modal.modal("hide")}var p,g,u=this,m=log4javascript.getLogger("j1.core.translator"),h=new liteURL(window.location.href),f=h.protocol.includes("https")?!0:!1,b=!1;this.props={contentURL:"/assets/data/translator",cookieName:"j1.user.state",cookieConsentName:"j1.user.consent",cookieStorageDays:365,cookieSameSite:"Strict",cookieSecure:f,translationEnabled:!1,disableLanguageSelector:!1,translatorName:"google",translationLanguages:"all",translationLanguage:"auto",translateAllPages:!0,hideSuggestionBox:!0,hidePoweredBy:!0,hideTopFrame:!0,dialogLanguage:"content",dialogLanguages:["en","de"],dialogContainerID:"translator-modal",xhrDataElement:"",postSelectionCallback:""};for(var S in o)this.props[S]=o[S];-1!==this.props.dialogLanguage.indexOf("-")&&(this.props.dialogLanguage=this.props.dialogLanguage.split("-")[0]),this.props.dialogLanguages.includes(this.props.dialogLanguage)||(this.props.dialogLanguage=this.props.dialogLanguages[0]),this.props.xhrDataElement=this.props.xhrDataElement+"-"+this.props.dialogLanguage,m.info("\ninitializing core module: started"),m.info("\nstate: started");var v={set:function(o,e,t,n,a){var i=window.btoa(e),s="";if(t){var r=new Date;r.setTime(r.getTime()+24*t*60*60*1e3),s="; expires="+r.toUTCString()}a?document.cookie=o+"="+(i||"")+s+"; Path=/; SameSite="+n+"; secure="+a+";":document.cookie=o+"="+(i||"")+s+"; Path=/; SameSite="+n+";"},get:function(o){for(var e=o+"=",t=document.cookie.split(";"),n=0;n<t.length;n++){for(var a=t[n];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(e)){var i=a.substring(e.length,a.length),s=window.atob(i);return s}}return void 0}},k={documentReady:function(o){"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)}};this.showDialog=function(){a()},this.getSettings=function(o){var e=v.get(u.props.cookieName);if(e){var t=JSON.parse(v.get(u.props.cookieName));return void 0===o?t:t?t[o]:!1}return void 0},m.info("\ninitializing core module finished"),m.info("\nstate: finished")}
|
@@ -96,7 +96,7 @@
|
|
96
96
|
buttonsHTML += '</span>';
|
97
97
|
buttonsHTML += '</div>';
|
98
98
|
|
99
|
-
h.$id = "#" + h.$el["0"].id;
|
99
|
+
h.$id = "#void" + h.$el["0"].id;
|
100
100
|
h.$pickerHeigth = h.options.height.replace("px", "");
|
101
101
|
h.$pickerHeigth = Number(h.$pickerHeigth);
|
102
102
|
h.$wrapper = h.$el.wrap('<div class="twemoji-wrap"></div>').parent();
|
@@ -16,4 +16,4 @@
|
|
16
16
|
# For details, https://github.com/xLs51/Twemoji-Picker
|
17
17
|
# -----------------------------------------------------------------------------
|
18
18
|
*/
|
19
|
-
(function(c,h,a){var k=150;var i={};var e="/assets/data/twa_v1.json";var j;var l;c.TwemojiPicker=function(d,b){var f=this;c.when(this._loadDatabase()).done(function(m){f.$el=c(d);f._init(b)})};c.TwemojiPicker.defaults={init:null,language:"en",size:25,icon:"grinning",iconSize:25,height:100,width:null,category:["smile","cherry-blossom","video-game","oncoming-automobile","symbols"],categorySize:20,pickerPosition:null,pickerHeight:150,pickerWidth:null,placeholder:"Click on Picker to select Emoji's from a Category",};c.TwemojiPicker.prototype={_init:function(b){this.options=c.extend(true,{},c.TwemojiPicker.defaults,b);this._initPicker();this._initCategory();this._initTwemoji();this._initText();this._initStyle();this._initEvents()},_loadDatabase:function g(){return c.ajax({url:e,success:function(b){if(typeof b=="string"){i=JSON.parse(b)}if(typeof b=="object"){i=b}}})},_initPicker:function(){var f=this;var b;var d;if(f.options.language=="en"){b="Clear";j="Copied to Clipboard";l=f.options.placeholder}else{if(f.options.language=="de"){b="Löschen";j="Kopiert zur Zwischenablage";l="Klicken Sie auf Picker zur Auswahl von Emoji's aus einer Kategorie"}else{b="Clear";j="in Clipboard";l=f.options.placeholder}}d='<div class="twemoji-icon-picker">';d+='<span id="open-group" class="mr-2" style="width: 2rem; height: 2rem;">';d+='<button type="button" name="open-group" class="btn btn-raised btn-flex btn-primary mr-2"><i class="toggle-button mdi mdi-lg mr-1 mdi-toggle-switch-off"></i> Picker </button>';d+="</span>";d+='<span id="clear-textarea" style="width: 2rem; height: 2rem;">';d+='<button type="button" name="clear-textarea" class="btn btn-raised btn-flex btn-primary"><i class="mdi mdi-close mdi-lg mr-1"></i>'+b+"</button>";d+="</span>";d+="</div>";f.$id="#"+f.$el["0"].id;f.$pickerHeigth=f.options.height.replace("px","");f.$pickerHeigth=Number(f.$pickerHeigth);f.$wrapper=f.$el.wrap('<div class="twemoji-wrap"></div>').parent();f.$wrapper.append('<div class="twemoji-textarea" contentEditable="true" placeholder="'+l+'"></div>');f.$wrapper.append('<div class="twemoji-textarea-duplicate"></div>');f.$wrapper.append(d);f.$wrapper.append('<div class="twemoji-picker"></div>');f.$el.hide();f.$textarea=f.$wrapper.find(".twemoji-textarea");f.$textareaDuplicate=f.$wrapper.find(".twemoji-textarea-duplicate").hide();f.$iconPicker=f.$wrapper.find("#open-group");f.$clearTextarea=f.$wrapper.find("#clear-textarea");f.$picker=f.$wrapper.find(".twemoji-picker").hide()},_initCategory:function(){var d=this;var b=this.options.category;this.categoryName=["people","nature","object","place","symbol"];this.$picker.append('<div class="twemoji-picker-category"></div>');this.$pickerCategory=this.$picker.find(".twemoji-picker-category");c.each(this.categoryName,function(m,f){d.$pickerCategory.append('<span data-category="'+f+'">'+d.imageFromName(b[m])+"</span>")});this.$pickerCategory.find("span:first").addClass("active")},_initTwemoji:function(){var b=this;c.each(this.categoryName,function(f,d){b.$picker.append('<div class="twemoji-list '+d+'"></div>');c.each(i,function(n,m){if(m.category===d){b.$wrapper.find(".twemoji-picker ."+d).append('<span><img class="emoji" draggable="false" src="'+m.base64+'" alt="'+m.value+'" title="'+m.name+'"></span>')}})});this.$twemojiList=this.$picker.find(".twemoji-list");this.$twemojiList.not(":first").hide()},_initText:function(){if(this.options.init){var b=this.options.init;var d=/:([\w-]+):/g;var f;while(f==d.exec(b)){b=b.replace(f[0],this.imageFromName(f[1],true))}this.$textarea.html(b);this.copyTextArea(this.$textarea.html())}},_initStyle:function(){this.$wrapper.css({width:this.options.width?this.options.width:"100%",height:this.options.height?this.options.height:"",});this.$wrapper.find("img").css({width:this.options.size,height:this.options.size,});this.$iconPicker.css({width:this.options.iconSize,height:this.options.iconSize,});this.$pickerCategory.find("img").css({width:this.options.categorySize,height:this.options.categorySize,});this.$twemojiList.css({width:this.options.pickerWidth?this.options.pickerWidth:"100%",height:this.options.pickerHeight,});this.$picker.css({width:this.options.pickerWidth?this.options.pickerWidth:"100%",top:this.options.pickerPosition==="top"?"-"+this.$picker.outerHeight()+"px":"",})},_initEvents:function(){var b=this;this.$textarea.on("keyup",function(){b.copyTextArea(c(this).html())});this.$iconPicker.on("click",function(){var d=c(".twemoji-picker").height()+k;c("#picker").height(d);c(".toggle-button").toggleClass("mdi-toggle-switch-off mdi-toggle-switch");if(!b.openedPicker){b.openPicker()}else{b.closePicker();c("#picker").height(b.$pickerHeigth)}});this.$clearTextarea.on("click",function(){b.copyTextArea("");c(b.$id).val("");c(".twemoji-textarea > .emoji-span").remove()});this.$pickerCategory.find("span").on("click",function(){var d=c(this).data("category");b.openCategory(c(this),d)});this.$pickerCategory.find(".close").on("click",function(){if(b.openedPicker){b.closePicker()}});this.$twemojiList.find("img").on("click",function(){b.copyTwemoji(c(this))})},copyText:function(f){var d=document.createElement("textarea");d.setAttribute("style","position:fixed;opacity:0;top:100px;left:100px;");d.value=f;document.body.appendChild(d);d.select();document.execCommand("copy");var b=document.createElement("div");b.setAttribute("class","copied");b.appendChild(document.createTextNode(j));document.body.appendChild(b);setTimeout(function(){document.body.removeChild(d);document.body.removeChild(b)},1500)},openPicker:function(){this.$picker.show();this.openedPicker=true},closePicker:function(){this.$picker.hide();this.openedPicker=false},openCategory:function(d,b){this.$pickerCategory.find("span").removeClass("active");d.addClass("active");this.$twemojiList.not(".twemoji-picker ."+b).hide();this.$twemojiList.filter(".twemoji-picker ."+b).show()},copyTwemoji:function(b){var m=b.attr("alt");var d=b.attr("src");var f=b.attr("title");var n="emoji:"+f+"[]";this.copyText(n);this.$textarea.focus();this.pasteAtCursor('<span class="emoji-span"><img class="emoji" src="'+d+'" title="'+f+'" alt="'+m+'" width="'+this.options.size+'" height="'+this.options.size+'"> '+n+"</span> ");this.copyTextArea(this.$textarea.html())},copyTextArea:function(b){var f=this.$textareaDuplicate.html(b);f.find("img").replaceWith(function(){return this.alt});var d=f.html();this.$el.text(d)},imageFromName:function(d,b){var f=c.grep(i,function(m){return m.name==d});if(b){return'<img class="emoji" src="'+f[0].base64+'" alt="'+f[0].value+'" width="'+this.options.size+'" height="'+this.options.size+'">'}return'<img class="emoji" draggable="false" src="'+f[0].base64+'" alt="'+d+'">'},pasteAtCursor:function(b){var d,q;if(h.getSelection){d=h.getSelection();if(d.getRangeAt&&d.rangeCount){q=d.getRangeAt(0);q.deleteContents();var p=document.createElement("div");p.innerHTML=b;var r=document.createDocumentFragment(),f,o;while((f=p.firstChild)){o=r.appendChild(f)}q.insertNode(r);if(o){q=q.cloneRange();q.setStartAfter(o);q.collapse(true);d.removeAllRanges();d.addRange(q)}}}else{if(document.selection&&document.selection.type!="Control"){document.selection.createRange().pasteHTML(b)}}}};c.fn.twemojiPicker=function(b){var d=c.data(this,"twemojiPicker");this.each(function(){d?d._init():d=c.data(this,"twemojiPicker",new c.TwemojiPicker(this,b))});return d}})(jQuery,window);
|
19
|
+
(function(c,h,a){var k=150;var i={};var e="/assets/data/twa_v1.json";var j;var l;c.TwemojiPicker=function(d,b){var f=this;c.when(this._loadDatabase()).done(function(m){f.$el=c(d);f._init(b)})};c.TwemojiPicker.defaults={init:null,language:"en",size:25,icon:"grinning",iconSize:25,height:100,width:null,category:["smile","cherry-blossom","video-game","oncoming-automobile","symbols"],categorySize:20,pickerPosition:null,pickerHeight:150,pickerWidth:null,placeholder:"Click on Picker to select Emoji's from a Category",};c.TwemojiPicker.prototype={_init:function(b){this.options=c.extend(true,{},c.TwemojiPicker.defaults,b);this._initPicker();this._initCategory();this._initTwemoji();this._initText();this._initStyle();this._initEvents()},_loadDatabase:function g(){return c.ajax({url:e,success:function(b){if(typeof b=="string"){i=JSON.parse(b)}if(typeof b=="object"){i=b}}})},_initPicker:function(){var f=this;var b;var d;if(f.options.language=="en"){b="Clear";j="Copied to Clipboard";l=f.options.placeholder}else{if(f.options.language=="de"){b="Löschen";j="Kopiert zur Zwischenablage";l="Klicken Sie auf Picker zur Auswahl von Emoji's aus einer Kategorie"}else{b="Clear";j="in Clipboard";l=f.options.placeholder}}d='<div class="twemoji-icon-picker">';d+='<span id="open-group" class="mr-2" style="width: 2rem; height: 2rem;">';d+='<button type="button" name="open-group" class="btn btn-raised btn-flex btn-primary mr-2"><i class="toggle-button mdi mdi-lg mr-1 mdi-toggle-switch-off"></i> Picker </button>';d+="</span>";d+='<span id="clear-textarea" style="width: 2rem; height: 2rem;">';d+='<button type="button" name="clear-textarea" class="btn btn-raised btn-flex btn-primary"><i class="mdi mdi-close mdi-lg mr-1"></i>'+b+"</button>";d+="</span>";d+="</div>";f.$id="#void"+f.$el["0"].id;f.$pickerHeigth=f.options.height.replace("px","");f.$pickerHeigth=Number(f.$pickerHeigth);f.$wrapper=f.$el.wrap('<div class="twemoji-wrap"></div>').parent();f.$wrapper.append('<div class="twemoji-textarea" contentEditable="true" placeholder="'+l+'"></div>');f.$wrapper.append('<div class="twemoji-textarea-duplicate"></div>');f.$wrapper.append(d);f.$wrapper.append('<div class="twemoji-picker"></div>');f.$el.hide();f.$textarea=f.$wrapper.find(".twemoji-textarea");f.$textareaDuplicate=f.$wrapper.find(".twemoji-textarea-duplicate").hide();f.$iconPicker=f.$wrapper.find("#open-group");f.$clearTextarea=f.$wrapper.find("#clear-textarea");f.$picker=f.$wrapper.find(".twemoji-picker").hide()},_initCategory:function(){var d=this;var b=this.options.category;this.categoryName=["people","nature","object","place","symbol"];this.$picker.append('<div class="twemoji-picker-category"></div>');this.$pickerCategory=this.$picker.find(".twemoji-picker-category");c.each(this.categoryName,function(m,f){d.$pickerCategory.append('<span data-category="'+f+'">'+d.imageFromName(b[m])+"</span>")});this.$pickerCategory.find("span:first").addClass("active")},_initTwemoji:function(){var b=this;c.each(this.categoryName,function(f,d){b.$picker.append('<div class="twemoji-list '+d+'"></div>');c.each(i,function(n,m){if(m.category===d){b.$wrapper.find(".twemoji-picker ."+d).append('<span><img class="emoji" draggable="false" src="'+m.base64+'" alt="'+m.value+'" title="'+m.name+'"></span>')}})});this.$twemojiList=this.$picker.find(".twemoji-list");this.$twemojiList.not(":first").hide()},_initText:function(){if(this.options.init){var b=this.options.init;var d=/:([\w-]+):/g;var f;while(f==d.exec(b)){b=b.replace(f[0],this.imageFromName(f[1],true))}this.$textarea.html(b);this.copyTextArea(this.$textarea.html())}},_initStyle:function(){this.$wrapper.css({width:this.options.width?this.options.width:"100%",height:this.options.height?this.options.height:"",});this.$wrapper.find("img").css({width:this.options.size,height:this.options.size,});this.$iconPicker.css({width:this.options.iconSize,height:this.options.iconSize,});this.$pickerCategory.find("img").css({width:this.options.categorySize,height:this.options.categorySize,});this.$twemojiList.css({width:this.options.pickerWidth?this.options.pickerWidth:"100%",height:this.options.pickerHeight,});this.$picker.css({width:this.options.pickerWidth?this.options.pickerWidth:"100%",top:this.options.pickerPosition==="top"?"-"+this.$picker.outerHeight()+"px":"",})},_initEvents:function(){var b=this;this.$textarea.on("keyup",function(){b.copyTextArea(c(this).html())});this.$iconPicker.on("click",function(){var d=c(".twemoji-picker").height()+k;c("#picker").height(d);c(".toggle-button").toggleClass("mdi-toggle-switch-off mdi-toggle-switch");if(!b.openedPicker){b.openPicker()}else{b.closePicker();c("#picker").height(b.$pickerHeigth)}});this.$clearTextarea.on("click",function(){b.copyTextArea("");c(b.$id).val("");c(".twemoji-textarea > .emoji-span").remove()});this.$pickerCategory.find("span").on("click",function(){var d=c(this).data("category");b.openCategory(c(this),d)});this.$pickerCategory.find(".close").on("click",function(){if(b.openedPicker){b.closePicker()}});this.$twemojiList.find("img").on("click",function(){b.copyTwemoji(c(this))})},copyText:function(f){var d=document.createElement("textarea");d.setAttribute("style","position:fixed;opacity:0;top:100px;left:100px;");d.value=f;document.body.appendChild(d);d.select();document.execCommand("copy");var b=document.createElement("div");b.setAttribute("class","copied");b.appendChild(document.createTextNode(j));document.body.appendChild(b);setTimeout(function(){document.body.removeChild(d);document.body.removeChild(b)},1500)},openPicker:function(){this.$picker.show();this.openedPicker=true},closePicker:function(){this.$picker.hide();this.openedPicker=false},openCategory:function(d,b){this.$pickerCategory.find("span").removeClass("active");d.addClass("active");this.$twemojiList.not(".twemoji-picker ."+b).hide();this.$twemojiList.filter(".twemoji-picker ."+b).show()},copyTwemoji:function(b){var m=b.attr("alt");var d=b.attr("src");var f=b.attr("title");var n="emoji:"+f+"[]";this.copyText(n);this.$textarea.focus();this.pasteAtCursor('<span class="emoji-span"><img class="emoji" src="'+d+'" title="'+f+'" alt="'+m+'" width="'+this.options.size+'" height="'+this.options.size+'"> '+n+"</span> ");this.copyTextArea(this.$textarea.html())},copyTextArea:function(b){var f=this.$textareaDuplicate.html(b);f.find("img").replaceWith(function(){return this.alt});var d=f.html();this.$el.text(d)},imageFromName:function(d,b){var f=c.grep(i,function(m){return m.name==d});if(b){return'<img class="emoji" src="'+f[0].base64+'" alt="'+f[0].value+'" width="'+this.options.size+'" height="'+this.options.size+'">'}return'<img class="emoji" draggable="false" src="'+f[0].base64+'" alt="'+d+'">'},pasteAtCursor:function(b){var d,q;if(h.getSelection){d=h.getSelection();if(d.getRangeAt&&d.rangeCount){q=d.getRangeAt(0);q.deleteContents();var p=document.createElement("div");p.innerHTML=b;var r=document.createDocumentFragment(),f,o;while((f=p.firstChild)){o=r.appendChild(f)}q.insertNode(r);if(o){q=q.cloneRange();q.setStartAfter(o);q.collapse(true);d.removeAllRanges();d.addRange(q)}}}else{if(document.selection&&document.selection.type!="Control"){document.selection.createRange().pasteHTML(b)}}}};c.fn.twemojiPicker=function(b){var d=c.data(this,"twemojiPicker");this.each(function(){d?d._init():d=c.data(this,"twemojiPicker",new c.TwemojiPicker(this,b))});return d}})(jQuery,window);
|