Added /notice

This commit is contained in:
Mattias Erming 2014-05-03 19:21:11 +02:00
parent 750a0313ba
commit 13e4115f04
5 changed files with 45 additions and 33 deletions

View file

@ -13,6 +13,7 @@ These are the commands currently implemented:
- `/mode`
- `/msg`
- `/nick`
- `/notice`
- `/op`
- `/part`
- `/query`

View file

@ -17,7 +17,6 @@
<aside id="sidebar">
<div id="menu">
<h2>Shout Client</h2>
<button data-target="#start">Start</button>
<button data-target="#settings">Settings</button>
</div>
<div id="networks"></div>
@ -30,7 +29,6 @@
</aside>
<div id="main">
<div id="windows">
<div id="start" class="window"></div>
<div id="settings" class="window"></div>
</div>
<div id="chat"></div>

View file

@ -13,6 +13,7 @@ $(function() {
"/mode",
"/msg",
"/nick",
"/notice",
"/op",
"/part",
"/query",

View file

@ -71,17 +71,17 @@
* Copyright (c) 2014 Mattias Erming <mattias@mattiaserming.com>
* 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);
/*!

View file

@ -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]) {