PageSourceSearch

https://www.mateli.jp/webcatalog/javascript/BookPreview.js

js mateli.jp collected 2026-10-08 06:46:44 UTC 45,904 bytes, 1,284 lines download raw bytes

1/** 2020.10.22.01**/
2class BookPreviewPublic {
3
4    constructor() {
5        this.isShowAlert = true;
6    }
7
8    setBookConfig(params) {
9        for (var prop in params) {
10            bookConfig[prop] = params[prop];
11        }
12        checkBookConfig();
13    }
14
15    isHasButton(name, enterName) {
16        if (enterName) var button = toolBar.getButton(name, enterName);
17        else var button = toolBar.getButton(name);
18        if (button) return true
19        else return false;
20    }
21
22    toolBarAddNewButton(button) {
23        toolBar.setButtonTitle(button);
24        toolBar.buttons.add(button);
25    }
26
27    showAlert() {
28        if (!this.isShowAlert) return;
29        this.time = 3000;
30
31        if (!this.isShow) {
32            this.isShow = true;
33            var alert = $("<div style='display:none;z-index:99999;padding: 5px 20px;letter-spacing: 1px;left:50%;top:50%;transform:translate(-50%,-50%);-webkit-transform:translate(-50%,-50%);position:absolute;background:rgba(85,85,85,0.5);line-height:40px;font-size:18px;color:#fff;'>此设置无法实时预览,请点击<span style='color:#ffa500'> \"应用设置\" </span>按钮</div>");
34            if (global.templeteName == 'brief') alert.html("此模板不支持实时预览,请点击<span style='color:#ffa500'> \"应用设置\" </span>按钮");
35            tmpContainer.append(alert);
36            alert.fadeIn(200);
37
38            var timer = setInterval(function () {
39                this.time -= 1000;
40                if (this.time <= 0) {
41                    alert.fadeOut(200, function () {
42                        clearInterval(timer);
43                        timer = null;
44                        alert.remove();
45                        this.isShow = false;
46                    }.bind(this));
47                }
48            }.bind(this), 1000);
49
50        }
51    }
52}
53
54class BookPreviewInterface extends BookPreviewPublic {
55    setBackgroundColor(params) { // bgBeginColor bgEndColor bgMRotation backgroundOpacity
56        this.setBookConfig(params);
57        if (backgroundObj != undefined) backgroundObj.resetBgColor();
58    }
59    setBackgroundImage(params) { // backGroundImgURL backgroundPosition
60        this.setBookConfig(params);
61        if (backgroundObj != undefined) backgroundObj.resetBgImg();
62    }
63    setToolbarColor(params) { // toolbarColor ToolBarAlpha
64        this.setBookConfig(params);
65        toolBar.resetToolbarColor();
66    }
67    setToolbarButtonColor(params) { // iconColor iconFontColor
68        this.setBookConfig(params);
69        toolBar.resetButtonColor();
70    }
71    setFormColor(params) { // formBackgroundColor formFontColor
72        this.setBookConfig(params);
73        if (global.aboutBody) global.aboutBody.resetFormColor();
74        if (global.bookmark) global.bookmark.resetFormColor();
75        if (global.downLoadBody) global.downLoadBody.resetFormColor();
76        if (global.helpBody) global.helpBody.resetFormColor();
77        if (global.printBody) global.printBody.resetFormColor();
78        if (global.frmSearch) global.frmSearch.resetFormColor();
79        if (global.sharePanel) global.sharePanel.resetFormColor();
80        if (global.frmTableOfContent) global.frmTableOfContent.resetFormColor();
81        if (global.thumbnail) global.thumbnail.resetFormColor();
82        if (global.videoGallery) global.videoGallery.resetFormColor();
83    }
84    setBookLogo(params) { // appLogoIcon appLogoLinkURL appLogoOpenWindow logoPadding logoTop logoHeight
85        this.setBookConfig(params);
86        if (!bookConfig.appLogoIcon) {
87            $('#logoBar').html('');
88        } else {
89            initLogoBar();
90        }
91    }
92    setBookLargeLogo(params) { // appLargeLogoIcon isFixLogoSize appLargeLogoURL LargeLogoTarget logoFixWidth logoFixHeight
93        this.setBookConfig(params);
94
95        if (bookConfig.appLargeLogoIcon) {
96            if (!global.largeAppLogo) global.largeAppLogo = new AppLargeLogo(bookContainer);
97            else global.largeAppLogo.initCss();
98        } else {
99            if (global.largeAppLogo) global.largeAppLogo.hideLargeLogo();
100        }
101
102    }
103    setFlippingTime(params) { // flippingTime
104        this.setBookConfig(params);
105    }
106    preventPopupTheWebMenu(params) { // isStopMouseMenu
107        this.setBookConfig(params);
108    }
109    showFlipShortcutButton() { // flipshortcutbutton
110        if (bookConfig.flipshortcutbutton) return;
111        bookConfig.flipshortcutbutton = true;
112        if (!global.flipShotButton) global.flipShotButton = new FlipShotButton(tmpContainer);
113        global.flipShotButton.show();
114    }
115    hideFlipShortcutButton() { // flipshortcutbutton
116        if (!bookConfig.flipshortcutbutton) return;
117        bookConfig.flipshortcutbutton = false;
118        if (global.flipShotButton) flipShotButton.hide();
119    }
120    showQRCode() { // QRCode
121        bookConfig.QRCode = true;
122        if (!global.qrButton) global.qrButton = new QRButton(tmpContainer);
123        global.qrButton.resetQRButton();
124    }
125    hideQRCode() { // QRCode
126        if (global.qrCode) global.qrCode.hide();
127        if (global.qrButton) global.qrButton.hide();
128        bookConfig.QRCode = false;
129    }
130    showBackwardForwardButtons() {
131        if (global.templeteName == 'brief') {
132            // if(global.phoneGotoPagePanel) global.phoneGotoPagePanel.resetPosition();
133            this.showAlert();
134            return;
135        }
136        if (bookConfig.enablePageBack || this.isHasButton('backward')) return;
137        bookConfig.enablePageBack = true;
138
139        this.toolBarAddNewButton(new BackwardButton());
140        this.toolBarAddNewButton(new ForwardButton());
141
142        toolBar.sortXMLButton();
143        toolBar.onResize();
144    }
145    hideBackwardForwardButtons() {
146        bookConfig.enablePageBack = false;
147        if (global.templeteName == 'brief') {
148            // if(global.phoneGotoPagePanel) global.phoneGotoPagePanel.resetPosition();
149            this.showAlert();
150            return;
151        } else {
152            toolBar.removeButton('forward');
153            toolBar.removeButton('backward');
154        }
155        toolBar.onResize();
156    }
157    setHomeButtonURL(params) { // HomeURL
158        this.setBookConfig(params);
159    }
160    showHomeButton() {
161        if (global.templeteName == 'brief') {
162            // this.toolBarAddNewButton(new PhoneHomeButton());
163            this.showAlert();
164            return;
165        }
166        if (bookConfig.HomeButtonVisible || this.isHasButton('home')) return;
167        bookConfig.HomeButtonVisible = true;
168        this.toolBarAddNewButton(new HomeButton());
169        toolBar.sortXMLButton();
170        toolBar.onResize();
171    }
172    hideHomeButton() {
173        if (global.templeteName == 'brief') {
174            this.showAlert();
175            return;
176        }
177        if (!bookConfig.HomeButtonVisible) return;
178        bookConfig.HomeButtonVisible = false;
179        toolBar.removeButton('home');
180        toolBar.onResize();
181    }
182    showShareButton() {
183        if (global.templeteName == 'brief') {
184            // this.toolBarAddNewButton(new PhoneShareButton());
185            this.showAlert();
186            return;
187        }
188        if (bookConfig.ShareButtonVisible || this.isHasButton('share', 'sharethis')) return;
189        bookConfig.ShareButtonVisible = true;
190        if (toolBar.btnShare) {
191            toolBar.initShareButton();
192        } else this.toolBarAddNewButton(new ShareButton());
193        toolBar.sortXMLButton();
194        initComponents();
195        toolBar.onResize();
196        global.sharePanel.onResize();
197    }
198    hideShareButton() {
199        if (global.templeteName == 'brief') {
200            this.showAlert();
201            return;
202        }
203        if (!bookConfig.ShareButtonVisible) return;
204        bookConfig.ShareButtonVisible = false;
205
206        if (global.sharePanel) global.sharePanel.hide();
207        var share = toolBar.getButton("ShareButton", 'sharethis');
208        if (toolBar.btnShare) {
209            share = toolBar.btnShare;
210            if (toolBar.shareBevel) toolBar.shareBevel.$body.remove();
211        }
212        toolBar.removeButton(share);
213        toolBar.onResize();
214    }
215
216    setShareButtonParams(params) { // addCurrentPage
217        if (global.templeteName == 'brief') {
218            this.showAlert();
219            return;
220        }
221        this.setBookConfig(params);
222        if (global.sharePanel && global.sharePanel.elements) {
223            global.sharePanel.elements.showOrHideCheck();
224        }
225    }
226
227    showEmailButton() {
228        if (global.templeteName == 'brief') {
229            // this.toolBarAddNewButton(new PhoneEmailButton());
230            this.showAlert();
231            return;
232        }
233        if (bookConfig.EmailButtonVisible || this.isHasButton('email')) return;
234        bookConfig.EmailButtonVisible = true;
235        this.toolBarAddNewButton(new ShareEmailButton());
236        toolBar.sortXMLButton();
237        toolBar.onResize();
238    }
239
240    hideEmailButton() {
241        if (global.templeteName == 'brief') {
242            this.showAlert();
243            return;
244        }
245        if (!bookConfig.EmailButtonVisible) return;
246        bookConfig.EmailButtonVisible = false;
247
248        toolBar.removeButton('email');
249        toolBar.onResize();
250    }
251
252    setEmailShareParams(params) { // btnShareWithEmailSubject btnShareWithEmailBody
253        this.setBookConfig(params);
254    }
255
256    showTelephoneNumberButton() {
257        if (global.templeteName == 'brief') {
258            // this.toolBarAddNewButton(new PhoneNumberButton());
259            this.showAlert();
260            return;
261        }
262        if (!global.phoneNumber.length || this.isHasButton('phoneNumber')) return;
263        bookConfig.PhoneButtonVisible = true;
264        this.toolBarAddNewButton(new TelephoneNumberButton());
265        toolBar.sortXMLButton();
266        toolBar.onResize();
267    }
268
269    hideTelephoneNumberButton() {
270        if (global.templeteName == 'brief') {
271            this.showAlert();
272            return;
273        }
274        if (!this.isHasButton('phoneNumber')) return;
275        bookConfig.PhoneButtonVisible = false;
276
277        toolBar.removeButton('phoneNumber');
278        toolBar.onResize();
279    }
280
281    setTelephoneNumberParams(params) { // PhoneNumbers PhoneButtonIcon PhoneButtonVisible
282        if (global.templeteName == 'brief') {
283            this.showAlert();
284            return;
285        }
286        if (params.PhoneNumbers != undefined) window.phoneNumber = params.PhoneNumbers;
287        this.setBookConfig(params);
288
289        if (window.phoneNumber && window.phoneNumber.length) {
290            if (bookConfig.PhoneButtonVisible) this.showTelephoneNumberButton();
291            if (global.PcTelephoneNumberFrame) global.PcTelephoneNumberFrame.addItem();
292        } else {
293            if (this.isHasButton('phoneNumber')) {
294                toolBar.removeButton('phoneNumber');
295                toolBar.onResize();
296            }
297        }
298
299        if (params.PhoneButtonIcon != undefined) {
300            var button = toolBar.getButton('phoneNumber');
301            if (button) {
302                button.setCustomIcon(bookConfig.PhoneButtonIcon);
303                button.resetImg();
304                button.changeCaptionColor();
305                if (!bookConfig.PhoneButtonIcon) button.changeColor();
306            }
307        }
308
309    }
310
311    showMagnifierButton() {
312        if (global.templeteName == 'brief' || bookConfig.MagnifierButtonVisible || this.isHasButton('MagnifierButton')) return;
313        bookConfig.MagnifierButtonVisible = true;
314        this.toolBarAddNewButton(new MagnifierButton());
315        toolBar.sortXMLButton();
316        toolBar.onResize();
317    }
318
319    hideMagnifierButton() {
320        if (global.templeteName == 'brief' || !bookConfig.MagnifierButtonVisible) return;
321        global.canMagnifierZoom = false;
322        if (BookInfo.getBook()) BookInfo.getBook().unMagnifierZoom();
323        bookConfig.MagnifierButtonVisible = false;
324
325        toolBar.removeButton('MagnifierButton');
326        toolBar.onResize();
327    }
328
329    showWeChatShareButton() {
330        if (global.templeteName == 'brief') {
331            // this.toolBarAddNewButton(new PhoneWeChatShareButton());
332            this.showAlert();
333            return;
334        }
335        if (bookConfig.WeChatShareButtonVisible || this.isHasButton('wechat')) return;
336        bookConfig.WeChatShareButtonVisible = true;
337
338        this.toolBarAddNewButton(new WeChatShareButton());
339
340        toolBar.sortXMLButton();
341        toolBar.onResize();
342    }
343
344    hideWeChatShareButton() {
345        if (global.templeteName == 'brief') {
346            this.showAlert();
347            return;
348        }
349        if (!bookConfig.WeChatShareButtonVisible) return;
350        bookConfig.WeChatShareButtonVisible = false;
351
352        if (global.WeChatShareImg) global.WeChatShareImg.destroy();
353        toolBar.removeButton('wechat');
354        toolBar.onResize();
355    }
356
357    setWeChatShareParams(params) { // WeChatShareButtonIcon
358        this.setBookConfig(params);
359        if (global.templeteName == 'brief') {
360            this.showAlert();
361            return;
362        }
363        var button = toolBar.getButton('wechat');
364        if (button) {
365            button.setCustomIcon(bookConfig.WeChatShareButtonIcon);
366            button.resetImg();
367            button.changeCaptionColor();
368            if (!bookConfig.WeChatShareButtonIcon) {
369                button.changeColor();
370            }
371        }
372    }
373
374    showSoundButton() {
375        if (global.templeteName == 'brief') {
376            // this.toolBarAddNewButton(new PhoneBackgroundSoundButton());
377            this.showAlert();
378            return;
379        }
380        if ((!bookConfig.FlipSound && !bookConfig.BackgroundSoundURL) || this.isHasButton('sound')) return;
381        bookConfig.BackgroundSoundButtonVisible = true;
382        if (toolBar.btnSound) {
383            toolBar.initSoundButton();
384        } else {
385            this.toolBarAddNewButton(new BackgroundSoundButton());
386        }
387        toolBar.sortXMLButton();
388        if (bgSound) bgSound.play();
389        toolBar.onResize();
390        initComponents();
391    }
392    hideSoundButton() {
393        if (global.templeteName == 'brief') {
394            this.showAlert();
395            return;
396        }
397        if (!this.isHasButton('sound')) return;
398        bookConfig.BackgroundSoundButtonVisible = false;
399
400        if (bgSound) bgSound.pause();
401
402        var btnSound = toolBar.getButton('sound');
403        if (toolBar.btnSound) {
404            btnSound = toolBar.btnSound;
405            if (toolBar.soundBevel) toolBar.soundBevel.$body.remove();
406        }
407        toolBar.removeButton(btnSound);
408        toolBar.onResize();
409    }
410    playFlipSound(params) { // FlipSound BackgroundSoundButtonVisible
411        if (global.templeteName == 'brief') {
412            this.showAlert();
413            return;
414        }
415        this.setBookConfig(params);
416
417        if (!bookConfig.FlipSound && !bookConfig.BackgroundSoundURL) {
418            if (this.isHasButton('sound')) this.hideSoundButton();
419        } else {
420            if (bookConfig.BackgroundSoundButtonVisible) {
421                this.showSoundButton();
422            }
423        }
424    }
425    setBackgroundSound(params) { // BackgroundSoundURL BackgroundSoundLoop BackgroundSoundButtonVisible
426        if (global.templeteName == 'brief') {
427            this.showAlert();
428            return;
429        }
430        this.setBookConfig(params);
431        initComponents();
432
433        if (!bookConfig.FlipSound && !bookConfig.BackgroundSoundURL) {
434            if (this.isHasButton('sound')) this.hideSoundButton();
435        } else {
436            if (bookConfig.BackgroundSoundButtonVisible) {
437                this.showSoundButton();
438            }
439        }
440
441        if (global.bgSound.resetResource) global.bgSound.resetResource();
442    }
443    showAutoFlipButton() {
444        if (global.templeteName == 'brief') {
445            // this.toolBarAddNewButton(new PhoneAutoPlayButton());
446            this.showAlert();
447            return;
448        }
449        if (bookConfig.AutoPlayButtonVisible || this.isHasButton('autoplay')) return;
450        bookConfig.AutoPlayButtonVisible = true;
451        if (toolBar.btnAutoPlay) {
452            toolBar.initAutoPlayButton();
453        } else {
454            this.toolBarAddNewButton(new AutoPlayButton());
455        }
456        if (bookConfig.autoPlayAutoStart) {
457            StateSynchronous.instance().findButtons("AutoPlayButton", true).each(function (button) {
458                button.setAsStop();
459                button.executeCallback();
460            });
461        }
462        toolBar.sortXMLButton();
463        toolBar.onResize();
464    }
465    hideAutoFlipButton() {
466        if (global.templeteName == 'brief') {
467            this.showAlert();
468            return;
469        }
470        if (!bookConfig.AutoPlayButtonVisible) return;
471        bookConfig.AutoPlayButtonVisible = false;
472
473        var autoplay = toolBar.getButton('autoplay');
474        if (toolBar.btnAutoPlay) {
475            autoplay = toolBar.btnAutoPlay;
476            if (toolBar.soundBevel) toolBar.soundBevel.$body.remove();
477        }
478        if (!bookConfig.autoPlayAutoStart) {
479            StateSynchronous.instance().findButtons("AutoPlayButton", true).each(function (button) {
480                button.setAsStart();
481                button.executeCallback();
482            });
483        }
484        toolBar.removeButton(autoplay);
485        toolBar.onResize();
486    }
487    setAutoFlipParams(params) { // autoPlayAutoStart
488        this.setBookConfig(params);
489        if (bookConfig.autoPlayAutoStart && auto_player) global.auto_player.start();
490        if (!bookConfig.autoPlayAutoStart && auto_player) global.auto_player.stop();
491    }
492    showThumbnailButton() {
493        if (global.templeteName == 'brief') {
494            // this.toolBarAddNewButton(new PhoneThumbnailButton());
495            this.showAlert();
496            return;
497        }
498        if (bookConfig.ThumbnailsButtonVisible || this.isHasButton('thumbnail')) return;
499        bookConfig.ThumbnailsButtonVisible = true;
500        if (global.templeteName != "active") {
501            if (toolBar.btnThumbnail) {
502                toolBar.initThumbnailButton();
503            } else {
504                this.toolBarAddNewButton(new ThumbnailButton());
505            }
506        }
507
508        toolBar.sortXMLButton();
509        toolBar.onResize();
510        initComponents();
511        global.thumbnail.onResize();
512        if (global.templeteName == "active") thumbnail.show();
513
514        if (BookInfo.isDoublePage(BookInfo.getBookType())) {
515            thumbnail.mergeAll();
516        } else {
517            thumbnail.fissionAll();
518        }
519    }
520    hideThumbnailButton() {
521        if (global.templeteName == 'brief') {
522            this.showAlert();
523            return;
524        }
525        if (!bookConfig.ThumbnailsButtonVisible) return;
526        bookConfig.ThumbnailsButtonVisible = false;
527
528        if (global.thumbnail) global.thumbnail.hide();
529
530        var btnThumbnail = toolBar.getButton('thumbnail');
531        if (toolBar.btnThumbnail) {
532            btnThumbnail = toolBar.btnThumbnail;
533            if (toolBar.thumbBevel) toolBar.thumbBevel.$body.remove();
534        }
535
536        toolBar.removeButton(btnThumbnail);
537        toolBar.onResize();
538    }
539    showPrintButton() {
540        if (global.templeteName == 'brief') {
541            // this.toolBarAddNewButton(new PhonePrintButton());
542            this.showAlert();
543            return;
544        }
545        if (bookConfig.PrintButtonVisible || this.isHasButton('print')) return;
546        bookConfig.PrintButtonVisible = true;
547        this.toolBarAddNewButton(new PrintButton());
548        toolBar.sortXMLButton();
549        toolBar.onResize();
550        initComponents();
551        global.printBody.onResize();
552    }
553    hidePrintButton() {
554        if (global.templeteName == 'brief') {
555            this.showAlert();
556            return;
557        }
558        if (!bookConfig.PrintButtonVisible) return;
559        bookConfig.PrintButtonVisible = false;
560
561        if (global.printBody) global.printBody.hide();
562        toolBar.removeButton('print');
563        toolBar.onResize();
564    }
565    setPrintWatermark(params) { // printWatermarkFile
566        this.setBookConfig(params);
567        if (global.templeteName == 'brief') {
568            this.showAlert();
569            return;
570        }
571    }
572    setZoomOperation(params) { // ZoomButtonVisible SupportOperatePageZoom ZoomToolbarVisible ZoomMapVisible
573        if (global.templeteName == 'brief' || params.SupportOperatePageZoom != undefined) {
574            // this.toolBarAddNewButton(new PhoneZoomButton());
575            this.showAlert();
576            return;
577        }
578        this.setBookConfig(params);
579
580        if (params.ZoomMapVisible || params.ZoomToolbarVisible || params.SupportOperatePageZoom) {
581            this.showAlert();
582        }
583
584        if (bookConfig.ZoomButtonVisible) {
585            if (!this.isHasButton('zoom')) {
586                this.toolBarAddNewButton(new ZoomButton());
587                toolBar.sortXMLButton();
588                toolBar.onResize();
589            }
590        } else {
591            bookConfig.SupportOperatePageZoom = false;
592            bookConfig.ZoomToolbarVisible = false;
593            bookConfig.ZoomMapVisible = false;
594
595            toolBar.removeButton('zoom');
596            toolBar.onResize();
597        }
598    }
599
600    showFullscreenButton() {
601        if (global.templeteName == 'brief' || bookConfig.FullscreenButtonVisible || this.isHasButton('fullscreen')) return;
602        bookConfig.FullscreenButtonVisible = true;
603        this.toolBarAddNewButton(new FullscreenButton());
604        toolBar.sortXMLButton();
605        toolBar.onResize();
606    }
607    hideFullscreenButton() {
608        if (global.templeteName == 'brief' || !bookConfig.FullscreenButtonVisible) return;
609        bookConfig.FullscreenButtonVisible = false;
610        toolBar.removeButton('fullscreen');
611        toolBar.onResize();
612    }
613    showTableOfContentsButton() {
614        if (global.templeteName == 'brief') {
615            // this.toolBarAddNewButton(new PhoneTableOfContentButton());
616            this.showAlert();
617            return;
618        }
619        if (bookConfig.TableOfContentButtonVisible || this.isHasButton('tableofcontent')) return;
620        bookConfig.TableOfContentButtonVisible = true;
621        this.toolBarAddNewButton(new TableOfContentButton());
622        toolBar.sortXMLButton();
623        toolBar.onResize();
624        initComponents();
625        global.frmTableOfContent.onResize();
626    }
627    hideTableOfContentsButton() {
628        if (global.templeteName == 'brief') {
629            this.showAlert();
630            return;
631        }
632        if (!bookConfig.TableOfContentButtonVisible) return;
633        bookConfig.TableOfContentButtonVisible = false;
634
635        if (global.frmTableOfContent && global.frmTableOfContent.visible) global.frmTableOfContent.hide();
636        toolBar.removeButton('tableofcontent');
637        toolBar.onResize();
638    }
639    setShrinkRootNode(params) { // isHideTabelOfContentNodes
640        this.setBookConfig(params);
641        if (!global.frmTableOfContent) return;
642        if (params && params.isHideTabelOfContentNodes != undefined) {
643            if (!bookConfig.isHideTabelOfContentNodes) global.frmTableOfContent.elements.expandItems();
644            else global.frmTableOfContent.elements.collapseItems();
645        }
646    }
647    showBookmarkButton() {
648        if (global.templeteName == 'brief') {
649            // this.toolBarAddNewButton(new PhoneBookmarkButton());
650            this.showAlert();
651            return;
652        }
653        if (bookConfig.BookMarkButtonVisible || this.isHasButton('bookmark')) return;
654        bookConfig.BookMarkButtonVisible = true;
655        this.toolBarAddNewButton(new BookmarkButton());
656        toolBar.sortXMLButton();
657        toolBar.onResize();
658        initComponents();
659        global.bookmark.onResize();
660    }
661    hideBookmarkButton() {
662        if (global.templeteName == 'brief') {
663            this.showAlert();
664            return;
665        }
666        if (!bookConfig.BookMarkButtonVisible) return;
667        bookConfig.BookMarkButtonVisible = false;
668        if (global.bookmark && global.bookmark.visible) global.bookmark.hide();
669        toolBar.removeButton('bookmark');
670        toolBar.onResize();
671    }
672    showAnnotationButton() {
673        if (global.templeteName == 'brief') {
674            // this.toolBarAddNewButton(new PhoneAnnotationButton());
675            this.showAlert();
676            return;
677        }
678        if (bookConfig.AnnotationButtonVisible || this.isHasButton('annotation')) return;
679        bookConfig.AnnotationButtonVisible = true;
680        this.toolBarAddNewButton(new AnnotationButton());
681
682        if (!global.annotationPannel) {
683            global.annotationPannel = new AnnotationPannel(tmpContainer);
684            var pageArray = BookInfo.getBook().pageArray;
685            for (var i = 0; i < pageArray.length; i++) {
686                if (!pageArray[i]) continue;
687                this.getPage().pageAttachments.createAnnotation();
688            }
689        }
690        // global.annotationPannel.show();
691
692        toolBar.sortXMLButton();
693        toolBar.onResize();
694    }
695    getPage() {
696        var index = BookInfo.getBook().currentPageIndex;
697        var page = '';
698        if (bookConfig.FlipStyle.toLocaleLowerCase() == 'slide' && BookInfo.isDoublePage(BookInfo.getBookType())) {
699            if (BookInfo.getBook().pageArray[index].leftPage) page = BookInfo.getBook().pageArray[index].leftPage;
700            else if (BookInfo.getBook().pageArray[index].rightPage) page = BookInfo.getBook().pageArray[index].rightPage;
701
702            if (rightToLeft && BookInfo.getBook().pageArray[index].rightPage) page = BookInfo.getBook().pageArray[index].rightPage;
703        } else {
704            page = BookInfo.getBook().pageArray[index].page;
705        }
706        return page;
707    }
708    hideAnnotationButton() {
709        if (global.templeteName == 'brief') {
710            this.showAlert();
711            return;
712        }
713        if (!bookConfig.AnnotationButtonVisible) return;
714        bookConfig.AnnotationButtonVisible = false;
715
716        if (global.annotationPannel && global.annotationPannel.visible) global.annotationPannel.hide();
717        toolBar.removeButton('annotation');
718        toolBar.onResize();
719    }
720    showSearchButton() {
721        if (global.templeteName == 'brief') {
722            // this.toolBarAddNewButton(new PhoneSearchButton());
723            this.showAlert();
724            return;
725        }
726        if (bookConfig.SearchButtonVisible || this.isHasButton('search')) return;
727        bookConfig.SearchButtonVisible = true;
728
729        if (toolBar.showOrHideSearchBar) {
730            toolBar.showOrHideSearchBar();
731        } else {
732            this.toolBarAddNewButton(new SearchButton());
733            toolBar.sortXMLButton();
734        }
735
736        toolBar.onResize();
737        initComponents();
738        global.frmSearch.onResize();
739    }
740    hideSearchButton() {
741        if (global.templeteName == 'brief') {
742            this.showAlert();
743            return;
744        }
745        if (!bookConfig.SearchButtonVisible) return;
746        bookConfig.SearchButtonVisible = false;
747
748        if (toolBar.showOrHideSearchBar) {
749            toolBar.showOrHideSearchBar();
750        } else {
751            toolBar.removeButton('search');
752        }
753
754        if (global.frmSearch && global.frmSearch.visible) global.frmSearch.hide();
755        toolBar.onResize();
756    }
757    setSearchParams(params) { // leastSearchChar searchKeywordFontColor searchHightlightColor
758        this.setBookConfig(params);
759        if (global.templeteName == 'brief') {
760            this.showAlert();
761            return;
762        }
763        if (!global.frmSearch) return;
764        if (frmSearch.visible && frmSearch.input.val()) {
765            bookConfig.searchKeywordFontColor = Color(bookConfig.searchKeywordFontColor).toString();
766            bookConfig.searchHightlightColor = Color(bookConfig.searchHightlightColor).toString();
767            frmSearch.elements.searchText = '';
768            frmSearch.elements.searchStart();
769        }
770    }
771    showSelectTextButton() {
772        if (global.templeteName == 'brief') {
773            // this.toolBarAddNewButton(new PhoneSelectTextButton());
774            this.showAlert();
775            return;
776        }
777        if (bookConfig.SelectTextButtonVisible || this.isHasButton('select')) return;
778        bookConfig.SelectTextButtonVisible = true;
779        this.toolBarAddNewButton(new SelectTextButton());
780        toolBar.sortXMLButton();
781        toolBar.onResize();
782    }
783    hideSelectTextButton() {
784        if (global.templeteName == 'brief') {
785            this.showAlert();
786            return;
787        }
788        if (!bookConfig.SelectTextButtonVisible) return;
789        bookConfig.SelectTextButtonVisible = false;
790
791        if (BookInfo.getBook().unSelect) BookInfo.getBook().unSelect();
792        toolBar.removeButton('select');
793        toolBar.onResize();
794    }
795    showHelpButton() {
796        if (global.templeteName == 'brief' || bookConfig.HelpButtonVisible || this.isHasButton('help')) return;
797        bookConfig.HelpButtonVisible = true;
798        this.toolBarAddNewButton(new HelpButton());
799        toolBar.sortXMLButton();
800        toolBar.onResize();
801        initComponents();
802        global.helpBody.onResize();
803    }
804    hideHelpButton() {
805        if (global.templeteName == 'brief' || !bookConfig.HelpButtonVisible) return;
806        bookConfig.HelpButtonVisible = false;
807        toolBar.removeButton('help');
808        toolBar.onResize();
809    }
810    showAboutButton() {
811        if (global.templeteName == 'brief') {
812            // this.toolBarAddNewButton(new PhoneAboutButton());
813            this.showAlert();
814            return;
815        }
816        if (bookConfig.aboutButtonVisible || this.isHasButton('about')) return;
817        bookConfig.aboutButtonVisible = true;
818        this.toolBarAddNewButton(new AboutButton());
819        toolBar.sortXMLButton();
820        toolBar.onResize();
821        initComponents();
822        global.aboutBody.onResize();
823    }
824    hideAboutButton() {
825        if (global.templeteName == 'brief') {
826            this.showAlert();
827            return;
828        }
829        if (!bookConfig.aboutButtonVisible) return;
830        bookConfig.aboutButtonVisible = false;
831
832        toolBar.removeButton('about');
833        toolBar.onResize();
834    }
835    setBookAboutInfo(params) { // CompanyLogoFile AboutAuthor AboutEmail AboutWebsite AboutMobile AboutAddress AboutDescription
836        this.setBookConfig(params);
837        if (global.templeteName == 'brief') {
838            this.showAlert();
839            return;
840        }
841        if (!global.aboutBody) return;
842        if (global.aboutBody.elements) global.aboutBody.elements.resetAboutHtml();
843        if (global.aboutBody.initLogo) global.aboutBody.initLogo();
844        if (global.aboutBody.aboutSwiper) global.aboutBody.aboutSwiper.refreshData();
845    }
846    showDownloadButton() {
847        if (global.templeteName == 'brief') {
848            // this.toolBarAddNewButton(new PhoneDownloadButton());
849            this.showAlert();
850            return;
851        }
852        if (bookConfig.DownloadButtonVisible || this.isHasButton('download')) return;
853        bookConfig.DownloadButtonVisible = true;
854        this.toolBarAddNewButton(new DownloadButton());
855        toolBar.sortXMLButton();
856        toolBar.onResize();
857    }
858    hideDownloadButton() {
859        if (global.templeteName == 'brief') {
860            this.showAlert();
861            return;
862        }
863        if (!bookConfig.DownloadButtonVisible) return;
864        bookConfig.DownloadButtonVisible = false;
865
866        toolBar.removeButton('download');
867        toolBar.onResize();
868    }
869    setDownloadURL(params) { // DownloadURL
870        this.setBookConfig(params);
871    }
872
873    setPageCaption(params) { // totalPagesCaption pageNumberCaption
874        if (global.templeteName == 'brief') {
875            this.showAlert();
876            return;
877        }
878        this.setBookConfig(params);
879        setCurrentIndexTextField();
880    }
881
882    //xiayuting
883    resetBookConfig(params) {
884        // retainBookCenter isTheBookOpen
885        // isHardCover hardCoverBorderWidth cornerRound borderColor outerCoverBorder coverTexture isHardPage
886        // pageBackgroundColor
887        // thicknessWidthType thicknessColor
888        // leftMargin topMargin rightMargin bottomMargin
889        // bleedAreaLeft bleedAreaTop bleedAreaRight bleedAreaBottom
890        // BindingType
891        // ShowTopLeftShadow LeftShadowWidth LeftShadowAlpha RightShadowWidth RightShadowAlpha
892        this.setBookConfig(params);
893        this.resetBook();
894    }
895    showAsSinglePage(params) { // showMirrorSide SingleModeBanFlipToLastPage
896        if (bookConfig.autoDoublePage) {
897            this.showAlert();
898            return;
899        } else {
900            this.setBookConfig(params);
901            this.resetBook();
902        }
903    }
904
905    mouseWheelFlip(params) { // mouseWheelFlip
906        this.setBookConfig(params);
907    }
908    curlingPageCorner(params) { // CurlingPageCorner
909        this.setBookConfig(params);
910    }
911    resetBook() {
912        bookConfig.OriginPageIndex = BookInfo.getCurrentPageIndex();
913
914        if (window.flipBook) {
915            flipBook.flipBook.remove();
916            flipBook.destroy();
917            flipBook = null;
918        }
919        if (window.singlePageBook) {
920            singlePageBook.flipBook.remove();
921            singlePageBook.destroy();
922            singlePageBook = null;
923        }
924        if (window.slideBook) {
925            slideBook.flipBook.remove();
926            slideBook.destroy();
927            slideBook = null;
928        }
929        if (window.singleSlideBook) {
930            singleSlideBook.flipBook.remove();
931            singleSlideBook.destroy();
932            singleSlideBook = null;
933        }
934        if (window.catalogBook) {
935            catalogBook.flipBook.remove();
936            catalogBook.destroy();
937            catalogBook = null;
938        }
939        if (window.singleCatalogBook) {
940            singleCatalogBook.flipBook.remove();
941            singleCatalogBook.destroy();
942            singleCatalogBook = null;
943        }
944
945        global.bookType = (bookConfig.showDoublePage != "single") ? 0 : 1;
946        global.rightToLeft = parseBool(bookConfig.RightToLeft, false);
947        global.originTotalPageCount = parseInt(bookConfig.totalPageCount);
948        global.totalPageCount = originTotalPageCount +
949            (((originTotalPageCount % 2 == 1 && !bookConfig.isTheBookOpen) ||
950                (originTotalPageCount % 2 == 0 && bookConfig.isTheBookOpen)) ? 1 : 0);
951        initBook();
952        changeShowBook(bookType);
953        changeShowBookByWindow();
954    }
955}
956
957var BookPreview = new BookPreviewInterface();
958
959class KeyBridge {
960
961    constructor(params) {
962        this.params = params;
963        var functionName = this.getFunctionName(this.params);
964        if (functionName && BookPreview[functionName])
965            BookPreview[functionName](this.params);
966            
967        return {
968            'functionName' : functionName
969        }
970    }
971
972    getFunctionName(params) {
973        var prop = Object.keys(params)[0];
974        switch (prop) {
975            case "bgBeginColor":
976            case "bgEndColor":
977            case "bgMRotation":
978            case "backgroundOpacity": {
979                return "setBackgroundColor";
980            }
981            case "backGroundImgURL":
982            case "backgroundPosition": {
983                return "setBackgroundImage";
984            }
985            case "toolbarColor":
986            case "ToolBarAlpha": {
987                return "setToolbarColor";
988            }
989            case "iconColor":
990            case "iconFontColor": {
991                return "setToolbarButtonColor";
992            }
993            case "formBackgroundColor":
994            case "formFontColor": {
995                return "setFormColor";
996            }
997            case "appLogoIcon":
998            case "appLogoLinkURL":
999            case "appLogoOpenWindow":
1000            case "logoPadding":
1001            case "logoTop":
1002            case "logoHeight": {
1003                return "setBookLogo";
1004            }
1005            case "appLargeLogoIcon":
1006            case "isFixLogoSize":
1007            case "appLargeLogoURL":
1008            case "LargeLogoTarget":
1009            case "logoFixWidth":
1010            case "logoFixHeight": {
1011                return "setBookLargeLogo";
1012            }
1013            case "flippingTime": {
1014                return "setFlippingTime";
1015            }
1016            case "isStopMouseMenu": {
1017                return "preventPopupTheWebMenu";
1018            }
1019            case "flipshortcutbutton": {
1020                if (parseBool(this.params["flipshortcutbutton"], false)) {
1021                    return "showFlipShortcutButton";
1022                } else {
1023                    return "hideFlipShortcutButton";
1024                }
1025            }
1026            case "QRCode": {
1027                if (parseBool(this.params["QRCode"], false)) {
1028                    return "showQRCode";
1029                } else {
1030                    return "hideQRCode";
1031                }
1032            }
1033            case "enablePageBack": {
1034                if (parseBool(this.params["enablePageBack"], false)) {
1035                    return "showBackwardForwardButtons";
1036                } else {
1037                    return "hideBackwardForwardButtons";
1038                }
1039            }
1040            case "HomeURL": {
1041                return "setHomeButtonURL";
1042            }
1043            case "HomeButtonVisible": {
1044                if (parseBool(this.params["HomeButtonVisible"], false)) {
1045                    return "showHomeButton";
1046                } else {
1047                    return "hideHomeButton";
1048                }
1049            }
1050            case "ShareButtonVisible": {
1051                if (parseBool(this.params["ShareButtonVisible"], false)) {
1052                    return "showShareButton";
1053                } else {
1054                    return "hideShareButton";
1055                }
1056            }
1057            case "addCurrentPage": {
1058                return "setShareButtonParams";
1059            }
1060            case "EmailButtonVisible": {
1061                if (parseBool(this.params["EmailButtonVisible"], false)) {
1062                    return "showEmailButton";
1063                } else {
1064                    return "hideEmailButton";
1065                }
1066            }
1067            case "btnShareWithEmailSubject":
1068            case "btnShareWithEmailBody": {
1069                return "setEmailShareParams";
1070            }
1071            case "PhoneButtonVisible": {
1072                if (parseBool(this.params["PhoneButtonVisible"], false)) {
1073                    return "showTelephoneNumberButton";
1074                } else {
1075                    return "hideTelephoneNumberButton";
1076                }
1077            }
1078            case "PhoneNumbers":
1079            case "PhoneButtonIcon": {
1080                return "setTelephoneNumberParams";
1081            }
1082            case "MagnifierButtonVisible": {
1083                if (parseBool(this.params["MagnifierButtonVisible"], false)) {
1084                    return "showMagnifierButton";
1085                } else {
1086                    return "hideMagnifierButton";
1087                }
1088            }
1089            case "WeChatShareButtonVisible": {
1090                if (parseBool(this.params["WeChatShareButtonVisible"], false)) {
1091                    return "showWeChatShareButton";
1092                } else {
1093                    return "hideWeChatShareButton";
1094                }
1095            }
1096            case "WeChatShareButtonIcon": {
1097                return "setWeChatShareParams";
1098            }
1099            case "BackgroundSoundButtonVisible": {
1100                if (parseBool(this.params["BackgroundSoundButtonVisible"], false)) {
1101                    return "showSoundButton";
1102                } else {
1103                    return "hideSoundButton";
1104                }
1105            }
1106            case "FlipSound":
1107            case "BackgroundSoundButtonVisible": {
1108                return "playFlipSound";
1109            }
1110            case "BackgroundSoundURL":
1111            case "BackgroundSoundLoop":
1112            case "BackgroundSoundButtonVisible": {
1113                return "setBackgroundSound";
1114            }
1115            case "AutoPlayButtonVisible": {
1116                if (parseBool(this.params["AutoPlayButtonVisible"], false)) {
1117                    return "showAutoFlipButton";
1118                } else {
1119                    return "hideAutoFlipButton";
1120                }
1121            }
1122            case "autoPlayAutoStart": {
1123                return "setAutoFlipParams";
1124            }
1125            case "ThumbnailsButtonVisible": {
1126                if (parseBool(this.params["ThumbnailsButtonVisible"], false)) {
1127                    return "showThumbnailButton";
1128                } else {
1129                    return "hideThumbnailButton";
1130                }
1131            }
1132            case "PrintButtonVisible": {
1133                if (parseBool(this.params["PrintButtonVisible"], false)) {
1134                    return "showPrintButton";
1135                } else {
1136                    return "hidePrintButton";
1137                }
1138            }
1139            case "printWatermarkFile": {
1140                return "setPrintWatermark";
1141            }
1142            case "ZoomButtonVisible":
1143            case "SupportOperatePageZoom":
1144            case "ZoomToolbarVisible":
1145            case "ZoomMapVisible": {
1146                return "setZoomOperation";
1147            }
1148            case "FullscreenButtonVisible": {
1149                if (parseBool(this.params["FullscreenButtonVisible"], false)) {
1150                    return "showFullscreenButton";
1151                } else {
1152                    return "hideFullscreenButton";
1153                }
1154            }
1155            case "TableOfContentButtonVisible": {
1156                if (parseBool(this.params["TableOfContentButtonVisible"], false)) {
1157                    return "showTableOfContentsButton";
1158                } else {
1159                    return "hideTableOfContentsButton";
1160                }
1161            }
1162            case "BookMarkButtonVisible": {
1163                if (parseBool(this.params["BookMarkButtonVisible"], false)) {
1164                    return "showBookmarkButton";
1165                } else {
1166                    return "hideBookmarkButton";
1167                }
1168            }
1169            case "isHideTabelOfContentNodes": {
1170                return "setShrinkRootNode";
1171            }
1172            case "AnnotationButtonVisible": {
1173                if (parseBool(this.params["AnnotationButtonVisible"], false)) {
1174                    return "showAnnotationButton";
1175                } else {
1176                    return "hideAnnotationButton";
1177                }
1178            }
1179            case "SearchButtonVisible": {
1180                if (parseBool(this.params["SearchButtonVisible"], false)) {
1181                    return "showSearchButton";
1182                } else {
1183                    return "hideSearchButton";
1184                }
1185            }
1186            case "leastSearchChar":
1187            case "searchKeywordFontColor":
1188            case "searchHightlightColor": {
1189                return "setSearchParams";
1190            }
1191            case "SelectTextButtonVisible": {
1192                if (parseBool(this.params["SelectTextButtonVisible"], false)) {
1193                    return "showSelectTextButton";
1194                } else {
1195                    return "hideSelectTextButton";
1196                }
1197            }
1198            case "HelpButtonVisible": {
1199                if (parseBool(this.params["HelpButtonVisible"], false)) {
1200                    return "showHelpButton";
1201                } else {
1202                    return "hideHelpButton";
1203                }
1204            }
1205            case "aboutButtonVisible": {
1206                if (parseBool(this.params["aboutButtonVisible"], false)) {
1207                    return "showAboutButton";
1208                } else {
1209                    return "hideAboutButton";
1210                }
1211            }
1212            case "DownloadButtonVisible": {
1213                if (parseBool(this.params["DownloadButtonVisible"], false)) {
1214                    return "showDownloadButton";
1215                } else {
1216                    return "hideDownloadButton";
1217                }
1218            }
1219            case "CompanyLogoFile":
1220            case "AboutAuthor":
1221            case "AboutEmail":
1222            case "AboutWebsite":
1223            case "AboutMobile":
1224            case "AboutAddress":
1225            case "AboutDescription": {
1226                return "setBookAboutInfo";
1227            }
1228            case "DownloadURL": {
1229                return "setDownloadURL";
1230            }
1231            case "totalPagesCaption":
1232            case "pageNumberCaption": {
1233                return "setPageCaption";
1234            }
1235            case "mouseWheelFlip": {
1236                return "mouseWheelFlip";
1237            }
1238            case "CurlingPageCorner": {
1239                return "curlingPageCorner";
1240            }
1241            case "retainBookCenter":
1242            case "isTheBookOpen":
1243            case "HardPageEnable":
1244            case "hardCoverBorderWidth":
1245            case "cornerRound":
1246            case "borderColor":
1247            case "outerCoverBorder":
1248            case "coverTexture":
1249            case "HardInnerPageEnable":
1250            case "pageBackgroundColor":
1251            case "thicknessWidthType":
1252            case "thicknessColor":
1253            case "leftMargin":
1254            case "topMargin":
1255            case "rightMargin":
1256            case "bottomMargin":
1257            case "bleedAreaLeft":
1258            case "bleedAreaTop":
1259            case "bleedAreaRight":
1260            case "bleedAreaBottom":
1261            case "BindingType":
1262            case "ShowTopLeftShadow":
1263            case "LeftShadowWidth":
1264            case "LeftShadowAlpha":
1265            case "RightShadowWidth":
1266            case "RightShadowAlpha": {
1267                return "resetBookConfig";
1268            }
1269            case "showMirrorSide":
1270            case "SingleModeBanFlipToLastPage": {
1271                return "showAsSinglePage";
1272            }
1273            default: {
1274                return "showAlert";
1275            }
1276        }
1277    }
1278
1279}
1280
1281//Custom settings
1282// new KeyBridge({bgBeginColor:"#ffffff"});
1283//还原的时候不弹出提示
1284//BookPreview.isShowAlert = false;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.