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` - `/mode`
- `/msg` - `/msg`
- `/nick` - `/nick`
- `/notice`
- `/op` - `/op`
- `/part` - `/part`
- `/query` - `/query`

View File

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

View File

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

View File

@ -71,17 +71,17 @@
* Copyright (c) 2014 Mattias Erming <mattias@mattiaserming.com> * Copyright (c) 2014 Mattias Erming <mattias@mattiaserming.com>
* Licensed under the MIT License. * Licensed under the MIT License.
* *
* Version 1.1.0 * Version 1.2.0
*/ */
(function($) { (function($) {
$.fn.scrollGlue = function(options) { $.fn.scrollGlue = function(options) {
var settings = $.extend({ var settings = $.extend({
disableManualScroll: false, disableManualScroll: false,
overflow: "scroll", overflow: 'scroll',
scrollToBottom: true, scrollToBottom: true,
speed: 0 speed: 0
}, options); }, options);
var self = this; var self = this;
if (self.size() > 1) { if (self.size() > 1) {
return self.each(function() { return self.each(function() {
@ -89,50 +89,62 @@
}); });
} }
self.css("overflow-y", settings.overflow); self.css('overflow-y', settings.overflow);
if (settings.scrollToBottom) { if (settings.scrollToBottom) {
self.scrollToBottom(); self.scrollToBottom();
} }
var timer;
var resizing = false;
$(window).on('resize', function() { $(window).on('resize', function() {
self.finish(); 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; var sticky = true;
self.on('scroll', function() { self.on('scroll', function() {
if (settings.disableManualScroll) { if (settings.disableManualScroll) {
self.scrollToBottom(); self.scrollToBottom();
} else { } else if (!resizing) {
sticky = self.isScrollAtBottom(); sticky = self.isScrollAtBottom();
} }
}); });
self.trigger('scroll'); self.trigger('scroll');
self.on('append', function() { self.on('prepend append', function() {
if (sticky) { if (sticky) {
self.scrollToBottom(settings.speed); self.scrollToBottom(settings.speed);
} }
}); });
return this; return this;
}; };
var prepend = $.fn.prepend;
$.fn.prepend = function() {
return prepend.apply(this, arguments).trigger('append');
};
var append = $.fn.append; // Normally, these functions won't trigger any events.
$.fn.append = function() { // Lets override them.
return append.apply(this, arguments).trigger('append'); var events = ['prepend', 'append'];
}; $.each(events, function(i, e) {
var fn = $.fn[e];
var html = $.fn.html; $.fn[e] = function() {
$.fn.html = function(string) { return fn.apply(this, arguments).trigger(e);
var result = html.apply(this, arguments); };
if (typeof string !== 'undefined') { });
this.trigger('append');
$.fn.isScrollAtBottom = function() {
if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop('scrollHeight')) {
return true;
} }
return result;
}; };
$.fn.scrollToBottom = function(speed) { $.fn.scrollToBottom = function(speed) {
@ -140,12 +152,6 @@
$(this).finish().animate({scrollTop: this.scrollHeight}, speed || 0); $(this).finish().animate({scrollTop: this.scrollHeight}, speed || 0);
}); });
}; };
$.fn.isScrollAtBottom = function() {
if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop('scrollHeight')) {
return true;
}
};
})(jQuery); })(jQuery);
/*! /*!

View File

@ -152,6 +152,12 @@ function input(data) {
} }
break; break;
case "notice":
if (client && args[2]) {
client.notice(args[1], args.slice(2).join(" "));
}
break;
case "server": case "server":
case "connect": case "connect":
if (args[1]) { if (args[1]) {