PluginProbe
Survey Maker by AYS / 5.2.3.2
Survey Maker by AYS v5.2.3.2
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 / survey-maker-admin-terms-and-conditions.js

survey-maker-admin-terms-and-conditions.js in Survey Maker by AYS 5.2.3.2, at admin/js/survey-maker-admin-terms-and-conditions.js

88 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 'use strict';
3
4 function AysSurveyMakerCondTerms(element, options){
5 this.el = element;
6 this.$el = $(element);
7 this.htmlClassPrefix = 'ays_survey_';
8 this.dbOptions = undefined;
9 this.htmlPrefix = 'ays_';
10 this.addSection = this.htmlPrefix+'terms_and_condition_add';
11 this.init();
12
13 return this;
14 }
15
16 AysSurveyMakerCondTerms.prototype.init = function() {
17 var _this = this;
18 _this.setEvents();
19 };
20
21 AysSurveyMakerCondTerms.prototype.setEvents = function(e){
22 var _this = this;
23
24 _this.$el.on("click" , "."+_this.htmlClassPrefix+"add_new_textarea", function(){
25 _this.addTermsConds();
26 });
27
28 _this.$el.on("click" , "."+_this.htmlClassPrefix+"remove_textarea", function(){
29 _this.deleteTermsConds($(this));
30 });
31 }
32
33 AysSurveyMakerCondTerms.prototype.addTermsConds = function (element){
34 var deleteImageUrl = SurveyMakerAdmin.icons.deleteTermsAndConds;
35 var content = '';
36
37 var addedTermsandConds = this.$el.find("."+this.htmlClassPrefix+"terms_conditions_edit_block");
38 var addedTermsandCondsId = this.$el.find("."+this.htmlClassPrefix+"terms_conditions_edit_block:last-child");
39 var dataId = addedTermsandConds.length >= 1 ? addedTermsandCondsId.data("conditionId") + 1 : 1;
40
41 var termsCondsMessageAttrName = this.newTermsCondsMessageAttrName( this.addSection , dataId , "messages" );
42
43 content += '<div class = "ays_survey_terms_conditions_edit_block" data-condition-id="' + dataId + '">';
44 content += '<div class="ays_survey_terms_and_conditions_checkbox">';
45 content += '<div class="ays-survey-icons">'
46 content += '<img src="'+SurveyMakerAdmin.icons.checkboxUnchecked+'">'
47 content += '</div>'
48 content += '</div>';
49 content += '<div class="ays_survey_terms_and_conditions_textarea_div">';
50 content += '<textarea name="' + termsCondsMessageAttrName + '"></textarea>';
51 content += '</div>';
52 content += '<div class="ays_survey_icons appsMaterialWizButtonPapericonbuttonEl">';
53 content += '<img class="ays_survey_remove_textarea" src="' + deleteImageUrl + '">';
54 content += '</div>';
55 content += '</div>';
56
57 $(document).find('.ays_survey_terms_and_conditions_content').append(content);
58 }
59
60 AysSurveyMakerCondTerms.prototype.deleteTermsConds = function (element){
61 var $this = element;
62 var $thisMainParent = $this.parent().parent();
63 $thisMainParent.remove();
64 }
65
66 AysSurveyMakerCondTerms.prototype.newTermsCondsMessageAttrName = function (termCondName, termCondId, messageText){
67 var _this = this;
68 return termCondName + '['+ termCondId +']['+ messageText +']';
69
70 }
71
72 $.fn.AysSurveyTermsAndConditions = function(options) {
73 return this.each(function() {
74 if (!$.data(this, 'AysSurveyTermsAndConditions')) {
75 $.data(this, 'AysSurveyTermsAndConditions', new AysSurveyMakerCondTerms(this, options));
76 } else {
77 try {
78 $(this).data('AysSurveyTermsAndConditions').init();
79 } catch (err) {
80 console.error('AysSurveyTermsAndConditions has not initiated properly');
81 }
82 }
83 });
84 };
85
86 $(document).find('.ays_survey_terms_and_conditions_all_inputs_block').AysSurveyTermsAndConditions();
87 })(jQuery);
88