| 1 |
(function($){ |
| 2 |
'use strict'; |
| 3 |
$(document).ready(function(){ |
| 4 |
|
| 5 |
var defaultColors = { |
| 6 |
classicLight: { |
| 7 |
surveyColor: "#ff5722", |
| 8 |
bgColor: "#fff", |
| 9 |
textColor: "#333", |
| 10 |
buttonsTextColor: "#333", |
| 11 |
buttonsBgColor: "#fff", |
| 12 |
startPageBgColor: "#fff", |
| 13 |
startPageTextColor: "#333", |
| 14 |
titleTextShadColor: "#333", |
| 15 |
paginationTextColor: "#333", |
| 16 |
fullScreenButtonColor: "#333", |
| 17 |
questionCaptionTextColor: "#333", |
| 18 |
}, |
| 19 |
classicDark: { |
| 20 |
surveyColor: "#ff5722", |
| 21 |
bgColor: "#333", |
| 22 |
textColor: "#fff", |
| 23 |
buttonsTextColor: "#333", |
| 24 |
startPageBgColor: "#333", |
| 25 |
startPageTextColor: "#fff", |
| 26 |
buttonsBgColor: "#fff", |
| 27 |
titleTextShadColor: "#333", |
| 28 |
paginationTextColor: "#fff", |
| 29 |
fullScreenButtonColor: "#fff", |
| 30 |
questionCaptionTextColor: "#fff", |
| 31 |
}, |
| 32 |
minimal: { |
| 33 |
surveyColor: "rgba(0,0,0,0)", |
| 34 |
bgColor: "#ffffff", //"rgba(0,0,0,0)", |
| 35 |
textColor: "#0a0a0a", |
| 36 |
loaderColor: "#333", |
| 37 |
buttonsTextColor: "#0a0a0a", |
| 38 |
startPageBgColor: "rgba(0,0,0,0)", |
| 39 |
startPageTextColor: "#0a0a0a", |
| 40 |
questionCaptionTextColor: "#0a0a0a", |
| 41 |
}, |
| 42 |
modern: { |
| 43 |
surveyColor: "rgba(0,0,0,0)", |
| 44 |
bgColor: "#ffffff", //"rgba(0,0,0,0)", |
| 45 |
textColor: "#0a0a0a", |
| 46 |
loaderColor: "#333", |
| 47 |
buttonsTextColor: "#fff", |
| 48 |
startPageBgColor: "rgba(0,0,0,0)", |
| 49 |
startPageTextColor: "#0a0a0a", |
| 50 |
buttonsBgColor: "#4285F4", |
| 51 |
startPageBgColor: "rgba(0,0,0,0)", |
| 52 |
startPageTextColor: "#0a0a0a", |
| 53 |
questionCaptionTextColor: "#0a0a0a", |
| 54 |
adminNoteColor: "#000000", |
| 55 |
questionsStarsColor: "#fc0", |
| 56 |
sliderBubbleBgColor: "#4285F4", |
| 57 |
sliderBubbleTextColor: "#fff", |
| 58 |
}, |
| 59 |
}; |
| 60 |
|
| 61 |
$(document).find('input[name="ays_survey_theme"]').on("change", function(e){ |
| 62 |
surveyThemeChange( $(this).val() ); |
| 63 |
}); |
| 64 |
|
| 65 |
var SurveyTheme = $(document).find('input[name="ays_survey_theme"]:checked').val(); |
| 66 |
surveyThemeSetup( SurveyTheme ); |
| 67 |
|
| 68 |
function surveyThemeChange( SurveyTheme ){ |
| 69 |
var defaultTextColor, |
| 70 |
defaultLoaderColor, |
| 71 |
defaultBgColor, |
| 72 |
defaultStartPageBgColor, |
| 73 |
defaultStartPageTextColor, |
| 74 |
defaultSurveyColor, |
| 75 |
defaultButtonsTextColor, |
| 76 |
defaultButtonsBgColor, |
| 77 |
defaultTitleTShColor, |
| 78 |
defaultPaginationTextColor, |
| 79 |
defaultFullScreenButtonColor, |
| 80 |
defaultQestionCaptionTextColor; |
| 81 |
|
| 82 |
switch ( SurveyTheme ) { |
| 83 |
case 'classic_dark': |
| 84 |
defaultSurveyColor = defaultColors.classicDark.surveyColor; |
| 85 |
defaultBgColor = defaultColors.classicDark.bgColor; |
| 86 |
defaultTextColor = defaultColors.classicDark.textColor; |
| 87 |
defaultLoaderColor = defaultColors.classicDark.loaderColor; |
| 88 |
defaultButtonsTextColor = defaultColors.classicDark.buttonsTextColor; |
| 89 |
defaultStartPageBgColor = defaultColors.classicDark.startPageBgColor; |
| 90 |
defaultStartPageTextColor = defaultColors.classicDark.startPageTextColor; |
| 91 |
defaultButtonsBgColor = defaultColors.classicDark.buttonsBgColor; |
| 92 |
defaultTitleTShColor = defaultColors.classicDark.titleTextShadColor; |
| 93 |
defaultPaginationTextColor = defaultColors.classicDark.paginationTextColor; |
| 94 |
defaultFullScreenButtonColor = defaultColors.classicDark.fullScreenButtonColor; |
| 95 |
defaultQestionCaptionTextColor = defaultColors.classicDark.questionCaptionTextColor; |
| 96 |
break; |
| 97 |
case 'classic_light': |
| 98 |
defaultSurveyColor = defaultColors.classicLight.surveyColor; |
| 99 |
defaultBgColor = defaultColors.classicLight.bgColor; |
| 100 |
defaultTextColor = defaultColors.classicLight.textColor; |
| 101 |
defaultLoaderColor = defaultColors.classicLight.loaderColor; |
| 102 |
defaultButtonsTextColor = defaultColors.classicLight.buttonsTextColor; |
| 103 |
defaultStartPageBgColor = defaultColors.classicLight.startPageBgColor; |
| 104 |
defaultStartPageTextColor = defaultColors.classicLight.startPageTextColor; |
| 105 |
defaultButtonsBgColor = defaultColors.classicLight.buttonsBgColor; |
| 106 |
defaultTitleTShColor = defaultColors.classicLight.titleTextShadColor; |
| 107 |
defaultPaginationTextColor = defaultColors.classicLight.paginationTextColor; |
| 108 |
defaultFullScreenButtonColor = defaultColors.classicLight.fullScreenButtonColor; |
| 109 |
defaultQestionCaptionTextColor = defaultColors.classicLight.questionCaptionTextColor; |
| 110 |
break; |
| 111 |
case 'minimal': |
| 112 |
//Colors |
| 113 |
defaultSurveyColor = defaultColors.minimal.surveyColor; |
| 114 |
defaultBgColor = defaultColors.minimal.bgColor; |
| 115 |
defaultTextColor = defaultColors.minimal.textColor; |
| 116 |
defaultLoaderColor = defaultColors.minimal.loaderColor; |
| 117 |
defaultButtonsTextColor = defaultColors.minimal.buttonsTextColor; |
| 118 |
defaultStartPageBgColor = defaultColors.minimal.startPageBgColor; |
| 119 |
defaultStartPageTextColor = defaultColors.minimal.startPageTextColor; |
| 120 |
defaultQestionCaptionTextColor = defaultColors.minimal.questionCaptionTextColor; |
| 121 |
break; |
| 122 |
case 'modern': |
| 123 |
//Colors |
| 124 |
defaultSurveyColor = defaultColors.modern.surveyColor; |
| 125 |
defaultBgColor = defaultColors.modern.bgColor; |
| 126 |
defaultTextColor = defaultColors.modern.textColor; |
| 127 |
defaultLoaderColor = defaultColors.modern.loaderColor; |
| 128 |
defaultButtonsTextColor = defaultColors.modern.buttonsTextColor; |
| 129 |
defaultStartPageBgColor = defaultColors.modern.startPageBgColor; |
| 130 |
defaultStartPageTextColor = defaultColors.modern.startPageTextColor; |
| 131 |
defaultButtonsBgColor = defaultColors.modern.buttonsBgColor; |
| 132 |
defaultQestionCaptionTextColor = defaultColors.modern.questionCaptionTextColor; |
| 133 |
break; |
| 134 |
default: |
| 135 |
defaultSurveyColor = defaultColors.classicLight.surveyColor; |
| 136 |
defaultBgColor = defaultColors.classicLight.bgColor; |
| 137 |
defaultTextColor = defaultColors.classicLight.textColor; |
| 138 |
defaultLoaderColor = defaultColors.classicLight.loaderColor; |
| 139 |
defaultButtonsTextColor = defaultColors.classicLight.buttonsTextColor; |
| 140 |
defaultStartPageBgColor = defaultColors.classicLight.startPageBgColor; |
| 141 |
defaultStartPageTextColor = defaultColors.classicLight.startPageTextColor; |
| 142 |
defaultButtonsBgColor = defaultColors.classicLight.buttonsBgColor; |
| 143 |
defaultTitleTShColor = defaultColors.classicLight.titleTextShadColor; |
| 144 |
defaultPaginationTextColor = defaultColors.classicLight.paginationTextColor; |
| 145 |
defaultFullScreenButtonColor = defaultColors.classicLight.fullScreenButtonColor; |
| 146 |
defaultQestionCaptionTextColor = defaultColors.classicLight.questionCaptionTextColor; |
| 147 |
break; |
| 148 |
} |
| 149 |
$(document).find('#ays_survey_color').wpColorPicker('color', defaultSurveyColor); |
| 150 |
$(document).find('#ays_survey_background_color').wpColorPicker('color', defaultBgColor); |
| 151 |
$(document).find('#ays_survey_text_color').wpColorPicker('color', defaultTextColor); |
| 152 |
$(document).find('#ays_survey_loader_color').wpColorPicker('color', defaultLoaderColor); |
| 153 |
$(document).find('#ays_survey_buttons_text_color').wpColorPicker('color', defaultButtonsTextColor); |
| 154 |
$(document).find('#ays_survey_start_page_background_color').wpColorPicker('color', defaultStartPageBgColor); |
| 155 |
$(document).find('#ays_survey_start_page_text_color').wpColorPicker('color', defaultStartPageTextColor); |
| 156 |
$(document).find('#ays_survey_button_bg_color').wpColorPicker('color', defaultButtonsBgColor); |
| 157 |
$(document).find('#ays_survey_title_box_shadow_color').wpColorPicker('color', defaultTitleTShColor); |
| 158 |
$(document).find('#ays_survey_pagination_text_color,#ays_survey_pagination_text_color_mobile').wpColorPicker('color', defaultPaginationTextColor); |
| 159 |
$(document).find('#ays_survey_full_screen_button_color').wpColorPicker('color', defaultFullScreenButtonColor); |
| 160 |
$(document).find('#ays_survey_question_caption_text_color,#ays_survey_question_caption_text_color_mobile').wpColorPicker('color', defaultQestionCaptionTextColor); |
| 161 |
} |
| 162 |
|
| 163 |
function surveyThemeSetup( SurveyTheme ){ |
| 164 |
var defaultTextColor, defaultLoaderColor, defaultBgColor, defaultSurveyColor,defaultButtonsTextColor,defaultStartPageBgColor, defaultStartPageTextColor, defaultButtonsBgColor, defaultTitleTShColor, defaultPaginationTextColor, defaultFullScreenButtonColor, defaultQestionCaptionTextColor; |
| 165 |
|
| 166 |
switch ( SurveyTheme ) { |
| 167 |
case 'classic_dark': |
| 168 |
defaultSurveyColor = defaultColors.classicDark.surveyColor; |
| 169 |
defaultBgColor = defaultColors.classicDark.bgColor; |
| 170 |
defaultTextColor = defaultColors.classicDark.textColor; |
| 171 |
defaultLoaderColor = defaultColors.classicDark.loaderColor; |
| 172 |
defaultButtonsTextColor = defaultColors.classicDark.buttonsTextColor; |
| 173 |
defaultButtonsBgColor = defaultColors.classicDark.buttonsBgColor; |
| 174 |
defaultStartPageBgColor = defaultColors.classicDark.startPageBgColor; |
| 175 |
defaultStartPageTextColor = defaultColors.classicDark.startPageTextColor; |
| 176 |
defaultTitleTShColor = defaultColors.classicDark.titleTextShadColor; |
| 177 |
defaultPaginationTextColor = defaultColors.classicDark.paginationTextColor; |
| 178 |
defaultFullScreenButtonColor = defaultColors.classicDark.fullScreenButtonColor; |
| 179 |
defaultQestionCaptionTextColor = defaultColors.classicDark.questionCaptionTextColor; |
| 180 |
break; |
| 181 |
case 'classic_light': |
| 182 |
defaultSurveyColor = defaultColors.classicLight.surveyColor; |
| 183 |
defaultBgColor = defaultColors.classicLight.bgColor; |
| 184 |
defaultTextColor = defaultColors.classicLight.textColor; |
| 185 |
defaultLoaderColor = defaultColors.classicLight.loaderColor; |
| 186 |
defaultButtonsTextColor = defaultColors.classicLight.buttonsTextColor; |
| 187 |
defaultStartPageBgColor = defaultColors.classicLight.startPageBgColor; |
| 188 |
defaultStartPageTextColor = defaultColors.classicLight.startPageTextColor; |
| 189 |
defaultButtonsBgColor = defaultColors.classicLight.buttonsBgColor; |
| 190 |
defaultTitleTShColor = defaultColors.classicLight.titleTextShadColor; |
| 191 |
defaultPaginationTextColor = defaultColors.classicLight.paginationTextColor; |
| 192 |
defaultFullScreenButtonColor = defaultColors.classicLight.fullScreenButtonColor; |
| 193 |
defaultQestionCaptionTextColor = defaultColors.classicLight.questionCaptionTextColor; |
| 194 |
break; |
| 195 |
case 'minimal': |
| 196 |
//Color |
| 197 |
defaultSurveyColor = defaultColors.minimal.surveyColor; |
| 198 |
defaultBgColor = defaultColors.minimal.bgColor; |
| 199 |
defaultTextColor = defaultColors.minimal.textColor; |
| 200 |
defaultLoaderColor = defaultColors.minimal.loaderColor; |
| 201 |
defaultButtonsTextColor = defaultColors.minimal.buttonsTextColor; |
| 202 |
defaultStartPageBgColor = defaultColors.minimal.startPageBgColor; |
| 203 |
defaultStartPageTextColor = defaultColors.minimal.startPageTextColor; |
| 204 |
defaultQestionCaptionTextColor = defaultColors.minimal.questionCaptionTextColor; |
| 205 |
break; |
| 206 |
case 'modern': |
| 207 |
//Color |
| 208 |
defaultSurveyColor = defaultColors.modern.surveyColor; |
| 209 |
defaultBgColor = defaultColors.modern.bgColor; |
| 210 |
defaultTextColor = defaultColors.modern.textColor; |
| 211 |
defaultLoaderColor = defaultColors.modern.loaderColor; |
| 212 |
defaultButtonsTextColor = defaultColors.modern.buttonsTextColor; |
| 213 |
defaultButtonsBgColor = defaultColors.modern.buttonsBgColor; |
| 214 |
defaultStartPageBgColor = defaultColors.modern.startPageBgColor; |
| 215 |
defaultStartPageTextColor = defaultColors.modern.startPageTextColor; |
| 216 |
defaultQestionCaptionTextColor = defaultColors.modern.questionCaptionTextColor; |
| 217 |
break; |
| 218 |
default: |
| 219 |
defaultSurveyColor = defaultColors.classicLight.surveyColor; |
| 220 |
defaultBgColor = defaultColors.classicLight.bgColor; |
| 221 |
defaultTextColor = defaultColors.classicLight.textColor; |
| 222 |
defaultLoaderColor = defaultColors.classicLight.loaderColor; |
| 223 |
defaultButtonsTextColor = defaultColors.classicLight.buttonsTextColor; |
| 224 |
defaultButtonsBgColor = defaultColors.classicLight.buttonsBgColor; |
| 225 |
defaultStartPageBgColor = defaultColors.classicLight.startPageBgColor; |
| 226 |
defaultStartPageTextColor = defaultColors.classicLight.startPageTextColor; |
| 227 |
defaultTitleTShColor = defaultColors.classicLight.titleTextShadColor; |
| 228 |
defaultPaginationTextColor = defaultColors.classicLight.paginationTextColor; |
| 229 |
defaultFullScreenButtonColor = defaultColors.classicLight.fullScreenButtonColor; |
| 230 |
defaultQestionCaptionTextColor = defaultColors.classicLight.questionCaptionTextColor; |
| 231 |
break; |
| 232 |
} |
| 233 |
|
| 234 |
var ays_survey_color_picker = { |
| 235 |
defaultColor: defaultSurveyColor, |
| 236 |
change: function (e) { |
| 237 |
} |
| 238 |
}; |
| 239 |
|
| 240 |
var ays_survey_background_color_picker = { |
| 241 |
defaultColor: defaultBgColor, |
| 242 |
change: function (e) { |
| 243 |
} |
| 244 |
}; |
| 245 |
|
| 246 |
var ays_survey_text_color_picker = { |
| 247 |
defaultColor: defaultTextColor, |
| 248 |
change: function (e) { |
| 249 |
} |
| 250 |
}; |
| 251 |
|
| 252 |
var ays_survey_loader_color_picker = { |
| 253 |
defaultColor: defaultLoaderColor, |
| 254 |
change: function (e) { |
| 255 |
} |
| 256 |
}; |
| 257 |
|
| 258 |
var ays_survey_buttons_text_color_picker = { |
| 259 |
defaultColor: defaultButtonsTextColor, |
| 260 |
change: function (e) { |
| 261 |
} |
| 262 |
}; |
| 263 |
|
| 264 |
var ays_survey_start_page_background_color_picker = { |
| 265 |
defaultColor: defaultStartPageBgColor, |
| 266 |
change: function (e) { |
| 267 |
} |
| 268 |
}; |
| 269 |
|
| 270 |
var ays_survey_start_page_text_color_picker = { |
| 271 |
defaultColor: defaultStartPageTextColor, |
| 272 |
change: function (e) { |
| 273 |
} |
| 274 |
}; |
| 275 |
|
| 276 |
var ays_survey_buttons_background_color_picker = { |
| 277 |
defaultColor: defaultButtonsBgColor, |
| 278 |
change: function (e) { |
| 279 |
} |
| 280 |
}; |
| 281 |
|
| 282 |
var ays_survey_title_box_shadow_color_picker = { |
| 283 |
defaultColor: defaultTitleTShColor, |
| 284 |
change: function (e) { |
| 285 |
} |
| 286 |
}; |
| 287 |
|
| 288 |
var ays_survey_pagination_text_color = { |
| 289 |
defaultColor: defaultPaginationTextColor, |
| 290 |
change: function (e) { |
| 291 |
} |
| 292 |
}; |
| 293 |
|
| 294 |
var ays_survey_full_screen_button_color = { |
| 295 |
defaultColor: defaultFullScreenButtonColor, |
| 296 |
change: function (e) { |
| 297 |
} |
| 298 |
}; |
| 299 |
|
| 300 |
var ays_survey_question_caption_text_color = { |
| 301 |
defaultColor: defaultQestionCaptionTextColor, |
| 302 |
change: function (e) { |
| 303 |
} |
| 304 |
}; |
| 305 |
|
| 306 |
|
| 307 |
// Initialize color pickers |
| 308 |
$(document).find('#ays_survey_color').wpColorPicker(ays_survey_color_picker); |
| 309 |
$(document).find('#ays_survey_background_color').wpColorPicker(ays_survey_background_color_picker); |
| 310 |
$(document).find('#ays_survey_text_color').wpColorPicker(ays_survey_text_color_picker); |
| 311 |
$(document).find('#ays_survey_loader_color').wpColorPicker(ays_survey_loader_color_picker); |
| 312 |
$(document).find('#ays_survey_buttons_text_color').wpColorPicker(ays_survey_buttons_text_color_picker); |
| 313 |
$(document).find('#ays_survey_start_page_background_color').wpColorPicker(ays_survey_start_page_background_color_picker); |
| 314 |
$(document).find('#ays_survey_start_page_text_color').wpColorPicker(ays_survey_start_page_text_color_picker); |
| 315 |
$(document).find('#ays_survey_button_bg_color').wpColorPicker(ays_survey_buttons_background_color_picker); |
| 316 |
$(document).find('#ays_survey_title_box_shadow_color').wpColorPicker(ays_survey_title_box_shadow_color_picker); |
| 317 |
$(document).find('#ays_survey_pagination_text_color,#ays_survey_pagination_text_color_mobile').wpColorPicker(ays_survey_pagination_text_color); |
| 318 |
$(document).find('#ays_survey_full_screen_button_color').wpColorPicker(ays_survey_full_screen_button_color); |
| 319 |
$(document).find('#ays_survey_question_caption_text_color,#ays_survey_question_caption_text_color_mobile').wpColorPicker(ays_survey_question_caption_text_color); |
| 320 |
} |
| 321 |
|
| 322 |
$(document).find('#ays_survey_buttons_size').aysDropdown({ |
| 323 |
onChange: function(value, text, $choice){ |
| 324 |
buttonsSizeChange( value ); |
| 325 |
} |
| 326 |
}); |
| 327 |
|
| 328 |
$(document).find('#ays_survey_buttons_alignment,#ays_survey_buttons_alignment_mobile').aysDropdown(); |
| 329 |
|
| 330 |
// var SurveyButtonsSize = $(document).find('#ays_survey_buttons_size').aysDropdown('get value'); |
| 331 |
// buttonsSizeChange( SurveyButtonsSize, false ); |
| 332 |
|
| 333 |
function buttonsSizeChange( buttonsSize ){ |
| 334 |
var buttonsFontSize, |
| 335 |
buttonsLeftRightPadding, |
| 336 |
buttonsTopBottomPadding, |
| 337 |
buttonsBorderRadiusMobile, |
| 338 |
buttonsBorderRadius; |
| 339 |
|
| 340 |
switch(buttonsSize){ |
| 341 |
case "small": |
| 342 |
buttonsFontSize = 11; |
| 343 |
buttonsLeftRightPadding = 11; |
| 344 |
buttonsTopBottomPadding = 0; |
| 345 |
buttonsBorderRadius = 4; |
| 346 |
buttonsBorderRadiusMobile = 4; |
| 347 |
break; |
| 348 |
case "large": |
| 349 |
buttonsFontSize = 17; |
| 350 |
buttonsLeftRightPadding = 27; |
| 351 |
buttonsTopBottomPadding = 3; |
| 352 |
buttonsBorderRadius = 4; |
| 353 |
buttonsBorderRadiusMobile = 4; |
| 354 |
break; |
| 355 |
default: |
| 356 |
buttonsFontSize = 14; |
| 357 |
buttonsLeftRightPadding = 24; |
| 358 |
buttonsTopBottomPadding = 0; |
| 359 |
buttonsBorderRadius = 4; |
| 360 |
buttonsBorderRadiusMobile = 4; |
| 361 |
break; |
| 362 |
} |
| 363 |
|
| 364 |
$(document).find('#ays_survey_buttons_font_size').val(buttonsFontSize); |
| 365 |
$(document).find('#ays_survey_buttons_left_right_padding').val(buttonsLeftRightPadding); |
| 366 |
$(document).find('#ays_survey_buttons_top_bottom_padding').val(buttonsTopBottomPadding); |
| 367 |
$(document).find('#ays_survey_buttons_border_radius').val(buttonsBorderRadius); |
| 368 |
$(document).find('#ays_survey_buttons_border_radius_mobile').val(buttonsBorderRadius); |
| 369 |
|
| 370 |
$(document).find('.ays_buttons_div input[name="next"]').css('font-size', buttonsFontSize + 'px'); |
| 371 |
$(document).find('.ays_buttons_div input[name="next"]').css('padding', buttonsTopBottomPadding+'px '+ buttonsLeftRightPadding+'px'); |
| 372 |
$(document).find('.ays_buttons_div input[name="next"]').css('border-radius', buttonsBorderRadius + 'px'); |
| 373 |
} |
| 374 |
|
| 375 |
|
| 376 |
if($(document).find('.ays-top-menu').width() <= $(document).find('div.ays-top-tab-wrapper').width()){ |
| 377 |
$(document).find('.ays_menu_left').css('display', 'flex'); |
| 378 |
$(document).find('.ays_menu_right').css('display', 'flex'); |
| 379 |
} |
| 380 |
$(window).resize(function(){ |
| 381 |
if($(document).find('.ays-top-menu').width() < $(document).find('div.ays-top-tab-wrapper').width()){ |
| 382 |
$(document).find('.ays_menu_left').css('display', 'flex'); |
| 383 |
$(document).find('.ays_menu_right').css('display', 'flex'); |
| 384 |
}else{ |
| 385 |
$(document).find('.ays_menu_left').css('display', 'none'); |
| 386 |
$(document).find('.ays_menu_right').css('display', 'none'); |
| 387 |
$(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(0px)'); |
| 388 |
} |
| 389 |
}); |
| 390 |
var menuItemWidths0 = []; |
| 391 |
var menuItemWidths = []; |
| 392 |
$(document).find('.ays-top-tab-wrapper .nav-tab').each(function(){ |
| 393 |
var $this = $(this); |
| 394 |
menuItemWidths0.push($this.outerWidth()); |
| 395 |
}); |
| 396 |
|
| 397 |
for(var i = 0; i < menuItemWidths0.length; i+=2){ |
| 398 |
if(menuItemWidths0.length <= i+1){ |
| 399 |
menuItemWidths.push(menuItemWidths0[i]); |
| 400 |
}else{ |
| 401 |
menuItemWidths.push(menuItemWidths0[i]+menuItemWidths0[i+1]); |
| 402 |
} |
| 403 |
} |
| 404 |
var menuItemWidth = 0; |
| 405 |
for(var i = 0; i < menuItemWidths.length; i++){ |
| 406 |
menuItemWidth += menuItemWidths[i]; |
| 407 |
} |
| 408 |
menuItemWidth = menuItemWidth / menuItemWidths.length; |
| 409 |
|
| 410 |
$(document).on('click', '.ays_menu_left', function(){ |
| 411 |
var scroll = parseInt($(this).attr('data-scroll')); |
| 412 |
scroll -= menuItemWidth; |
| 413 |
if(scroll < 0){ |
| 414 |
scroll = 0; |
| 415 |
} |
| 416 |
$(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(-'+scroll+'px)'); |
| 417 |
$(this).attr('data-scroll', scroll); |
| 418 |
$(document).find('.ays_menu_right').attr('data-scroll', scroll); |
| 419 |
}); |
| 420 |
$(document).on('click', '.ays_menu_right', function(){ |
| 421 |
var scroll = parseInt($(this).attr('data-scroll')); |
| 422 |
var howTranslate = $(document).find('div.ays-top-tab-wrapper').width() - $(document).find('.ays-top-menu').width(); |
| 423 |
howTranslate += 7; |
| 424 |
if(scroll == -1){ |
| 425 |
scroll = menuItemWidth; |
| 426 |
} |
| 427 |
scroll += menuItemWidth; |
| 428 |
if(scroll > howTranslate){ |
| 429 |
scroll = Math.abs(howTranslate); |
| 430 |
} |
| 431 |
$(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(-'+scroll+'px)'); |
| 432 |
$(this).attr('data-scroll', scroll); |
| 433 |
$(document).find('.ays_menu_left').attr('data-scroll', scroll); |
| 434 |
}); |
| 435 |
|
| 436 |
$(document).find('.ays-survey-reset-styles-button').on("click", function(e){ |
| 437 |
e.preventDefault(); |
| 438 |
// Change theme with color (trigger) |
| 439 |
$(document).find("#ays-survey-classic_light").prop('checked', true).change(); |
| 440 |
|
| 441 |
// Set values where value is empty by default at once (for all options) |
| 442 |
$(document).find("#ays_survey_width,#ays_survey_mobile_width,#ays_mobile_max_width,#ays_survey_question_image_width,#ays_survey_question_image_height,#ays_survey_question_image_height_mobile,#ays_survey_custom_class").val(''); |
| 443 |
// Set dropdowns in pixels |
| 444 |
$(document).find("#ays_survey_width_by_percentage_px").aysDropdown('set selected', 'pixels'); |
| 445 |
// Set dropdowns in percentage |
| 446 |
$(document).find("#ays_survey_mobile_width_by_percentage_px").aysDropdown('set selected', 'percentage'); |
| 447 |
// Set all images to defalut (no image) |
| 448 |
$(document).find("#tab2 .removeImage,#tab2 .removeCoverImage").trigger('click'); |
| 449 |
// Set dropdowns where value is left (for all options) |
| 450 |
$(document).find("#ays_survey_title_alignment,#ays_survey_title_alignment_mobile,#ays_survey_section_title_alignment,#ays_survey_section_title_alignment_mobile,#ays_survey_section_description_alignment,#ays_survey_section_description_alignment_mobile,#ays_survey_question_title_alignment,#ays_survey_answers_view_alignment,#ays_survey_buttons_alignment,#ays_survey_buttons_alignment_mobile").aysDropdown('set selected', 'left'); |
| 451 |
// Title font size |
| 452 |
$(document).find("#ays_survey_title_font_size,#ays_survey_title_font_size_for_mobile").val(30); |
| 453 |
// Survey title letter spacing |
| 454 |
$(document).find("#ays_survey_title_letter_spacing").val(0); |
| 455 |
// Survey title letter spacing |
| 456 |
$(document).find("#ays_survey_title_letter_spacing_mobile").val(0); |
| 457 |
// Disabel title box shadow |
| 458 |
$(document).find("#ays_survey_title_box_shadow_enable").prop('checked' , false).change(); |
| 459 |
// Section title font size |
| 460 |
$(document).find("#ays_survey_section_title_font_size,#ays_survey_section_title_font_size_mobile").val(32); |
| 461 |
// Section title letter spacing |
| 462 |
$(document).find("#ays_survey_section_title_letter_spacing").val(0); |
| 463 |
// Section title letter spacing mobile |
| 464 |
$(document).find("#ays_survey_section_title_letter_spacing_mobile").val(0); |
| 465 |
// Section description font size |
| 466 |
$(document).find("#ays_survey_section_description_font_size,#ays_survey_section_description_font_size_mobile").val(14); |
| 467 |
// Section description letter spacing |
| 468 |
$(document).find("#ays_survey_section_description_letter_spacing").val(0); |
| 469 |
$(document).find("#ays_survey_section_description_letter_spacing_mobile").val(0); |
| 470 |
|
| 471 |
// == Question styles == |
| 472 |
// Section question font size |
| 473 |
$(document).find("#ays_survey_question_font_size,#ays_survey_question_font_size_mobile").val(16); |
| 474 |
// Set dropdowns where value is cover (for all options) |
| 475 |
$(document).find("#ays_survey_question_image_sizing,#ays_survey_answers_object_fit,#ays_survey_answers_object_fit").aysDropdown('set selected', 'cover'); |
| 476 |
// Question font size |
| 477 |
$(document).find("#ays_survey_question_padding").val(24); |
| 478 |
// Question font size mobile |
| 479 |
$(document).find("#ays_survey_question_padding_mobile").val(24); |
| 480 |
// Question caption text alignment |
| 481 |
$(document).find("#ays_survey_question_caption_text_alignment").aysDropdown('set selected', 'center'); |
| 482 |
// Question caption text alignment on mobile |
| 483 |
$(document).find("#ays_survey_question_caption_text_alignment_on_mobile").aysDropdown('set selected', 'center'); |
| 484 |
// == == |
| 485 |
|
| 486 |
// == Answer styles == |
| 487 |
// Answer font size |
| 488 |
$(document).find("#ays_survey_answer_font_size,#ays_survey_answer_font_size_on_mobile").val(15); |
| 489 |
// Answer letter spacing |
| 490 |
$(document).find("#ays_survey_answer_letter_spacing").val(0); |
| 491 |
// Answer letter spacing on mobile |
| 492 |
$(document).find("#ays_survey_answer_letter_spacing_mobile").val(0); |
| 493 |
// Answer view |
| 494 |
$(document).find("#ays_survey_answers_view").aysDropdown('set selected', 'list'); |
| 495 |
// Answer padding |
| 496 |
$(document).find("#ays_survey_answers_padding").val(8); |
| 497 |
// Answer padding mobile |
| 498 |
$(document).find("#ays_survey_answers_padding_mobile").val(8); |
| 499 |
// Answer gap |
| 500 |
$(document).find("#ays_survey_answers_gap").val(0); |
| 501 |
// Answer gap mobile |
| 502 |
$(document).find("#ays_survey_answers_gap_mobile").val(0); |
| 503 |
// Answer image size |
| 504 |
$(document).find("#ays_survey_answers_image_size").val(195); |
| 505 |
// Answer image size mobile |
| 506 |
$(document).find("#ays_survey_answers_image_size_mobile").val(195); |
| 507 |
// == == |
| 508 |
|
| 509 |
// == Button styles == |
| 510 |
// Button size |
| 511 |
$(document).find("#ays_survey_buttons_size").aysDropdown('set selected', 'medium'); |
| 512 |
// Button font size |
| 513 |
$(document).find("#ays_survey_buttons_font_size,#ays_survey_buttons_mobile_font_size").val(14); |
| 514 |
// Button border-radius |
| 515 |
$(document).find("#ays_survey_buttons_border_radius").val(3); |
| 516 |
// Button border-radius |
| 517 |
$(document).find("#ays_survey_buttons_border_radius_mobile").val(3); |
| 518 |
// Button top distance |
| 519 |
$(document).find("#ays_survey_buttons_top_distance,#ays_survey_buttons_top_distance_mobile").val(10); |
| 520 |
// Button text letter spacing |
| 521 |
$(document).find("#ays_survey_buttons_text_letter_spacing").val(0); |
| 522 |
// == == |
| 523 |
|
| 524 |
setTimeout(function(){ |
| 525 |
if($(document).find('#ays_survey_custom_css').length > 0){ |
| 526 |
if(wp.codeEditor){ |
| 527 |
$(document).find('#ays_survey_custom_css').next('.CodeMirror').remove(); |
| 528 |
$(document).find('#ays_survey_custom_css').val(''); |
| 529 |
wp.codeEditor.initialize($(document).find('#ays_survey_custom_css'), cm_settings); |
| 530 |
} |
| 531 |
} |
| 532 |
}, 100); |
| 533 |
|
| 534 |
$(document).find("#tab2").goToNormal(); |
| 535 |
|
| 536 |
}); |
| 537 |
|
| 538 |
}); |
| 539 |
})(jQuery); |
| 540 |
|