← Back
Editing: themes-tab.min.js
jQuery(document).ready(function(s){var e=function(){var e=s("<li></li>").prependTo(".wp-filter > .filter-links");s('<a href="" data-sort="gd-recommended" class="js-gd-recommended"></a>').text(gdThemesTab.tab).appendTo(e),s(".page-title-action").attr("aria-expanded",!0)},t=function(){s(".add-new-theme").remove().prependTo(".theme-browser .themes")},a=wp.themes.view.Installer.prototype,n=s("body"),i=(wp.themes.view.Installer=wp.themes.view.Installer.extend({events:function(){var e=_.extend({},a.events,{"click .filter-links li > a.js-gd-recommended":"gdThemes"});return delete e["click .filter-links li > a"],e["click .filter-links li > a:not( .js-gd-recommended )"]="onSort",e},browse:function(e){"gd-recommended"===e?this.loadThemes():this.collection.query({browse:e})},gdThemes:function(e){e.preventDefault(),this.clearSearch();var e=e.target,t=e.getAttribute("data-sort");e.classList.contains(this.activeClass)||(n.removeClass("filters-applied show-filters"),s(".drawer-toggle").attr("aria-expanded","false"),n.removeClass("show-favorites-form"),s(".filter-links li > a, .theme-filter").removeClass(this.activeClass),s("[data-sort]").filter(function(){return s(this).data("sort")===t}).addClass(this.activeClass),this.loadThemes(),wp.themes.router.navigate(wp.themes.router.baseUrl(wp.themes.router.browsePath+t)))},loadThemes:function(){n.addClass("loading-content").removeClass("no-results"),s.post(ajaxurl,{action:"gd_render_themes"},function(e){e.success&&(n.removeClass("loading-content"),s(".theme-browser .themes").empty().append(e.data),s(".theme-count").text(s(".theme-browser .themes > div.theme").length))}),s("#gd-theme-install").length||s(".theme-browser .themes").after('<div id="gd-theme-install" style="display:none;"></div>')},scroller:function(){s(".js-gd-recommended").hasClass("current")||a.scroller.apply(this,arguments)}}),{notice:function(e,t){return s("<div></div>").addClass(e).append(s("<p></p>").text(t))},init:function(t){var e={action:"gd_install_theme",slug:t.data("slug"),gd_package:t.data("package"),_ajax_nonce:t.data("nonce")},a=t.closest("div.theme");s.post(ajaxurl,e,function(e){e.success?a.append(i.notice("notice notice-success notice-alt",gdThemesTab.installed)).removeClass("focus").find(".theme-actions > .theme-install").removeClass("updating-message").text(gdThemesTab.installed).addClass("disabled").delay(1500).replaceWith([s('<a class="button button-primary activate-theme"></a>').attr("href",e.data.activateUrl).text(gdThemesTab.activate)[0],s('<a class="button button-secondary live-preview-theme"></a>').attr("href",e.data.customizeUrl).text(gdThemesTab.live_preview)[0]]):(a.append(i.notice("notice notice-error notice-alt update-message",gdThemesTab.error)),t.removeClass("updating-message"))})}});e(),s(window).on("load",t),s(document).on("click",".theme.godaddy .theme-screenshot, .theme.godaddy .more-details",function(){var e=s(this).closest(".theme.godaddy").attr("data-demo-url");window.open(e,"_blank")}),s(document).on("click",".theme.godaddy .button.theme-install",function(e){e.preventDefault(),e.stopPropagation(),s(this).addClass("updating-message").parents("div.theme").addClass("focus"),i.init(s(this))})});
Save File
Cancel