From 421f585d233ef741db543925ff665b7281761288 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Mon, 14 Apr 2014 01:49:22 +0200 Subject: [PATCH] Moved js libraries to submodules --- .gitmodules | 9 +++ client/index.html | 5 +- client/js/chat.js | 4 +- client/js/lib/jquery-input-history | 1 + client/js/lib/jquery-scroll-glue | 1 + client/js/lib/jquery-tab-complete | 1 + client/js/lib/jquery.scrollGlue.js | 90 ----------------------------- client/js/lib/jquery.tabComplete.js | 66 --------------------- 8 files changed, 17 insertions(+), 160 deletions(-) create mode 160000 client/js/lib/jquery-input-history create mode 160000 client/js/lib/jquery-scroll-glue create mode 160000 client/js/lib/jquery-tab-complete delete mode 100644 client/js/lib/jquery.scrollGlue.js delete mode 100644 client/js/lib/jquery.tabComplete.js diff --git a/.gitmodules b/.gitmodules index c40ff071..47824dd9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,12 @@ [submodule "node_modules/slate-irc"] path = node_modules/slate-irc url = http://github.com/erming/slate-irc +[submodule "client/js/lib/jquery-scroll-glue"] + path = client/js/lib/jquery-scroll-glue + url = http://github.com/erming/jquery-scroll-glue +[submodule "client/js/lib/jquery-input-history"] + path = client/js/lib/jquery-input-history + url = http://github.com/erming/jquery-input-history +[submodule "client/js/lib/jquery-tab-complete"] + path = client/js/lib/jquery-tab-complete + url = http://github.com/erming/jquery-tab-complete diff --git a/client/index.html b/client/index.html index 6fc55e80..bc7ae387 100644 --- a/client/index.html +++ b/client/index.html @@ -121,8 +121,9 @@ - - + + + diff --git a/client/js/chat.js b/client/js/chat.js index 55f7e393..f09542a2 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -72,7 +72,7 @@ $(function() { .end(); chat.find(".window") .find("input") - .tabComplete(commands, {appendSpace: true}) + .tabComplete({after: " ", list: commands}) .end() .first() .bringToTop() @@ -99,7 +99,7 @@ $(function() { ).find(".window") .last() .find("input") - .tabComplete(commands, {appendSpace: true}) + .tabComplete({after: " ", list: commands}) .end() .bringToTop() .find(".messages") diff --git a/client/js/lib/jquery-input-history b/client/js/lib/jquery-input-history new file mode 160000 index 00000000..574732d8 --- /dev/null +++ b/client/js/lib/jquery-input-history @@ -0,0 +1 @@ +Subproject commit 574732d84a70abce4dc6e93a88cbe167129fb84f diff --git a/client/js/lib/jquery-scroll-glue b/client/js/lib/jquery-scroll-glue new file mode 160000 index 00000000..e5178ce2 --- /dev/null +++ b/client/js/lib/jquery-scroll-glue @@ -0,0 +1 @@ +Subproject commit e5178ce29594a11c3fdb453de35a167f0a49619b diff --git a/client/js/lib/jquery-tab-complete b/client/js/lib/jquery-tab-complete new file mode 160000 index 00000000..461258f8 --- /dev/null +++ b/client/js/lib/jquery-tab-complete @@ -0,0 +1 @@ +Subproject commit 461258f880c0cd1dd3d8dbb7924a6d5044bae664 diff --git a/client/js/lib/jquery.scrollGlue.js b/client/js/lib/jquery.scrollGlue.js deleted file mode 100644 index d868284d..00000000 --- a/client/js/lib/jquery.scrollGlue.js +++ /dev/null @@ -1,90 +0,0 @@ -/*! - * jquery-scroll-glue - * https://github.com/erming/jquery-scroll-glue - * - * Copyright (c) 2014 Mattias Erming - * Licensed under the MIT License. - * - * Version 0.1.1 - */ - -(function($) { - var append = $.fn.append; - $.fn.append = function() { - return append.apply(this, arguments).trigger("append"); - }; - - var html = $.fn.html; - $.fn.html = function() { - var result = html.apply(this, arguments); - if (arguments.length) { - // Only trigger this event when something - // has been inserted. - this.trigger("html"); - } - return result; - }; - - $.fn.scrollGlue = function(options) { - var settings = $.extend({ - animate: 0 - }, options); - - var self = this; - if (self.size() > 1) { - return self.each(function() { - $(this).scrollGlue(options); - }); - } - - var timer; - var resizing = false; - $(window).on("resize", function() { - // This will prevent the scroll event from triggering - // while resizing the window. - resizing = true; - - clearTimeout(timer); - timer = setTimeout(function() { - resizing = false; - }, 100); - - if (sticky) { - self.scrollToBottom(); - } - }); - - var sticky = false; - self.on("scroll", function() { - if (!resizing) { - sticky = self.isScrollAtBottom(); - } - }); - self.trigger("scroll"); - self.on("append html", function() { - if (sticky) { - self.scrollToBottom(settings.animate); - } - }); - - return this; - }; - - $.fn.scrollToBottom = function(animate) { - return this.each(function() { - $(this).finish().animate({scrollTop: this.scrollHeight}, animate || 0); - }); - }; - - $.fn.isScrollAtBottom = function() { - if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop("scrollHeight")) { - return true; - } - }; - - $(function() { - // Find elements with the 'scroll-glue' attribute and - // activate the plugin. - $("[scroll-glue]").scrollGlue(); - }); -})(jQuery); \ No newline at end of file diff --git a/client/js/lib/jquery.tabComplete.js b/client/js/lib/jquery.tabComplete.js deleted file mode 100644 index 966b98ca..00000000 --- a/client/js/lib/jquery.tabComplete.js +++ /dev/null @@ -1,66 +0,0 @@ -/*! - * jquery-tab-complete - * https://github.com/erming/jquery-tab-complete - * - * Copyright (c) 2014 Mattias Erming - * Licensed under the MIT License. - * - * Version 0.2.0 - */ - -(function($) { - $.fn.tabComplete = function(list, options) { - var settings = $.extend({ - after: '', - caseSensitive: false, - }, options); - - var self = this; - if (self.size() > 1) { - return self.each(function() { - $(this).tabComplete(list, options); - }); - } - - // Keep the list stored in the DOM via jQuery.data() variable. - self.data('list', list); - - var match = []; - self.on('keydown', function(e) { - var key = e.which; - if (key != 9) { - match = []; - return; - } - - var text = self.val().trim().split(' '); - var last = text.splice(-1)[0]; - - if (!match.length) { - match = $.grep(self.data('list'), function(w) { - var l = last; - if (l == '') { - return; - } - if (!settings.caseSensitive) { - l = l.toLowerCase(); - w = w.toLowerCase(); - } - return w.indexOf(l) !== -1; - }); - } - - var i = match.indexOf(last) + 1; - if (i == match.length) { - i = 0; - } - - if (match.length) { - text.push(match[i]); - self.val(text.join(' ') + settings.after); - } - - return false; - }); - }; -})(jQuery);