当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript View.getCurrent方法代码示例

本文整理汇总了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;
     }
   }
 });
开发者ID:mycard,项目名称:mycard,代码行数:12,代码来源:candy.ts

示例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);
//.........这里部分代码省略.........
开发者ID:mycard,项目名称:mycard,代码行数:101,代码来源:candy.ts


注:本文中的candy.View.getCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。