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.

356 lines
10 KiB

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