summaryrefslogtreecommitdiffstats
path: root/admin/survey/script/zoom.js
blob: debc25460a134076fa76ea7bd086602810c69cdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
function showZoomSettings() {
	$('#fade').fadeTo('slow', 1);
	$('#fullscreen').html('')
	$('#zoom_div').load('ajax.php?t=zoom&a=showProfile', {anketa:srv_meta_anketa_id}).fadeIn('slow');	
}
function zoomChangeProfile(pid) {
	$.post( 'ajax.php?t=zoom&a=changeProfile', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran, pid:pid }, function() {
		$("#zoom_div").load( 'ajax.php?t=zoom&a=showProfile', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran, pid:pid });
	});
}
function removeZoomProfile() {
	$.post( 'ajax.php?t=zoom&a=changeProfile', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran,pid:0 }, function() {
		return reloadData('zoom');
	});
}
function removeZoomCheckbox() {

	$.post( 'ajax.php?t=zoom&a=removeZoomCheckbox', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran,pid:0 }, function() 
		{
			return reloadData('zoom');
		}
	);
}
function zoomProfileAction(action) {
	
	if (action == 'cancel') {		
		$("#zoom_div").hide(200);	
		return reloadData('zoom');
		
	} else if (action == 'runProfile' || action == 'run_session_profile') {
		// poiščemo id izbranega profila
		if (action == 'runProfile') {
			var pid = $("#zoom_profiles .active").attr('value');
		} else {
			var pid = '-1';
		}
		
		var vars = new Array();
		$('input[name="zoom_vars"]:checked').each(function(index,el) {
			vars.push($(el).val());
		});
		
		if (vars.length > 0) {
			$("#zoom_div").hide(200);
			$("#zoom_div").load("ajax.php?t=zoom&a=saveProfile", {anketa:srv_meta_anketa_id, pid:pid, vars:vars, action:action}, function(response) {
				return reloadData('zoom');
			});
		} else {
			$('#zoom_div').load('ajax.php?t=zoom&a=showProfile', {anketa:srv_meta_anketa_id, error:'srv_zoom_error_no_var'}).fadeIn('slow');
		}
	} else if (action == 'showRename'){
		//$("#zoom_cover_div").show();
		$("#zoom_div div#renameProfileDiv").show();
	} else if (action == 'cancelRename'){
		//$("#zoom_cover_div").hide();
		$("#zoom_div div#renameProfileDiv").hide();
	} else if (action == 'doRename'){
		var pid = $("#zoom_profiles .active").attr('value');
		var name = $("#zoom_div div#renameProfileDiv input#renameProfileName").val();
		
		$.post('ajax.php?t=zoom&a=renameProfile', { anketa : srv_meta_anketa_id, pid : pid, name:name  }, function() {
			$("#zoom_div").load('ajax.php?t=zoom&a=showProfile', {
				anketa : srv_meta_anketa_id,
				meta_akcija : srv_meta_akcija,
				podstran : srv_meta_podstran
			}, function () {
				$("#zoom_div div#renameProfileDiv").hide();
				//$("#zoom_cover_div").fadeOut();
			});
		});

	} else if (action == 'showDelete'){
		//$("#zoom_cover_div").show();
		$("#zoom_div div#deleteProfileDiv").show();
	} else if (action == 'cancelDelete'){
		//$("#zoom_cover_div").hide();
		$("#zoom_div div#deleteProfileDiv").hide();
	} else if (action == 'newName'){
		var vars = new Array();
		$('#zoom_div input[name="zoom_vars"]:checked').each(function(index,el) {
			vars.push($(el).val());
		});

		if (vars.length > 0) {
			//$("#zoom_cover_div").show();
			$("#zoom_div div#newProfileDiv").show();
		} else {
			genericAlertPopup('alert_choose_variables');
		}

	} else if (action == 'newCancel'){
		//$("#zoom_cover_div").hide();
		$("#zoom_div div#newProfileDiv").hide();
	} else if (action == 'newCreate'){
		var name = $("#zoom_div div#newProfileDiv input#newProfileName").val();
		var vars = new Array();
		$('#zoom_div input[name="zoom_vars"]:checked').each(function(index,el) {
			vars.push($(el).val());
		});
		
		// kreiramo nov profil z novim id
		//$.post('ajax.php?t=zoom&a=create_condition_profile', { 
		$.post('ajax.php?t=zoom&a=createNewProfile', { 
			anketa : srv_meta_anketa_id, name : name, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran, vars:vars }, function(data) {
				data = jQuery.parseJSON(data);
				if (data.error == '0') {
					if (data.newId > 0) {
						zoomChangeProfile(data.newId);
						//$("#div_condition_profiles").load('ajax.php?t=conditionProfile&a=show_condition_profile', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran, pid: newId });
						// dropdownu dodamo nov prodil in ga izberemo
							//$("#current_condition_profile").append( $("<option></option>").attr("value", newId).attr( "selected", true).text(name));
					} else {
						genericAlertPopup('alert_parameter_datamsg',data.msg);
					}
				} else {
					genericAlertPopup('alert_parameter_datamsg',data.msg);
				}
		});
		//$("#zoom_cover_div").hide();
		//$("#zoom_div div#newProfileDiv").hide();
	} else if (action == 'doDelete'){
		var pid = $("#zoom_profiles div.active").attr('value');
		$.post('ajax.php?t=zoom&a=deleteProfile', { anketa : srv_meta_anketa_id, pid : pid }, function() {
			$("#zoom_div").load('ajax.php?t=zoom&a=showProfile', {
						anketa : srv_meta_anketa_id,
						meta_akcija : srv_meta_akcija,
						podstran : srv_meta_podstran
					});
		});
		$("#zoom_div div#deleteProfileDiv").hide();
		//$("#zoom_cover_div").fadeOut();
	} else {
		genericAlertPopup('alert_parameter_action',action);	
	}
}

function  changeZoomCheckbox() {
	// poišemo vse obkljukane checkboxe
	var vars = new Array();
	$('#div_zoom_condition input:checked').each(function(index,el) {
		vars.push($(el).val());
	});
	
	$("#div_analiza_data").load('ajax.php?t=zoom&a=changeZoomCheckbox', { anketa : srv_meta_anketa_id, meta_akcija : srv_meta_akcija, podstran : srv_meta_podstran, vars:vars});

	// če imamo pogoj  naj bo gumb odstrani samo spodaj pri pogoju
	if (vars.length > 0 ) {
		$("#span_zoom_condition_remove").hide();
	} else {
		$("#span_zoom_condition_remove").show();
	}
}

function toggleAllZoom(what) {
	// shranimo v sehjo extendet
	$.post('ajax.php?t=zoom&a=togleExtended', { anketa : srv_meta_anketa_id, what:what}, function() {
		
		if (what == 0) {
			$("#div_zoom_condition ul").parent().removeClass('displayNone');	
			$("#div_zoom_condition #zoomSpritesMinus").removeClass('displayNone');	
			$("#div_zoom_condition #zoomSpritesPlus").addClass('displayNone');	
		} else {
			$("#div_zoom_condition ul").parent().addClass('displayNone');		
			$("#div_zoom_condition #zoomSpritesMinus").addClass('displayNone');
			$("#div_zoom_condition #zoomSpritesPlus").removeClass('displayNone');
		}
	});
}

function toggleShowZoomVariables(what) {
	// shranimo v sehjo extendet
	$.post('ajax.php?t=zoom&a=toggleShowZoomVariables', { anketa : srv_meta_anketa_id, what:what}, function() {
		if (what == 0) {
			$("#div_zoom_condition").show();	
			$("#conditionProfileNote #zoomSpritesMinus1").show();	
			$("#conditionProfileNote #zoomSpritesPlus1").hide();	
		} else {
			$("#div_zoom_condition").hide();
			$("#conditionProfileNote #zoomSpritesMinus1").hide();	
			$("#conditionProfileNote #zoomSpritesPlus1").show();	
		}
	});
}