1/** PIXWELL_CORE_SCRIPT */ 2var PIXWELL_CORE_SCRIPT = (function (Module, $) { 3 "use strict"; 4 5 Module.init = function () { 6 let self = this; 7 this._body = $('body'); 8 $(window).trigger('RB:CountBookmark'); 9 self.newsLetterSubmit(); 10 self.rbGallery(); 11 self.rbCookie(); 12 self.headerStrip(); 13 self.bookMarkCounter(); 14 self.bookmarkList(); 15 self.removeBookmarkList(); 16 self.removeBookMark(); 17 self.newsLetterPopup(); 18 self.switchDarkMode(); 19 }; 20 21 Module.initReaction = function () { 22 this.clickReaction(); 23 this.loadReactions(); 24 } 25 26 Module.rbBookMarks = function () { 27 this.loadBookMarks(); 28 this.addBookMark(); 29 }; 30 31 /** module newsletter */ 32 Module.newsLetterSubmit = function () { 33 $('.rb-newsletter-form').submit(function (e) { 34 e.preventDefault(); 35 e.stopPropagation(); 36 let target = $(this); 37 let responseWrap = target.closest('.rb-newsletter').find('.newsletter-response'); 38 responseWrap.find('.is-show').removeClass('is-show'); 39 let subscribeEmail = target.find('input[name="rb_email_subscribe"]').val(); 40 if (!subscribeEmail) { 41 responseWrap.find('.email-error').addClass('is-show'); 42 responseWrap.find('.email-error').addClass('showing'); 43 return false; 44 } 45 46 let postData = { 47 action: 'rb_submit_newsletter', 48 email: subscribeEmail 49 }; 50 51 let privacy = target.find(':checkbox[name="rb_privacy"]'); 52 if (privacy != null && privacy.length > 0) { 53 let privacyVal = privacy.prop('checked'); 54 if (!privacyVal) { 55 responseWrap.find('.privacy-error').addClass('is-show showing'); 56 return false; 57 } else { 58 postData.privacy = privacyVal; 59 } 60 } 61 62 $.ajax({
63 type: 'POST', 64 url: pixwellParams.ajaxurl, 65 data: postData, 66 success: function (response) { 67 responseWrap.find('.' + response.notice).addClass('is-show'); 68 responseWrap.find('.' + response.notice).addClass('showing'); 69 } 70 }); 71 72 return false; 73 }); 74 }; 75 76 /** Newsletter popup */ 77 Module.newsLetterPopup = function () { 78 79 if ($(window).width() < 768) { 80 return; 81 } 82 83 let targetID = '#rb-newsletter-popup'; 84 if ($(targetID).length > 0 && '1' !== $.cookie('ruby_newsletter_popup')) { 85 let delay = $(targetID).data('delay'); 86 if (!delay) { 87 delay = 2000; 88 } 89 setTimeout(function () { 90 if (PIXWELL_MAIN_SCRIPTS && true === PIXWELL_MAIN_SCRIPTS.siteAccessFlag) { 91 return; 92 } 93 $.magnificPopup.open({ 94 type: 'inline', 95 preloader: false, 96 closeBtnInside: true, 97 removalDelay: 300, 98 showCloseBtn: true, 99 closeOnBgClick: false, 100 disableOn: 992, 101 items: { 102 src: targetID, 103 type: 'inline' 104 }, 105 mainClass: 'rb-popup-effect', 106 fixedBgPos: true, 107 fixedContentPos: true, 108 closeMarkup: '<button id="rb-close-newsletter" title="%title%" aria-label="%title%" class="mfp-close"><i class="rbi rbi-move"></i></button>', 109 callbacks: { 110 close: function () { 111 let expiresTime = $(targetID).data('expired'); 112 $.cookie('ruby_newsletter_popup', '1', {expires: parseInt(expiresTime), path: '/'}); 113 } 114 } 115 }); 116 117 }, delay); 118 } 119 }; 120 121 /** Ruby gallery */ 122 Module.rbGallery = function () { 123 let gallery = $('.rb-gallery-wrap'); 124 if (gallery.length > 0) { 125 gallery.each(function () { 126 let el = $(this); 127 let inner = el.find('.gallery-inner').eq(0); 128 $(inner).isotope({ 129 itemSelector: '.rb-gallery-el', 130 percentPosition: true, 131 masonry: { 132 columnWidth: inner.find('.rb-gallery-el')[0] 133 } 134 }); 135 136 $(window).on('RB:LazyLoaded', function () { 137 inner.imagesLoaded().progress(function () { 138 $(inner).isotope('layout'); 139 }); 140 }); 141 142 $('body').imagesLoaded(function () { 143 $(inner).isotope('layout'); 144 }); 145 146 setTimeout(function () { 147 inner.removeClass('gallery-loading'); 148 }, 2000); 149 inner.imagesLoaded(function () { 150 inner.removeClass('gallery-loading'); 151 }); 152 }); 153 } 154 }; 155 156 //share action 157 Module.sharesAction = function () { 158 $('a.share-action').off('click').on('click', function (e) { 159 e.preventDefault(); 160 e.stopPropagation(); 161 window.open($(this).attr('href'), '_blank', 'width=600, height=350'); 162 return false; 163 }) 164 }; 165 166 167 /** rb cookie */ 168 Module.rbCookie = function () { 169 let rbCookie = $('#rb-cookie'); 170 if (rbCookie.length > 0) { 171 if ($.cookie('ruby_cookie_popup') !== '1') { 172 rbCookie.css('display', 'block'); 173 setTimeout(function () { 174 rbCookie.addClass('is-show'); 175 }, 10) 176 } 177 178 $('#cookie-accept').off('click').on('click', function (e) { 179 e.preventDefault(); 180 e.stopPropagation(); 181 $.cookie('ruby_cookie_popup', '1', {expires: 30, path: '/'});
182 rbCookie.removeClass('is-show'); 183 setTimeout(function () { 184 rbCookie.css('display', 'none'); 185 }, 500) 186 }) 187 } 188 }; 189 190 191 /** header strip */ 192 Module.headerStrip = function () { 193 let headerStrips = $('.rb-headerstrip'); 194 if (headerStrips.length > 0) { 195 headerStrips.each(function () { 196 let headerStrip = $(this); 197 let id = headerStrip.attr('id'); 198 if ($.cookie(id) !== '1') { 199 headerStrip.css('display', 'block'); 200 } 201 }); 202 } 203 204 $('.headerstrip-submit').off('click').on('click', function (e) { 205 e.preventDefault(); 206 e.stopPropagation(); 207 let wrap = $(this).parents('.rb-headerstrip'); 208 let expired = wrap.data('headerstrip'); 209 if (!expired) { 210 expired = 30; 211 } 212 let id = wrap.attr('id'); 213 $.cookie(id, '1', {expires: expired, path: '/'}); 214 wrap.slideUp(300, function () { 215 wrap.remove(); 216 }); 217 }); 218 }; 219 220 /** add bookmark */ 221 Module.addBookMark = function () { 222 let self = this; 223 $('.read-it-later').off('click').on('click', function (e) { 224 e.preventDefault(); 225 e.stopPropagation(); 226 227 let target = $(this); 228 let postID = target.data('bookmarkid'); 229 if (!postID) { 230 return; 231 } 232 let dataBookMark = $.cookie('RBBookmarkData'); 233 if (dataBookMark) { 234 dataBookMark = JSON.parse(dataBookMark); 235 } 236 237 if (typeof dataBookMark != 'object' || null == dataBookMark || !dataBookMark) { 238 dataBookMark = []; 239 } 240 241 dataBookMark = self.toggleArrayItem(target, dataBookMark, postID); 242 $.cookie('RBBookmarkData', JSON.stringify(dataBookMark), {expires: 30, path: '/'}); 243 $(window).trigger('RB:CountBookmark'); 244 }); 245 }; 246 247 /** toggle data */ 248 Module.toggleArrayItem = function (target, data, value) { 249 let i = $.inArray(value, data); 250 if (i === -1) { 251 $('[data-bookmarkid= ' + value + ']').addClass('added'); 252 data.push(value); 253 } else { 254 $('[data-bookmarkid= ' + value + ']').removeClass('added'); 255 data.splice(i, 1); 256 } 257 return data; 258 }; 259 260 261 /** remove bookmarks */ 262 Module.removeBookmarkList = function () { 263 $('#remove-bookmark-list').on('click', function (e) { 264 e.preventDefault(); 265 e.stopPropagation(); 266 $.removeCookie('RBBookmarkData', {path: '/'}); 267 window.location.reload(); 268 }) 269 }; 270 271 Module.loadBookMarks = function () { 272 let dataBookMark = $.cookie('RBBookmarkData'); 273 if (dataBookMark) { 274 dataBookMark = JSON.parse(dataBookMark); 275 } 276 $('.read-it-later:not(.loaded)').each(function () { 277 let target = $(this); 278 target.addClass('loaded'); 279 280 let postID = target.data('bookmarkid'); 281 if (!postID) { 282 return; 283 } 284 let i = $.inArray(postID, dataBookMark); 285 if (i !== -1) { 286 target.addClass('added'); 287 } 288 }); 289 $(window).trigger('RB:CountBookmark'); 290 }; 291 292 /** remove single bookmark */ 293 Module.removeBookMark = function () { 294 let removeID = $('.rb-remove-bookmark').data('bookmarkid'); 295 if (removeID) { 296 let dataBookMark = $.cookie('RBBookmarkData'); 297 if (dataBookMark) { 298 dataBookMark = JSON.parse(dataBookMark); 299 } 300 if (typeof dataBookMark != 'object') { 301 return; 302 } 303 let i = $.inArray(removeID, dataBookMark); 304 if (i != -1) { 305 dataBookMark.splice(i, 1); 306 } 307 $.cookie('RBBookmarkData', JSON.stringify(dataBookMark), {expires: 30, path: '/'}); 308 } 309 }; 310 311 /** total bookmarks */ 312 Module.bookMarkCounter = function () { 313 $(window).on('RB:CountBookmark', function () { 314 let dataBookMark = $.cookie('RBBookmarkData'); 315 if (dataBookMark) { 316 dataBookMark = JSON.parse(dataBookMark); 317 if (dataBookMark != null && dataBookMark.length > 0) { 318 $('.bookmark-counter').fadeOut(0).html(dataBookMark.length).fadeIn(200); 319 } 320 } 321 }); 322 }; 323 324 /** ajax get bookmark list */ 325 Module.bookmarkList = function () { 326 327 let bookmarkList = $('#bookmarks-list'); 328 if (null == bookmarkList || bookmarkList.length < 1) { 329 return; 330 } 331 let dataBookMark = $.cookie('RBBookmarkData'); 332 if (dataBookMark) { 333 dataBookMark = JSON.parse(dataBookMark); 334 } 335 336 $.ajax({
337 type: 'POST', 338 url: pixwellParams.ajaxurl, 339 data: { 340 action: 'rb_bookmark', 341 ids: dataBookMark 342 }, 343 success: function (data) { 344 data = $.parseJSON(JSON.stringify(data)); 345 $('#bookmarks-list').html(data); 346 $(window).trigger('load'); 347 } 348 }); 349 }; 350 351 352 /** lazyload */ 353 Module.getWidth = function (imgObject) { 354 let width = imgObject.parent().width() - 20; 355 if (!width) { 356 width = imgObject.data('sizes'); 357 } else { 358 if (width < 1) { 359 width = 1; 360 } 361 width += 'px'; 362 } 363 return width; 364 }; 365 366 Module.setDarkModeCookie = function (id, value) { 367 if (pixwellCoreParams.darkCookieMode !== undefined) { 368 var date = new Date() 369 date.setTime(date.getTime() + 5184000000); 370 document.cookie = id + '= ' + value + '; path=/; expires=' + date.toGMTString() + ';'; 371 } 372 } 373 374 Module.switchDarkMode = function () { 375 let self = this; 376 let darkModeID = pixwellCoreParams.darkModeID; 377 378 $('.dark-mode-toggle').off('click').on('click', function (e) { 379 e.preventDefault(); 380 e.stopPropagation(); 381 382 if (!$(this).hasClass('trigged')) { 383 $(this).addClass('trigged') 384 } 385 386 let iconDefault = $('.mode-icon-default'); 387 let iconDark = $('.mode-icon-dark'); 388 389 let currentMode = localStorage.getItem(darkModeID); 390 if (null === currentMode) { 391 currentMode = self._body.data('theme'); 392 } 393 394 self._body.addClass('switch-smooth'); 395 396 if (null === currentMode || 'default' === currentMode) { 397 localStorage.setItem(darkModeID, 'dark'); 398 self.setDarkModeCookie(darkModeID, 'dark'); 399 self._body.attr('data-theme', 'dark'); 400 iconDefault.removeClass('activated'); 401 iconDark.addClass('activated'); 402 } else { 403 localStorage.setItem(darkModeID, 'default'); 404 self.setDarkModeCookie(darkModeID, 'default'); 405 self._body.attr('data-theme', 'default'); 406 iconDefault.addClass('activated'); 407 iconDark.removeClass('activated'); 408 } 409 }) 410 }; 411 412 /** reaction */ 413 Module.loadReactions = function () { 414 let self = this; 415 416 self.reaction = $('.rb-reaction'); 417 if (self.reaction.length < 1) { 418 return; 419 } 420 self.reactionProcessing = false; 421 self.reaction.each(function () { 422 let currentReaction = $(this); 423 let uid = currentReaction.data('reaction_uid'); 424 if (!currentReaction.hasClass('data-loaded')) { 425 self.loadCurrentReaction(currentReaction, uid); 426 } 427 }); 428 }; 429 430 Module.loadCurrentReaction = function (currentReaction, uid) { 431 let self = this; 432 self.reactionProcessing = true; 433 $.ajax({
434 type: 'POST', 435 url: pixwellParams.ajaxurl, 436 data: { 437 action: 'rb_load_reaction', 438 uid: uid 439 }, 440 success: function (data) { 441 data = $.parseJSON(JSON.stringify(data)); 442 $.each(data, function (index, val) { 443 currentReaction.find('[data-reaction=' + val + ']').addClass('active'); 444 }); 445 currentReaction.addClass('data-loaded'); 446 self.reactionProcessing = false; 447 } 448 }); 449 }; 450 451 Module.clickReaction = function () { 452 453 let self = this; 454 $('.reaction').off('click').on('click', function (e) { 455 e.preventDefault(); 456 e.stopPropagation(); 457 458 let target = $(this); 459 let reaction = target.data('reaction'); 460 let uid = target.data('reaction_uid'); 461 let push = 1; 462 463 if (self.reactionProcessing) { 464 return; 465 } 466 target.addClass('loading'); 467 self.reactionProcessing = true; 468 let reactionCount = target.find('.reaction-count'); 469 let total = parseInt(reactionCount.html()); 470 if (target.hasClass('active')) { 471 total--; 472 push = '-1'; 473 } else { 474 total++; 475 } 476 $.ajax({
477 type: 'POST', 478 url: pixwellParams.ajaxurl, 479 data: { 480 action: 'rb_add_reaction', 481 uid: uid, 482 reaction: reaction, 483 push: push 484 }, 485 486 success: function (data) { 487 if (true !== data) { 488 let oldReactions = target.siblings('.active'); 489 if (oldReactions.length > 0) { 490 $.each(oldReactions, function () { 491 $(this).removeClass('active'); 492 let oldReactionCount = $(this).find('.reaction-count'); 493 let oldTotal = parseInt(oldReactionCount.html()) - 1; 494 oldReactionCount.hide().html(oldTotal).fadeIn(300); 495 }); 496 } 497 } 498 reactionCount.hide().html(total).fadeIn(300); 499 target.toggleClass('active'); 500 target.removeClass('loading'); 501 self.reactionProcessing = false; 502 } 503 }); 504 505 return false; 506 }); 507 }; 508 509 return Module; 510 511}(PIXWELL_CORE_SCRIPT || {}, jQuery)); 512 513jQuery(document).ready(function () { 514 PIXWELL_CORE_SCRIPT.init(); 515}); 516 517jQuery(window).on('load', function () { 518 PIXWELL_CORE_SCRIPT.sharesAction(); 519 PIXWELL_CORE_SCRIPT.rbBookMarks(); 520 PIXWELL_CORE_SCRIPT.initReaction(); 521});
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.