1function SetCookie(cookieName,cookieValue,nDays) { 2 var today = new Date(); 3 var expire = new Date(); 4 if (nDays==null || nDays==0) nDays=1; 5 expire.setTime(today.getTime() + 3600000*24*nDays); 6 document.cookie = cookieName+"="+escape(cookieValue) 7 + ";expires="+expire.toGMTString(); 8} 9 10function shareToFriend() 11{ 12 if ( $(this).hasClass( 'shared' ) ) return false; 13 var sNick = $(this).attr( 'rel' ); 14 var button = $(this); 15 $.ajax({ 16 type: "POST", 17 url: sUrlShareFriend, 18 data: 'share-for-username='+sNick+'&idBook='+idBook, 19 success: function(msg){ 20 var data = eval("(" + msg + ")"); 21 if ( data['result'] == true ) { 22 $(button).addClass( 'shared' ); 23 } 24 } 25 }); 26 return false; 27} 28 29function shareToMail() 30{ 31 var sEmail = $('input:[name=share-for]').val(); 32 var sSubject = $('input:[name=share-subject]').val(); 33 $.ajax({ 34 type: "POST", 35 url: sUrlShareMail, 36 data: 'share-url='+sShareUrl+'&share-for='+sEmail+'&share-subject='+sSubject+'&message='+sShareUrl, 37 success: function(msg){ 38 var data = eval("(" + msg + ")"); 39 //sem by som dal fancybox 40 $.fancybox( data['html'] ); 41 } 42 }); 43 return false; 44} 45 46function showJSBox( html ) 47{ 48 if ( $('#jsbox').html() == null ) 49 { 50 $('body').append( '<div id="js-overlay" style="position:absolute;top:0;left:0;z-index:90;width:100%;height:100%;background:#000;opacity:0.7"></div>' ); 51 html = '<div id="jsbox" class="jsBox">'+html+'</div>'; 52 $('body').append( html ); 53 centerBox( 'jsbox' ); 54 } 55 else 56 { 57 $('#jsbox').html( html ); 58 } 59} 60 61function centerBox( boxId ) 62{ 63 $('#'+boxId).css( 'position','absolute' ); 64 $('#'+boxId).css( 'left','50%' ); 65 $('#'+boxId).css( 'top','40%' ); 66 var width = $('#'+boxId).width(); 67 var height = $('#'+boxId).height(); 68 var paddingTop = parseInt($('#'+boxId).css("padding-top")); 69 var paddingBottom = parseInt($('#'+boxId).css("padding-bottom")); 70 var borderTop = parseInt($('#'+boxId).css("border-top-width")); 71 var borderBottom = parseInt($('#'+boxId).css("border-bottom-width")); 72 var mediaBorder = (borderTop+borderBottom)/2; 73 var mediaPadding = (paddingTop+paddingBottom)/2; 74 var halfWidth = (width/2)*(-1); 75 var halfHeight = ((height/2)*(-1))-mediaPadding-mediaBorder; 76 $('#'+boxId).css( 'marginTop',halfHeight+'px' ); 77 $('#'+boxId).css( 'marginLeft',halfWidth+'px' ); 78} 79 80function closeJSBox() 81{ 82 $('#js-overlay').remove(); 83 $('#jsbox').remove(); 84 return false; 85} 86 87function assignHideTitle() 88{ 89 $('input.hidTitle').blur( function () { if( $(this).attr('value') == '' ) $(this).attr('value', $(this).attr('title') ); } ); 90 $('input.hidTitle').focus( function () { if( $(this).attr('value') == $(this).attr('title') ) $(this).attr('value', ''); } ); 91 $('textarea.hidTitle').blur( function () { if( $(this).html() == '' ) $(this).html( $(this).attr('title') ); } ); 92 $('textarea.hidTitle').focus( function () { if( $(this).html() == $(this).attr('title') ) $(this).html(''); } ); 93} 94 95$(document).ready(function() 96{ 97 assignHideTitle(); 98 //global 99 $('span.del').click( deleteFolderBox ); 100 $('a.delete-book').click( deleteBookBox ); 101 $('a#favourite-pub').click( addFavBox ); 102 $('a.new-folder').click( addFolderBox ); 103 $('a.add-report').click( addReportBox ); 104 $('a.share-pubs').click( addShareBox ); 105 $('a#selectAll').click( selectAll ); 106 $('a#selectNone').click( selectNone ); 107}); 108 109function selectAll() 110{ 111 $('table#bookList input[type=checkbox]').attr( 'checked', 'checked' ); 112} 113 114function selectNone() 115{ 116 $('table#bookList input[type=checkbox]').attr( 'checked', '' ); 117} 118 119function addFolderBox() 120{ 121 var url = $(this).attr("href"); 122 $.ajax({ 123 type: "GET", 124 url: url, 125 data: "", 126 success: function(msg){ 127 var data = eval("(" + msg + ")"); 128 if ( data["html"] ) 129 { 130 var params = { 131 title: data["title"], 132 html: data["html"], 133 yesButton: data['yes'], 134 noButton: data['no'] 135 } 136 popupBox("confirm", params, function(ret){ if ( ret === true ) addFolder(); } ); 137 } 138 assignHideTitle(); 139 } 140 }); 141 return false; 142} 143 144function addFolder() 145{ 146 var frm = $('div.popup-box form'); 147 var url = '/ajax/submit-new-folder'; 148 var s = new Array();
149 var elements = frm.find('select, input[type=text], input:hidden, input:checkbox:checked, input:radio:checked, input:password, textarea'); 150 for(var i = 0; i < elements.length; i++){ 151 s.push($(elements[i]).attr('name') + '=' + encodeURIComponent($(elements[i]).val())); 152 } 153 s.push( 'name='+ $('input#folder-name').val() ); 154 $.ajax({ 155 type: 'POST', 156 url: url, 157 data: s.join('&'), 158 success: function(msg){ 159 var data = eval("(" + msg + ")"); 160 closeJSBox(); 161 if ( data["html"] ) 162 { 163 var params = { 164 title: data["title"], 165 text: data["html"], 166 autoclose: 2000 167 } 168 popupBox("alert", params, function(ret){ if ( data['result'] === true ) {window.location.reload();} } ); 169 } 170 } 171 }); 172 return false; 173} 174 175function deleteFolderBox() 176{ 177 var idFolder = $(this).attr('tag'); 178 $.ajax({ 179 type: "GET", 180 url: '/ajax/get-delete-folder-box', 181 data: "idFolder="+idFolder, 182 success: function(msg){ 183 var data = eval("(" + msg + ")"); 184 if ( data["html"] ) 185 { 186 var params = { 187 title: data["title"], 188 text: data["html"], 189 yesButton: data['yes'], 190 noButton: data['no'] 191 } 192 popupBox("confirm", params, function(ret){ if ( ret === true ) deleteFolder(idFolder); } ); 193 } 194 assignHideTitle(); 195 } 196 }); 197 return false; 198} 199 200function deleteFolder(idFolder) 201{ 202 $.ajax({ 203 type: 'POST', 204 url: '/ajax/delete-folder', 205 data: 'idFolder='+idFolder, 206 success: function(msg){ 207 var data = eval("(" + msg + ")"); 208 if ( data["html"] ) 209 { 210 var params = { 211 title: data["title"], 212 text: data["html"], 213 autoclose: 2000 214 } 215 popupBox("alert", params, function(ret){ if ( data['result'] === true ) {window.location.reload();} } ); 216 } 217 } 218 }); 219 closeJSBox(); 220 return false; 221} 222 223function deleteBookBox() 224{ 225 var idBook = $(this).attr('tag'); 226 $.ajax({ 227 type: "GET", 228 url: '/ajax/get-delete-book-box', 229 data: "idBook="+idBook, 230 success: function(msg){ 231 var data = eval("(" + msg + ")"); 232 if ( data["html"] ) 233 { 234 var params = { 235 title: data["title"], 236 text: data["html"], 237 yesButton: data['yes'], 238 noButton: data['no'] 239 } 240 popupBox("confirm", params, function(ret){ if ( ret === true ) deleteBook(idBook); } ); 241 } 242 assignHideTitle(); 243 } 244 }); 245 return false; 246} 247 248function deleteBook(idBook) 249{ 250 $.ajax({ 251 type: 'POST', 252 url: '/ajax/delete-book', 253 data: 'idBook='+idBook, 254 success: function(msg){ 255 var data = eval("(" + msg + ")"); 256 if ( data["html"] ) 257 { 258 var params = { 259 title: data["title"], 260 text: data["html"], 261 autoclose: 2000 262 } 263 popupBox("alert", params, function(ret){ if ( data['result'] === true ) {window.location.reload();} } ); 264 } 265 } 266 }); 267 closeJSBox(); 268 return false; 269} 270 271function addReportBox() 272{ 273 var url = $(this).attr("href"); 274 $.ajax({ 275 type: "GET", 276 url: url, 277 data: "", 278 success: function(msg){ 279 var data = eval("(" + msg + ")"); 280 if ( data["html"] ) 281 { 282 var params = { 283 title: data["title"], 284 html: data["html"], 285 yesButton: data['yes'], 286 noButton: data['no'] 287 } 288 popupBox("confirm", params, function(ret){ if ( ret === true ) addReport('submit-report'); } ); 289 } 290 assignHideTitle(); 291 } 292 }); 293 return false; 294} 295 296function addFavBox() 297{ 298 var url = $(this).attr("href"); 299 $.ajax({ 300 type: "GET", 301 url: url, 302 data: "", 303 success: function(msg){ 304 var data = eval("(" + msg + ")"); 305 if ( data["html"] ) 306 { 307 var params = { 308 title: data["title"], 309 html: data["html"], 310 yesButton: data['yes'], 311 noButton: data['no'] 312 } 313 popupBox("confirm", params, function(ret){ if ( ret === true ) addReport('fav-pub'); } ); 314 } 315 assignHideTitle(); 316 } 317 }); 318 return false; 319} 320 321function addReport(what) 322{ 323 var frm = $('div.popup-box form'); 324 var url = '/ajax/' + what; 325 var s = new Array(); 326 327 var elements = frm.find('select, input:text, input:hidden, input:checkbox:checked, input:radio:checked, input:password, textarea'); 328 for(var i = 0; i < elements.length; i++){ 329 s.push($(elements[i]).attr('name') + '=' + encodeURIComponent($(elements[i]).val())); 330 } 331 if (what == 'send-share-pubs') { 332 s.push( 'share-for='+ $('input.share-for').val() ); 333 s.push( 'share-url='+ $('input#share-url').val() ); 334 s.push( 'share-subject='+ $('input#share-subject').val() ); 335 s.push( 'share-for-username='+ $('input#share-for-username').val() ); 336 } 337 if (what == 'submit-report') { 338 s.push( 'subject='+ $('input#subject').val() ); 339 } 340 if (what == 'fav-pub') { 341 s.push( $('a#favourite-pub').attr('href').split('?')[1] ); 342 } 343 $.ajax({ 344 type: 'POST', 345 url: url, 346 data: s.join('&'), 347 success: function(msg){ 348 var data = eval("(" + msg + ")"); 349 350 closeJSBox(); 351 if ( data["html"] ) 352 { 353 var params = { 354 title: data["title"], 355 text: data["html"], 356 autoclose: 2000 357 } 358 popupBox("alert", params, function(ret){ if ( data['result'] === true ) {window.location.reload();} } ); 359 } 360 } 361 }); 362 return false;
363} 364 365function addShareBoxx() 366{ 367 var url = $(this).attr("href"); 368 $.ajax({ 369 type: "GET", 370 url: url, 371 data: "", 372 success: function(msg){ 373 var data = eval("(" + msg + ")"); 374 if ( data["html"] ) 375 { 376 showJSBox( data['html'] ); 377 } 378 $('form#submitReport input[name=submit]').click( addReport ); 379 $('form#submitReport input[name=cancel]').click( closeJSBox ); 380 $('a#share-email').click(function () { 381 $('div#sendProfile').hide(); 382 $('div#sendEmail').show(); 383 $('#shareType').val('1'); 384 $('a#share-friend').removeClass('active'); 385 $(this).addClass('active'); 386 return false; 387 }); 388 $('a#share-friend').click(function () { 389 $('div#sendProfile').show(); 390 $('div#sendEmail').hide(); 391 $('#shareType').val('2'); 392 $('a#share-email').removeClass('active'); 393 $(this).addClass('active'); 394 return false; 395 }); 396 assignHideTitle(); 397 } 398 }); 399 return false; 400} 401 402function addShareBox() 403{ 404 var url = $(this).attr("href"); 405 $.ajax({ 406 type: "GET", 407 url: url, 408 data: "", 409 success: function(msg){ 410 var data = eval("(" + msg + ")"); 411 if ( data["html"] ) 412 { 413 var params = { 414 title: data["title"], 415 html: data["html"], 416 yesButton: data['yes'], 417 noButton: data['no'] 418 } 419 popupBox("confirm", params, function(ret){ if ( ret === true ) addReport('send-share-pubs'); } ); 420 } 421 422 $('a#share-email').click(function () { 423 $('div#sendProfile').hide(); 424 $('div#sendEmail').show(); 425 $('#shareType').val('1'); 426 $('a#share-friend').removeClass('active'); 427 $(this).addClass('active'); 428 return false; 429 }); 430 $('a#share-friend').click(function () { 431 $('div#sendProfile').show(); 432 $('div#sendEmail').hide(); 433 $('#shareType').val('2'); 434 $('a#share-email').removeClass('active'); 435 $(this).addClass('active'); 436 return false; 437 }); 438 439 assignHideTitle(); 440 } 441 }); 442 return false; 443} 444 445function editTitle(elem) { 446 var title = $(elem).parent(); 447 $('legend',title).html($('<input/>').val($('legend',title).text())); 448// $('.title-manager-type',title).html($('#newTitleType')); 449 var cntrySelect = $('#newTitleCountry').clone(); 450 $('.title-manager-country',title).html(cntrySelect.val($('.title-manager-country',title).attr('rel'))); 451 $('.title-manager-edit',title).hide(); 452 $('.title-manager-save',title).show(); 453 $('.title-manager-save',title).removeClass('hidden'); 454} 455 456function saveTitle(elem) { 457 var title = $(elem).parent(); 458 $('.title-manager-status',title).html($('<img/>').attr('src','/vendors/images/red-circlular-loader.gif')); 459 460 var url = '/ajax/update-title'; 461 var id = $(elem).parent().children('input[name^="titleId"]').val(); 462 var country = $('.title-manager-country select',title).val(); 463 var countryName = $('.title-manager-country select option:selected',title).text(); 464 var name = $('legend input',title).val(); 465 466/* 467 var period = $(elem).parent().children('select[name^="titlePeriodicity"]').val(); 468*/ 469 470 if(country == '' || country == 0 || name == '') 471 return false; 472 473 $.ajax({ 474 type: "GET", 475 url: url, 476 data: "id="+id+"&country="+country+"&name="+name, 477 success: function(msg) { 478 if(msg == '0') { 479 $('legend',title).html(name); 480 $('.title-manager-country',title).html(countryName); 481 $('.title-manager-country',title).attr('rel',country); 482 $('.title-manager-status',title).addClass('green').html('OK'); 483 $('.title-manager-edit',title).show(); 484 $('.title-manager-save',title).hide(); 485 } 486 } 487 }); 488 489 490 491 492} 493 494function addTitle() { 495 496 var url = '/ajax/add-title'; 497 var name = $('#newTitle').val(); 498 var periodicity = $('#newTitleType').val(); 499 var typeName = $('#newTitleType option:selected').text(); 500 var cntry = $('#newTitleCountry').val(); 501 var cntryName = $('#newTitleCountry option:selected').text(); 502 var user = $('input[name="idUser"]').val(); 503 var days = 0; 504 if($('#dailyTitle').attr("checked") == true) { 505 $('#daysForTitle input').each(function(){ 506 if($(this).attr("checked")) { 507 days += parseInt($(this).val()); 508 }; 509 }); 510 } 511 if(name == '' || user == '' || periodicity == '' || cntry == 0 || cntry == '') 512 return false; 513 514 $.ajax({ 515 type: "GET", 516 url: url, 517 data: "user="+user+"&name="+name+"&periodicity="+periodicity+"&cntry="+cntry+"&days="+days, 518 success: function(msg){ 519 if(msg) { 520 var template = $('#fsTemplate'); 521 $(template).find('input[name="periodicity"]').attr({ 522 value: periodicity 523 }); 524 var fs = $('<fieldset></fieldset>') 525 .append($('<input>').attr({ 526 type: 'hidden', 527 value: msg, 528 name: 'titleId[]' 529 })) 530 .append($('<input>').attr({ 531 type: 'hidden', 532 value: name, 533 name: 'titleName[]' 534 })) 535 .append($('<legend></legend>').html(name)) 536 .append($(template).html()); 537 $('.title-manager-country',fs).text(cntryName); 538 $('.title-manager-country',fs).attr('rel',cntry); 539 $('.title-manager-type',fs).text(typeName); 540 $('.newTitle',fs).text(msg); 541 if(days == 0) { 542 $('.title-manager-days',fs).hide(); 543 } else { 544 $('.title-manager-days span',fs).each(function() { 545 if(parseInt($(this).attr('rel')) &~ days) { 546 $(this).remove(); 547 }; 548 }); 549 var tmp = $('.title-manager-days span:last',fs); 550 tmp.text( tmp.text().replace(new RegExp(',$'),'') ); 551 } 552 $('button[name="editPrepaid"]',fs).click(function(){ 553 document.location.href=$('button[name="editPrepaid"]',fs).attr('href')+msg; 554 return false;
555 }); 556 $('button[name="title-manager-edit"]',fs).click(function(){ 557 document.location.href=$('button[name="title-manager-edit"]',fs).attr('href')+msg; 558 return false; 559 }); 560 $('#titles').append(fs); 561 $('#newTitle').val(''); 562 } 563 } 564 }); 565 return false; 566}; 567 568function deleteTitle(elem,id) { 569 if(confirm($("#question").val())) 570 { 571 var url = '/ajax/delete-title'; 572 $.ajax({ 573 type: "GET", 574 url: url, 575 data: "id="+id, 576 success: function(msg){ 577 $(elem).parents('tr').next().remove(); 578 $(elem).parents('tr').remove(); 579 } 580 }); 581 } 582 return false; 583}; 584 585function addPrepaid(elem) { 586 var titleId = $(elem).parent().children('input[name^="titleId"]').val(); 587 var type = $(elem).parent().children('input[name="periodicity"]').val(); 588 var to = $(elem).siblings('div[class="prepaids"]'); 589 var template = $('.ppTemplate').clone(true); 590 $(template).removeClass('ppTemplate').show(); 591 var a = $('<div></div>').append(template); 592 $('input[name^="prepaidTitleId"]',a).val(titleId); 593 if(type == 1) { 594 $('input[name^="prepaidPieces"]',a).attr('value',1); 595 $('input[name^="prepaidTimeOrPieces"]',a).val('0'); 596 $('span.pieces',a).hide(); 597 } 598 $('input[name^="placeholder"]',a).attr('name','prepaidId[]'); 599 $(to).append(a); 600 return false; 601}; 602 603function deletePrepaid(elem) { 604 if(confirm($("#question").val())) 605 { 606 var tr = $(elem).parents('tr'); 607 tr.prev().remove(); 608 tr.remove(); 609 } 610}; 611 612function showPromoCodesList() { 613 $('#all-promo-codes').toggle(); 614} 615 616function generatePromoCodesPDF() { 617 var lang = $('#promo-code-langs').val(); 618 var template = $('#promo-code-temps').val(); 619 var campaignId = $('#hidden-campaign-id').html(); 620 if(!template || template == "0" || !lang) { 621 $('#promo-code-temps').css('color','#ff0000'); 622 return false; 623 } else { 624 $('#promo-code-temps').css('color','#000000'); 625 } 626 $.ajax({ 627 type: "POST", 628 url: '/ajax/get-promo-code-list', 629 data: 'campaign='+campaignId, 630 dataType: 'json', 631 success: function(data){ 632 if ( data.length > 0 ) { 633 $('#promo-zip').html('<span>0</span>/'+data.length); 634 return generatePromoCodePDF(0,data,lang,template); 635 } 636 } 637 }); 638 return false; 639 } 640 641function generatePromoCodePDF(index,data,lang,template) { 642 var elem = $('#promo-codes-list td[rel="i'+data[index]+'"]'); 643 if(elem.length > 0) 644 { 645 elem.html($('<img/>').attr('src','/vendors/images/red-circlular-loader.gif')); 646 } 647 648 $.ajax({ 649 type: "POST", 650 url: '/ajax/generate-promo-pdf', 651 data: 'promo='+data[index]+'&lang='+lang+'&template='+template, 652 dataType: 'json', 653 success: function(msg){ 654 if(typeof msg.error == 'undefined') { 655 if(elem.length > 0) 656 { 657 elem.html('<a href="/get-promo-pdf/'+data[index]+'"><img src="/vendors/images/style/pixel.gif" class="pdf"/></a>'); 658 } 659 var counter = parseInt($('#promo-zip span').html()); 660 counter += 1; 661 $('#promo-zip span').html(counter); 662 if(index < data.length-1) 663 { 664 return generatePromoCodePDF(index+1,data,lang,template); 665 } else { 666 $('#promo-zip').html('<div class="form-button"><ins></ins><div class="form-button-inner"><a href="/get-promo-zip/'+$('#hidden-campaign-id').html()+'" >ZIP ('+msg.size+')</a></div><del></del></div>'); 667 return true; 668 } 669 670 } else { 671 if(elem.length > 0) 672 { 673 elem.html('<b class="red" title="'+msg.error+'"> X</b>'); 674 } 675 alert(msg.error); 676 return false; 677 } 678 } 679 }); 680} 681 682function savePOEmail() { 683 var email = $('#poEmail').val(); 684 if(email != '') { 685 $('#poEmailButton').after($('<img/>').attr('src','/vendors/images/red-circlular-loader.gif').attr('id','loader')); 686 $('#poEmailButton').hide(); 687 $.ajax({ 688 type: "POST", 689 url: '/ajax/save-poemail', 690 data: 'email='+email, 691 success: function(msg){ 692 if(msg == '0') { 693 $('#loader').remove(); 694 $('#poEmailButton').show(); 695 } 696 } 697 }); 698 } 699} 700 701 702function deleteTemplate(elem) { 703 var params = { 704 html: $("#question").val() 705 }; 706 var answer = confirm($("#question").val()); 707 if ( answer ) { 708 var tr = $(elem).parents('tr'); 709 var id = $('td:first',tr).html(); 710 if(id) { 711 $.ajax({ 712 type: "POST", 713 url: '/ajax/remove-promo-template', 714 data: 'id='+id, 715 success: function(msg){ 716 if(msg == '0') { 717 tr.next().remove(); 718 tr.remove(); 719 } 720 } 721 }); 722 } 723 } 724 725 return false;
726} 727 728function shareWithServicesBox() 729{ 730 $.ajax({ 731 type: "GET", 732 url: "/ajax/share-with-services", 733 data: "loc="+document.location.href, 734 success: function(msg){ 735 var data = eval("(" + msg + ")"); 736 if ( data["html"] ) 737 { 738 $.fancybox(data["html"]); 739 } 740 return false; 741 } 742 }); 743} 744 745function shareFacebook() 746{ 747 var share = { 748 method: "stream.share", 749 u: $(this).attr( "href" ) 750 }; 751 752 FB.ui(share, function(response) {}); 753 return false; 754} 755 756function updateShelfPage(shelfName, page, fade) { 757 var shelf = $('div.shelf[rel="'+shelfName+'"]'); 758 var filter = $('span.filter',shelf); 759 var visiblePage = $('.page:visible',shelf); 760 var newPage = $('.page[rel="page'+page+'"]',shelf); 761 var params = new Array(); 762 if(typeof shelfPredefined == 'function') 763 { 764 params = shelfPredefined(); 765 } 766 $(filter).each(function() { 767 params[$(this).attr('rel')] = $(this).text(); 768 }); 769 if(newPage.length > 0) 770 { 771 if(visiblePage.length > 0) 772 { 773 var pageCount = $('div[rel="page-count"]', visiblePage).text(); 774 $(visiblePage).fadeOut(fade,function() { 775 $(newPage).fadeIn(fade,function() { 776 updateShelfPager(shelfName, page, params['perpage'], pageCount*params['perpage'] ); 777 }); 778 }); 779 } else { 780 var pageCount = $('div[rel="page-count"]', newPage).text(); 781 $(newPage).fadeIn(fade,function() { 782 updateShelfPager(shelfName, page, params['perpage'], pageCount*params['perpage'] ); 783 }); 784 } 785 if(page == 1 && !params['cycle']) { 786 $('.arrow-left:visible',shelf).fadeOut(); 787 } 788 if(page != 1) { 789 $('.arrow-left:not(:visible)',shelf).fadeIn(); 790 } 791 if(page == pageCount && !params['cycle']) { 792 $('.arrow-right:visible',shelf).fadeOut(); 793 } 794 if(page != pageCount) { 795 $('.arrow-right:not(:visible)',shelf).fadeIn(); 796 } 797 798 } else { 799 var data = "page="+page; 800 for (i in params) { 801 data = data+'&'+i+'='+params[i]; 802 } 803 $.ajax({ 804 type: "POST", 805 url: "/ajax/shelf-page", 806 data: data, 807 success: function(msg){ 808 var shelf = $('div.shelf[rel="'+shelfName+'"]'); 809 var innerShelf = $('.inner-wide-shelf',shelf); 810 if(visiblePage.length > 0) 811 { 812 var visiblePageNo = $(visiblePage).attr('rel').substr(4); 813 var pageCount = $('div[rel="page-count"]', visiblePage).text(); 814 $(visiblePage).fadeOut(fade,function() { 815 if(visiblePageNo < page) 816 $(this).after(msg); 817 else 818 $(this).before(msg); 819 $('.page:visible',shelf).hide().fadeIn(fade, function() { 820 updateShelfPager(shelfName, page, params['perpage'], pageCount*params['perpage'] ); 821 }); 822 }); 823 } else { 824 $('.page',shelf).hide(); 825 $(innerShelf).append(msg); 826 var pageCount = $('.page:visible div[rel="page-count"]', shelf).text(); 827 $('.page:visible',shelf).hide().fadeIn(fade, function() { 828 updateShelfPager(shelfName, page, params['perpage'], pageCount*params['perpage'] ); 829 }); 830 } 831 if(page == 1) { 832 $('.arrow-left',shelf).hide(); 833 } else { 834 $('.arrow-left',shelf).show(); 835 } 836 if(pageCount == 0 || page == pageCount) { 837 $('.arrow-right',shelf).hide(); 838 } else { 839 $('.arrow-right',shelf).show(); 840 } 841 } 842 }); 843 } 844} 845 846function updateShelfPager(shelfName, page, perpage, count) { 847 if($('.shelf-pager[rel="'+shelfName+'"]').length > 0) 848 { 849 850 var hash = window.location.hash.substr(1); 851 if(hash != '') { 852 var afterlink = ''; 853 hashPairs = hash.split('&'); 854 for(var i in hashPairs) { 855 var hashPair = String(hashPairs[i]).split('='); 856 if(hashPair[0] == shelfName) 857 { 858 afterlink = hashPair[1].replace(/^[0-9]*/,''); 859 break; 860 } 861 } 862 var link = '#'+shelfName+'='; 863 $.ajax({ 864 type: "POST", 865 url: "/ajax/shelf-pager", 866 data: 'page='+page+'&perpage='+perpage+'&count='+count+'&link='+link+'&linkafter='+afterlink, 867 success: function(msg){ 868 $('.shelf-pager[rel="'+shelfName+'"]').removeClass('clicked').html(msg); 869 } 870 }); 871 } 872 } 873 if(typeof shelfPredefined == 'function') 874 { 875 params = shelfPredefined(); 876 if(typeof params['callback'] == 'function') params['callback'](); 877 } 878} 879 880function slidePages(elem,direction) { 881 var shelf = $(elem).parent(); 882 var shelfName = $(shelf).attr('rel'); 883 var innerShelf = $('.inner-wide-shelf',shelf); 884 var visiblePage = $('.page:visible',shelf); 885 if(visiblePage.length == 0) return; 886 var visiblePageNo = $(visiblePage).attr('rel').substr(4); 887 var filter = $('span.filter',shelf); 888 var params = new Array(); 889 if(typeof shelfPredefined == 'function') 890 { 891 params = shelfPredefined(); 892 } 893 894 $(filter).each(function() { 895 params[$(this).attr('rel')] = $(this).text(); 896 }); 897 var pageCount = $('.page[rel="page'+visiblePageNo+'"] div[rel="page-count"]', shelf).text(); 898 var newPageNo = params['cycle'] ? ( direction == 1 ? ( parseInt(visiblePageNo) == pageCount ? 1 : parseInt(visiblePageNo)+(1*direction) ) : ( parseInt(visiblePageNo) == 1 ? pageCount : parseInt(visiblePageNo)+(1*direction) ) ) : parseInt(visiblePageNo)+(1*direction); 899// var newPageNo = parseInt(visiblePageNo)+(1*direction); 900 if(visiblePageNo == 1 && direction == -1 && !params['cycle']) return false;
901 if(visiblePageNo == pageCount && direction == 1 && !params['cycle']) return false; 902 $('img',elem).addClass('loader'); 903 if($('.page[rel="page'+newPageNo+'"]',shelf).length > 0) 904 { 905 var newPage = $('.page[rel="page'+newPageNo+'"]',shelf); 906 if(direction == -1) 907 { 908 $(newPage).css('marginLeft',-$(newPage).outerWidth()).show(); 909 if($(newPage).index() > $(visiblePage).index()) $(newPage).insertBefore($(visiblePage)); 910 var slideElem = newPage; 911 var margin = 0; 912 } else { 913 $(newPage).css('marginLeft',0).show(); 914 if($(newPage).index() < $(visiblePage).index()) $(newPage).insertAfter($(visiblePage)); 915 var slideElem = visiblePage; 916 var margin =-$(visiblePage).outerWidth(); 917 } 918 if($('.page[rel="page'+newPageNo+'"] .outer',shelf).length == 0) 919 { 920 pageCount = newPageNo; 921 $('img',elem).removeClass('loader'); 922 } else { 923 $(slideElem).animate({ marginLeft: margin },'slow','swing',function() { 924 $(visiblePage).hide(0,function() { 925 $(this).css('marginLeft',0); 926 }); 927 if(params['nohash'] != true) 928 { 929 setShelfPageHash(shelfName, newPageNo, undefined, undefined); 930 } 931 932 updateShelfPager(shelfName, newPageNo, params['perpage'], pageCount*params['perpage'] ); 933 $('img',elem).removeClass('loader'); 934 }); 935 } 936 if(direction == -1 && newPageNo == 1 && !params['cycle']) { 937 $('.arrow-left',shelf).fadeOut(); 938 } 939 if(direction == 1 && newPageNo != 1) { 940 $('.arrow-left',shelf).fadeIn(); 941 } 942 if(direction == 1 && pageCount != -1 && newPageNo >= pageCount && !params['cycle']) { 943 $('.arrow-right',shelf).fadeOut(); 944 } 945 if(direction == -1 && newPageNo != pageCount) { 946 $('.arrow-right',shelf).fadeIn(); 947 } 948 949 } else { 950 var data = "page="+newPageNo; 951 for (i in params) { 952 data = data+'&'+i+'='+params[i]; 953 } 954 $.ajax({ 955 type: "POST", 956 url: "/ajax/shelf-page", 957 data: data, 958 success: function(msg){ 959 if(direction == -1) 960 { 961 $(msg).insertBefore(visiblePage); 962 var newPage = $('.page[rel="page'+newPageNo+'"]',shelf); 963 $(newPage).css('marginLeft',-$(newPage).outerWidth()); 964 var slideElem = newPage; 965 var margin = 0; 966 } else { 967 $(msg).insertAfter(visiblePage); 968 var newPage = $('.page[rel="page'+newPageNo+'"]',shelf); 969 var slideElem = visiblePage; 970 var margin =-$(visiblePage).outerWidth(); 971 } 972 if($('.page[rel="page'+newPageNo+'"] .outer',shelf).length == 0) 973 { 974 pageCount = newPageNo; 975 $('img',elem).removeClass('loader'); 976 } else { 977 $(slideElem).animate({ marginLeft: margin },'slow','swing',function() { 978 $(visiblePage).css('marginLeft',0).hide(); 979 $('img',elem).removeClass('loader'); 980 if(params['nohash'] != true) 981 { 982 983 // if($('span.filter',shelf).length > 0) { 984 // setShelfPageHash(shelfName, newPageNo, $('span.filter',shelf).text(), $('span.filter',shelf).attr('rel')); 985 // } else { 986 setShelfPageHash(shelfName, newPageNo, undefined, undefined); 987 // } 988 } 989 990 updateShelfPager(shelfName, newPageNo, params['perpage'], pageCount*params['perpage'] ); 991 }); 992 } 993 if(direction == -1 && newPageNo == 1 && !params['cycle']) { 994 $('.arrow-left',shelf).fadeOut(); 995 } 996 if(direction == 1 && newPageNo != 1) { 997 $('.arrow-left',shelf).fadeIn(); 998 } 999 if(direction == 1 && newPageNo == pageCount && !params['cycle']) { 1000 $('.arrow-right',shelf).fadeOut(); 1001 } 1002 if(direction == -1 && newPageNo != pageCount) { 1003 $('.arrow-right',shelf).fadeIn(); 1004 } 1005 } 1006 }); 1007 } 1008 return false; 1009}; 1010 1011function setShelfPageHash(shelf, page, filter, name, forceSingle) { 1012 var hashPairs = new Array(); 1013 var updated = false; 1014 1015 var hash = window.location.hash.substr(1); 1016 if(hash != '') { 1017 hashPairs = hash.split('&'); 1018 1019 1020 for(var i in hashPairs) { 1021 var hashPair = String(hashPairs[i]).split('='); 1022 var filters = String(hashPair[1]).split('/'); 1023 if(hashPair[0] == shelf) { 1024 if(filter != undefined) { 1025 if(name != undefined) { 1026 var filtered = false; 1027 for(var j in filters) { 1028 if(j > 0 && j%2 == 0 && (filters[j] == name || forceSingle)) 1029 { 1030 filters[j-1] = filter; 1031 filtered = true; 1032 break; 1033 } 1034 } 1035 if(!filtered) 1036 { 1037 filters.push(filter); 1038 filters.push(name); 1039 } 1040 } 1041 } 1042 if(filters[0] != page) 1043 { 1044 filters[0] = page; 1045 } 1046 hashPairs[i] = shelf+'='+filters.join('/'); 1047 updated = true; 1048 } 1049 } 1050 1051 } 1052 if(!updated) { 1053 if(filter != undefined) { 1054 if(name != undefined) { 1055 hashPairs.push(shelf+'='+page+'/'+filter+'/'+name); 1056 } else { 1057 hashPairs.push(shelf+'='+page+'/'+filter+'/'); 1058 } 1059 } else { 1060 hashPairs.push(shelf+'='+page); 1061 } 1062 } 1063 1064 window.location.hash = '#'+hashPairs.join('&'); 1065} 1066 1067function loadShelfPage(shelf, newPageNo) { 1068 var shelf = $(shelf); 1069 var shelfName = $(shelf).attr('rel'); 1070 var innerShelf = $('.inner-wide-shelf',shelf); 1071 var filter = $('span.filter',shelf); 1072 var params = new Array(); 1073 if(typeof shelfPredefined == 'function') 1074 { 1075 params = shelfPredefined(); 1076 } 1077 1078 $(filter).each(function() { 1079 params[$(this).attr('rel')] = $(this).text(); 1080 }); 1081 1082 var data = "page="+newPageNo; 1083 for (i in params) { 1084 data = data+'&'+i+'='+params[i]; 1085 } 1086 $(shelf).addClass('loader'); 1087 $.ajax({ 1088 type: "POST", 1089 url: "/ajax/shelf-page", 1090 data: data, 1091 success: function(msg){ 1092 page = $(msg).hide(); 1093 $('.page',shelf).hide(); 1094 $(innerShelf).append(page); 1095 1096 if($('.page[rel="page'+newPageNo+'"] .outer',shelf).length == 0) 1097 { 1098 pageCount = newPageNo; 1099 $(shelf).removeClass('loader'); 1100 } else { 1101 pageCount = $('div[rel="page-count"]', page).text(); 1102 $(shelf).removeClass('loader'); 1103 $(page).fadeIn(300,function() { 1104 //$('img',elem).removeClass('loader'); 1105 if(params['nohash'] != true) 1106 { 1107 setShelfPageHash(shelfName, newPageNo, undefined, undefined); 1108 } 1109 updateShelfPager(shelfName, newPageNo, params['perpage'], pageCount*params['perpage'] ); 1110 }); 1111 } 1112 if(newPageNo == 1 && !params['cycle']) { 1113 $('.arrow-left',shelf).fadeOut(); 1114 } 1115 if(newPageNo != 1) { 1116 $('.arrow-left',shelf).fadeIn(); 1117 } 1118 if(newPageNo == pageCount && !params['cycle']) { 1119 $('.arrow-right',shelf).fadeOut(); 1120 } 1121 if(newPageNo != pageCount) { 1122 $('.arrow-right',shelf).fadeIn(); 1123 } 1124 } 1125 }); 1126 return false;
1127}; 1128 1129$(document).ajaxStop(function() { 1130 if(typeof $.fancybox == 'function') { 1131 $('a[rel="fancybox"], a.fancybox').fancybox({ 1132 'type' : 'ajax', 1133 'showNavArrows': false, 1134 'titleShow' : false, 1135 'padding' : 0 1136 }); 1137 } 1138}); 1139 1140 1141$(document).ready(function() { 1142 1143 if(typeof $.fancybox == 'function') { 1144 $('a[rel="fancybox"], a.fancybox').fancybox({ 1145 'type' : 'ajax', 1146 'showNavArrows': false, 1147 'titleShow' : false, 1148 'padding' : 0 1149 }); 1150 $('a[rel="fancyboxp"], a.fancyboxp').live('click',function() { 1151 $.fancybox.showActivity(); 1152 $.ajax({ 1153 type : 'POST', 1154 url : $(this).attr('href'), 1155 dataType: 'json', 1156 success: function(data) { 1157 if(data && data['html']) { 1158 $.fancybox(data['html'],{'padding' : 0}); 1159 } 1160 } 1161 }); 1162 return false; 1163 }); 1164 $('a[rel="fancyboxi"]').fancybox({ 1165 'type' : 'iframe', 1166 'showNavArrows': false, 1167 'titleShow' : false, 1168 'padding' : 0 1169 }); 1170 $('a[rel="fancyboxr"], a.fancyboxr').fancybox({ 1171 'type' : 'ajax', 1172 'showNavArrows': false, 1173 'titleShow' : false, 1174 'padding' : 0, 1175 'onClosed': function() { 1176 window.location.reload(); 1177 } 1178 }); 1179 $('a[rel="fancybox-close"]').live('click',function() { 1180 $.fancybox.close(); 1181 return false; 1182 }); 1183 1184 $('a[rel="fancyboxj"], a.fancyboxj').live('click', function () { 1185 $.fancybox.showActivity(); 1186 url = $(this).attr('href'); 1187 if(url.indexOf('?') != -1) 1188 url = url+'&'; 1189 else 1190 url = url+'?'; 1191 $.getJSON( url+'callback=?', function(data){ $.fancybox(data["html"],{"padding":0}); } ); 1192 return false; 1193 }); 1194 1195 $('a.add-friend, button.add-friend, a.remove-friend, button.remove-friend, a.join-club, a.quit-club').fancybox({ 1196 'type':'ajax', 1197 'padding' : 0, 1198 'onClosed': function() { 1199 window.location.reload(); 1200 } 1201 }); 1202 }; 1203 1204 $('.book-detail .price').click(function() { 1205 $('.dualprice',this).slideToggle(100); 1206 return false; 1207 }); 1208 1209 $('body').click(function() { 1210 $('#header .flat-button .menu-panel, #header .menu-button .menu-panel').fadeOut(100); 1211 $('#header .flat-button .menu-panel, #header .menu-button .menu-panel').removeClass('open');; 1212 }); 1213 1214 $('a.video-help').click(function() { 1215 $.ajax({ 1216 type : 'POST', 1217 url : '/ajax/embed-video', 1218 data : 'link='+encodeURIComponent(this.href), 1219 success: function(data) { 1220 $.fancybox(data,{ 1221 'autoDimensions' : false, 1222 'width' : 640, 1223 'height' : 360, 1224 'padding' : 0 1225 }); 1226 } 1227 }); 1228 return false; 1229 }); 1230 1231/* lightbox */ 1232 $('.add-to-lightbox').live('click',function() { 1233 var button = $(this); 1234 var maxWidth = 77; 1235 var maxHeight = 104; 1236 var idBook = $(button).parent().attr('rel'); 1237 if($('#lightbox .outer a[rel="'+idBook+'"]').length > 0) return false; 1238 $.ajax({ 1239 type: "POST", 1240 url: '/ajax/add-to-lightbox', 1241 data: 'idBook='+idBook, 1242 success: function(msg){ 1243 if(msg == 1) 1244 { 1245 var pub = $(button).parents('.outer').clone(); 1246 if(pub.length == 0) 1247 { 1248 pub = $('<div class="outer"></div>').append($(button).parents('div.image').clone()); 1249 } 1250 $.ajax({ 1251 type: "POST", 1252 url: '/ajax/highest-link-for-book', 1253 data: 'idBook='+idBook, 1254 success: function(msg){ 1255 $('.image a',pub).attr('href',msg); 1256 } 1257 }); 1258 if($('h4',pub).length <= 0 ) 1259 { 1260 $(pub).append($('<h4></h4>')); 1261 } 1262 $('h4',pub).html('<strong>'+$('.pub-detail .full-name',pub).html()+'</strong> | <a href="'+$('.pub-detail .author-link',pub).html()+'">'+$('.pub-detail .author',pub).html()+'</a> | <b>'+$('.pub-detail .pricetag',pub).html()+'</b>'); 1263 $('a[rel="'+idBook+'"] .add-to-lightbox').addClass('hide'); 1264 if($('.favtag',pub).length == 0) 1265 $('.image a',pub).append($('.add-to-lightbox',pub).clone().removeClass('add-to-lightbox').addClass('add-to-bookmarks')); 1266 var iwidth = $('.image a',pub).width(); 1267 var iheight = $('.image a',pub).height(); 1268 if(iheight > maxHeight || iwidth > maxWidth) 1269 { 1270 if(maxHeight/maxWidth < iheight/iwidth) 1271 { 1272 newHeight = maxHeight; 1273 newWidth = newHeight*iwidth/iheight; 1274 } 1275 else 1276 { 1277 newWidth = maxWidth; 1278 newHeight = newWidth*iheight/iwidth; 1279 } 1280 $('.image a',pub).width(newWidth); 1281 $('.image a',pub).height(newHeight); 1282 $('.image a img',pub).width(newWidth); 1283 $('.image a img',pub).height(newHeight); 1284 } 1285 $('.pub-detail, .left-shadow, .right-shadow, .price, span.link, .rent',pub).remove(); 1286 $('.add-to-lightbox',pub).addClass('remove-from-lightbox').removeClass('add-to-lightbox'); 1287 $(pub).css('opacity',0); 1288 $('#lightbox-bottom-inner-wide.page').append(pub); 1289 $(pub).animate({opacity:1},200); 1290 $('#lightbox-top-inner .count').text($('#lightbox-bottom-inner .outer').length); 1291 if($('#lightbox').hasClass('hide')) 1292 { 1293 $('#lightbox').fadeToggle(200,function() { 1294 SetCookie('lightbox-state',2,100); 1295 $('#lightbox').toggleClass('hide'); 1296 }); 1297 } 1298 } 1299 } 1300 }); 1301 return false;
1302 }); 1303 1304 $('.remove-from-lightbox').live('click',function() { 1305 var button = $(this); 1306 var idBook = $(button).parent().attr('rel'); 1307 $.ajax({ 1308 type: "POST", 1309 url: '/ajax/remove-from-lightbox', 1310 data: 'idBook='+idBook, 1311 success: function(msg){ 1312 if(msg == 1) 1313 { 1314 $('a[rel="'+idBook+'"] .add-to-lightbox').removeClass('hide'); 1315 $(button).parents('.outer').fadeOut(200,function() { 1316 $(this).remove(); 1317 $('[rel="'+idBook+'"] .add-to-lightbox').removeClass('hide'); 1318 $('#lightbox-top-inner .count').text($('#lightbox-bottom-inner .outer').length); 1319 if($('#lightbox-bottom-inner .outer').length == 0) 1320 { 1321 $('#lightbox-top-inner .hider').trigger('click'); 1322 $('#lightbox-title').html(''); 1323 } 1324 }); 1325 } 1326 } 1327 }); 1328 return false; 1329 }); 1330 1331 $('.favtag').live('click',function() { 1332 var button = $(this); 1333 var idBook = $(this).parent().attr('rel'); 1334 if($(this).hasClass('added')) 1335 { 1336 $.ajax({ 1337 type: "POST", 1338 url: '/ajax/fav-pub', 1339 data: 'idBook='+idBook+'&action=2', 1340 success: function(msg){ 1341 var data = eval("(" + msg + ")"); 1342 if(data['result']) 1343 { 1344 $('div.image a[rel="'+idBook+'"] .favtag').removeClass('added'); 1345 //fadeOut(150,function() { $(button).removeClass('added'); }); 1346 } 1347 } 1348 }); 1349 } 1350 else 1351 { 1352 $.ajax({ 1353 type: "POST", 1354 url: '/ajax/fav-pub', 1355 data: 'idBook='+idBook+'&action=1', 1356 success: function(msg){ 1357 var data = eval("(" + msg + ")"); 1358 if(data['result']) 1359 { 1360 $('div.image a[rel="'+idBook+'"] .favtag').addClass('added'); 1361 /*$(button).addClass('added'); 1362 $('.favtag',$('.add-to-lightbox[rel="'+$(button).attr('rel')+'"]').parent()).fadeIn(150,function() { 1363 $(button).addClass('added'); 1364 });*/ 1365 } 1366 } 1367 }); 1368 } 1369 return false; 1370 }); 1371 1372 $('#lightbox-top .close').live('click',function() { 1373 $('#lightbox').fadeOut(200,function() { 1374 $('#lightbox').addClass('hide'); 1375 SetCookie('lightbox-state',0,100); 1376 }); 1377 }); 1378 1379 $('.my-lightbox').click(function() { 1380 $('#lightbox').fadeToggle(200,function() { 1381 if($('#lightbox').hasClass('hide')) 1382 { 1383 SetCookie('lightbox-state',2,100); 1384 } else { 1385 SetCookie('lightbox-state',0,100); 1386 } 1387 $('#lightbox').toggleClass('hide'); 1388 }); 1389 }); 1390 1391 $('#lightbox-top-inner .hider').live('click',function() { 1392 $('#lightbox').addClass('hidden'); 1393 SetCookie('lightbox-state',1,100); 1394 }); 1395 1396 $('.hidden #lightbox-top-inner .hider').live('click',function() { 1397 $('#lightbox').removeClass('hidden'); 1398 SetCookie('lightbox-state',2,100); 1399 }); 1400 $('#lightbox .arrow-right').live('click',function() { 1401 $('#lightbox-bottom-inner').animate({scrollLeft: $('#lightbox-bottom-inner').scrollLeft()+$('#lightbox-bottom-inner').width()}, 300); 1402 }); 1403 $('#lightbox .arrow-left').live('click',function() { 1404 $('#lightbox-bottom-inner').animate({scrollLeft: $('#lightbox-bottom-inner').scrollLeft()-$('#lightbox-bottom-inner').width()}, 300); 1405 }); 1406 $('#lightbox .operations').click(function() { 1407 $('.menu-panel',this).slideToggle(100); 1408 }); 1409 $('#lightbox .operations .clear').click(function() { 1410 if($('#lightbox .outer').length <= 0) return false; 1411 $.ajax({ 1412 type: "POST", 1413 url: '/ajax/clear-lightbox', 1414 success: function(msg){ 1415 if(msg == 1) 1416 { 1417 $('.add-to-lightbox').removeClass('hide'); 1418 $('#lightbox .outer').fadeOut(200,function() { 1419 $(this).remove(); 1420 }); 1421 $('#lightbox-title').html(''); 1422 $('#lightbox-top-inner .count').text('0'); 1423 $('#lightbox-top-inner .hider').trigger('click'); 1424 } 1425 } 1426 }); 1427 }); 1428 $('#lightbox .outer').live('mouseover',function() { 1429 $('#lightbox-title').html($('h4',this).html()); 1430 }); 1431 1432/* /lightbox */ 1433 1434/* bookshelf */ 1435
1436 $('.shelf').each(function() { 1437 if($('.page',this).length) 1438 { 1439 pageNo = $('.page',this).attr('rel').substr(4); 1440 pageCount = $('div[rel="page-count"]',this).html(); 1441 } else { 1442 pageNo = 0; 1443 pageCount = 0; 1444 } 1445 if(pageCount == 0 || (pageNo >= pageCount && pageCount != -1)) 1446 { 1447 $('button.arrow-right',this).hide(); 1448 } 1449 }); 1450 1451 $('.shelf .arrow-right').live('click',function() { 1452 if (typeof shelfInterval != 'undefined' && typeof shelfInterval[$(this).parent().attr('rel')] != 'undefined') { window.clearInterval( shelfInterval[$(this).parent().attr('rel')] ) }; 1453 return $('img',this).hasClass('loader') ? false : slidePages(this,1); 1454 }); 1455 $('.shelf .arrow-left').live('click',function() { 1456 if (typeof shelfInterval != 'undefined' && typeof shelfInterval[$(this).parent().attr('rel')] != 'undefined') { window.clearInterval( shelfInterval[$(this).parent().attr('rel')] ) }; 1457 return $('img',this).hasClass('loader') ? false : slidePages(this,-1); 1458 }); 1459 $('.shelf .select-box').click(function() { 1460 $('.menu-panel',this).slideToggle(100); 1461 }); 1462 $('.shelf .select-box a').click(function() { 1463 var shelf = $(this).parents('div.shelf'); 1464 var selectBox = $(this).parents('div.select-box'); 1465 var filterType = $(this).parent().attr('rel'); 1466 var filterValue = $(this).attr('rel'); 1467 var filterName = $(this).text(); 1468 var shelfName = $(shelf).attr('rel'); 1469 if($('.filter',shelf).text() == $(this).attr('rel')) { 1470 $('.menu-panel',selectBox).slideToggle(100); 1471 return false; 1472 } 1473 $('.filter',shelf).text(filterValue); 1474 $('.filter',shelf).attr('rel',filterType); 1475 $('span.box-selected',selectBox).text(filterName); 1476 $('ul',selectBox).hide(); 1477 $('.shelf[rel!="'+shelfName+'"] .select-box li a').removeClass('hide').show(); 1478 $('.shelf[rel!="'+shelfName+'"] .select-box li[rel="'+filterType+'"] a[rel="'+filterValue+'"]').hide(); 1479 $('.page',shelf).remove(); 1480 updateShelfPage($(shelf).attr('rel'),1,100); 1481 setShelfPageHash($(shelf).attr('rel'), 1, filterValue, filterType, true); 1482 return false; 1483 }); 1484 1485 $('#user-title-filter').change(function() { 1486 var shelf = $('div.shelf[rel="'+$(this).attr('rel')+'"]'); 1487 if(shelf.length > 0) 1488 { 1489 $('.page',shelf).remove(); 1490 if($('.filter[rel="title"]',shelf).length > 0) 1491 { 1492 $('.filter[rel="title"]',shelf).text($(this).val()); 1493 } 1494 else 1495 { 1496 $(shelf).append('<span class="filter" rel="title">'+$(this).val()+'</span>'); 1497 } 1498 updateShelfPage($(shelf).attr('rel'),1,100); 1499 setShelfPageHash($(shelf).attr('rel'), 1, $(this).val(), 'title'); 1500 } 1501 }); 1502 1503 $('#search-form.user-title-search').submit(function() { 1504 var shelfName = $(this).attr('rel'); 1505 var shelf = $('div.shelf[rel="'+shelfName+'"]'); 1506 var searchText = $('#search-input',this).val(); 1507 if(shelf.length > 0) 1508 { 1509 $('.page',shelf).remove(); 1510 if($('.filter[rel="text"]',shelf).length > 0) 1511 { 1512 $('.filter[rel="text"]',shelf).text(searchText); 1513 } 1514 else 1515 { 1516 $(shelf).append('<span class="filter" rel="text">'+searchText+'</span>'); 1517 } 1518 updateShelfPage(shelfName,1,100); 1519 setShelfPageHash(shelfName, 1, searchText, 'text'); 1520 return false; 1521 } 1522 }); 1523 1524 $('.shelf-pager a').live('click',function() { 1525 if($(this).parents('.shelf-pager').hasClass('clicked')) return false; 1526 $(this).parents('.shelf-pager').addClass('clicked'); 1527 shelfName = $(this).parents('.shelf-pager').attr('rel'); 1528 var re = new RegExp('^.*'+shelfName+'=([0-9]*).*'); 1529 var page = $(this).attr('href').replace(re,'$1'); 1530 if($(this).hasClass('first')) 1531 { 1532 slidePages($('.shelf[rel="'+shelfName+'"] > button.arrow-left '),-1); 1533 } else if($(this).hasClass('last')) 1534 { 1535 slidePages($('.shelf[rel="'+shelfName+'"] > button.arrow-right'),1); 1536 } else 1537 { 1538 updateShelfPage(shelfName, page, 100); 1539 } 1540 //return false; // the link should be a hash anchor! 1541 }); 1542 1543 var hash = window.location.hash.substr(1); 1544 if(hash != '') { 1545 hashPairs = hash.split('&'); 1546 var hashSubPair = new Array(); 1547 for(var i in hashPairs) { 1548 var hashPair = String(hashPairs[i]).split('='); 1549 var shelf = $('.shelf[rel="'+hashPair[0]+'"]'); 1550 if(shelf.length > 0) 1551 { 1552// var filter = $('span.filter',shelf); 1553 var changed = false;
1554 if(hashPair[1] != undefined) 1555 { 1556 hashSubPair = String(hashPair[1]).split('/'); 1557 for(var j in hashSubPair) { 1558 if(j > 0 && j%2 == 0) 1559 { 1560 if(hashSubPair[j] == 'title' && $('select.title-filter[rel="'+hashPair[0]+'"]').length > 0) 1561 { 1562 $('select.title-filter[rel="'+hashPair[0]+'"] option[value="'+hashSubPair[j-1]+'"]').attr('selected','selected'); 1563 } 1564 if(hashSubPair[j] == 'text' && $('form.user-title-search[rel="'+hashPair[0]+'"] #search-input').length > 0) 1565 { 1566 $('form.user-title-search[rel="'+hashPair[0]+'"] #search-input').val(hashSubPair[j-1]); 1567 } 1568 1569 var changed2 = false; 1570 var filter = $('span.filter[rel="'+hashSubPair[j]+'"]',shelf); 1571 if(filter.length > 0) 1572 { 1573 if($(filter).text() != hashSubPair[j-1]) 1574 { 1575 $('span.filter[rel="'+hashSubPair[j]+'"]',shelf).text(hashSubPair[j-1]); 1576 changed = true; 1577 changed2 = true; 1578 } 1579 } else { 1580 $('span.filter',shelf).each(function() { 1581 if($('.select-box',shelf).length > 0 && $('.select-box li[rel="'+$(this).attr('rel')+'"] a[rel="'+$(this).text()+'"]',shelf).length > 0) 1582 { 1583 $('span.filter[rel="'+$(this).attr('rel')+'"]',shelf).text(hashSubPair[j-1]); 1584 $('span.filter[rel="'+$(this).attr('rel')+'"]',shelf).attr('rel',hashSubPair[j]); 1585 changed2 = true; 1586 changed = true; 1587 } 1588 }); 1589 if(!changed2) 1590 { 1591 $(shelf).append('<span class="filter" rel="'+hashSubPair[j]+'">'+hashSubPair[j-1]+'</span>'); 1592 changed = true; 1593 changed2 = true; 1594 } 1595 } 1596 1597 if(changed2) 1598 { 1599 if($('.select-box',shelf).length > 0 && $('.select-box li[rel="'+hashSubPair[j]+'"] a[rel="'+hashSubPair[j-1]+'"]',shelf).length > 0) 1600 { 1601 $('span.box-selected',shelf).text($('.menu-panel li[rel="'+hashSubPair[j]+'"] a[rel="'+hashSubPair[j-1]+'"]',shelf).text()); 1602 $('.shelf[rel!="'+hashPair[0]+'"] .select-box li a').removeClass('hide').show(); 1603 $('.shelf[rel!="'+hashPair[0]+'"] .select-box li[rel="'+hashSubPair[j]+'"] a[rel="'+hashSubPair[j-1]+'"]').hide(); 1604 } 1605 } 1606 } 1607 } 1608 1609 } 1610 1611 console.log(changed); 1612 1613 if(changed || hashSubPair[0] != 1) 1614 { 1615 $('div.shelf[rel="'+hashPair[0]+'"] .page').remove(); 1616 updateShelfPage(hashPair[0], hashSubPair[0],0); 1617 } else { 1618 filter = $('span.filter',shelf); 1619 params = new Array(); 1620 if(typeof shelfPredefined == 'function') 1621 { 1622 params = shelfPredefined(); 1623 } 1624 $(filter).each(function() { 1625 params[$(this).attr('rel')] = $(this).text(); 1626 }); 1627 if(params['cycle']) 1628 { 1629 $('.arrow-left, .arrow-right',shelf).show(); 1630 1631 } 1632 } 1633 1634 1635/* if(hashSubPair[0] != 1 || (hashSubPair[1] != undefined && hashSubPair[1] != filter.text()) || (hashSubPair[2] != undefined && hashSubPair[2] != filter.text())) { 1636 if(hashSubPair[1] != undefined && filter.length > 0) 1637 { 1638 if(hashSubPair[2] != undefined && filter.length > 0) 1639 { 1640 filter.attr('rel',hashSubPair[2]); 1641 } 1642 filter.text(hashSubPair[1]); 1643 $('.shelf[rel="'+hashPair[0]+'"] span.box-selected').text($('.shelf[rel="'+hashPair[0]+'"] .menu-panel li[rel="'+filter.attr('rel')+'"] a[rel="'+hashSubPair[1]+'"]').text()); 1644 $('.shelf[rel!="'+hashPair[0]+'"] .select-box li a').removeClass('hide').show(); 1645 $('.shelf[rel!="'+hashPair[0]+'"] .select-box li[rel="'+filter.attr('rel')+'"] a[rel="'+filter.text()+'"]').hide(); 1646 } 1647 updateShelfPage(hashPair[0], hashSubPair[0],0); 1648 }*/ 1649 } 1650 } 1651 1652 } 1653 1654/* /bookshelf */ 1655 1656 $('#header .flat-button:has(.menu-panel), #header .menu-button:has(.menu-panel)').click(function(event) { 1657 var isOpen = $('.menu-panel',this).hasClass('open'); 1658 $('#header .flat-button .menu-panel, #header .menu-button .menu-panel').fadeOut(100); 1659 $('#header .flat-button .menu-panel, #header .menu-button .menu-panel').removeClass('open');; 1660 if(!isOpen) 1661 { 1662 $('.menu-panel',this).addClass('open'); 1663 $('.menu-panel',this).fadeIn(200); 1664 event.stopPropagation(); 1665 } 1666 }).dblclick(function() { 1667 window.getSelection().removeAllRanges(); 1668 return false;
1669 }); 1670 1671/* share */ 1672 1673 $('.flw_share').each( function () 1674 { 1675 var sBook = $(this).attr('tag'); 1676 var idBook = $(this).attr('idBook'); 1677 $(this).fancybox({ 1678 ajax : { 1679 type : "POST", 1680 data : 'url='+sBook+'&idBook='+idBook 1681 }, 1682 'type':'ajax', 1683 'showNavArrows': false, 1684 'titleShow' : false, 1685 'padding' : 0 1686 }); 1687 }); 1688 1689 $('ul.friends-share li a').live( 'click', shareToFriend ); 1690 $('button[name=shareMailSend]').live( 'click', shareToMail ); 1691 1692/* /share */ 1693 1694 $('#titles').change(function() { 1695 if($('#titles option:selected').val() != 0) { 1696 $('#editButton').show(); 1697 $('#deleteButton').show(); 1698 } else { 1699 $('#editButton').hide(); 1700 $('#deleteButton').hide(); 1701 } 1702 }); 1703 1704 $('#dailyTitle').click(function() { 1705 if ($(this).attr("checked") == true) { 1706 $('#daysForTitle').show(); 1707 } else { 1708 $('#daysForTitle').hide(); 1709 } 1710 }); 1711 1712 $('#newContent').click(function() { 1713 if ($(this).attr("checked") == true) { 1714 $('#changesPdf').show(); 1715 } else { 1716 $('#changesPdf').hide(); 1717 } 1718 }); 1719 1720 $('#oldchangeslink').click(function() { 1721 $('#oldchangeslist').toggle(200); 1722 return false; 1723 }); 1724 1725 $('#registration-form input[name="sefName"]').live("keyup",function() { 1726 var input = $(this); 1727 var nick = $(input).val(); 1728 var idUser = $('#idUser').text(); 1729 var data = 'sefName='+nick; 1730 if(idUser != false) { 1731 data = 'sefName='+nick+'&idUser='+idUser; 1732 } 1733 $.ajax({ 1734 type: "POST", 1735 url: '/ajax/nick-preview', 1736 data: data, 1737 success: function(msg){ 1738 if(msg != "0") { 1739 $(input).addClass('error'); 1740 $('.error-frame ul li[rel="sefName"]').addClass('visible').html(msg).show(); 1741 $('.error-frame').slideDown(100); 1742 } else { 1743 $('.error-frame ul li[rel="sefName"]').removeClass('visible').hide(); 1744 if($('.error-frame td li.visible').size() == 0) { 1745 $('.error-frame').slideUp(100); 1746 } 1747 $(input).removeClass('error'); 1748 } 1749 } 1750 }); 1751 }); 1752 1753 $('#registration-form input[name="email"], #buy-book-form #fEmail, #buy-reg-book-form #fEmail, #buy-reg-online-form #fEmail, #order-printed-form #fEmail').die('blur'); 1754 $('#registration-form input[name="email"], #buy-book-form #fEmail, #buy-reg-book-form #fEmail, #buy-reg-online-form #fEmail, #order-printed-form #fEmail').live('blur',function() { 1755 var input = $(this); 1756 var email = $(this).val(); 1757 if(email.length < 1) 1758 return; 1759 $.ajax({ 1760 type: "POST", 1761 url: '/ajax/email-preview', 1762 data: { email: email }, 1763 success: function(msg){ 1764 if(msg != "0") { 1765 $(input).addClass('error'); 1766 $('.error-frame ul li[rel="email2"]').addClass('visible').html(msg).show(); 1767 $('.error-frame').slideDown(100); 1768 } else { 1769 $('.error-frame ul li[rel="email2"]').removeClass('visible').hide(); 1770 if($('.error-frame td li.visible').size() == 0) { 1771 $('.error-frame').slideUp(100); 1772 } 1773 $(input).removeClass('error'); 1774 } 1775 } 1776 }); 1777 }); 1778 1779 $('.batch-titles select').change(function() { 1780 $.ajax({ 1781 type: "POST", 1782 url: '/ajax/batch-titles', 1783 data: 'id='+$(this).val(), 1784 success: function(msg){ 1785 $('.batch-prepaids').html(msg); 1786 } 1787 }); 1788 }); 1789 1790 $('#add-promo-link').click(function() { 1791 $('#add-promo-table').toggle('slow'); 1792 return false; 1793 }); 1794 1795 $('select[name="promo-title"]').live('change',function() { 1796 $.ajax({ 1797 type: "POST", 1798 url: '/ajax/batch-titles', 1799 data: 'id='+$(this).val(), 1800 success: function(msg){ 1801 $('.promo-prepaids').html(msg); 1802 $('.promo-prepaids select').attr('name','promo-prepaid'); 1803 } 1804 }); 1805 }); 1806 1807 $('#title-manager-edit #type').live('change',function() { 1808 $('#title-manager-edit select[id^="category_"]').addClass('hide'); 1809 $('#title-manager-edit select[id^="category_'+$(this).val()+'"]').removeClass('hide'); 1810 }); 1811 1812 $('input[name="promo-date"]').keyup(function() { 1813 var reg = /^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/ 1814 if(reg.exec($(this).val())) { 1815 $(this).siblings('span').addClass('green'); 1816 $(this).siblings('span').removeClass('error'); 1817 $(this).removeClass('errorInput'); 1818 } else { 1819 $(this).siblings('span').removeClass('green'); 1820 $(this).siblings('span').addClass('error'); 1821 } 1822 }); 1823 1824 $('#add-promo-table #generate-codes').live('click',function() { 1825 var reg = /^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$/ 1826 var dt = $('input[name="promo-date"]'); 1827 if(!$('input[name="date-from-activate"]').is(':checked') && !reg.exec(dt.val())) { 1828 dt.removeClass('green'); 1829 dt.addClass('error'); 1830 return false;
1831 } 1832 }); 1833 1834 if(typeof $.datepicker !== 'undefined') { 1835 $('.datepicker').datepicker({ dateFormat: 'dd.mm.yy' }); 1836 } 1837 1838 $('#poEmail').keyup(function() { 1839 $('#poEmailButton').removeClass('hidden').css('display','inline'); 1840 }); 1841 1842 $('#title-filter').change(function() { 1843 var url = document.location.href; 1844 if(url.match(/\/[0-9]+\/[0-9]+$/g)) { 1845 var slash = url.lastIndexOf('/'); 1846 if($(this).val() != 0) 1847 window.location = url.substring(0,slash)+'/'+$(this).val(); 1848 else 1849 window.location = url.substring(0,slash); 1850 } else if(url.match(/\/[0-9]+$/g)) { 1851 if($(this).val() != 0) 1852 window.location = url+'/'+$(this).val(); 1853 else 1854 window.location = url; 1855 } else { 1856 if($(this).val() != 0) { 1857 if(url.match(/\/$/g)) { 1858 window.location = url+"1/"+$(this).val(); 1859 } else { 1860 window.location = url+"/1/"+$(this).val(); 1861 } 1862 } else { 1863 window.location = url; 1864 } 1865 } 1866 }); 1867 1868 $('#title-search-filter').change(function() { 1869 var url = document.location.href.split('?')[0]; 1870 if(url.match(/\/[0-9]+$/g)) { 1871 var slash = url.lastIndexOf('/'); 1872 if($(this).val() != 0) 1873 window.location = url.substring(0,slash)+'/'+$(this).val(); 1874 else 1875 window.location = url.substring(0,slash); 1876 } else { 1877 if($(this).val() != 0) { 1878 if(url.match(/\/$/g)) { 1879 window.location = url+$(this).val(); 1880 } else { 1881 window.location = url+"/"+$(this).val(); 1882 } 1883 } else { 1884 window.location = url; 1885 } 1886 } 1887 }); 1888 1889 $('input.unempty').live('focus',function() { 1890 if($(this).val() == $(this).data('unempty')) 1891 { 1892 $(this).val('').removeClass('blurred'); 1893 } 1894 }).live('blur',function() { 1895 if($(this).val() == '') 1896 { 1897 $(this).val($(this).data('unempty')).addClass('blurred'); 1898 } 1899 }); 1900 1901});
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.