From f042f729e1b9f4e9a998ca924c332632e5391711 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 21 Mar 2015 16:43:46 +0100 Subject: [PATCH 1/2] switch from twitter's emoji lib to emojione --- css/glowingbear.css | 19 +++++++++++++------ js/filters.js | 4 ++-- js/glowingbear.js | 6 +++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index bda2406..4b764ef 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -539,12 +539,19 @@ li.buffer.indent.private a { user-select: none; } -/* Scales emoji to font size */ -img.emoji { - height: 1em; - width: 1em; - margin: 0 .05em 0 .1em; - vertical-align: -0.1em; +.emojione { + font-size: inherit; + height: 3ex; + width: 3.1ex; + min-height: 20px; + min-width: 20px; + display: inline-block; + margin: -.2ex .15em .2ex; + line-height: normal; + vertical-align: middle; +} +img.emojione { + width: auto; } @media (min-width: 1400px) { diff --git a/js/filters.js b/js/filters.js index 9317af4..0e1246d 100644 --- a/js/filters.js +++ b/js/filters.js @@ -141,11 +141,11 @@ weechat.filter('getBufferQuickKeys', function () { }; }); -// Emojifis the string using https://github.com/twitter/twemoji +// Emojifis the string using https://github.com/Ranks/emojione weechat.filter('emojify', function() { return function(text, enable_JS_Emoji) { if (enable_JS_Emoji === true) { - return twemoji.parse(text); + return emojione.unicodeToImage(text); } else { return(text); } diff --git a/js/glowingbear.js b/js/glowingbear.js index 83be41b..210900e 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -385,17 +385,17 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }); - // To reduce loading times for users who don't want twemoji, + // To reduce loading times for users who don't want emojione, // load it only if the setting is enabled. // This also fires when the page is loaded. settings.addCallback('enableJSEmoji', function(enabled) { if (enabled && !$rootScope.twemoji_init) { - // Load twemoji only once + // Load script only once $rootScope.twemoji_init = true; (function() { var script = document.createElement("script"); script.type = "text/javascript"; - script.src = "//twemoji.maxcdn.com/twemoji.min.js"; + script.src = "//cdn.jsdelivr.net/emojione/1.3.0/lib/js/emojione.min.js"; document.getElementsByTagName("head")[0].appendChild(script); })(); } From 99ccd551b6183e9e4fa178ca168ddf12c9aaaa5e Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 21 Mar 2015 17:23:05 +0100 Subject: [PATCH 2/2] Enable by default, except on mobile. Convert by default. --- css/glowingbear.css | 8 ++++---- directives/input.html | 2 +- index.html | 1 + js/glowingbear.js | 18 +----------------- js/inputbar.js | 5 +++++ 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 4b764ef..f90c001 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -541,10 +541,10 @@ li.buffer.indent.private a { .emojione { font-size: inherit; - height: 3ex; - width: 3.1ex; - min-height: 20px; - min-width: 20px; + height: 1em; + width: 1.1em; + min-height: 16px; + min-width: 16px; display: inline-block; margin: -.2ex .15em .2ex; line-height: normal; diff --git a/directives/input.html b/directives/input.html index e373298..afcf580 100644 --- a/directives/input.html +++ b/directives/input.html @@ -1,6 +1,6 @@
- diff --git a/index.html b/index.html index 03aa1f2..b9ce305 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@ + diff --git a/js/glowingbear.js b/js/glowingbear.js index 210900e..2d1e3f8 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -36,7 +36,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', 'fontsize': '14px', 'fontfamily': (utils.isMobileUi() ? 'sans-serif' : 'Inconsolata, Consolas, Monaco, Ubuntu Mono, monospace'), 'readlineBindings': false, - 'enableJSEmoji': false, + 'enableJSEmoji': (utils.isMobileUi() ? false : true), 'enableMathjax': false, }); $scope.settings = settings; @@ -385,22 +385,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', } }); - // To reduce loading times for users who don't want emojione, - // load it only if the setting is enabled. - // This also fires when the page is loaded. - settings.addCallback('enableJSEmoji', function(enabled) { - if (enabled && !$rootScope.twemoji_init) { - // Load script only once - $rootScope.twemoji_init = true; - (function() { - var script = document.createElement("script"); - script.type = "text/javascript"; - script.src = "//cdn.jsdelivr.net/emojione/1.3.0/lib/js/emojione.min.js"; - document.getElementsByTagName("head")[0].appendChild(script); - })(); - } - }); - // To prevent unnecessary loading times for users who don't // want MathJax, load it only if the setting is enabled. // This also fires when the page is loaded if enabled. diff --git a/js/inputbar.js b/js/inputbar.js index ab4394a..6f6daf0 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -23,6 +23,11 @@ weechat.directive('inputBar', function() { IrcUtils, settings) { + // E.g. Turn :smile: into the unicode equivalent + $scope.inputChanged = function() { + $scope.command = emojione.shortnameToUnicode($scope.command); + }; + /* * Returns the input element */