diff --git a/README.md b/README.md index 66f082f7..3c971daf 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ These are the commands currently implemented: - `/mode` - `/msg` - `/nick` +- `/notice` - `/op` - `/part` - `/query` diff --git a/client/index.html b/client/index.html index 122c6503..41af48da 100644 --- a/client/index.html +++ b/client/index.html @@ -17,7 +17,6 @@
-
diff --git a/client/js/chat.js b/client/js/chat.js index de163b98..6d56cf36 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -13,6 +13,7 @@ $(function() { "/mode", "/msg", "/nick", + "/notice", "/op", "/part", "/query", diff --git a/client/js/jquery.plugins.js b/client/js/jquery.plugins.js index 87ec3ae3..529eb4a6 100644 --- a/client/js/jquery.plugins.js +++ b/client/js/jquery.plugins.js @@ -71,17 +71,17 @@ * Copyright (c) 2014 Mattias Erming * Licensed under the MIT License. * - * Version 1.1.0 + * Version 1.2.0 */ (function($) { $.fn.scrollGlue = function(options) { var settings = $.extend({ disableManualScroll: false, - overflow: "scroll", + overflow: 'scroll', scrollToBottom: true, speed: 0 }, options); - + var self = this; if (self.size() > 1) { return self.each(function() { @@ -89,50 +89,62 @@ }); } - self.css("overflow-y", settings.overflow); + self.css('overflow-y', settings.overflow); if (settings.scrollToBottom) { self.scrollToBottom(); } - + + var timer; + var resizing = false; $(window).on('resize', function() { self.finish(); + + // This will prevent the scroll event from triggering + // while resizing the browser. + resizing = true; + + clearTimeout(timer); + timer = setTimeout(function() { + resizing = false; + }, 100); + + if (sticky) { + self.scrollToBottom(); + } }); - + var sticky = true; self.on('scroll', function() { if (settings.disableManualScroll) { self.scrollToBottom(); - } else { + } else if (!resizing) { sticky = self.isScrollAtBottom(); } }); self.trigger('scroll'); - self.on('append', function() { + self.on('prepend append', function() { if (sticky) { self.scrollToBottom(settings.speed); } }); - + return this; }; - - var prepend = $.fn.prepend; - $.fn.prepend = function() { - return prepend.apply(this, arguments).trigger('append'); - }; - var append = $.fn.append; - $.fn.append = function() { - return append.apply(this, arguments).trigger('append'); - }; - - var html = $.fn.html; - $.fn.html = function(string) { - var result = html.apply(this, arguments); - if (typeof string !== 'undefined') { - this.trigger('append'); + // Normally, these functions won't trigger any events. + // Lets override them. + var events = ['prepend', 'append']; + $.each(events, function(i, e) { + var fn = $.fn[e]; + $.fn[e] = function() { + return fn.apply(this, arguments).trigger(e); + }; + }); + + $.fn.isScrollAtBottom = function() { + if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop('scrollHeight')) { + return true; } - return result; }; $.fn.scrollToBottom = function(speed) { @@ -140,12 +152,6 @@ $(this).finish().animate({scrollTop: this.scrollHeight}, speed || 0); }); }; - - $.fn.isScrollAtBottom = function() { - if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop('scrollHeight')) { - return true; - } - }; })(jQuery); /*! diff --git a/lib/server.js b/lib/server.js index 724bcf1c..27ee5eff 100644 --- a/lib/server.js +++ b/lib/server.js @@ -152,6 +152,12 @@ function input(data) { } break; + case "notice": + if (client && args[2]) { + client.notice(args[1], args.slice(2).join(" ")); + } + break; + case "server": case "connect": if (args[1]) {