1
Surpriseplus
2022-09-16 8d1a91c23df335b090e38b2edd15203aa3b03da9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
 
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
  <meta name="format-detection" content="telephone=no">
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <title>Turn.js 实现翻书效果</title>
  <link rel="stylesheet" type="text/css" href="css/basic.css" />
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" src="js/modernizr.2.5.3.min.js"></script>
 
</head>
 
<body>
  <div class="shade">
 
    <div class="number"></div>
  </div>
  <div class="flipbook-viewport" style="display:none;">
    <div class="previousPage" style="display:none;"></div>
    <div class="nextPage"></div>
    <!-- <div class="return"></div> -->
    <!-- <img class="btnImg" src="./image/btn.gif" />  -->
    <div class="container">
      <div class="flipbook">
        <div style=" background:url(image/1.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/2.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/3.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/4.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/5.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/6.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/7.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/8.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/9.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/10.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/11.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/12.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/13.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/14.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/15.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/16.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/17.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/18.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/19.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/20.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/21.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/22.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/23.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/24.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/25.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/26.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/27.png) no-repeat center;background-size:100% 100%"></div>
        <div style=" background:url(image/28.png) no-repeat center;background-size:100% 100%"></div>
      </div>
    </div>
  </div>
  <script>
    //自定义仿iphone弹出层
    (function ($) {
      $(".flipbook-viewport").show();
      $(".shade").hide();
      function loadApp () {
        var w = $(window).width();
        var h = $(window).height();
        //   var w = "900px";
        //   var h = "600px";
        $(".flipboox").width(w).height(h);
        $(window).resize(function () {
          w = $(window).width();
          h = $(window).height();
          // w = "900px";
          // h = "600px";
          $(".flipboox").width(w).height(h);
        });
        $(".flipbook").turn({
          // Width
          width: w,
          // Height
          height: h,
          // Elevation
          elevation: 50,
          display: "single",
          // Enable gradients
          gradients: true,
          // Auto center this flipbook
          // autoCenter: true,
 
          when: {
            turning: function (e, page, view) {
              var total = $(".flipbook").turn("pages"); //总页数
              if (page !== 1) {
                $(".previousPage").css("display", "block");
              }
              if (page == total) {
                $(".nextPage").css("display", "none");
              }
              if (page !== total) {
                $(".nextPage").css("display", "block");
              }
            },
            turned: function (e, page, view) {
              var total = $(".flipbook").turn("pages"); //总页数
              if (page == 1) {
                $(".previousPage").css("display", "none");
              }
              if (page == total) {
                $(".nextPage").css("display", "none");
              }
            },
          },
        });
      }
      yepnope({
        test: Modernizr.csstransforms,
        yep: ["js/turn.js"],
        complete: loadApp,
      });
      //ios confirm box
      // jQuery.fn.confirm = function (title, option, okCall, cancelCall) {
      //     var defaults = {
      //         title: null, //what text
      //         cancelText: '取消', //the cancel btn text
      //         okText: '确定' //the ok btn text
      //     };
 
      //     if (undefined === option) {
      //         option = {};
      //     }
      //     if ('function' != typeof okCall) {
      //         okCall = $.noop;
      //     }
      //     if ('function' != typeof cancelCall) {
      //         cancelCall = $.noop;
      //     }
 
      //     var o = $.extend(defaults, option, {title: title, okCall: okCall, cancelCall: cancelCall});
 
      //     var $dom = $(this);
 
      //     var dom = $('<div class=" g-plugin-confirm">');
      // var dom1 = $('<div>').appendTo(dom);
      // var dom_content = $('<div>').html(o.title).appendTo(dom1);
      // var dom_btn = $('<div>').appendTo(dom1);
      // var btn_cancel = $('<a href="#"></a>').html(o.cancelText).appendTo(dom_btn);
      // var btn_ok = $('<a href="#"></a>').html(o.okText).appendTo(dom_btn);
      // btn_cancel.on('click', function (e) {
      // o.cancelCall();
      // dom.remove();
      // e.preventDefault();
      // });
      // btn_ok.on('click', function (e) {
      // o.okCall();
      // dom.remove();
      // e.preventDefault();
      // });
 
      // dom.appendTo($('body'));
      // return $dom;
      // };
 
    })(jQuery);
 
    $(".previousPage").bind("click", function () {
      var pageCount = $(".flipbook").turn("pages"); //总页数
      var currentPage = $(".flipbook").turn("page"); //当前页
      if (currentPage >= 2) {
        $(".flipbook").turn("page", currentPage - 1);
      } else {
      }
    });
    // 下一页
    $(".nextPage").bind("click", function () {
      var pageCount = $(".flipbook").turn("pages"); //总页数
      var currentPage = $(".flipbook").turn("page"); //当前页
      if (currentPage <= pageCount) {
        $(".flipbook").turn("page", currentPage + 1);
      } else {
      }
    });
 
    //返回到目录页
    $(".return").bind("touchend", function () {
      $(document).confirm('您确定要返回首页吗?', {}, function () {
        $(".flipbook").turn('page', 1); //跳转页数
      }, function () {
      });
    });
  </script>
  <!-- <script type="text/javascript" src="js/main.js"></script> -->
</body>
 
</html>