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.

387 lines
11 KiB

  1. ---
  2. layout : 'default'
  3. css : 'rating'
  4. title : 'Rating'
  5. description : 'A rating lets a user assess and view the desirability of content'
  6. type : 'UI Module'
  7. ---
  8. <%- @partial('header', { tabs: 'module' }) %>
  9. <script src="/javascript/rating.js"></script>
  10. <div class="main container">
  11. <div class="ui active tab" data-tab="definition">
  12. <div class="peek">
  13. <div class="ui vertical pointing secondary menu">
  14. <a class="active item">Types</a>
  15. <a class="item">Variations</a>
  16. </div>
  17. </div>
  18. <h2 class="ui dividing header">Types</h2>
  19. <div class="example">
  20. <h4 class="ui header">Rating</h4>
  21. <p>A basic rating</p>
  22. <div class="ui rating">
  23. <i class="icon"></i>
  24. <i class="icon"></i>
  25. <i class="icon"></i>
  26. <i class="icon"></i>
  27. <i class="icon"></i>
  28. </div>
  29. </div>
  30. <div class="example">
  31. <h4 class="ui header">Star</h4>
  32. <p>A rating can use a set of star icons</p>
  33. <div class="ui info message">Star and heart rating types require the inclusion of semantic <a href="/elements/icon.html">ui icons</a></div>
  34. <div class="ui star rating">
  35. <i class="icon"></i>
  36. <i class="icon"></i>
  37. <i class="icon"></i>
  38. <i class="icon"></i>
  39. <i class="icon"></i>
  40. </div>
  41. </div>
  42. <div class="example">
  43. <h4 class="ui header">Heart</h4>
  44. <p>A rating can use a set of heart icons</p>
  45. <div class="ui heart rating">
  46. <i class="icon"></i>
  47. <i class="icon"></i>
  48. <i class="icon"></i>
  49. <i class="icon"></i>
  50. <i class="icon"></i>
  51. </div>
  52. </div>
  53. <h2 class="ui dividing header">Variations</h2>
  54. <div class="example">
  55. <h4 class="ui header">Size</h4>
  56. <p>A rating can vary in size</p>
  57. <div class="another example">
  58. <div class="ui small star rating">
  59. <i class="icon"></i>
  60. <i class="icon"></i>
  61. <i class="icon"></i>
  62. <i class="icon"></i>
  63. <i class="icon"></i>
  64. </div>
  65. </div>
  66. <div class="another example">
  67. <div class="ui star rating">
  68. <i class="icon"></i>
  69. <i class="icon"></i>
  70. <i class="icon"></i>
  71. <i class="icon"></i>
  72. <i class="icon"></i>
  73. </div>
  74. </div>
  75. <div class="another example">
  76. <div class="ui large star rating">
  77. <i class="icon"></i>
  78. <i class="icon"></i>
  79. <i class="icon"></i>
  80. <i class="icon"></i>
  81. <i class="icon"></i>
  82. </div>
  83. </div>
  84. <div class="another example">
  85. <div class="ui huge star rating">
  86. <i class="icon"></i>
  87. <i class="icon"></i>
  88. <i class="icon"></i>
  89. <i class="icon"></i>
  90. <i class="icon"></i>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="ui tab" data-tab="examples">
  96. <div class="example">
  97. <h3 class="ui header">Setting existing values</h3>
  98. <p>Starting ratings can be set either using metadata values or the setting <code>initialRating</code>.</p>
  99. <div class="ui ignored info message">If a metadata rating is specified it will automatically override any initial rating. This way you can set a default value but also allow it to be overridden.</div>
  100. <div class="ui divided list">
  101. <div class="item">
  102. <img src="/images/demo/avatar2.jpg">
  103. <div class="ui heart rating" data-rating="5">
  104. <i class="icon"></i>
  105. <i class="icon"></i>
  106. <i class="icon"></i>
  107. <i class="icon"></i>
  108. <i class="icon"></i>
  109. </div>
  110. <div class="content">
  111. <div class="header">New York Dog Fair</div>
  112. A fun day at the fair
  113. </div>
  114. </div>
  115. <div class="item">
  116. <img src="/images/demo/avatar3.jpg">
  117. <div class="ui heart rating" data-rating="2">
  118. <i class="icon"></i>
  119. <i class="icon"></i>
  120. <i class="icon"></i>
  121. <i class="icon"></i>
  122. <i class="icon"></i>
  123. </div>
  124. <div class="content">
  125. <div class="header">Dog Appreciation Day</div>
  126. I night to tell your dog he's great
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="toggle no example">
  132. <h3 class="ui header">Read-Only Ratings</h3>
  133. <p>You can disable or enable interactive rating</p>
  134. <div class="code" data-type="javascript" data-demo="true">
  135. $('.toggle.example .rating')
  136. .rating('disable')
  137. ;
  138. </div>
  139. <div class="code" data-type="javascript" data-demo="true">
  140. $('.toggle.example .rating')
  141. .rating('enable')
  142. ;
  143. </div>
  144. <div class="ui heart demo rating" data-rating="3">
  145. <i class="icon"></i>
  146. <i class="icon"></i>
  147. <i class="icon"></i>
  148. <i class="icon"></i>
  149. <i class="icon"></i>
  150. </div>
  151. </div>
  152. <div class="clearing no example">
  153. <h3 class="ui header">Clearing Ratings</h3>
  154. <p>When clearable is set to <code>true</code> you can clear the rating by clicking on the current start rating.</p>
  155. <div class="evaluated code" data-type="javascript">
  156. $('.clearing.example .rating')
  157. .rating('setting', 'clearable', true)
  158. ;
  159. </div>
  160. <div class="ui heart demo rating" data-rating="3">
  161. <i class="icon"></i>
  162. <i class="icon"></i>
  163. <i class="icon"></i>
  164. <i class="icon"></i>
  165. <i class="icon"></i>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="ui tab" data-tab="usage">
  170. <h2 class="ui dividing header">Initializing</h2>
  171. <p>To change the range of your rating, simply adjust the number of icons in the initialized html</p>
  172. <div class="ui warning message">
  173. To use any variations besides the basic rating <a href="/elements/icon.html">ui icons</a> must be included to provide the additional icons required.
  174. </div>
  175. <div class="code" data-type="javascript">
  176. $('.ui.rating')
  177. .rating()
  178. ;
  179. </div>
  180. <div class="code" data-type="html">
  181. <div class="ui rating">
  182. <i class="icon"></i>
  183. <i class="icon"></i>
  184. <i class="icon"></i>
  185. <i class="icon"></i>
  186. <i class="icon"></i>
  187. </div>
  188. </div>
  189. <h2 class="ui dividing header">Behavior</h2>
  190. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  191. <div class="code">
  192. $('.ui.rating')
  193. .modal('behavior name', argumentOne, argumentTwo)
  194. ;
  195. </div>
  196. <table class="ui definition celled sortable table segment">
  197. <thead>
  198. <th>Behavior</th>
  199. <th>Description</th>
  200. </thead>
  201. <tbody>
  202. <tr>
  203. <td>set rating(rating)</td>
  204. <td>Sets rating programmatically</td>
  205. </tr>
  206. <tr>
  207. <td>get rating</td>
  208. <td>Gets current rating</td>
  209. </tr>
  210. <tr>
  211. <td>disable</td>
  212. <td>Disables interactive rating mode</td>
  213. </tr>
  214. <tr>
  215. <td>enable</td>
  216. <td>Enables interactive rating mode</td>
  217. </tr>
  218. <tr>
  219. <td>clear rating</td>
  220. <td>Clears current rating</td>
  221. </tr>
  222. </tbody>
  223. </table>
  224. </div>
  225. <div class="ui tab" data-tab="settings">
  226. <h3 class="ui header">
  227. Rating Settings
  228. <div class="sub header">Rating settings modify the rating's behavior</div>
  229. </h3>
  230. <table class="ui celled sortable definition table segment">
  231. <thead>
  232. <th>Setting</th>
  233. <th class="four wide">Default</th>
  234. <th>Description</th>
  235. </thead>
  236. <tbody>
  237. <tr>
  238. <td>initialRating</td>
  239. <td>0</td>
  240. <td>A number representing the default rating to apply</td>
  241. </tr>
  242. <tr>
  243. <td>clearable</td>
  244. <td>false</td>
  245. <td>If enabled clicking on the current star rating will clear the rating</td>
  246. </tr>
  247. <tr>
  248. <td>interactive</td>
  249. <td>true</td>
  250. <td>Whether to enable user's ability to rate</td>
  251. </tr>
  252. </tbody>
  253. </table>
  254. <h3 class="ui header">
  255. Callbacks
  256. <div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
  257. </h3>
  258. <table class="ui celled sortable definition table segment">
  259. <thead>
  260. <th class="four wide">Setting</th>
  261. <th>Context</th>
  262. <th>Description</th>
  263. </thead>
  264. <tbody>
  265. <tr>
  266. <td>onRate(value)</td>
  267. <td>Rating</td>
  268. <td>Is called after user selects a new rating</td>
  269. </tr>
  270. </tbody>
  271. </table>
  272. <h3 class="ui header">
  273. DOM Settings
  274. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  275. </h3>
  276. <table class="ui celled sortable definition table segment">
  277. <thead>
  278. <th>Setting</th>
  279. <th class="four wide">Default</th>
  280. <th>Description</th>
  281. </thead>
  282. <tbody>
  283. <tr>
  284. <td>namespace</td>
  285. <td>rating</td>
  286. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  287. </tr>
  288. <tr>
  289. <td>selector</td>
  290. <td colspan="2">
  291. <div class="code">
  292. selector : {
  293. icon : '.icon'
  294. }
  295. </div>
  296. </td>
  297. </tr>
  298. <tr>
  299. <td>className</td>
  300. <td colspan="2">
  301. <div class="code">
  302. className : {
  303. active : 'active',
  304. hover : 'hover',
  305. loading : 'loading'
  306. },
  307. </div>
  308. </td>
  309. </tr>
  310. </tbody>
  311. </table>
  312. <h3 class="ui header">
  313. Debug Settings
  314. <div class="sub header">Debug settings controls debug output to the console</div>
  315. </h3>
  316. <table class="ui celled sortable definition table segment">
  317. <thead>
  318. <th>Setting</th>
  319. <th class="four wide">Default</th>
  320. <th>Description</th>
  321. </thead>
  322. <tbody>
  323. <tr>
  324. <td>name</td>
  325. <td>Rating</td>
  326. <td>Name used in debug logs</td>
  327. </tr>
  328. <tr>
  329. <td>debug</td>
  330. <td>True</td>
  331. <td>Provides standard debug output to console</td>
  332. </tr>
  333. <tr>
  334. <td>performance</td>
  335. <td>True</td>
  336. <td>Provides standard debug output to console</td>
  337. </tr>
  338. <tr>
  339. <td>verbose</td>
  340. <td>True</td>
  341. <td>Provides ancillary debug output to console</td>
  342. </tr>
  343. <tr>
  344. <td>error</td>
  345. <td colspan="2">
  346. <div class="code">
  347. error : {
  348. action : 'You called a rating action that was not defined'
  349. }
  350. </div>
  351. </td>
  352. </tr>
  353. </tbody>
  354. </table>
  355. </div>
  356. </div>
  357. </body>
  358. </html>