(function($){
////configuration
var width_book //width book
var height_book //height book
var book_slug; //slug for book
var window_width; //width area [px]
var window_height; //height area [px]
var zoom_step //steps size for zoom
var zoom_double_click_enabled; //enabled double click for zoom
var zoom_double_click; //zoom for double click
var gotopage_width; //width for input field
var is_as_template //if this template
var tool_tip_visible //tooltip visible
var swf_address //swf address
var tools_visible //toolbar visible
var rtl //right to left
/* = event ready
--------------------------*/
$(document).ready(function(e) {
if( general.browser_firefox() ) {
console.log('book:version jquery = '+$.fn.jquery);
}
book_v7.ready();
});
$(window).load(function(e){
book_v7.load()
})
/* = set page
--------------------------*/
setpage=function(nr_) {
if( swf_address == "true" ){
var results= $("#fb7-deeplinking ul li[data-page="+nr_+"]");
var address = results.attr('data-address');
setaddress( $('#fb7').attr('data-current')+"/"+address);
}else{
$('#fb7-book').turn('page',nr_);
}
};
/* = set address
--------------------------*/
setaddress=function(address_) {
$.address.value( address_ );
};
/* = show lightbox with video
--------------------------*/
youtube=function(id_,w_,h_) {
var w=w_;
var h=h_;
var id=id_;
$('body').prepend('
');
$(window).trigger('orientationchange');
$("#v7_lightbox").click(function(){
$(this).children().hide();
$(this).remove();
book_v7.zoomauto();
})
$("#v7_lightbox").css('display','block');
};
/* = prototype
--------------------------*/
number.prototype.rtl=function()
{
return (book_v7.getlength()+1)-this.valueof();
}
/* = local general function
--------------------------*/
var general={
browser_firefox:function(){
if(navigator.useragent.tolowercase().indexof('firefox') > -1) {
return true;
}else{
return false;
}
}
}
/* = flipbook v7
--------------------------*/
var book_v7 = {
toolsheight:0, //tools height
zoom:1, //zoom
page_padding:0.1,
paddingl:0.06,
paddingr:0.06,
paddingt:0.05,
paddingb:0.05,
currentpage:0,
ready: function(){
if( general.browser_firefox() ) {
console.log('book:ready');
}
///even and odd using jquery
//$("#fb7-book > div:odd").addclass("odd");
///even and odd
//$("#fb7-book > div:even").addclass("even");
//configuration
var config=$('#fb7-ajax').data('config');
book_v7.config=config;
width_book=number(config['page_width'])*2;
height_book=number(config['page_height']);
zoom_step=number(config['zoom_step']);
zoom_double_click_enabled=(config['double_click_enabled']);
zoom_double_click=number(config['zoom_double_click'])
gotopage_width=number(config['gotopage_width']);
tool_tip_visible=(config['tooltip_visible']);
swf_address=(config['deeplinking_enabled']);
rtl=config['rtl'];
//add class 'even' and 'odd' using jquery
if( rtl == "false" ){
$("#fb7-book > div:odd").addclass("odd");
$("#fb7-book > div:even").addclass("even");
}else{
$("#fb7-book > div:odd").addclass("even");
$("#fb7-book > div:even").addclass("odd");
}
is_as_template= $('#fb7-ajax').attr('data-template') == "true" ? true : false;
tools_visible=(config['toolbar_visible']);
if( tools_visible == "true" ){
book_v7.toolsheight=69;
}else{
book_v7.toolsheight=0;
}
window_width=$('#fb7').width();
window_height=$('#fb7').height();
///about show
$('#fb7-about').css('display','block');
//event resize
$(window).bind('orientationchange resize', function(event){
book_v7.book_area();
book_v7.zoomauto();
book_v7.book_position();
book_v7.dragdrop_init();
book_v7.resize_page()
book_v7.center($('#v7_lightbox'));
book_v7.center_icon();
book_v7.center_icon();
book_v7.media_queries()
});
//reverse book
$( $('#fb7-book>div').get().reverse() ).each(function(index,element) {
var item=$(element);
var meta=$('div.fb7-meta',this);
///for only reverse
if( rtl == "true" ){
//reverse
$(this).appendto( $(this).parent() );
//reorder description and number
var desc=$('span.fb7-description',item);
if( desc.index() ==0 ){
//desc.appendto(meta);
}else{
//desc.prependto(meta);
}
///for double
if( item.hasclass('fb7-double') ){
if( item.hasclass('fb7-first') ){
item.removeclass('fb7-first').addclass('fb7-second');
}else if( item.hasclass('fb7-second') ){
item.removeclass('fb7-second').addclass('fb7-first');
}
}
//add data for meta
if( index%2!=0 ){
//meta.addclass('fb5-left');
}else{
//meta.addclass('fb5-right');
}
}else{
//add data for meta
if( index%2==0 ){
//meta.addclass('fb5-left');
}else{
//meta.addclass('fb5-right');
}
}
});
//preloader start
var preloader_visible=book_v7.config['preloader_visible'];
if( preloader_visible=="true"){
$('.fb7-preloader').css('display','block');
}
book_v7.resize_input_text()
book_v7.book_area();
$("#fb7").css('opacity','1');
/* scale page in flipbook /*/
//size default for class .fb7-cont-page-book
$("#fb7 .fb7-cont-page-book").css('width',(width_book/2)+'px');
$("#fb7 .fb7-cont-page-book").css('height',height_book+'px');
$("#fb7 .fb7-cont-page-book").css({'transform-origin':'0 0','-ms-transform-origin':'0 0','-webkit-transform-origin':'0 0'});
//size default for class .page_book
var paddingl=width_book*this.paddingl;
var paddingr=width_book*this.paddingr;
var paddingt=width_book*this.paddingt;
var paddingb=width_book*this.paddingb;
$("#fb7 .fb7-page-book").css('width',(width_book/2-(paddingl+paddingr))+'px');
$("#fb7 .fb7-page-book").css('height',(height_book-(paddingt+paddingb))+'px');
/* scale about near flipbook /*/
$("#fb7 #fb7-about").css('width',(width_book/2)+'px');
$("#fb7 #fb7-about").css('height',height_book+'px');
if(rtl=='true'){
$("#fb7 #fb7-about").css('right','0px');
$("#fb7 #fb7-about").css({'transform-origin':'right 0','-ms-transform-origin':'right 0','-webkit-transform-origin':'right 0'});
}else{
$("#fb7 #fb7-about").css({'transform-origin':'0 0','-ms-transform-origin':'0 0','-webkit-transform-origin':'0 0'});
}
//run key
this.key_down();
//show and hide full screen icon
if(!$.support.fullscreen){
$('li a.fb7-fullscreen').parent(this).remove();
}
},
load: function(){
if( general.browser_firefox() ) {
console.log('book:load');
}
//preloader hide
$('.fb7-preloader').css('display','none');
$.address.strict(false)
$.address.autoupdate(true)
$('#fb7-container-book').show();
book_v7.init();
book_v7.zoomauto();
book_v7.book_position();
book_v7.dragdrop_init();
navigation_v7.init();
book_v7.resize_page();
if( tools_visible == "true" ){
$("#fb7 #fb7-footer").css('opacity','1');
}
//center icon
book_v7.center_icon();
book_v7.center_icon();
book_v7.media_queries()
},
getlength:function(){
return $('#fb7-deeplinking ul li').length;
},
center_icon:function(){
//$('#fb7 #fb7-footer').css('width',($('#fb7').width()-12));
//icon tools position
var icon=$('#fb7-center');
var all_width=$('#fb7').width();
var left_w=$('#fb7-logo').width();
var center_w=$('#fb7-center').width();
var right_w=$('#fb7-right').width();
var posx=all_width/2-center_w/2;
icon.css('left',posx+'px');
var zoom_org=$('a.fb7-zoom-original').parent();
var zoom_auto=$('a.fb7-zoom-auto').parent();
if( all_width <= 450 ){
zoom_org.css('display','none');
zoom_auto.css('display','none');
}else{
zoom_org.css('display','block');
zoom_auto.css('display','block');
}
},
media_queries:function (){
//center
var position_center=$('#fb7-center').position();
var xmax_center=position_center.left+$('#fb7-center').width();
var xmin_center=position_center.left
//right
var position_right=$('#fb7-right').position();
var xmin_right=position_right.left;
//left
var position_left=$('#fb7-logo').position();
var xmax_left=position_left.left+$('#fb7-logo').width();
if( xmax_center > xmin_right || xmax_left > xmin_center ){
$('#fb7 #fb7-right,#fb7 #fb7-logo').css('visibility','hidden');
}else{
$('#fb7 #fb7-right,#fb7 #fb7-logo').css('visibility','visible');
}
},
automarginb:function(){
return math.round( $('#fb7').height()*0.02 )
},
automargint:function(){
return math.round( $('#fb7').height()*0.02 )
},
automarginl:function(){
return math.round( $('#fb7').width()*0.02 )
},
automarginr:function(){
return math.round( $('#fb7').width()*0.02 )
},
change_address:function(){
var th=this;
if( general.browser_firefox() ) {
console.log("book:change address")
}
//$('h1.entry-title').append(' /change ')
///for slug
var slug=$.address.pathnames()[0];
if(th.tmp_slug!=undefined&&slug!=th.tmp_slug){
//setaddress('book5-1');
settimeout(function(){
window.location.reload();
},1);
if( general.browser_firefox() ) {
console.log("book:change book")
}
//$('h1.entry-title').append(' /change book ')
$("#fb7").remove();
// ajax_v7.ready()
return;
}
th.tmp_slug=slug;
//normal
var address=$.address.pathnames()[$.address.pathnames().length-1];
var results=$('#fb7-deeplinking ul li[data-address='+address+']');
var nrpage=results.attr('data-page')
if(rtl=='true'){
var nrpage = ( book_v7.getlength()+1 ) -results.attr('data-page');
}
//error nr page
if(!nrpage){
if(rtl=='true'){
nrpage=book_v7.getlength();
}else{
nrpage=1;
}
}
$('#fb7-book').turn('page',nrpage);
book_v7.resize_page();
},
shadow_normal:function(display_){
var shadow=$('#fb7 .fb7-shadow')
if(display_==false){
shadow.css('display','none');
}
if( shadow.hasclass('fb7-shadow-right') ){
shadow.removeclass('fb7-shadow-right');
}
if( shadow.hasclass('fb7-shadow-left') ){
shadow.removeclass('fb7-shadow-left');
}
shadow.addclass('fb7-shadow-double');
},
shadow_right:function(display_){
var shadow=$('#fb7 .fb7-shadow');
if(display_==false){
shadow.css('display','none');
}
if( shadow.hasclass('fb7-shadow-left') ){
shadow.removeclass('fb7-shadow-left');
}
if( shadow.hasclass('fb7-shadow-double') ){
shadow.removeclass('fb7-shadow-double');
}
shadow.addclass('fb7-shadow-right');
},
shadow_left:function(display_){
var shadow=$('#fb7 .fb7-shadow')
if(display_==false){
shadow.css('display','none');
}
if( shadow.hasclass('fb7-shadow-right') ){
shadow.removeclass('fb7-shadow-right');
}
if( shadow.hasclass('fb7-shadow-double') ){
shadow.removeclass('fb7-shadow-double');
}
shadow.addclass('fb7-shadow-left');
},
init: function() {
var th=this;
//this.on_start = true;
if( swf_address=="true" ){
/* = jquery addresss init
--------------------------*/
var current_address=$.address.pathnames()[$.address.pathnames().length-1];
book_slug=$.address.pathnames()[0];
var results=$('#fb7-deeplinking ul li[data-address='+current_address+']');
var nrpage = results.attr('data-page');
if(rtl=='true'){
var nrpage = ( book_v7.getlength()+1 ) -results.attr('data-page');
}
//error nr page
if(!nrpage){
if(rtl=='true'){
nrpage=book_v7.getlength();
}else{
nrpage=1;
}
}
/* = jquery addresss change
--------------------------*/
$.address.change(function(event) {
th.change_address()
})
}
$('#fb7-book').turn({
display: 'double',
acceleration: true,
gradients:true,
elevation:50,
page:nrpage,
when: {
first: function(e, page) {
$('.fb7-nav-arrow.prev').hide();
var old=$('#fb7-book').turn('page')
//console.log("event first")
if(old==book_v7.getlength() ){
var shadow=$('#fb7 .fb7-shadow')
shadow.css('display','none');
}
book_v7.shadow_normal();
book_v7.shadow_right();
},
start: function(event, pageobject, corner) {
var page=pageobject.page;
//console.log('event start '+corner+" / "+page);
if(page==2 && ( corner=="bl" || corner=="tl" ) ){
book_v7.shadow_right();
}
if(page==book_v7.getlength()-1 && ( corner=="br" || corner=="tr" ) ){
book_v7.shadow_left();
}
},
end: function(event, pageobject, corner) {
//console.log('event end: ');
},
turned: function(e, page) {
//console.log("turned = "+page);
if(page>=2&&page 1) {
$('.fb7-nav-arrow.prev').fadein();
//$('#fb7-about').hide();
}
if( (page==1&&rtl=='false') || ( page==$(this).turn('pages')&&rtl=='true') ){
$('#fb7-about').css('z-index',11);
}
if ( page < $(this).turn('pages') ) {
$('.fb7-nav-arrow.next').fadein();
}
var page1=page;
if(rtl=="true"){
page1=book_v7.getlength()-page+1;
}
var page2;
if(page1>1&&page1225){
height_container=225;
}
cont_thumbs.css('height',height_container+'px');
//position thumbs
var _top=( (area_height/2) - ( (cont_thumbs.outerheight())/2 ) )
cont_thumbs.css('top',_top+'px');
var summary = 0;
var self = this;
var slider_width = $('#fb7-slider').width();
$('#fb7-slider').append('');
$('#fb7-slider li').each(function() {
li_width = $(this).outerwidth();
summary += li_width;
})
$('#fb7-slider').css('width', summary);
$("#fb7-menu-holder").mousemove(function(e) {
if ( $(this).width() < $("#fb7-slider").width() ) {
var distance = e.pagex - $(this).offset().left;
var percentage = distance / $(this).width();
var targetx = -math.round(($("#fb7-slider").width() - $(this).width()) * percentage);
$('#fb7-slider').animate({left: [targetx+"px",'easeoutcubic'] }, { queue:false, duration: 200 });
}
});
//////////////////////swipe
if(self.events_thumbs!=1){
$('#fb7-all-pages .fb7-container-pages').bind("touchstart", function(e) {
$('#fb7-slider').stop();
//time
self.time_start=new date().gettime();
self.time_move_old=self.time_start;
//road
self.x_start = e.originalevent.targettouches[0].pagex;
self.x_move=undefined;
self.x_move_old=self.x_start;
});
$('#fb7-all-pages .fb7-container-pages').bind("touchmove", function(e) {
//current round and time
self.x_move = e.originalevent.targettouches[0].pagex;
self.time_move=new date().gettime();
//time - delta
self.delta_t=new date().gettime()-self.time_move_old;
self.time_move_old=new date().gettime();
//round- delta
self.delta_s=self.x_move-self.x_move_old;
self.x_move_old=self.x_move;
//set position thumbs
self.current_x=parseint( $('#fb7-slider').css('left') );
var new_position=self.current_x+self.delta_s;
if(new_position>0){ new_position=0 }
var minx=-summary+window_width;
if(new_position0){new_position=0}
var minx=-summary+window_width;
if(new_position 5){
$('#fb7-slider').animate({ left:[new_position+"px","easeoutcubic"] },t);
}
//e.preventdefault(e);
});
//////////////////////end swipe
self.events_thumbs=1;
}
$('#fb7-slider li').on('click',function() {
self.x_start=null;
self.x_move=null;
$('#fb7-slider').stop();
var page_index = $(this).attr('class');
var tmp = parseint(page_index);
close_overlay();
settimeout(function(){
setpage(tmp);
},100);
})
$(document).on('click',function(e) {
var target = $(e.target);
if ( target.hasclass('fb7-overlay') ) close_overlay();
});
},
book_grab: function() {
$('#fb7-container-book').css('cursor', '-webkit-grab');
$('#fb7-container-book').css('cursor', '-moz-grab');
},
book_grabbing: function() {
$('#fb7-container-book').css('cursor', '-webkit-grabbing');
$('#fb7-container-book').css('cursor', '-moz-grabbing');
},
book_area: function(){
var width_book=$('#fb7').width();
///if(is_as_template==true){
// var height=$(window).height()+"px";
//}else{
//var height=(width_book*height_book/width_book)+this.toolsheight+"px";
///}
if(is_as_template==true){
var height="100%";
}else{
if( $('#fb7').hasclass('fullscreen') ){
var height="100%";
}else{
var height=(width_book*height_book/width_book)+this.toolsheight+"px";
}
}
$("#fb7").css('height',height);
},
///current width book
widthbook: function(){
return $('#fb7-container-book').width();
},
//current height book
heightbook: function(){
return $('#fb7-container-book').height();
},
book_position: function() {
var book_height = this.heightbook();
var book_width = this.widthbook();
var half_height = ( (book_height/2)+this.toolsheight/2 );
var half_width = ( book_width/2 );
var x=$('#fb7').width()/2-half_width;
var y=$('#fb7').height()/2-half_height;
$('#fb7-container-book').css({ left: x, top:y });
/*footer position/*/
var new_y=book_height+this.automargint()+this.automarginb();
//$("#fb7-footer").css({top:new_y+'px'});
//$("#fb7").css('height',new_y+this.toolsheight);
},
touchstart_book:function(e){
this.book_x = e.originalevent.touches[0].pagex;
this.book_y = e.originalevent.touches[0].pagey;
},
touchmove_book:function(e){
//delta x
this.book_x_delta=e.originalevent.touches[0].pagex-this.book_x;
this.book_x=e.originalevent.touches[0].pagex;
//delta y
this.book_y_delta=e.originalevent.touches[0].pagey-this.book_y;
this.book_y=e.originalevent.touches[0].pagey;
var current_x= parseint( $('#fb7-container-book').css('left') )
var current_y= parseint( $('#fb7-container-book').css('top') )
var x=current_x+this.book_x_delta;
var y=current_y+this.book_y_delta;
$('#fb7-container-book').css( {left:x,top:y } );
e.preventdefault();
//var t=e.originalevent.changedtouches[0].pagex
//alert("move");
},
touchend_book:function(e){
},
drag: function(e) {
var el = $(this);
var dragged = el.addclass('draggable');
$('#fb7-container-book').unbind('mousemove');
$('#fb7-container-book').bind('mousemove', book_v7.book_grabbing);
var d_h = dragged.outerheight();
var d_w = dragged.outerwidth();
var pos_y = dragged.offset().top + d_h - e.pagey;
var pos_x = dragged.offset().left + d_w - e.pagex;
dragged.parents().unbind("mousemove");
dragged.parents().bind("mousemove", function(e) {
$('.draggable').offset({
top:e.pagey + pos_y - d_h,
left:e.pagex + pos_x - d_w
});
});
e.preventdefault();
},
drop: function() {
book_v7.book_grab();
$('#fb7-container-book').bind('mousemove', book_v7.book_grab);
$('#fb7-container-book').removeclass('draggable');
},
checkscrollbook: function () {
var vertical=$('#fb7-book').height() > $("#fb7").height() - this.toolsheight;
var horizontal=$('#fb7-book').width() > $("#fb7").width() - (this.arrow_width*1);
if ( vertical || horizontal ) {
higherthanwindow = true;
} else {
higherthanwindow = false;
}
return higherthanwindow;
},
dragdrop_init: function() {
this.checkscrollbook();
if ( higherthanwindow == false ) {
//mobile
$('#fb7-container-book').unbind('touchstart', book_v7.touchstart_book);
$('#fb7-container-book').unbind('touchmove', book_v7.touchmove_book);
$('#fb7-container-book').unbind('touchend', book_v7.touchend_book);
$('#fb7-container-book').unbind('mousedown', book_v7.drag);
$('#fb7-container-book').unbind('mouseup', book_v7.drop);
$('#fb7-container-book').unbind('mousemove', book_v7.book_grab);
$('#fb7-container-book').unbind('mousemove', book_v7.book_grabbing);
$('#fb7-container-book').css('cursor', 'default');
} else {
//mobile
$('#fb7-container-book').bind('touchstart', book_v7.touchstart_book);
$('#fb7-container-book').bind('touchmove', book_v7.touchmove_book);
$('#fb7-container-book').bind('touchend', book_v7.touchend_book);
$('#fb7-container-book').bind('mousedown', book_v7.drag);
$('#fb7-container-book').bind('mouseup', book_v7.drop);
$('#fb7-container-book').bind('mousemove', book_v7.book_grab);
book_v7.book_grab();
}
book_v7.resize_page();
},
scalestart: function() {
//if ( this.on_start == true ) {
this.checkscrollbook();
//this.on_start = false;
//}
},
setsize:function(w_,h_){
$('#fb7-container-book').css({ width:w_, height:h_ });
$('#fb7-book').turn('size',w_,h_);
},
zoomto:function(zoom_){
this.zoom=zoom_;
var new_width=(width_book*this.zoom);
var new_height=(height_book*this.zoom);
this.setsize(new_width,new_height);
this.scale_arrows()
this.book_position();
book_v7.dragdrop_init();
book_v7.resize_page()
},
zoomoriginal:function(){
this.zoomto(1);
},
scale_arrows:function(){
var height_arrow=$('.fb7-nav-arrow').height()
var width_arrow=$('.fb7-nav-arrow').width()
//console.log(width_arrow+" "+height_arrow)
var height_arrow=this.heightbook()*0.12;
if( height_arrow > height_arrow ){
height_arrow=height_arrow;
}
var width_arrow= (height_arrow*width_arrow)/height_arrow;
this.zoom_arrows=height_arrow/height_arrow;
$('.fb7-nav-arrow').css({'transform':'scale('+this.zoom_arrows+')','-ms-transform':'scale('+this.zoom_arrows+')','-webkit-transform':'scale('+this.zoom_arrows+')'});
///position arrow right
var arrow_next=$('#fb7 .fb7-nav-arrow.next');
var newx=this.widthbook()-( width_arrow * this.zoom_arrows )*0.4;
arrow_next.css('left',newx+'px');
///position arrow left
var arrow_prev=$('#fb7 .fb7-nav-arrow.prev');
var newx=this.widthbook()-( width_arrow * this.zoom_arrows )*0.4
arrow_prev.css('right',newx+'px');
},
zoomauto: function() {
book_v7.scalestart();
////resize one
var zoom=this.getautozoombook(0);
this.zoomto( zoom )
////resize two (with arrow)
this.scale_arrows();
var arrow_width=$('.fb7-nav-arrow').width()*this.zoom_arrows;
this.arrow_width=arrow_width;
var zoom=this.getautozoombook(arrow_width*1);
if(book_v7.config['arrows_visible']=='false'){
var zoom=this.getautozoombook(0);
}
//console.log('arrow visible = '+(book_v7.config['arrows_visible']=='false'));
//calculate optimal zoom
zoom=math.round(zoom * 100) / 100
var percent=zoom*100;
if(percent%2!=0){
zoom=zoom-0.01;
}
this.zoomto( zoom )
book_v7.resize_page()
},
getautozoombook: function(arrow_width_){
var book_width=this.widthbook();
var book_height=this.heightbook();
var screen_width = $("#fb7").width()- ( this.automarginl()+this.automarginr() + (arrow_width_) );
var screen_height = $("#fb7").height()-this.toolsheight-( this.automargint()+this.automarginb() )
if(screen_width>width_book){
screen_width=width_book
}
if(screen_height>height_book){
screen_height=height_book
}
var scalew=screen_width/book_width;
var scaleh=screen_height/book_height;
var scale=math.min(scalew,scaleh)
var new_width = book_width*scale;
var new_height = book_height*scale;
var auto_zoom= new_width/width_book
return auto_zoom;
},
zoomin: function() {
var zoom=this.zoom;
this.zoomto(zoom+zoom_step );
},
zoomout: function() {
this.zoomto( this.zoom-zoom_step );
},
resize_page: function (){
/* resize page in flipbook /*/
//resize class .fb7-page-book
var page_width=this.widthbook()/2;
var width_current_page=(page_width)
var width_orginal_page= ( width_book/2 )
var zoom= (width_current_page / width_orginal_page);
$('.fb7-cont-page-book').css({'transform':'scale('+zoom+')','-ms-transform':'scale('+zoom+')','-webkit-transform':'scale('+zoom+')'});
///center class .fb7-page-book
var paddingl=(this.widthbook()*this.paddingl)/zoom;
var paddingr=(this.widthbook()*this.paddingr)/zoom;
var paddingt=(this.widthbook()*this.paddingt)/zoom;
$('#fb7 .turn-page.odd .fb7-page-book').css({'left':paddingr+'px','top':paddingt+'px'});
$('#fb7 .turn-page.even .fb7-page-book').css({'left':paddingl+'px','top':paddingt+'px'});
/* resize about in flipbook /*/
$('#fb7-about').css({'transform':'scale('+zoom+')','-ms-transform':'scale('+zoom+')','-webkit-transform':'scale('+zoom+')'});
//padding top
var padding_top=(this.heightbook()*0.05);
$('#fb7-about').css('top',padding_top+'px');
//height
var height=(this.heightbook()-( padding_top*2) )/zoom;
$('#fb7-about').css('height',height+'px');
//width
var width=( (this.widthbook()/2)-( this.widthbook()*0.05 ) )/zoom;
$('#fb7-about').css('width',width+'px');
//center vertical for home page
//var posy=$('.fb7-page-book').height()/2 - $('#fb7 #fb7-cover ul').innerheight()/2;
//$('#fb7 #fb7-cover ul').css('top',posy+'px');
},
resize_font: function($size_original_,path_){
var w=this.widthbook();
var size= ($size_original_*w)/width_book;
var new_size=math.round(parseint(size))+"px";
///$(path_).css('font-size',new_size);
///$(path_).css('line-height',new_size);
$(path_).css('font-size',$size_original_+"px");
$(path_).css('line-height',$size_original_+"px");
}
}
/* = navigation
--------------------------*/
var navigation_v7 = {
tooltip: function() {
$('.fb7-menu li').filter(':not(.fb7-goto,.fb7-menu li:first-child,.fb7-menu li:last-child )').each(function() {
$(this).css('cursor','pointer');
var description = $('a', this).attr('title');
var tooltip = ''+description+'';
$('a', this).removeattr("title");
$(this).append(tooltip);
});
$('.fb7-menu li').mousemove(function(e) {
var tooltip=$('.fb7-tooltip', this);
var offset = $(this).offset();
var rely = e.pagey - offset.top;
var x2= e.pagex-$('#fb7').offset().left+tooltip.width()
var width_area=$('#fb7').width()
if( (x2+20)>width_area){
var orient="right";
}else{
var orient="left";
}
if(orient=="left"){
var relx = e.pagex - offset.left;
$('#fb7 .fb7-tooltip b').css('left','6px')
}else{
var relx = e.pagex - offset.left-tooltip.width()-5;
$('#fb7 .fb7-tooltip b').css('left',(tooltip.width()+6)+'px')
}
//$('.fb7-tooltip', this).html( x2+" > "+width_area );
$('.fb7-tooltip', this).css({ left: relx, top: rely-45 });
})
$('.fb7-menu li').hover(function() {
$('.fb7-tooltip').stop();
$('.fb7-tooltip', this).fadein();
}, function() {
$('.fb7-tooltip').hide();
});
book_v7.resize_page()
},
///event mouse down in book
book_mouse_down: function(){
$('#fb7-about').css('z-index',5);
//book_v7.resize_page();
},
book_mouse_up: function(e){
var offset = $(this).offset();
var relativex = (e.pagex - offset.left);
if( relativex > ( width_book / 2 ) ){
//$('#fb7-about').css('z-index',11);
}
},
init: function() {
// double click
if(zoom_double_click_enabled=="true"){
$('#fb7-book').dblclick(function() {
if(book_v7.checkscrollbook()==false){ //zoom
book_v7.zoomto(zoom_double_click)
}else{
book_v7.zoomauto();
$('#fb7-container-book').css('cursor', 'default');
}
});
}
//focus for page manager
var page_manager=$('#fb7-page-number');
page_manager.focus(function(e) {
var target=$(e.currenttarget);
target.data('current',target.val());
target.val('')
//target.addclass('focus_input');
});
page_manager.focusout(function(e) {
var target=$(e.currenttarget);
var old=target.data('current');
//target.removeclass('focus_input');
if( target.val() ==''){
target.val(old);
}
});
//full screen
$('.fb7-fullscreen').on('click', function() {
$('.fb7-tooltip').hide();
$('#fb7').fullscreen({
'callback': function(isfullscreen){
book_v7.book_area();
book_v7.zoomauto();
book_v7.center_icon();
if(isfullscreen){
}else{
}
}
});
e.preventdefault();
});
//download
$('.fb7-download').on('click', function(event) {
//$.address.update();
// event.preventdefault();
});
// home
$('.fb7-home').on('click', function() {
setpage(1);
//setaddress('book5-1');
});
// zoom original
$('.fb7-zoom-original').click(function() {
book_v7.zoomoriginal();
});
// zoom auto
$('.fb7-zoom-auto').on('click', function() {
book_v7.zoomauto();
});
// zoom in
$('.fb7-zoom-in').on('click', function() {
book_v7.zoomin();
});
// zoom out
$('.fb7-zoom-out').on('click', function() {
book_v7.zoomout();
});
// all pages
$('.fb7-show-all').on('click', function() {
$('#fb7-all-pages').
addclass('active').
css('opacity', 0).
animate({ opacity: 1 }, 1000);
book_v7.all_pages();
return false;
})
// goto page
$('#fb7-page-number').keydown(function(e) {
if (e.keycode == 13) {
setpage( $('#fb7-page-number').val() );
}
});
$('.fb7-goto button').click(function(e) {
setpage( $('#fb7-page-number').val() );
});
// contact
$('.contact').click(function() {
$('#fb7-contact').addclass('active').animate({ opacity: 1 }, 1000);
contact_form();
clear_on_focus();
return false;
})
//change z-index in about
$('#fb7-book').bind('mousedown',this.book_mouse_down);
$('#fb7-book').bind('mouseup',this.book_mouse_up);
if (book_v7.isiphone()) {//for iphone
$('#fb7-book').bind('touchstart',this.book_mouse_down);
$('#fb7-book').bind('touchend',this.book_mouse_up);
}
//show tooltip for icon
if ( !book_v7.isiphone() && tool_tip_visible=="true" ) {
this.tooltip();
}
}
}
/* = contact form
--------------------------*/
function clear_on_focus() {
$('input[type="text"], input[type="password"], textarea').each( function() {
var startvalue = $(this).val();
$.data(this, "startvalue", startvalue);
this.value=startvalue;
})
$('input[type="text"], input[type="password"], textarea').focus(function() {
var startvalue = $.data(this, "startvalue");
if ( this.value == startvalue ) {
this.value = '';
}
});
$('input[type="text"], input[type="password"], textarea').blur(function() {
var startvalue = $.data(this, "startvalue");
if ( this.value == '' ) {
this.value = startvalue;
}
})
}
function close_overlay() {
$('.fb7-overlay').removeclass('active');
settimeout(function(){
book_v7.corner_change(false);
},1000);
}
function contact_form() {
$('#fb7-contact .req').each(function() {
var startvalue = $(this).val();
$.data(this, "startvalue", startvalue);
});
$('#fb7-contact button[type="submit"]').click(function() {
$('#fb7-contact .req').removeclass('fb7-error');
$('#fb7-contact button').fadeout('fast');
var iserror = 0;
// get the data from the form
var name = $('#fb7-contact #fb7-form-name').val();
var email = $('#fb7-contact #fb7-form-email').val();
var message = $('#fb7-contact #fb7-form-message').val();
// validate the data
$('#fb7-contact .req').each(function() {
var startvalue = jquery.data(this, "startvalue");
if ( ($(this).val() == '') || (this.value == startvalue) ) {
$(this).addclass('fb7-error');
iserror = 1;
}
});
var reg = /^([a-za-z0-9_\-\.])+\@([a-za-z0-9_\-\.])+\.([a-za-z]{2,4})$/;
if (reg.test(email)==false) {
$('#fb7-contact #fb7-form-email').addclass('fb7-error');
iserror=1;
}
// terminate the script if an error is found
if (iserror == 1) {
$('#fb7-contact button').fadein('fast');
return false;
}
$.ajaxsetup ({
cache: false
});
var _email=book_v7.config['email_form'];
var datastring = 'name='+ name + '&email=' + email + '&message=' + message+'&_email='+_email;
$.ajax({
type: "post",
url: $('#fb7-ajax').data('book_url')+"php/submit-form-ajax.php",
data: datastring,
success: function(msg) {
// check to see if the mail was successfully sent
if (msg == 'mail sent') {
$("#fb7-contact fieldset").hide();
$("#fb7-contact fieldset.fb7-thanks").show();
settimeout(function() {
close_overlay();
}, 5000);
} else {
$('#fb7-contact button').fadein('fast');
alert('the problem with sending it, please try again!');
}
},
error: function(ob,errstr) {
alert('the problem with sending it, please try again.');
}
});
return false;
});
$('#fb7-contact .fb7-close').click(function() {
close_overlay();
})
}
/*
* $ easing v1.3 - http://gsgd.co.uk/sandbox/$/easing/
*
* uses the built in easing capabilities added in $ 1.1
* to offer multiple easing options
*/
$.easing["jswing"]=$.easing["swing"];$.extend($.easing,{def:"easeoutquad",swing:function(a,b,c,d,e){return $.easing[$.easing.def](a,b,c,d,e)},easeinquad:function(a,b,c,d,e){return d*(b/=e)*b+c},easeoutquad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c},easeinoutquad:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b+c;return-d/2*(--b*(b-2)-1)+c},easeincubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeoutcubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeinoutcubic:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b+c;return d/2*((b-=2)*b*b+2)+c},easeinquart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c},easeoutquart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeinoutquart:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b+c;return-d/2*((b-=2)*b*b*b-2)+c},easeinquint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeoutquint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeinoutquint:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b*b+c;return d/2*((b-=2)*b*b*b*b+2)+c},easeinsine:function(a,b,c,d,e){return-d*math.cos(b/e*(math.pi/2))+d+c},easeoutsine:function(a,b,c,d,e){return d*math.sin(b/e*(math.pi/2))+c},easeinoutsine:function(a,b,c,d,e){return-d/2*(math.cos(math.pi*b/e)-1)+c},easeinexpo:function(a,b,c,d,e){return b==0?c:d*math.pow(2,10*(b/e-1))+c},easeoutexpo:function(a,b,c,d,e){return b==e?c+d:d*(-math.pow(2,-10*b/e)+1)+c},easeinoutexpo:function(a,b,c,d,e){if(b==0)return c;if(b==e)return c+d;if((b/=e/2)<1)return d/2*math.pow(2,10*(b-1))+c;return d/2*(-math.pow(2,-10*--b)+2)+c},easeincirc:function(a,b,c,d,e){return-d*(math.sqrt(1-(b/=e)*b)-1)+c},easeoutcirc:function(a,b,c,d,e){return d*math.sqrt(1-(b=b/e-1)*b)+c},easeinoutcirc:function(a,b,c,d,e){if((b/=e/2)<1)return-d/2*(math.sqrt(1-b*b)-1)+c;return d/2*(math.sqrt(1-(b-=2)*b)+1)+c},easeinelastic:function(a,b,c,d,e){var f=1.70158;var g=0;var h=d;if(b==0)return c;if((b/=e)==1)return c+d;if(!g)g=e*.3;if(h