更多', lessLink: ' 收起', }); }); $('.hide-theme-dark').click(function(){ document.body.classList.remove('theme-light'); document.body.classList.add("theme-dark"); localStorage.setItem(themeKey, 'dark'); }); $('.hide-theme-light').click(function(){ document.body.classList.remove('theme-dark'); document.body.classList.add("theme-light"); localStorage.setItem(themeKey, 'light'); }); var toolKey = 'tk'; if (localStorage.getItem(toolKey) < 2 || !(toolKey in localStorage)) { $('.tools-menu').css('display', 'block'); } $('.tools-menu a').click(function(){ localStorage.setItem(toolKey, 2); $('.tools-menu').css('display', 'none'); }); function lazyEnter(el) { var flag = el.getAttribute("data-lazy-enter"); var hash = el.getAttribute("data-hash"); if (!flag || !hash) return; var hashArr = str2char(atob(hash)); el.style.backgroundImage = 'url("'+thumbHashToDataURL(hashArr)+'")'; }; window.lazyLoadedFn = { photos: function (el) { $(el).removeClass('invisible'); if ($(el).prev().hasClass('loader')) { $(el).prev().remove(); } else { $(el).parent().removeClass('loader').addClass('w-100'); } $(el).parents('a').css('min-height', 'auto'); var $fp = $(el).parents('.focuspoint'); if($fp.length) { $fp.attr({'data-image-w':el.naturalWidth,'data-image-h':el.naturalHeight}); loadjs(['/js/jquery.focuspoint.min.js','/assets/vendors/velocity/2.0.6/velocity.min.js'], function(){ $fp.focusPoint(); }); } if(typeof $masonry !== 'undefined') { $masonry.masonry('layout'); } }, photo: function (el) { $(el).removeClass('invisible'); $(el).parents('.photo-div').css('background-image', ''); }, fp: function (el) { $(el).removeClass('invisible'); if ($(el).prev().hasClass('loader')) { $(el).prev().remove(); } var $fp = $(el).parents('.focuspoint'); if($fp.length) { $fp.attr({'data-image-w':el.naturalWidth,'data-image-h':el.naturalHeight}); loadjs(['/js/jquery.focuspoint.min.js','/assets/vendors/velocity/2.0.6/velocity.min.js'], function(){ $fp.focusPoint(); }); } } }; function execLazyLoadedFn(el) { var lazyFnName = el.getAttribute("data-lazy-loaded"); var lazyFn = window.lazyLoadedFn[lazyFnName]; if (!lazyFn) return; lazyFn(el); } var pageLazyLoad = new LazyLoad({ elements_selector: ".lazy", unobserve_entered: true, callback_enter: lazyEnter, callback_loaded: execLazyLoadedFn }); $('.favorite,.similar,.recommend,.collect,.color-icon').tooltip({container:'body',placement:'bottom'}); $('.favorite,.similar,.recommend,.collect,.color-icon,.link').hover(function(){ $(this).css('transform','scale(1.25)'); $(this).find('.icon').addClass('icon-pulse'); },function(){ $(this).css('transform','scale(1)'); $(this).find('.icon').removeClass('icon-pulse'); }); var spinner = $('#spinner').clone(); $('.ajax-modal').click(function(e){ e.preventDefault(); var that = $(this); $('#modaljx').modal('show'); $('#modaljx').find('.modal-dialog').html(spinner.html()).load(that.attr("data-href")); }); $('.favorite').on('ajax:success', function(event, data, status, xhr) { var that = $(this); if(data.code == 200){ that.find('.icon').toggleClass('text-red'); var msg = data.increment > 0 ? '已喜欢' : '加入喜欢'; $('.tooltip-inner').text(msg); that.attr('title', msg).attr('data-bs-original-title', msg); }else if(data.code == 401){ if(!confirm(data.message)){ return false; } location.href=data.url; }else{ alert(data.message); } }).on('ajax:error',function(event, xhr, status, error){ if(xhr.status == 401){ $('#modaljx').find('.modal-dialog').html(spinner).load('https://colorhub.me/auth/login'); $('#modaljx').modal('show'); }else{ alert('服务器错误,请稍后重试'); } }); if (typeof pageLazyLoad !== 'undefined'){ pageLazyLoad.update(); } });