customizer-preview.js 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874
  1. /**
  2. * This file adds some LIVE to the Theme Customizer live preview. To leverage
  3. * this, set your custom settings to 'postMessage' and then add your handling
  4. * here. Your javascript should grab settings from customizer controls, and
  5. * then make any necessary changes to the page using jQuery.
  6. *
  7. * @package Astra
  8. */
  9. /**
  10. * Generate font size in PX & REM
  11. */
  12. function astra_font_size_rem( size, with_rem, device ) {
  13. var css = '';
  14. if( size != '' ) {
  15. var device = ( typeof device != undefined ) ? device : 'desktop';
  16. // font size with 'px'.
  17. css = 'font-size: ' + size + 'px;';
  18. // font size with 'rem'.
  19. if ( with_rem ) {
  20. var body_font_size = wp.customize( 'astra-settings[font-size-body]' ).get();
  21. body_font_size['desktop'] = ( body_font_size['desktop'] != '' ) ? body_font_size['desktop'] : 15;
  22. body_font_size['tablet'] = ( body_font_size['tablet'] != '' ) ? body_font_size['tablet'] : body_font_size['desktop'];
  23. body_font_size['mobile'] = ( body_font_size['mobile'] != '' ) ? body_font_size['mobile'] : body_font_size['tablet'];
  24. css += 'font-size: ' + ( size / body_font_size[device] ) + 'rem;';
  25. }
  26. }
  27. return css;
  28. }
  29. /**
  30. * Apply CSS for the element
  31. */
  32. function astra_color_responsive_css( addon, control, css_property, selector ) {
  33. wp.customize( control, function( value ) {
  34. value.bind( function( value ) {
  35. if ( value.desktop || value.mobile || value.tablet ) {
  36. // Remove <style> first!
  37. control = control.replace( '[', '-' );
  38. control = control.replace( ']', '' );
  39. jQuery( 'style#' + control + '-' + addon ).remove();
  40. var DeskVal = '',
  41. TabletFontVal = '',
  42. MobileVal = '';
  43. if ( '' != value.desktop ) {
  44. DeskVal = css_property + ': ' + value.desktop;
  45. }
  46. if ( '' != value.tablet ) {
  47. TabletFontVal = css_property + ': ' + value.tablet;
  48. }
  49. if ( '' != value.mobile ) {
  50. MobileVal = css_property + ': ' + value.mobile;
  51. }
  52. // Concat and append new <style>.
  53. jQuery( 'head' ).append(
  54. '<style id="' + control + '-' + addon + '">'
  55. + selector + ' { ' + DeskVal + ' }'
  56. + '@media (max-width: 768px) {' + selector + ' { ' + TabletFontVal + ' } }'
  57. + '@media (max-width: 544px) {' + selector + ' { ' + MobileVal + ' } }'
  58. + '</style>'
  59. );
  60. } else {
  61. jQuery( 'style#' + control + '-' + addon ).remove();
  62. }
  63. } );
  64. } );
  65. }
  66. /**
  67. * Responsive Font Size CSS
  68. */
  69. function astra_responsive_font_size( control, selector ) {
  70. wp.customize( control, function( value ) {
  71. value.bind( function( value ) {
  72. if ( value.desktop || value.mobile || value.tablet ) {
  73. // Remove <style> first!
  74. control = control.replace( '[', '-' );
  75. control = control.replace( ']', '' );
  76. var fontSize = '',
  77. tabletFontSize = '',
  78. mobileFontSize = '',
  79. css_property = 'font-size';
  80. jQuery( 'style#' + control + '-' + css_property ).remove();
  81. if ( '' != value.desktop ) {
  82. fontSize = 'font-size: ' + value.desktop + value['desktop-unit'];
  83. }
  84. if ( '' != value.tablet ) {
  85. tabletFontSize = 'font-size: ' + value.tablet + value['tablet-unit'];
  86. }
  87. if ( '' != value.mobile ) {
  88. mobileFontSize = 'font-size: ' + value.mobile + value['mobile-unit'];
  89. }
  90. if( value['desktop-unit'] == 'px' ) {
  91. fontSize = astra_font_size_rem( value.desktop, true, 'desktop' );
  92. }
  93. // Concat and append new <style>.
  94. jQuery( 'head' ).append(
  95. '<style id="' + control + '-' + css_property + '">'
  96. + selector + ' { ' + fontSize + ' }'
  97. + '@media (max-width: 768px) {' + selector + ' { ' + tabletFontSize + ' } }'
  98. + '@media (max-width: 544px) {' + selector + ' { ' + mobileFontSize + ' } }'
  99. + '</style>'
  100. );
  101. } else {
  102. jQuery( 'style#' + control + '-font-size' ).remove();
  103. }
  104. } );
  105. } );
  106. }
  107. /**
  108. * Responsive Spacing CSS
  109. */
  110. function astra_responsive_spacing( control, selector, type, side ) {
  111. wp.customize( control, function( value ) {
  112. value.bind( function( value ) {
  113. var sidesString = "";
  114. var spacingType = "padding";
  115. if ( value.desktop.top || value.desktop.right || value.desktop.bottom || value.desktop.left || value.tablet.top || value.tablet.right || value.tablet.bottom || value.tablet.left || value.mobile.top || value.mobile.right || value.mobile.bottom || value.mobile.left ) {
  116. if ( typeof side != undefined ) {
  117. sidesString = side + "";
  118. // Replace comma character with dash, necessary to separate out spacing dimensions.
  119. sidesString = sidesString.replace(/,/g , "-");
  120. }
  121. if ( typeof type != undefined ) {
  122. spacingType = type + "";
  123. }
  124. // Remove <style> first!
  125. control = control.replace( '[', '-' );
  126. control = control.replace( ']', '' );
  127. jQuery( 'style#' + control + '-' + spacingType + '-' + sidesString ).remove();
  128. var desktopPadding = '',
  129. tabletPadding = '',
  130. mobilePadding = '';
  131. var paddingSide = ( typeof side != undefined ) ? side : [ 'top','bottom','right','left' ];
  132. jQuery.each(paddingSide, function( index, sideValue ){
  133. if ( '' != value['desktop'][sideValue] ) {
  134. desktopPadding += spacingType + '-' + sideValue +': ' + value['desktop'][sideValue] + value['desktop-unit'] +';';
  135. }
  136. });
  137. jQuery.each(paddingSide, function( index, sideValue ){
  138. if ( '' != value['tablet'][sideValue] ) {
  139. tabletPadding += spacingType + '-' + sideValue +': ' + value['tablet'][sideValue] + value['tablet-unit'] +';';
  140. }
  141. });
  142. jQuery.each(paddingSide, function( index, sideValue ){
  143. if ( '' != value['mobile'][sideValue] ) {
  144. mobilePadding += spacingType + '-' + sideValue +': ' + value['mobile'][sideValue] + value['mobile-unit'] +';';
  145. }
  146. });
  147. // Concat and append new <style>.
  148. jQuery( 'head' ).append(
  149. '<style id="' + control + '-' + spacingType + '-' + sidesString + '">'
  150. + selector + ' { ' + desktopPadding +' }'
  151. + '@media (max-width: 768px) {' + selector + ' { ' + tabletPadding + ' } }'
  152. + '@media (max-width: 544px) {' + selector + ' { ' + mobilePadding + ' } }'
  153. + '</style>'
  154. );
  155. } else {
  156. wp.customize.preview.send( 'refresh' );
  157. jQuery( 'style#' + control + '-' + spacingType + '-' + sidesString ).remove();
  158. }
  159. } );
  160. } );
  161. }
  162. /**
  163. * CSS
  164. */
  165. function astra_css_font_size( control, selector ) {
  166. wp.customize( control, function( value ) {
  167. value.bind( function( size ) {
  168. if ( size ) {
  169. // Remove <style> first!
  170. control = control.replace( '[', '-' );
  171. control = control.replace( ']', '' );
  172. jQuery( 'style#' + control ).remove();
  173. var fontSize = 'font-size: ' + size;
  174. if ( ! isNaN( size ) || size.indexOf( 'px' ) >= 0 ) {
  175. size = size.replace( 'px', '' );
  176. fontSize = astra_font_size_rem( size, true );
  177. }
  178. // Concat and append new <style>.
  179. jQuery( 'head' ).append(
  180. '<style id="' + control + '">'
  181. + selector + ' { ' + fontSize + ' }'
  182. + '</style>'
  183. );
  184. } else {
  185. jQuery( 'style#' + control ).remove();
  186. }
  187. } );
  188. } );
  189. }
  190. /**
  191. * Return get_hexdec()
  192. */
  193. function get_hexdec( hex ) {
  194. var hexString = hex.toString( 16 );
  195. return parseInt( hexString, 16 );
  196. }
  197. /**
  198. * Apply CSS for the element
  199. */
  200. function astra_css( control, css_property, selector, unit ) {
  201. wp.customize( control, function( value ) {
  202. value.bind( function( new_value ) {
  203. // Remove <style> first!
  204. control = control.replace( '[', '-' );
  205. control = control.replace( ']', '' );
  206. if ( new_value || 0 === new_value ) {
  207. /**
  208. * If ( unit == 'url' ) then = url('{VALUE}')
  209. * If ( unit == 'px' ) then = {VALUE}px
  210. * If ( unit == 'em' ) then = {VALUE}em
  211. * If ( unit == 'rem' ) then = {VALUE}rem.
  212. */
  213. if ( 'undefined' != typeof unit) {
  214. if ( 'url' === unit ) {
  215. new_value = 'url(' + new_value + ')';
  216. } else {
  217. new_value = new_value + unit;
  218. }
  219. }
  220. // Remove old.
  221. jQuery( 'style#' + control + '-' + css_property ).remove();
  222. // Concat and append new <style>.
  223. jQuery( 'head' ).append(
  224. '<style id="' + control + '-' + css_property + '">'
  225. + selector + ' { ' + css_property + ': ' + new_value + ' }'
  226. + '</style>'
  227. );
  228. if( 'unset' === new_value ){
  229. jQuery( 'style#' + control + '-' + css_property ).remove();
  230. }
  231. } else {
  232. // Remove old.
  233. jQuery( 'style#' + control + '-' + css_property ).remove();
  234. }
  235. } );
  236. } );
  237. }
  238. /**
  239. * Dynamic Internal/Embedded Style for a Control
  240. */
  241. function astra_add_dynamic_css( control, style ) {
  242. control = control.replace( '[', '-' );
  243. control = control.replace( ']', '' );
  244. jQuery( 'style#' + control ).remove();
  245. jQuery( 'head' ).append(
  246. '<style id="' + control + '">' + style + '</style>'
  247. );
  248. }
  249. /**
  250. * Generate background_obj CSS
  251. */
  252. function astra_background_obj_css( wp_customize, bg_obj, ctrl_name, style ) {
  253. var gen_bg_css = '';
  254. var bg_img = bg_obj['background-image'];
  255. var bg_color = bg_obj['background-color'];
  256. if( '' === bg_color && '' === bg_img ) {
  257. jQuery( 'style#' + ctrl_name ).remove();
  258. }else{
  259. if( undefined !== bg_obj['background-type'] && '' !== bg_obj['background-type'] ) {
  260. if ( ( 'color' === bg_obj['background-type'] ) ) {
  261. if ( '' !== bg_img && '' !== bg_color && undefined !== bg_color && 'unset' !== bg_color ) {
  262. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');';
  263. } else if ( undefined === bg_img || '' === bg_img || 'unset' === bg_img ) {
  264. gen_bg_css = 'background-color: ' + bg_color + ';';
  265. }
  266. } else if ( 'image' === bg_obj['background-type'] ) {
  267. if ( '' !== bg_img && '' !== bg_color && undefined !== bg_color && 'unset' !== bg_color && ! bg_color.includes("linear-gradient") && ! bg_color.includes("radial-gradient") ) {
  268. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');';
  269. }
  270. if ( ( undefined === bg_color || '' === bg_color || 'unset' === bg_color || bg_color.includes("linear-gradient") || bg_color.includes("radial-gradient") ) && '' !== bg_img ) {
  271. gen_bg_css = 'background-image: url(' + bg_img + ');';
  272. }
  273. } else if ( 'gradient' === bg_obj['background-type'] ) {
  274. if ( '' !== bg_color && 'unset' !== bg_color ) {
  275. gen_bg_css = 'background-image: ' + bg_color + ';';
  276. }
  277. }
  278. }
  279. if ( '' !== bg_img ) {
  280. gen_bg_css += 'background-repeat: ' + bg_obj['background-repeat'] + ';';
  281. gen_bg_css += 'background-position: ' + bg_obj['background-position'] + ';';
  282. gen_bg_css += 'background-size: ' + bg_obj['background-size'] + ';';
  283. gen_bg_css += 'background-attachment: ' + bg_obj['background-attachment'] + ';';
  284. }
  285. var dynamicStyle = style.replace( "{{css}}", gen_bg_css );
  286. astra_add_dynamic_css( ctrl_name, dynamicStyle );
  287. }
  288. }
  289. /*
  290. * Generate Font Family CSS
  291. */
  292. function astra_generate_outside_font_family_css( control, selector ) {
  293. wp.customize( control, function (value) {
  294. value.bind( function ( value, oldValue ) {
  295. var cssProperty = 'font-family';
  296. var link = '';
  297. var fontName = value.split(",")[0];
  298. // Replace ' character with space, necessary to separate out font prop value.
  299. fontName = fontName.replace(/'/g, '');
  300. // Remove <style> first!
  301. control = control.replace( '[', '-' );
  302. control = control.replace( ']', '' );
  303. jQuery('style#' + control + '-' + cssProperty ).remove();
  304. if ( fontName in astraCustomizer.googleFonts ) {
  305. // Remove old.
  306. var fontName = fontName.split(' ').join('+');
  307. jQuery('link#' + control).remove();
  308. link = '<link id="' + control + '" href="https://fonts.googleapis.com/css?family=' + fontName + '" rel="stylesheet">';
  309. }
  310. // Concat and append new <style> and <link>.
  311. jQuery('head').append(
  312. '<style id="' + control + '-' + cssProperty + '">'
  313. + selector + ' { ' + cssProperty + ': ' + value + ' }'
  314. + '</style>'
  315. + link
  316. );
  317. });
  318. });
  319. }
  320. /*
  321. * Generate Font Weight CSS
  322. */
  323. function astra_generate_font_weight_css( font_control, control, css_property, selector ) {
  324. wp.customize( control, function( value ) {
  325. value.bind( function( new_value ) {
  326. control = control.replace( '[', '-' );
  327. control = control.replace( ']', '' );
  328. var link = '';
  329. if ( new_value ) {
  330. /**
  331. * If ( unit == 'url' ) then = url('{VALUE}')
  332. * If ( unit == 'px' ) then = {VALUE}px
  333. * If ( unit == 'em' ) then = {VALUE}em
  334. * If ( unit == 'rem' ) then = {VALUE}rem.
  335. */
  336. if ( 'undefined' != typeof unit) {
  337. if ( 'url' === unit ) {
  338. new_value = 'url(' + new_value + ')';
  339. } else {
  340. new_value = new_value + unit;
  341. }
  342. }
  343. var fontName = wp.customize._value[font_control]._value;
  344. fontName = fontName.split(',');
  345. fontName = fontName[0].replace( /'/g, '' );
  346. // Remove old.
  347. jQuery( 'style#' + control + '-' + css_property ).remove();
  348. if ( fontName in astraCustomizer.googleFonts ) {
  349. // Remove old.
  350. jQuery('#' + font_control).remove();
  351. if( new_value === "inherit" ) {
  352. link = '<link id="' + font_control + '" href="https://fonts.googleapis.com/css?family=' + fontName + '" rel="stylesheet">';
  353. } else {
  354. link = '<link id="' + font_control + '" href="https://fonts.googleapis.com/css?family=' + fontName + '%3A' + new_value + '" rel="stylesheet">';
  355. }
  356. }
  357. // Concat and append new <style>.
  358. jQuery( 'head' ).append(
  359. '<style id="' + control + '-' + css_property + '">'
  360. + selector + ' { ' + css_property + ': ' + new_value + ' }'
  361. + '</style>'
  362. + link
  363. );
  364. } else {
  365. // Remove old.
  366. jQuery( 'style#' + control ).remove();
  367. }
  368. } );
  369. });
  370. }
  371. /**
  372. * Apply CSS for the element
  373. */
  374. function astra_apply_responsive_background_css( control, selector, device, singleColorSelector, addon ) {
  375. wp.customize( control, function( value ) {
  376. value.bind( function( bg_obj ) {
  377. addon = addon || '';
  378. singleColorSelector = singleColorSelector || '';
  379. addon = ( addon ) ? addon : 'header';
  380. control = control.replace( '[', '-' );
  381. control = control.replace( ']', '' );
  382. if( '' === bg_obj[device] || undefined === bg_obj[device] ){
  383. return;
  384. }
  385. var gen_bg_css = '';
  386. var bg_img = bg_obj[device]['background-image'];
  387. var bg_tab_img = bg_obj['tablet']['background-image'];
  388. var bg_desk_img = bg_obj['desktop']['background-image'];
  389. var bg_color = bg_obj[device]['background-color'];
  390. var tablet_css = ( bg_obj['tablet']['background-image'] ) ? true : false;
  391. var desktop_css = ( bg_obj['desktop']['background-image'] ) ? true : false;
  392. if( undefined !== bg_obj[device]['background-type'] && '' !== bg_obj[device]['background-type'] ) {
  393. if ( ( 'color' === bg_obj[device]['background-type'] ) ) {
  394. if ( '' !== bg_img && '' !== bg_color && undefined !== bg_color && 'unset' !== bg_color ) {
  395. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');';
  396. } else if ( 'mobile' === device ) {
  397. if ( desktop_css ) {
  398. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_desk_img + ');';
  399. } else if ( tablet_css ) {
  400. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_tab_img + ');';
  401. } else {
  402. gen_bg_css = 'background-color: ' + bg_color + ';';
  403. gen_bg_css += 'background-image: none;';
  404. }
  405. } else if ( 'tablet' === device ) {
  406. if ( desktop_css ) {
  407. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_desk_img + ');';
  408. } else {
  409. gen_bg_css = 'background-color: ' + bg_color + ';';
  410. gen_bg_css += 'background-image: none;';
  411. }
  412. } else if ( undefined === bg_img || '' === bg_img ) {
  413. gen_bg_css = 'background-color: ' + bg_color + ';';
  414. gen_bg_css += 'background-image: none;';
  415. }
  416. } else if ( 'image' === bg_obj[device]['background-type'] ) {
  417. if ( '' !== bg_img && '' !== bg_color && undefined !== bg_color && 'unset' !== bg_color && ! bg_color.includes("linear-gradient") && ! bg_color.includes("radial-gradient") ) {
  418. gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');';
  419. }
  420. if ( ( undefined === bg_color || '' === bg_color || 'unset' === bg_color || bg_color.includes("linear-gradient") || bg_color.includes("radial-gradient") ) && '' !== bg_img ) {
  421. gen_bg_css = 'background-image: url(' + bg_img + ');';
  422. }
  423. } else if ( 'gradient' === bg_obj[device]['background-type'] ) {
  424. if ( '' !== bg_color && 'unset' !== bg_color ) {
  425. gen_bg_css = 'background-image: ' + bg_color + ';';
  426. }
  427. }
  428. }
  429. if ( '' !== bg_img ) {
  430. gen_bg_css += 'background-repeat: ' + bg_obj[device]['background-repeat'] + ';';
  431. gen_bg_css += 'background-position: ' + bg_obj[device]['background-position'] + ';';
  432. gen_bg_css += 'background-size: ' + bg_obj[device]['background-size'] + ';';
  433. gen_bg_css += 'background-attachment: ' + bg_obj[device]['background-attachment'] + ';';
  434. }
  435. // Remove old.
  436. jQuery( 'style#' + control + '-' + device + '-' + addon ).remove();
  437. if ( 'desktop' == device ) {
  438. var dynamicStyle = '<style id="' + control + '-' + device + '-' + addon + '">'
  439. + selector + ' { ' + gen_bg_css + ' }'
  440. + '</style>'
  441. }
  442. if ( 'tablet' == device ) {
  443. var dynamicStyle = '<style id="' + control + '-' + device + '-' + addon + '">'
  444. + '@media (max-width: 768px) {' + selector + ' { ' + gen_bg_css + ' } }'
  445. + '</style>'
  446. }
  447. if ( 'mobile' == device ) {
  448. var dynamicStyle = '<style id="' + control + '-' + device + '-' + addon + '">'
  449. + '@media (max-width: 544px) {' + selector + ' { ' + gen_bg_css + ' } }'
  450. + '</style>'
  451. }
  452. // Concat and append new <style>.
  453. jQuery( 'head' ).append(
  454. dynamicStyle
  455. );
  456. });
  457. });
  458. }
  459. function getChangedKey( value, other ) {
  460. value = isJsonString(value) ? JSON.parse(value) : value;
  461. other = isJsonString(other) ? JSON.parse(other) : other;
  462. // Compare two items
  463. var compare = function ( item1, item2 ) {
  464. // Get the object type
  465. var itemType = Object.prototype.toString.call(item1);
  466. // If an object or array, compare recursively
  467. if (['[object Array]', '[object Object]'].indexOf(itemType) >= 0) {
  468. if ('string' == typeof getChangedKey(item1, item2)) {
  469. return false;
  470. }
  471. }
  472. // Otherwise, do a simple comparison
  473. else {
  474. // If the two items are not the same type, return false
  475. if (itemType !== Object.prototype.toString.call(item2)) return false;
  476. // Else if it's a function, convert to a string and compare
  477. // Otherwise, just compare
  478. if (itemType === '[object Function]') {
  479. if (item1.toString() !== item2.toString()) return false;
  480. } else {
  481. if (item1 !== item2) return false;
  482. }
  483. }
  484. };
  485. for ( var key in value ) {
  486. if ( other.hasOwnProperty(key) && value.hasOwnProperty(key) ) {
  487. if ( compare( value[key], other[key] ) === false ) return key;
  488. } else {
  489. return key;
  490. }
  491. }
  492. // If nothing failed, return true
  493. return true;
  494. }
  495. function isJsonString( str ) {
  496. try {
  497. JSON.parse(str);
  498. } catch (e) {
  499. return false;
  500. }
  501. return true;
  502. }
  503. function hasWordPressWidgetBlockEditor() {
  504. return astraCustomizer.has_block_editor_support || false;
  505. }
  506. ( function( $ ) {
  507. /*
  508. * Site Identity Logo Width
  509. */
  510. wp.customize( 'astra-settings[ast-header-responsive-logo-width]', function( setting ) {
  511. setting.bind( function( logo_width ) {
  512. if ( logo_width['desktop'] != '' || logo_width['tablet'] != '' || logo_width['mobile'] != '' ) {
  513. var dynamicStyle = '#masthead .site-logo-img .custom-logo-link img { max-width: ' + logo_width['desktop'] + 'px; } @media( max-width: 768px ) { #masthead .site-logo-img .custom-logo-link img { max-width: ' + logo_width['tablet'] + 'px; } #masthead .site-logo-img img { max-height: ' + logo_width['tablet'] + 'px; } } @media( max-width: 544px ) { .ast-header-break-point .site-branding img, .ast-header-break-point #masthead .site-logo-img .custom-logo-link img { max-width: ' + logo_width['mobile'] + 'px; }' +
  514. '#masthead .site-logo-img img { max-height: ' + logo_width['mobile'] + 'px; } .astra-logo-svg{width: ' + logo_width['mobile'] + 'px !important; } }';
  515. astra_add_dynamic_css( 'ast-header-responsive-logo-width', dynamicStyle );
  516. var mobileLogoStyle = '.ast-header-break-point #masthead .site-logo-img .custom-mobile-logo-link img { max-width: ' + logo_width['tablet'] + 'px; } @media( max-width: 768px ) { .ast-header-break-point #masthead .site-logo-img .custom-mobile-logo-link img { max-width: ' + logo_width['tablet'] + 'px; } @media( max-width: 544px ) { .ast-header-break-point #masthead .site-logo-img .custom-mobile-logo-link img { max-width: ' + logo_width['mobile'] + 'px; }';
  517. astra_add_dynamic_css( 'mobile-header-logo-width', mobileLogoStyle );
  518. }
  519. else{
  520. wp.customize.preview.send( 'refresh' );
  521. }
  522. } );
  523. } );
  524. /*
  525. * Responsive Logo Visibility
  526. */
  527. wp.customize( 'astra-settings[display-site-title-responsive]', function( setting ) {
  528. setting.bind( function( logo_visibility ) {
  529. var desktopTitleVisibility = ( logo_visibility['desktop'] ) ? 'block' : 'none';
  530. var tabletTitleVisibility = ( logo_visibility['tablet'] ) ? 'block' : 'none';
  531. var mobileTitleVisibility = ( logo_visibility['mobile'] ) ? 'block' : 'none';
  532. var tabletBreakPoint = astraBuilderPreview.tablet_break_point || 768,
  533. mobileBreakPoint = astraBuilderPreview.mobile_break_point || 544;
  534. var dynamicStyle = '.ast-site-title-wrap .site-title { display: ' + desktopTitleVisibility + ';} @media( max-width: ' + tabletBreakPoint + 'px) { .ast-site-title-wrap .site-title { display: ' + tabletTitleVisibility + ';} } @media( max-width: ' + mobileBreakPoint + 'px) { .ast-site-title-wrap .site-title { display: ' + mobileTitleVisibility + ';} }';
  535. astra_add_dynamic_css( 'display-site-title-responsive', dynamicStyle );
  536. } );
  537. } );
  538. /*
  539. * Responsive Tagline Visibility
  540. */
  541. wp.customize( 'astra-settings[display-site-tagline-responsive]', function( setting ) {
  542. setting.bind( function( tagline_visibility ) {
  543. var desktopTaglineVisibility = ( tagline_visibility['desktop'] ) ? 'block' : 'none';
  544. var tabletTaglineVisibility = ( tagline_visibility['tablet'] ) ? 'block' : 'none';
  545. var mobileTaglineVisibility = ( tagline_visibility['mobile'] ) ? 'block' : 'none';
  546. var tabletBreakPoint = astraBuilderPreview.tablet_break_point || 768,
  547. mobileBreakPoint = astraBuilderPreview.mobile_break_point || 544;
  548. var dynamicStyle = '.ast-site-title-wrap .site-description { display: ' + desktopTaglineVisibility + ';} @media( max-width: ' + tabletBreakPoint + 'px) { .ast-site-title-wrap .site-description { display: ' + tabletTaglineVisibility + ';} } @media( max-width: ' + mobileBreakPoint + 'px) { .ast-site-title-wrap .site-description { display: ' + mobileTaglineVisibility + ';} }';
  549. astra_add_dynamic_css( 'display-site-tagline-responsive', dynamicStyle );
  550. } );
  551. } );
  552. /*
  553. * Full width layout
  554. */
  555. wp.customize( 'astra-settings[site-content-width]', function( setting ) {
  556. setting.bind( function( width ) {
  557. var dynamicStyle = '@media (min-width: 554px) {';
  558. dynamicStyle += '.ast-container, .fl-builder #content .entry-header { max-width: ' + ( 40 + parseInt( width ) ) + 'px } ';
  559. dynamicStyle += '}';
  560. if ( jQuery( 'body' ).hasClass( 'ast-page-builder-template' ) ) {
  561. dynamicStyle += '@media (min-width: 554px) {';
  562. dynamicStyle += '.ast-page-builder-template .comments-area { max-width: ' + ( 40 + parseInt( width ) ) + 'px } ';
  563. dynamicStyle += '}';
  564. }
  565. astra_add_dynamic_css( 'site-content-width', dynamicStyle );
  566. } );
  567. } );
  568. /*
  569. * Full width layout
  570. */
  571. wp.customize( 'astra-settings[header-main-menu-label]', function( setting ) {
  572. setting.bind( function( label ) {
  573. if( $('button.main-header-menu-toggle .mobile-menu-wrap .mobile-menu').length > 0 ) {
  574. if ( label != '' ) {
  575. $('button.main-header-menu-toggle .mobile-menu-wrap .mobile-menu').text(label);
  576. } else {
  577. $('button.main-header-menu-toggle .mobile-menu-wrap').remove();
  578. }
  579. } else {
  580. var html = $('button.main-header-menu-toggle').html();
  581. if( '' != label ) {
  582. html += '<div class="mobile-menu-wrap"><span class="mobile-menu">'+ label +'</span> </div>';
  583. }
  584. $('button.main-header-menu-toggle').html( html )
  585. }
  586. } );
  587. } );
  588. /*
  589. * Layout Body Background
  590. */
  591. astra_apply_responsive_background_css( 'astra-settings[site-layout-outside-bg-obj-responsive]', 'body, .ast-separate-container', 'desktop' );
  592. astra_apply_responsive_background_css( 'astra-settings[site-layout-outside-bg-obj-responsive]', 'body, .ast-separate-container', 'tablet' );
  593. astra_apply_responsive_background_css( 'astra-settings[site-layout-outside-bg-obj-responsive]', 'body, .ast-separate-container', 'mobile' );
  594. if( astraCustomizer.is_content_bg_option_to_load ) {
  595. var content_layout = astraCustomizer.content_layout;
  596. var site_layout = astraCustomizer.site_layout;
  597. var blog_grid = (typeof ( wp.customize._value['astra-settings[blog-grid]'] ) != 'undefined') ? wp.customize._value['astra-settings[blog-grid]']._value : 1;
  598. var blog_layout = (typeof ( wp.customize._value['astra-settings[blog-layout]'] ) != 'undefined') ? wp.customize._value['astra-settings[blog-layout]']._value : 'blog-layout-1';
  599. var dynamicSelector = '.ast-separate-container .ast-article-single:not(.ast-related-post), .ast-separate-container .comments-area .comment-respond,.ast-separate-container .comments-area .ast-comment-list li, .ast-separate-container .ast-woocommerce-container, .ast-separate-container .error-404, .ast-separate-container .no-results, .single.ast-separate-container .ast-author-meta, .ast-separate-container .related-posts, .ast-separate-container .comments-count-wrapper, .ast-separate-container .comments-area .comments-title, .ast-single-related-posts-container';
  600. if( 'blog-layout-1' == blog_layout && 1 != blog_grid ) {
  601. dynamicSelector += ', .ast-separate-container .blog-layout-1, .ast-separate-container .blog-layout-2, .ast-separate-container .blog-layout-3';
  602. } else {
  603. dynamicSelector += ', .ast-separate-container .ast-article-post';
  604. }
  605. /**
  606. * Content background color
  607. */
  608. if( 'boxed-container' == content_layout ) {
  609. dynamicSelector += ', .ast-separate-container.ast-two-container #secondary .widget';
  610. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'desktop' );
  611. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'tablet' );
  612. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'mobile' );
  613. }
  614. else if ( 'content-boxed-container' == content_layout ) {
  615. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'desktop' );
  616. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'tablet' );
  617. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'mobile' );
  618. } else if ( astraCustomizer.apply_content_bg_fullwidth_layouts && ( 'ast-box-layout' == site_layout || 'ast-padded-layout' == site_layout ) && ( 'plain-container' == content_layout || 'page-builder' == content_layout ) ) {
  619. var fullWidthLayoutSelector = '.ast-plain-container, .ast-page-builder-template';
  620. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', fullWidthLayoutSelector, 'desktop' );
  621. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', fullWidthLayoutSelector, 'tablet' );
  622. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', fullWidthLayoutSelector, 'mobile' );
  623. }
  624. else if ( 'plain-container' == content_layout && ( 'ast-box-layout' == site_layout || 'ast-padded-layout' == site_layout ) ) {
  625. dynamicSelector += ', .ast-box-layout.ast-plain-container .site-content, .ast-padded-layout.ast-plain-container .site-content';
  626. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'desktop' );
  627. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'tablet' );
  628. astra_apply_responsive_background_css( 'astra-settings[content-bg-obj-responsive]', dynamicSelector, 'mobile' );
  629. }
  630. }
  631. /*
  632. * Blog Custom Width
  633. */
  634. wp.customize( 'astra-settings[blog-max-width]', function( setting ) {
  635. setting.bind( function( width ) {
  636. var dynamicStyle = '@media all and ( min-width: 921px ) {';
  637. if ( ! jQuery( 'body' ).hasClass( 'ast-woo-shop-archive' ) ) {
  638. dynamicStyle += '.blog .site-content > .ast-container,.archive .site-content > .ast-container{ max-width: ' + ( parseInt( width ) ) + 'px } ';
  639. }
  640. if ( jQuery( 'body' ).hasClass( 'ast-fluid-width-layout' ) ) {
  641. dynamicStyle += '.blog .site-content > .ast-container,.archive .site-content > .ast-container{ padding-left:20px; padding-right:20px; } ';
  642. }
  643. dynamicStyle += '}';
  644. astra_add_dynamic_css( 'blog-max-width', dynamicStyle );
  645. } );
  646. } );
  647. /*
  648. * Single Blog Custom Width
  649. */
  650. wp.customize( 'astra-settings[blog-single-max-width]', function( setting ) {
  651. setting.bind( function( width ) {
  652. var dynamicStyle = '@media all and ( min-width: 921px ) {';
  653. dynamicStyle += '.single-post .site-content > .ast-container{ max-width: ' + ( 40 + parseInt( width ) ) + 'px } ';
  654. if ( jQuery( 'body' ).hasClass( 'ast-fluid-width-layout' ) ) {
  655. dynamicStyle += '.single-post .site-content > .ast-container{ padding-left:20px; padding-right:20px; } ';
  656. }
  657. dynamicStyle += '}';
  658. astra_add_dynamic_css( 'blog-single-max-width', dynamicStyle );
  659. } );
  660. } );
  661. /*
  662. * EDD Archive Custom Width
  663. */
  664. wp.customize( 'astra-settings[edd-archive-max-width]', function( setting ) {
  665. setting.bind( function( width ) {
  666. var dynamicStyle = '.ast-edd-archive-page .site-content > .ast-container { max-width: ' + parseInt( width ) + 'px } ';
  667. astra_add_dynamic_css( 'edd-archive-max-width', dynamicStyle );
  668. } );
  669. } );
  670. /**
  671. * Primary Width Option
  672. */
  673. wp.customize( 'astra-settings[site-sidebar-width]', function( setting ) {
  674. setting.bind( function( width ) {
  675. if ( ! jQuery( 'body' ).hasClass( 'ast-no-sidebar' ) && width >= 15 && width <= 50 ) {
  676. var dynamicStyle = '@media (min-width: 769px) {';
  677. dynamicStyle += '#primary { width: ' + ( 100 - parseInt( width ) ) + '% } ';
  678. dynamicStyle += '#secondary { width: ' + width + '% } ';
  679. dynamicStyle += '}';
  680. astra_add_dynamic_css( 'site-sidebar-width', dynamicStyle );
  681. }
  682. } );
  683. } );
  684. /**
  685. * Header Bottom Border
  686. */
  687. wp.customize( 'astra-settings[header-main-sep]', function( setting ) {
  688. setting.bind( function( border ) {
  689. var dynamicStyle = 'body.ast-header-break-point .main-header-bar { border-bottom-width: ' + border + 'px }';
  690. dynamicStyle += '.ast-desktop .main-header-bar {';
  691. dynamicStyle += 'border-bottom-width: ' + border + 'px';
  692. dynamicStyle += '}';
  693. astra_add_dynamic_css( 'header-main-sep', dynamicStyle );
  694. } );
  695. } );
  696. /**
  697. * Small Footer Top Border
  698. */
  699. wp.customize( 'astra-settings[footer-sml-divider]', function( value ) {
  700. value.bind( function( border_width ) {
  701. jQuery( '.ast-small-footer' ).css( 'border-top-width', border_width + 'px' );
  702. } );
  703. } );
  704. /**
  705. * Footer Widget Top Border
  706. */
  707. wp.customize( 'astra-settings[footer-adv-border-width]', function( value ) {
  708. value.bind( function( border_width ) {
  709. jQuery( '.footer-adv .footer-adv-overlay' ).css( 'border-top-width', border_width + 'px' );
  710. } );
  711. } );
  712. wp.customize( 'astra-settings[footer-adv-border-color]', function( value ) {
  713. value.bind( function( border_color ) {
  714. jQuery( '.footer-adv .footer-adv-overlay' ).css( 'border-top-color', border_color );
  715. } );
  716. } );
  717. /**
  718. * Small Footer Top Border Color
  719. */
  720. wp.customize( 'astra-settings[footer-sml-divider-color]', function( value ) {
  721. value.bind( function( border_color ) {
  722. jQuery( '.ast-small-footer' ).css( 'border-top-color', border_color );
  723. } );
  724. } );
  725. /**
  726. * Button Border Radius
  727. */
  728. wp.customize( 'astra-settings[button-radius]', function( setting ) {
  729. setting.bind( function( border ) {
  730. var search_button_selector = hasWordPressWidgetBlockEditor() ? ', form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button' : '' ;
  731. var lmsButtonSelectors = ', body #ld_course_list .btn, body a.btn-blue, body a.btn-blue:visited, body a#quiz_continue_link, body .btn-join, body .learndash_checkout_buttons input.btn-join[type="button"], body #btn-join, body .learndash_checkout_buttons input.btn-join[type="submit"], body .wpProQuiz_content .wpProQuiz_button2, a.llms-button-primary, .llms-button-secondary, .llms-button-action, .llms-field-button, .llms-button-action.large';
  732. var dynamicStyle = '.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .wp-block-button .wp-block-button__link' + lmsButtonSelectors + search_button_selector + '{ border-radius: ' + ( parseInt( border ) ) + 'px } ';
  733. if ( jQuery( 'body' ).hasClass( 'woocommerce' ) ) {
  734. dynamicStyle += '.woocommerce a.button, .woocommerce button.button, .woocommerce .product a.button, .woocommerce .woocommerce-message a.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce input.button,.woocommerce input.button:disabled, .woocommerce input.button:disabled[disabled] { border-radius: ' + ( parseInt( border ) ) + 'px } ';
  735. }
  736. if ( jQuery( 'body' ).hasClass( 'edd-page' ) ) {
  737. dynamicStyle += '.ast-edd-site-header-cart .widget_edd_cart_widget .edd_checkout a, .widget_edd_cart_widget .edd_checkout a { border-radius: ' + ( parseInt( border ) ) + 'px } ';
  738. }
  739. astra_add_dynamic_css( 'button-radius', dynamicStyle );
  740. } );
  741. } );
  742. /**
  743. * Header Bottom Border width
  744. */
  745. wp.customize( 'astra-settings[header-main-sep]', function( value ) {
  746. value.bind( function( border ) {
  747. var dynamicStyle = ' body.ast-header-break-point .main-header-bar { border-bottom-width: ' + border + 'px } ';
  748. dynamicStyle += '.ast-desktop .main-header-bar {';
  749. dynamicStyle += 'border-bottom-width: ' + border + 'px';
  750. dynamicStyle += '}';
  751. astra_add_dynamic_css( 'header-main-sep', dynamicStyle );
  752. } );
  753. } );
  754. /**
  755. * Header Bottom Border color
  756. */
  757. wp.customize( 'astra-settings[header-main-sep-color]', function( value ) {
  758. value.bind( function( color ) {
  759. if (color == '') {
  760. wp.customize.preview.send( 'refresh' );
  761. }
  762. if ( color ) {
  763. var dynamicStyle = ' .ast-desktop .main-header-bar { border-bottom-color: ' + color + '; } ';
  764. dynamicStyle += ' body.ast-header-break-point .main-header-bar { border-bottom-color: ' + color + '; } ';
  765. astra_add_dynamic_css( 'header-main-sep-color', dynamicStyle );
  766. }
  767. } );
  768. } );
  769. /**
  770. * Primary Toggle Button Color
  771. */
  772. wp.customize( 'astra-settings[mobile-header-toggle-btn-style-color]', function( setting ) {
  773. setting.bind( function( toggle_button_color ) {
  774. if ( toggle_button_color != '' ) {
  775. if( jQuery( '.menu-toggle' ).hasClass( 'ast-mobile-menu-buttons-fill' ) ) {
  776. var dynamicStyle = '.ast-header-break-point .ast-mobile-menu-buttons-fill.menu-toggle { background: ' + toggle_button_color + '}';
  777. }
  778. else if( jQuery( '.menu-toggle' ).hasClass( 'ast-mobile-menu-buttons-outline' ) ) {
  779. var dynamicStyle = '.ast-header-break-point .ast-mobile-menu-buttons-outline.menu-toggle { border: 1px solid ' + toggle_button_color + '; color: ' + toggle_button_color + '}';
  780. }
  781. else {
  782. var dynamicStyle = '.ast-header-break-point .ast-mobile-menu-buttons-minimal.menu-toggle { color: ' + toggle_button_color + '}';
  783. }
  784. astra_add_dynamic_css( 'primary-toggle-button-color', dynamicStyle );
  785. }
  786. else{
  787. wp.customize.preview.send( 'refresh' );
  788. }
  789. });
  790. });
  791. astra_responsive_font_size( 'astra-settings[font-size-site-tagline]', '.site-header .site-description' );
  792. astra_responsive_font_size( 'astra-settings[font-size-site-title]', '.site-title' );
  793. /**
  794. * Single Post Container Outside Spacing
  795. */
  796. astra_responsive_spacing( 'astra-settings[single-post-outside-spacing]','.ast-separate-container.ast-single-post.ast-right-sidebar #primary, .ast-separate-container.ast-single-post.ast-left-sidebar #primary, .ast-separate-container.ast-single-post #primary, .ast-plain-container.ast-single-post #primary', 'margin', ['top', 'bottom' ] );
  797. astra_responsive_spacing( 'astra-settings[single-post-outside-spacing]','.ast-left-sidebar.ast-single-post #primary, .ast-right-sidebar.ast-single-post #primary, .ast-separate-container.ast-single-post.ast-right-sidebar #primary, .ast-separate-container.ast-single-post.ast-left-sidebar #primary, .ast-separate-container.ast-single-post #primary', 'padding', ['left', 'right' ] );
  798. // Remove padding top to container if padding top is given to Container Outer Spacing.
  799. wp.customize( 'astra-settings[single-post-outside-spacing]', function( value ) {
  800. value.bind( function( padding ) {
  801. var dynamicStyle = '';
  802. if( padding.desktop.top != '' || padding.tablet.top != '' || padding.mobile.top != '' ) {
  803. dynamicStyle += '.ast-separate-container.ast-single-post #primary { padding-top: 0px;} ';
  804. }
  805. if( padding.desktop.bottom != '' || padding.tablet.bottom != '' || padding.mobile.bottom != '' ) {
  806. dynamicStyle += '.ast-separate-container.ast-single-post #primary { padding-bottom: 0px;} ';
  807. }
  808. astra_add_dynamic_css( 'remove-header-spacing', dynamicStyle );
  809. } );
  810. } );
  811. astra_responsive_font_size( 'astra-settings[font-size-entry-title]', '.ast-single-post .entry-title, .page-title' );
  812. astra_responsive_font_size( 'astra-settings[font-size-archive-summary-title]', '.ast-archive-description .ast-archive-title' );
  813. astra_responsive_font_size( 'astra-settings[font-size-page-title]', 'body:not(.ast-single-post) .entry-title' );
  814. // Check if anchors should be loaded in the CSS for headings.
  815. if (true == astraCustomizer.includeAnchorsInHeadindsCss) {
  816. astra_responsive_font_size('astra-settings[font-size-h1]', 'h1, .entry-content h1, .entry-content h1 a');
  817. astra_responsive_font_size('astra-settings[font-size-h2]', 'h2, .entry-content h2, .entry-content h2 a');
  818. astra_responsive_font_size('astra-settings[font-size-h3]', 'h3, .entry-content h3, .entry-content h3 a');
  819. astra_responsive_font_size('astra-settings[font-size-h4]', 'h4, .entry-content h4, .entry-content h4 a');
  820. astra_responsive_font_size('astra-settings[font-size-h5]', 'h5, .entry-content h5, .entry-content h5 a');
  821. astra_responsive_font_size('astra-settings[font-size-h6]', 'h6, .entry-content h6, .entry-content h6 a');
  822. } else {
  823. astra_responsive_font_size('astra-settings[font-size-h1]', 'h1, .entry-content h1');
  824. astra_responsive_font_size('astra-settings[font-size-h2]', 'h2, .entry-content h2');
  825. astra_responsive_font_size('astra-settings[font-size-h3]', 'h3, .entry-content h3');
  826. astra_responsive_font_size('astra-settings[font-size-h4]', 'h4, .entry-content h4');
  827. astra_responsive_font_size('astra-settings[font-size-h5]', 'h5, .entry-content h5');
  828. astra_responsive_font_size('astra-settings[font-size-h6]', 'h6, .entry-content h6');
  829. }
  830. // paragraph margin bottom.
  831. wp.customize( 'astra-settings[para-margin-bottom]', function( value ) {
  832. value.bind( function( marginBottom ) {
  833. if ( marginBottom == '' ) {
  834. wp.customize.preview.send( 'refresh' );
  835. }
  836. if ( marginBottom ) {
  837. var dynamicStyle = ' p, .entry-content p { margin-bottom: ' + marginBottom + 'em; } ';
  838. astra_add_dynamic_css( 'para-margin-bottom', dynamicStyle );
  839. }
  840. } );
  841. } );
  842. // Add preview underline in customizer for content links.
  843. wp.customize( 'astra-settings[underline-content-links]', function( setting ) {
  844. setting.bind( function( value ) {
  845. var dynamicStyle = '';
  846. if ( value ) {
  847. dynamicStyle = '.ast-single-post .entry-content a, .ast-comment-content a:not(.ast-comment-edit-reply-wrap a) { text-decoration: underline; } ';
  848. astra_add_dynamic_css( 'underline-content-links', dynamicStyle );
  849. } else {
  850. dynamicStyle = '.ast-single-post .entry-content a, .ast-comment-content a:not(.ast-comment-edit-reply-wrap a) { text-decoration: unset; } ';
  851. astra_add_dynamic_css( 'underline-content-links', dynamicStyle );
  852. }
  853. } );
  854. } );
  855. if ( astraCustomizer.page_builder_button_style_css ) {
  856. if (true == astraCustomizer.includeAnchorsInHeadindsCss) {
  857. if ( 'color-typo' == astraCustomizer.elementor_default_color_font_setting || 'typo' == astraCustomizer.elementor_default_color_font_setting ) {
  858. astra_css('astra-settings[headings-line-height]', 'line-height', '.elementor-widget-heading h1.elementor-heading-title, .elementor-widget-heading h2.elementor-heading-title, .elementor-widget-heading h3.elementor-heading-title, .elementor-widget-heading h4.elementor-heading-title, .elementor-widget-heading h5.elementor-heading-title, .elementor-widget-heading h6.elementor-heading-title');
  859. }
  860. astra_css('astra-settings[headings-line-height]', 'line-height', 'h1, .entry-content h1, .entry-content h1 a, h2, .entry-content h2, .entry-content h2 a, h3, .entry-content h3, .entry-content h3 a, h4, .entry-content h4, .entry-content h4 a, h5, .entry-content h5, .entry-content h5 a, h6, .entry-content h6, .entry-content h6 a, .site-title, .site-title a');
  861. } else {
  862. if ( 'color-typo' == astraCustomizer.elementor_default_color_font_setting || 'typo' == astraCustomizer.elementor_default_color_font_setting ) {
  863. astra_css('astra-settings[headings-line-height]', 'line-height', '.elementor-widget-heading h1.elementor-heading-title, .elementor-widget-heading h2.elementor-heading-title, .elementor-widget-heading h3.elementor-heading-title, .elementor-widget-heading h4.elementor-heading-title, .elementor-widget-heading h5.elementor-heading-title, .elementor-widget-heading h6.elementor-heading-title');
  864. }
  865. astra_css('astra-settings[headings-line-height]', 'line-height', 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a');
  866. }
  867. } else {
  868. if (true == astraCustomizer.includeAnchorsInHeadindsCss) {
  869. astra_css('astra-settings[headings-line-height]', 'line-height', 'h1, .entry-content h1, .entry-content h1 a, h2, .entry-content h2, .entry-content h2 a, h3, .entry-content h3, .entry-content h3 a, h4, .entry-content h4, .entry-content h4 a, h5, .entry-content h5, .entry-content h5 a, h6, .entry-content h6, .entry-content h6 a, .site-title, .site-title a');
  870. } else {
  871. astra_css('astra-settings[headings-line-height]', 'line-height', 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a');
  872. }
  873. }
  874. // Check if anchors should be loaded in the CSS for headings.
  875. if (true == astraCustomizer.includeAnchorsInHeadindsCss) {
  876. astra_generate_outside_font_family_css('astra-settings[headings-font-family]', 'h1, .entry-content h1, .entry-content h1 a, h2, .entry-content h2, .entry-content h2 a, h3, .entry-content h3, .entry-content h3 a, h4, .entry-content h4, .entry-content h4 a, h5, .entry-content h5, .entry-content h5 a, h6, .entry-content h6, .entry-content h6 a, .site-title, .site-title a');
  877. astra_generate_font_weight_css( 'astra-settings[headings-font-family]', 'astra-settings[headings-font-weight]', 'font-weight', 'h1, .entry-content h1, .entry-content h1 a, h2, .entry-content h2, .entry-content h2 a, h3, .entry-content h3, .entry-content h3 a, h4, .entry-content h4, .entry-content h4 a, h5, .entry-content h5, .entry-content h5 a, h6, .entry-content h6, .entry-content h6 a, .site-title, .site-title a' );
  878. astra_css('astra-settings[headings-text-transform]', 'text-transform', 'h1, .entry-content h1, .entry-content h1 a, h2, .entry-content h2, .entry-content h2 a, h3, .entry-content h3, .entry-content h3 a, h4, .entry-content h4, .entry-content h4 a, h5, .entry-content h5, .entry-content h5 a, h6, .entry-content h6, .entry-content h6 a, .site-title, .site-title a');
  879. } else {
  880. astra_generate_outside_font_family_css('astra-settings[headings-font-family]', 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a');
  881. astra_generate_font_weight_css( 'astra-settings[headings-font-family]', 'astra-settings[headings-font-weight]', 'font-weight', 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a' );
  882. astra_css('astra-settings[headings-text-transform]', 'text-transform', 'h1, .entry-content h1, h2, .entry-content h2, h3, .entry-content h3, h4, .entry-content h4, h5, .entry-content h5, h6, .entry-content h6, .site-title, .site-title a');
  883. }
  884. // Footer Bar.
  885. astra_css( 'astra-settings[footer-color]', 'color', '.ast-small-footer' );
  886. astra_css( 'astra-settings[footer-link-color]', 'color', '.ast-small-footer a' );
  887. astra_css( 'astra-settings[footer-link-h-color]', 'color', '.ast-small-footer a:hover' );
  888. // Footer Bar background.
  889. wp.customize( 'astra-settings[footer-bg-obj]', function( value ) {
  890. value.bind( function( bg_obj ) {
  891. var dynamicStyle = ' .ast-small-footer > .ast-footer-overlay { {{css}} }';
  892. astra_background_obj_css( wp.customize, bg_obj, 'footer-bg-obj', dynamicStyle );
  893. } );
  894. } );
  895. // Footer Widgets.
  896. astra_css( 'astra-settings[footer-adv-wgt-title-color]', 'color', '.footer-adv .widget-title, .footer-adv .widget-title a' );
  897. astra_css( 'astra-settings[footer-adv-text-color]', 'color', '.footer-adv' );
  898. astra_css( 'astra-settings[footer-adv-link-color]', 'color', '.footer-adv a' );
  899. astra_css( 'astra-settings[footer-adv-link-h-color]', 'color', '.footer-adv a:hover, .footer-adv .no-widget-text a:hover, .footer-adv a:focus, .footer-adv .no-widget-text a:focus' );
  900. // Footer Widget background.
  901. wp.customize( 'astra-settings[footer-adv-bg-obj]', function( value ) {
  902. value.bind( function( bg_obj ) {
  903. var dynamicStyle = ' .footer-adv-overlay { {{css}} }';
  904. astra_background_obj_css( wp.customize, bg_obj, 'footer-adv-bg-obj', dynamicStyle );
  905. } );
  906. } );
  907. /*
  908. * Woocommerce Shop Archive Custom Width
  909. */
  910. wp.customize( 'astra-settings[shop-archive-max-width]', function( setting ) {
  911. setting.bind( function( width ) {
  912. var dynamicStyle = '@media all and ( min-width: 921px ) {';
  913. dynamicStyle += '.ast-woo-shop-archive .site-content > .ast-container{ max-width: ' + ( parseInt( width ) ) + 'px } ';
  914. if ( jQuery( 'body' ).hasClass( 'ast-fluid-width-layout' ) ) {
  915. dynamicStyle += '.ast-woo-shop-archive .site-content > .ast-container{ padding-left:20px; padding-right:20px; } ';
  916. }
  917. dynamicStyle += '}';
  918. astra_add_dynamic_css( 'shop-archive-max-width', dynamicStyle );
  919. } );
  920. } );
  921. //[1] Primary Menu Toggle Button Style.
  922. wp.customize( 'astra-settings[mobile-header-toggle-btn-style]', function( setting ) {
  923. setting.bind( function( icon_style ) {
  924. var icon_color = wp.customize('astra-settings[mobile-header-toggle-btn-color]').get();
  925. if ( '' === icon_color && 'fill' === icon_style ) {
  926. var dynamicStyle = ' [data-section="section-header-mobile-trigger"] .ast-button-wrap .mobile-menu-toggle-icon .ast-mobile-svg { fill: #ffffff; } ';
  927. astra_add_dynamic_css( 'mobile-header-toggle-btn-style', dynamicStyle );
  928. } else {
  929. astra_add_dynamic_css( 'mobile-header-toggle-btn-style', '' );
  930. }
  931. var buttons = $(document).find('.ast-mobile-menu-buttons .menu-toggle');
  932. buttons.removeClass('ast-mobile-menu-buttons-default ast-mobile-menu-buttons-fill ast-mobile-menu-buttons-outline');
  933. buttons.removeClass('ast-mobile-menu-buttons-default ast-mobile-menu-buttons-fill ast-mobile-menu-buttons-minimal');
  934. buttons.addClass( 'ast-mobile-menu-buttons-' + icon_style );
  935. var themeColor = wp.customize( 'astra-settings[theme-color]' ).get();
  936. var defaultColor = '#ffffff';
  937. var toggleButtonColor = wp.customize( 'astra-settings[mobile-header-toggle-btn-color]' ).get();
  938. if ( 'fill' !== icon_style ) {
  939. defaultColor = themeColor
  940. }
  941. var iconColor = defaultColor;
  942. if ( '' !== toggleButtonColor && undefined !== toggleButtonColor && null !== toggleButtonColor ) {
  943. iconColor = toggleButtonColor
  944. }
  945. var dynamicStyle = '[data-section="section-header-mobile-trigger"] .ast-button-wrap .mobile-menu-toggle-icon .ast-mobile-svg {';
  946. dynamicStyle += 'fill: ' + iconColor + ';';
  947. dynamicStyle +='}';
  948. dynamicStyle += '[data-section="section-header-mobile-trigger"] .ast-button-wrap .mobile-menu-wrap .mobile-menu {';
  949. dynamicStyle += 'color: ' + iconColor + ';';
  950. dynamicStyle +='}';
  951. dynamicStyle += '[data-section="section-header-mobile-trigger"] .ast-button-wrap .ast-mobile-menu-trigger-fill, [data-section="section-header-mobile-trigger"] .ast-button-wrap .ast-mobile-menu-trigger-minimal {';
  952. dynamicStyle += 'color: ' + iconColor + ';';
  953. dynamicStyle += 'border: none;';
  954. dynamicStyle +='}';
  955. dynamicStyle += '[data-section="section-header-mobile-trigger"] .ast-button-wrap .ast-mobile-menu-trigger-outline {';
  956. dynamicStyle += 'color: ' + iconColor + ';';
  957. dynamicStyle +='}';
  958. ;
  959. astra_add_dynamic_css( 'mobile-header-toggle-btn-style', dynamicStyle );
  960. } );
  961. } );
  962. //[1] Toggle Button Border Radius.
  963. wp.customize( 'astra-settings[mobile-header-toggle-btn-border-radius]', function( setting ) {
  964. setting.bind( function( border ) {
  965. var dynamicStyle = '.ast-header-break-point .main-header-bar .ast-button-wrap .menu-toggle { border-radius: ' + ( parseInt( border ) ) + 'px } ';
  966. astra_add_dynamic_css( 'mobile-header-toggle-btn-border-radius', dynamicStyle );
  967. } );
  968. } );
  969. /**
  970. * Primary Submenu border
  971. */
  972. wp.customize( 'astra-settings[primary-submenu-border]', function( value ) {
  973. value.bind( function( border ) {
  974. var color = wp.customize( 'astra-settings[primary-submenu-b-color]' ).get();
  975. if( '' != border.top || '' != border.right || '' != border.bottom || '' != border.left ) {
  976. var dynamicStyle = '.ast-desktop .main-header-menu.submenu-with-border .sub-menu';
  977. dynamicStyle += '{';
  978. dynamicStyle += 'border-top-width:' + border.top + 'px;';
  979. dynamicStyle += 'border-right-width:' + border.right + 'px;';
  980. dynamicStyle += 'border-left-width:' + border.left + 'px;';
  981. dynamicStyle += 'border-bottom-width:' + border.bottom + 'px;';
  982. dynamicStyle += 'border-color:' + color + ';';
  983. dynamicStyle += 'border-style: solid;';
  984. dynamicStyle += '}';
  985. dynamicStyle += '.ast-desktop .main-header-menu.submenu-with-border .sub-menu .sub-menu';
  986. dynamicStyle += '{';
  987. dynamicStyle += 'top:-' + border.top + 'px;';
  988. dynamicStyle += '}';
  989. // Submenu items goes outside?
  990. dynamicStyle += '@media (min-width: 769px){';
  991. dynamicStyle += '.main-header-menu .sub-menu .menu-item.ast-left-align-sub-menu:hover > .sub-menu, .main-header-menu .sub-menu .menu-item.ast-left-align-sub-menu.focus > .sub-menu';
  992. dynamicStyle += '{';
  993. dynamicStyle += 'margin-left:-' + ( +border.left + +border.right ) + 'px;';
  994. dynamicStyle += '}';
  995. dynamicStyle += '}';
  996. astra_add_dynamic_css( 'primary-submenu-border', dynamicStyle );
  997. } else {
  998. wp.customize.preview.send( 'refresh' );
  999. }
  1000. } );
  1001. } );
  1002. /**
  1003. * Primary Submenu border COlor
  1004. */
  1005. wp.customize( 'astra-settings[primary-submenu-b-color]', function( value ) {
  1006. value.bind( function( color ) {
  1007. var border = wp.customize( 'astra-settings[primary-submenu-border]' ).get();
  1008. if ( '' != color ) {
  1009. if( '' != border.top || '' != border.right || '' != border.bottom || '' != border.left ) {
  1010. var dynamicStyle = '.ast-desktop .main-header-menu.submenu-with-border .sub-menu';
  1011. dynamicStyle += '{';
  1012. dynamicStyle += 'border-top-width:' + border.top + 'px;';
  1013. dynamicStyle += 'border-right-width:' + border.right + 'px;';
  1014. dynamicStyle += 'border-left-width:' + border.left + 'px;';
  1015. dynamicStyle += 'border-bottom-width:' + border.bottom + 'px;';
  1016. dynamicStyle += 'border-color:' + color + ';';
  1017. dynamicStyle += 'border-style: solid;';
  1018. dynamicStyle += '}';
  1019. dynamicStyle += '.ast-desktop .main-header-menu.submenu-with-border .sub-menu .sub-menu';
  1020. dynamicStyle += '{';
  1021. dynamicStyle += 'top:-' + border.top + 'px;';
  1022. dynamicStyle += '}';
  1023. // Submenu items goes outside?
  1024. dynamicStyle += '@media (min-width: 769px){';
  1025. dynamicStyle += '.main-header-menu .sub-menu .menu-item.ast-left-align-sub-menu:hover > .sub-menu, .main-header-menu .sub-menu .menu-item.ast-left-align-sub-menu.focus > .sub-menu';
  1026. dynamicStyle += '{';
  1027. dynamicStyle += 'margin-left:-' + ( +border.left + +border.right ) + 'px;';
  1028. dynamicStyle += '}';
  1029. dynamicStyle += '}';
  1030. astra_add_dynamic_css( 'primary-submenu-border-color', dynamicStyle );
  1031. }
  1032. } else {
  1033. wp.customize.preview.send( 'refresh' );
  1034. }
  1035. } );
  1036. } );
  1037. /**
  1038. * Primary Submenu border COlor
  1039. */
  1040. wp.customize('astra-settings[primary-submenu-item-b-color]', function (value) {
  1041. value.bind(function (color) {
  1042. var insideBorder = wp.customize('astra-settings[primary-submenu-item-border]').get();
  1043. if ('' != color) {
  1044. if ( true == insideBorder ) {
  1045. var dynamicStyle = '';
  1046. dynamicStyle += '.ast-desktop .main-header-menu.submenu-with-border .sub-menu .menu-link';
  1047. dynamicStyle += '{';
  1048. dynamicStyle += 'border-bottom-width:' + ( ( true === insideBorder ) ? '1px;' : '0px;' );
  1049. dynamicStyle += 'border-color:' + color + ';';
  1050. dynamicStyle += 'border-style: solid;';
  1051. dynamicStyle += '}';
  1052. astra_add_dynamic_css('primary-submenu-item-b-color', dynamicStyle);
  1053. }
  1054. } else {
  1055. wp.customize.preview.send('refresh');
  1056. }
  1057. });
  1058. });
  1059. /**
  1060. * Primary Submenu border COlor
  1061. */
  1062. wp.customize( 'astra-settings[primary-submenu-item-border]', function( value ) {
  1063. value.bind( function( border ) {
  1064. var color = wp.customize( 'astra-settings[primary-submenu-item-b-color]' ).get();
  1065. if( true === border ) {
  1066. var dynamicStyle = '.ast-desktop .main-header-menu.submenu-with-border .sub-menu .menu-link';
  1067. dynamicStyle += '{';
  1068. dynamicStyle += 'border-bottom-width:' + ( ( true === border ) ? '1px;' : '0px;' );
  1069. dynamicStyle += 'border-color:' + color + ';';
  1070. dynamicStyle += 'border-style: solid;';
  1071. dynamicStyle += '}';
  1072. astra_add_dynamic_css( 'primary-submenu-item-border', dynamicStyle );
  1073. } else {
  1074. wp.customize.preview.send( 'refresh' );
  1075. }
  1076. } );
  1077. } );
  1078. astra_css( 'astra-settings[header-main-rt-section-button-text-color]', 'color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1079. astra_css( 'astra-settings[header-main-rt-section-button-back-color]', 'background-color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1080. astra_css( 'astra-settings[header-main-rt-section-button-text-h-color]', 'color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button:hover' );
  1081. astra_css( 'astra-settings[header-main-rt-section-button-back-h-color]', 'background-color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button:hover' );
  1082. astra_css( 'astra-settings[header-main-rt-section-button-border-radius]', 'border-radius', '.main-header-bar .ast-container .button-custom-menu-item .ast-custom-button-link .ast-custom-button', 'px' );
  1083. astra_css( 'astra-settings[header-main-rt-section-button-border-color]', 'border-color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1084. astra_css( 'astra-settings[header-main-rt-section-button-border-h-color]', 'border-color', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button:hover' );
  1085. astra_responsive_spacing( 'astra-settings[header-main-rt-section-button-padding]','.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button', 'padding', ['top', 'right', 'bottom', 'left' ] );
  1086. // Header custom button - Typography preview stylings.
  1087. astra_generate_outside_font_family_css( 'astra-settings[primary-header-button-font-family]', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1088. astra_responsive_font_size( 'astra-settings[primary-header-button-font-size]', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1089. astra_css( 'astra-settings[primary-header-button-font-weight]', 'font-weight', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1090. astra_css( 'astra-settings[primary-header-button-line-height]', 'line-height', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1091. astra_css( 'astra-settings[primary-header-button-text-transform]', 'text-transform', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button' );
  1092. astra_css( 'astra-settings[primary-header-button-letter-spacing]', 'letter-spacing', '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button, .ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button', 'px' );
  1093. /**
  1094. * Custom Button border
  1095. */
  1096. wp.customize( 'astra-settings[header-main-rt-section-button-border-size]', function( value ) {
  1097. value.bind( function( border ) {
  1098. if( '' != border.top || '' != border.right || '' != border.bottom || '' != border.left ) {
  1099. var dynamicStyle = '.main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button';
  1100. dynamicStyle += '{';
  1101. dynamicStyle += 'border-top-width:' + border.top + 'px;';
  1102. dynamicStyle += 'border-right-width:' + border.right + 'px;';
  1103. dynamicStyle += 'border-left-width:' + border.left + 'px;';
  1104. dynamicStyle += 'border-bottom-width:' + border.bottom + 'px;';
  1105. dynamicStyle += 'border-style: solid;';
  1106. dynamicStyle += '}';
  1107. astra_add_dynamic_css( 'header-main-rt-section-button-border-size', dynamicStyle );
  1108. }
  1109. } );
  1110. } );
  1111. var ele_border_radius_selector = '';
  1112. var ele_border_width_selector = '';
  1113. var ele_padding_selector = '';
  1114. if ( astraCustomizer.page_builder_button_style_css ) {
  1115. if ( 'color-typo' == astraCustomizer.elementor_default_color_font_setting || 'color' == astraCustomizer.elementor_default_color_font_setting || 'font' == astraCustomizer.elementor_default_color_font_setting ) {
  1116. ele_border_radius_selector = ', .elementor-button-wrapper .elementor-button.elementor-size-sm, .elementor-button-wrapper .elementor-button.elementor-size-xs, .elementor-button-wrapper .elementor-button.elementor-size-md, .elementor-button-wrapper .elementor-button.elementor-size-lg, .elementor-button-wrapper .elementor-button.elementor-size-xl, .elementor-button-wrapper .elementor-button';
  1117. ele_border_width_selector = ', .elementor-button-wrapper .elementor-button, .elementor-button-wrapper .elementor-button:visited';
  1118. ele_padding_selector = ', .elementor-button-wrapper .elementor-button.elementor-size-sm, .elementor-button-wrapper .elementor-button.elementor-size-xs, .elementor-button-wrapper .elementor-button.elementor-size-md, .elementor-button-wrapper .elementor-button.elementor-size-lg, .elementor-button-wrapper .elementor-button.elementor-size-xl, .elementor-button-wrapper .elementor-button';
  1119. }
  1120. }
  1121. astra_css( 'astra-settings[button-radius]', 'border-radius', '.menu-toggle, button, .ast-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"]' + ele_border_radius_selector, 'px' );
  1122. /**
  1123. * Button border
  1124. */
  1125. wp.customize( 'astra-settings[theme-button-border-group-border-size]', function( value ) {
  1126. value.bind( function( border ) {
  1127. var search_button_selector = hasWordPressWidgetBlockEditor() ? ', form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button' : '' ;
  1128. var dynamicStyle = '.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .wp-block-button .wp-block-button__link' + ele_border_width_selector + search_button_selector;
  1129. if( '' != border.top || '' != border.right || '' != border.bottom || '' != border.left ) {
  1130. if( astraCustomizer.gb_outline_buttons_patterns_support && ! astraCustomizer.updated_gb_outline_button_patterns ) {
  1131. wp.customize.preview.send( 'refresh' );
  1132. } else {
  1133. dynamicStyle += '{';
  1134. dynamicStyle += 'border-top-width:' + border.top + 'px;';
  1135. dynamicStyle += 'border-right-width:' + border.right + 'px;';
  1136. dynamicStyle += 'border-left-width:' + border.left + 'px;';
  1137. dynamicStyle += 'border-bottom-width:' + border.bottom + 'px;';
  1138. dynamicStyle += 'border-style: solid;';
  1139. dynamicStyle += '}';
  1140. astra_add_dynamic_css( 'theme-button-border-group-border-size', dynamicStyle );
  1141. }
  1142. } else {
  1143. if( astraCustomizer.gb_outline_buttons_patterns_support && ! astraCustomizer.updated_gb_outline_button_patterns ) {
  1144. wp.customize.preview.send( 'refresh' );
  1145. } else {
  1146. dynamicStyle += '{';
  1147. dynamicStyle += 'border-top-width: 0;';
  1148. dynamicStyle += 'border-right-width: 0;';
  1149. dynamicStyle += 'border-left-width: 0;';
  1150. dynamicStyle += 'border-bottom-width: 0;';
  1151. dynamicStyle += '}';
  1152. astra_add_dynamic_css( 'theme-button-border-group-border-size', dynamicStyle );
  1153. }
  1154. }
  1155. } );
  1156. } );
  1157. var search_button_selector = hasWordPressWidgetBlockEditor() ? ', form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button' : '' ;
  1158. astra_responsive_spacing( 'astra-settings[theme-button-padding]','.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .woocommerce a.button, .woocommerce button.button, .woocommerce .product a.button, .woocommerce .woocommerce-message a.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce input.button,.woocommerce input.button:disabled, .woocommerce input.button:disabled[disabled], .wp-block-button .wp-block-button__link' + ele_padding_selector + search_button_selector, 'padding', [ 'top', 'bottom' ] );
  1159. astra_responsive_spacing( 'astra-settings[theme-button-padding]','.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .woocommerce a.button, .woocommerce button.button, .woocommerce .product a.button, .woocommerce .woocommerce-message a.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce input.button,.woocommerce input.button:disabled, .woocommerce input.button:disabled[disabled], .wp-block-button .wp-block-button__link' + ele_padding_selector + search_button_selector, 'padding', [ 'left', 'right' ] );
  1160. /**
  1161. * Button border
  1162. */
  1163. wp.customize( 'astra-settings[transparent-header-button-border-group]', function( value ) {
  1164. value.bind( function( value ) {
  1165. var optionValue = JSON.parse(value);
  1166. var border = optionValue['header-main-rt-trans-section-button-border-size'];
  1167. if( '' != border.top || '' != border.right || '' != border.bottom || '' != border.left ) {
  1168. var dynamicStyle = '.ast-theme-transparent-header .main-header-bar .button-custom-menu-item .ast-custom-button-link .ast-custom-button';
  1169. dynamicStyle += '{';
  1170. dynamicStyle += 'border-top-width:' + border.top + 'px;';
  1171. dynamicStyle += 'border-right-width:' + border.right + 'px;';
  1172. dynamicStyle += 'border-left-width:' + border.left + 'px;';
  1173. dynamicStyle += 'border-bottom-width:' + border.bottom + 'px;';
  1174. dynamicStyle += 'border-style: solid;';
  1175. dynamicStyle += '}';
  1176. astra_add_dynamic_css( 'header-main-rt-trans-section-button-border-size', dynamicStyle );
  1177. }
  1178. } );
  1179. } );
  1180. // Site Title - Font family
  1181. astra_generate_outside_font_family_css( 'astra-settings[font-family-site-title]', '.site-title, .site-title a' );
  1182. // Site Title - Font Weight
  1183. astra_generate_font_weight_css( 'astra-settings[font-family-site-title]', 'astra-settings[font-weight-site-title]', 'font-weight', '.site-title, .site-title a' );
  1184. // Site Title - Font Size
  1185. astra_responsive_font_size( 'astra-settings[font-size-site-title]', '.site-title, .site-title a' );
  1186. // Site Title - Line Height
  1187. astra_css( 'astra-settings[line-height-site-title]', 'line-height', '.site-title, .site-title a' );
  1188. // Site Title - Text Transform
  1189. astra_css( 'astra-settings[text-transform-site-title]', 'text-transform', '.site-title, .site-title a' );
  1190. // Site tagline - Font family
  1191. astra_generate_outside_font_family_css( 'astra-settings[font-family-site-tagline]', '.site-header .site-description' );
  1192. // Site Tagline - Font Weight
  1193. astra_generate_font_weight_css( 'astra-settings[font-family-site-tagline]', 'astra-settings[font-weight-site-tagline]', 'font-weight', '.site-header .site-description' );
  1194. // Site Tagline - Font Size
  1195. astra_responsive_font_size( 'astra-settings[font-size-site-tagline]', '.site-header .site-description' );
  1196. // Site Tagline - Line Height
  1197. astra_css( 'astra-settings[line-height-site-tagline]', 'line-height', '.site-header .site-description' );
  1198. // Site Tagline - Text Transform
  1199. astra_css( 'astra-settings[text-transform-site-tagline]', 'text-transform', '.site-header .site-description' );
  1200. var search_button_selector = hasWordPressWidgetBlockEditor() ? ', form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button' : '' ;
  1201. var search_button_hover_selector = hasWordPressWidgetBlockEditor() ? ', form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button:hover, form[CLASS*="wp-block-search__"].wp-block-search .wp-block-search__inside-wrapper .wp-block-search__button:focus' : '' ;
  1202. if ( astraCustomizer.page_builder_button_style_css ) {
  1203. var btn_color_ele = '';
  1204. var btn_bg_color_ele = '';
  1205. var btn_h_color_ele = '';
  1206. var btn_bg_h_color_ele = '';
  1207. var btn_border_color_ele = '';
  1208. var btn_border_h_color_ele = '';
  1209. if ( 'color-typo' == astraCustomizer.elementor_default_color_font_setting || 'color' == astraCustomizer.elementor_default_color_font_setting ) {
  1210. // Theme Button - Text Color
  1211. btn_color_ele = ',.elementor-button-wrapper .elementor-button, .elementor-button-wrapper .elementor-button:visited';
  1212. // Theme Button - Background Color
  1213. btn_bg_color_ele = ',.elementor-button-wrapper .elementor-button, .elementor-button-wrapper .elementor-button:visited';
  1214. // Theme Button - Text Hover Color
  1215. btn_h_color_ele = ',.elementor-button-wrapper .elementor-button:hover, .elementor-button-wrapper .elementor-button:focus';
  1216. // Theme Button - Background Hover Color
  1217. btn_bg_h_color_ele = ',.elementor-button-wrapper .elementor-button:hover, .elementor-button-wrapper .elementor-button:focus';
  1218. // Theme Button - Border Color
  1219. btn_border_color_ele = ', .elementor-button-wrapper .elementor-button, .elementor-button-wrapper .elementor-button:visited';
  1220. // Theme Button - Border Hover Color
  1221. btn_border_h_color_ele = ',.elementor-button-wrapper .elementor-button:hover, .elementor-button-wrapper .elementor-button:focus';
  1222. }
  1223. var btnSelector = '.menu-toggle, button, .ast-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .wp-block-button .wp-block-button__link, .ast-custom-button' + btn_bg_color_ele + search_button_selector;
  1224. astraHandleButtonPresetPreview( btnSelector );
  1225. // Theme Button - Text Hover Color
  1226. astra_css( 'astra-settings[button-h-color]', 'color', 'button:focus, .menu-toggle:hover, button:hover, .ast-button:hover, .button:hover, input[type=reset]:hover, input[type=reset]:focus, input#submit:hover, input#submit:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .wp-block-button .wp-block-button__link:hover, .wp-block-button .wp-block-button__link:focus, .ast-custom-button:hover, .ast-custom-button:focus' + btn_h_color_ele + search_button_hover_selector );
  1227. // Theme Button - Background Hover Color
  1228. astra_css( 'astra-settings[button-bg-h-color]', 'background-color', 'button:focus, .menu-toggle:hover, button:hover, .ast-button:hover, .button:hover, input[type=reset]:hover, input[type=reset]:focus, input#submit:hover, input#submit:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .wp-block-button .wp-block-button__link:hover, .wp-block-button .wp-block-button__link:focus, .ast-custom-button:hover, .ast-custom-button:focus' + btn_bg_h_color_ele + search_button_hover_selector );
  1229. astra_css( 'astra-settings[theme-button-border-group-border-color]', 'border-color', '.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .wp-block-button .wp-block-button__link' + btn_border_color_ele + search_button_selector );
  1230. // Theme Button - Border Hover Color
  1231. astra_css( 'astra-settings[theme-button-border-group-border-h-color]', 'border-color', 'button:focus, .menu-toggle:hover, button:hover, .ast-button:hover, .ast-custom-button:hover, .button:hover, input[type=reset]:hover, input[type=reset]:focus, input#submit:hover, input#submit:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .wp-block-button .wp-block-button__link:hover, .wp-block-button .wp-block-button__link:focus' + btn_border_h_color_ele + search_button_hover_selector );
  1232. } else {
  1233. var btnSelector = '.menu-toggle, button, .ast-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .ast-custom-button' + search_button_selector;
  1234. astraHandleButtonPresetPreview( btnSelector );
  1235. // Theme Button - Border Color
  1236. astra_css( 'astra-settings[button-bg-color]', 'border-color', '.menu-toggle, button, .ast-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .ast-custom-button' + search_button_selector );
  1237. // Theme Button - Text Hover Color
  1238. astra_css( 'astra-settings[button-h-color]', 'color', 'button:focus, .menu-toggle:hover, button:hover, .ast-button:hover, .button:hover, input[type=reset]:hover, input[type=reset]:focus, input#submit:hover, input#submit:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .ast-custom-button:hover, .ast-custom-button:focus' + search_button_hover_selector );
  1239. // Theme Button - Background Hover Color
  1240. astra_css( 'astra-settings[button-bg-h-color]', 'background-color', 'button:focus, .menu-toggle:hover, button:hover, .ast-button:hover, .button:hover, input[type=reset]:hover, input[type=reset]:focus, input#submit:hover, input#submit:focus, input[type="button"]:hover, input[type="button"]:focus, input[type="submit"]:hover, input[type="submit"]:focus, .ast-custom-button:hover, .ast-custom-button:focus' + search_button_hover_selector );
  1241. astra_responsive_spacing( 'astra-settings[theme-button-padding]','.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .woocommerce a.button, .woocommerce button.button, .woocommerce .product a.button, .woocommerce .woocommerce-message a.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce input.button,.woocommerce input.button:disabled, .woocommerce input.button:disabled[disabled]' + search_button_selector, 'padding', [ 'top', 'bottom' ] );
  1242. astra_responsive_spacing( 'astra-settings[theme-button-padding]','.menu-toggle, button, .ast-button, .ast-custom-button, .button, input#submit, input[type="button"], input[type="submit"], input[type="reset"], .woocommerce a.button, .woocommerce button.button, .woocommerce .product a.button, .woocommerce .woocommerce-message a.button, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt, .woocommerce input.button,.woocommerce input.button:disabled, .woocommerce input.button:disabled[disabled]' + search_button_selector, 'padding', [ 'left', 'right' ] );
  1243. }
  1244. // Global custom event which triggers when partial refresh occurs.
  1245. wp.customize.bind('preview-ready', function () {
  1246. wp.customize.selectiveRefresh.bind('render-partials-response', function (response) {
  1247. if( response.contents.hasOwnProperty('astra-settings[footer-desktop-items]')
  1248. || ( ! ( response.contents.hasOwnProperty('astra-settings[header-desktop-items]')
  1249. || response.contents.hasOwnProperty('astra-settings[header-mobile-items]') ) ) ) {
  1250. return false;
  1251. }
  1252. setTimeout( function () {
  1253. document.dispatchEvent( new CustomEvent( "astLayoutWidthChanged", { "detail": { 'response' : response } }) );
  1254. }, 10 );
  1255. });
  1256. wp.customize.selectiveRefresh.bind('partial-content-rendered', function (response) {
  1257. if( response.partial.id.includes("footer") ) {
  1258. return false;
  1259. }
  1260. sessionStorage.setItem('astPartialContentRendered', true);
  1261. document.dispatchEvent( new CustomEvent( "astPartialContentRendered", { "detail": { 'response' : response } }) );
  1262. });
  1263. wp.customize.selectiveRefresh.bind('partial-content-rendered', function (response) {
  1264. wp.customize.preview.send( 'AstraBuilderPartialContentRendered', response );
  1265. });
  1266. wp.customize.preview.bind( 'astPreviewDeviceChanged', function( device ) {
  1267. document.dispatchEvent( new CustomEvent( "astPreviewDeviceChanged", { "detail": device }) );
  1268. } );
  1269. })
  1270. /**
  1271. * Related Posts Query Arguments - Customizer preview support.
  1272. */
  1273. wp.customize( 'astra-settings[related-posts-based-on]', function( setting ) {
  1274. setting.bind( function() {
  1275. wp.customize.preview.send( 'refresh' );
  1276. } );
  1277. } );
  1278. wp.customize( 'astra-settings[related-posts-order-by]', function( setting ) {
  1279. setting.bind( function() {
  1280. wp.customize.preview.send( 'refresh' );
  1281. } );
  1282. } );
  1283. wp.customize( 'astra-settings[related-posts-order]', function( setting ) {
  1284. setting.bind( function() {
  1285. wp.customize.preview.send( 'refresh' );
  1286. } );
  1287. } );
  1288. /**
  1289. * Related Posts color stylings.
  1290. */
  1291. astra_css( 'astra-settings[related-posts-text-color]', 'color', '.ast-related-post-content .entry-header .ast-related-post-title a, .ast-related-post-content .ast-related-post-excerpt' );
  1292. astra_css( 'astra-settings[related-posts-meta-color]', 'color', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1293. astra_css( 'astra-settings[related-posts-title-color]', 'color', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1294. astra_css( 'astra-settings[related-posts-background-color]', 'background-color', '.ast-single-related-posts-container' );
  1295. astra_css( 'astra-settings[related-posts-link-color]', 'color', '.ast-related-post-content .ast-related-post-cta a' );
  1296. astra_css( 'astra-settings[related-posts-link-hover-color]', 'color', '.ast-related-post-content .ast-related-post-cta a:hover' );
  1297. astra_css( 'astra-settings[related-posts-meta-link-hover-color]', 'color', '.ast-related-post-content .entry-meta a:hover, .ast-related-post-content .entry-meta span a span:hover' );
  1298. // Related Posts - Customizer preview for Post Title.
  1299. astra_generate_outside_font_family_css( 'astra-settings[related-posts-title-font-family]', '.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' );
  1300. astra_css( 'astra-settings[related-posts-title-font-weight]', 'font-weight', '.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' );
  1301. astra_responsive_font_size( 'astra-settings[related-posts-title-font-size]', '.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' );
  1302. astra_css( 'astra-settings[related-posts-title-line-height]', 'line-height', '.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' );
  1303. astra_css( 'astra-settings[related-posts-title-text-transform]', 'text-transform', '.ast-related-post-content .entry-header .ast-related-post-title, .ast-related-post-content .entry-header .ast-related-post-title a' );
  1304. // Related Posts - Customizer preview for Section Title.
  1305. astra_generate_outside_font_family_css( 'astra-settings[related-posts-section-title-font-family]', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1306. astra_css( 'astra-settings[related-posts-section-title-font-weight]', 'font-weight', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1307. astra_responsive_font_size( 'astra-settings[related-posts-section-title-font-size]', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1308. astra_css( 'astra-settings[related-posts-section-title-line-height]', 'line-height', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1309. astra_css( 'astra-settings[related-posts-section-title-text-transform]', 'text-transform', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1310. astra_css( 'astra-settings[releted-posts-title-alignment]', 'text-align', '.ast-single-related-posts-container .ast-related-posts-title-section .ast-related-posts-title' );
  1311. // Related Posts - Customizer preview for Post Meta.
  1312. astra_generate_outside_font_family_css( 'astra-settings[related-posts-meta-font-family]', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1313. astra_css( 'astra-settings[related-posts-meta-font-weight]', 'font-weight', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1314. astra_responsive_font_size( 'astra-settings[related-posts-meta-font-size]', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1315. astra_css( 'astra-settings[related-posts-meta-line-height]', 'line-height', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1316. astra_css( 'astra-settings[related-posts-meta-text-transform]', 'text-transform', '.ast-related-post-content .entry-meta, .ast-related-post-content .entry-meta *' );
  1317. // Related Posts - Customizer preview for Post Content.
  1318. astra_generate_outside_font_family_css( 'astra-settings[related-posts-content-font-family]', '.ast-related-post-content .ast-related-post-excerpt' );
  1319. astra_css( 'astra-settings[related-posts-content-font-weight]', 'font-weight', '.ast-related-post-content .ast-related-post-excerpt' );
  1320. astra_responsive_font_size( 'astra-settings[related-posts-content-font-size]', '.ast-related-post-content .ast-related-post-excerpt' );
  1321. astra_css( 'astra-settings[related-posts-content-line-height]', 'line-height', '.ast-related-post-content .ast-related-post-excerpt' );
  1322. astra_css( 'astra-settings[related-posts-content-text-transform]', 'text-transform', '.ast-related-post-content .ast-related-post-excerpt' );
  1323. // Title Color.
  1324. astra_css(
  1325. 'astra-settings[header-color-site-title]',
  1326. 'color',
  1327. '.ast-site-identity .site-title a, .ast-site-identity .site-title'
  1328. );
  1329. // Title Hover Color.
  1330. astra_css(
  1331. 'astra-settings[header-color-h-site-title]',
  1332. 'color',
  1333. '.ast-site-identity .site-title a:hover, .ast-site-identity .site-title:hover'
  1334. );
  1335. // Tagline Color.
  1336. astra_css(
  1337. 'astra-settings[header-color-site-tagline]',
  1338. 'color',
  1339. '.ast-site-identity .site-description'
  1340. );
  1341. function astraHandleButtonPresetPreview( btnSelector ) {
  1342. wp.customize( 'astra-settings[button-preset-style]', function( setting ) {
  1343. setting.bind( function( value ) {
  1344. var buttonBGColor = wp.customize( 'astra-settings[button-bg-color]' ).get();
  1345. var buttonTextColor = wp.customize( 'astra-settings[button-color]' ).get();
  1346. var themeColor = wp.customize( 'astra-settings[theme-color]' ).get();
  1347. if( 'button_04' === value || 'button_05' === value || 'button_06' === value ) {
  1348. var buttonBorderColor = wp.customize( 'astra-settings[theme-button-border-group-border-color]' ).get();
  1349. if( '' === buttonBorderColor ) {
  1350. jQuery( 'style#astra-settings-theme-button-border-group-border-color' ).remove();
  1351. // Theme Button - Background Color
  1352. jQuery( 'head' ).append(
  1353. '<style id="astra-settings-theme-button-border-group-border-color">'
  1354. + btnSelector + ' { border-color: ' + buttonBGColor + ' }'
  1355. + '</style>'
  1356. );
  1357. }
  1358. if( '' === buttonTextColor && '' !== buttonBGColor ) {
  1359. jQuery( 'style#astra-settings-button-outline-preset-color' ).remove();
  1360. jQuery( 'head' ).append(
  1361. '<style id="astra-settings-button-outline-preset-color">'
  1362. + btnSelector + ' { color: ' + buttonBGColor + ' }'
  1363. + '</style>'
  1364. );
  1365. }
  1366. if( '' === buttonTextColor && '' === buttonBGColor ) {
  1367. jQuery( 'style#astra-settings-button-outline-preset-color' ).remove();
  1368. jQuery( 'head' ).append(
  1369. '<style id="astra-settings-button-outline-preset-color">'
  1370. + btnSelector + ' { color: ' + themeColor + ' }'
  1371. + '</style>'
  1372. );
  1373. }
  1374. // Remove old.
  1375. jQuery( 'style#astra-settings-button-preset-style-background-color' ).remove();
  1376. // Concat and append new <style>.
  1377. jQuery( 'head' ).append(
  1378. '<style id="astra-settings-button-preset-style-background-color">'
  1379. + btnSelector + ' { background: transparent }'
  1380. + '</style>'
  1381. );
  1382. } else {
  1383. jQuery( 'style#astra-settings-button-bg-color-background-color' ).remove();
  1384. jQuery( 'style#astra-settings-button-outline-preset-color' ).remove();
  1385. if( '' === buttonTextColor && '' === buttonBGColor ) {
  1386. jQuery( 'head' ).append(
  1387. '<style id="astra-settings-button-bg-color-background-color">'
  1388. + btnSelector + ' { background-color: ' + themeColor + ' }'
  1389. + '</style>'
  1390. );
  1391. } else {
  1392. // Set background color for button to theme color when value is empty.
  1393. buttonBGColor = ( '' != buttonBGColor ) ? buttonBGColor : themeColor;
  1394. // Theme Button - Background Color
  1395. jQuery( 'head' ).append(
  1396. '<style id="astra-settings-button-bg-color-background-color">'
  1397. + btnSelector + ' { background-color: ' + buttonBGColor + ' }'
  1398. + '</style>'
  1399. );
  1400. }
  1401. if( '' === buttonTextColor ) {
  1402. // Set button text color to white when value is empty.
  1403. jQuery( 'head' ).append(
  1404. '<style id="astra-settings-button-outline-preset-color">'
  1405. + btnSelector + ' { color: #FFFFFF; }'
  1406. + '</style>'
  1407. );
  1408. jQuery( 'style#astra-settings-button-color-color' ).remove();
  1409. }
  1410. }
  1411. } );
  1412. } );
  1413. wp.customize( 'astra-settings[button-color]', function( setting ) {
  1414. setting.bind( function( value ) {
  1415. if( '' === value ) {
  1416. var buttonPreset = wp.customize( 'astra-settings[button-preset-style]' ).get();
  1417. // If button has outline preset.
  1418. if( 'button_04' === buttonPreset || 'button_05' === buttonPreset || 'button_06' === buttonPreset ) {
  1419. var buttonBGColor = wp.customize( 'astra-settings[button-bg-color]' ).get();
  1420. jQuery( 'style#astra-settings-button-outline-color' ).remove();
  1421. // Theme Button - Background Color
  1422. jQuery( 'head' ).append(
  1423. '<style id="astra-settings-button-color-color">'
  1424. + btnSelector + ' { color: ' + buttonBGColor + ' }'
  1425. + '</style>'
  1426. );
  1427. } else {
  1428. jQuery( 'style#astra-settings-button-color-color' ).remove();
  1429. // Theme Button - Background Color
  1430. jQuery( 'head' ).append(
  1431. '<style id="astra-settings-button-color-color">'
  1432. + btnSelector + ' { color: #FFFFFF }'
  1433. + '</style>'
  1434. );
  1435. }
  1436. } else {
  1437. jQuery( 'style#astra-settings-button-color-color' ).remove();
  1438. // Theme Button - Background Color
  1439. jQuery( 'head' ).append(
  1440. '<style id="astra-settings-button-color-color">'
  1441. + btnSelector + ' { color: ' + value + ' }'
  1442. + '</style>'
  1443. );
  1444. }
  1445. } );
  1446. } );
  1447. wp.customize( 'astra-settings[button-bg-color]', function( setting ) {
  1448. setting.bind( function( value ) {
  1449. var buttonPreset = wp.customize( 'astra-settings[button-preset-style]' ).get();
  1450. var themeColor = wp.customize( 'astra-settings[theme-color]' ).get();
  1451. var buttonTextColor = wp.customize( 'astra-settings[button-color]' ).get();
  1452. // If button has outline preset.
  1453. if( 'button_04' === buttonPreset || 'button_05' === buttonPreset || 'button_06' === buttonPreset ) {
  1454. var buttonTextColor = wp.customize( 'astra-settings[button-color]' ).get();
  1455. var buttonBorderColor = wp.customize( 'astra-settings[theme-button-border-group-border-color]' ).get();
  1456. if( '' === buttonBorderColor ) {
  1457. // Theme Button - Background Color
  1458. jQuery( 'style#astra-settings-theme-button-border-group-border-color' ).remove();
  1459. // Theme Button - Background Color
  1460. jQuery( 'head' ).append(
  1461. '<style id="astra-settings-theme-button-border-group-border-color">'
  1462. + btnSelector + ' { border-color: ' + value + ' }'
  1463. + '</style>'
  1464. );
  1465. }
  1466. if( '' === buttonTextColor ) {
  1467. jQuery( 'style#astra-settings-button-outline-preset-color' ).remove();
  1468. jQuery( 'head' ).append(
  1469. '<style id="astra-settings-button-outline-preset-color">'
  1470. + btnSelector + ' { color: ' + value + ' }'
  1471. + '</style>'
  1472. );
  1473. }
  1474. } else {
  1475. jQuery( 'style#astra-settings-button-bg-color-background-color' ).remove();
  1476. jQuery( 'style#astra-settings-button-outline-preset-color' ).remove();
  1477. // Set background color for button to theme color when value is empty.
  1478. value = ( '' != value ) ? value : themeColor;
  1479. if( '' === buttonTextColor ) {
  1480. jQuery( 'head' ).append(
  1481. '<style id="astra-settings-button-outline-preset-color">'
  1482. + btnSelector + ' { color: #FFFFFF; }'
  1483. + '</style>'
  1484. );
  1485. }
  1486. // Theme Button - Background Color
  1487. jQuery( 'head' ).append(
  1488. '<style id="stra-settings-button-bg-color-background-color">'
  1489. + btnSelector + ' { background-color: ' + value + ' }'
  1490. + '</style>'
  1491. );
  1492. }
  1493. } );
  1494. } );
  1495. }
  1496. } )( jQuery );