Customify – A Theme Customizer Booster - Version 2.10.2

Version Description

  • Improve Font Palettes behavior for a fresh installation (no Font Palette selected).
Download this release

Release Info

Developer pixelgrade
Plugin Icon Customify – A Theme Customizer Booster
Version 2.10.2
Comparing to
See all releases

Code changes from version 2.10.1 to 2.10.2

customify.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Customify
4
  * Plugin URI: https://wordpress.org/plugins/customify/
5
  * Description: A Theme Customizer Booster to easily and consistently customize Fonts, Colors, and other options for your site.
6
- * Version: 2.10.1
7
  * Author: Pixelgrade
8
  * Author URI: https://pixelgrade.com
9
  * Author Email: contact@pixelgrade.com
@@ -33,7 +33,7 @@ require_once 'includes/extras.php';
33
  function PixCustomifyPlugin() {
34
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-pixcustomify.php';
35
 
36
- return PixCustomifyPlugin::instance( __FILE__, '2.10.1' );
37
  }
38
 
39
  // Now get the party started.
3
  * Plugin Name: Customify
4
  * Plugin URI: https://wordpress.org/plugins/customify/
5
  * Description: A Theme Customizer Booster to easily and consistently customize Fonts, Colors, and other options for your site.
6
+ * Version: 2.10.2
7
  * Author: Pixelgrade
8
  * Author URI: https://pixelgrade.com
9
  * Author Email: contact@pixelgrade.com
33
  function PixCustomifyPlugin() {
34
  require_once plugin_dir_path( __FILE__ ) . 'includes/class-pixcustomify.php';
35
 
36
+ return PixCustomifyPlugin::instance( __FILE__, '2.10.2' );
37
  }
38
 
39
  // Now get the party started.
js/customizer/color-palettes.js CHANGED
@@ -909,38 +909,6 @@ window.customify = window.customify || parent.customify || {};
909
  updateFilteredColors()
910
  reinitializeConnectedFields()
911
  })
912
-
913
- initializeStyleManagerTabs();
914
- }
915
-
916
- const initializeStyleManagerTabs = function() {
917
- $( '.sm-tabs' ).each( function( i, obj ) {
918
- const $wrapper = $( obj );
919
- const $section = $wrapper.closest( '.control-section' );
920
- const $tabs = $wrapper.children( '.sm-tabs__item' );
921
- const targets = $tabs.map( ( i, el ) => {
922
- const target = $( el ).data( 'target' );
923
- return `sm-view-${ target }`
924
- } );
925
-
926
- const targetClassnames = targets.toArray().join( " " );
927
-
928
- function setActiveTab( $active ) {
929
- const target = $active.data( 'target' );
930
-
931
- $tabs.removeClass( 'sm-tabs__item--active' );
932
- $active.addClass( 'sm-tabs__item--active' );
933
-
934
- $section.removeClass( targetClassnames ).addClass( `sm-view-${ target }` );
935
- }
936
-
937
- $wrapper.on( 'click', '.sm-tabs__item', function(e) {
938
- e.preventDefault();
939
- setActiveTab( $( this ) );
940
- } );
941
-
942
- setActiveTab( $tabs.first() );
943
- } );
944
  }
945
 
946
  const updateFilterPreviews = _.debounce(() => {
909
  updateFilteredColors()
910
  reinitializeConnectedFields()
911
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  }
913
 
914
  const updateFilterPreviews = _.debounce(() => {
js/customizer/color-palettes.min.js CHANGED
@@ -1 +1 @@
1
- window.customify=window.customify||parent.customify||{},function(e,t,n){void 0===t.colorPalettes&&(t.colorPalettes={}),_.extend(t.colorPalettes,function(){const o=n.customize;let s;const i={};let c=!1;const r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(e){return isNaN(e)?"00":r[(e-e%16)/16]+r[e%16]}function l(e){return"#"+a(e[0])+a(e[1])+a(e[2])}function d(e){return l(k(e.hue,e.saturation,e.lightness))}function u(e){let t=0,n=0,o=0,s=0;/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e)&&(3===(e=e.substring(1).split("")).length&&(e=[e[0],e[0],e[1],e[1],e[2],e[2],"F","F"]),4===e.length&&(e=[e[0],e[0],e[1],e[1],e[2],e[2],e[3],e[3]]),t=parseInt([e[0],e[1]].join(""),16),n=parseInt([e[2],e[3]].join(""),16),o=parseInt([e[4],e[5]].join(""),16),s=parseInt([e[6],e[7]].join(""),16));const i=f(t,n,o);return{red:t,green:n,blue:o,alpha:s,hue:i[0],saturation:i[1],lightness:i[2],luma:.2126*t+.7152*n+.0722*o}}function f(e,t,n){e/=255,t/=255,n/=255;const o=Math.max(e,t,n),s=Math.min(e,t,n);let i,c,r=(o+s)/2;if(o==s)i=c=0;else{const a=o-s;switch(c=r>.5?a/(2-o-s):a/(o+s),o){case e:i=(t-n)/a+(t<n?6:0);break;case t:i=(n-e)/a+2;break;case n:i=(e-t)/a+4}i/=6}return[i,c,r]}const m=()=>{_.each(t.colorPalettes.masterSettingIds,(function(e){const t=o(e);if(void 0!==t){const n=t();i[e]=F(n)}}))},h=e=>i[e],g=function(){_.each(t.colorPalettes.masterSettingIds,(function(e){if(void 0!==s[e]){const n=s[e],i=o(e);_.isUndefined(n.connected_fields)||(t.colorPalettes.connectedFieldsCallbacks[e]=function(e,t){return function(n,s){const i=h(t);_.each(e.connected_fields,(function(e){if(_.isUndefined(e)||_.isUndefined(e.setting_id)||!_.isString(e.setting_id))return;const t=o(e.setting_id);_.isUndefined(t)||t.set(i)})),Q();const c=o(t+"_final");_.isUndefined(c)||(_.isUndefined(e.connected_fields)||_.isEmpty(e.connected_fields)?c.set(""):c.set(i))}}(n,e),i.bind(t.colorPalettes.connectedFieldsCallbacks[e]),_.each(n.connected_fields,(function(e){const n=e.setting_id,s=o(n);void 0!==s&&(t.colorPalettes.connectedFieldsCallbacks[n]=j,s.bind(t.colorPalettes.connectedFieldsCallbacks[n]))})))}}))},p=function(){_.each(t.colorPalettes.connectedFieldsCallbacks,(function(e,t){o(t).unbind(e)})),t.colorPalettes.connectedFieldsCallbacks={}},v=e=>t.colorPalettes.variations.hasOwnProperty(e)?t.colorPalettes.variations[e]:"light",y=()=>{const e=[];return _.each(t.colorPalettes.masterSettingIds,(function(t){const n=o(t)();e.push(n)})),e};function k(e,t,n){let o,s,i;if(0==t)o=s=i=n;else{const c=function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e},r=n<.5?n*(1+t):n+t-n*t,a=2*n-r;o=c(a,r,e+1/3),s=c(a,r,e),i=c(a,r,e-1/3)}return[Math.round(255*o),Math.round(255*s),Math.round(255*i)]}function b(e,t,n,o){return t[e]*(1-o)+n[e]*o}function C(e,t,n){return e*(1-n)+t*n}const F=(t,n)=>{n=void 0===n?e('[name*="sm_palette_filter"]:checked').val():n;let o=u(t);const s=y(),i=s.slice(0,3),c=s.slice(3,6);J(x(s)),J(x(i)),J(x(c));if("vivid"===n)return o=k(o.hue,C(o.saturation,1,.5),o.lightness),l(o);if("warm"===n&&t!==s[0]){let e=u("#704214");return e.saturation=b("saturation",e,o,1),e.lightness=b("lightness",e,o,1),e=u(d(e)),o.saturation=.75*o.saturation,o=u(d(o)),a=e,_=(_=.75)||.5,(r=o).red=parseInt(a.red*_+r.red*(1-_),10),r.green=parseInt(a.green*_+r.green*(1-_),10),r.blue=parseInt(a.blue*_+r.blue*(1-_),10),o=u(l([r.red,r.green,r.blue])),o.lightness=b("lightness",o,u(o.lightness>.5?"#FFF":"#000"),.2),d(o)}var r,a,_;if("softer"===n)return o.saturation=b("saturation",o,u("#FFF"),.3),o.lightness=b("lightness",o,u("#FFF"),.1),d(o);if("pastel"===n)return o.saturation=b("saturation",o,u("#FFF"),.6),o.lightness=b("lightness",o,u("#FFF"),.2),d(o);if("greyish"===n)return o=k(o.hue,C(o.saturation,0,.8),o.lightness),l(o);if("clarendon"===n)return t===s[0]||t===s[1]||t===s[2]?(o=k(o.hue,C(o.saturation,1,.3),o.lightness),l(o)):(t!==s[3]&&t!==s[4]&&t!==s[5]||(o.lightness=b("lightness",o,u("#000"),.4)),t!==s[6]&&t!==s[7]&&t!==s[8]||(o.lightness=b("lightness",o,u("#FFF"),.4)),d(o));if("cold"===n&&t!==s[0]){const e=.55;o.saturation=b("saturation",o,u("#FFF"),.4),o.hue=(o.hue-e)/18+e,o=u(d(o));const t=f(o.red,o.green,o.blue);return o.hue=t[0],o.saturation=C(t[1],1,.1),o.lightness=b("lightness",o,u(o.lightness>.5?"#FFF":"#000"),.2),d(o)}return"dumb"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.lightness=b("lightness",o,u("#000"),.2),o.saturation=b("saturation",o,u("#000"),.2),t===s[2]&&(o.lightness=b("lightness",o,u("#000"),.2),o.saturation=b("saturation",o,u("#000"),.2)),d(o)):(o.hue=u(s[0]).hue,d(o)):"mayfair"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.hue=(o.hue+.05)%1,t===s[2]&&(o.hue=(o.hue+.05)%1),d(o)):(o.hue=u(s[0]).hue,d(o)):"sierra"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.hue=(o.hue+.95)%1,t===s[2]&&(o.hue=(o.hue+.95)%1),d(o)):(o.hue=u(s[0]).hue,d(o)):t},P=function(){_.each(t.colorPalettes.masterSettingIds,(function(t){e(".c-color-palette").find(".sm-color-palette__color."+t).css("color",h(t))}))},w=function(){_.each(t.colorPalettes.masterSettingIds,(function(t){const n=o(t)();e(".c-color-palette").find(".sm-color-palette__color."+t).css("color",n)}))},U=function(){e(this).trigger("customify:preset-change"),m(),A()},S=_.debounce(()=>{let n=e();_.each(t.colorPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const o=s[t];_.isUndefined(o.connected_fields)||_.each(o.connected_fields,(function(t){const o=t.setting_id.match(/\[(.*?)\]/);if(o){const t=o[1],s=e(".customize-control-color").filter('[id*="'+t+'"]').find(".wp-color-picker");n=n.add(s)}}))}})),n.iris({palettes:y()})},30),j=_.debounce(()=>{const n=[];let i;_.each(t.colorPalettes.masterSettingIds,(function(e){let t=s[e].connected_fields;const i=o(e)();let c=!1;_.isUndefined(t)||Array.isArray(t)||(t=Object.keys(t).map((function(e){return t[e]}))),!_.isUndefined(t)&&t.length&&(_.each(t,(function(e){const t=e.setting_id,n=o(t);if(void 0!==n){const e=n();"string"==typeof e&&e.toLowerCase()!==F(i).toLowerCase()&&(c=!0)}})),c&&n.push(e))})),i="."+n.join(", ."),e(".c-color-palette .color").removeClass("altered"),n.length&&e(".c-color-palette .color").filter(i).addClass("altered")},30),I=_.debounce(()=>{const n=[];let o;_.each(t.colorPalettes.masterSettingIds,(function(e){const t=s[e].connected_fields;_.isUndefined(t)||_.isEmpty(t)||n.push(e)})),o=_.isEmpty(n)?"*":"."+n.join(", ."),e(".sm-palette-filter .color").addClass("hidden").filter(o).removeClass("hidden"),e(".sm-color-palette__color").addClass("hidden").filter(o).removeClass("hidden"),e(".js-color-palette .palette__item").addClass("hidden").filter(o).removeClass("hidden")},30),O=()=>{j(),I(),S(),P()},D=(e,t)=>{const n=JSON.parse(JSON.stringify(e)),o=JSON.parse(JSON.stringify(e));return _.each(t,(function(e,t){if(void 0!==n[t]){let s=[];e instanceof Array&&_.each(e,(function(e){let t;_.isUndefined(o[e].connected_fields)&&(o[e].connected_fields=[]),t=Object.values(o[e].connected_fields),s=s.concat(t)})),n[t].connected_fields=Object.keys(s).map((function(e){return s[e]}))}})),_.clone(n)},z=(e,t,n,o)=>{const s=_.clone(e);if(!_.isUndefined(s[n])&&!_.isUndefined(s[t])){_.isUndefined(s[t].connected_fields)&&(s[t].connected_fields=[]),_.isUndefined(s[n].connected_fields)&&(s[n].connected_fields=[]);const e=Object.values(s[t].connected_fields),i=Object.values(s[n].connected_fields).concat(e),c=Math.round(o*i.length);let r=i.slice(0,c);const a=i.slice(c);r=Object.keys(r).map((function(e){return r[e]})),r=Object.keys(r).map((function(e){return r[e]})),s[n].connected_fields=r,s[t].connected_fields=a}return s},N=()=>{let n=JSON.parse(JSON.stringify(t.settingsClone));const i=e('[name*="sm_color_diversity"]'),c=e('[name*="sm_coloration_level"]'),r=!!i.length,a=void 0!==i.filter(":checked").data("default"),l=!r||a,d=!!c.length,u=void 0!==e('[name*="sm_coloration_level"]:checked').data("default"),f=!d||u,m=r?e('[name*="sm_color_diversity"]:checked').val():o("sm_color_diversity")();if(!l||!f){const t=e("#_customize-input-sm_dark_color_primary_slider_control").val()/100,o=e("#_customize-input-sm_dark_color_secondary_slider_control").val()/100,s=e("#_customize-input-sm_dark_color_tertiary_slider_control").val()/100;n=z(n,"sm_dark_primary","sm_color_primary",t),n=z(n,"sm_dark_secondary","sm_color_secondary",o),n=z(n,"sm_dark_tertiary","sm_color_tertiary",s);const i=v("color_diversity_low");n=D(n,i),"medium"===m&&(n=z(n,"sm_color_primary","sm_color_secondary",.5)),"high"===m&&(n=z(n,"sm_color_primary","sm_color_secondary",.67),n=z(n,"sm_color_secondary","sm_color_tertiary",.5))}const h=e('[name*="sm_shuffle_colors"]:checked').val();if("default"!==h){const e=v("shuffle_"+h);n=D(n,e)}if("on"===e('[name*="sm_dark_mode_control"]:checked').val()){const e=v("dark");n=D(n,e)}_.each(t.colorPalettes.masterSettingIds,(function(e){s[e]=n[e]}))},x=function(e){const t=[];return _.each(e,(function(e){t.push(u(e))})),t},J=function(e){const t={red:0,green:0,blue:0,alpha:0,hue:0,saturation:0,lightness:0,luma:0};for(let n=0;n<e.length;n++){const o=e[n];for(let e in t)t[e]+=o[e]}for(let n in t)t[n]/=e.length;return t},M=()=>{const n=e('[name*="sm_coloration_level"]:checked').val();if(void 0!==e('[name*="sm_coloration_level"]:checked').data("default")){const n=["sm_dark_color_primary_slider","sm_dark_color_secondary_slider","sm_dark_color_tertiary_slider"];_.each(n,(function(n){const s=t.config.settings[n];o(n).set(s.default),e("#_customize-input-"+n+"_control ").val(s.default)}))}else{const t=parseFloat(n);e("#_customize-input-sm_dark_color_primary_slider_control, #_customize-input-sm_dark_color_secondary_slider_control, #_customize-input-sm_dark_color_tertiary_slider_control").val(t)}A()},A=()=>{N(),p(),g(),O(),_.each(t.colorPalettes.masterSettingIds,(function(e){if(void 0!==o(e)){let t=s[e];const n=h(e);_.each(t.connected_fields,(function(e){if(_.isUndefined(e)||_.isUndefined(e.setting_id)||!_.isString(e.setting_id))return;const t=o(e.setting_id);_.isUndefined(t)||t.set(n)}));const i=o(e+"_final");_.isUndefined(i)||(_.isUndefined(t.connected_fields)||_.isEmpty(t.connected_fields)?i.set(""):i.set(n))}}))},E=t=>{const n=!!e(".c-color-palette .color.altered").length;let o=!0;return n&&(o=confirm("One or more fields connected to the color palette have been modified. By changing the palette variation you will lose changes to any color made prior to this action.")),!(n&&!o)&&("function"==typeof t&&t(),!0)},L=()=>{const n=e(".c-color-palette__control"),s=(()=>{const e=o("sm_color_palette_variation");if(_.isUndefined(e))return"light";const n=e();return t.colorPalettes.variations.hasOwnProperty(n)?n:"light"})();n.removeClass("active"),n.filter(".variation-"+s).addClass("active"),e(document).on("click",".js-color-palette input",(function(e){E(U.bind(this))||e.preventDefault()})),e('[for*="sm_palette_filter"], [for*="sm_coloration_level"], [for*="sm_color_diversity"], [for*="sm_shuffle_colors"], [for*="sm_dark_mode"]').on("click",(function(e){E()||e.preventDefault()})),e('[name*="sm_coloration_level"]').on("change",M),e('[name*="sm_color_diversity"]').on("change",A),e('[name*="sm_shuffle_colors"]').on("change",A),e('[name*="sm_dark_mode"]').on("change",A),e('[name*="sm_palette_filter"]').on("change",()=>{m(),A()}),B()},B=function(){e(".sm-tabs").each((function(t,n){const o=e(n),s=o.closest(".control-section"),i=o.children(".sm-tabs__item"),c=i.map((t,n)=>"sm-view-"+e(n).data("target")).toArray().join(" ");function r(e){const t=e.data("target");i.removeClass("sm-tabs__item--active"),e.addClass("sm-tabs__item--active"),s.removeClass(c).addClass("sm-view-"+t)}o.on("click",".sm-tabs__item",(function(t){t.preventDefault(),r(e(this))})),r(i.first())}))},Q=_.debounce(()=>{e(".sm-palette-filter").each((function(){e(this).find("input").each((function(t,n){const s=e(n),i=s.next("label"),c=s.val();i.find(".sm-color-palette__color").each((function(t,n){const s=e(n),i=s.data("setting"),r=o(i)();s.css("color",F(r,c))}))}))}))},30);function W(e,t){const n=o(e)(),s=o(t)();o(e).set(s),o(t).set(n)}return o.bind("ready",(function(){s=o.settings.settings,c||(_.each(t.colorPalettes.masterSettingIds,(function(e){i[e]=""})),void 0===t.settingsClone&&(t.settingsClone=e.extend(!0,{},s)),void 0===t.colorPalettes.connectedFieldsCallbacks&&(t.colorPalettes.connectedFieldsCallbacks={}),c=!0),(()=>{const t=e(".c-color-palette"),n=t.find(".c-color-palette__fields").find("input");if(!t.length)return;const s=t.find(".sm-color-palette__color");s.each((c,r)=>{const a=e(r),l=a.data("setting"),d=n.filter("."+l),_=o(l);if(a.data("target",d),a.hasClass("js-no-picker"))return;d.iris({change:(e,n)=>{const o=n.color.toString();a.css("color",F(o)),i[l]=F(o),_.set(o),"external"!==e.originalEvent.type&&t.find(".sm-color-palette__color."+l).removeClass("altered"),S()}}),a.find(".iris-picker").on("click",(function(e){e.stopPropagation(),e.preventDefault()}));const u=()=>{s.not(a).each((function(t,n){e(n).data("target").not(d).hide()})),d.show().focus()};a.on("click",e=>{e.stopPropagation(),e.preventDefault(),d.is(":visible")?(d.iris("hide"),d.hide(),s.removeClass("active inactive")):a.is(".altered")?E(u):u()}),d.on("click",e=>{e.stopPropagation(),e.preventDefault()}),d.on("focus",n=>{s.not(a).addClass("inactive").removeClass("active"),a.addClass("active").removeClass("inactive"),s.not(a).each((function(t,n){e(n).data("target").iris("hide")}));const o=d.next(".iris-picker"),i=t.find(".c-color-palette__colors").outerWidth(),c=s.filter(":visible"),r=c.index(a);o.css("left",(i-200)*r/(c.length-1)),w(),d.iris("show")}),d.on("focusout",e=>{P()})}),e("body").on("click",(function(){s.removeClass("active inactive"),s.each((function(t,n){const o=e(n).data("target");e(n).hasClass("js-no-picker")||o.iris("hide"),o.hide()}))}))})(),N(),m(),p(),g(),O(),Q(),function(){const t=e(document);t.on("click",'[data-action="sm_swap_colors"]',(function(e){e.preventDefault(),W("sm_color_primary","sm_color_secondary")})),t.on("click",'[data-action="sm_swap_dark_light"]',(function(e){e.preventDefault(),W("sm_dark_primary","sm_light_primary"),W("sm_dark_secondary","sm_light_secondary"),W("sm_dark_tertiary","sm_light_tertiary")})),t.on("click",'[data-action="sm_swap_colors_dark"]',(function(e){e.preventDefault(),W("sm_color_primary","sm_dark_primary"),W("sm_color_secondary","sm_dark_secondary"),W("sm_color_tertiary","sm_dark_tertiary")})),t.on("click",'[data-action="sm_swap_secondary_colors_dark"]',(function(e){e.preventDefault(),W("sm_color_secondary","sm_dark_secondary")}))}(),L()})),{}}())}(jQuery,customify,wp);
1
+ window.customify=window.customify||parent.customify||{},function(e,t,n){void 0===t.colorPalettes&&(t.colorPalettes={}),_.extend(t.colorPalettes,function(){const o=n.customize;let s;const i={};let c=!1;const r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(e){return isNaN(e)?"00":r[(e-e%16)/16]+r[e%16]}function l(e){return"#"+a(e[0])+a(e[1])+a(e[2])}function d(e){return l(k(e.hue,e.saturation,e.lightness))}function u(e){let t=0,n=0,o=0,s=0;/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(e)&&(3===(e=e.substring(1).split("")).length&&(e=[e[0],e[0],e[1],e[1],e[2],e[2],"F","F"]),4===e.length&&(e=[e[0],e[0],e[1],e[1],e[2],e[2],e[3],e[3]]),t=parseInt([e[0],e[1]].join(""),16),n=parseInt([e[2],e[3]].join(""),16),o=parseInt([e[4],e[5]].join(""),16),s=parseInt([e[6],e[7]].join(""),16));const i=f(t,n,o);return{red:t,green:n,blue:o,alpha:s,hue:i[0],saturation:i[1],lightness:i[2],luma:.2126*t+.7152*n+.0722*o}}function f(e,t,n){e/=255,t/=255,n/=255;const o=Math.max(e,t,n),s=Math.min(e,t,n);let i,c,r=(o+s)/2;if(o==s)i=c=0;else{const a=o-s;switch(c=r>.5?a/(2-o-s):a/(o+s),o){case e:i=(t-n)/a+(t<n?6:0);break;case t:i=(n-e)/a+2;break;case n:i=(e-t)/a+4}i/=6}return[i,c,r]}const h=()=>{_.each(t.colorPalettes.masterSettingIds,(function(e){const t=o(e);if(void 0!==t){const n=t();i[e]=C(n)}}))},m=e=>i[e],g=function(){_.each(t.colorPalettes.masterSettingIds,(function(e){if(void 0!==s[e]){const n=s[e],i=o(e);_.isUndefined(n.connected_fields)||(t.colorPalettes.connectedFieldsCallbacks[e]=function(e,t){return function(n,s){const i=m(t);_.each(e.connected_fields,(function(e){if(_.isUndefined(e)||_.isUndefined(e.setting_id)||!_.isString(e.setting_id))return;const t=o(e.setting_id);_.isUndefined(t)||t.set(i)})),B();const c=o(t+"_final");_.isUndefined(c)||(_.isUndefined(e.connected_fields)||_.isEmpty(e.connected_fields)?c.set(""):c.set(i))}}(n,e),i.bind(t.colorPalettes.connectedFieldsCallbacks[e]),_.each(n.connected_fields,(function(e){const n=e.setting_id,s=o(n);void 0!==s&&(t.colorPalettes.connectedFieldsCallbacks[n]=j,s.bind(t.colorPalettes.connectedFieldsCallbacks[n]))})))}}))},p=function(){_.each(t.colorPalettes.connectedFieldsCallbacks,(function(e,t){o(t).unbind(e)})),t.colorPalettes.connectedFieldsCallbacks={}},v=e=>t.colorPalettes.variations.hasOwnProperty(e)?t.colorPalettes.variations[e]:"light",y=()=>{const e=[];return _.each(t.colorPalettes.masterSettingIds,(function(t){const n=o(t)();e.push(n)})),e};function k(e,t,n){let o,s,i;if(0==t)o=s=i=n;else{const c=function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e},r=n<.5?n*(1+t):n+t-n*t,a=2*n-r;o=c(a,r,e+1/3),s=c(a,r,e),i=c(a,r,e-1/3)}return[Math.round(255*o),Math.round(255*s),Math.round(255*i)]}function b(e,t,n,o){return t[e]*(1-o)+n[e]*o}function F(e,t,n){return e*(1-n)+t*n}const C=(t,n)=>{n=void 0===n?e('[name*="sm_palette_filter"]:checked').val():n;let o=u(t);const s=y(),i=s.slice(0,3),c=s.slice(3,6);J(x(s)),J(x(i)),J(x(c));if("vivid"===n)return o=k(o.hue,F(o.saturation,1,.5),o.lightness),l(o);if("warm"===n&&t!==s[0]){let e=u("#704214");return e.saturation=b("saturation",e,o,1),e.lightness=b("lightness",e,o,1),e=u(d(e)),o.saturation=.75*o.saturation,o=u(d(o)),a=e,_=(_=.75)||.5,(r=o).red=parseInt(a.red*_+r.red*(1-_),10),r.green=parseInt(a.green*_+r.green*(1-_),10),r.blue=parseInt(a.blue*_+r.blue*(1-_),10),o=u(l([r.red,r.green,r.blue])),o.lightness=b("lightness",o,u(o.lightness>.5?"#FFF":"#000"),.2),d(o)}var r,a,_;if("softer"===n)return o.saturation=b("saturation",o,u("#FFF"),.3),o.lightness=b("lightness",o,u("#FFF"),.1),d(o);if("pastel"===n)return o.saturation=b("saturation",o,u("#FFF"),.6),o.lightness=b("lightness",o,u("#FFF"),.2),d(o);if("greyish"===n)return o=k(o.hue,F(o.saturation,0,.8),o.lightness),l(o);if("clarendon"===n)return t===s[0]||t===s[1]||t===s[2]?(o=k(o.hue,F(o.saturation,1,.3),o.lightness),l(o)):(t!==s[3]&&t!==s[4]&&t!==s[5]||(o.lightness=b("lightness",o,u("#000"),.4)),t!==s[6]&&t!==s[7]&&t!==s[8]||(o.lightness=b("lightness",o,u("#FFF"),.4)),d(o));if("cold"===n&&t!==s[0]){const e=.55;o.saturation=b("saturation",o,u("#FFF"),.4),o.hue=(o.hue-e)/18+e,o=u(d(o));const t=f(o.red,o.green,o.blue);return o.hue=t[0],o.saturation=F(t[1],1,.1),o.lightness=b("lightness",o,u(o.lightness>.5?"#FFF":"#000"),.2),d(o)}return"dumb"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.lightness=b("lightness",o,u("#000"),.2),o.saturation=b("saturation",o,u("#000"),.2),t===s[2]&&(o.lightness=b("lightness",o,u("#000"),.2),o.saturation=b("saturation",o,u("#000"),.2)),d(o)):(o.hue=u(s[0]).hue,d(o)):"mayfair"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.hue=(o.hue+.05)%1,t===s[2]&&(o.hue=(o.hue+.05)%1),d(o)):(o.hue=u(s[0]).hue,d(o)):"sierra"===n?t===s[1]||t===s[2]?(o=u(s[0]),o.hue=(o.hue+.95)%1,t===s[2]&&(o.hue=(o.hue+.95)%1),d(o)):(o.hue=u(s[0]).hue,d(o)):t},P=function(){_.each(t.colorPalettes.masterSettingIds,(function(t){e(".c-color-palette").find(".sm-color-palette__color."+t).css("color",m(t))}))},U=function(){_.each(t.colorPalettes.masterSettingIds,(function(t){const n=o(t)();e(".c-color-palette").find(".sm-color-palette__color."+t).css("color",n)}))},w=function(){e(this).trigger("customify:preset-change"),h(),E()},S=_.debounce(()=>{let n=e();_.each(t.colorPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const o=s[t];_.isUndefined(o.connected_fields)||_.each(o.connected_fields,(function(t){const o=t.setting_id.match(/\[(.*?)\]/);if(o){const t=o[1],s=e(".customize-control-color").filter('[id*="'+t+'"]').find(".wp-color-picker");n=n.add(s)}}))}})),n.iris({palettes:y()})},30),j=_.debounce(()=>{const n=[];let i;_.each(t.colorPalettes.masterSettingIds,(function(e){let t=s[e].connected_fields;const i=o(e)();let c=!1;_.isUndefined(t)||Array.isArray(t)||(t=Object.keys(t).map((function(e){return t[e]}))),!_.isUndefined(t)&&t.length&&(_.each(t,(function(e){const t=e.setting_id,n=o(t);if(void 0!==n){const e=n();"string"==typeof e&&e.toLowerCase()!==C(i).toLowerCase()&&(c=!0)}})),c&&n.push(e))})),i="."+n.join(", ."),e(".c-color-palette .color").removeClass("altered"),n.length&&e(".c-color-palette .color").filter(i).addClass("altered")},30),I=_.debounce(()=>{const n=[];let o;_.each(t.colorPalettes.masterSettingIds,(function(e){const t=s[e].connected_fields;_.isUndefined(t)||_.isEmpty(t)||n.push(e)})),o=_.isEmpty(n)?"*":"."+n.join(", ."),e(".sm-palette-filter .color").addClass("hidden").filter(o).removeClass("hidden"),e(".sm-color-palette__color").addClass("hidden").filter(o).removeClass("hidden"),e(".js-color-palette .palette__item").addClass("hidden").filter(o).removeClass("hidden")},30),O=()=>{j(),I(),S(),P()},z=(e,t)=>{const n=JSON.parse(JSON.stringify(e)),o=JSON.parse(JSON.stringify(e));return _.each(t,(function(e,t){if(void 0!==n[t]){let s=[];e instanceof Array&&_.each(e,(function(e){let t;_.isUndefined(o[e].connected_fields)&&(o[e].connected_fields=[]),t=Object.values(o[e].connected_fields),s=s.concat(t)})),n[t].connected_fields=Object.keys(s).map((function(e){return s[e]}))}})),_.clone(n)},D=(e,t,n,o)=>{const s=_.clone(e);if(!_.isUndefined(s[n])&&!_.isUndefined(s[t])){_.isUndefined(s[t].connected_fields)&&(s[t].connected_fields=[]),_.isUndefined(s[n].connected_fields)&&(s[n].connected_fields=[]);const e=Object.values(s[t].connected_fields),i=Object.values(s[n].connected_fields).concat(e),c=Math.round(o*i.length);let r=i.slice(0,c);const a=i.slice(c);r=Object.keys(r).map((function(e){return r[e]})),r=Object.keys(r).map((function(e){return r[e]})),s[n].connected_fields=r,s[t].connected_fields=a}return s},N=()=>{let n=JSON.parse(JSON.stringify(t.settingsClone));const i=e('[name*="sm_color_diversity"]'),c=e('[name*="sm_coloration_level"]'),r=!!i.length,a=void 0!==i.filter(":checked").data("default"),l=!r||a,d=!!c.length,u=void 0!==e('[name*="sm_coloration_level"]:checked').data("default"),f=!d||u,h=r?e('[name*="sm_color_diversity"]:checked').val():o("sm_color_diversity")();if(!l||!f){const t=e("#_customize-input-sm_dark_color_primary_slider_control").val()/100,o=e("#_customize-input-sm_dark_color_secondary_slider_control").val()/100,s=e("#_customize-input-sm_dark_color_tertiary_slider_control").val()/100;n=D(n,"sm_dark_primary","sm_color_primary",t),n=D(n,"sm_dark_secondary","sm_color_secondary",o),n=D(n,"sm_dark_tertiary","sm_color_tertiary",s);const i=v("color_diversity_low");n=z(n,i),"medium"===h&&(n=D(n,"sm_color_primary","sm_color_secondary",.5)),"high"===h&&(n=D(n,"sm_color_primary","sm_color_secondary",.67),n=D(n,"sm_color_secondary","sm_color_tertiary",.5))}const m=e('[name*="sm_shuffle_colors"]:checked').val();if("default"!==m){const e=v("shuffle_"+m);n=z(n,e)}if("on"===e('[name*="sm_dark_mode_control"]:checked').val()){const e=v("dark");n=z(n,e)}_.each(t.colorPalettes.masterSettingIds,(function(e){s[e]=n[e]}))},x=function(e){const t=[];return _.each(e,(function(e){t.push(u(e))})),t},J=function(e){const t={red:0,green:0,blue:0,alpha:0,hue:0,saturation:0,lightness:0,luma:0};for(let n=0;n<e.length;n++){const o=e[n];for(let e in t)t[e]+=o[e]}for(let n in t)t[n]/=e.length;return t},M=()=>{const n=e('[name*="sm_coloration_level"]:checked').val();if(void 0!==e('[name*="sm_coloration_level"]:checked').data("default")){const n=["sm_dark_color_primary_slider","sm_dark_color_secondary_slider","sm_dark_color_tertiary_slider"];_.each(n,(function(n){const s=t.config.settings[n];o(n).set(s.default),e("#_customize-input-"+n+"_control ").val(s.default)}))}else{const t=parseFloat(n);e("#_customize-input-sm_dark_color_primary_slider_control, #_customize-input-sm_dark_color_secondary_slider_control, #_customize-input-sm_dark_color_tertiary_slider_control").val(t)}E()},E=()=>{N(),p(),g(),O(),_.each(t.colorPalettes.masterSettingIds,(function(e){if(void 0!==o(e)){let t=s[e];const n=m(e);_.each(t.connected_fields,(function(e){if(_.isUndefined(e)||_.isUndefined(e.setting_id)||!_.isString(e.setting_id))return;const t=o(e.setting_id);_.isUndefined(t)||t.set(n)}));const i=o(e+"_final");_.isUndefined(i)||(_.isUndefined(t.connected_fields)||_.isEmpty(t.connected_fields)?i.set(""):i.set(n))}}))},A=t=>{const n=!!e(".c-color-palette .color.altered").length;let o=!0;return n&&(o=confirm("One or more fields connected to the color palette have been modified. By changing the palette variation you will lose changes to any color made prior to this action.")),!(n&&!o)&&("function"==typeof t&&t(),!0)},L=()=>{const n=e(".c-color-palette__control"),s=(()=>{const e=o("sm_color_palette_variation");if(_.isUndefined(e))return"light";const n=e();return t.colorPalettes.variations.hasOwnProperty(n)?n:"light"})();n.removeClass("active"),n.filter(".variation-"+s).addClass("active"),e(document).on("click",".js-color-palette input",(function(e){A(w.bind(this))||e.preventDefault()})),e('[for*="sm_palette_filter"], [for*="sm_coloration_level"], [for*="sm_color_diversity"], [for*="sm_shuffle_colors"], [for*="sm_dark_mode"]').on("click",(function(e){A()||e.preventDefault()})),e('[name*="sm_coloration_level"]').on("change",M),e('[name*="sm_color_diversity"]').on("change",E),e('[name*="sm_shuffle_colors"]').on("change",E),e('[name*="sm_dark_mode"]').on("change",E),e('[name*="sm_palette_filter"]').on("change",()=>{h(),E()})},B=_.debounce(()=>{e(".sm-palette-filter").each((function(){e(this).find("input").each((function(t,n){const s=e(n),i=s.next("label"),c=s.val();i.find(".sm-color-palette__color").each((function(t,n){const s=e(n),i=s.data("setting"),r=o(i)();s.css("color",C(r,c))}))}))}))},30);function Q(e,t){const n=o(e)(),s=o(t)();o(e).set(s),o(t).set(n)}return o.bind("ready",(function(){s=o.settings.settings,c||(_.each(t.colorPalettes.masterSettingIds,(function(e){i[e]=""})),void 0===t.settingsClone&&(t.settingsClone=e.extend(!0,{},s)),void 0===t.colorPalettes.connectedFieldsCallbacks&&(t.colorPalettes.connectedFieldsCallbacks={}),c=!0),(()=>{const t=e(".c-color-palette"),n=t.find(".c-color-palette__fields").find("input");if(!t.length)return;const s=t.find(".sm-color-palette__color");s.each((c,r)=>{const a=e(r),l=a.data("setting"),d=n.filter("."+l),_=o(l);if(a.data("target",d),a.hasClass("js-no-picker"))return;d.iris({change:(e,n)=>{const o=n.color.toString();a.css("color",C(o)),i[l]=C(o),_.set(o),"external"!==e.originalEvent.type&&t.find(".sm-color-palette__color."+l).removeClass("altered"),S()}}),a.find(".iris-picker").on("click",(function(e){e.stopPropagation(),e.preventDefault()}));const u=()=>{s.not(a).each((function(t,n){e(n).data("target").not(d).hide()})),d.show().focus()};a.on("click",e=>{e.stopPropagation(),e.preventDefault(),d.is(":visible")?(d.iris("hide"),d.hide(),s.removeClass("active inactive")):a.is(".altered")?A(u):u()}),d.on("click",e=>{e.stopPropagation(),e.preventDefault()}),d.on("focus",n=>{s.not(a).addClass("inactive").removeClass("active"),a.addClass("active").removeClass("inactive"),s.not(a).each((function(t,n){e(n).data("target").iris("hide")}));const o=d.next(".iris-picker"),i=t.find(".c-color-palette__colors").outerWidth(),c=s.filter(":visible"),r=c.index(a);o.css("left",(i-200)*r/(c.length-1)),U(),d.iris("show")}),d.on("focusout",e=>{P()})}),e("body").on("click",(function(){s.removeClass("active inactive"),s.each((function(t,n){const o=e(n).data("target");e(n).hasClass("js-no-picker")||o.iris("hide"),o.hide()}))}))})(),N(),h(),p(),g(),O(),B(),function(){const t=e(document);t.on("click",'[data-action="sm_swap_colors"]',(function(e){e.preventDefault(),Q("sm_color_primary","sm_color_secondary")})),t.on("click",'[data-action="sm_swap_dark_light"]',(function(e){e.preventDefault(),Q("sm_dark_primary","sm_light_primary"),Q("sm_dark_secondary","sm_light_secondary"),Q("sm_dark_tertiary","sm_light_tertiary")})),t.on("click",'[data-action="sm_swap_colors_dark"]',(function(e){e.preventDefault(),Q("sm_color_primary","sm_dark_primary"),Q("sm_color_secondary","sm_dark_secondary"),Q("sm_color_tertiary","sm_dark_tertiary")})),t.on("click",'[data-action="sm_swap_secondary_colors_dark"]',(function(e){e.preventDefault(),Q("sm_color_secondary","sm_dark_secondary")}))}(),L()})),{}}())}(jQuery,customify,wp);
js/customizer/font-palettes.js CHANGED
@@ -34,7 +34,7 @@ window.customify = window.customify || parent.customify || {};
34
  /*
35
  * Create the value of the font field and set in the setting.
36
  */
37
- if (_.isUndefined(connectedFieldData) || _.isUndefined(connectedFieldData.setting_id) || !_.isString(connectedFieldData.setting_id) || _.isUndefined(parentSettingData.fonts_logic)) {
38
  return
39
  }
40
 
@@ -44,10 +44,13 @@ window.customify = window.customify || parent.customify || {};
44
  }
45
 
46
  /* ======================
47
- * Process the font logic for the master (parent) font control to get the value that should be applied to the connected (font) fields.
 
 
48
  */
49
  const newFontData = {}
50
- const fontsLogic = parentSettingData.fonts_logic
 
51
 
52
  if (typeof fontsLogic.reset !== 'undefined') {
53
  const settingID = connectedFieldData.setting_id
@@ -69,7 +72,7 @@ window.customify = window.customify || parent.customify || {};
69
 
70
  // The font family is straight forward as it comes directly from the parent field font logic configuration.
71
  if (typeof fontsLogic.font_family !== 'undefined') {
72
- newFontData['font_family'] = newValue.font_family
73
  }
74
 
75
  if (_.isEmpty(newFontData['font_family'])) {
@@ -185,6 +188,9 @@ window.customify = window.customify || parent.customify || {};
185
  }
186
 
187
  const onPaletteChange = function () {
 
 
 
188
  // Take the fonts config for each setting and distribute it to each (master) setting.
189
  const data = $(this).data('fonts_logic')
190
 
@@ -199,8 +205,6 @@ window.customify = window.customify || parent.customify || {};
199
  }
200
 
201
  const setFieldFontsLogicConfig = function (settingID, config) {
202
- apiSettings[settingID].fonts_logic = config
203
-
204
  // We also need to trigger a fake setting value change since the master font controls don't usually hold a (usable) value.
205
  const setting = api(settingID)
206
  if (_.isUndefined(setting)) {
@@ -223,6 +227,7 @@ window.customify = window.customify || parent.customify || {};
223
 
224
  // Handle the palette change logic.
225
  $('.js-font-palette input[name="sm_font_palette"]').on('change', onPaletteChange)
 
226
  // Handle the case where one clicks on the already selected palette - force a reset.
227
  $('.js-font-palette .customize-inside-control-row').on('click', function(event) {
228
  // Find the input
@@ -256,6 +261,21 @@ window.customify = window.customify || parent.customify || {};
256
  input.trigger('customify:preset-change')
257
  }
258
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
 
261
  /**
34
  /*
35
  * Create the value of the font field and set in the setting.
36
  */
37
+ if (_.isUndefined(connectedFieldData) || _.isUndefined(connectedFieldData.setting_id) || !_.isString(connectedFieldData.setting_id)) {
38
  return
39
  }
40
 
44
  }
45
 
46
  /* ======================
47
+ * Process the font logic to get the value that should be applied to the connected (font) fields.
48
+ *
49
+ * The font logic is already in the new value - @see setFieldFontsLogicConfig()
50
  */
51
  const newFontData = {}
52
+
53
+ const fontsLogic = newValue
54
 
55
  if (typeof fontsLogic.reset !== 'undefined') {
56
  const settingID = connectedFieldData.setting_id
72
 
73
  // The font family is straight forward as it comes directly from the parent field font logic configuration.
74
  if (typeof fontsLogic.font_family !== 'undefined') {
75
+ newFontData['font_family'] = fontsLogic.font_family
76
  }
77
 
78
  if (_.isEmpty(newFontData['font_family'])) {
188
  }
189
 
190
  const onPaletteChange = function () {
191
+ // Make sure that the advanced tab is visible.
192
+ showAdvancedFontPaletteControls();
193
+
194
  // Take the fonts config for each setting and distribute it to each (master) setting.
195
  const data = $(this).data('fonts_logic')
196
 
205
  }
206
 
207
  const setFieldFontsLogicConfig = function (settingID, config) {
 
 
208
  // We also need to trigger a fake setting value change since the master font controls don't usually hold a (usable) value.
209
  const setting = api(settingID)
210
  if (_.isUndefined(setting)) {
227
 
228
  // Handle the palette change logic.
229
  $('.js-font-palette input[name="sm_font_palette"]').on('change', onPaletteChange)
230
+
231
  // Handle the case where one clicks on the already selected palette - force a reset.
232
  $('.js-font-palette .customize-inside-control-row').on('click', function(event) {
233
  // Find the input
261
  input.trigger('customify:preset-change')
262
  }
263
  })
264
+
265
+ // Handle the case when there is no selected font palette (like on a fresh installation without any demo data import).
266
+ // In this case we want to hide the advanced tab.
267
+ const currentFontPaletteSetting = api('sm_font_palette');
268
+ if (typeof currentFontPaletteSetting === 'function' && '' === currentFontPaletteSetting()) {
269
+ hideAdvancedFontPaletteControls();
270
+ }
271
+ }
272
+
273
+ const hideAdvancedFontPaletteControls = () => {
274
+ $('#sub-accordion-section-sm_font_palettes_section .sm-tabs__item[data-target="advanced"]').css('visibility', 'hidden');
275
+ }
276
+
277
+ const showAdvancedFontPaletteControls = () => {
278
+ $('#sub-accordion-section-sm_font_palettes_section .sm-tabs__item[data-target="advanced"]').css('visibility', 'visible');
279
  }
280
 
281
  /**
js/customizer/font-palettes.min.js CHANGED
@@ -1 +1 @@
1
- window.customify=window.customify||parent.customify||{},function(t,e,n,i){void 0===e.fontPalettes&&(e.fontPalettes={}),_.extend(e.fontPalettes,function(){const i=n.customize;let s;const o=function(){_.each(e.fontPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const n=s[t],o=i(t);void 0!==n.connected_fields&&(e.fontPalettes.connectedFieldsCallbacks[t]=function(t,n){return function(n,s){_.each(t.connected_fields,(function(s){if(_.isUndefined(s)||_.isUndefined(s.setting_id)||!_.isString(s.setting_id)||_.isUndefined(t.fonts_logic))return;const o=i(s.setting_id);if(_.isUndefined(o))return;const l={},f=t.fonts_logic;if(void 0!==f.reset){const t=s.setting_id,n=e.config.settings[t].default;_.isUndefined(o)||_.isEmpty(n)||(l.font_family=n.font_family,l.font_size=n.font_size,l.line_height=n.line_height,l.letter_spacing=n.letter_spacing,l.text_transform=n.text_transform,l.font_variant=n.font_variant)}if(void 0!==f.font_family&&(l.font_family=n.font_family),!_.isEmpty(l.font_family)){if(void 0!==s.font_size&&!1!==s.font_size){if(l.font_size=e.fontFields.standardizeNumericalValue(s.font_size),!isNaN(l.font_size.value)){let t=1;void 0!==f.font_size_multiplier&&(t=parseFloat(f.font_size_multiplier),t<=0&&(t=1)),l.font_size.value=c(parseFloat(l.font_size.value)*t,e.fonts.floatPrecision)}if(void 0!==f.font_styles_intervals&&_.isArray(f.font_styles_intervals)&&f.font_styles_intervals.length>0){let t=0;for(;t<f.font_styles_intervals.length-1&&void 0!==f.font_styles_intervals[t].end&&f.font_styles_intervals[t].end<=s.font_size.value;)t++;if(_.isEmpty(f.font_styles_intervals[t].font_variant)||(l.font_variant=f.font_styles_intervals[t].font_variant),_.isEmpty(f.font_styles_intervals[t].letter_spacing)||(l.letter_spacing=e.fontFields.standardizeNumericalValue(f.font_styles_intervals[t].letter_spacing)),_.isEmpty(f.font_styles_intervals[t].text_transform)||(l.text_transform=f.font_styles_intervals[t].text_transform),!isNaN(l.font_size.value)){let n=1;void 0!==f.font_styles_intervals[t].font_size_multiplier&&(n=parseFloat(f.font_styles_intervals[t].font_size_multiplier),n<=0&&(n=1)),l.font_size.value=c(parseFloat(l.font_size.value)*n,e.fonts.floatPrecision)}}if(void 0!==f.font_size_to_line_height_points&&_.isArray(f.font_size_to_line_height_points)){const t=regression.logarithmic(f.font_size_to_line_height_points,{precision:e.fonts.floatPrecision}).predict(l.font_size.value)[1];l.line_height=e.fontFields.standardizeNumericalValue(t)}}o.set(l)}}))}}(n),o.bind(e.fontPalettes.connectedFieldsCallbacks[t]))}}))},l=()=>{_.each(e.fontPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const n=s[t],o=i(t);void 0!==n.connected_fields&&void 0!==e.fontPalettes.connectedFieldsCallbacks[t]&&o.unbind(e.fontPalettes.connectedFieldsCallbacks[t]),delete e.fontPalettes.connectedFieldsCallbacks[t]}})),o()},f=function(){const e=t(this).data("fonts_logic");_.isUndefined(e)||t.each(e,(function(t,e){a(t,e)})),t(this).trigger("customify:preset-change")},a=function(t,e){s[t].fonts_logic=e;const n=i(t);_.isUndefined(n)||n.set(e)},c=function(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n};return i.bind("ready",()=>{s=i.settings.settings,void 0===e.settingsClone&&(e.settingsClone=t.extend(!0,{},s)),void 0===e.fontPalettes.connectedFieldsCallbacks&&(e.fontPalettes.connectedFieldsCallbacks={}),l(),t('.js-font-palette input[name="sm_font_palette"]').on("change",f),t(".js-font-palette .customize-inside-control-row").on("click",(function(e){let n=t(e.target).siblings("input");if(n.length||(n=t(e.target).children("input")),n.length&&n.prop("checked")){const e=n.data("fonts_logic");_.isUndefined(e)||t.each(e,(function(t,e){const n=i(t);_.isUndefined(n)||(n.set({}),a(t,e))})),n.trigger("customify:preset-change")}}))}),{}}())}(jQuery,customify,wp,document);
1
+ window.customify=window.customify||parent.customify||{},function(t,e,n,i){void 0===e.fontPalettes&&(e.fontPalettes={}),_.extend(e.fontPalettes,function(){const i=n.customize;let s;const o=function(){_.each(e.fontPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const n=s[t],o=i(t);void 0!==n.connected_fields&&(e.fontPalettes.connectedFieldsCallbacks[t]=function(t,n){return function(n,s){_.each(t.connected_fields,(function(t){if(_.isUndefined(t)||_.isUndefined(t.setting_id)||!_.isString(t.setting_id))return;const s=i(t.setting_id);if(_.isUndefined(s))return;const o={},a=n;if(void 0!==a.reset){const n=t.setting_id,i=e.config.settings[n].default;_.isUndefined(s)||_.isEmpty(i)||(o.font_family=i.font_family,o.font_size=i.font_size,o.line_height=i.line_height,o.letter_spacing=i.letter_spacing,o.text_transform=i.text_transform,o.font_variant=i.font_variant)}if(void 0!==a.font_family&&(o.font_family=a.font_family),!_.isEmpty(o.font_family)){if(void 0!==t.font_size&&!1!==t.font_size){if(o.font_size=e.fontFields.standardizeNumericalValue(t.font_size),!isNaN(o.font_size.value)){let t=1;void 0!==a.font_size_multiplier&&(t=parseFloat(a.font_size_multiplier),t<=0&&(t=1)),o.font_size.value=r(parseFloat(o.font_size.value)*t,e.fonts.floatPrecision)}if(void 0!==a.font_styles_intervals&&_.isArray(a.font_styles_intervals)&&a.font_styles_intervals.length>0){let n=0;for(;n<a.font_styles_intervals.length-1&&void 0!==a.font_styles_intervals[n].end&&a.font_styles_intervals[n].end<=t.font_size.value;)n++;if(_.isEmpty(a.font_styles_intervals[n].font_variant)||(o.font_variant=a.font_styles_intervals[n].font_variant),_.isEmpty(a.font_styles_intervals[n].letter_spacing)||(o.letter_spacing=e.fontFields.standardizeNumericalValue(a.font_styles_intervals[n].letter_spacing)),_.isEmpty(a.font_styles_intervals[n].text_transform)||(o.text_transform=a.font_styles_intervals[n].text_transform),!isNaN(o.font_size.value)){let t=1;void 0!==a.font_styles_intervals[n].font_size_multiplier&&(t=parseFloat(a.font_styles_intervals[n].font_size_multiplier),t<=0&&(t=1)),o.font_size.value=r(parseFloat(o.font_size.value)*t,e.fonts.floatPrecision)}}if(void 0!==a.font_size_to_line_height_points&&_.isArray(a.font_size_to_line_height_points)){const t=regression.logarithmic(a.font_size_to_line_height_points,{precision:e.fonts.floatPrecision}).predict(o.font_size.value)[1];o.line_height=e.fontFields.standardizeNumericalValue(t)}}s.set(o)}}))}}(n),o.bind(e.fontPalettes.connectedFieldsCallbacks[t]))}}))},a=()=>{_.each(e.fontPalettes.masterSettingIds,(function(t){if(void 0!==s[t]){const n=s[t],o=i(t);void 0!==n.connected_fields&&void 0!==e.fontPalettes.connectedFieldsCallbacks[t]&&o.unbind(e.fontPalettes.connectedFieldsCallbacks[t]),delete e.fontPalettes.connectedFieldsCallbacks[t]}})),o()},l=function(){d();const e=t(this).data("fonts_logic");_.isUndefined(e)||t.each(e,(function(t,e){f(t,e)})),t(this).trigger("customify:preset-change")},f=function(t,e){const n=i(t);_.isUndefined(n)||n.set(e)},c=()=>{t('#sub-accordion-section-sm_font_palettes_section .sm-tabs__item[data-target="advanced"]').css("visibility","hidden")},d=()=>{t('#sub-accordion-section-sm_font_palettes_section .sm-tabs__item[data-target="advanced"]').css("visibility","visible")},r=function(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n};return i.bind("ready",()=>{s=i.settings.settings,void 0===e.settingsClone&&(e.settingsClone=t.extend(!0,{},s)),void 0===e.fontPalettes.connectedFieldsCallbacks&&(e.fontPalettes.connectedFieldsCallbacks={}),a(),t('.js-font-palette input[name="sm_font_palette"]').on("change",l),t(".js-font-palette .customize-inside-control-row").on("click",(function(e){let n=t(e.target).siblings("input");if(n.length||(n=t(e.target).children("input")),n.length&&n.prop("checked")){const e=n.data("fonts_logic");_.isUndefined(e)||t.each(e,(function(t,e){const n=i(t);_.isUndefined(n)||(n.set({}),f(t,e))})),n.trigger("customify:preset-change")}}));const n=i("sm_font_palette");"function"==typeof n&&""===n()&&c()}),{}}())}(jQuery,customify,wp,document);
js/customizer/style-manager.js CHANGED
@@ -17,6 +17,8 @@ window.customify = window.customify || parent.customify || {};
17
 
18
  api.bind('ready', function () {
19
 
 
 
20
  // Handle the Style Manager user feedback logic.
21
  const $userFeedbackModal = $('#style-manager-user-feedback-modal')
22
  if ($userFeedbackModal.length) {
@@ -131,6 +133,36 @@ window.customify = window.customify || parent.customify || {};
131
  }
132
  })
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  // Reverses a hex color to either black or white
135
  const inverseHexColorToBlackOrWhite = function (hex) {
136
  return inverseHexColor(hex, true)
17
 
18
  api.bind('ready', function () {
19
 
20
+ initializeStyleManagerTabs();
21
+
22
  // Handle the Style Manager user feedback logic.
23
  const $userFeedbackModal = $('#style-manager-user-feedback-modal')
24
  if ($userFeedbackModal.length) {
133
  }
134
  })
135
 
136
+ const initializeStyleManagerTabs = function() {
137
+ $( '.sm-tabs' ).each( function( i, obj ) {
138
+ const $wrapper = $( obj );
139
+ const $section = $wrapper.closest( '.control-section' );
140
+ const $tabs = $wrapper.children( '.sm-tabs__item' );
141
+ const targets = $tabs.map( ( i, el ) => {
142
+ const target = $( el ).data( 'target' );
143
+ return `sm-view-${ target }`
144
+ } );
145
+
146
+ const targetClassnames = targets.toArray().join( " " );
147
+
148
+ function setActiveTab( $active ) {
149
+ const target = $active.data( 'target' );
150
+
151
+ $tabs.removeClass( 'sm-tabs__item--active' );
152
+ $active.addClass( 'sm-tabs__item--active' );
153
+
154
+ $section.removeClass( targetClassnames ).addClass( `sm-view-${ target }` );
155
+ }
156
+
157
+ $wrapper.on( 'click', '.sm-tabs__item', function(e) {
158
+ e.preventDefault();
159
+ setActiveTab( $( this ) );
160
+ } );
161
+
162
+ setActiveTab( $tabs.first() );
163
+ } );
164
+ }
165
+
166
  // Reverses a hex color to either black or white
167
  const inverseHexColorToBlackOrWhite = function (hex) {
168
  return inverseHexColor(hex, true)
js/customizer/style-manager.min.js CHANGED
@@ -1 +1 @@
1
- window.customify=window.customify||parent.customify||{},function(e,n,t,i){void 0===customify.styleManager&&(customify.styleManager={}),_.extend(customify.styleManager,function(){const n=t.customize;n.bind("ready",(function(){const t=e("#style-manager-user-feedback-modal");if(t.length){const i=t.find("form"),o=t.find(".close"),s=t.find(".first-step"),a=t.find(".second-step"),c=t.find(".thanks-step"),d=t.find(".error-step");let r=!1,f=!1,u=!1;n.bind("saved",(function(){r||!f&&!u||(e("body").addClass("feedback-modal-open modal-open"),r=!0)}));const l=n("sm_color_palette");_.isUndefined(l)||l.bind((function(e,n){e!=n&&(f=!0)}));const m=n("sm_color_palette_variation");_.isUndefined(m)||m.bind((function(e,n){e!=n&&(f=!0)}));const p=n("sm_font_palette");_.isUndefined(p)||p.bind((function(e,n){e!=n&&(u=!0)})),i.on("submit",(function(n){n.preventDefault();let t=e(n.target),i={action:"customify_style_manager_user_feedback",nonce:customify.styleManager.userFeedback.nonce,type:t.find("input[name=type]").val(),rating:t.find("input[name=rating]:checked").val(),message:t.find("textarea[name=message]").val()};e.post(customify.config.ajax_url,i,(function(e){!0===e.success?(s.hide(),a.hide(),c.show(),d.hide()):(s.hide(),a.hide(),c.hide(),d.show())}))})),i.find("input[name=rating]").on("change",(function(e){setTimeout((function(){a.show()}),300);let n=i.find("input[name=rating]:checked").val();i.find(".rating-placeholder").text(n)})),o.on("click",(function(n){n.preventDefault(),e("body").removeClass("feedback-modal-open modal-open"),setTimeout((function(){s.show(),a.hide(),c.hide(),d.hide()}),300)}))}}));const i=function(e,n){if(0===e.indexOf("#")&&(e=e.slice(1)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)throw new Error("Invalid HEX color.");let t=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16);return n?.299*t+.587*i+.114*s>186?"#000000":"#FFFFFF":(t=(255-t).toString(16),i=(255-i).toString(16),s=(255-s).toString(16),"#"+o(t)+o(i)+o(s))},o=function(e,n){n=n||2;return(new Array(n).join("0")+e).slice(-n)};return{inverseHexColor:i,inverseHexColorToBlackOrWhite:function(e){return i(e,!0)},padZero:o}}())}(jQuery,window.customify,wp,document);
1
+ window.customify=window.customify||parent.customify||{},function(e,n,t,i){void 0===customify.styleManager&&(customify.styleManager={}),_.extend(customify.styleManager,function(){const n=t.customize;n.bind("ready",(function(){i();const t=e("#style-manager-user-feedback-modal");if(t.length){const i=t.find("form"),o=t.find(".close"),s=t.find(".first-step"),a=t.find(".second-step"),c=t.find(".thanks-step"),r=t.find(".error-step");let d=!1,f=!1,l=!1;n.bind("saved",(function(){d||!f&&!l||(e("body").addClass("feedback-modal-open modal-open"),d=!0)}));const u=n("sm_color_palette");_.isUndefined(u)||u.bind((function(e,n){e!=n&&(f=!0)}));const m=n("sm_color_palette_variation");_.isUndefined(m)||m.bind((function(e,n){e!=n&&(f=!0)}));const p=n("sm_font_palette");_.isUndefined(p)||p.bind((function(e,n){e!=n&&(l=!0)})),i.on("submit",(function(n){n.preventDefault();let t=e(n.target),i={action:"customify_style_manager_user_feedback",nonce:customify.styleManager.userFeedback.nonce,type:t.find("input[name=type]").val(),rating:t.find("input[name=rating]:checked").val(),message:t.find("textarea[name=message]").val()};e.post(customify.config.ajax_url,i,(function(e){!0===e.success?(s.hide(),a.hide(),c.show(),r.hide()):(s.hide(),a.hide(),c.hide(),r.show())}))})),i.find("input[name=rating]").on("change",(function(e){setTimeout((function(){a.show()}),300);let n=i.find("input[name=rating]:checked").val();i.find(".rating-placeholder").text(n)})),o.on("click",(function(n){n.preventDefault(),e("body").removeClass("feedback-modal-open modal-open"),setTimeout((function(){s.show(),a.hide(),c.hide(),r.hide()}),300)}))}}));const i=function(){e(".sm-tabs").each((function(n,t){const i=e(t),o=i.closest(".control-section"),s=i.children(".sm-tabs__item"),a=s.map((n,t)=>"sm-view-"+e(t).data("target")).toArray().join(" ");function c(e){const n=e.data("target");s.removeClass("sm-tabs__item--active"),e.addClass("sm-tabs__item--active"),o.removeClass(a).addClass("sm-view-"+n)}i.on("click",".sm-tabs__item",(function(n){n.preventDefault(),c(e(this))})),c(s.first())}))},o=function(e,n){if(0===e.indexOf("#")&&(e=e.slice(1)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)throw new Error("Invalid HEX color.");let t=parseInt(e.slice(0,2),16),i=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return n?.299*t+.587*i+.114*o>186?"#000000":"#FFFFFF":(t=(255-t).toString(16),i=(255-i).toString(16),o=(255-o).toString(16),"#"+s(t)+s(i)+s(o))},s=function(e,n){n=n||2;return(new Array(n).join("0")+e).slice(-n)};return{inverseHexColor:o,inverseHexColorToBlackOrWhite:function(e){return o(e,!0)},padZero:s}}())}(jQuery,window.customify,wp,document);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: pixelgrade, vlad.olaru, babbardel, razvanonofrei, gorby31
3
  Tags: design, customizer, fonts, colors, gutenberg, font palettes, color palettes
4
  Requires at least: 4.9.14
5
  Tested up to: 5.5.3
6
- Stable tag: 2.10.1
7
  Requires PHP: 5.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -30,6 +30,9 @@ This plugin is **primarily intended** to be used together with [Pixelgrade theme
30
 
31
  == Changelog ==
32
 
 
 
 
33
  = 2.10.1 =
34
  * Fix live preview for the advanced Dark Mode control introduced in 2.10.0
35
 
3
  Tags: design, customizer, fonts, colors, gutenberg, font palettes, color palettes
4
  Requires at least: 4.9.14
5
  Tested up to: 5.5.3
6
+ Stable tag: 2.10.2
7
  Requires PHP: 5.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
30
 
31
  == Changelog ==
32
 
33
+ = 2.10.2 =
34
+ * Improve Font Palettes behavior for a fresh installation (no Font Palette selected).
35
+
36
  = 2.10.1 =
37
  * Fix live preview for the advanced Dark Mode control introduced in 2.10.0
38