You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

286 lines
7.4 KiB

  1. ---
  2. layout : 'default'
  3. css : 'chatroom'
  4. title : 'Chatroom'
  5. description : 'A chatroom allows users to communicate with each other in real time.'
  6. type : 'UI Module'
  7. ---
  8. <link rel="stylesheet" type="text/css" href="/build/uncompressed/modules/chatroom.css">
  9. <script src="http://js.pusher.com/2.1/pusher.min.js" type="text/javascript"></script>
  10. <script src="/build/uncompressed/modules/chatroom.js"></script>
  11. <%- @partial('header') %>
  12. <div class="main container">
  13. <div class="peek">
  14. <div class="ui vertical pointing secondary menu">
  15. <a class="active item">Usage</a>
  16. <a class="item">Types</a>
  17. <a class="item">Examples</a>
  18. <a class="item">Settings</a>
  19. </div>
  20. </div>
  21. <h2 class="ui dividing header">Usage</h2>
  22. <h3 class="ui header">Initializing a chat room</h3>
  23. <p>Using chatroom requires an account with <a href="http://www.pusher.com" target="_blank">pusher</a>, a company that provides turn-key web socket access.</p>
  24. <div class="code" data-type="javascript" data-demo="true">
  25. // modify these for your api settings received from pusher
  26. $('.ui.chatroom')
  27. .chatroom({
  28. key : 'f812089c851866cc2f3e',
  29. endpoint: {
  30. authentication : '/chat/authentication',
  31. message : '/chat/send'
  32. }
  33. })
  34. ;
  35. </div>
  36. <div class="ui chatroom">
  37. <div class="actions">
  38. <div class="message">
  39. <span class="ui mini inline loader"></span>
  40. Joining chat
  41. </div>
  42. <div class="ui secondary mini right floated icon buttons">
  43. <div class="ui button">
  44. <i class="users icon"></i>
  45. </div>
  46. <div class="ui button">
  47. <i class="full resize icon"></i>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="room">
  52. <div class="container">
  53. <div class="user-list">
  54. <div class="ui small text loader">Loading</div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="talk">
  59. <div class="avatar">
  60. <img src="/images/demo/avatar.jpg">
  61. </div>
  62. <input type="text" maxlength="200">
  63. <div class="ui send button">
  64. <i class="ui icon comment"></i>
  65. Send
  66. </div>
  67. </div>
  68. </div>
  69. <h2 class="ui dividing header">Settings</h2>
  70. <div class="no example">
  71. <h4 class="ui header">Chatroom Settings</h4>
  72. <p>Chatroom settings modify the chatroom's behavior</p>
  73. <table class="ui celled sortable definition table segment">
  74. <thead>
  75. <th>Setting</th>
  76. <th class="four wide">Default</th>
  77. <th>Description</th>
  78. </thead>
  79. <tbody>
  80. <tr>
  81. <td>key</td>
  82. <td>false</td>
  83. <td>Pusher API key</td>
  84. </tr>
  85. <tr>
  86. <td>key</td>
  87. <td>presence-chat</td>
  88. <td>Channel to use. Pusher requires chatrooms to use channels beginning with presence-</td>
  89. </tr>
  90. <tr>
  91. <td>scrollArea</td>
  92. <td>9999</td>
  93. <td>If a user is this many pixels away from bottom of the page it will automatically scroll when a message is receieved</td>
  94. </tr>
  95. <tr>
  96. <td>customEvents</td>
  97. <td>{}</td>
  98. <td>An object containing custom events and functions to use with pusher</td>
  99. </tr>
  100. <tr>
  101. <td>endpoint</td>
  102. <td>
  103. <div class="code">
  104. {
  105. message: false,
  106. authentication: false
  107. }
  108. </div>
  109. </td>
  110. <td>Endpoints used to communicate authentication and chat messages</td>
  111. </tr>
  112. <tr>
  113. <td>partingMessages</td>
  114. <td>false</td>
  115. <td>Whether to display messages when a user has joined chat</td>
  116. </tr>
  117. <tr>
  118. <td>userCount</td>
  119. <td>true</td>
  120. <td>Whether to display the current logged in user count</td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <div class="ui horizontal section icon divider"><i class="icon setting"></i></div>
  125. <h4 class="ui header">Callbacks</h4>
  126. <p>Callback settings specify a function to occur after a specific behavior.</p>
  127. <table class="ui celled sortable definition table segment">
  128. <thead>
  129. <th class="four wide">Setting</th>
  130. <th>Context</th>
  131. <th>Description</th>
  132. </thead>
  133. <tbody>
  134. <tr>
  135. <td>onJoin(user)</td>
  136. <td>Chatroom</td>
  137. <td>Called after each user joins a chat room</td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. </div>
  142. <div class="no example">
  143. <h4 class="ui header">DOM Settings</h4>
  144. <p>DOM settings specify how this module should interface with the DOM</p>
  145. <table class="ui celled sortable definition table segment">
  146. <thead>
  147. <th>Setting</th>
  148. <th class="four wide">Default</th>
  149. <th>Description</th>
  150. </thead>
  151. <tbody>
  152. <tr>
  153. <td>namespace</td>
  154. <td>chatroom</td>
  155. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  156. </tr>
  157. <tr>
  158. <td>selector</td>
  159. <td colspan="2">
  160. <div class="code">
  161. selector : {
  162. icon : '.icon'
  163. }
  164. </div>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td>className</td>
  169. <td colspan="2">
  170. <div class="code">
  171. className : {
  172. active : 'active',
  173. hover : 'hover',
  174. loading : 'loading'
  175. },
  176. </div>
  177. </td>
  178. </tr>
  179. </tbody>
  180. </table>
  181. </div>
  182. <div class="no example">
  183. <h4 class="ui header">Debug Settings</h4>
  184. <p>Debug settings controls debug output to the console</p>
  185. <table class="ui celled sortable definition table segment">
  186. <thead>
  187. <th>Setting</th>
  188. <th class="four wide">Default</th>
  189. <th>Description</th>
  190. </thead>
  191. <tbody>
  192. <tr>
  193. <td>name</td>
  194. <td>Chatroom</td>
  195. <td>Name used in debug logs</td>
  196. </tr>
  197. <tr>
  198. <td>debug</td>
  199. <td>True</td>
  200. <td>Provides standard debug output to console</td>
  201. </tr>
  202. <tr>
  203. <td>performance</td>
  204. <td>True</td>
  205. <td>Provides performance output to console</td>
  206. </tr>
  207. <tr>
  208. <td>verbose</td>
  209. <td>True</td>
  210. <td>Provides ancillary debug output to console</td>
  211. </tr>
  212. <tr>
  213. <td>selector</td>
  214. <td colspan="2">
  215. <div class="code">
  216. selector : {
  217. userCount : '.actions .message',
  218. userListButton : '.actions .list.button',
  219. expandButton : '.actions .expand.button',
  220. room : '.room',
  221. userList : '.room .list',
  222. log : '.room .log',
  223. message : '.room .log .message',
  224. author : '.room log .message .author',
  225. messageInput : '.talk input',
  226. messageButton : '.talk .send.button'
  227. }
  228. </div>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>className</td>
  233. <td colspan="2">
  234. <div class="code">
  235. className : {
  236. expand : 'expand',
  237. active : 'active',
  238. hover : 'hover',
  239. down : 'down',
  240. loading : 'loading'
  241. }
  242. </div>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td>error</td>
  247. <td colspan="2">
  248. <div class="code">
  249. error: {
  250. method : 'The method you called is not defined',
  251. endpoint : 'Please define a message and authentication endpoint.',
  252. key : 'You must specify a pusher key and channel.',
  253. pusher : 'You must include the Pusher library.'
  254. }
  255. </div>
  256. </td>
  257. </tr>
  258. </tbody>
  259. </table>
  260. </div>
  261. </div>
  262. </body>
  263. </html>