Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Module for Chat UI representation

NotificationsYou must be signed in to change notification settings

artemdemo/chat-ui

Repository files navigation

Русская версия

Chat UI

Module for Chat UI representation

alt tag

Technologies

  • ES6
  • Babel
  • Webpack
  • Gulp
  • Less

Getting started

You can use Chat UI as module:

importChatUIfrom'./vendor/chat-ui';

or use it as stand alone file in your project:

<scriptsrc="../lib/chat-ui.js"></script><linkhref="../lib/chat-ui.css"rel="stylesheet"media="all"/>
$(document).ready(function(){varchat=ChatUI({title:'John Doe',avatar:'./john-doe.jpg',subtitle:'consultant'}).render('#chat');});

Initialization

varchat=ChatUI(settings).render(tagId);
  • settings - settings object of chat properties
  • tagId - id of tag, where chat will be rendered

Chat settings

  • title - chat title or name of the consultant
  • subtitle - position or consultant description
  • avatar - avatar image of the consultant - string or boolean
  • sendText - text for "send" button in chat window
  • inputPlaceholder - placeholder text on the input
  • isTyping - message that operator is typing

Default settings:

letsettings={title:'John Doe',subtitle:'consultant',avatar:false,sendText:'Send',inputPlaceholder:'Enter your message',isTyping:`        <divpl-s1">${LIB_NAME}-dots-loading">            <span>&#8226;</span>            <span>&#8226;</span>            <span>&#8226;</span>        </div>    `}

Events

Your interaction with chat will be via different events

.trigger(eventName)

Open chat window

chat.trigger('open-chat');

Show message in chat dialog list

// There is number of options for message// It can be string:// var message = 'Hello!';// Simple object:// var message = {message:'Hello'};// Full object, where you can decide on which side text will appear: 'user' or 'chat'// var message = {side: 'chat', message:'Hello'};chat.trigger('add-phrase',message);

Close chat window

chat.trigger('close-chat');

Clear dialog list

chat.trigger('clear-dialog');

Show "typing" icon to the user

chat.trigger('is-typing');

.on(eventName)

User send message callback

chat.on('user-send-message',function(message){// ...});

Chat closed callback

chat.on('chat-closed',function(data){console.log('chat-closed',data);});

Developing

Watch function for all files

$ npm run watch

Build regular and minified versions of the library files.

$ npm run build

Code quality

  • eslint, based on airbnb specs

Testing

Libraries


[8]ページ先頭

©2009-2025 Movatter.jp