var KeyplaceOpenClose=""; var Page = (function() { var $container = $( '#container' ), $bookBlock = $( '#bb-bookblock' ), $items = $bookBlock.children(), itemsCount = $items.length, current = 0, bb = $( '#bb-bookblock' ).bookblock( { speed : 600, perspective : 1800, shadowSides : 0.8, shadowFlip : 0.2, onEndFlip : function(old, page, isLimit) { current = page; // update TOC current updateTOC(); // updateNavigation updateNavigation( isLimit ); // initialize jScrollPane on the content div for the new item setJSP( 'init' ); // destroy jScrollPane on the content div for the old item setJSP( 'destroy', old ); } } ), $navNext_2 = $( '#bb-nav-next-2' ), $navPrev_2 = $( '#bb-nav-prev-2' ), $navNext = $( '#bb-nav-next' ), $navPrev = $( '#bb-nav-prev' ).hide(), $menuItems = $container.find( 'ul.ebook_list > li' ), // - test $tblcontents = $( '#tblcontents' ), $RealMovePage = $('#RealMovePage'), transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' }, transEndEventName = transEndEventNames[Modernizr.prefixed('transition')], supportTransitions = Modernizr.csstransitions, NextBtnAlert = 0; function init() { // initialize jScrollPane on the content div of the first item setJSP( 'init' ); initEvents(); } function initEvents() { // add navigation events $navNext.on( 'click', function() { if (StateRecording==0){ $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.next(); if (ContentEbookPlusSiteID!="20"){//원바이트월드에서 안나오게 하기 if (NextBtnAlert==1){ if (ContentEbookPlusLibraryID!=""){//라이브러리 다시 보기 $.confirm({ title: "Notice", content: "This is the last page.", buttons: { "Close": function () { EbookClose(); }, "Cancel": function () { } } }); }else{ if (KeyplaceOpenClose=="1"){ window.parent.postMessage( "KeyPlaceEbookPlusEnded", '*' );//부모로 메시지 보내기 }else{ $.alert({title: "Notice", content: "This is the last page.", buttons: {"OK" : function(){}} }); } } } } return false; } } ); $navPrev.on( 'click', function() { if (StateRecording==0){ $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.prev(); return false; } } ); $navNext_2.on( 'click', function() { if (StateRecording==0){ $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.next(); return false; } } ); $navPrev_2.on( 'click', function() { if (StateRecording==0){ $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.prev(); return false; } } ); // add swipe events $items.on( { 'swipeleft' : function( event ) { if (StateRecording==0){ if( $container.data( 'opened' ) ) { return false; } $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.next(); return false; } }, 'swiperight' : function( event ) { if (StateRecording==0){ if( $container.data( 'opened' ) ) { return false; } $("#DivDrawCanvasContainer_"+(current+1)).css("visibility","hidden"); bb.prev(); return false; } } } ); // show table of contents $tblcontents.on( 'click', toggleTOC ); // click a menu item - test $menuItems.on( 'click', function() { if (StateRecording==0){ var $el = $( this ), idx = $el.index(), jump = function() { bb.jump( idx + 1 ); }; current !== idx ? closeTOC( jump ) : closeTOC(); return false; } } ); $RealMovePage.on('change', function(){ if (StateRecording==0){ var item_num = $RealMovePage.val(); bb.jump(item_num); } }); $('#menu-toc li').on('click', function(){ if (StateRecording==0){ var item_name=$(this).attr('id'); var item_name_array = item_name.split("_"); var item_num=item_name_array[1]; bb.jump(item_num); } }); // reinit jScrollPane on window resize $( window ).on( 'debouncedresize', function() { // reinitialise jScrollPane on the content div setJSP( 'reinit' ); } ); } function setJSP( action, idx ) { var idx = idx === undefined ? current : idx, $content = $items.eq( idx ).children( 'div.content' ), apiJSP = $content.data( 'jsp' ); if( action === 'init' && apiJSP === undefined ) { $content.jScrollPane({verticalGutter : 0, hideFocus : true }); } else if( action === 'reinit' && apiJSP !== undefined ) { apiJSP.reinitialise(); } else if( action === 'destroy' && apiJSP !== undefined ) { apiJSP.destroy(); } } function updateTOC() { $menuItems.removeClass( 'active' ).eq( current ).addClass( 'active' ); // - test UpdatePage(current); } function updateNavigation( isLastPage ) { NextBtnAlert = 0; if( current === 0 ) { $navNext.show(); $navPrev.hide(); } else if( isLastPage ) { //$navNext.hide(); $navPrev.show(); NextBtnAlert = 1; } else { $navNext.show(); $navPrev.show(); } } function toggleTOC() { var opened = $container.data( 'opened' ); opened ? closeTOC() : openTOC(); } function openTOC() { $navNext.hide(); $navPrev.hide(); $container.addClass( 'slideRight' ).data( 'opened', true ); } function closeTOC( callback ) { updateNavigation( current === itemsCount - 1 ); $container.removeClass( 'slideRight' ).data( 'opened', false ); if( callback ) { if( supportTransitions ) { $container.on( transEndEventName, function() { $( this ).off( transEndEventName ); callback.call(); } ); } else { callback.call(); } } } return { init : init }; })();