fc5c84867f25577030e706c1e6fb2fc0d413ef25.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title>星级评价</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!--评星级控件start-->
  19. <script type="text/javascript" src="<%=path%>/libs/js/form/rating.js"></script>
  20. <!--评星级控件end-->
  21. <body>
  22. <div class="box1" panelWidth="800">
  23. <fieldset>
  24. <legend>1、基本用法</legend>
  25. <div class="rating"></div>
  26. </fieldset>
  27. <div class="height_15"></div>
  28. <fieldset>
  29. <legend>2、只读并在初始时赋值</legend>
  30. <div class="rating" readOnly="true" value="2"></div>
  31. </fieldset>
  32. <div class="height_15"></div>
  33. <fieldset>
  34. <legend>3、使用隐藏域</legend>
  35. <p>如果为组件添加name属性,那么会自动生成一个隐藏域input,用来存储组件当前的value,该input的name与组件name一致。<br/>在提交表单时会用到。</p>
  36. <div class="rating" name="bo.raty"></div>
  37. <input type="button" value="获取隐藏域选中值" onclick="getHiddenValue()"/>
  38. </fieldset>
  39. <div class="height_15"></div>
  40. <fieldset>
  41. <legend>4、自定义个数</legend>
  42. <div class="rating" number="10"></div>
  43. </fieldset>
  44. <div class="height_15"></div>
  45. <fieldset>
  46. <legend>5、自定义图标和提示语</legend>
  47. <div class="rating" tip="a,,null,d,5" starOn="medal-on.gif" starOff="medal-off.gif"></div>
  48. </fieldset>
  49. <div class="height_15"></div>
  50. <fieldset>
  51. <legend>6、使用取消按钮</legend>
  52. <div class="rating" showCancel="true"></div>
  53. </fieldset>
  54. <div class="height_15"></div>
  55. <fieldset>
  56. <legend>7、手动渲染(处理点击事件)</legend>
  57. 手动渲染可以使用事件。
  58. <div id="rating7"></div>
  59. </fieldset>
  60. <div class="height_15"></div>
  61. <fieldset>
  62. <legend>8、手动渲染自定义取消按钮</legend>
  63. 手动渲染还做更加个性化的设置。如自定义取消按钮。
  64. <div id="rating8"></div>
  65. </fieldset>
  66. <div class="height_15"></div>
  67. <fieldset>
  68. <legend>9、动态创建</legend>
  69. <input type="button" value="点击生成" id="testBtn" onclick="dynamic()"/>
  70. </fieldset>
  71. <div class="height_15"></div>
  72. <fieldset>
  73. <legend>10、动态赋值</legend>
  74. <div class="rating" id="rating10"></div>
  75. <input type="button" value="点击赋值" onclick="setValue()"/>
  76. </fieldset>
  77. </div>
  78. <script type="text/javascript">
  79. function initComplete() {
  80. //手动渲染
  81. $('div#rating7').Rating({
  82. onClick: function(score) {
  83. top.Dialog.alert('分数: ' + score);
  84. }
  85. });
  86. //手动渲染
  87. $('div#rating8').Rating({
  88. cancelHint: '取消',
  89. cancelPlace: 'right',
  90. showCancel: true,
  91. onClick: function(score) {
  92. top.Dialog.alert('分数: ' + score);
  93. }
  94. });
  95. }
  96. //获取隐藏域值
  97. function getHiddenValue(){
  98. top.Dialog.alert($("input:hidden[name='bo.raty']").val());
  99. }
  100. //动态生成
  101. function dynamic(){
  102. //动态生成星级控件需要设置id
  103. var $rating = $('<div class="rating" id="rating9"></div>');
  104. $("#testBtn").after($rating);
  105. $("#testBtn").after($("<br/>"));
  106. //渲染
  107. $rating.render();
  108. }
  109. //动态赋值
  110. function setValue(){
  111. $("#rating10").attr("value",3);
  112. $("#rating10").render();
  113. }
  114. </script>
  115. </body>
  116. </html>