chapter.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>chapter</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <link rel="stylesheet" href="../css/mui.min.css">
  10. <link rel="stylesheet" href="../css/iconfont.css">
  11. <script src="../js/mui.min.js"></script>
  12. <script src="../js/app.js"></script>
  13. <script src="../js/service.js"></script>
  14. <style type="text/css">
  15. #list {
  16. /*避免导航边框和列表背景边框重叠,看起来像两条边框似得;*/
  17. margin-top: -1px;
  18. }
  19. #topPopover {
  20. position: fixed;
  21. top: 16px;
  22. right: 6px;
  23. }
  24. #topPopover .mui-popover-arrow {
  25. left: auto;
  26. right: 6px;
  27. }
  28. .mui-popover {
  29. height: 100px;
  30. }
  31. .kaishi {
  32. width: 100px;
  33. height: 30px;
  34. border-radius: 4px;
  35. margin-left: auto;
  36. margin-right: auto;
  37. padding-top: 6px;
  38. background-color: #EA5555;
  39. color: white;
  40. font-size: 14px;
  41. }
  42. .biaoti {
  43. word-wrap: break-word;
  44. word-break: normal;
  45. white-space: normal;
  46. height: 70px;
  47. padding-top: 20px;
  48. padding-left: 15px;
  49. padding-right: 15px;
  50. }
  51. .zhang {
  52. height: 120px;
  53. width: 90%;
  54. margin: 0 auto;
  55. border: 1px solid lightgray;
  56. background-color: white;
  57. border-radius: 4px;
  58. }
  59. .mui-media-li-self {
  60. margin-top: 30px;
  61. }
  62. .jindulan {
  63. height: 100%;
  64. background-color: #428bca;
  65. border-bottom-left-radius: 4px;
  66. border-top-left-radius: 4px;
  67. }
  68. .jindu {
  69. text-align: center;
  70. font-size: 12px;
  71. margin: 0 auto;
  72. width: 60%;
  73. height: 20px;
  74. border-radius: 4px;
  75. background-color: lightgray;
  76. }
  77. .mui-popover {
  78. width: 150px !important;
  79. }
  80. </style>
  81. </head>
  82. <body>
  83. <div class="mui-content">
  84. <ul id="list" class="mui-table-view mui-grid-view" style="padding-top: 30px;
  85. padding-bottom: 30px;background-color: #F3F3F3;">
  86. </ul>
  87. </div>
  88. <!--右上角弹出菜单-->
  89. <div id="topPopover" class="mui-popover ">
  90. <div class="mui-scroll-wrapper">
  91. <div class="mui-scroll">
  92. <ul class="mui-table-view">
  93. <li class="mui-table-view-cell">
  94. <a id="cuotiben" data-course-id="" data-href="review-chapter.html" data-type='2' style="color: red;">
  95. <i class="mui-icon icon iconfont icon-zhangben" style="margin-right: 10px;"></i>错题本
  96. </a>
  97. </li>
  98. <li class="mui-table-view-cell">
  99. <a id="shoucangben" data-course-id="" data-href="review-chapter.html" data-type='1' style="color: blue;">
  100. <i class="mui-icon icon iconfont icon-shu" style="margin-right: 10px;"></i>收藏本
  101. </a>
  102. </li>
  103. </ul>
  104. </div>
  105. </div>
  106. </div>
  107. <script type="text/html" id="template-chapter-id">
  108. <li class="mui-table-view-cell mui-media mui-col-xs-12 mui-media-li-self">
  109. <a href="section.html" data-title="{name}" data-chapter-id='{code}'>
  110. <div class="zhang">
  111. <div class=" biaoti">
  112. {name}
  113. </div>
  114. <div class="jindu" style="text-align: center;">
  115. <div class="jindulan" style="width: {progress}%;">
  116. </div>
  117. <div style="margin-top:-20px;font-size: 12px;color: #4D4D4D;">已完成{progress}%</div>
  118. </div>
  119. </div>
  120. </a>
  121. </li>
  122. </script>
  123. <script>
  124. function initDom() {
  125. var courseId = window.self.courseId;
  126. queryCategory(courseId, function(rows) {
  127. var scriptCourse = document.getElementById('template-chapter-id');
  128. var template = scriptCourse.innerHTML;
  129. var htmlStr = '';
  130. for (var i = 0; i < rows.length; i++) {
  131. var row = rows[i];
  132. htmlStr += render(template, row);
  133. }
  134. var ct = document.getElementById('list');
  135. ct.innerHTML = htmlStr;
  136. });
  137. }
  138. function chapterTapEvent() {
  139. mui('#list').on('tap', 'a', function() {
  140. var chapterTitle = this.getAttribute('data-title');
  141. var chapterId = this.getAttribute('data-chapter-id');
  142. mui.openWindow({
  143. id: 'section-win',
  144. url: this.href,
  145. waiting: {
  146. autoShow: true
  147. },
  148. extras: {
  149. chapterTitle: chapterTitle,
  150. chapterId: chapterId
  151. }
  152. })
  153. });
  154. }
  155. //右上角菜单点击事件(收藏本、错题本)
  156. function rightBarTapEvent() {
  157. mui('#topPopover').on('tap', 'a', function() {
  158. var courseId = this.getAttribute('data-course-id');
  159. var href = this.getAttribute('data-href');
  160. var type = this.getAttribute('data-type');
  161. var title = this.innerHTML;
  162. mui.openWindow({
  163. id: 'bar-' + courseId,
  164. url: href,
  165. waiting: {
  166. autoShow: true
  167. },
  168. extras: {
  169. barTitle: title,
  170. courseId: courseId,
  171. type: type
  172. }
  173. })
  174. mui("#topPopover").popover("toggle");
  175. });
  176. }
  177. //只有ios支持的功能需要在Android平台隐藏;
  178. if (mui.os.android) {
  179. var list = document.querySelectorAll('.ios-only');
  180. if (list) {
  181. for (var i = 0; i < list.length; i++) {
  182. list[i].style.display = 'none';
  183. }
  184. }
  185. }
  186. mui.plusReady(function() {
  187. window.self = plus.webview.currentWebview();
  188. initDom();
  189. var cuotiben = document.getElementById('cuotiben');
  190. var shoucangben = document.getElementById('shoucangben');
  191. cuotiben.setAttribute("data-course-id", window.self.courseId);
  192. shoucangben.setAttribute('data-course-id', window.self.courseId);
  193. chapterTapEvent();
  194. rightBarTapEvent();
  195. //关闭splash页面;
  196. plus.navigator.closeSplashscreen();
  197. });
  198. var index = null; //主页面
  199. function openMenu() {
  200. !index && (index = mui.currentWebview.parent());
  201. mui.fire(index, "menu:open");
  202. }
  203. //在android4.4.2中的swipe事件,需要preventDefault一下,否则触发不正常
  204. // window.addEventListener('dragright', function(e) {
  205. // e.detail.gesture.preventDefault();
  206. // });
  207. //
  208. // //监听右滑事件,若侧滑菜单未显示,右滑要显示菜单;
  209. // window.addEventListener("swiperight", function(e) {
  210. // //默认滑动角度在-45度到45度之间,都会触发右滑菜单,为避免误操作,可自定义限制滑动角度;
  211. // if (Math.abs(e.detail.angle) < 4) {
  212. // openMenu();
  213. // }
  214. // });
  215. </script>
  216. </body>
  217. </html>