Merge pull request #1491 from realies/master
Focus a channel by joining it, refactor user commands #1189
This commit is contained in:
commit
ca389c914f
@ -182,14 +182,12 @@ $(function() {
|
|||||||
input.val("");
|
input.val("");
|
||||||
resetInputHeight(input.get(0));
|
resetInputHeight(input.get(0));
|
||||||
|
|
||||||
if (text.indexOf("/collapse") === 0) {
|
if (text.charAt(0) === "/") {
|
||||||
$(".chan.active .toggle-preview.opened").click();
|
const args = text.substr(1).split(" ");
|
||||||
return;
|
const cmd = args.shift().toLowerCase();
|
||||||
}
|
if (typeof utils.inputCommands[cmd] === "function" && utils.inputCommands[cmd](args)) {
|
||||||
|
return;
|
||||||
if (text.indexOf("/expand") === 0) {
|
}
|
||||||
$(".chan.active .toggle-preview:not(.opened)").click();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
@ -198,18 +196,6 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function findCurrentNetworkChan(name) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
|
|
||||||
return $(".network .chan.active")
|
|
||||||
.parent(".network")
|
|
||||||
.find(".chan")
|
|
||||||
.filter(function() {
|
|
||||||
return $(this).data("title").toLowerCase() === name;
|
|
||||||
})
|
|
||||||
.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
$("button#set-nick").on("click", function() {
|
$("button#set-nick").on("click", function() {
|
||||||
utils.toggleNickEditor(true);
|
utils.toggleNickEditor(true);
|
||||||
|
|
||||||
@ -266,7 +252,7 @@ $(function() {
|
|||||||
|
|
||||||
chat.on("click", ".inline-channel", function() {
|
chat.on("click", ".inline-channel", function() {
|
||||||
var name = $(this).data("chan");
|
var name = $(this).data("chan");
|
||||||
var chan = findCurrentNetworkChan(name);
|
var chan = utils.findCurrentNetworkChan(name);
|
||||||
|
|
||||||
if (chan.length) {
|
if (chan.length) {
|
||||||
chan.click();
|
chan.click();
|
||||||
@ -284,7 +270,7 @@ $(function() {
|
|||||||
|
|
||||||
chat.on("click", ".user", function() {
|
chat.on("click", ".user", function() {
|
||||||
var name = $(this).data("name");
|
var name = $(this).data("name");
|
||||||
var chan = findCurrentNetworkChan(name);
|
var chan = utils.findCurrentNetworkChan(name);
|
||||||
|
|
||||||
if (chan.length) {
|
if (chan.length) {
|
||||||
chan.click();
|
chan.click();
|
||||||
|
@ -7,6 +7,8 @@ var serverHash = -1;
|
|||||||
var lastMessageId = -1;
|
var lastMessageId = -1;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
inputCommands: {collapse, expand, join},
|
||||||
|
findCurrentNetworkChan,
|
||||||
serverHash,
|
serverHash,
|
||||||
lastMessageId,
|
lastMessageId,
|
||||||
confirmExit,
|
confirmExit,
|
||||||
@ -19,6 +21,18 @@ module.exports = {
|
|||||||
requestIdleCallback,
|
requestIdleCallback,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function findCurrentNetworkChan(name) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
|
||||||
|
return $(".network .chan.active")
|
||||||
|
.parent(".network")
|
||||||
|
.find(".chan")
|
||||||
|
.filter(function() {
|
||||||
|
return $(this).data("title").toLowerCase() === name;
|
||||||
|
})
|
||||||
|
.first();
|
||||||
|
}
|
||||||
|
|
||||||
function resetHeight(element) {
|
function resetHeight(element) {
|
||||||
element.style.height = element.style.minHeight;
|
element.style.height = element.style.minHeight;
|
||||||
}
|
}
|
||||||
@ -29,6 +43,27 @@ function forceFocus() {
|
|||||||
input.trigger("click").focus();
|
input.trigger("click").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function collapse() {
|
||||||
|
$(".chan.active .toggle-button.opened").click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function expand() {
|
||||||
|
$(".chan.active .toggle-button:not(.opened)").click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function join(args) {
|
||||||
|
const channel = args[0];
|
||||||
|
if (channel) {
|
||||||
|
const chan = findCurrentNetworkChan(channel);
|
||||||
|
if (chan.length) {
|
||||||
|
chan.click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleNickEditor(toggle) {
|
function toggleNickEditor(toggle) {
|
||||||
$("#nick").toggleClass("editable", toggle);
|
$("#nick").toggleClass("editable", toggle);
|
||||||
$("#nick-value").attr("contenteditable", toggle);
|
$("#nick-value").attr("contenteditable", toggle);
|
||||||
|
Loading…
Reference in New Issue
Block a user