本文整理汇总了TypeScript中candy.View.getCurrent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript View.getCurrent方法的具体用法?TypeScript View.getCurrent怎么用?TypeScript View.getCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类candy.View
的用法示例。
在下文中一共展示了View.getCurrent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
elem.find('a.label').click(function (event: any) {
event.preventDefault();
// Check if user is online and not myCandy.View.Pane
const room = Candy.Core.getRoom(roomJid);
if (room &&
name !== Candy.View.Pane.Room.getUser(Candy.View.getCurrent().roomJid).getNick() &&
room.getRoster().get(roomJid + '/' + name)) {
if (Candy.View.Pane.PrivateRoom.open(roomJid + '/' + name, name, true) === false) {
return false;
}
}
});
示例2: function
Candy.View.Pane.Message.show = function (roomJid: any, name: any, message: any, xhtmlMessage: any, timestamp: any,
from: any, carbon: any, stanza: any) {
message = Candy.Util.Parser.all(message.substring(0, Candy.View.getOptions().crop.message.body));
if (Candy.View.getOptions().enableXHTML === true && xhtmlMessage) {
xhtmlMessage = Candy.Util.parseAndCropXhtml(xhtmlMessage, Candy.View.getOptions().crop.message.body);
}
timestamp = timestamp || new Date();
// Assume we have an ISO-8601 date string and convert it to a Date object
if (!timestamp.toDateString) {
timestamp = Candy.Util.iso8601toDate(timestamp);
}
// Before we add the new message, check to see if we should be automatically scrolling or not.
const messagePane = Candy.View.Pane.Room.getPane(roomJid, '.message-pane');
let enableScroll;
if (stanza && stanza.children('delay').length > 0) {
enableScroll = true;
} else {
enableScroll =
messagePane.scrollTop() + messagePane.outerHeight() === messagePane.prop('scrollHeight') || !$(messagePane).is(':visible');
}
Candy.View.Pane.Chat.rooms[roomJid].enableScroll = enableScroll;
const evtData: any = {
roomJid: roomJid,
name: name,
message: message,
xhtmlMessage: xhtmlMessage,
from: from,
stanza: stanza
};
if ($(Candy).triggerHandler('candy:view.message.before-show', evtData) === false) {
return;
}
message = evtData.message;
xhtmlMessage = evtData.xhtmlMessage;
if (xhtmlMessage !== undefined && xhtmlMessage.length > 0) {
message = xhtmlMessage;
}
if (!message) {
return;
}
const renderEvtData = {
template: Candy.View.Template.Message.item,
templateData: {
name: name,
displayName: Candy.Util.crop(name, Candy.View.getOptions().crop.message.nickname),
message: message,
time: Candy.Util.localizedTime(timestamp),
timestamp: timestamp.toISOString(),
roomjid: roomJid,
from: from
},
stanza: stanza
};
$(Candy).triggerHandler('candy:view.message.before-render', renderEvtData);
const html = Mustache.to_html(renderEvtData.template, renderEvtData.templateData);
Candy.View.Pane.Room.appendToMessagePane(roomJid, html);
const elem = Candy.View.Pane.Room.getPane(roomJid, '.message-pane').children().last();
// click on username opens private chat
elem.find('a.label').click(function (event: any) {
event.preventDefault();
// Check if user is online and not myCandy.View.Pane
const room = Candy.Core.getRoom(roomJid);
if (room &&
name !== Candy.View.Pane.Room.getUser(Candy.View.getCurrent().roomJid).getNick() &&
room.getRoster().get(roomJid + '/' + name)) {
if (Candy.View.Pane.PrivateRoom.open(roomJid + '/' + name, name, true) === false) {
return false;
}
}
});
if (!carbon) {
const notifyEvtData = {
name: name,
displayName: Candy.Util.crop(name, Candy.View.getOptions().crop.message.nickname),
roomJid: roomJid,
message: message,
time: Candy.Util.localizedTime(timestamp),
timestamp: timestamp.toISOString()
};
$(Candy).triggerHandler('candy:view.message.notify', notifyEvtData);
// Check to see if in-core notifications are disabled
if (!Candy.Core.getOptions().disableCoreNotifications) {
if (Candy.View.getCurrent().roomJid !== roomJid || !Candy.View.Pane.Window.hasFocus()) {
Candy.View.Pane.Chat.increaseUnreadMessages(roomJid);
if (!Candy.View.Pane.Window.hasFocus()) {
// Notify the user about a new private message OR on all messages if configured
if (Candy.View.Pane.Chat.rooms[roomJid].type === 'chat' || Candy.View.getOptions().updateWindowOnAllMessages === true) {
Candy.View.Pane.Chat.Toolbar.playSound();
}
}
}
}
if (Candy.View.getCurrent().roomJid === roomJid) {
requestIdleCallback(function () {
Candy.View.Pane.Room.scrollToBottom(roomJid);
});
}
}
evtData.element = elem;
$(Candy).triggerHandler('candy:view.message.after-show', evtData);
//.........这里部分代码省略.........