Moved js libraries to submodules

This commit is contained in:
Mattias Erming 2014-04-14 01:49:22 +02:00
parent 661e1d7b1d
commit 421f585d23
8 changed files with 17 additions and 160 deletions

9
.gitmodules vendored
View File

@ -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

View File

@ -121,8 +121,9 @@
<script src="/socket.io/socket.io.js"></script>
<script src="/js/lib/bootstrap.js"></script>
<script src="/js/lib/jquery.scrollGlue.js"></script>
<script src="/js/lib/jquery.tabComplete.js"></script>
<script src="/js/lib/jquery-input-history/jquery.inputHistory.js"></script>
<script src="/js/lib/jquery-scroll-glue/jquery.scrollGlue.js"></script>
<script src="/js/lib/jquery-tab-complete/jquery.tabComplete.js"></script>
<script src="/js/chat.js"></script>
</div>

View File

@ -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")

@ -0,0 +1 @@
Subproject commit 574732d84a70abce4dc6e93a88cbe167129fb84f

@ -0,0 +1 @@
Subproject commit e5178ce29594a11c3fdb453de35a167f0a49619b

@ -0,0 +1 @@
Subproject commit 461258f880c0cd1dd3d8dbb7924a6d5044bae664

View File

@ -1,90 +0,0 @@
/*!
* jquery-scroll-glue
* https://github.com/erming/jquery-scroll-glue
*
* Copyright (c) 2014 Mattias Erming <mattias@mattiaserming.com>
* 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);

View File

@ -1,66 +0,0 @@
/*!
* jquery-tab-complete
* https://github.com/erming/jquery-tab-complete
*
* Copyright (c) 2014 Mattias Erming <mattias@mattiaserming.com>
* 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);