1/* ======================================================================== 2 * DOM-based Routing 3 * Based on http://goo.gl/EUTi53 by Paul Irish 4 * 5 * Only fires on body classes that match. If a body class contains a dash, 6 * replace the dash with an underscore when adding it to the object below. 7 * 8 * .noConflict() 9 * The routing is enclosed within an anonymous function so that you can 10 * always reference jQuery with $, even when in .noConflict() mode. 11 * 12 * Google CDN, Latest jQuery 13 * To use the default WordPress version of jQuery, go to lib/config.php and 14 * remove or comment out: add_theme_support('jquery-cdn'); 15 * ======================================================================== */ 16 17(function($) { 18 19 function padZeroes(i) { 20 var bar = ""+i; 21 while(bar.length < 3) { 22 bar = "0"+bar; 23 } 24 return bar; 25 } 26 27 function TextualiJpgsLoader() { 28 this.lastloaded = parseInt(window.DifdufGoTo) > 1 ? window.DifdufGoTo - 1 : 0; 29 this.hasmore = true; 30 this.book = window.DifdufBase; 31 this.bookurl = window.DifdufUrl; 32 this.loadmore = function() { 33 var i = 0; 34 var loader = this; 35 while(i++ < 5 && loader.hasmore) { 36 this.loadNext() 37 } 38 }; 39 40 this.setParams = function(url) { 41 ret = true; 42 this.bookurl = url; 43 m = url.match(/([a-z]\d{3})\/?$/); 44 if(m && m.length == 2) { 45 this.book = m[1]; 46 window.DifdufLimit = -1; 47 } 48 else { 49 ret = false; 50 } 51 return ret; 52 } 53 54 this.loadNext = function() { 55 var loader = this; 56 var loading = new Image(); 57 loading.src = loader.next(); 58 loading.onload = function() { 59 $('#phone-difduf-area').append(this); 60 if(loader.hasmore && ((loader.lastloaded < window.DifdufLimit) || window.DifdufLimit == -1)) { 61 loader.loadNext(); 62 } 63 } 64 loading.onerror = function() { 65 loader.hasmore = false; 66 } 67 } 68 69 this.next = function() { 70 this.lastloaded++; 71 var ret = this.bookurl; 72 ret += '/jpg/'+this.book; 73 ret += 'p'+padZeroes(this.lastloaded)+'.jpg'; 74 return ret; 75 }; 76 77 this.bind_scroll = function() { 78 var h = $('#phone-difduf-area img').eq(0).get(0).height; 79 $(window).scroll(function(){ 80 if ($(this).scrollTop() > (tjloader.lastloaded - 2) * h && tjloader.hasmore) { 81 tjloader.loadmore(); 82 } 83 else { 84 console.log($(this).scrollTop(), tjloader, h); 85 } 86 }); 87 }; 88 89 } 90 91 92 //for elegance later 93 $.fn.runNumbers = function(newcount) { 94 var j = 1, d = 1500/newcount, tar=$(this); 95 tar.text(0).fadeIn(d); 96 function RunNumbers() { 97 if(j <= newcount) { 98 tar.text(j++); 99 } 100 else { 101 tar.delay(2000).fadeOut(300); 102 clearInterval(RunningIt); 103 } 104 } 105 var RunningIt = setInterval(RunNumbers,d); 106 return tar; 107 }; 108 109 function modal_display_response(data) { 110 $('#textuali-frame').modal('show').find('.modal-body').html(data); 111 } 112 function update_rating_columns(data) { 113 if(data.updated) { 114 for(ind in data.columns) { 115 $('.rating-bar').eq(ind-1).animate({ 116 height: data.columns[ind].new_height 117 },300 ).find('.vote-counter').runNumbers(data.columns[ind].votes); 118 } 119 } 120 else { 121 $('#revote').data('rate',data.revote); 122 $('#failed-vote-alert-content').html(data.fail_message); 123 $('#failed-vote-alert').fadeIn(300); 124 } 125 } 126 127 //a little helper for the next one 128 function sum_heights(container,stopelem) { 129 h = 0; 130 cur = container.find('> *').first(); 131 while(cur.get(0) != stopelem) { 132 h += cur.outerHeight(); 133 cur = cur.next(); 134 } 135 return h; 136 } 137 138 //some adjustments because of absolute positioning in archive type pages 139 function adjust_main_andoffsets() { 140 var ex = $('.excerpt-full'), 141 m = $('.main.twoblocks'); 142 if(ex.length > 0) { 143 var bottom = ex.last().offset().top+ex.last().height(); 144 m.css('min-height', Math.max(bottom,m.height()) +'px'); 145 ex.each(function() { 146 offs = sum_heights($(this).parent(),$(this).prev().get(0)); 147 $(this).css('top', offs + 'px'); 148 }); 149 } 150 } 151 152 // Use this variable to set up the common and page specific functions. If you 153 function get_more_issues() { 154 $.ajax({ 155 type: "POST", 156 url: location.host, 157 data: {action : 'get_more_issues', already_paged: window.pagedIssues}, 158 success: function(data) { 159 if(data == 'no_more_issues') { 160 return; 161 } 162 else { 163 //$('<div>'+data.html+'</div>').find(window.isoIt).each(function() { 164 //$('main').prepend($(this)).isotope('prepended' , $(this)); 165 //}); 166 $('main').prepend(data.html); 167 if(typeof(data.add_to_paged) == 'object' && data.add_to_paged.length > 0) { 168 window.pagedIssues = window.pagedIssues.concat(data.add_to_paged); 169 get_more_issues(); 170 } 171 } 172 }, 173 dataType: "JSON" 174 175 }); 176 177 /*$(window.isoCont).isotope('layout').find(window.isoIt).click(function() { 178 $(window.isoIt).not(this).removeClass('open'); 179 $(this).toggleClass('open'); 180 $("html, body").animate({ scrollTop: $(this).offset().top - 100 , scrollLeft: $(this).width()}, 600); 181 182 });*/ 183 $('.think-issue-block').click(function() { 184 $('.think-issue-block').not(this).removeClass('open'); 185 $(this).toggleClass('open'); 186 var tar = $(this); 187 setTimeout(function() { 188 var p = tar.find('.block-popup').height(), 189 i = tar.find('img').height(); 190 if(p > i + 25) { 191 tar.find('.block-popup').height(i - 20).after('<span class="more">××¢××...</span>'); 192 } 193 },210); 194 $('html,body').animate({scrollTop: $(this).offset().top - 100, scrollLeft: $(this).width()},600); 195 }); 196 } 197 function difduf_frame_height() { 198 var height = $(window).height() - 40; 199 $('#textuali-frame').find('iframe').height(Math.max(height,500)); 200 } 201 function iframe_in_modal(url) {
202 $('#textuali-frame').modal('show').find('.modal-body').html('<iframe></iframe>'); 203 difduf_frame_height(); 204 setTimeout(function() { 205 $('#textuali-frame').find('iframe').attr('src',url); 206 },100); 207 } 208 209 // rename this variable, you will also need to rename the namespace below. 210 211 var Roots = { 212 // All pages 213 common: { 214 init: function() { 215 //var authurl = "http://textuali.com/texts/zvi_yanai/"; 216 var authurl = location.origin+'/machshavot/'; 217 var display_params = location.href.match(/#(vid|book|slideshow|doc)=(.*)$/); 218 if(display_params != null) { 219 switch(display_params[1]) { 220 case 'book' : 221 var u = display_params[2]; 222 var d = decodeURIComponent(window.location.hash); 223 if (/#page\/\d+(&q=.+)?$/.test(d)){ 224 u += d.replace('&','?'); 225 } 226 iframe_in_modal(authurl+'/'+u); 227 break; 228 case 'vid' : 229 video_in_modal(display_params[2]); 230 break; 231 case 'slideshow' : 232 slideshow_in_modal(display_params[2]) 233 break; 234 case 'doc': 235 $('.doc-wrap#'+display_params[2]).trigger('click'); 236 break; 237 default: 238 $.noop(); 239 } 240 } 241 242 $(".navbar-toggle").click(function() { 243 $(this).toggleClass("nav-is-open"); 244 }); 245 246 $('#textuali-frame').on('hidden.bs.modal', function (e) { 247 $(this).find('.modal-body').empty(); 248 }); 249 var h = $(window).height(); 250 $('body').css('min-height', h); 251 $('main,#timeline').css('min-height', h - 85 - 20 ); 252 $('.editorial-collapser').click(function() { 253 $(this).toggleClass('open'); 254 }); 255 $('.writer-photo').click(function() { 256 var tar = $(this).data('popover'); 257 $('.writer-popover:not('+tar+')').removeClass('in'); 258 $(tar).toggleClass('in'); 259 }); 260 261 $('.close-popover').click(function() { 262 $(this).closest('.writer-popover').removeClass('in'); 263 }); 264 if(window.screenType == "phone" && window.hasDifduf) { 265 tjloader = new TextualiJpgsLoader(); 266 tjloader.loadNext(); 267 } 268 269 $(window).scroll(function(){ 270 if ($(this).scrollTop() > 100) { 271 $('#scrollup').fadeIn(); 272 } else { 273 $('#scrollup').fadeOut(); 274 } 275 }); 276 $('#scrollup').click(function(){ 277 $("html, body").animate({ scrollTop: 0 }, 600); 278 return false; 279 }); 280 281 $('#right-strip .sidebar-component > iframe').css('height', $(window).height()*0.9); 282 283 $('.rating-bar,.rating-label,#revote').click(function() { 284 var d = $('#post-ratings').data(); 285 var data = 'action=postratings&pid=' + d.postid + '&rate=' + $(this).data('rate'); 286 data += '&postratings_' + d.postid + '_nonce=' + d.nonce; 287 if($(this).is('#revote')) { 288 data += '&revote=true'; 289 } 290 $.ajax({ 291 url: '/', 292 xhrFields: {withCredentials: true}, 293 dataType: 'json', 294 data: data, 295 cache: false, 296 type:'POST', 297 dataType:'json', 298 success: update_rating_columns 299 }); 300 301 if($(this).is('#revote')) { 302 $('.alert').fadeOut(300); 303 } 304 }); 305 306 $('#failed-vote-alert').find('.close,#dont-revote,#revote').click(function() { 307 $('#failed-vote-alert').fadeOut(300); 308 }); 309 310 $('#rating-stats a').click(function(c) { 311 c.preventDefault(); 312 var n = $('#rating-stats').data('nonce'); 313 var a = this.id.replace('-','_'); 314 $.ajax({ 315 url: location.origin+'/wp-admin/admin-ajax.php', 316 xhrFields: {withCredentials: true}, 317 dataType: 'json', 318 data: 'action='+a+'&ratingstatsn='+n, 319 cache: false, 320 type:'POST', 321 dataType:'html', 322 success: modal_display_response 323 }); 324 }); 325 326 $('#searchform-trigger,#share-trigger').click(function() { 327 var share = $(this).is('#share-trigger'), 328 par = share ? $('#share-container') : $('#search-container'), 329 bro = share ? $('#searchform-trigger') : $('#share-trigger'), 330 bropar = share ? $('#search-container') : $('#share-container'); 331 bropar.removeClass('in'); 332 bro.removeClass('active'); 333 $(this).toggleClass('active'); 334 par.toggleClass('in'); 335 }); 336 337 338 if('undefined' != typeof(Isotope) && $(window).width() > 480) { 339 $(window).load(function() { 340 $(window.isoCont).isotope({ 341 isOriginLeft: false, 342 //rtl: true, 343 itemSelector: window.isoIt, 344 layoutMode: 'masonry', 345 //sortBy: 'order', 346 //getSortData : { 347 // order : '[data-order]' 348 //} 349 }); 350 if(typeof(window.isAllIssues) != 'undefined' ) { 351 get_more_issues(); 352 } 353 }); 354 } 355 356 $('#show-sidebar').click(function() { 357 if($('#primary-navigation').hasClass('in')) { 358 $('#primary-navigation').collapse('hide'); 359 } 360 $(this).fadeOut(200, function() { 361 $(this).toggleClass('shower').fadeIn(150); 362 }); 363 364 //$(this).find('span').toggleClass('glyphicon-remove'); 365 $('body').toggleClass('sidebar-display'); 366 367 }); 368 $('#zenit').click(function() { 369 $(this).fadeOut(200, function() { 370 $(this).toggleClass('shower').fadeIn(150); 371 }); 372 $('#right-strip').toggleClass('darkened'); 373 }); 374 375 $('#font-size-toggle').click(function(c) { 376 c.preventDefault(); 377 var target = $($(this).data('target')); 378 if($(this).hasClass('enlarge')) { 379 var l = $(this).data('large'); 380 target.find('*').css('font-size',l); 381 $(this).removeClass('enlarge').addClass('diminish').attr('title', Hebrew.diminish_font).tooltip('fixTitle'); 382 } 383 else { 384 var s = $(this).data('small'); 385 target.find('*').css('font-size',s); 386 $(this).addClass('enlarge').removeClass('diminish').attr('title', Hebrew.enlarge_font).tooltip('fixTitle'); 387 } 388 }); 389 390 $('[data-toggle="tooltip"]').tooltip() 391 392 function flipCover(hideme,showme, duration) { 393 $(hideme).addClass('hidecover').removeClass('showcover'); 394 setTimeout(function() { 395 $(hideme).hide(); 396 $(showme).show().addClass('showcover').removeClass('hidecover'); 397 },duration); 398 } 399 400 $('.local-difduf-button.desktop, .local-difduf-button.tablet').click(function() { 401 var url = window.DifdufUrl;//$(this).data('difduf'); 402 if(parseInt(window.DifdufGoTo) > 0) { 403 url += '/#page/'+window.DifdufGoTo; 404 } 405 iframe_in_modal(url); 406 }); 407 408 $('.load-modaliframe').click(function(c) { 409 c.preventDefault(); 410 var h = this.href; 411 if(window.screenType == "phone") { 412 tjloader = new TextualiJpgsLoader(); 413 $('#phone-difduf-area').show().find('img').detach(); 414 $('main').hide(); 415 $('#scrollup').css('right', '+=25px'); 416 if(tjloader.setParams(h)) { 417 tjloader.loadNext(); 418 } 419 else { 420 iframe_in_modal(h); 421 } 422 } 423 else { 424 iframe_in_modal(h); 425 } 426 }); 427 428 $('.local-difduf-button.phone').click(function() { 429 $('main').hide(); 430 $('#phone-difduf-area').show(); 431 $('#scrollup').css('right', '+=25px'); 432 //tjloader.loadmore(); 433 }); 434 $('#close-phone-difduf').click(function() { 435 $('#scrollup').css('right', '-=25px'); 436 $('main').show(); 437 $('#phone-difduf-area').hide(); 438 }); 439 440 $('.front-back').click(function() { 441 var dur = 1200; 442 if($(this).hasClass('showing-front')) { 443 flipCover('#front-cover','#back-cover',dur); 444 $(this).removeClass('showing-front').addClass('showing-back'); 445 } 446 else { 447 flipCover('#back-cover','#front-cover',dur); 448 $(this).removeClass('showing-back').addClass('showing-front'); 449 } 450 }); 451 452 $(window).resize(difduf_frame_height); 453 $('.util.smaller').click(function() { 454 $('html').removeClass('large-font'); 455 $('.util.larger').addClass('in'); 456 $(this).removeClass('in'); 457 }); 458 $('.util.larger').click(function() { 459 $('html').addClass('large-font'); 460 $('.util.smaller').addClass('in'); 461 $(this).removeClass('in'); 462 }); 463 464 $('.util.print').click(function() { 465 var content = $('#content').html(); 466 467 if(undefined != content) { 468 var w = window.open('','win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');
469 w.document.write('<html><head><title>print text</title></head>'); 470 w.document.write('<body style="direction:rtl;text-align:right;"><button onclick="window.print();" id="print">print</button>'+content+'</body></html>'); 471 } 472 }); 473 } 474 }, 475 476 // pages with isotope 477 //moved to "common" because I don't know when the writers photos widget is used 478 _isotope_: { 479 init: function() { 480 /*if('undefined' != typeof(Isotope)) { 481 $(window).load(function() { 482 $(window.isoCont).isotope({ 483 rtl: true, 484 itemSelector: window.isoIt, 485 layoutMode: 'masonry' 486 }); 487 if(typeof(window.isAllIssues) != 'undefined' ) { 488 get_more_issues(); 489 } 490 }); 491 }*/ 492 } 493 }, 494 books : { 495 init: function() { 496 $('.book-item').click(function() { 497 var src = $(this).data('difduf'); 498 $('#difduf-area iframe').attr('src', src); 499 }); 500 } 501 }, 502 archive: { 503 init: function() { 504 //adjust_main_andoffsets(); 505 //$(window).resize(adjust_main_andoffsets); 506 } 507 }, 508 people: { 509 init: function() { 510 $(window).on({ 511 'resize' : adjust_main_andoffsets, 512 'load' : adjust_main_andoffsets 513 }); 514 } 515 }, 516 issues : { 517 init: function() { 518 //$('#accordion-1').find('.accordion-title').eq(0).trigger('click'); 519 520 } 521 }, 522 523 // About us page, note the change from about-us to about_us. 524 about_us: { 525 init: function() { 526 // JavaScript to be fired on the about us page 527 } 528 }, 529 all_issues: { 530 init: function() { 531 $('main').height($('body').height()); 532 } 533 }, 534 timeline: { 535 init: function() { 536 $(window).resize(function() { 537 $('#timeline').attr('src',this.src).css('min-height', $(window).height() - 90); 538 539 }); 540 } 541 }, 542 texts: { 543 init: function() { 544 /*var d = $('#sidebar-tabs-remarks').detach(); 545 $(window).load(function() { 546 $('#sidebar-tabs').after(d.addClass('in')); 547 /*$('.tab-activator').click(function() { 548 var active = $(this).hasClass('active'), 549 hider = $(this).hasClass('hideremarks'); 550 if(!active && hider) { 551 $('#sidebar-tabs-remarks').removeClass('in'); 552 } 553 else if(!hider) { 554 $('#sidebar-tabs-remarks').addClass('in'); 555 } 556 }); 557 558 }); 559 $('a[data-toggle="tab"]').on('shown.bs.tab', function() { 560 var tabid = $(this).attr('href'); 561 if($(tabid).height() > $(this).closest('ul').height()) { 562 $('#sidebar-tabs-remarks').removeClass('in'); 563 } 564 });*/ 565 } 566 } 567 }; 568 569 // The routing fires all common scripts, followed by the page specific scripts. 570 // Add additional events for more control over timing e.g. a finalize event 571 var UTIL = { 572 fire: function(func, funcname, args) { 573 var namespace = Roots; 574 funcname = (funcname === undefined) ? 'init' : funcname; 575 if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') { 576 namespace[func][funcname](args); 577 } 578 }, 579 loadEvents: function() { 580 UTIL.fire('common'); 581 582 $.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) { 583 UTIL.fire(classnm); 584 }); 585 } 586 }; 587 588 $(document).ready(UTIL.loadEvents); 589 590})(jQuery); // Fully reference jQuery after this point.
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.