Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/wp-content/themes/themify-ultra/themify/js/admin/scripts.js
Назад
/*************************************************************************** * * ---------------------------------------------------------------------- * DO NOT EDIT THIS FILE * ---------------------------------------------------------------------- * * Copyright (C) Themify * * ---------------------------------------------------------------------- * ***************************************************************************/ ((Themify,$,win,doc)=>{ 'use strict'; /* decode HTML entities */ var decodeEntities = function( string ) { var textarea = doc.createElement( 'textarea' ); textarea.innerHTML = string; return textarea.innerText; }; /* copy of :contains $ filter that ignores text case */ $.expr[':'].icontains = function(a, i, m) { return $(a).text().toUpperCase() .indexOf(m[3].toUpperCase()) >= 0; }; $(function() { // Themify Directory var $body = $('body'), $themify = $('#themify'), $panel = $('#setting>.subtabnav'), inputAuto = $( '#themify_404_page_autocomplete' ), $panelTop; /*******************************************************************************/ /* Tab Events */ // // Get Subtab height based on Navigation height // $themify.find('.maintab').not('[aria-expanded="false"]').each(function(){ $(this).find('.subtab').css('minHeight', $(this).find('.subtabnav').outerHeight()); }); if( inputAuto.length>0) { var cache = {}, inputWrapper = inputAuto.closest( '.themify_404_autocomplete_wrap' ); inputAuto.autocomplete( { minLength: 2, autoFocus: true, classes: { "ui-autocomplete": "highlight" }, source( request, response ) { var term = request.term; inputWrapper.addClass( 'themify_autocomplete_run' ); if ( term in cache ) { response( cache[ term ] ); inputWrapper.removeClass( 'themify_autocomplete_run' ); return; } $.ajax( { url: ajaxurl, dataType: "json", type:'POST', data: {'term': term, 'action': 'themify_get_404_pages'}, success( data ) { for ( const i in data ) { data[ i ]['label'] = decodeEntities( data[ i ]['label'] ); } cache[ term ] = data; response( data.length ? data : [themify_js_vars.page_not_found] ); inputWrapper.removeClass( 'themify_autocomplete_run' ); } }); }, select( event, ui ) { event.preventDefault(); if( ui.item.value === themify_js_vars.page_not_found ) return; inputAuto.val( ui.item.label ).next( 'input[type="hidden"]' ).val( ui.item.value ); }, change( event, ui ) { if( ! ui.item && ! event.target.value ) { inputAuto.next( 'input[type="hidden"]' ).val( '' ); } } } ).focus( function () { $(this).autocomplete( 'search' ); } ); } if ($panel.length > 0) { $panelTop = $panel.offset().top - 32; } var expandableOptionsInit = false; // // Create Tabs // Update address URL when Themify sub tab is clicked var updateTabURL = function( e, ui ) { $('.search-setting-holder .clear-search').trigger( 'click' ); var el = e.type === 'tabscreate' ? win.location : ui.newTab.find('a')[0]; history.replaceState( null, null, el.hash || null ); if (e.type === 'tabscreate' && !expandableOptionsInit) { expandableOptionsInit = true; var subtabs = $('#themify div#setting div.subtab'); subtabs.each(function() { var $this = $(this), fieldset = $this.find('fieldset'); if (fieldset.length > 2) { fieldset.children('.themify_panel_fieldset_wrap').hide(); } else { fieldset.find('legend').addClass('themify_panel_fieldset_nocollapse'); } }); subtabs.find('legend:not(.themify_panel_fieldset_nocollapse)').on('click', function() { var $this = $(this), $icon = $this.children('i'); if ($icon.hasClass('tf_plus_icon')) { $this.siblings().slideDown( "fast", function() { if(this.tfClass('CodeMirror').length<1){ const editors = this.tfClass('tf_code_editor'); for(let i=editors.length-1;i>-1;--i){ themify_code_editor(editors[i]); } } $icon.removeClass('tf_plus_icon').addClass('ti-minus'); }); } else { $this.siblings().slideUp( "fast", function() { $icon.removeClass('ti-minus').addClass('tf_plus_icon'); }); } }); } }; $('.maintab, #content').tabs({ fx: { opacity: 'toggle', duration: 200 }, cache: true, select() { $(this).css({ 'height': $(this).height(), 'overflow': 'hidden' }); }, show() { $(this).css({ 'height': 'auto', 'overflow': 'visible' }); if ($panel.length > 0) { $panelTop = $panel.offset().top - 32; } }, beforeActivate: updateTabURL, create: updateTabURL }); /* fix deep linking to sub tabs in theme settings page */ let link = win.location.hash && doc.querySelector( 'a[href="' + win.location.hash + '"]' ); if ( link && link.closest( '.subtabnav' ) ) { const maintab_id = link.closest( '.maintab' ).getAttribute( 'id' ), tab=doc.tfId( 'maintabnav' ).querySelector( 'a[href="#' + maintab_id + '"]' ); if(tab){ tab.click(); } } // fixed themify panel while scrolling if ($panel.length > 0) { win.tfOn('scroll',function() { if ($(this).scrollTop() > $panelTop) { if (!$panel.hasClass('themify_settings_fixed')){ $panel.addClass('themify_settings_fixed'); } } else { $panel.removeClass('themify_settings_fixed'); } },{passive:true}); } /*******************************************************************************/ /* Global Events */ /** *Search in settings * */ var mark = function() { var keyword = $("#search-setting").val(); if ( keyword.length <= 0 ){ clearButtonStatus(); $(".subtab",'#setting').unmark({ "done" () { $('.searching').removeClass('searching'); $('.contain-result').removeClass('contain-result'); $('#setting').removeClass('not-found'); } }); return; }else if ( keyword.length ){ if (!$('.search-setting-holder .clear-search').hasClass('show')){ //show clear button clearButtonStatus(); } } $(".subtab",'#setting').unmark({ done() { $('.searching').removeClass('searching'); $('.contain-result').removeClass('contain-result'); $('#setting').removeClass('not-found'); $("*:not(:input):icontains('"+ keyword + "')","#setting .subtab").mark(keyword,{ diacritics: true, separateWordSearch: true, exclude: [ "option", ".tm-option-title-fw" ], filter(textNode, foundTerm, totalCounter, counter){ if ( textNode.nodeName === "#text" ){ if ( $(textNode).parent().parent().css('display') === 'none' ){ return false; } } else { if ( $(textNode).parent().css('display') === 'none' ){ return false; } } return true; // must return either true or false }, each(element) { $(element).closest('fieldset').addClass('contain-result'); $(element).closest('.subtab').addClass('contain-result'); }, done() { $('#setting').addClass('searching'); }, noMatch() { $('#setting').addClass('not-found'); } }); } }); }; $("#search-setting").on("input", mark); $('.search-setting-holder .clear-search').on('click',function () { var $input = $(this).prev(); $input.val(''); mark(); }); /** * Based on input value it shows or hide * clear button */ function clearButtonStatus() { var button = $('.search-setting-holder .clear-search'); if( button.prev().val().length <= 0 ){ button.removeClass('show'); }else{ button.addClass('show'); } } // // Validation of Numbers // $('.valid_num').on('keyup input paste',function(){ if(!is_numeric($(this).val())){ $(this).val($(this).val().substring(0,($(this).val().length-1))); } }); function themify_save_settings() { themify_show_alert(); var data = $themify.serialize(); $.post( ajaxurl, { 'action': 'themify_save', 'data': data, 'nonce' : themify_js_vars.nonce }, function() { themify_hide_alert(); $( 'body' ).triggerHandler( 'themify_save' ); } ); } /** * Save user settings * Uses nonces for security */ $('.save-button').on('click',function(e){ themify_save_settings(); return false; }); /** * Save user settings when pressing Shift+Enter */ if($themify.length > 0){ $(doc).on('keydown', function(event){ if (83 == event.which && (true == event.ctrlKey || true == event.metaKey)) { event.preventDefault(); themify_save_settings(); } }); } /** * Reset user settings */ $( '#reset-setting' ).on( 'click', function( e ) { e.preventDefault(); var actionType = $( this ).prop( 'id' ) !== 'reset-setting' ? 'styling' : 'settings'; if( confirm( themify_lang[ 'confirm_reset_' + actionType ] ) ) { themify_show_alert(); $.post( ajaxurl,{ action: 'themify_reset_' + actionType, data : $themify.serialize(), nonce : themify_js_vars.nonce }, function() { themify_hide_alert(); win.location.reload( true ); } ); } }); /* TF Message, displayed above theme settings */ ( function() { let el = doc.tfId( 'tf_message' ), message = localStorage.getItem( 'tf_message' ), dismiss = localStorage.getItem( 'tf_message_dismiss' ), show = function() { el.className = 'show'; el.innerHTML = message + ' '; let dis = doc.createElement( 'a' ); dis.href = '#'; dis.textContent = el.dataset.dismiss; dis.tfOn( 'click', e=> { e.preventDefault(); el.style.display = 'none'; localStorage.setItem( 'tf_message_dismiss', 1 ); } ); el.appendChild( dis ); }; if ( el && ! dismiss ) { if ( message === null ) { $.ajax( { url : 'https://themify.org/public-api/update-message/index.txt', success ( response ) { message = response; localStorage.setItem( 'tf_message', message ); if ( message.trim() !== '' ) { show(); } } } ); } else if ( message !== '' ) { show(); } } } )(); $('.themify_changelogs').on('click', function(e){ e.preventDefault(); var $self = $(this), url = $self.data('changelog'); $('.show-login, .show-error').hide(); $('.overlay, .prompt-box').fadeIn(300); $( '.prompt-box iframe' ).remove(); $('.tb_alert').addClass('busy').fadeIn(300); var $iframe = $('<iframe src="'+url+'" />'); $iframe.on('load', function(){ $('.tb_alert').removeClass('busy').fadeOut(300); }).prependTo( '.prompt-box' ); $('.prompt-box').addClass('show-changelog'); }); $( '.overlay' ).on( 'click', function() { $( this ).add( '.prompt-box' ).fadeOut(); } ); // // Feature Box Image / Posts Display // $(".feature-box-display").on('click',function(){ if($(this).val() === "images"){ $(this).parent().parent().find(".feature_box_posts").fadeOut(200, function(){ $(this).parent().parent().find(".feature_box_images").fadeIn(200); }); } else { $(this).parent().parent().find(".feature_box_images").fadeOut(200, function(){ $(this).parent().parent().find(".feature_box_posts").fadeIn(200); }); } }); // // Generic show/hide block for radio buttons // Requires the value="x" and a data-hide="y" where y is the suffix of the block to hide // $(".block-toggle").on('click',function(){ var $self = $(this), val = $self.val(), hide = $self.data('hide'); $self.parent().parent().find('.feature_box_' + hide).fadeOut(200, function(){ $self.parent().parent().find('.feature_box_' + val).fadeIn(200); }); }); // // Feature Box Enabled Display // $(".feature_box_enabled_check").on('change',function(){ if('on' === $(this).val()){ $(this).closest('fieldset').find(".feature_box_enabled_display").fadeIn(200); } else { $(this).closest('fieldset').find(".feature_box_enabled_display").fadeOut(200); } }); /** * Display box if checkbox is checked * Markup required * <div class="row"> * <input type="checkbox" class="box_enabled_check" /> * <*tag* class="box_enabled_display"> * <select> */ var $boxEnabledCheck = $('.box_enabled_check'); $boxEnabledCheck.on( 'click', function(){ if($(this).is(":checked")){ $(this).parent().find(".box_enabled_display").fadeIn(200); } else { $(this).parent().find(".box_enabled_display").fadeOut(200); } }); if($boxEnabledCheck.is(":checked")){ $boxEnabledCheck.parent().find(".box_enabled_display").show(); } /** * Display matched boxes if checkbox is checked * Markup required * <input type="checkbox" class="box_enabled_check" /> * <span class="box_enabled_display"> */ var $disableImgPhp = $('.disable_img_php'); $disableImgPhp.on( 'click', function(){ if($disableImgPhp.is(":checked")){ $( '.show_if_disabled_img_php' ).fadeIn(200); $( '.show_if_enabled_img_php' ).fadeOut(200); } else { $( '.show_if_disabled_img_php' ).fadeOut(200); $( '.show_if_enabled_img_php' ).fadeIn(200); } }); if($disableImgPhp.is(":checked")){ $(".show_if_disabled_img_php").show(); } else { if($disableImgPhp.not(":checked")){ $(".show_if_enabled_img_php").show(); } } $('.gallery_lightbox_type').on( 'change', function(){ var lightboxIndex = $('.gallery_lightbox_type').prop('selectedIndex'); if(lightboxIndex != 1){ $( '.show_if_photoswipe_enabled' ).fadeOut(200); } else { $( '.show_if_photoswipe_enabled' ).fadeIn(200); } }).trigger( 'change' ); /*******************************************************************************/ /* Skin CSS Load */ // // Skins Load // $("#skins .skin-preview").on( 'click', function(e){ if(e.target.nodeName!=='INPUT' && e.target.nodeName!=='LABEL'){ if( ! $( e.target ).parent().hasClass( 'view-demo' ) ) { e.preventDefault(); } $("#skins .skin-preview").removeClass( 'selected' ); $(this).addClass('selected'); $( "input[name='skin']" ).val( $(this).attr( 'data-skin' ) ); } }); /*******************************************************************************/ /* Is Numeric Function */ function is_numeric(string){ var ValidChars = " 0123456789.+-", IsNumber = true, Char; for (var i = 0; i < string.length && IsNumber === true; i++){ Char = string.charAt(i); if(!ValidChars.includes(Char)){ IsNumber = false; } } return IsNumber; } /** * Group drop down containing Featured Image sizes with the Featured Image field * .featimgdropdown */ var $featImgControl = $('.featimgcontrol'); if( $featImgControl.length > 0 && $('.featimgdropdown').length > 0 ) { $featImgControl.each( function() { $(this).append($(this).next('.featimgdropdown')); }); } /** * Social Links Panel */ var $socialType = $('#social-link-type' ), $socialLinksWrapper = $('#social-links-wrapper'), $socialLinkIDs = $('#setting-link_field_ids'), $socialLinkHash = $('#setting-link_field_hash'); /** * Link type selector */ if($('input[value="font-icon"]', $socialType).prop('checked')) { $('.image-icon', $socialLinksWrapper).fadeOut(); $('.font-icon', $socialLinksWrapper).fadeIn(); } else { $('.font-icon', $socialLinksWrapper).fadeOut(); $('.image-icon', $socialLinksWrapper).fadeIn(); } $('input', $socialType).on('click', function(){ var $self = $(this); if($self.prop('checked')) { $('.' + $self.data('hide'), $socialLinksWrapper).fadeOut(); $('.' + $self.val(), $socialLinksWrapper).fadeIn(); } }); /** * Links settings page */ // Set up drag & drop $socialLinksWrapper.length && $socialLinksWrapper.sortable({ placeholder: 'social-link-placeholder', handle: '.social-drag', update() { var field_ids = {}; $('.social-link-item').each(function(){ field_ids[$(this).attr('id')] = $(this).attr('id'); }); $socialLinkIDs.val(JSON.stringify(field_ids)); } }) // Remove Link .on('click', '.remove-item', function(event) { event.preventDefault(); var field_ids = JSON.parse($socialLinkIDs.val()), removeId = $(this).data('removelink'); $('#' + removeId).remove(); delete field_ids[removeId]; $socialLinkIDs.val(JSON.stringify(field_ids)); }); // Add Link $('.add-social-link a').on('click',e=> { const field_ids = JSON.parse($socialLinkIDs.val()), value=$socialLinkHash.val(), hash = parseInt(value), type = $socialType[0].querySelector('input[value=font-icon]:checked')? 'font-icon':'image-icon'; e.preventDefault(); Themify.fetch({ action: 'themify_add_link_field', nonce : themify_js_vars.nonce, fid : hash, type : type },'html').then(res=>{ doc.tfId('social-links-wrapper').appendChild( res ); const el=doc.tfId('themify-link-' + value), plupload = el.tfClass('plupload-upload-uic')[0]; // Add new key/element to JSON object field_ids['themify-link-' + value] = 'themify-link-' + value; $socialLinkIDs.val(JSON.stringify(field_ids)); if ( plupload ) { // Initialize plupload in this new field themify_create_pluploader($(plupload)); } win.Themify_Metabox.color_picker( $(el) ); // Increase hash number $socialLinkHash.val(hash + 1); }); }); // Validate slug input $('.slug-rewrite').each(function(){ $(this).on('keypress', function (event) { var regex = new RegExp("^[a-z0-9_\-]+$"), key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } }); }); var Themify_Visibility = { target : '', /* string copy of the current values in "target" while Conditions box is open */ currentValues : '', lightboxEl : null, overlayEl : null, getDocHeight() { var D = doc; return Math.max( Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight) ); }, update_inputs( container ) { if ( ! container ) { container = this.lightboxEl; } const inputs = container.querySelectorAll( 'input[type="checkbox"]' ); for ( let i = 0; i < inputs.length; i++ ) { inputs[ i ].checked = this.currentValues.includes( inputs[ i ].name + '=on' ); } }, showLightbox() { const top = $(doc).scrollTop() + 80; if ( ! this.lightboxEl ) { themify_show_alert(); $.ajax({ 'type' : 'POST', url: ajaxurl, async: false, data: { action: 'themify_get_visibility_options', nonce : themify_js_vars.nonce }, success( data ) { themify_hide_alert( 'done' ); const tmp = document.createElement( 'template' ); tmp.innerHTML = data; document.body.appendChild( tmp.content ); } }); this.lightboxEl = document.getElementById( 'themify_lightbox_visibility' ); this.overlayEl = document.getElementById( 'themify_lightbox_overlay' ); $( '#visibility-tabs', this.lightboxEl ).tabs(); $( '#visibility-tabs .themify-visibility-inner-tabs', this.lightboxEl ).tabs(); } this.update_inputs(); this.overlayEl.style.display = 'block'; $( this.lightboxEl ) .show() .css('top', this.getDocHeight()) .animate({ 'top': top }, 800); }, closeLightbox(){ const self = this; $( self.lightboxEl ).animate({ 'top': self.getDocHeight() }, 800, function() { self.overlayEl.style.display = 'none'; self.lightboxEl.style.display = 'none'; self.currentValues = ''; self.update_inputs(); }); } }; $body.on('click', '.themify-visibility-toggle', function(){ Themify_Visibility.target = this.nextElementSibling; Themify_Visibility.currentValues = decodeURIComponent( this.nextElementSibling.value ); Themify_Visibility.showLightbox(); return false; }).on('click', '.themify_lightbox_visibility .close_lightbox, #themify_lightbox_overlay', function(){ Themify_Visibility.closeLightbox(); return false; }); // Generate inner page for tab function getPaginationPages(e) { let type = this.dataset.type; let tab = Themify_Visibility.lightboxEl.querySelector( this.getAttribute( 'href' ) ); if ( ! type ) { /* look for sub tabs */ tab.querySelector( '.inline-tabs .ui-tabs-active a' ).click(); return; } if ( tab.getElementsByClassName( 'themify-visibility-items-page-1' )[0] ) { return; } $.ajax({ url: ajaxurl, type: 'post', data: { action: 'themify_create_inner_page', nonce : themify_js_vars.nonce, type: type }, beforeSend: function() { themify_show_alert(); }, success: function(data){ themify_hide_alert( 'done' ); tab.firstElementChild.innerHTML = data; Themify_Visibility.update_inputs( tab ); } }); } // Generate pagination for tab function showPaginationPage(e) { e.preventDefault(); const paged = parseInt( this.getAttribute( 'href' ) ), container = this.closest( '.themify-visibility-items-inner' ), panels = container.getElementsByClassName( 'themify-visibility-items-page' ); if ( ! container.getElementsByClassName( 'themify-visibility-items-page-' + paged )[0] ) { $.ajax({ url: ajaxurl, async : false, type: 'post', data: { action: 'themify_create_inner_page', type: ( this.closest( '.themify-visibility-inner-tab' ) ? this.closest( '.themify-visibility-inner-tabs' ) : Themify_Visibility.lightboxEl ).querySelector( '.ui-tabs-active a' ).dataset.type, paged: paged, nonce : themify_js_vars.nonce }, beforeSend: function() { themify_show_alert(); }, success: function(data){ themify_hide_alert( 'done' ); const tmp = document.createElement('template'); tmp.innerHTML = data; Themify_Visibility.update_inputs( tmp.content ); container.appendChild( tmp.content ); } }); } for ( let i = 0; i < panels.length; i++ ) { panels[ i ].style.display = panels[ i ].classList.contains( 'themify-visibility-items-page-' + paged ) ? 'block' : 'none'; } } $body.on( 'mouseover', '.tb_hook_conditions li', function() { if ( this.getElementsByClassName( 'remove-item' )[0] ) { return; } const el = document.createElement( 'a' ), span = document.createElement( 'span' ); el.className = 'remove-item'; span.className = 'tf_close'; el.appendChild( span ); this.appendChild( el ); } ) .on('click', '.themify-visibility-pagination a.page-numbers', showPaginationPage) .on('click', '#visibility-tabs .themify_hc_load_ajax, #visibility-tabs .inline-tabs a', getPaginationPages) .on( 'change', '#themify_lightbox_visibility input[type="checkbox"]', function() { if ( this.checked ) { Themify_Visibility.currentValues += '&' + this.name + '=on'; } else { Themify_Visibility.currentValues = Themify_Visibility.currentValues.replace( this.name + '=on', '' ); } } ) .on('click', '.visibility-save', function(){ Themify_Visibility.target.value = Themify_Visibility.currentValues; const id = Themify_Visibility.target.previousElementSibling.dataset.item; Themify.fetch({ action: 'themify_hc_conditions', nonce : themify_js_vars.nonce, selected : Themify_Visibility.currentValues, }, 'html' ).then(res=>{ $( '#hook-content-list li[data-id="' + id + '"] .tb_hook_conditions' ).replaceWith( res ); } ); Themify_Visibility.closeLightbox(); return false; }).on('click', '.themify_lightbox_visibility .uncheck-all', function(){ Themify_Visibility.currentValues = ''; Themify_Visibility.update_inputs(); return false; }); $('#setting-hooks').on('click', '.remove-item', function(e){ e.preventDefault(); if ( this.closest( '.tb_hook_conditions' ) ) { const input = this.closest( '.social-link-item' ).querySelector( 'input[type="hidden"]' ), item = this.closest( 'li' ); input.value = decodeURIComponent( input.value ).replace( item.dataset.id + '=on', '' ); item.remove(); } else { const field_ids = JSON.parse( $('#themify-hooks-field-ids').val() ), $item = $(this).closest('.social-link-item').fadeOut('fast', function(){ const removeId = $item.attr('data-id'); for( let key in field_ids ) { if ( field_ids.hasOwnProperty(key) && field_ids[key] == removeId ) { field_ids.splice(key, 1); } } $('#themify-hooks-field-ids').val( JSON.stringify( field_ids ) ); $('.themify-admin-lightbox-' + removeId).removeClass('is-loaded').find('.lightbox_container').html(''); }); } }). on('click', '.themify-add-hook a', function(e){ e.preventDefault(); $(this).before('<span class="tb_slider_loader_wrapper"><span class="tb_slider_loader"></span></span>'); let field_ids = JSON.parse( $('#themify-hooks-field-ids').val() ), new_field_id = 1; if( field_ids.length > 0 ) { field_ids = field_ids.filter( Number ); new_field_id = Math.max.apply(null, field_ids) + 1; } else { field_ids = []; } $.ajax({ url: ajaxurl, type: 'post', data: { action: 'themify_hooks_add_item', field_id : new_field_id, nonce: themify_js_vars.nonce }, success(data){ const hook_list = $('#hook-content-list'); field_ids.push( new_field_id ); $('#themify-hooks-field-ids').val( JSON.stringify( field_ids ) ); $('#setting-hooks .tb_slider_loader_wrapper').remove(); hook_list.append(data); $('textarea[name=setting-hooks-' + new_field_id + '-code]', hook_list).html(''); $('select[name=setting-hooks-' + new_field_id + '-location] optgroup:first-child option[value=themify_body_start]', hook_list).attr('selected', true); if (hook_list.find('li').length > 1) { $('.themify-admin-lightbox:first').clone().removeClass('themify-admin-lightbox-1').addClass('themify-admin-lightbox-' + new_field_id).data('item', new_field_id).insertAfter('.themify-admin-lightbox:last'); } $('.lightbox_container', '.themify-admin-lightbox-' + new_field_id).html(''); $('#setting-hooks-' + new_field_id + '-visibility', hook_list).val(''); $('.themify-admin-lightbox:last').removeClass('is-loaded'); hook_list.find( 'li[data-id="' + new_field_id + '"] .tf_hook_repeat' ).hide(); } }); }); // Set up drag & drop const $hookContentList = $('#hook-content-list'); $hookContentList.length && $hookContentList.sortable({ placeholder: 'social-link-placeholder', handle: '.social-drag', update() { var field_ids = []; $hookContentList.find('li').each(function(){ field_ids.push( parseInt( $(this).attr('data-id') ) ); }); $('#themify-hooks-field-ids').val( JSON.stringify( field_ids ) ); } }); $( 'body' ).on( 'click', '.see-hook-locations', function( e ) { e.preventDefault(); win.tf_hook_target = this.closest( 'li' ).querySelector( 'select' ); /* used by hook-locations-urlfix.js */ $.magnificPopup.open({ items : [ this ], type: 'iframe', iframe: { markup: '<div class="mfp-iframe-scaler" style="max-width: 100% !important; height: 100%;">'+ '<div role="button" class="tf_close mfp-close"></div>'+ '<iframe id="tf_hook_location_iframe" class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+ '</div>' } }); } ) .on( 'change', '.tf_hook_location', function() { /* warning specific for wp_head hook location */ this.closest( 'li' ).querySelector( '.wp_head_notice' ).style.display = this.value === 'wp_head' ? 'block' : 'none'; let group = $( 'option:selected', this ).closest( 'optgroup' ).data( 'key' ); $( this ).closest( 'li' ).find( '.tf_hook_repeat' ).toggle( group !== 'layout' && group !== 'general' && group !== 'ecommerce' ) .find( 'span' ) .eq(0).toggle( group !== 'post_content' ) .end().eq(1).toggle( group === 'post_content' ); } ) .find( '.tf_hook_location' ).each( function() { $( this ).trigger( 'change' ); } ); $('#setting-editor-gfonts-list').on('change',function(){ $(this).next().val( JSON.stringify( $(this).val() ) ); }).trigger( 'change' ); // Skin selection in the Demo Import notice box $body.on( 'click', '#demo-import-notice .skin-preview', function(e){ if( ! $( e.target ).parent().hasClass( 'view-demo' ) ) { e.preventDefault(); } $("#demo-import-notice .skin-preview").removeClass( 'selected' ); $(this).addClass('selected'); $( '#skins .skin-preview[data-skin="' + $(this).data( 'skin' ) + '"]' ).trigger( 'click' ); } ); $( '.themify-modal .dismiss-import-notice' ).on('click',function(){ $( this ).closest( '.themify-modal' ).fadeOut(); themify_modal_action('close'); return false; }); // <select> Wrapper themify_select_wrapper($themify); // New general show/hide elements toggle. themify_init_show_if( $('#themify, .toplevel_page_themify-builder #wpbody-content') ); // Clear cache builder $('.js-clear-cache').on('click', function( e ){ e.preventDefault(); const $this = $(this); if ( $this.hasClass('disabled') ) return; $this.addClass('disabled').find('span').text( $this.data('clearing-text') ).end() .find('i').removeClass().addClass('tf_loader'); Themify.fetch({ action:this.dataset.action, data:this.dataset.send==='all'?$themify.serialize():'', nonce: themify_js_vars.nonce }).then(resp=>{ if(resp && resp.error){ alert(resp.error); } $this.find('span').text( $this.data('done-text') ).end() .find('i').removeClass(); if(resp && resp.remove_after){ setTimeout(()=>{$this.closest('.pushlabel').remove();}, 3000); return; } setTimeout(()=>{ $this.find('span').text( $this.data('default-text') ).end() .find('i').removeClass().addClass( $this.data('default-icon')).end(); }, 3000); }). finally(()=>{ $this.removeClass('disabled'); }); }); $('.input-range .range-slider').each(function(){ let $this = $(this), $input = $this.next(), isRange = $input.data('range') ? true: false; $this.slider({ range: isRange, min: $input.data('min'), max: $input.data('max'), values: $input.val().split('-'), slide( event, ui ) { if ( ui.values[0] == ui.values[ 1 ] || ! isRange ) { $input.val( ui.values[ 0 ] ); } else { $input.val( ui.values[ 0 ] + '-' + ui.values[ 1 ] ); } } }); $input.on('keyup',function(){ const $el = $(this), val = parseInt($el.val()); // Update min if(val < parseInt($el.data('default-min'))){ $this.slider( "option", "min", val ); } // Update max if(val > parseInt($el.data('default-max'))){ $this.slider( "option", "max", val ); } $this.slider( "values", [val] ); }); }); themify_regenerate_css_files(); tb_find_and_replace(); tb_maintenance_mode(); const font_import = doc.tfId( 'tf_font_import_notice' ), size_slider_wrap = doc.tfId( 'tf_font_size_slider_wrap' ); if ( font_import ) { $( font_import ).insertAfter( '.wp-header-end' ); } if ( size_slider_wrap ) { $( "#tf_font_size_slider_wrap" ).appendTo( 'th#font_preview' ); let style = doc.tfId( 'tf_font_preview_style' ), size = localStorage.getItem( 'tf_font_preview_size' ) || 1, update_preview = function( size ) { style.innerText = '.font_preview span { font-size: ' + size + 'em; }'; }; update_preview( size ); $( "#tf_font_size_slider" ).slider({ value : size, min : 0.5, max : 4, step : .1, slide ( event, ui ) { update_preview( ui.value ); localStorage.setItem( 'tf_font_preview_size', ui.value ); } }); } let child_theme_generate_btns = doc.tfClass( 'generate-child-theme' ); for ( let i = 0; i < child_theme_generate_btns.length; i++ ) { child_theme_generate_btns[ i ].tfOn( 'click', e => { e.preventDefault(); if ( confirm( child_theme_generate_btns[ i ].dataset.confirm ) ) { themify_show_alert(); $.ajax( { url : ajaxurl, type : 'POST', data : { action : 'themify_generate_child_theme', nonce : themify_js_vars.nonce, import_customizer : child_theme_generate_btns[ i ].closest( 'div' ).querySelector('input[type="checkbox"]').checked ? 1 : 0 }, success : ( response ) => { themify_hide_alert(); if ( response.success ) { child_theme_generate_btns[ i ].classList.add( 'disabled' ); child_theme_generate_btns[ i ].closest( '.tf_generate_child_theme' ).classList.add( 'tf_done' ); } else { alert( response.data[0].message ); // oof } } } ); } } ); } function themify_init_show_if( $context ){ var selectors = $context.find('[data-show-if-element]').map(function(){ return $(this).data('show-if-element'); }).get().filter(function(itm, i, selectors){ return i === selectors.indexOf( itm ); }); $.each(selectors, function(i, selector){ var $source_element_selector = selector; themify_apply_show_if( $source_element_selector ); $( doc ).on( 'change', $source_element_selector, function(e){ themify_apply_show_if( $source_element_selector ); }); }); } function themify_apply_show_if( $source_element_selector_new ){ $( '[data-show-if-element="' + $source_element_selector_new + '"]' ).each(function(){ var $target_element = $(this), $target_value = $target_element.data( 'show-if-value' ), $source_element = $( $target_element.data( 'show-if-element' ).toString() ), $source_element_value = ''; /* Check the reason */ if ($source_element.length <= 0) return; if ( $source_element.is(':checkbox') ) { $source_element_value = $source_element.is(':checked') ? 'true' : 'false' ; } else if( $source_element.is(':radio') ) { $source_element_value = $source_element.filter( ':checked' ).val(); } else { $source_element_value = $source_element.val().trim(); } $target_value = Array.isArray($target_value) ? $target_value : [$target_value.toString()]; if( 'undefined' !== typeof( $source_element_value ) && $.inArray($source_element_value,$target_value)!==-1){ // Show $target_element.slideDown( { duration: 200 } ); } else { // Hide $target_element.slideUp( { duration: 200 } ); } }); } function themify_regenerate_css_files(){ const btn = doc.tfId('builder-regenerate-css-files'); if ( ! btn ) return; btn.tfOn( 'click', async e=>{ const bt=e.currentTarget, defaultText=bt.value; if(!bt.disabled){ bt.value='Regenerating ...'; bt.disabled=true; await Themify.loadJs(Themify.url+'js/admin/notification',!!win.TF_Notification); TF_Notification.show('info','Regenerating ...'); try{ const res=await Themify.fetch({ nonce: themify_js_vars.nonce, action: 'themify_regenerate_css_files_ajax', all:doc.querySelector('#tmp_regenerate_all_css:checked')?1:0 }); if(!res.success){ throw res; } await TF_Notification.showHide('done','Done',1500); } catch(e){ const msg=e.data?e.data:e; await TF_Notification.showHide('error',msg); } bt.value=defaultText; bt.disabled=false; } },{passive:true}); } // Get builder posts and make data ready to send find and replace ajax request async function tb_get_builder_posts(){ Themify.loadJs(Themify.url+'js/admin/notification',!!win.TF_Notification); const find = doc.tfId('original_string').value.trim(), replace = doc.tfId('replace_string').value.trim(); await Themify.loadJs(Themify.url+'js/admin/modules/find-replace',!!win.TF_Replace); return TF_Replace(find,replace,themify_js_vars.nonce); } // Handle find and replace string functionality tools function tb_find_and_replace(){ $('#builder-find-and-replace-btn').on( 'click', async e=>{ const bt=e.currentTarget.classList; if(!bt.contains('disabled')){ bt.add('disabled'); if('' === $('#original_string').val()){ alert('Please fill original value for search!'); } else if (confirm("WARNING: This will replace all data in your database. It can not be undone. Please backup your database before proceeding.")) { try{ await tb_get_builder_posts(); } catch(e){ } } bt.remove('disabled'); } }); } // Handle maintenance functionality tool function tb_maintenance_mode(){ const pagesDropdown = doc.tfId('setting-page_builder_maintenance_page'); if( null === pagesDropdown ){ return; } pagesDropdown.tfOn('mousedown',function(e){ var self = this; $.ajax( { url: ajaxurl, type:'POST', data: { action: 'themify_load_maintenance_pages', nonce : themify_js_vars.nonce }, success( data ) { self.innerHTML = data; // Fix safari bug - Safari does not update the select after HTML is changed if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){ self.blur(); self.dispatchEvent(e); } } }); },{once:true,passive:true}); } async function themify_code_editor(el){ try{ await Themify.loadJs(Themify.url+'js/admin/modules/codemirror/codemirror',!!win.ThemifyCodeMiror); const obj=new ThemifyCodeMiror(el,'htmlmixed'); await obj.run(); } catch(e){ } } // Tooltip helper $(function() { const previewIcon = $( '#themify .preview-icon' ); if( previewIcon.length ) { previewIcon.each( function() { var $item = $( this ), title = $item.attr( 'title' ); $item.removeAttr( 'title' ).append( '<span class="tm-option-title-fw">' + title + '</span>' ); } ); } } ); // Custom Posts in RSS option, this multiselect option is stored as a string $( '#themify_feed_settings select' ).on( 'change', function() { $( this ).next().val( $( this ).val().join( ',' ) ); } ); /*******************************************************************************/ /* Display Alerts */ function themify_show_alert(){ const alert=doc.tfClass('tb_alert')[0]; if(alert && !alert.classList.contains('busy')){ alert.classList.add('busy'); $(alert).fadeIn(800); } } function themify_hide_alert(status){ const el=$(".tb_alert").removeClass("busy"); if(status === 'error'){ status = 'error'; //themify_show_errors(); } else if(status==='hide'){ el[0].style.display='none'; setTimeout(()=>{ el[0].style.display=''; },200); return; } else { status = 'done'; } el.addClass(status).delay(800).fadeOut(800, function(){ $(this).removeClass(status); }); } function themify_modal_action(act='open'){ doc.body.classList.toggle('themify-modal-active','open'===act); } function themify_select_wrapper($el){ $el.find('select').not('[multiple]').wrap('<div class="selectwrapper"></div>'); $el.find('.selectwrapper').on('click',function(){ $(this).toggleClass('clicked'); }); } async function themify_erase_content(keep_modify){ themify_show_alert(); await Themify.loadJs(Themify.url+'js/admin/notification',!!win.TF_Notification); await TF_Notification.show('info',themify_js_vars.erase.processing); try{ const resp=await Themify.fetch({ action: 'themify_erase_content', nonce:themify_js_vars.nonce, data:{ keep_modify:keep_modify?1:0 } }); if(!resp.success){ throw 'error'; } if(resp.data==='repeat'){ await themify_erase_content(keep_modify); } else{ themify_hide_alert('done'); await TF_Notification.showHide('done',themify_js_vars.erase.done,2000); if(resp.data!=='hasdemo'){ for(let eraseLink=doc.tfClass('skin-erase-link'),i=eraseLink.length-1;i>-1;--i){ eraseLink[i].parentNode.tfClass('tf_erase_box')[0].remove(); eraseLink[i].remove(); } } } } catch(e){ const er=typeof e==='string'?e:''; await TF_Notification.showHide('error',themify_js_vars.erase.error.replace('%error%',er),4000); throw e; } } Themify.on('themify_erase_content',themify_erase_content); doc.tfOn('click',async e=>{ const classes=[ '.license-link', '.themify-ajax-installer', '.update-license.themify_button', '.skin-demo-import', '.skin-erase-demo', '.import-sample-content', '.erase-sample-content' ].join(','), target=e.target?e.target.closest(classes):null; if(target){ e.preventDefault(); const cl=target.classList; try{ if(!cl.contains( 'disabled' )){ cl.add( 'disabled' ); Themify.loadJs(Themify.url+'js/admin/notification',!!win.TF_Notification);//start loading const moduleUrl=Themify.url+'js/admin/modules/'; if(cl.contains('license-link') || cl.contains('update-license')){ await Themify.loadJs(moduleUrl+'license',!!win.TF_License); if(cl.contains('update-license')){ themify_show_alert(); await TF_License.update(); if(typeof ThemifyUpdater!=='undefined'){ ThemifyUpdater.updateThemeBtn(); } themify_hide_alert('done'); if(doc.tfClass('required-addons')[0]===undefined){ setTimeout(()=>{ win.location.reload(); },100); } } else{ TF_License.init(); } } else if(cl.contains('erase-sample-content') || cl.contains('skin-erase-demo')){ let keep_modify= target.closest('.tf_erase_box'); if(keep_modify){ keep_modify=keep_modify.querySelector('.tf_modify_demo:checked'); } await Themify.trigger('themify_erase_content',!!keep_modify); } else if(cl.contains('themify-ajax-installer')){ themify_show_alert(); await Themify.loadJs(Themify.url+'js/admin/modules/install-updater',!!win.TF_Install_Updater); await TF_Install_Updater(themify_js_vars.nonce); themify_hide_alert('done'); setTimeout(()=>{ win.location.reload(); },100); } else if(cl.contains('skin-demo-import') || cl.contains('import-sample-content')){ themify_show_alert(); await Themify.loadJs(moduleUrl+'skin',!!win.TF_Skin); const data={}; if(doc.tfId('license-modal')===null){ data.license=1; } if(target.dataset.plugins){ data.plugins=target.dataset.plugins; } if(target.dataset.id){ data.skin=target.dataset.id; } const state=await TF_Skin.init(data); themify_hide_alert(state==='open'?'hide':'done'); } } } catch(e){ themify_hide_alert('error'); } finally{ cl.remove( 'disabled' ); } } }); }); })(Themify,jQuery,window,document);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка