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.

275 lines
7.1 KiB

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