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.

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