| 1 |
( function( $ ) { |
| 2 |
|
| 3 |
"use strict"; |
| 4 |
|
| 5 |
/** |
| 6 |
* Adds <style> to <head>, replace if such exist |
| 7 |
* |
| 8 |
* @param $style_id |
| 9 |
* style id |
| 10 |
* @param $new_style |
| 11 |
* <style id="...">...</style> |
| 12 |
*/ |
| 13 |
function mphb_divi_add_new_style($style_id, $new_style){ |
| 14 |
|
| 15 |
var $style_old = $('#'+$style_id); |
| 16 |
|
| 17 |
if ( $style_old.length ) { |
| 18 |
$style_old.replaceWith( $new_style ); |
| 19 |
} else { |
| 20 |
$( 'head' ).append( $new_style ); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Forms font style css |
| 26 |
* |
| 27 |
* @param value |
| 28 |
* font styles |
| 29 |
* @param important_tag |
| 30 |
* important tag |
| 31 |
* @returns {string} |
| 32 |
* font style css |
| 33 |
*/ |
| 34 |
function mphb_divi_font_styles( value, important_tag ) { |
| 35 |
var font_styles = value.split( '|' ), |
| 36 |
style = ''; |
| 37 |
|
| 38 |
if ( $.inArray( 'bold', font_styles ) >= 0 ) { |
| 39 |
style += "font-weight: bold " + important_tag + ";"; |
| 40 |
} else { |
| 41 |
style += "font-weight: inherit " + important_tag + ";"; |
| 42 |
} |
| 43 |
|
| 44 |
if ( $.inArray( 'italic', font_styles ) >= 0 ) { |
| 45 |
style += "font-style: italic " + important_tag + ";"; |
| 46 |
} else { |
| 47 |
style += "font-style: inherit " + important_tag + ";"; |
| 48 |
} |
| 49 |
|
| 50 |
if ( $.inArray( 'underline', font_styles ) >= 0 ) { |
| 51 |
style += "text-decoration: underline " + important_tag + ";"; |
| 52 |
} else { |
| 53 |
style += "text-decoration: inherit " + important_tag + ";"; |
| 54 |
} |
| 55 |
|
| 56 |
if ( $.inArray( 'uppercase', font_styles ) >= 0 ) { |
| 57 |
style += "text-transform: uppercase " + important_tag + ";"; |
| 58 |
} else { |
| 59 |
style += "text-transform: inherit " + important_tag + ";"; |
| 60 |
} |
| 61 |
|
| 62 |
return style; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* button font size css |
| 67 |
*/ |
| 68 |
wp.customize( 'et_divi[all_buttons_font_size]', function( value ) { |
| 69 |
value.bind( function( to ) { |
| 70 |
|
| 71 |
var $button_style = '<style id="mphb-divi-button-font-size">' + |
| 72 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 73 |
'.mphb_sc_search-wrapper .button,'+ |
| 74 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 75 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 76 |
'.mphb_sc_room-wrapper .button,'+ |
| 77 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 78 |
'.widget_mphb_rooms_widget .button,'+ |
| 79 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 80 |
'.mphb-booking-form .button{'+ |
| 81 |
'font-size:' + to + 'px !important;'+ |
| 82 |
'}'+ |
| 83 |
'</style>'; |
| 84 |
|
| 85 |
mphb_divi_add_new_style('mphb-divi-button-font-size', $button_style); |
| 86 |
|
| 87 |
} ); |
| 88 |
} ); |
| 89 |
|
| 90 |
/** |
| 91 |
* button text color css |
| 92 |
*/ |
| 93 |
wp.customize( 'et_divi[all_buttons_text_color]', function( value ) { |
| 94 |
value.bind( function( to ) { |
| 95 |
|
| 96 |
var $button_style = '<style id="mphb-divi-button-text-color">' + |
| 97 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 98 |
'.mphb_sc_search-wrapper .button,'+ |
| 99 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 100 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 101 |
'.mphb_sc_room-wrapper .button,'+ |
| 102 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 103 |
'.widget_mphb_rooms_widget .button,'+ |
| 104 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 105 |
'.mphb-booking-form .button{'+ |
| 106 |
'color:' + to + ' !important;'+ |
| 107 |
'}'+ |
| 108 |
'</style>'; |
| 109 |
|
| 110 |
mphb_divi_add_new_style('mphb-divi-button-text-color', $button_style); |
| 111 |
|
| 112 |
} ); |
| 113 |
} ); |
| 114 |
|
| 115 |
/** |
| 116 |
* button bg color css |
| 117 |
*/ |
| 118 |
wp.customize( 'et_divi[all_buttons_bg_color]', function( value ) { |
| 119 |
value.bind( function( to ) { |
| 120 |
|
| 121 |
var $button_style = '<style id="mphb-divi-button-bg-color">' + |
| 122 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 123 |
'.mphb_sc_search-wrapper .button,'+ |
| 124 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 125 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 126 |
'.mphb_sc_room-wrapper .button,'+ |
| 127 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 128 |
'.widget_mphb_rooms_widget .button,'+ |
| 129 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 130 |
'.mphb-booking-form .button{'+ |
| 131 |
'background:' + to + ' !important;'+ |
| 132 |
'}'+ |
| 133 |
'</style>'; |
| 134 |
|
| 135 |
mphb_divi_add_new_style('mphb-divi-button-bg-color', $button_style); |
| 136 |
|
| 137 |
} ); |
| 138 |
|
| 139 |
} ); |
| 140 |
|
| 141 |
/** |
| 142 |
* button border width css |
| 143 |
*/ |
| 144 |
wp.customize( 'et_divi[all_buttons_border_width]', function( value ) { |
| 145 |
value.bind( function( to ) { |
| 146 |
|
| 147 |
var $button_style = '<style id="mphb-divi-button-border-width">' + |
| 148 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 149 |
'.mphb_sc_search-wrapper .button,'+ |
| 150 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 151 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 152 |
'.mphb_sc_room-wrapper .button,'+ |
| 153 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 154 |
'.widget_mphb_rooms_widget .button,'+ |
| 155 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 156 |
'.mphb-booking-form .button{'+ |
| 157 |
'border-width:' + to + 'px !important;'+ |
| 158 |
'}'+ |
| 159 |
'</style>'; |
| 160 |
|
| 161 |
mphb_divi_add_new_style('mphb-divi-button-border-width', $button_style); |
| 162 |
|
| 163 |
} ); |
| 164 |
} ); |
| 165 |
|
| 166 |
/** |
| 167 |
* button border color css |
| 168 |
*/ |
| 169 |
wp.customize( 'et_divi[all_buttons_border_color]', function( value ) { |
| 170 |
value.bind( function( to ) { |
| 171 |
|
| 172 |
var $button_style = '<style id="mphb-divi-button-border-color">' + |
| 173 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 174 |
'.mphb_sc_search-wrapper .button,'+ |
| 175 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 176 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 177 |
'.mphb_sc_room-wrapper .button,'+ |
| 178 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 179 |
'.widget_mphb_rooms_widget .button,'+ |
| 180 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 181 |
'.mphb-booking-form .button{'+ |
| 182 |
'border-color:' + to + ' !important;'+ |
| 183 |
'}'+ |
| 184 |
'</style>'; |
| 185 |
|
| 186 |
mphb_divi_add_new_style('mphb-divi-button-border-color', $button_style); |
| 187 |
|
| 188 |
} ); |
| 189 |
} ); |
| 190 |
|
| 191 |
/** |
| 192 |
* button border radius css |
| 193 |
*/ |
| 194 |
wp.customize( 'et_divi[all_buttons_border_radius]', function( value ) { |
| 195 |
value.bind( function( to ) { |
| 196 |
|
| 197 |
var $button_style = '<style id="mphb-divi-button-border-radius">' + |
| 198 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 199 |
'.mphb_sc_search-wrapper .button,'+ |
| 200 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 201 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 202 |
'.mphb_sc_room-wrapper .button,'+ |
| 203 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 204 |
'.widget_mphb_rooms_widget .button,'+ |
| 205 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 206 |
'.mphb-booking-form .button{'+ |
| 207 |
'border-radius:' + to + 'px !important;'+ |
| 208 |
'}'+ |
| 209 |
'</style>'; |
| 210 |
|
| 211 |
mphb_divi_add_new_style('mphb-divi-button-border-radius', $button_style); |
| 212 |
|
| 213 |
} ); |
| 214 |
} ); |
| 215 |
|
| 216 |
/** |
| 217 |
* button font style css |
| 218 |
*/ |
| 219 |
wp.customize( 'et_divi[all_buttons_font_style]', function( value ) { |
| 220 |
value.bind( function( to ) { |
| 221 |
var $font_style = mphb_divi_font_styles(to, ''), |
| 222 |
$button_style = '<style id="mphb-divi-button-font-style">' + |
| 223 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 224 |
'.mphb_sc_search-wrapper .button,'+ |
| 225 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 226 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 227 |
'.mphb_sc_room-wrapper .button,'+ |
| 228 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 229 |
'.widget_mphb_rooms_widget .button,'+ |
| 230 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 231 |
'.mphb-booking-form .button{'+$font_style+'}'+ |
| 232 |
'</style>'; |
| 233 |
|
| 234 |
mphb_divi_add_new_style('mphb-divi-button-font-style', $button_style); |
| 235 |
|
| 236 |
} ); |
| 237 |
} ); |
| 238 |
|
| 239 |
/** |
| 240 |
* button letter spacing css |
| 241 |
*/ |
| 242 |
wp.customize( 'et_divi[all_buttons_spacing]', function( value ) { |
| 243 |
value.bind( function( to ) { |
| 244 |
|
| 245 |
var $button_style = '<style id="mphb-divi-button-spacing">' + |
| 246 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 247 |
'.mphb_sc_search-wrapper .button,'+ |
| 248 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 249 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 250 |
'.mphb_sc_room-wrapper .button,'+ |
| 251 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 252 |
'.widget_mphb_rooms_widget .button,'+ |
| 253 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 254 |
'.mphb-booking-form .button{'+ |
| 255 |
'letter-spacing:' + to +'px; !important}'+ |
| 256 |
'</style>'; |
| 257 |
|
| 258 |
mphb_divi_add_new_style('mphb-divi-button-spacing', $button_style); |
| 259 |
|
| 260 |
} ); |
| 261 |
} ); |
| 262 |
|
| 263 |
/** |
| 264 |
* button font css |
| 265 |
*/ |
| 266 |
wp.customize( 'et_divi[all_buttons_font]', function( value ) { |
| 267 |
value.bind( function( to ) { |
| 268 |
|
| 269 |
var $button_style = '<style id="mphb-divi-button-font">' + |
| 270 |
'.mphb_sc_rooms-wrapper .button,'+ |
| 271 |
'.mphb_sc_search-wrapper .button,'+ |
| 272 |
'.mphb_sc_search_results-wrapper .button,'+ |
| 273 |
'.mphb_sc_checkout-wrapper .button,'+ |
| 274 |
'.mphb_sc_room-wrapper .button,'+ |
| 275 |
'.mphb_sc_booking_form-wrapper .button,'+ |
| 276 |
'.widget_mphb_rooms_widget .button,'+ |
| 277 |
'.widget_mphb_search_availability_widget form .button,'+ |
| 278 |
'.mphb-booking-form .button{'+ |
| 279 |
'font-family:' + to +', sans-serif !important; }'+ |
| 280 |
'</style>'; |
| 281 |
|
| 282 |
mphb_divi_add_new_style('mphb-divi-button-font', $button_style); |
| 283 |
|
| 284 |
} ); |
| 285 |
} ); |
| 286 |
|
| 287 |
/** |
| 288 |
* button hover color css |
| 289 |
*/ |
| 290 |
wp.customize( 'et_divi[all_buttons_text_color_hover]', function( value ) { |
| 291 |
value.bind( function( to ) { |
| 292 |
|
| 293 |
var $button_style = '<style id="mphb-divi-button-text-color-hover">' + |
| 294 |
'.mphb_sc_rooms-wrapper .button:hover,'+ |
| 295 |
'.mphb_sc_search-wrapper .button:hover,'+ |
| 296 |
'.mphb_sc_search_results-wrapper .button:hover,'+ |
| 297 |
'.mphb_sc_checkout-wrapper .button:hover,'+ |
| 298 |
'.mphb_sc_room-wrapper .button:hover,'+ |
| 299 |
'.mphb_sc_booking_form-wrapper .button:hover,'+ |
| 300 |
'.widget_mphb_rooms_widget .button:hover,'+ |
| 301 |
'.widget_mphb_search_availability_widget form .button:hover,'+ |
| 302 |
'.mphb-booking-form .button:hover{'+ |
| 303 |
'color:' + to +' !important; }'+ |
| 304 |
'</style>'; |
| 305 |
|
| 306 |
mphb_divi_add_new_style('mphb-divi-button-text-color-hover', $button_style); |
| 307 |
|
| 308 |
} ); |
| 309 |
} ); |
| 310 |
|
| 311 |
/** |
| 312 |
* button hover bg color css |
| 313 |
*/ |
| 314 |
wp.customize( 'et_divi[all_buttons_bg_color_hover]', function( value ) { |
| 315 |
value.bind( function( to ) { |
| 316 |
|
| 317 |
var $button_style = '<style id="mphb-divi-button-bg-color-hover">' + |
| 318 |
'.mphb_sc_rooms-wrapper .button:hover,'+ |
| 319 |
'.mphb_sc_search-wrapper .button:hover,'+ |
| 320 |
'.mphb_sc_search_results-wrapper .button:hover,'+ |
| 321 |
'.mphb_sc_checkout-wrapper .button:hover,'+ |
| 322 |
'.mphb_sc_room-wrapper .button:hover,'+ |
| 323 |
'.mphb_sc_booking_form-wrapper .button:hover,'+ |
| 324 |
'.widget_mphb_rooms_widget .button:hover,'+ |
| 325 |
'.widget_mphb_search_availability_widget form .button:hover,'+ |
| 326 |
'.mphb-booking-form .button:hover{'+ |
| 327 |
'background:' + to +' !important; }'+ |
| 328 |
'</style>'; |
| 329 |
|
| 330 |
mphb_divi_add_new_style('mphb-divi-button-bg-color-hover', $button_style); |
| 331 |
|
| 332 |
} ); |
| 333 |
} ); |
| 334 |
|
| 335 |
/** |
| 336 |
* button hover border color css |
| 337 |
*/ |
| 338 |
wp.customize( 'et_divi[all_buttons_border_color_hover]', function( value ) { |
| 339 |
value.bind( function( to ) { |
| 340 |
|
| 341 |
var $button_style = '<style id="mphb-divi-button-border-color-hover">' + |
| 342 |
'.mphb_sc_rooms-wrapper .button:hover,'+ |
| 343 |
'.mphb_sc_search-wrapper .button:hover,'+ |
| 344 |
'.mphb_sc_search_results-wrapper .button:hover,'+ |
| 345 |
'.mphb_sc_checkout-wrapper .button:hover,'+ |
| 346 |
'.mphb_sc_room-wrapper .button:hover,'+ |
| 347 |
'.mphb_sc_booking_form-wrapper .button:hover,'+ |
| 348 |
'.widget_mphb_rooms_widget .button:hover,'+ |
| 349 |
'.widget_mphb_search_availability_widget form .button:hover,'+ |
| 350 |
'.mphb-booking-form .button:hover{'+ |
| 351 |
'border-color:' + to +' !important; }'+ |
| 352 |
'</style>'; |
| 353 |
|
| 354 |
mphb_divi_add_new_style('mphb-divi-button-border-color-hover', $button_style); |
| 355 |
|
| 356 |
} ); |
| 357 |
} ); |
| 358 |
|
| 359 |
/** |
| 360 |
* button hover border radius css |
| 361 |
*/ |
| 362 |
wp.customize( 'et_divi[all_buttons_border_radius_hover]', function( value ) { |
| 363 |
value.bind( function( to ) { |
| 364 |
|
| 365 |
var $button_style = '<style id="mphb-divi-button-border-radius-hover">' + |
| 366 |
'.mphb_sc_rooms-wrapper .button:hover,'+ |
| 367 |
'.mphb_sc_search-wrapper .button:hover,'+ |
| 368 |
'.mphb_sc_search_results-wrapper .button:hover,'+ |
| 369 |
'.mphb_sc_checkout-wrapper .button:hover,'+ |
| 370 |
'.mphb_sc_room-wrapper .button:hover,'+ |
| 371 |
'.mphb_sc_booking_form-wrapper .button:hover,'+ |
| 372 |
'.widget_mphb_rooms_widget .button:hover,'+ |
| 373 |
'.widget_mphb_search_availability_widget form .button:hover,'+ |
| 374 |
'.mphb-booking-form .button:hover{'+ |
| 375 |
'border-radius:' + to +'px !important; }'+ |
| 376 |
'</style>'; |
| 377 |
|
| 378 |
mphb_divi_add_new_style('mphb-divi-button-border-radius-hover', $button_style); |
| 379 |
|
| 380 |
} ); |
| 381 |
} ); |
| 382 |
|
| 383 |
/** |
| 384 |
* button hover letter spacing css |
| 385 |
*/ |
| 386 |
wp.customize( 'et_divi[all_buttons_spacing_hover]', function( value ) { |
| 387 |
value.bind( function( to ) { |
| 388 |
|
| 389 |
var $button_style = '<style id="mphb-divi-button-spacing-hover">' + |
| 390 |
'.mphb_sc_rooms-wrapper .button:hover,'+ |
| 391 |
'.mphb_sc_search-wrapper .button:hover,'+ |
| 392 |
'.mphb_sc_search_results-wrapper .button:hover,'+ |
| 393 |
'.mphb_sc_checkout-wrapper .button:hover,'+ |
| 394 |
'.mphb_sc_room-wrapper .button:hover,'+ |
| 395 |
'.mphb_sc_booking_form-wrapper .button:hover,'+ |
| 396 |
'.widget_mphb_rooms_widget .button:hover,'+ |
| 397 |
'.widget_mphb_search_availability_widget form .button:hover,'+ |
| 398 |
'.mphb-booking-form .button:hover{'+ |
| 399 |
'letter-spacing: '+ to +'px !important; }'+ |
| 400 |
'</style>'; |
| 401 |
|
| 402 |
mphb_divi_add_new_style('mphb-divi-button-spacing-hover', $button_style); |
| 403 |
|
| 404 |
} ); |
| 405 |
} ); |
| 406 |
|
| 407 |
|
| 408 |
})(jQuery); |