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.

418 lines
12 KiB

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