PluginProbe
Survey Maker by AYS / 5.2.1.8
Survey Maker by AYS v5.2.1.8
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / admin / js / functions.js

functions.js in Survey Maker by AYS 5.2.1.8, at admin/js/functions.js

687 lines 28.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // (function($){
2
3 var $html_name_prefix = 'ays_';
4 String.prototype.hexToRgbA = function(a) {
5
6 if (typeof a === 'undefined'){
7 a = 1;
8 }
9 var ays_rgb;
10 var result1 = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})jQuery/i.exec(this);
11 var result2 = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})jQuery/i.exec(this);
12 if(result1){
13 ays_rgb = {
14 r: parseInt(result1[1], 16),
15 g: parseInt(result1[2], 16),
16 b: parseInt(result1[3], 16)
17 };
18 return 'rgba('+ays_rgb.r+','+ays_rgb.g+','+ays_rgb.b+','+a+')';
19 }else if(result2){
20 ays_rgb = {
21 r: parseInt(result2[1]+''+result2[1], 16),
22 g: parseInt(result2[2]+''+result2[2], 16),
23 b: parseInt(result2[3]+''+result2[3], 16)
24 };
25 return 'rgba('+ays_rgb.r+','+ays_rgb.g+','+ays_rgb.b+','+a+')';
26 }else{
27 return null;
28 }
29 }
30
31 jQuery.fn.aysModal = function(action){
32 var jQuerythis = jQuery(this);
33 switch(action){
34 case 'hide':
35 jQuery(this).find('.ays-modal-content').css('animation-name', 'zoomOut');
36 setTimeout(function(){
37 jQuery(document.body).removeClass('modal-open');
38 jQuery(document).find('.ays-modal-backdrop').remove();
39 jQuerythis.hide();
40 }, 250);
41 break;
42 case 'show':
43 default:
44 jQuerythis.show();
45 jQuery(this).find('.ays-modal-content').css('animation-name', 'zoomIn');
46 jQuery(document).find('.modal-backdrop').remove();
47 jQuery(document.body).append('<div class="ays-modal-backdrop"></div>');
48 jQuery(document.body).addClass('modal-open');
49 break;
50 }
51 }
52
53 jQuery.fn.aysEditorModal = function(action){
54 var jQuerythis = jQuery(this);
55 switch(action){
56 case 'hide':
57 jQuery(this).find('.ays-modal-content').css('animation-name', 'zoomOut');
58 setTimeout(function(){
59 jQuery(document.body).removeClass('modal-open');
60 jQuery(document).find('.ays-modal-backdrop').remove();
61 jQuerythis.hide();
62 }, 250);
63 break;
64 case 'show':
65 default:
66 jQuerythis.show();
67 jQuery(this).find('.ays-modal-content').css('animation-name', 'zoomIn');
68 jQuery(document).find('.modal-backdrop').remove();
69 jQuery(document.body).append('<div class="ays-modal-backdrop"></div>');
70 jQuery(document.body).addClass('modal-open');
71 break;
72 }
73 }
74
75 function checkTrue(flag) {
76 return flag === true;
77 }
78
79 function openMediaUploaderForImage(e, element) {
80 e.preventDefault();
81 var aysUploader = wp.media({
82 title: 'Upload',
83 button: {
84 text: 'Upload'
85 },
86 library: {
87 type: 'image'
88 },
89 multiple: false
90 }).on('select', function () {
91 var attachment = aysUploader.state().get('selection').first().toJSON();
92 var answerImgCont = element.parents('.ays-survey-image-container').find('.ays-survey-image-body');
93 var img = answerImgCont.find('img.ays-survey-img');
94 var hiddenInp = answerImgCont.find('input.ays-survey-img-src');
95
96 element.text( SurveyMakerAdmin.editImage );
97 img.attr('src', attachment.url);
98 hiddenInp.val(attachment.url);
99 answerImgCont.show();
100 img.removeClass('fade');
101 jQuery(document).find(".ays-survey-logo-url-box").removeClass("display_none_not_important");
102 var checkImgUrl = jQuery(document).find("#ays_survey_logo_enable_image_url").prop("checked");
103 element.parents('.ays-survey-image-container').parent().find('.ays-survey-logo-open').show();
104 if(checkImgUrl){
105 element.parents('.ays-survey-image-container').parent().find('.ays-survey-logo-open-close').show();
106 }
107 }).open();
108 return false;
109 }
110
111 function openMediaUploaderForCoverImage(e, element) {
112 e.preventDefault();
113 var aysUploader = wp.media({
114 title: 'Upload',
115 button: {
116 text: 'Upload'
117 },
118 library: {
119 type: 'image'
120 },
121 multiple: false
122 }).on('select', function () {
123 var attachment = aysUploader.state().get('selection').first().toJSON();
124 var answerImgCont = element.parents('.ays-survey-image-container').find('.ays-survey-image-body');
125 var thisParent = element.parents(".ays_survey_cover_image_main");
126 thisParent.find('.ays-survey-cover-image-options').css("display" , "flex");
127 thisParent.find('.ays-survey-cover-image-options-hr').fadeIn(500);
128 var img = answerImgCont.find('img.ays-survey-cover-img');
129 var hiddenInp = answerImgCont.find('input.ays-survey-cover-img-src');
130
131 element.text( SurveyMakerAdmin.editImage );
132 img.attr('src', attachment.url);
133 hiddenInp.val(attachment.url);
134 answerImgCont.show();
135 img.removeClass('fade');
136
137 }).open();
138 return false;
139 }
140
141
142 function openMediaUploaderForGifLoader(e, element) {
143 e.preventDefault();
144 var aysUploader = wp.media({
145 title: 'Upload',
146 button: {
147 text: 'Upload'
148 },
149 library: {
150 type: 'image'
151 },
152 multiple: false
153 }).on('select', function () {
154 var attachment = aysUploader.state().get('selection').first().toJSON();
155 var wrap = element.parents('.ays-survey-image-wrap');
156 wrap.find('.ays-survey-image-container img.ays_survey_img_loader_custom_gif').attr('src', attachment.url);
157 wrap.find('input.ays-survey-image-path').val(attachment.url);
158 wrap.find('.ays-survey-image-container').fadeIn();
159 wrap.find('button.add_survey_loader_custom_gif').hide();
160 }).open();
161 return false;
162 }
163
164 // function openMediaUploader(e, element) {
165 // e.preventDefault();
166 // var aysUploader = wp.media({
167 // title: 'Upload',
168 // button: {
169 // text: 'Upload'
170 // },
171 // library: {
172 // type: 'image'
173 // },
174 // multiple: false
175 // }).on('select', function () {
176 // var attachment = aysUploader.state().get('selection').first().toJSON();
177 // element.text('Edit Image');
178 // element.parent().parent().find('.ays-question-image-container').fadeIn();
179 // element.parent().parent().find('img#ays-question-img').attr('src', attachment.url);
180 // element.parent().parent().find('input#ays-question-image').val(attachment.url);
181 // }).open();
182 // return false;
183 // }
184
185
186 function openMediaUploader(e, element, type) {
187 e.preventDefault();
188 var aysUploader = wp.media({
189 title: 'Upload',
190 button: {
191 text: 'Upload'
192 },
193 library: {
194 type: 'image'
195 },
196 multiple: false
197 }).on('select', function () {
198 var attachment = aysUploader.state().get('selection').first().toJSON();
199 switch(type){
200 case 'questionImgButton':
201 var $this = element.parents('.ays-survey-question-answer-conteiner').find('.ays-survey-question-image-container');
202 var hiddenInp = $this.find('.ays-survey-question-img-src');
203 var img = $this.find('img.ays-survey-question-img');
204
205 $this.removeAttr('style');
206 img.attr('src', attachment.url);
207 hiddenInp.val(attachment.url);
208 break;
209 case 'answerImgButton':
210 var answerImgCont = element.parents('.ays-survey-answer-row').find('.ays-survey-answer-image-container');
211 var parent = element.parents('.ays-survey-section-box');
212
213 var section_id = parent.data('id');
214 var question_id = element.parents('.ays-survey-question-answer-conteiner').data('id');
215 var answer_id = element.parents('.ays-survey-answer-row').data('id');
216 var imgInputName = element.parents('.ays-survey-answer-row').find('input.ays-survey-input').attr('name');
217 var checkInputName = imgInputName.indexOf('ays_section_add');
218 var inputName = false;
219 if (checkInputName >= 0) {
220 inputName = true;
221 }
222
223 var name = 'section';
224 if (inputName) {
225 name = 'section_add';
226 }
227 // var inputNameAttr = $html_name_prefix+name+'['+section_id+'][question]['+question_id+'][answers]['+answer_id+'][image]';
228
229 var img = answerImgCont.find('img.ays-survey-answer-img');
230 var hiddenInp = answerImgCont.find('input.ays-survey-answer-img-src');
231
232 img.attr('src', attachment.url);
233 hiddenInp.val(attachment.url);
234 answerImgCont.show();
235 img.removeClass('Fade');
236 break;
237 }
238
239 }).open();
240 return false;
241 }
242
243
244 function openMediaUploaderQuestionBg(e, element) {
245 e.preventDefault();
246 var aysUploader = wp.media({
247 title: 'Upload Question Background',
248 button: {
249 text: 'Upload'
250 },
251 library: {
252 type: 'image'
253 },
254 multiple: false
255 }).on('select', function () {
256 var attachment = aysUploader.state().get('selection').first().toJSON();
257 element.text('Edit Image');
258 element.parent().parent().find('.ays-question-bg-image-container').fadeIn();
259 element.parent().parent().find('img#ays-question-bg-img').attr('src', attachment.url);
260 element.parent().parent().find('input#ays-question-bg-image').val(attachment.url);
261 }).open();
262 return false;
263 }
264
265 function openMusicMediaUploader(e, element) {
266 e.preventDefault();
267 var aysUploader = wp.media({
268 title: 'Upload music',
269 button: {
270 text: 'Upload'
271 },
272 library: {
273 type: 'audio'
274 },
275 multiple: false
276 }).on('select', function () {
277 var attachment = aysUploader.state().get('selection').first().toJSON();
278 element.next().attr('src', attachment.url);
279 element.parent().find('input.ays_quiz_bg_music').val(attachment.url);
280 }).open();
281 return false;
282 }
283
284 function openQuizMediaUploader(e, element) {
285 e.preventDefault();
286 var aysUploader = wp.media({
287 title: 'Upload',
288 button: {
289 text: 'Upload'
290 },
291 library: {
292 type: 'image'
293 },
294 multiple: false
295 }).on('select', function () {
296 var attachment = aysUploader.state().get('selection').first().toJSON();
297 if(element.hasClass('add-quiz-bg-image')){
298 element.parent().find('img#ays-quiz-bg-img').attr('src', attachment.url);
299 element.parent().find('.ays-quiz-bg-image-container').fadeIn();
300 element.next().val(attachment.url);
301 jQuery(document).find('.ays-quiz-live-container').css({'background-image': 'url("'+attachment.url+'")'});
302 element.hide();
303 }else if(element.hasClass('ays-edit-quiz-bg-img')){
304 element.parent().find('.ays-quiz-bg-image-container').fadeIn();
305 element.parent().find('img#ays-quiz-bg-img').attr('src', attachment.url);
306 jQuery(document).find('#ays_quiz_bg_image').val(attachment.url);
307 jQuery(document).find('.ays-quiz-live-container').css({'background-image': 'url("'+attachment.url+'")'});
308 }else{
309 element.text('Edit Image');
310 element.parent().parent().find('.ays-quiz-image-container').fadeIn();
311 element.parent().parent().find('img#ays-quiz-img').attr('src', attachment.url);
312 jQuery('input#ays-quiz-image').val(attachment.url);
313 var ays_quiz_theme = jQuery(document).find('input[name="ays_quiz_theme"]:checked').val();
314 switch (ays_quiz_theme) {
315 case 'elegant_dark':
316 case 'elegant_light':
317 case 'rect_light':
318 case 'rect_dark':
319 case 'classic_dark':
320 case 'classic_light':
321 jQuery(document).find('#ays-quiz-live-image').attr('src', attachment.url);
322 jQuery(document).find('#ays-quiz-live-image').css({'display': 'block'});
323 break;
324 case 'modern_light':
325 case 'modern_dark':
326 jQuery(document).find('.ays-quiz-live-container').css({'background-image':'url('+attachment.url+')'});
327 jQuery(document).find('#ays-quiz-live-image').css({'display': 'none'});
328 jQuery(document).find('#ays-quiz-live-button').css('border','1px solid');
329 break;
330 default:
331 jQuery(document).find('#ays-quiz-live-image').attr('src', attachment.url);
332 jQuery(document).find('#ays-quiz-live-image').css({'display': 'block'});
333 break;
334
335 }
336 }
337 }).open();
338
339 return false;
340 }
341
342 function openAnswerMediaUploader(e, element) {
343 e.preventDefault();
344 var aysUploader = wp.media({
345 title: 'Upload',
346 button: {
347 text: 'Upload'
348 },
349 library: {
350 type: 'image'
351 },
352 multiple: false
353 }).on('select', function () {
354 var attachment = aysUploader.state().get('selection').first().toJSON();
355 element.parents().eq(1).find('.add-answer-image').css({'display': 'none'})
356 element.parent().parent().find('.ays-answer-image-container').fadeIn();
357 element.parent().parent().find('img.ays-answer-img').attr('src', attachment.url);
358 element.parents('tr').find('input.ays-answer-image-path').val(attachment.url);
359 if(element.hasClass('add-interval-image')){
360 element.parent().parent().find('img').attr('src', attachment.url);
361 element.parents('tr').find('input.ays-answer-image').val(attachment.url);
362 }
363 }).open();
364 return false;
365 }
366
367 function show_hide_rows(page) {
368
369 var rows = jQuery('table.ays-add-questions-table tbody tr');
370 rows.each(function (index) {
371 jQuery(this).css('display', 'none');
372 });
373 var counter = page * 5 - 4;
374 for (var i = counter; i < (counter + 5); i++) {
375 rows.eq(i - 1).css('display', 'table-row');
376 }
377 }
378
379 function createPagination(pagination, pagesCount, pageShow) {
380 (function (baseElement, pages, pageShow) {
381 var pageNum = 0, pageOffset = 0;
382
383 function _initNav() {
384 var appendAble = '';
385 for (var i = 0; i < pagesCount; i++) {
386 var activeClass = (i === 0) ? 'active' : '';
387 appendAble += '<li class="' + activeClass + ' ays-question-page" data-page="' + (i + 1) + '">' + (i + 1) + '</li>';
388 }
389 jQuery('ul.ays-question-nav-pages').html(appendAble);
390 var pagePos = (jQuery('div.ays-question-pagination').width()/2) - (parseInt(jQuery('ul.ays-question-nav-pages>li:first-child').css('width'))/2);
391 jQuery('ul.ays-question-nav-pages').css({
392 'margin-left': pagePos,
393 });
394 //init events
395 var toPage;
396 baseElement.on('click', '.ays-question-nav-pages li, .ays-question-nav-btn', function (e) {
397 if (jQuery(e.target).is('.ays-question-nav-btn')) {
398 toPage = jQuery(this).hasClass('ays-question-prev') ? pageNum - 1 : pageNum + 1;
399 } else {
400 toPage = jQuery(this).index();
401 }
402 var page = Number(toPage) + 1;
403 show_hide_rows(page);
404 _navPage(toPage);
405 });
406 }
407
408 function _navPage(toPage) {
409 var sel = jQuery('.ays-question-nav-pages li', baseElement), w = sel.first().outerWidth(),
410 diff = toPage - pageNum;
411
412 if (toPage >= 0 && toPage <= pages - 1) {
413 sel.removeClass('active').eq(toPage).addClass('active');
414 pageNum = toPage;
415 } else {
416 return false;
417 }
418
419 if (toPage <= (pages - (pageShow + (diff > 0 ? 0 : 1))) && toPage >= 0) {
420 pageOffset = pageOffset + -w * diff;
421 } else {
422 pageOffset = (toPage > 0) ? -w * (pages - pageShow) : 0;
423 }
424
425 sel.parent().css('left', pageOffset + 'px');
426 }
427
428 _initNav();
429
430 })(pagination, pagesCount, pageShow);
431 }
432
433 // window.onload = function () {
434 // if (document.getElementById('import_button')) {
435 // document.getElementById('import_button').addEventListener('click', function () {
436 // document.getElementById('import_file').click();
437 // });
438 //// document.getElementById('example_button').addEventListener('click', function () {
439 //// document.getElementById('example_file').click();
440 //// });
441 // }
442 // }
443
444 function activate_question(element){
445 element.find('.ays_question_overlay').addClass('display_none');
446 element.find('.ays_fa.ays_fa_times').parent()
447 .removeClass('show_remove_answer')
448 .addClass('active_remove_answer');
449 element.find('.ays_add_answer').parents().eq(1).removeClass('show_add_answer');
450 element.addClass('active_question');
451 var this_question = element.find('.ays_question').text();
452 element.find('.ays_question').remove();
453 element.prepend('<input type="text" value="' + this_question + '" class="ays_question_input">');
454 var answers_tr = element.find('.ays_answers_table tr');
455 for (var i = 0; i < answers_tr.length; i++) {
456 var answer_text = (jQuery(answers_tr.eq(i)).find('.ays_answer').text() && jQuery(answers_tr.eq(i)).find('.ays_answer').text() !== "Answer") ? "value='" + jQuery(answers_tr.eq(i)).find('.ays_answer').text() + "'" : "placeholder='Answer text'";
457 jQuery(answers_tr.eq(i)).find('.ays_answer_td').empty();
458 jQuery(answers_tr.eq(i)).find('.ays_answer_td').append('<input type="text" ' + answer_text + ' class="ays_answer">');
459 }
460 }
461
462 function deactivate_questions() {
463 if (jQuery('.active_question').length !== 0) {
464 var question = jQuery('.active_question').eq(0);
465 if(!jQuery(question).find('input[name^="ays_answer_radio"]:checked').length){
466 jQuery(question).find('input[name^="ays_answer_radio"]').eq(0).attr('checked',true)
467 }
468 jQuery(question).find('.ays_add_answer').parents().eq(1).addClass('show_add_answer');
469 jQuery(question).find('.fa.fa-times').parent().removeClass('active_remove_answer').addClass('show_remove_answer');
470
471 var question_text = jQuery(question).find('.ays_question_input').val();
472 jQuery(question).find('.ays_question_input').remove();
473 jQuery(question).prepend('<p class="ays_question">' + question_text + '</p>');
474 var answers_tr = jQuery(question).find('.ays_answers_table tr');
475 for (var i = 0; i < answers_tr.length; i++) {
476 var answer_text = (jQuery(answers_tr.eq(i)).find('.ays_answer').val()) ? jQuery(answers_tr.eq(i)).find('.ays_answer').val() : '';
477 jQuery(answers_tr.eq(i)).find('.ays_answer_td').empty();
478 var answer_html = '<p class="ays_answer">' + answer_text + '</p>'+((answer_text == '')?'<p>Answer</p>':'');
479 jQuery(answers_tr.eq(i)).find('.ays_answer_td').append(answer_html)
480 }
481 jQuery('.active_question').find('.ays_question_overlay').removeClass('display_none');
482 jQuery('.active_question').removeClass('active_question');
483 }
484 }
485
486 function searchForPage(params, data) {
487 // If there are no search terms, return all of the data
488 if (jQuery.trim(params.term) === '') {
489 return data;
490 }
491
492 // Do not display the item if there is no 'text' property
493 if (typeof data.text === 'undefined') {
494 return null;
495 }
496 var searchText = data.text.toLowerCase();
497 // `params.term` should be the term that is used for searching
498 // `data.text` is the text that is displayed for the data object
499 if (searchText.indexOf(params.term) > -1) {
500 var modifiedData = jQuery.extend({}, data, true);
501 modifiedData.text += ' (matched)';
502
503 // You can return modified objects from here
504 // This includes matching the `children` how you want in nested data sets
505 return modifiedData;
506 }
507
508 // Return `null` if the term should not be displayed
509 return null;
510 }
511
512 function selectElementContents(el) {
513 if (window.getSelection && document.createRange) {
514 // var sel = window.getSelection();
515 // var range = document.createRange();
516 // range.selectNodeContents(el);
517 // sel.removeAllRanges();
518 // sel.addRange(range);
519
520 // var _this = jQuery(document).find('strong.ays-survey-shortcode-box');
521 var _this = jQuery(document).find( el );
522
523 var text = el.textContent;
524 var textField = document.createElement('textarea');
525
526 textField.innerText = text;
527 document.body.appendChild(textField);
528 textField.select();
529 document.execCommand('copy');
530 textField.remove();
531
532 var selection = window.getSelection();
533 selection.setBaseAndExtent(el,0,el,1);
534
535 _this.attr( "data-original-title", SurveyMakerAdmin.copied );
536 _this.attr( "title", SurveyMakerAdmin.copied );
537
538 _this.tooltip("show");
539
540 } else if (document.selection && document.body.createTextRange) {
541 var textRange = document.body.createTextRange();
542 textRange.moveToElementText(el);
543 textRange.select();
544 }
545 }
546
547 function selectElementContentsCopy(element) {
548 var _this = element;
549 var text = _this.attr("data-clipboard-text");
550 var newElement = jQuery('<textarea>').appendTo('body').val(text).select();
551 document.execCommand('copy');
552 newElement.remove();
553 _this.attr( "data-original-title", SurveyMakerAdmin.copied );
554 _this.attr( "title", SurveyMakerAdmin.copied );
555 _this.tooltip("show");
556 }
557
558 function selectAndCopyElementContents(el) {
559 if (window.getSelection && document.createRange) {
560 var _this = jQuery(document).find('.ays-survey-copy-element-box');
561
562 var text = el.textContent;
563 var textField = document.createElement('textarea');
564
565 textField.innerText = text;
566 document.body.appendChild(textField);
567 textField.select();
568 document.execCommand('copy');
569 textField.remove();
570
571 var selection = window.getSelection();
572 selection.setBaseAndExtent(el,0,el,1);
573
574 _this.attr( "data-original-title", SurveyMakerAdmin.copied );
575 _this.attr( "title", SurveyMakerAdmin.copied );
576
577 _this.tooltip("show");
578
579 } else if (document.selection && document.body.createTextRange) {
580 var textRange = document.body.createTextRange();
581 textRange.moveToElementText(el);
582 textRange.select();
583 }
584 }
585
586 function nl2br (str, is_xhtml) {
587 if (typeof str === 'undefined' || str === null) {
588 return '';
589 }
590 var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
591 return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
592 }
593
594 function getEachSubmission(e){
595
596 var innerInput = jQuery(this).parents(".ays_survey_results").find(".ays_survey_result");
597 var innerInputVal = innerInput.val();
598 var submissionIdStr = jQuery("#questions").find('.ays_submissions_id_str').val();
599 var submissionIdArr = submissionIdStr.split(",");
600 var newSubmissionArr = [];
601
602 for(var i = 0; i < submissionIdArr.length; i++ ){
603 newSubmissionArr[i+1] = submissionIdArr[i];
604 }
605
606 var forInput = newSubmissionArr.indexOf(innerInputVal);
607 changeTabTo("questions");
608 jQuery(document).find('.ays_number_of_result').val(forInput);
609
610 setTimeout(function(){
611 jQuery(document).find('.ays_number_of_result').trigger('change');
612 }, 500);
613
614 jQuery(document.body).goTo();
615
616 }
617
618 function changeTabTo(href){
619 var newHref = "#"+href;
620 jQuery(document).find('.nav-tab-wrapper a.nav-tab').each(function () {
621 if (jQuery(this).hasClass('nav-tab-active')) {
622 jQuery(this).removeClass('nav-tab-active');
623 }
624 });
625 jQuery(document).find('a[href='+newHref+']').addClass('nav-tab-active');
626
627 jQuery(document).find('.ays-survey-tab-content').each(function () {
628 jQuery(this).css('display', 'none');
629 });
630
631 jQuery('.ays-survey-tab-content' + newHref).css('display', 'block');
632 }
633
634 /**
635 * @return {string}
636 */
637 function aysEscapeHtml(text) {
638 var map = {
639 '&': '&amp;',
640 '<': '&lt;',
641 '>': '&gt;',
642 '"': '&quot;',
643 "'": '&#039;'
644 };
645 return text.replace(/[&<>\"']/g, function(m) { return map[m]; });
646 }
647
648 function makeAllQuestionsRequired(button, inSection){
649 var getButtonDataFlag = button.attr("data-flag");
650 var setButtonDataFlag = false;
651 var thisCheckbox = button.find(".make-questions-required-checkbox");
652 var requiredInputs = jQuery(document).find("#tab1 .ays-survey-input-required-question.ays-switch-checkbox");
653 if(inSection){
654 thisCheckbox = button.parent().find(".make-questions-required-checkbox");
655 requiredInputs = button.parents('.ays-survey-section-box').find(".ays-survey-input-required-question.ays-switch-checkbox");
656 }
657
658 if(getButtonDataFlag == "off"){
659 setButtonDataFlag = false;
660 button.attr("data-flag" , "on");
661 button.find("img.ays-survey-required-section-img").show();
662 }
663 else{
664 setButtonDataFlag = true;
665 button.attr("data-flag" , "off");
666 button.find("img.ays-survey-required-section-img").hide();
667 }
668 thisCheckbox.prop("checked", !setButtonDataFlag);
669
670 if(thisCheckbox.prop("checked")){
671 requiredInputs.prop("checked" , true);
672 }
673 else{
674 requiredInputs.prop("checked" , false);
675 }
676
677 }
678
679 function aysSurveystripHTML( dirtyString ) {
680 var container = document.createElement('div');
681 var text = document.createTextNode(dirtyString);
682 container.appendChild(text);
683
684 return container.innerHTML; // innerHTML will be a xss safe string
685 }
686 //})(jQuery);
687