1/** PIXWELL_CORE_SCRIPT */ 2var PIXWELL_CORE_SCRIPT = (function (Module, $) { 3 "use strict"; 4 5 /** init */ 6 Module.init = function () { 7 var self = this; 8 $(window).trigger('RB:CountBookmark'); 9 10 self.initLazyLoad(); 11 self.newsLetterSubmit(); 12 self.rbGallery(); 13 self.rbCookie(); 14 self.headerStrip(); 15 self.bookMarkCounter(); 16 self.bookmarkList(); 17 self.removeBookmarkList(); 18 self.removeBookMark(); 19 self.reloadSizes(); 20 self.newsLetterPopup(); 21 22 23 }; 24 25 Module.rbBookMarks = function () { 26 this.loadBookMarks(); 27 this.addBookMark(); 28 }; 29 30 /** module newsletter */ 31 Module.newsLetterSubmit = function () { 32 $('.rb-newsletter-form').submit(function (e) { 33 e.preventDefault(); 34 e.stopPropagation(); 35 var target = $(this); 36 var responseWrap = target.closest('.rb-newsletter').find('.newsletter-response'); 37 responseWrap.find('.is-show').removeClass('is-show'); 38 var subscribeEmail = target.find('input[name="rb_email_subscribe"]').val(); 39 if (!subscribeEmail) { 40 responseWrap.find('.email-error').addClass('is-show'); 41 responseWrap.find('.email-error').addClass('showing'); 42 return false; 43 } 44 45 var postData = { 46 action: 'rb_submit_newsletter', 47 email: subscribeEmail 48 }; 49 50 var privacy = target.find(':checkbox[name="rb_privacy"]'); 51 if (privacy != null && privacy.length > 0) { 52 var privacyVal = privacy.prop('checked'); 53 if (!privacyVal) { 54 responseWrap.find('.privacy-error').addClass('is-show showing'); 55 return false; 56 } else { 57 postData.privacy = privacyVal; 58 } 59 } 60 61 $.ajax({
62 type: 'POST', 63 url: pixwellParams.ajaxurl, 64 data: postData, 65 success: function (response) { 66 responseWrap.find('.' + response.notice).addClass('is-show'); 67 responseWrap.find('.' + response.notice).addClass('showing'); 68 } 69 }); 70 71 return false; 72 }); 73 }; 74 75 /** Newsletter popup */ 76 Module.newsLetterPopup = function () { 77 78 if ($(window).width() < 768) { 79 return; 80 } 81 82 var targetID = '#rb-newsletter-popup'; 83 if ($(targetID).length > 0 && '1' !== $.cookie('ruby_newsletter_popup')) { 84 var delay = $(targetID).data('delay'); 85 if (!delay) { 86 delay = 2000; 87 } 88 setTimeout(function () { 89 $.magnificPopup.open({ 90 type: 'inline', 91 preloader: false, 92 closeBtnInside: true, 93 removalDelay: 500, 94 showCloseBtn: true, 95 closeOnBgClick: false, 96 disableOn: 992, 97 items: { 98 src: targetID, 99 type: 'inline' 100 }, 101 mainClass: 'rb-popup-effect', 102 fixedBgPos: true, 103 fixedContentPos: true, 104 closeMarkup: '<button id="rb-close-newsletter" title="%title%" class="mfp-close"><i class="rbi rbi-move"></i></button>', 105 callbacks: { 106 close: function () { 107 var expiresTime = $(targetID).data('expired'); 108 $.cookie('ruby_newsletter_popup', '1', {expires: parseInt(expiresTime), path: '/'}); 109 } 110 } 111 }); 112 113 }, delay); 114 } 115 }; 116 117 /** Ruby gallery */ 118 Module.rbGallery = function () { 119 var gallery = $('.rb-gallery-wrap'); 120 if (gallery.length > 0) { 121 gallery.each(function () { 122 var el = $(this); 123 var inner = el.find('.gallery-inner').eq(0); 124 $(inner).isotope({ 125 itemSelector: '.rb-gallery-el', 126 percentPosition: true, 127 masonry: { 128 columnWidth: inner.find('.rb-gallery-el')[0] 129 } 130 }); 131 132 $(window).on('RB:LazyLoaded', function () { 133 inner.imagesLoaded().progress(function () { 134 $(inner).isotope('layout'); 135 }); 136 }); 137 138 $('body').imagesLoaded(function () { 139 $(inner).isotope('layout'); 140 }); 141 142 setTimeout(function () { 143 inner.removeClass('gallery-loading'); 144 }, 2000); 145 inner.imagesLoaded(function () { 146 inner.removeClass('gallery-loading'); 147 }); 148 }); 149 } 150 }; 151 152 //share action 153 Module.sharesAction = function () { 154 $('a.share-action').off('click').on('click', function (e) { 155 e.preventDefault(); 156 e.stopPropagation(); 157 window.open($(this).attr('href'), '_blank', 'width=600, height=350'); 158 159 return false; 160 }) 161 }; 162 163 164 /** rb cookie */ 165 Module.rbCookie = function () { 166 var rbCookie = $('#rb-cookie'); 167 if (rbCookie.length > 0) { 168 if ($.cookie('ruby_cookie_popup') !== '1') { 169 rbCookie.css('display', 'block'); 170 setTimeout(function () { 171 rbCookie.addClass('is-show'); 172 }, 10) 173 } 174 175 $('#cookie-accept').off('click').on('click', function (e) { 176 e.preventDefault(); 177 e.stopPropagation(); 178 $.cookie('ruby_cookie_popup', '1', {expires: 30, path: '/'});
179 rbCookie.removeClass('is-show'); 180 setTimeout(function () { 181 rbCookie.css('display', 'none'); 182 }, 500) 183 }) 184 } 185 }; 186 187 188 /** header strip */ 189 Module.headerStrip = function () { 190 var headerStrips = $('.rb-headerstrip'); 191 if (headerStrips.length > 0) { 192 headerStrips.each(function () { 193 var headerStrip = $(this); 194 var id = headerStrip.attr('id'); 195 if ($.cookie(id) !== '1') { 196 headerStrip.css('display', 'block'); 197 } 198 }); 199 } 200 201 $('.headerstrip-submit').off('click').on('click', function (e) { 202 e.preventDefault(); 203 e.stopPropagation(); 204 var wrap = $(this).parents('.rb-headerstrip'); 205 var expired = wrap.data('headerstrip'); 206 if (!expired) { 207 expired = 30; 208 } 209 var id = wrap.attr('id'); 210 $.cookie(id, '1', {expires: expired, path: '/'}); 211 wrap.slideUp(300, function () { 212 wrap.remove(); 213 }); 214 }); 215 }; 216 217 /** add bookmark */ 218 Module.addBookMark = function () { 219 var self = this; 220 $('.read-it-later').off('click').on('click', function (e) { 221 e.preventDefault(); 222 e.stopPropagation(); 223 224 var target = $(this); 225 var postID = target.data('bookmarkid'); 226 if (!postID) { 227 return; 228 } 229 var dataBookMark = $.cookie('RBBookmarkData'); 230 if (dataBookMark) { 231 dataBookMark = JSON.parse(dataBookMark); 232 } 233 if (typeof dataBookMark != 'object') { 234 dataBookMark = []; 235 } 236 dataBookMark = self.toggleArrayItem(target, dataBookMark, postID); 237 $.cookie('RBBookmarkData', JSON.stringify(dataBookMark), {expires: 30, path: '/'}); 238 $(window).trigger('RB:CountBookmark'); 239 }); 240 }; 241 242 /** toggle data */ 243 Module.toggleArrayItem = function (target, data, value) { 244 var i = $.inArray(value, data); 245 if (i === -1) { 246 $('[data-bookmarkid= ' + value + ']').addClass('added'); 247 data.push(value); 248 } else { 249 $('[data-bookmarkid= ' + value + ']').removeClass('added'); 250 data.splice(i, 1); 251 } 252 return data; 253 }; 254 255 256 /** remove bookmarks */ 257 Module.removeBookmarkList = function () { 258 $('#remove-bookmark-list').on('click', function (e) { 259 e.preventDefault(); 260 e.stopPropagation(); 261 $.removeCookie('RBBookmarkData', {path: '/'}); 262 window.location.reload(); 263 }) 264 }; 265 266 Module.loadBookMarks = function () { 267 var dataBookMark = $.cookie('RBBookmarkData'); 268 if (dataBookMark) { 269 dataBookMark = JSON.parse(dataBookMark); 270 } 271 $('.read-it-later:not(.loaded)').each(function () { 272 var target = $(this); 273 target.addClass('loaded'); 274 275 var postID = target.data('bookmarkid'); 276 if (!postID) { 277 return; 278 } 279 var i = $.inArray(postID, dataBookMark); 280 if (i != -1) { 281 target.addClass('added'); 282 } 283 }); 284 $(window).trigger('RB:CountBookmark'); 285 }; 286 287 /** remove single bookmark */ 288 Module.removeBookMark = function () { 289 var removeID = $('.rb-remove-bookmark').data('bookmarkid'); 290 if (removeID) { 291 var dataBookMark = $.cookie('RBBookmarkData'); 292 if (dataBookMark) { 293 dataBookMark = JSON.parse(dataBookMark); 294 } 295 if (typeof dataBookMark != 'object') { 296 return; 297 } 298 var i = $.inArray(removeID, dataBookMark); 299 if (i != -1) { 300 dataBookMark.splice(i, 1); 301 } 302 $.cookie('RBBookmarkData', JSON.stringify(dataBookMark), {expires: 30, path: '/'}); 303 } 304 }; 305 306 /** total bookmarks */ 307 Module.bookMarkCounter = function () { 308 $(window).on('RB:CountBookmark', function () { 309 var dataBookMark = $.cookie('RBBookmarkData'); 310 if (dataBookMark) { 311 dataBookMark = JSON.parse(dataBookMark); 312 if (dataBookMark != null && dataBookMark.length > 0) { 313 $('.bookmark-counter').fadeOut(0).html(dataBookMark.length).fadeIn(200); 314 } 315 } 316 }); 317 }; 318 319 /** ajax get bookmark list */ 320 Module.bookmarkList = function () { 321 322 var bookmarkList = $('#bookmarks-list'); 323 324 if (null == bookmarkList || bookmarkList.length < 1) { 325 return; 326 } 327 var dataBookMark = $.cookie('RBBookmarkData'); 328 if (dataBookMark) { 329 dataBookMark = JSON.parse(dataBookMark); 330 } 331 332 $.ajax({
333 type: 'POST', 334 url: pixwellParams.ajaxurl, 335 data: { 336 action: 'rb_bookmark', 337 ids: dataBookMark 338 }, 339 success: function (data) { 340 data = $.parseJSON(JSON.stringify(data)); 341 $('#bookmarks-list').html(data); 342 $(window).trigger('load'); 343 } 344 }); 345 }; 346 347 348 /** lazyload */ 349 Module.getWidth = function (imgObject) { 350 var width = imgObject.parent().width() - 20; 351 if (!width) { 352 width = imgObject.data('sizes'); 353 } else { 354 if (width < 1) { 355 width = 1; 356 } 357 width += 'px'; 358 } 359 return width; 360 }; 361 362 Module.initLazyLoad = function () { 363 var self = this; 364 $(window).on('load RB:LazyLoad', function () { 365 var imageData = $('.rb-lazyload'); 366 if (imageData.length > 0) { 367 imageData.each(function () { 368 var item = $(this); 369 if (item.hasClass('rb-autosize')) { 370 item.attr('sizes', self.getWidth(item)); 371 } else { 372 item.attr('sizes', item.data('sizes')); 373 } 374 }); 375 imageData.lazyload(); 376 $(window).trigger('RB:LazyLoaded'); 377 } 378 }); 379 }; 380 381 Module.reloadSizes = function () { 382 var self = this; 383 $(window).resize(function () { 384 $('.rb-lazyload').each(function () { 385 var imgObject = $(this); 386 imgObject.attr('sizes', self.getWidth(imgObject)); 387 }); 388 }) 389 }; 390 391 return Module; 392 393}(PIXWELL_CORE_SCRIPT || {}, jQuery)); 394 395 396jQuery(document).ready(function () { 397 PIXWELL_CORE_SCRIPT.init(); 398}); 399 400jQuery(window).on('load', function () { 401 PIXWELL_CORE_SCRIPT.sharesAction(); 402 PIXWELL_CORE_SCRIPT.rbBookMarks(); 403});
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.