Projekt

Allgemein

Profil

GX-Bug #22325 » gm_gprint-USERMOD.js

Daniel Wu, 30.01.2014 14:07

 
1
/* gm_gprint.js <?php
2
#   --------------------------------------------------------------
3
#   gm_gprint.js 2013-03-06 gm
4
#   Gambio GmbH
5
#   http://www.gambio.de
6
#   Copyright (c) 2013 Gambio GmbH
7
#   Released under the GNU General Public License (Version 2)
8
#   [http://www.gnu.org/licenses/gpl-2.0.html]
9
#   --------------------------------------------------------------
10
?>*/
11

    
12
<?php
13
if($_SESSION['customers_status']['customers_status_id'] === '0' && $_GET['mode'] == 'backend')
14
{
15
	define('GM_GPRINT_ADMIN', true);
16
}
17

    
18
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/jquery/plugins/ajaxfileupload/ajaxfileupload.js'));
19
?>
20

    
21
var c_mode = encodeURIComponent('<?php echo gm_prepare_string($_GET['mode']); ?>');
22

    
23
if(typeof(gm_session_id) == 'undefined')
24
{
25
	var gm_session_id = '<?php echo gm_prepare_string($_GET['XTCsid']); ?>';
26
}
27
gm_session_id = encodeURIComponent(gm_session_id);
28

    
29

    
30
var t_current_page = '<?php echo gm_prepare_string($_GET['page']); ?>';
31

    
32
var coo_surfaces_manager = null;
33
var coo_surfaces_groups_manager = null;
34
var coo_gprint_configuration = null;
35
var coo_cart_wishlist_manager = null;
36

    
37
var t_gprint_dragging = false;
38

    
39
<?php
40
if(defined('GM_GPRINT_ADMIN'))
41
{
42
?>
43
var t_hover_element = false;
44
<?php
45
}
46
?>
47

    
48
<?php
49
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/gm_gprint_functions.js'));
50
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintConfiguration.js'));
51
if(defined('GM_GPRINT_ADMIN'))
52
{
53
	include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintSurfacesGroupsManager.js'));
54
}
55
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintSurfacesManager.js'));
56
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintSurfaces.js'));
57
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintElements.js'));
58
include_once(get_usermod(DIR_FS_CATALOG . 'gm/javascript/GMGPrintCartWishlistManager.js'));
59
?>
60

    
61
function update_current_surface()
62
{
63
	var f_width = $('#current_surface_width').val();
64
    var f_height = $('#current_surface_height').val();
65
    
66
    var c_width = gm_gprint_clear_number(f_width);
67
    var c_height = gm_gprint_clear_number(f_height);
68
    
69
    coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].update_size(coo_surfaces_manager.get_current_surfaces_id(), c_width, c_height);
70
    
71
    var t_surfaces_names = new Object();
72
    var t_surface_language_id = '';
73
    
74
    $('.current_surface_name').each(function()
75
	{
76
        t_surface_language_id = $(this).attr('id');
77
        t_surface_language_id = t_surface_language_id.replace(/current_surface_language_/g, '');
78
        t_surfaces_names[t_surface_language_id] = this.value;
79
    });
80
    
81
    coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].update_names(coo_surfaces_manager.get_current_surfaces_id(), t_surfaces_names);
82
    coo_surfaces_manager.display_surface(coo_surfaces_manager.get_current_surfaces_id(), coo_gprint_configuration);
83
    
84
    $('.gm_gprint_wait').hide();
85
}
86

    
87
function update_current_element()
88
{
89
	var f_width = $('#current_element_width').val();
90
    var f_height = $('#current_element_height').val();
91
    var f_position_x = $('#current_element_position_x').val();
92
    var f_position_y = $('#current_element_position_y').val();
93
    var f_z_index = $('#current_element_z_index').val();
94
    var f_max_characters = $('#current_element_max_characters').val();
95
    var f_allowed_extensions = $('#current_element_allowed_extensions').val();
96
    var f_minimum_filesize = $('#current_element_minimum_filesize').val();
97
    var f_maximum_filesize = $('#current_element_maximum_filesize').val();
98
    
99
    var c_width = gm_gprint_clear_number(f_width);
100
    var c_height = gm_gprint_clear_number(f_height);
101
    var c_position_x = gm_gprint_clear_number(f_position_x);
102
    var c_position_y = gm_gprint_clear_number(f_position_y);
103
    var c_z_index = gm_gprint_clear_number(f_z_index);
104
    var c_max_characters = gm_gprint_clear_number(f_max_characters);
105
    
106
    var t_show_name = 0;
107
    
108
    if($('#current_element_show_name:checked').val() == '1')
109
    {
110
    	t_show_name = 1;
111
    }
112
    
113
    var t_element_language_id = '';
114
    var t_elements_names = new Object();
115
    
116
    $('.current_element_name').each(function()
117
	{
118
        t_element_language_id = $(this).attr('id');
119
        t_element_language_id = t_element_language_id.replace(/current_element_name_/g, '');
120
        t_elements_names[t_element_language_id] = this.value;
121
    });
122
    
123
    var t_elements_values = new Object();        
124
    var count_values_key = 0;
125
    var t_element_language_id_copy = '0';
126
    
127
    $('.current_element_value').each(function()
128
    {
129
    	t_element_language_id = $(this).attr('name');
130
    	t_element_language_id = t_element_language_id.replace(/current_element_language_/g, '');
131
                
132
    	if(t_element_language_id_copy != t_element_language_id)
133
    	{
134
    		count_values_key = 0;
135
    	}
136
                
137
    	if(typeof(t_elements_values[t_element_language_id]) != 'object')
138
    	{
139
    		t_elements_values[t_element_language_id] = new Object();
140
    	}
141

    
142
    	t_elements_values[t_element_language_id][count_values_key] = this.value;
143
                
144
    	count_values_key++;
145
                
146
    	t_element_language_id_copy = t_element_language_id; 
147
    });
148

    
149
    coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].v_elements[coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].get_current_elements_id()].update(c_width, c_height, c_position_x, c_position_y, c_z_index, c_max_characters, t_show_name, t_elements_names, t_elements_values, f_allowed_extensions, f_minimum_filesize, f_maximum_filesize);
150
    
151
    if($('.edit_element_image').css('display') == 'none')
152
    {
153
    	$('.gm_gprint_wait').hide();
154
    }
155
}
156

    
157
$(document).ready(function()
158
{
159
	coo_gprint_configuration = new GMGPrintConfiguration();
160
	<?php
161
	if(!empty($_GET['id']) && defined('GM_GPRINT_ADMIN'))
162
	{
163
	?>
164
	coo_gprint_configuration.load();
165
	<?php
166
	}
167
	else
168
	{
169
		echo 'coo_gprint_configuration.set_languages_id(' . $_SESSION['languages_id'] . ');';
170
	}
171
	?>
172
	
173
	<?php
174
	if(!empty($_GET['id']) && defined('GM_GPRINT_ADMIN'))
175
	{
176
		echo 'coo_surfaces_manager = new GMGPrintSurfacesManager(' . (int)$_GET['id'] . ', coo_gprint_configuration);';
177
		echo 'coo_surfaces_manager.load_surfaces_group(' . (int)$_GET['id'] . ');';
178
	}
179
	elseif(!defined('GM_GPRINT_ADMIN'))
180
	{
181
		echo 'coo_cart_wishlist_manager = new GMGPrintCartWishlistManager();';
182
		
183
		if(!empty($_GET['id']))
184
		{
185
			?>
186
			// TODO: get position from DB
187
			var t_gprint_position = '<?php if(gm_get_env_info('TEMPLATE_VERSION') >= FIRST_GX2_TEMPLATE_VERSION){ echo gm_get_conf('CUSTOMIZER_POSITION'); }else{ echo '3';} ?>';
188

    
189
			switch(t_gprint_position)
190
			{
191
				case '1': // append set to description
192

    
193
					if($('#tabbed_description_part ul li a:first').length > 0)
194
					{
195
						var t_description_id = $('#tabbed_description_part ul li a:first').attr('href');
196
						if(t_description_id.indexOf('#') !== 0)
197
						{
198
							t_description_id = t_description_id.substring(t_description_id.indexOf('#'));
199
						}
200
						$(t_description_id).append($('#tab_gx_customizer'));
201
					}
202

    
203
					break;
204
				case '2': // set as new tab
205
					$('#tabbed_description_part').tabs('add', '#tab_customizer', 'Customize');
206
					$('#tab_customizer').html($('#tab_gx_customizer'));
207
					
208
					break;
209
				case '3': // as placed in template
210
				default:
211
			}
212

    
213
			<?php
214
			echo 'coo_surfaces_manager = new GMGPrintSurfacesManager(' . (int)$_GET['id'] . ', coo_gprint_configuration);';
215
			echo 'coo_surfaces_manager.load_surfaces_group(' . (int)$_GET['id'] . ', \'' . addslashes($_GET['product']) . '\');';
216
			echo '$(\'#details_cart_part\').show();';
217
			
218
		}
219
	}
220
	?>
221
	
222
	<?php
223
	if(defined('GM_GPRINT_ADMIN'))
224
	{
225
	?>
226
	
227
	$('#copy_surfaces_group').click(function()
228
	{	
229
		var f_surfaces_group_name = $('#surfaces_group_name_copy').val();
230
		var f_surfaces_groups_id = $('#copy_surfaces_groups_id').val();
231
		var c_surfaces_groups_id = gm_gprint_clear_number(f_surfaces_groups_id);
232
        
233
        // noch saeubern
234
        var c_surfaces_group_name = encodeURIComponent(f_surfaces_group_name); 
235
        
236
        if(c_surfaces_group_name != '' || c_surfaces_groups_id > 0)
237
        {
238
        	var t_surfaces_groups_id = jQuery.ajax({
239
	            data: 'action=copy_surfaces_group&name=' + c_surfaces_group_name + '&surfaces_groups_id=' + c_surfaces_groups_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
240
	            url: '<?php echo GM_HTTP_SERVER . DIR_WS_CATALOG; ?>gm_gprint_ajax.php',
241
	            type: "POST",
242
	            async: false
243
	        }).responseText;
244

    
245
        	location.reload();
246
        }
247
	});
248
	
249
	$('#create_surfaces_group').click(function()
250
	{
251
        var f_surfaces_group_name = $('#surfaces_group_name').val();
252
        
253
        coo_surfaces_groups_manager = new GMGPrintSurfacesGroupsManager();
254
        coo_surfaces_groups_manager.create(f_surfaces_group_name);
255
        coo_surfaces_manager = new GMGPrintSurfacesManager(coo_surfaces_groups_manager.get_surfaces_groups_id(), coo_gprint_configuration);
256
        
257
        document.location.href = 'gm_gprint.php?id=' + coo_surfaces_manager.get_surfaces_groups_id() + '&action=edit&languages_id=<?php echo $_SESSION['languages_id']; ?>';
258
    });
259
    
260
    $('.surfaces_groups').click(function()
261
	{
262
        coo_surfaces_manager = new GMGPrintSurfacesManager($(this).attr('id'), coo_gprint_configuration);
263
        coo_surfaces_manager.load_surfaces_group($(this).attr('id'));
264
    });
265
    
266
    $('#rename_surfaces_group').click(function()
267
    {
268
    	var t_surfaces_groups_id = $('#rename_surfaces_groups_id').val();
269
    	coo_surfaces_manager = new GMGPrintSurfacesManager(t_surfaces_groups_id, coo_gprint_configuration);
270
    	coo_surfaces_manager.update_name($('#surfaces_group_name_rename').val());
271
    	$('#set_name_' + t_surfaces_groups_id).html($('#surfaces_group_name_rename').val());
272
    	$('#gm_gprint_save_sucsess').show();
273
    	setTimeout("$('#gm_gprint_save_sucsess').fadeOut('slow')", 10000);
274
	});
275
    
276
    $('#create_surface').click(function()
277
	{
278
        $('.gm_gprint_wait').show();
279
    	
280
    	var t_surfaces_names = new Object();
281
		var f_width = $('#surface_width').val();
282
        var f_height = $('#surface_height').val();
283
        
284
        var c_width = gm_gprint_clear_number(f_width);
285
        var c_height = gm_gprint_clear_number(f_height);
286
        
287
        var t_surface_language_id = '';
288
        
289
        $('.surface_name').each(function()
290
		{
291
            t_surface_language_id = $(this).attr('id');
292
            t_surface_language_id = t_surface_language_id.replace(/surface_language_/g, '');
293
            t_surfaces_names[t_surface_language_id] = this.value;
294
        });
295
        
296
        coo_surfaces_manager.create_surface(t_surfaces_names, c_width, c_height);
297
        
298
        coo_surfaces_manager.display_surface(coo_surfaces_manager.get_current_surfaces_id(), coo_gprint_configuration);
299
        coo_surfaces_manager.activate_tabs();
300
        
301
        $('#create_surface_div').hide();
302
        
303
        // clear input field
304
        $('.surface_name').val('');        
305
        
306
        $('#edit_surface_div').show();
307
        $('.gm_gprint_wait').hide();
308
    });
309
    
310
    $('#create_element').click(function()
311
	{
312
    	$('.gm_gprint_wait').show();
313
    	
314
        var t_elements_values = new Object();
315
        var t_elements_names = new Object();
316
        var f_type = $('#element_type').val();
317
        var f_width = $('#element_width').val();
318
        var f_height = $('#element_height').val();
319
        var f_position_x = $('#element_position_x').val();
320
        var f_position_y = $('#element_position_y').val();
321
        var f_z_index = $('#element_z_index').val();
322
        var f_max_characters = $('#element_max_characters').val();
323
        var f_allowed_extensions = $('#element_allowed_extensions').val();
324
        var f_minimum_filesize = $('#element_minimum_filesize').val();
325
        var f_maximum_filesize = $('#element_maximum_filesize').val();
326
        
327
        var t_element_language_id = '';
328
        
329
        $('.element_name').each(function()
330
        {
331
        	t_element_language_id = $(this).attr('id');
332
        	t_element_language_id = t_element_language_id.replace(/element_name_/g, '');
333
        	t_elements_names[t_element_language_id] = this.value;
334
        });
335
        
336
        var count_values_key = 0;
337
        var t_element_language_id_copy = '0';
338
        
339
        $('.element_value').each(function()
340
		{
341
        	t_element_language_id = $(this).attr('name');
342
            t_element_language_id = t_element_language_id.replace(/element_language_/g, '');
343
            
344
            if(t_element_language_id_copy != t_element_language_id)
345
            {
346
            	count_values_key = 0;
347
            }
348
            
349
            if(typeof(t_elements_values[t_element_language_id]) != 'object')
350
            {
351
            	t_elements_values[t_element_language_id] = new Object();
352
            }
353
            
354
            t_elements_values[t_element_language_id][count_values_key] = this.value;
355
            
356
            count_values_key++;
357
            
358
            t_element_language_id_copy = t_element_language_id; 
359
        });
360

    
361
        var c_width = gm_gprint_clear_number(f_width);
362
        var c_height = gm_gprint_clear_number(f_height);
363
        var c_position_x = gm_gprint_clear_number(f_position_x);
364
        var c_position_y = gm_gprint_clear_number(f_position_y);
365
        var c_z_index = gm_gprint_clear_number(f_z_index);
366
        var c_max_characters = gm_gprint_clear_number(f_max_characters);
367
        
368
        var t_show_name = 0;
369
        if($('#element_show_name:checked').val() == '1')
370
        {
371
        	 t_show_name = 1;
372
        }
373
        
374
        coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].create_element(f_type, c_width, c_height, c_position_x, c_position_y, c_z_index, c_max_characters, t_show_name, t_elements_names, t_elements_values, f_allowed_extensions, f_minimum_filesize, f_maximum_filesize, true);
375
    
376
        switch(f_type)
377
		{
378
			case 'text':
379
				$('.edit_element_size').show();
380
				$('.edit_element_value').show();
381
				$('.edit_element_image').hide();
382
				$('.edit_element_max_characters').val('');
383
				$('.edit_element_max_characters').hide();
384
				$('.edit_element_show_name').removeAttr('checked');
385
				$('.edit_element_show_name').hide();
386
				$('.edit_element_allowed_extensions').val('');
387
				$('.edit_element_allowed_extensions').hide();
388
				$('.edit_element_minimum_filesize').val('');
389
				$('.edit_element_minimum_filesize').hide();
390
				$('.edit_element_maximum_filesize').val('');
391
				$('.edit_element_maximum_filesize').hide();
392
				
393
				break;
394
			case 'text_input':
395
				$('.edit_element_size').show();
396
				$('.edit_element_value').show();
397
				$('.edit_element_image').hide();
398
				$('.edit_element_max_characters').show();
399
				$('.edit_element_show_name').show();
400
				$('.edit_element_allowed_extensions').val('');
401
				$('.edit_element_allowed_extensions').hide();
402
				$('.edit_element_minimum_filesize').val('');
403
				$('.edit_element_minimum_filesize').hide();
404
				$('.edit_element_maximum_filesize').val('');
405
				$('.edit_element_maximum_filesize').hide();
406
				
407
				break;
408
			case 'textarea':
409
				$('.edit_element_size').show();
410
				$('.edit_element_value').show();
411
				$('.edit_element_image').hide();
412
				$('.edit_element_max_characters').show();
413
				$('.edit_element_show_name').show();
414
				$('.edit_element_allowed_extensions').val('');
415
				$('.edit_element_allowed_extensions').hide();
416
				$('.edit_element_minimum_filesize').val('');
417
				$('.edit_element_minimum_filesize').hide();
418
				$('.edit_element_maximum_filesize').val('');
419
				$('.edit_element_maximum_filesize').hide();
420
				
421
				break;
422
			case 'file':
423
				$('.edit_element_size').show();
424
				$('.edit_element_value').hide();
425
				$('.edit_element_image').hide();
426
				$('.edit_element_max_characters').val('');
427
				$('.edit_element_max_characters').hide();
428
				$('.edit_element_show_name').removeAttr('checked');
429
				$('.edit_element_show_name').hide();
430
				$('.edit_element_allowed_extensions').show();
431
				$('.edit_element_minimum_filesize').show();
432
				$('.edit_element_maximum_filesize').show();
433
				
434
				break;
435
			case 'dropdown':
436
				$('.edit_element_size').show();
437
				$('.edit_element_value').show();
438
				$('.edit_element_image').hide();
439
				$('.edit_element_max_characters').show();
440
				$('.edit_element_show_name').show();
441
				$('.edit_element_allowed_extensions').val('');
442
				$('.edit_element_allowed_extensions').hide();
443
				$('.edit_element_minimum_filesize').val('');
444
				$('.edit_element_minimum_filesize').hide();
445
				$('.edit_element_maximum_filesize').val('');
446
				$('.edit_element_maximum_filesize').hide();
447
				
448
				break;
449
			case 'image':
450
				$('.edit_element_size').hide();
451
				$('.edit_element_value').hide();
452
				$('.edit_element_image').show();	
453
				$('.edit_element_max_characters').val('');
454
				$('.edit_element_max_characters').hide();
455
				$('.edit_element_show_name').removeAttr('checked');
456
				$('.edit_element_show_name').hide();
457
				$('.edit_element_allowed_extensions').val('');
458
				$('.edit_element_allowed_extensions').hide();
459
				$('.edit_element_minimum_filesize').val('');
460
				$('.edit_element_minimum_filesize').hide();
461
				$('.edit_element_maximum_filesize').val('');
462
				$('.edit_element_maximum_filesize').hide();
463
				
464
				break;
465
		}
466
        
467
        $('#create_element_div').hide();
468
        
469
        // clear input fields
470
        $('.element_name').val('');
471
        $('.element_value').val('');
472
        
473
        $('#edit_element_div').show();
474
        
475
        if(f_type != 'image')
476
        {
477
        	$('.gm_gprint_wait').hide();
478
        }
479
	});
480
    
481
    $('#update_current_surface').click(function()
482
	{
483
    	$('.gm_gprint_wait').show();
484
    	 
485
    	// set timeout to avoid problems with IE, Safari and Chrome not showing loading image
486
    	if(navigator.userAgent.search(/MSIE/) != -1
487
        	|| navigator.userAgent.search(/Safari/) != -1
488
        	|| navigator.userAgent.search(/Chrome/) != -1)
489
    	{
490
    		setTimeout('update_current_surface()', 500);
491
    	}
492
    	else
493
    	{
494
    		update_current_surface();
495
    	}
496
	});
497
    
498
    $('#update_current_element').click(function()
499
	{
500
    	$('.gm_gprint_wait').show();
501

    
502
    	// set timeout to avoid problems with IE, Safari and Chrome not showing loading image
503
    	if(navigator.userAgent.search(/MSIE/) != -1
504
    		|| navigator.userAgent.search(/Safari/) != -1
505
    		|| navigator.userAgent.search(/Chrome/) != -1)
506
    	{
507
    		setTimeout('update_current_element()', 500);
508
    	}
509
    	else
510
    	{
511
    		update_current_element();
512
    	}
513
	});
514
    
515
    $('#delete_current_surface').click(function()
516
	{
517
    	$('.gm_gprint_wait').show();
518
    	
519
    	coo_surfaces_manager.delete_surface(coo_surfaces_manager.get_current_surfaces_id());
520
    	
521
    	$('.gm_gprint_wait').hide();
522
        $('.gm_gprint_flyover').hide();
523
    });
524
    
525
    $('#delete_current_element').click(function()
526
	{
527
    	$('.gm_gprint_wait').show();
528

    
529
    	coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].delete_element(coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].get_current_elements_id());
530
    	
531
    	$('.gm_gprint_wait').hide();
532
    	$('.gm_gprint_flyover').hide();
533
	});
534
	
535
	$('#show_create_surface_flyover').click(function()
536
	{
537
		$('.gm_gprint_flyover').show();
538
		$('#create_surface_div').show();
539
		$('#create_element_div').hide();
540
		$('#edit_surface_div').hide();
541
		$('#edit_element_div').hide();
542
	});
543
	
544
	$('#hide_create_surface_flyover, #hide_create_element_flyover, #hide_edit_surface_flyover, #hide_edit_element_flyover').click(function()
545
	{
546
		$('.gm_gprint_flyover').hide();
547
	});
548
	
549
	$('#show_create_element_flyover').click(function()
550
	{
551
		$('.gm_gprint_flyover').show();
552
		$('#create_surface_div').hide();
553
		$('#create_element_div').show();
554
		$('#edit_surface_div').hide();
555
		$('#edit_element_div').hide();
556
	});
557
	
558
	$('#show_edit_surface_flyover').click(function()
559
	{
560
		$('.gm_gprint_flyover').show();
561
		$('#create_surface_div').hide();
562
		$('#create_element_div').hide();
563
		$('#edit_surface_div').show();
564
		$('#edit_element_div').hide();
565
	});
566
	
567
	$('#show_edit_element_flyover').click(function()
568
	{
569
		$('.gm_gprint_flyover').show();
570
		$('#create_surface_div').hide();
571
		$('#create_element_div').hide();
572
		$('#edit_surface_div').hide();
573
		$('#edit_element_div').show();
574
	});
575
	
576
	/*
577
	function gm_gprint_next_z_index()
578
	{
579
		var t_flyover_z_index = 0;
580
		var t_max_flyover_z_index = 0;
581
			
582
		$('.gm_gprint_flyover').each(function()
583
		{
584
			t_flyover_z_index = $(this).css('z-index');
585
			t_flyover_z_index = Number(t_flyover_z_index);
586
			if(t_flyover_z_index > t_max_flyover_z_index)
587
			{
588
				t_max_flyover_z_index = t_flyover_z_index;				
589
			}
590
		});
591
		t_max_flyover_z_index++;
592
		
593
		return t_max_flyover_z_index;
594
	}
595
	
596
	$('.gm_gprint_flyover').click(function()
597
	{
598
		$(this).css({
599
			'z-index': gm_gprint_next_z_index()
600
		});
601
	});
602
	
603
	$('.gm_gprint_flyover').draggable({
604
		start: function()
605
		{
606
			$(this).css({
607
				'z-index': gm_gprint_next_z_index()
608
			});
609
		}
610
	});
611
	*/
612
	
613
	$('.gm_gprint_flyover').draggable();
614
	
615
	var t_create_value_fields = new Object();
616
	var t_create_value_fields_key = '';
617
	
618
	$('.create_element_value_fields').each(function()
619
	{
620
		t_create_value_fields_key = $(this).attr('id').replace(/create_element_value_fields_/g, '');
621
		t_create_value_fields[t_create_value_fields_key] = $(this).html();
622
	});
623

    
624
	$('#create_element_div .add_field').click(function()
625
	{
626
		for(t_create_element_value_fields_id in t_create_value_fields)
627
		{
628
			$('#create_element_value_fields_' + t_create_element_value_fields_id).append('<input style="margin-top: 5px;" type="text" class="element_value" name="element_language_' + t_create_element_value_fields_id + '" /><br />');
629
		}
630
	});
631
	
632
	$('#create_element_div .remove_field').click(function()
633
			{
634
				var t_create_element_value_fields = '';
635
				
636
				for(t_create_element_value_fields_id in t_create_value_fields)
637
				{
638
					t_create_element_value_fields = $('#create_element_value_fields_' + t_create_element_value_fields_id).html();
639
					if(t_create_element_value_fields.toLowerCase().lastIndexOf('<input') > 0)
640
					{
641
						t_create_element_value_fields = t_create_element_value_fields.substring(0, t_create_element_value_fields.toLowerCase().lastIndexOf('<input'));
642
						$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_element_value_fields);
643
					}
644
				}
645
			});
646
	
647
	$('#edit_element_div .add_field').click(function()
648
	{
649
		for(t_create_element_value_fields_id in t_create_value_fields)
650
		{
651
			$('#edit_element_value_fields_' + t_create_element_value_fields_id).append('<input style="margin-bottom: 5px;" type="text" class="current_element_value" name="current_element_language_' + t_create_element_value_fields_id + '" /><br />');
652
		}
653
	});
654
	
655
	$('#edit_element_div .remove_field').click(function()
656
	{
657
		var t_edit_element_value_fields = '';
658
		
659
		for(t_create_element_value_fields_id in t_create_value_fields)
660
		{
661
			t_edit_element_value_fields = $('#edit_element_value_fields_' + t_create_element_value_fields_id).html();
662
			if(t_edit_element_value_fields.toLowerCase().lastIndexOf('<input') > 0)
663
			{
664
				t_edit_element_value_fields = t_edit_element_value_fields.substring(0, t_edit_element_value_fields.toLowerCase().lastIndexOf('<input'));
665
				$('#edit_element_value_fields_' + t_create_element_value_fields_id).html(t_edit_element_value_fields);
666
			}
667
		}
668
	});
669
	
670
	$('#element_type').change(function()
671
	{
672
		var t_element_type = $('#element_type option:selected').val();
673
		
674
		switch(t_element_type)
675
		{
676
			case 'text':
677
				$('#element_width').val('330');
678
				$('#element_height').val('100');
679
				$('.create_element_image').hide();
680
				$('.create_element_value').show();
681
				$('.create_element_size').show();
682
				$('.create_element_max_characters').val('');
683
				$('.create_element_max_characters').hide();
684
				$('#current_element_show_name').removeAttr('checked');
685
				$('.create_element_show_name').hide();
686
				$('.create_element_allowed_extensions').val('');
687
				$('.create_element_allowed_extensions').hide();
688
				$('.create_element_minimum_filesize').val('');
689
				$('.create_element_minimum_filesize').hide();
690
				$('.create_element_maximum_filesize').val('');
691
				$('.create_element_maximum_filesize').hide();
692
				
693
				$('.add_field').hide();
694
				$('.remove_field').hide();
695
				
696
				for(t_create_element_value_fields_id in t_create_value_fields)
697
				{
698
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_value_fields[t_create_element_value_fields_id]);
699
				}
700
				
701
				break;
702
			case 'text_input':
703
				$('#element_width').val('150');
704
				$('#element_height').val('20');
705
				$('.create_element_image').hide();
706
				$('.create_element_value').show();
707
				$('.create_element_size').show();
708
				$('.create_element_max_characters').show();
709
				$('.create_element_show_name').show();
710
				$('.create_element_allowed_extensions').val('');
711
				$('.create_element_allowed_extensions').hide();
712
				$('.create_element_minimum_filesize').val('');
713
				$('.create_element_minimum_filesize').hide();
714
				$('.create_element_maximum_filesize').val('');
715
				$('.create_element_maximum_filesize').hide();
716
				
717
				$('.add_field').hide();
718
				$('.remove_field').hide();
719
				
720
				for(t_create_element_value_fields_id in t_create_value_fields)
721
				{
722
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_value_fields[t_create_element_value_fields_id]);
723
				}
724
				
725
				break;
726
			case 'textarea':
727
				$('#element_width').val('330');
728
				$('#element_height').val('100');
729
				$('.create_element_image').hide();
730
				$('.create_element_value').show();
731
				$('.create_element_size').show();
732
				$('.create_element_max_characters').show();
733
				$('.create_element_show_name').show();
734
				$('.create_element_allowed_extensions').val('');
735
				$('.create_element_allowed_extensions').hide();
736
				$('.create_element_minimum_filesize').val('');
737
				$('.create_element_minimum_filesize').hide();
738
				$('.create_element_maximum_filesize').val('');
739
				$('.create_element_maximum_filesize').hide();
740
				
741
				$('.add_field').hide();
742
				$('.remove_field').hide();
743
				
744
				for(t_create_element_value_fields_id in t_create_value_fields)
745
				{
746
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_value_fields[t_create_element_value_fields_id]);
747
				}
748
				
749
				break;
750
			case 'file':
751
				$('#element_width').val('250');
752
				$('#element_height').val('23');
753
				$('.element_value').val('');
754
				$('.create_element_max_characters').val('');
755
				$('.create_element_max_characters').hide();
756
				$('#current_element_show_name').removeAttr('checked');
757
				$('.create_element_show_name').hide();
758
				$('.create_element_image').hide();
759
				$('.create_element_value').hide();
760
				$('.create_element_size').show();
761
				$('.create_element_allowed_extensions').show();
762
				$('.create_element_minimum_filesize').show();
763
				$('.create_element_maximum_filesize').show();
764
				
765
				for(t_create_element_value_fields_id in t_create_value_fields)
766
				{
767
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_value_fields[t_create_element_value_fields_id]);
768
				}
769
				
770
				break;
771
			case 'dropdown':
772
				$('#element_width').val('150');
773
				$('#element_height').val('20');
774
				$('.create_element_image').hide();
775
				$('.create_element_value').show();
776
				$('.create_element_size').show();
777
				$('.create_element_max_characters').val('');
778
				$('.create_element_max_characters').hide();
779
				$('.create_element_show_name').show();
780
				$('.create_element_allowed_extensions').val('');
781
				$('.create_element_allowed_extensions').hide();
782
				$('.create_element_minimum_filesize').val('');
783
				$('.create_element_minimum_filesize').hide();
784
				$('.create_element_maximum_filesize').val('');
785
				$('.create_element_maximum_filesize').hide();
786
				
787
				$('.add_field').show();
788
				$('.remove_field').show();
789
				
790
				for(t_create_element_value_fields_id in t_create_value_fields)
791
				{
792
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html('<input type="text" class="element_value" name="element_language_' + t_create_element_value_fields_id + '" /><br />');
793
				}
794
				
795
				break;
796
			case 'image':
797
				$('.create_element_max_characters').val('');
798
				$('.create_element_max_characters').hide();
799
				$('#current_element_show_name').removeAttr('checked');
800
				$('.create_element_show_name').hide();
801
				$('.create_element_image').show();
802
				$('.create_element_value').hide();
803
				$('.create_element_size').hide();
804
				$('.create_element_allowed_extensions').val('');
805
				$('.create_element_allowed_extensions').hide();
806
				$('.create_element_minimum_filesize').val('');
807
				$('.create_element_minimum_filesize').hide();
808
				$('.create_element_maximum_filesize').val('');
809
				$('.create_element_maximum_filesize').hide();
810
				
811
				for(t_create_element_value_fields_id in t_create_value_fields)
812
				{
813
					$('#create_element_value_fields_' + t_create_element_value_fields_id).html(t_create_value_fields[t_create_element_value_fields_id]);
814
				}
815
				
816
				break;
817
			
818
		}
819
	});
820
	
821
	<?php
822
	}
823
	?>
824
	
825
	<?php
826
	if(!defined('GM_GPRINT_ADMIN'))
827
	{
828
	?>
829

    
830
	if(t_current_page == 'ProductInfo' && $('#gm_gprint').attr('id') == 'gm_gprint')
831
	{
832
		if($('#gm_wishlist_link').attr('id') == 'gm_wishlist_link')
833
		{
834
			var t_wishlist_href = "javascript:coo_cart_wishlist_manager.get_customers_data(coo_surfaces_manager, 'wishlist');";
835
			$('#gm_wishlist_link').attr('href', t_wishlist_href);
836
		}
837
		
838
		$('#gm_wishlist_link').click(function()
839
		{
840
			$('#gm_gprint input[type="text"], #gm_gprint textarea').each(function()
841
			{
842
				var t_value = $(this).val();
843
				t_value = t_value.replace('?', '&euro;');
844
				$(this).val(t_value);
845
			});
846
			
847
			var t_product = '';
848
			
849
			var t_input_name = '';
850
			
851
			$('.gm_attr_calc_input').each(function()
852
			{
853
				t_input_name = $(this).attr('name');
854
			
855
				if(t_input_name.indexOf('id[') != -1)
856
				{
857
					if($(this).attr('type') == 'radio' && $(this).attr('checked') == true)
858
					{
859
						t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
860
					}
861
					else if($(this).attr('type') != 'radio')
862
					{
863
						t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
864
					}
865
				}
866
			});
867
			
868
			t_product_copy = t_product;
869
			t_input_name = $('#gm_gprint_random').attr('name');
870
			
871
			var t_product_random = '';
872
			t_product_random = '{' + gm_gprint_clear_number(t_input_name) + '}' + $('#gm_gprint_random').val();
873
			
874
			var t_opened_product = '<?php echo gm_prepare_string($_GET['product']); ?>';
875
						
876
			if((t_opened_product != '' && (t_opened_product.indexOf(t_product) == -1 || t_opened_product.indexOf(t_product_random) == -1)) || t_opened_product.substr(0, 4) == 'cart')
877
			{
878
				var t_random_number = Math.random() + '';
879
				t_random_number = t_random_number.substr(2, 6);
880
				
881
				if(t_random_number.substr(0, 1) == '0')
882
				{
883
					t_random_number = '1' + t_random_number.substr(1, 5);
884
				}
885
				$('#gm_gprint_random').attr('name', 'id[' + t_random_number + ']');
886
				
887
				var delete_file_id = '';
888
				var t_old_product = t_opened_product.replace(/wishlist_/g, '');
889
				t_old_product = t_old_product.replace(/cart_/g, '');
890
				
891
				var t_start = t_old_product.indexOf(t_product_random);
892
				var t_end = t_start+t_product_random.length;
893
				
894
				var t_new_product_part_1 = t_old_product.substring(0, t_start);
895
				var t_new_product_part_2 = t_old_product.substring(t_end);
896
				
897
				var t_new_product = t_new_product_part_1 + '{' + t_random_number + '}' + $('#gm_gprint_random').val() + t_new_product_part_2;
898

    
899
				var t_source = 'wishlist';
900
				if(t_opened_product.substr(0, 4) == 'cart')
901
				{
902
					t_source = 'cart';
903
				}
904
				
905
				$('.delete_file').each(function()
906
				{
907
					delete_file_id = $(this).attr('id');
908
					delete_file_id = delete_file_id.replace(/delete_file_/g, '');
909
					coo_cart_wishlist_manager.copy_file(delete_file_id, t_old_product, t_new_product, 'wishlist', t_source);
910
				});
911
			}
912
		});
913
		
914
		$('#cart_quantity').submit(function()
915
		{
916
			return false;
917
		});
918

    
919
		//$('#cart_button').unbind('click');
920

    
921
		$('#cart_button').click(function()
922
		{
923
			$('#gm_gprint input[type="text"], #gm_gprint textarea').each(function()
924
			{
925
				var t_value = $(this).val();
926
				t_value = t_value.replace('?', '&euro;');
927
				$(this).val(t_value);
928
			});
929
			
930
			var t_product = '';
931
			
932
			var t_input_name = '';
933
			
934
			$('.gm_attr_calc_input').each(function()
935
			{
936
				t_input_name = $(this).attr('name');
937
				
938
				if(t_input_name.indexOf('id[') != -1)
939
				{
940
					if($(this).attr('type') == 'radio' && $(this).attr('checked') == true)
941
					{
942
						t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
943
					}
944
					else if($(this).attr('type') != 'radio')
945
					{
946
						t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
947
					}
948
				}
949
			});
950
			
951
			t_product_copy = t_product;
952
			t_input_name = $('#gm_gprint_random').attr('name');
953

    
954
			var t_product_random = '';
955
			t_product_random = '{' + gm_gprint_clear_number(t_input_name) + '}' + $('#gm_gprint_random').val();
956
			
957
			var t_opened_product = '<?php echo gm_prepare_string($_GET['product']); ?>';
958
						
959
			if((t_opened_product != '' && (t_opened_product.indexOf(t_product) == -1 || t_opened_product.indexOf(t_product_random) == -1)) || t_opened_product.substr(0, 8) == 'wishlist')
960
			{
961
				var t_random_number = Math.random() + '';
962
				t_random_number = t_random_number.substr(2, 6);
963
				
964
				if(t_random_number.substr(0, 1) == '0')
965
				{
966
					t_random_number = '1' + t_random_number.substr(1, 5);
967
				}
968

    
969
				$('#gm_gprint_random').attr('name', 'id[' + t_random_number + ']');
970
				
971
				var delete_file_id = '';
972
				var t_old_product = t_opened_product.replace(/cart_/g, '');
973
				t_old_product = t_old_product.replace(/wishlist_/g, '');
974
				
975
				var t_start = t_old_product.indexOf(t_product_random);
976
				var t_end = t_start+t_product_random.length;
977
				
978
				var t_new_product_part_1 = t_old_product.substring(0, t_start);
979
				var t_new_product_part_2 = t_old_product.substring(t_end);
980
				
981
				var t_new_product = t_new_product_part_1 + '{' + t_random_number + '}' + $('#gm_gprint_random').val() + t_new_product_part_2;
982

    
983
				var t_source = 'cart';
984
				if(t_opened_product.substr(0, 8) == 'wishlist')
985
				{
986
					t_source = 'wishlist';
987
				}
988
				
989
				$('.delete_file').each(function()
990
				{
991
					delete_file_id = $(this).attr('id');
992
					delete_file_id = delete_file_id.replace(/delete_file_/g, '');
993
					coo_cart_wishlist_manager.copy_file(delete_file_id, t_old_product, t_new_product, 'cart', t_source);
994
				});
995
			}
996
			
997
			if(typeof(coo_dropdowns_listener) != 'undefined')
998
			{
999
				coo_dropdowns_listener.check_combi_status();
1000
			}
1001
			
1002
			coo_gm_qty_ckeck = new GMOrderQuantityChecker();
1003
			var t_gm_qty_check = coo_gm_qty_ckeck.check();
1004

    
1005
			if(t_gm_qty_check)
1006
			{
1007
				coo_cart_wishlist_manager.get_customers_data(coo_surfaces_manager, 'cart');
1008
			}
1009

    
1010
			return false;
1011
		});
1012
	}
1013
	else if(t_current_page == 'Cart')
1014
	{
1015
		$('#cart_quantity').submit(function(){
1016
			return coo_cart_wishlist_manager.update_cart();
1017
		});
1018
	}
1019
	else if(t_current_page == 'Wishlist' && $('#gm_update_wishlist').attr('id') == 'gm_update_wishlist' && $('#gm_wishlist_to_cart').attr('id') == 'gm_wishlist_to_cart')
1020
	{
1021
		var t_wishlist_delete_href = $('#gm_update_wishlist').attr('href');
1022
		t_wishlist_delete_href = t_wishlist_delete_href.replace(/:/g, ':coo_cart_wishlist_manager.update_wishlist();');
1023
		$('#gm_update_wishlist').attr('href', t_wishlist_delete_href);
1024
		
1025
		var t_wishlist_add_href = $('#gm_wishlist_to_cart').attr('href');
1026
		t_wishlist_add_href = t_wishlist_add_href.replace(/:/g, ':coo_cart_wishlist_manager.wishlist_to_cart();');
1027
		$('#gm_wishlist_to_cart').attr('href', t_wishlist_add_href);
1028
	}
1029

    
1030
	<?php
1031
	}
1032
	?>
1033
	if (typeof(coo_qty_input_resizer) == 'object')
1034
	{
1035
		coo_qty_input_resizer.init_binds();
1036
	}
1037
});
    (1-1/1)