|
38 | 38 | e.preventDefault();
|
39 | 39 | });
|
40 | 40 | self.sidebar = Object.create(p.Sidebar).init('#sidebar', self);
|
41 |
| - self.indexBtn = Object.create(p.IndexBtn).init('#sidebar .index_btn', self); |
| 41 | + self.buttons = Object.create(p.Buttons).init('#sidebar .buttons', self); |
42 | 42 | self.content = Object.create(window.shiu.ui.Content).init('#content', self);
|
43 | 43 | self.$heroUnit.one('click', function () {
|
44 | 44 | self.app.startRead();
|
|
56 | 56 | isOrientation = isOrientation || false;
|
57 | 57 | var x = window.screen.width,
|
58 | 58 | y = document.body.scrollHeight;
|
59 |
| - //$('#body').css('width', x + 'px'); |
60 |
| - //$('#main').css('width', x + 'px'); |
61 |
| - //$('#index').css('width', x + 'px'); |
62 |
| - //$('#content .chapter').css('width', x + 'px'); |
63 |
| - //$('#content .chapter').css('-moz-column-width', x + 'px'); |
64 |
| - //$('#content .chapter').css('-webkit-column-width', x + 'px'); |
65 |
| - //$('#body').css('height', y + 'px'); |
66 |
| - //$('#main').css('height', y + 'px'); |
67 |
| - //$('#index').css('height', y + 'px'); |
68 |
| - //$('#content').css('height', y + 'px'); |
69 | 59 | if (isOrientation) {
|
70 | 60 | this.SCREEN_WIDTH = y;
|
71 | 61 | this.SCREEN_HEIGHT = x;
|
|
210 | 200 | window.shiu.ui.Sidebar = Sidebar;
|
211 | 201 | }());
|
212 | 202 |
|
213 |
| -// 目录菜单按钮 |
| 203 | +// 菜单按钮 |
214 | 204 | (function () {
|
215 | 205 | 'use strict';
|
216 |
| - var IndexBtn = { |
| 206 | + var Buttons = { |
217 | 207 |
|
218 | 208 | init: function (selector, ui) {
|
219 | 209 | var self = this;
|
220 | 210 | self.$ = $(selector);
|
| 211 | + self.$index = $(selector).children('.index_btn'); |
| 212 | + self.$fontZi = $(selector).children('.font_zi_btn'); |
| 213 | + self.$fontZo = $(selector).children('.font_zo_btn'); |
221 | 214 | self.ui = ui;
|
222 | 215 | self.bindTouchStart();
|
223 | 216 | return self;
|
|
246 | 239 |
|
247 | 240 | bindTouchStart: function () {
|
248 | 241 | var self = this;
|
249 |
| - self.$.bind('touchstart', function (e) { |
| 242 | + self.$index.bind('touchstart', function (e) { |
250 | 243 | self.ui.sidebar.toggle();
|
251 | 244 | e.stopPropagation();
|
252 | 245 | return false;
|
253 | 246 | });
|
| 247 | + self.$fontZi.bind('touchstart', function (e) { |
| 248 | + self.ui.content.incFontSize(); |
| 249 | + e.stopPropagation(); |
| 250 | + return false; |
| 251 | + }); |
| 252 | + self.$fontZo.bind('touchstart', function (e) { |
| 253 | + self.ui.content.decFontSize(); |
| 254 | + e.stopPropagation(); |
| 255 | + return false; |
| 256 | + }); |
254 | 257 | },
|
255 | 258 |
|
256 | 259 | bindDragEnd: function () { // TODO 暂时不用
|
257 | 260 | var self = this;
|
258 |
| - self.$.ondragend = function (e) { |
| 261 | + self.$index.ondragend = function (e) { |
259 | 262 | self.ui.sidebar.show();
|
260 | 263 | };
|
261 | 264 | }
|
262 | 265 |
|
263 | 266 | };
|
264 | 267 |
|
265 |
| - window.shiu.ui.IndexBtn = IndexBtn; |
| 268 | + window.shiu.ui.Buttons = Buttons; |
266 | 269 | }());
|
267 | 270 |
|
268 | 271 | // 书籍内容模块 Content
|
|
292 | 295 | if (!self.isTouchEvent) {
|
293 | 296 | if (x < self.ui.SCREEN_WIDTH * 0.25) {
|
294 | 297 | self.ui.app.prePage();
|
295 |
| - self.ui.indexBtn.hide(); |
| 298 | + self.ui.buttons.hide(); |
296 | 299 | } else if (x > self.ui.SCREEN_WIDTH * 0.75) {
|
297 | 300 | self.ui.app.nextPage();
|
298 |
| - self.ui.indexBtn.hide(); |
| 301 | + self.ui.buttons.hide(); |
299 | 302 | } else {
|
300 |
| - self.ui.indexBtn.toggle(); |
| 303 | + self.ui.buttons.toggle(); |
301 | 304 | }
|
302 | 305 | }
|
303 | 306 | });
|
|
367 | 370 | self.$chapter.css('height',
|
368 | 371 | (self.ui.SCREEN_HEIGHT - self.ui.SCREEN_BOTTOM_HEIGHT) + 'px');
|
369 | 372 | self.$chapter.css('-webkit-column-width', self.ui.SCREEN_WIDTH + 'px');
|
| 373 | + self.$chapter.children('p').css('font-size', self.ui.app.book.getFontSize()); |
370 | 374 | },
|
371 | 375 |
|
372 | 376 | setPage: function (page) {
|
|
376 | 380 | },
|
377 | 381 |
|
378 | 382 | getPageCount: function () {
|
379 |
| - return (this.$chapter.children().last().offset().left - |
380 |
| - this.ui.SCREEN_PADDING) |
| 383 | + return ((this.$chapter.find('.end').offset().left - this.$chapter.children().first().offset().left)) |
381 | 384 | / (this.ui.SCREEN_WIDTH + this.ui.SCREEN_COLUMN_GAP)
|
382 | 385 | + 1;
|
| 386 | + }, |
| 387 | + |
| 388 | + incFontSize: function () { |
| 389 | + var self = this, |
| 390 | + size = parseInt(self.$chapter.children('p').css('font-size'), 10); |
| 391 | + if (size < 32) { |
| 392 | + self.$chapter.children('p').css('font-size', (size + 2) + 'px'); |
| 393 | + } |
| 394 | + self.ui.app.book.setPageCount(self.getPageCount()); |
| 395 | + self.ui.app.book.setFontSize(size); |
| 396 | + }, |
| 397 | + |
| 398 | + decFontSize: function () { |
| 399 | + var self = this, |
| 400 | + size = parseInt(self.$chapter.children('p').css('font-size'), 10); |
| 401 | + if (size > 12) { |
| 402 | + self.$chapter.children('p').css('font-size', (size - 2) + 'px'); |
| 403 | + } |
| 404 | + self.ui.app.book.setPageCount(self.getPageCount()); |
| 405 | + self.ui.app.book.setFontSize(size); |
| 406 | + |
| 407 | + // 过载保护 |
| 408 | + if (self.ui.app.book.getPageCount() <= self.ui.app.book.getCurrentPage()) { |
| 409 | + self.ui.app.prePage(); |
| 410 | + } |
383 | 411 | }
|
384 | 412 |
|
385 | 413 | };
|
|
0 commit comments