From febbb3ffdb27416a7e40fa2280fc78ddd02f6e3f Mon Sep 17 00:00:00 2001 From: Peter Elmers Date: Wed, 3 Jun 2015 22:14:56 -0700 Subject: [PATCH 1/3] Re-implement click to join functionality. Clicking channel names to join broke because of angular issue 9515. Reimplement the functionality by binding the scope.openBuffer method to the window and calling it from an onclick handler for channel name anchors. --- js/filters.js | 10 +++++----- js/glowingbear.js | 5 +++++ test/unit/filters.js | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/js/filters.js b/js/filters.js index 0b7abc5..71ecee9 100644 --- a/js/filters.js +++ b/js/filters.js @@ -24,7 +24,7 @@ weechat.filter('toArray', function () { }; }); -weechat.filter('irclinky', ['$filter', function($filter) { +weechat.filter('irclinky', function() { return function(text) { if (!text) { return text; @@ -36,12 +36,12 @@ weechat.filter('irclinky', ['$filter', function($filter) { // "#1" is much more likely to be "number 1" than "IRC channel #1". // Thus, we only match channels beginning with a # and having at least one letter in them. var channelRegex = /(^|[\s,.:;?!"'()+@-\~%])(#+[^\x00\x07\r\n\s,:]*[a-z][^\x00\x07\r\n\s,:]*)/gmi; - // This is SUPER nasty, but ng-click does not work inside a filter, as the markup has to be $compiled first, which is not possible in filter afaik. - // Therefore, get the scope, fire the method, and $apply. Yuck. I sincerely hope someone finds a better way of doing this. - var substitute = '$1$2'; + // Call the method we bound to window.openBuffer when we instantiated + // the Weechat controller. + var substitute = '$1$2'; return text.replace(channelRegex, substitute); }; -}]); +}); weechat.filter('inlinecolour', function() { return function(text) { diff --git a/js/glowingbear.js b/js/glowingbear.js index 8e2d642..55ac297 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -15,6 +15,11 @@ weechat.config(['$compileProvider', function ($compileProvider) { weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout', '$log', 'models', 'connection', 'notifications', 'utils', 'settings', function ($rootScope, $scope, $store, $timeout, $log, models, connection, notifications, utils, settings) { + window.openBuffer = function(channel) { + $scope.openBuffer(channel); + $scope.$apply(); + }; + $scope.command = ''; $scope.themes = ['dark', 'light']; diff --git a/test/unit/filters.js b/test/unit/filters.js index c8ea29e..ca1228e 100644 --- a/test/unit/filters.js +++ b/test/unit/filters.js @@ -16,11 +16,11 @@ describe('Filters', function() { })); it('should linkify IRC channels', inject(function(irclinkyFilter) { - expect(irclinkyFilter('#foo')).toEqual('#foo'); + expect(irclinkyFilter('#foo')).toEqual('#foo'); })); it('should not mess up IRC channels surrounded by HTML entities', inject(function(irclinkyFilter) { - expect(irclinkyFilter('<"#foo">')).toEqual('<"\'); $scope.$apply();">#foo">'); + expect(irclinkyFilter('<"#foo">')).toEqual('<"\');">#foo">'); })); }); From e096284502b822849f0ba27a9c69c5fd15930c4a Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Fri, 12 Jun 2015 11:10:48 +0200 Subject: [PATCH 2/3] Check modifier state and don't trigger on any altgr event --- js/inputbar.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/inputbar.js b/js/inputbar.js index 8553c07..37cc7d1 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -179,6 +179,14 @@ weechat.directive('inputBar', function() { // Support different browser quirks var code = $event.keyCode ? $event.keyCode : $event.charCode; + var altg = $event.getModifierState('AltGraph'); + + // Mac OSX behaves differntly for altgr, so we check for that + if (altg) { + // We don't handle any anything with altgr + return false; + } + // reset quick keys display $rootScope.showQuickKeys = false; From c7a5d8decf38938124752e109a31c6bfaff2db00 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sat, 13 Jun 2015 16:54:59 -0700 Subject: [PATCH 3/3] Added a check for DOM 3 getModifierState before attempting to use it, as some browsers may not have implemented that spec yet (Like stable Safari) --- js/inputbar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/inputbar.js b/js/inputbar.js index 37cc7d1..6fc4067 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -179,7 +179,8 @@ weechat.directive('inputBar', function() { // Support different browser quirks var code = $event.keyCode ? $event.keyCode : $event.charCode; - var altg = $event.getModifierState('AltGraph'); + // Safari doesn't implement DOM 3 input events yet as of 8.0.6 + var altg = $event.getModifierState ? $event.getModifierState('AltGraph') : false; // Mac OSX behaves differntly for altgr, so we check for that if (altg) {