From b730e605825dcfb2dad87008e608844b02800c65 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Mon, 28 Apr 2014 20:05:19 +0200 Subject: [PATCH] Added tab completion for users --- client/js/chat.js | 21 ++++++++++++++------- client/js/jquery.plugins.js | 23 +++++++++++++---------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/client/js/chat.js b/client/js/chat.js index eae5a7d1..a81268e8 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -44,13 +44,14 @@ $(function() { } function event(e, data) { + console.log(arguments); switch (e) { case "join": chat.append(render("#windows", {windows: [data.chan]})) .find(".window") .last() .find(".input") - .tabComplete({after: " ", list: commands}) + .tabComplete({list: commands}) .inputHistory({submit: true}) .end() .bringToTop() @@ -81,15 +82,15 @@ $(function() { .bringToTop() .end() .find(".input") - .tabComplete({after: " ", list: commands}) + .tabComplete({list: commands}) .inputHistory({submit: true}) .end() + .find(".messages") + .scrollGlue({speed: 400}) + .end() .find(".hidden") .prev(".show-more") - .show() - .parent() - .scrollGlue({speed: 400}) - .end(); + .show(); sidebar.html(render("#networks", {networks: data.networks})) .find(".channel") @@ -109,9 +110,15 @@ $(function() { break; case "users": + var users = $.map(data.users, function(u) { return u.name; }); + var tabComplete = commands.concat(users); $("#window-" + data.id) + .find(".input") + .data("list", tabComplete) + .end() .find(".users") - .html(render("#users", {users: data.users})); + .html(render("#users", {users: data.users})) + .end(); break; } } diff --git a/client/js/jquery.plugins.js b/client/js/jquery.plugins.js index ee7ff505..7b7df248 100644 --- a/client/js/jquery.plugins.js +++ b/client/js/jquery.plugins.js @@ -29,7 +29,7 @@ * Copyright (c) 2014 Mattias Erming * Licensed under the MIT License. * - * Version 0.1.1 + * Version 0.1.2 */ (function($) { $.fn.inputHistory = function(options) { @@ -95,13 +95,15 @@ * Copyright (c) 2014 Mattias Erming * Licensed under the MIT License. * - * Version 0.2.2 + * Version 1.1.0 */ (function($) { $.fn.scrollGlue = function(options) { var settings = $.extend({ - speed: 0, + disableManualScroll: false, + overflow: "scroll", scrollToBottom: true, + speed: 0 }, options); var self = this; @@ -111,6 +113,7 @@ }); } + self.css("overflow-y", settings.overflow); if (settings.scrollToBottom) { self.scrollToBottom(); } @@ -119,9 +122,13 @@ self.finish(); }); - var sticky = false; + var sticky = true; self.on('scroll', function() { - sticky = self.isScrollAtBottom(); + if (settings.disableManualScroll) { + self.scrollToBottom(); + } else { + sticky = self.isScrollAtBottom(); + } }); self.trigger('scroll'); self.on('append', function() { @@ -133,8 +140,6 @@ return this; }; - // Overrides - var prepend = $.fn.prepend; $.fn.prepend = function() { return prepend.apply(this, arguments).trigger('append'); @@ -154,8 +159,6 @@ return result; }; - // Utils - $.fn.scrollToBottom = function(speed) { return this.each(function() { $(this).finish().animate({scrollTop: this.scrollHeight}, speed || 0); @@ -176,7 +179,7 @@ * Copyright (c) 2014 Mattias Erming * Licensed under the MIT License. * - * Version 0.2.2 + * Version 0.2.3 */ (function($) { $.fn.tabComplete = function(options) {