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.

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