1jQuery(document).ready(function(){ 2 3 var win = $(window); 4 5 var heleo_pageview_id; 6 7 isMobile = false; //initiate as false 8 9 // device detection 10 if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 11 || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.
11substr(0,4))){ 12 isMobile = true; 13 } 14 15 ko.validation.init({ 16 insertMessages: false, 17 decorateInputElement : true, 18 decorateElementOnModified: true, 19 errorMessageClass: 'err' 20 }); 21 22 ko.bindingHandlers.fadeVisible = { 23 init: function(element, valueAccessor) { 24 // Initially set the element to be instantly visible/hidden depending on the value 25 var value = valueAccessor(); 26 $(element).toggle(ko.unwrap(value)); // Use "unwrapObservable" so we can handle values that may or may not be observable 27 }, 28 update: function(element, valueAccessor) { 29 // Whenever the value subsequently changes, slowly fade the element in or out 30 var value = valueAccessor(), 31 unwrappedValue = ko.unwrap(value), 32 display = unwrappedValue ? "inline-block" : "none", 33 action = unwrappedValue ? "fadeIn" : "fadeOut", 34 $element = $(element); 35 36 //this feels like a hack, but works... 37 if($element.closest('.topbar-share').length) { 38 $element[action](); 39 } else { 40 $element[action]("fast", function() { 41 $element.attr("style", "display: " + display + " !important"); 42 }); 43 } 44 } 45 }; 46 47 ko.bindingHandlers.fade = { 48 init: function(element, valueAccessor) { 49 var value = valueAccessor(); 50 $(element).toggle(ko.unwrap(value)); 51 }, 52 update: function(element, valueAccessor) { 53 var value = valueAccessor(), 54 unwrappedValue = ko.unwrap(value), 55 display = unwrappedValue ? "block" : "none", 56 action = unwrappedValue ? "fadeIn" : "fadeOut", 57 $element = $(element); 58 $element[action]("fast", function() { 59 $element.attr("style", "display: " + display + " !important"); 60 }); 61 } 62 }; 63 64 ViewModel = function() { 65 var self = this; 66 67 self.user_email = ko.observable(false); 68 postRead = ko.observable(false); 69 70 self.showToolbarIcons = ko.observable(false); 71 72 //signing up 73 self.signupSuccess = ko.observable(false); 74 self.remoteSignupSuccess = ko.observable(false); 75 self.signupError = ko.observable(false); 76 77 self.show_nav = ko.observable(false); 78 self.show_subnav = ko.observable(false); 79 self.show_dropdown = ko.observable(false); 80 self.show_sharebox = ko.observable(false); 81 self.show_search = ko.observable(false); 82 83 self.show_progressbar = ko.observable(false); 84 85 //influencer page 86 self.show_more_text = ko.observable(false); 87 self.show_influencer_feed = ko.observable(true); 88 self.show_influencer_about = ko.observable(false); 89 self.show_influencer_books = ko.observable(false); 90 91 //TL newsletter CTAs 92 self.show_influencer_slider = ko.observable(false); 93 self.show_influencer_signups = ko.observable(false); 94 95 self.submitted = ko.observable(false); 96 97 self.is_scrolled = ko.observable(false); 98 99 self.uid = Cookies.get('heleoid'); 100 self.sid = Cookies.get('heleosid'); 101 102 self.uuid = ko.observable(self.uid); 103 104 self.email = ko.observable().extend({ 105 required: true, 106 email: { 107 params: true, 108 message: "Email is invalid!" 109 } 110 }); 111 112 self.searchterm = ko.observable(); 113 114 self.reads = ko.observableArray([]); 115 self.influencers = ko.observableArray([]); 116 self.feed_items = ko.observableArray([]); 117 118 self.more_feed_items = ko.observableArray([]); 119 120 self.pagenumber = 1; 121 self.show_load_more = ko.observable(true); 122 123 // $('#popup-2').foundation('reveal', 'open'); 124 125 //should we show TL newsletter slider? 126 if(Heleo.Options.has_newsletter && Heleo.Options.newsletter_name.length && Heleo.Options.is_single && Heleo.Options.post_type !== 'conversation') { 127 128 var influencer = Heleo.Options.influencer_id; 129 var cookie = Cookies.getJSON('heleo_' + influencer); 130 var signedUp; 131 132 if(typeof cookie == 'undefined') { 133 self.show_influencer_slider(true); 134 Cookies.set('heleo_' + influencer, {shown: 1, signedUp: 0}, {expires: 8000, secure: true}); 135 } else { 136 137 var times_shown = cookie.shown; 138 var signedUp = cookie.signedUp; 139 140 if(times_shown <= 5 && !signedUp ) { 141 142 self.show_influencer_slider(true); 143 var num = ++cookie.shown; 144 145 Cookies.set('heleo_' + influencer, {shown: num, signedUp: signedUp}, {expires: 8000, secure: true}); 146 147 } else { 148 149 self.show_influencer_slider(false); 150 } 151 152 if(cookie.signedUp) { 153 self.show_influencer_signups(false); 154 } 155 156 } 157 //console.log(Cookies.getJSON('heleo_' + influencer)); 158 } 159 160 //should we show tl signups? 161 if (Heleo.Options.has_newsletter && Heleo.Options.newsletter_name.length && Heleo.Options.is_author) { 162 var cookieKey = 'heleo_' + Heleo.Options.influencer_id; 163 //console.log(cookieKey) 164 if (!Cookies.getJSON(cookieKey)) { 165 self.show_influencer_signups(true); 166 Cookies.set(cookieKey, {shown: 0, signedUp: 0}, {expires: 8000, secure: true}); 167 } else { 168 var cookie = Cookies.getJSON(cookieKey) 169 console.log(cookie) 170 self.show_influencer_signups(!cookie.signedUp); 171 } 172 } 173 174 self.toggleAuthorSlider = function() { 175 $(".author-slider").addClass('closed'); 176 } 177 178 Heleo.UI.hedDekAnimation(); 179 Heleo.UI.lazyloadImages(); 180 Heleo.UI.processExternalLinks(); 181 Heleo.UI.getRecommendedPosts(); 182 183 self.loadMore = function() { 184 self.pagenumber++; 185 var offset = $('.page-content .article-item').length 186 187 //load more on hp and topics pages: TODO: revisit this 188 if(Heleo.Options.topicname) { 189 segment = 'topic'; 190 key = Heleo.Options.topicname; 191 } else if(Heleo.Options.is_influencer) { 192 segment = 'influencer'; 193 key = Heleo.Options.influencer_id; 194 offset = $('.main-feed > article').length; 195 } else if(Heleo.Options.author_id) { 196 segment = 'author'; 197 key = Heleo.Options.author_id; 198 // } else if(Heleo.Options.is_search) { 199 // segment = null; 200 // key = null; 201 202 } else { 203 segment = null; 204 key = null; 205 } 206 207 var data = { 208 action: 'heleo_load_more', 209 topic: Heleo.Options.topicname, 210 object: segment, 211 val: key, 212 page: self.pagenumber, 213 security: Heleo.Options.nonce, 214 offset: offset 215 } 216 217 Heleo.API.get(Heleo.Options.ajaxurl, data, false, '.load-more') 218 219 .success(function(more, success) { 220 221 if(more.success !== false) { 222 $(more).appendTo('.main-feed').hide().fadeIn(1000); 223 Heleo.UI.lazyloadImages(); 224 Heleo.UI.hedDekAnimation(); 225 } else { 226 $('.main-feed').after(more.data); 227 self.show_load_more(!self.show_load_more()); 228 } 229 }); 230 }; 231 232 //NEWSLETTER COOKIES 233 self.getParameterByName = function(name) { 234 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
235 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 236 results = regex.exec(location.search); 237 return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 238 } 239 240 self.newsletter_cookie = function() { 241 242 //if no utm_source return 243 if (! self.getParameterByName('utm_source')) { 244 return; 245 } 246 247 const src = self.getParameterByName('utm_source') 248 const campaign = self.getParameterByName('utm_campaign') 249 const cookie = Cookies.get(src) 250 251 if ( typeof cookie === 'undefined' ) { 252 const expires = 365 * 20; 253 Cookies.set(src, campaign, {expires: expires, secure: true}) 254 } 255 } 256 self.newsletter_cookie(); 257 258 259 //triggers from email input box after ko determines email is valid 260 //asks wp about user 261 //we will need to create wp users on successful FOLLOW/SIGNUP 262 self.email.subscribe(function(newValue) { 263 }); 264 265 //search 266 search_form_submit = function (form) { 267 } 268 269 //the gist 270 signup_form_submit = function (form) { 271 272 self.submitted(true); // activate spinner 273 274 var data = {}; 275 $.each($(form).serializeArray(), function(i, field) { 276 data[field.name] = field.value; 277 }); 278 279 var remote = data.action == 'remote' 280 var gist = data.signup_gist == 'on' 281 var gist_list_id = data.gist_list_id || null 282 var gist_interests = data.gist_interests || null 283 var email = data.email 284 285 //DEBUG && console.log(data) 286 data = JSON.stringify(data) 287 288 Heleo.API.get(Heleo.Options.ajaxurl + '?action=heleo_signup&data=' + data) 289 .done(function(result) { 290 //reset forms 291 self.submitted(false); 292 293 switch(result) { 294 case 200: 295 296 DEBUG && console.log(result); 297 298 if(remote) { 299 //close author slider after 6s 300 setTimeout(function() { 301 $('.author-slider').addClass('closed'); 302 }, 6000); 303 304 //cookie 305 var influencer = Heleo.Options.influencer_id; 306 var cookie = Cookies.getJSON('heleo_' + influencer); 307 Cookies.set('heleo_' + influencer, {shown: 5, signedUp: true}, {expires: 8000, secure: true}); 308 309 } else { 310 activateSocialWidget('fbshares'); 311 activateSocialWidget('tweets'); 312 activateSocialWidget('linkedin'); 313 314 //set signup cookie 315 Cookies.set('heleo_subscribed', 1, {expires: 8000, secure: true}); 316 317 } 318 319 self.signupSuccess(!self.signupSuccess()); 320 321 //set signed up cookie 322 Cookies.set('heleo_subscribed', 1, {expires: 8000, secure: true}); 323 break; 324 325 default: 326 327 break; 328 } 329 }) 330 331 .error(function(err) { 332 DEBUG && console.log('err', err) 333 self.submitted(false); 334 335 }) 336 337 338 if(gist && remote && gist_list_id && gist_interests) { 339 // DEBUG && console.log('also signup gist') 340 var gist_data = {} 341 gist_data.list_id = gist_list_id 342 gist_data.interests = gist_interests 343 gist_data.email = email 344 gist_data.double_optin = 1 345 gist_data.action = 'signup' 346 347 DEBUG && console.log(gist_data) 348 349 gist_data = JSON.stringify(gist_data) 350 351 Heleo.API.get(Heleo.Options.ajaxurl + '?action=heleo_signup&data=' + gist_data) 352 .done(function(result) { 353 DEBUG && console.log('gist', result) 354 355 }) 356 } 357 358 return false 359 }; 360 361 self.read = function(post_id) { 362 if (Heleo.Options.is_single && post_id && postRead() == false) { 363 postRead(true); 364 Heleo.Analytics.trackEvent({ 365 action: 'Read', 366 scopeList: ['Post'], 367 label: 'Read', 368 heap: 'Post Read' 369 }); 370 } 371 }; 372 373 self.popup = function (data) { 374 DEBUG && console.log(data); 375 $('#popup-2').foundation('reveal', 'open'); 376 // activateSocialWidget('fbshares'); 377 // activateSocialWidget('tweets'); 378 // activateSocialWidget('linkedin'); 379 }; 380 //self.popup() 381 382 self.cookie = function() { 383 384 //show 1st pv of each new session, up to 6x 385 // check if referrer is not a heleo site 386 var external = true; 387 if (window.document.referrer && window.document.referrer.match(/heleo\.com\//gi)) { 388 external = false;
389 } 390 391 // if referrer is heleo, then it is not the 1st pv of the session 392 // ergo, don't show, return 393 if (!external) { 394 return; 395 } 396 397 var sessionsCount = parseInt(Cookies.get('heleo_sessions')); 398 if (!sessionsCount) { 399 sessionsCount = 0; 400 } 401 402 if(sessionsCount >= 6) { 403 return; 404 } 405 406 var optOut = Cookies.get('heleo_popup_optout') 407 var lastDayShown = Cookies.get('heleo_popup_last_shown') 408 var signedUp = Cookies.get('heleo_subscribed') 409 var today = new Date() 410 var shownToday = false; 411 412 //already subscribed, or opted out 413 if( ( typeof signedUp != 'undefined' && signedUp == 1) || 414 ( typeof optOut != 'undefined' && optOut == 1) ) { 415 return; 416 } 417 418 if (!lastDayShown) { 419 lastDayShown = 0; 420 } 421 422 if (today.setHours(0, 0, 0, 0) == lastDayShown) { 423 shownToday = true; 424 } 425 426 //for debugging 427 // shownToday = false 428 429 if (!shownToday) { 430 DEBUG && console.log('not shown today'); 431 sessionsCount++; 432 Cookies.set('heleo_sessions', sessionsCount, {expires: 8000, secure: true}); 433 Cookies.set('heleo_popup_last_shown', today.setHours(0, 0, 0, 0), { expires: 8000, secure: true}); 434 self.popup(); 435 // Heleo.Relay.subscribe('popup.show', self.popup); 436 Heleo.Analytics.trackEvent({ 437 action: 'Open', 438 scopeList: ['Popup'], 439 label: 'Popup', 440 heap: 'Open Popup' 441 }); 442 } 443 444 // SWDL BREAKS WITHOUT NEO4J 445 // if (visit.data.site) { 446 // Heleo.UI.populateSwdlBalloons(visit.data.site); 447 // } 448 }; 449 // self.cookie(); 450 451 self.signup_opt_out = function () { 452 Cookies.set('heleo_popup_optout', 1, {expires: 8000, secure: true}); 453 $('#popup-2').foundation('reveal', 'close'); 454 Heleo.Analytics.trackEvent({ 455 action: 'Opt Out', 456 scopeList: ['Popup'], 457 label: 'Popup', 458 heap: 'Opt Out Popup' 459 }); 460 }; 461 462 self.animate_numbers = function(el, num) { 463 $(el).text(''); 464 $({countNum: $(el).text()}).animate({countNum: num}, { 465 duration: 500, 466 easing: 'swing', 467 step: function() { 468 formattedNumber = numeral(Math.floor(this.countNum)).format(Heleo.UI.get_number_suffix(this.countNum)); 469 $(el).text(formattedNumber); 470 }, 471 complete: function() { 472 formattedNumber = numeral(Math.floor(this.countNum)).format(Heleo.UI.get_number_suffix(this.countNum)); 473 $(el).text(formattedNumber); 474 } 475 }); 476 }; 477 478 self.show_pageviews = function(id) { 479 var num = $('#' + id).data('pageviews'); 480 share_element = $('#' + id + ' .social-share-count').not('.sidebar').not('.sidebar *'); 481 482 if(!share_element.hasClass('social-share-count-complete')) { 483 self.animate_numbers(share_element, num); 484 share_element.addClass('social-share-count-complete'); 485 } 486 } 487 488 if(!isMobile) { 489 490 if(Heleo.Options.is_author) { //influencer 491 win.scroll(function(event) { 492 $("article.post").each(function(i, el) { 493 if($(el).visible(true)) { 494 self.show_pageviews($(el).attr('id')); 495 } 496 }); 497 }); 498 499 } else { //hp, topics 500 $(".main-feed").on('mouseenter', 'article', function(el){ 501 self.show_pageviews(el.currentTarget.id); 502 }); 503 } 504 } else { //mobile 505 win.scroll(function(event) { 506 $("article.post").each(function(i, el) { 507 if($(el).visible(true)) { 508 self.show_pageviews($(el).attr('id')); 509 } 510 }); 511 512 513 }); 514 } 515 516 $('#sidebar-gist').scrollToFixed({ 517 marginTop: 100, zIndex: 1, 518 limit: function() { 519 if(Heleo.Options.is_single) { 520 var limit = $('.post-footer').offset().top - $('#sidebar-gist').outerHeight(true) - 10; 521 } else { 522 var limit = null; 523 } 524 525 return limit; 526 }, 527 }); 528 529 toggleShareIcons = function () { 530 self.showToolbarIcons(!self.showToolbarIcons()); 531 } 532 533 self.toggleNav = function() { 534 if (self.show_nav()) { 535 Heleo.Analytics.trackEvent({ 536 action: 'Close', 537 scopeList: ['Menu'], 538 scope: 'Menu' 539 }); 540 } 541 self.show_nav(!self.show_nav()); 542 }; 543 544 self.toggleSubnav = function(one, subnav, name) { 545 546 547 var el = subnav.currentTarget; 548 549 //close all subnavs except ours 550 $('.subnav-open').each(function () { 551 552 if($(el).get(0) !== $(this).get(0)) { 553 554 $(this).next().slideUp("fast"); 555 $(this).toggleClass('subnav-open'); 556 } 557 }); 558 559 // Force lazyload. 560 setTimeout(function () { 561 win.trigger('scroll'); 562 }, 75); 563 564 $(el).next().slideToggle({duration:50, queue: false}); 565 $(el).toggleClass('subnav-open'); 566 }; 567 568 self.toggleTopicsSubnav = function() { 569 //$('.topics-toggle').trigger('click') 570 var element = $('#topics-toggle'); 571 //ko.utils.triggerEvent(element, 'click') 572 // $.event.trigger($.Event("click"), {}, element[0]); 573 element.next().slideToggle({duration:50, queue: false}); 574 }; 575 self.toggleTopicsSubnav() 576 577 578 579 self.toggleDropdown = function() { 580 self.show_dropdown(!self.show_dropdown()); 581 }; 582 583 if ($('#topbar-waypoint').length) { 584 585 var topbar_waypoint = new Waypoint({ 586 element: document.getElementById('topbar-waypoint'), 587 handler: function(direction) { 588 589 //if down and dropdown is closed 590 if (direction == 'down') { 591 self.is_scrolled(true); 592 } else { 593 self.is_scrolled(false); 594 } 595 }, 596 offset: '-25%' 597 }); 598 } 599 600 self.toggleSharebox = function(model, event) { 601 if (self.show_sharebox()) { 602 Heleo.Analytics.resetInteractionFlow(); 603 Heleo.Analytics.trackEvent({ 604 action: 'Close', 605 scopeList: ['Sharebox'], 606 scope: 'Sharebox' 607 }); 608 } else { 609 // slight delay temp hack 610 window.setTimeout(function () { 611 Heleo.Analytics.setInteractionFlow('Sharebox'); 612 }, 50); 613 } 614 self.show_sharebox(!self.show_sharebox()); 615 }; 616 617 Heleo.Analytics.registerAction('a[data-bind*="toggleSharebox"]', 'click', function (element, content) { 618 if (!self.show_sharebox()) { 619 return false;
620 } 621 content.action = 'Expand'; 622 }); 623 624 self.toggleSearch = function(model, event) { 625 if (self.show_search()) { 626 Heleo.Analytics.resetInteractionFlow(); 627 Heleo.Analytics.trackEvent({ 628 action: 'Close', 629 scopeList: ['Searchbox'], 630 scope: 'Searchbox' 631 }); 632 } else { 633 // slight delay temp hack 634 window.setTimeout(function () { 635 Heleo.Analytics.setInteractionFlow('Searchbox'); 636 }, 50); 637 } 638 self.show_search(!self.show_search()); 639 }; 640 641 Heleo.Analytics.registerAction('a[data-bind*="toggleSearch"]', 'click', function (element, content) { 642 if (!self.show_search()) { 643 return false; 644 } 645 content.action = 'Expand'; 646 }); 647 648 var read_waypoint = new Waypoint({ 649 element: document.getElementById('footer'), 650 handler: function(direction) { 651 // activateSocialWidget('fbshares'); 652 // activateSocialWidget('tweets'); 653 //activateSocialWidget('linkedin'); 654 }, 655 offset: 1500 656 }); 657 658 if($('#conversation-profiles').length && Heleo.Options.post_type === 'conversation') { 659 var read_waypoint = new Waypoint({ 660 element: document.getElementById('conversation-profiles'), 661 handler: function(direction) { 662 activateSocialWidget('fbshares'); 663 }, 664 offset: 200 665 }); 666 667 var bottom = $('.content-bottom').position().top - $('.main-photo').offset().top; 668 var top = $('.main-photo').position().top 669 var pb = new ProgressBar.Line( '.progressbar', { 670 easing: 'linear', 671 duration: 10 672 }) 673 674 var progress = 0; 675 $(window).scroll(); 676 677 $(window).scroll(function() { 678 var scrollTop = $(window).scrollTop(); 679 if ( scrollTop > top ) { 680 681 if(progress <= .99) { 682 progress = ((scrollTop - top) / bottom).toFixed(2) 683 pb.animate(progress) 684 } 685 686 self.show_progressbar(true); 687 688 } 689 690 if(progress < .05) { 691 progress = 0 692 pb.animate(0) 693 } 694 695 if(progress >= 1) { 696 //self.show_progressbar(false); 697 progress = .99 698 pb.animate(1) 699 } 700 701 }) 702 } 703 704 if(Heleo.Options.is_author) { 705 if($('#influencer-share').length) { 706 var read_waypoint = new Waypoint({ 707 element: document.getElementById('influencer-share'), 708 handler: function(direction) { 709 activateSocialWidget('fbshares'); 710 activateSocialWidget('tweets'); 711 }, 712 offset: 5000 713 }); 714 } 715 } 716 717 self.togglePushdown = function() { 718 //console.log('toggle'); 719 self.show_pushdown(!self.show_pushdown()); 720 }; 721 722 self.toggleRail = function() { 723 self.show_rail(!self.show_rail()); 724 }; 725 726 self.closePopup = function() { 727 $('#popup-2').foundation('reveal', 'close'); 728 }; 729 730 $(document).on('close.fndtn.reveal', '#popup-2', function () { 731 Heleo.Analytics.trackEvent({ 732 action: 'Close', 733 scopeList: ['Popup'], 734 label: 'Popup' 735 }); 736 }); 737 738 self.moreText = function() { 739 self.show_more_text(!self.show_more_text()); 740 }; 741 742 self.showInfluencerPanel = function(panel, model, el) { 743 744 //add selected class to nav item 745 $('.influencer-nav li a').each(function (item, el) { 746 $(el).removeClass('selected'); 747 }); 748 $(el.currentTarget).addClass('selected'); 749 750 //hide all panels 751 self.show_influencer_about(false); 752 self.show_influencer_books(false); 753 self.show_influencer_feed(false); 754 755 //show ours 756 self[panel](true); 757 758 $('html,body').animate({scrollTop: $('#panels').offset().top}, 100); 759 }; 760 761 if(Heleo.Options.is_author) { 762 $( window ).resize(function() { 763 764 if(Foundation.utils.is_large_up()) {
765 //add selected class to nav item 766 $('.influencer-nav li a').each(function (item, el) { 767 $(el).removeClass('selected'); 768 }); 769 770 $('.influencer-nav li a.default').addClass('selected'); 771 772 self.show_influencer_about(false); 773 self.show_influencer_books(false); 774 self.show_influencer_feed(true); 775 } 776 777 }); 778 } 779 780 self.toggleGridCard = function (model, event) { 781 var target = $(event.target), 782 card = target.parents('.card-grid-item'), 783 parent = card.parents('.card-grid-container'), 784 possibleHref = target.attr('href'); 785 if (parent.width() > 400 && possibleHref) { 786 window.location = possibleHref; 787 } else { 788 if (card.hasClass('active')) { 789 card.removeClass('active'); 790 } else { 791 $('.card-grid-item').removeClass('active'); 792 card.addClass('active'); 793 } 794 } 795 }; 796 797 self.gotoGridCard = function (model, event) { 798 var card = $(event.target), 799 href = card.data('href'), 800 isHeader = card.hasClass('.card-grid-item-header'); 801 if (!href) { 802 if (!isHeader && card.parents('.card-grid-item-header').length) { 803 isHeader = true; 804 } 805 card = card.parents('.card-grid-item'); 806 href = card.data('href'); 807 } 808 if (!isHeader && href) { 809 window.location = href; 810 } 811 }; 812 813 self.alphabetizeGridItems = function (model, event) { 814 815 var gridContainer = $(event.target).parents('.card-grid-container'), 816 gridItems = gridContainer.find('.card-grid-item'), 817 grid = gridContainer.find('.card-grid'), 818 sorted = grid.hasClass('sorted-alpha'); 819 820 gridItems = gridItems 821 .sort(function (a, b) { 822 var $item1 = sorted ? $(b) : $(a), 823 $item2 = sorted ? $(a) : $(b), 824 item1 = $item1.data('sortField').toLowerCase(), 825 item2 = $item2.data('sortField').toLowerCase(); 826 if (item1 < item2) 827 return -1; 828 if (item1 > item2) 829 return 1; 830 return 0; 831 }); 832 833 grid.addClass('sorted'); 834 grid.toggleClass('sorted-alpha'); 835 gridItems.detach().appendTo(grid); 836 }; 837 838 self.expandContent = function (model, event) { 839 var container = $(event.target).parents('.expandable-content-contain'); 840 container.toggleClass('toggle'); 841 self.show_more_text(!self.show_more_text()); 842 }; 843 844 self.goto = function(url) { 845 location.href = url; 846 }; 847 848 self.step_social = function (platform, decrement) { 849 var counter = $('.swdl-count-balloon-' + platform + ' .number'), 850 newCount; 851 if (decrement) { 852 Heleo.Wizard.put('/swdl/decrement_count/' + platform); 853 } else { 854 Heleo.Wizard.put('/swdl/increment_count/' + platform); 855 } 856 if (counter.length) { 857 newCount = parseInt(counter.attr('data-count')); 858 if (decrement) { 859 newCount--; 860 } else { 861 newCount++; 862 } 863 counter.attr('data-count', newCount); 864 counter.text(numeral(newCount).format(Heleo.UI.get_number_suffix(newCount))); 865 } 866 }; 867 868 function convertSocialForHeap (platform, subscribe) { 869 var action; 870 if (platform.toLowerCase() == 'facebook') { 871 action = (subscribe) ? 'Like' : 'Unlike'; 872 } else { 873 action = (subscribe) ? 'Follow' : 'Unfollow'; 874 }
875 return platform + ' ' + action; 876 } 877 878 // Fire up social tracking. 879 Heleo.Relay.subscribe('social.subscribe', function (data) { 880 Heleo.Analytics.trackEvent({ 881 action: 'Subscribe', 882 scopeList: Heleo.Analytics.getInteractionFlow(), 883 label: data.platform 884 }); 885 self.step_social(data.platform.toLowerCase()); 886 }); 887 Heleo.Relay.subscribe('social.unsubscribe', function (data) { 888 Heleo.Analytics.trackEvent({ 889 action: 'Unsubscribe', 890 scopeList: Heleo.Analytics.getInteractionFlow(), 891 label: data.platform 892 }); 893 self.step_social(data.platform.toLowerCase(), true); 894 }); 895 896 897 } 898 899 viewModel = new ViewModel(); 900 ko.applyBindings(viewModel); 901 902 //waypoints and stuff 903 $( window ).resize(function() { 904 if(Foundation.utils.is_medium_only() || Foundation.utils.is_small_only()) { 905 $(".topbar-share").fadeOut(200); 906 } 907 908 if(Foundation.utils.is_large_up()) { 909 if(window.scrollY > 300) { 910 $(".topbar-share").fadeIn(); 911 } 912 } 913 }); 914 915 if ($('#read-waypoint').length) { 916 917 var read_waypoint = new Waypoint({ 918 element: document.getElementById('read-waypoint'), 919 handler: function(direction) { 920 viewModel.read(Heleo.Options.post_id, Heleo.Options.post_type); 921 // console.log(this.element.id + ' triggers at ' + this.triggerPoint + ' with direction: ' + direction); 922 }, 923 offset: '75%' 924 }); 925 } 926 927 //topbar share icons on/off relative to post body icons 928 if ($('#share-waypoint').length) { 929 var share_waypoint = new Waypoint({ 930 element: document.getElementById('share-waypoint'), 931 handler: function(direction) { 932 // DEBUG && console.log('share waypoint:' + this.triggerPoint + ': ' + direction); 933 if (direction == 'down' && Foundation.utils.is_large_up()) { 934 $(".topbar-share").fadeIn(200); 935 936 } else if(direction == 'up' && Foundation.utils.is_large_up() ) { 937 $(".topbar-share").fadeOut(200); 938 } 939 940 if (direction == 'down') { 941 $('.footer-share').addClass('show'); 942 } else { 943 $('.footer-share').removeClass('show'); 944 } 945 }, 946 offset: '7%' 947 948 }); 949 } 950 951}); 952 953 954(function ($) { 955 956 if ($('.mission-widget').length) { 957 958 var $missionImage = $('#mission-image'), 959 lgPlaceholder = $missionImage.find('.large-placeholder'), 960 mdPlaceholder = $missionImage.find('.medium-placeholder'), 961 smPlaceholder = $missionImage.find('.small-placeholder'), 962 963 lgImg = $missionImage.find('.large-img'), 964 mdImg = $missionImage.find('.medium-img'), 965 smImg = $missionImage.find('.small-img'), 966 imgOpts = {isPageLoad: true}; 967 968 function resizeImage() { 969 if (Foundation.utils.is_large_up()) { 970 imgOpts.placeholder = lgPlaceholder; 971 imgOpts.img = lgImg; 972 } else if (Foundation.utils.is_medium_only()) { 973 imgOpts.placeholder = mdPlaceholder; 974 imgOpts.img = mdImg; 975 } else if (Foundation.utils.is_small_only()) { 976 imgOpts.placeholder = smPlaceholder; 977 imgOpts.img = smImg; 978 } 979 return new HeleoImageLoader(imgOpts); 980 } 981 982 resizeImage(); 983 delete imgOpts.isPageLoad; 984 $(window).resize(function () { 985 resizeImage(); 986 }); 987 988 } 989 990})(jQuery);
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.