jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
if(window.ActiveXObject) {
var io = document.createElement('');
if(typeof uri== 'boolean'){
io.src = 'javascript:false';
}
else if(typeof uri== 'string'){
io.src = uri;
}
}
else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';
document.body.appendChild(io);
return io
},
createUploadForm: function(id, fileElementId)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = $('
").html(data).evalScripts();
//alert($('param', data).each(function(){alert($(this).attr('value'));}));
return data;
}
})
var c_mode = encodeURIComponent('frontend');
if(typeof(gm_session_id) == 'undefined')
{
var gm_session_id = 'fb1493c3a02d9e08bab030ec9aace4ab';
}
gm_session_id = encodeURIComponent(gm_session_id);
var t_current_page = 'product_info';
var coo_surfaces_manager = null;
var coo_surfaces_groups_manager = null;
var coo_gprint_configuration = null;
var coo_cart_wishlist_manager = null;
var t_gprint_dragging = false;
function gm_gprint_clear_number(p_number)
{
var t_number = '' + p_number; // convert into string
var c_number = '';
var t_numbers = '0123456789';
for(var i = 0; i < t_number.length; i++)
{
if (t_numbers.indexOf(t_number.charAt(i)) != -1)
{
c_number += t_number.charAt(i);
}
}
c_number = Number(c_number);
return c_number;
}
function gm_unescape(p_value)
{
var t_value;
p_value = p_value + '';
if(typeof(p_value) == 'object')
{
t_value = p_value;
for(var t_key in p_value)
{
t_value[t_key] = p_value[t_key].split('+').join('%20');
t_value[t_key] = t_value[t_key].split('%80').join('€');
t_value[t_key] = unescape(t_value[t_key]);
}
}
else
{
p_value = p_value.split('%80').join('€');
t_value = unescape(p_value.split('+').join('%20'));
}
return t_value;
}
function gm_encodeURIComponent(p_value)
{
var t_value;
if(typeof(p_value) == 'object')
{
t_value = p_value;
for(var t_key in p_value)
{
t_value[t_key] = encodeURIComponent(p_value[t_key]);
}
}
else
{
t_value = encodeURIComponent(p_value[t_key]);
}
return t_value;
}
function GMGPrintConfiguration()
{
this.v_languages_id = '0';
this.v_languages_ids = new Array();
this.v_configuration = new Object();
this.load = function()
{
var t_configuration = new Object();
var c_languages_id = encodeURIComponent(this.get_languages_id());
jQuery.ajax({
data: 'action=load_configuration&languages_id=' + c_languages_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
dataType: 'json',
type: "POST",
async: false,
success: function(p_configuration)
{
t_configuration = p_configuration;
}
});
this.set_languages_id(t_configuration.v_languages_id);
this.set_languages_ids(t_configuration.v_languages_ids);
}
this.set_languages_id = function(p_languages_id)
{
this.v_languages_id = p_languages_id;
}
this.set_languages_ids = function(p_languages_ids)
{
this.v_languages_ids = p_languages_ids;
}
this.get_languages_id = function()
{
return this.v_languages_id;
}
this.get_languages_ids = function()
{
return this.v_languages_ids;
}
}
function GMGPrintSurfacesManager(p_surfaces_groups_id, p_coo_gprint_configuration)
{
this.v_surfaces = new Object();
this.v_name = '';
this.v_current_surfaces_id = 0;
this.v_surfaces_groups_id = p_surfaces_groups_id;
this.v_coo_gprint_configuration = p_coo_gprint_configuration;
this.load_surface = function(p_names, p_width, p_height, p_surfaces_id)
{
var coo_surface = new GMGPrintSurfaces(p_surfaces_id, this);
this.v_surfaces[p_surfaces_id] = coo_surface;
this.v_surfaces[p_surfaces_id].set_width(p_width);
this.v_surfaces[p_surfaces_id].set_height(p_height);
this.v_surfaces[p_surfaces_id].set_names(p_names);
this.set_current_surfaces_id(p_surfaces_id);
}
this.load_surfaces_group = function(p_surfaces_groups_id, p_product)
{
var coo_surfaces_group;
var coo_elements;
var t_first_surfaces_id;
var c_product;
if(typeof(p_product) != 'undefined')
{
c_product = encodeURIComponent(p_product);
}
else
{
c_product = '';
}
var c_surfaces_groups_id = gm_gprint_clear_number(p_surfaces_groups_id);
jQuery.ajax({
data: 'action=load_surfaces_group&surfaces_groups_id=' + c_surfaces_groups_id + '&mode=' + c_mode + '&product=' + c_product + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
dataType: 'json',
type: "POST",
async: false,
success: function(p_surfaces_group)
{
coo_surfaces_group = p_surfaces_group;
}
});
if(coo_surfaces_group.v_current_surfaces_id != '0')
{
this.reset_display();
for(var t_surfaces_id in coo_surfaces_group.v_surfaces)
{
if(t_first_surfaces_id == null)
{
t_first_surfaces_id = t_surfaces_id;
}
this.load_surface(coo_surfaces_group.v_surfaces[t_surfaces_id].v_names, coo_surfaces_group.v_surfaces[t_surfaces_id].v_width, coo_surfaces_group.v_surfaces[t_surfaces_id].v_height, t_surfaces_id);
this.display_surface(t_surfaces_id, this.get_coo_gprint_configuration());
coo_elements = coo_surfaces_group.v_surfaces[t_surfaces_id].v_elements;
this.v_surfaces[t_surfaces_id].load_elements(coo_elements);
}
this.set_name(coo_surfaces_group.v_name);
this.display_name(this.get_name());
this.set_current_surfaces_id(t_first_surfaces_id);
this.update_current_surfaces_id(t_first_surfaces_id);
this.display_surface(t_first_surfaces_id, this.get_coo_gprint_configuration());
this.activate_tabs();
}
else
{
this.set_name(coo_surfaces_group.v_name);
this.display_name(this.get_name());
}
$('.gm_gprint_field').keyup(function()
{
var t_input_text = $(this).val();
var t_exclude_spaces = '1';
var t_elements_id = gm_gprint_clear_number($(this).attr('id'));
if(t_exclude_spaces == '1')
{
t_input_text = t_input_text.replace(/\s+/g, '');
}
t_input_text = t_input_text.replace(/\n+/g, '');
t_input_text = t_input_text.replace(/\t+/g, '');
t_input_text = t_input_text.replace(/\r+/g, '');
t_input_text = t_input_text.replace(/\v+/g, '');
var t_input_length = t_input_text.length;
var t_surfaces_id = 0;
var t_max_characters = 0;
for(t_surfaces_id in coo_surfaces_group.v_surfaces)
{
if(typeof(coo_surfaces_group.v_surfaces[t_surfaces_id].v_elements[t_elements_id]) == 'object')
{
t_max_characters = Number(coo_surfaces_group.v_surfaces[t_surfaces_id].v_elements[t_elements_id].v_max_characters);
if(t_max_characters > 0 && t_input_length > t_max_characters)
{
var t_character_count = t_input_length - t_max_characters;
var t_original_input_text = $(this).val();
var t_new_input_text = t_original_input_text.substr(0, t_original_input_text.length - t_character_count);
if(t_exclude_spaces == '1')
{
t_new_input_text = t_new_input_text.replace(/^\s+/, '').replace(/\s+$/, '');
}
$(this).val(t_new_input_text);
alert('Die maximale Zeichenanzahl von ' + t_max_characters + ' wurde überschritten.');
}
}
}
});
this.show();
}
this.activate_tabs = function()
{
var coo_surfaces_manager_copy = this;
var coo_configuration_copy = this.get_coo_gprint_configuration();
$('.gm_gprint_tab, .gm_gprint_tab_active').click(function()
{
var f_clicked_surfaces_id = $(this).attr('id');
f_clicked_surfaces_id = f_clicked_surfaces_id.replace(/gm_gprint_tab_/g, '');
c_clicked_surfaces_id = gm_gprint_clear_number(f_clicked_surfaces_id);
coo_surfaces_manager_copy.set_current_surfaces_id(c_clicked_surfaces_id);
coo_surfaces_manager_copy.update_current_surfaces_id(c_clicked_surfaces_id);
coo_surfaces_manager_copy.display_surface(coo_surfaces_manager_copy.get_current_surfaces_id(), coo_configuration_copy);
});
}
this.display_surface = function(p_surfaces_id)
{
if($('#show_create_element_flyover').attr('id') == 'show_create_element_flyover')
{
$('#show_create_element_flyover').show();
$('#show_edit_surface_flyover').show();
}
$('#gm_gprint_content .gm_gprint_surface').each(function()
{
$(this).hide();
});
$('.gm_gprint_tab_active').each(function()
{
$(this).removeClass('gm_gprint_tab_active');
$(this).addClass('gm_gprint_tab');
});
if($('#tab_' + p_surfaces_id).attr('id') != 'tab_' + p_surfaces_id)
{
$('#gm_gprint_tabs').append('
' + this.v_surfaces[p_surfaces_id].get_name(this.v_coo_gprint_configuration.get_languages_id()) + ' ');
$('#gm_gprint_content').append('
');
}
else
{
$('#tab_' + p_surfaces_id).removeClass('gm_gprint_tab');
$('#tab_' + p_surfaces_id).addClass('gm_gprint_tab_active');
$('#tab_' + p_surfaces_id + ' span').html(this.v_surfaces[p_surfaces_id].get_name(this.v_coo_gprint_configuration.get_languages_id()));
$('#surface_' + p_surfaces_id).show();
}
this.v_surfaces[p_surfaces_id].update_form();
$('#gm_gprint_tabs .gm_gprint_tab').mouseover(function()
{
$(this).css({
'text-decoration': 'underline'
});
});
$('#gm_gprint_tabs .gm_gprint_tab_active').mouseover(function()
{
$(this).css({
'text-decoration': 'none'
});
});
$('#gm_gprint_tabs .gm_gprint_tab').mouseout(function()
{
$(this).css({
'text-decoration': 'none'
});
});
}
this.reset_display = function()
{
$('#gm_gprint_tabs').html('');
$('#gm_gprint_content').html('');
}
this.show = function()
{
$('#gm_gprint_tabs').show();
$('#gm_gprint_content').show();
}
this.update_current_surfaces_id = function(p_surfaces_id)
{
}
this.display_name = function()
{
$('#surfaces_group_name').val(this.get_name());
$('#surfaces_group_name_title').html(this.get_name());
}
this.set_name = function(p_name)
{
this.v_name = gm_unescape(p_name);
}
this.get_name = function()
{
return this.v_name;
}
this.set_current_surfaces_id = function(p_surfaces_id)
{
this.v_current_surfaces_id = p_surfaces_id;
}
this.get_current_surfaces_id = function()
{
return this.v_current_surfaces_id;
}
this.set_surfaces_groups_id = function(p_surfaces_groups_id)
{
this.v_surfaces_groups_id = v_surfaces_groups_id;
}
this.get_surfaces_groups_id = function()
{
return this.v_surfaces_groups_id;
}
this.get_coo_gprint_configuration = function()
{
return this.v_coo_gprint_configuration;
}
}
function GMGPrintSurfaces(p_surfaces_id, p_coo_surfaces_manager)
{
this.v_elements = new Object();
this.v_width = 0;
this.v_height = 0;
this.v_names = new Object();
this.v_surfaces_id = p_surfaces_id;
this.v_current_elements_id = 0;
this.v_coo_surfaces_manager = p_coo_surfaces_manager;
this.load_elements = function(p_elements)
{
for(var t_elements_id in p_elements)
{
this.load_element(p_elements[t_elements_id].v_type, p_elements[t_elements_id].v_width, p_elements[t_elements_id].v_height, p_elements[t_elements_id].v_position_x, p_elements[t_elements_id].v_position_y, p_elements[t_elements_id].v_z_index, p_elements[t_elements_id].v_max_characters, p_elements[t_elements_id].v_show_name, p_elements[t_elements_id].v_names, p_elements[t_elements_id].v_values, p_elements[t_elements_id].v_selected_dropdown_value, p_elements[t_elements_id].v_allowed_extensions, p_elements[t_elements_id].v_minimum_filesize, p_elements[t_elements_id].v_maximum_filesize, p_elements[t_elements_id].v_download_key, t_elements_id);
this.display_element(t_elements_id);
}
}
this.load_element = function(p_type, p_width, p_height, p_position_x, p_position_y, p_z_index, p_max_characters, p_show_name, p_names, p_values, p_selected_dropdown_value, p_allowed_extensions, p_minimum_filesize, p_maximum_filesize, p_download_key, p_elements_id)
{
var coo_element = new GMGPrintElements(p_elements_id);
coo_element.set_width(p_width);
coo_element.set_height(p_height);
coo_element.set_position_x(p_position_x);
coo_element.set_position_y(p_position_y);
coo_element.set_z_index(p_z_index);
coo_element.set_max_characters(p_max_characters);
coo_element.set_show_name(p_show_name);
coo_element.set_type(p_type);
coo_element.set_names(p_names);
coo_element.set_values(p_values);
coo_element.set_selected_dropdown_value(p_selected_dropdown_value);
coo_element.set_allowed_extensions(p_allowed_extensions);
coo_element.set_minimum_filesize(p_minimum_filesize);
coo_element.set_maximum_filesize(p_maximum_filesize);
coo_element.set_download_key(p_download_key);
this.v_elements[p_elements_id] = coo_element;
this.set_current_elements_id(p_elements_id);
}
this.display_element = function(p_elements_id)
{
if($('#show_edit_element_flyover').attr('id') == 'show_edit_element_flyover')
{
$('#show_edit_element_flyover').show();
}
$('#surface_' + this.get_surfaces_id() + ' #element_' + p_elements_id).remove();
$('#surface_' + this.get_surfaces_id()).append('
');
if(this.v_elements[p_elements_id].get_type() == 'text')
{
$('#element_container_' + p_elements_id).append('
' + this.v_elements[p_elements_id].v_values[coo_gprint_configuration.get_languages_id()][0] + '
');
}
else if(this.v_elements[p_elements_id].get_type() == 'text_input')
{
$('#element_container_' + p_elements_id).append('
' + this.v_elements[p_elements_id].v_names[coo_gprint_configuration.get_languages_id()] + ':
');
if(this.v_elements[p_elements_id].get_show_name() == true)
{
$('#element_show_name_' + p_elements_id).show();
}
}
else if(this.v_elements[p_elements_id].get_type() == 'textarea')
{
$('#element_container_' + p_elements_id).append('
' + this.v_elements[p_elements_id].v_names[coo_gprint_configuration.get_languages_id()] + ':
');
if(this.v_elements[p_elements_id].get_show_name() == true)
{
$('#element_show_name_' + p_elements_id).show();
}
}
else if(this.v_elements[p_elements_id].get_type() == 'file')
{
if(this.v_elements[p_elements_id].v_values[coo_gprint_configuration.get_languages_id()][0] == '')
{
$('#element_container_' + p_elements_id).append('
');
}
else
{
$('#element_container_' + p_elements_id).append('
');
var coo_surface = this;
$('#delete_file_' + p_elements_id).click(function()
{
$('#element_container_' + p_elements_id).html('
');
});
}
}
else if(this.v_elements[p_elements_id].get_type() == 'dropdown')
{
var t_dropdown_html = '
' + this.v_elements[p_elements_id].v_names[coo_gprint_configuration.get_languages_id()] + ':
';
var t_dropdown_values = this.v_elements[p_elements_id].v_values[coo_gprint_configuration.get_languages_id()];
var t_selected = '';
for(t_key in t_dropdown_values)
{
if(t_dropdown_values[t_key] == this.v_elements[p_elements_id].get_selected_dropdown_value())
{
t_selected = ' selected="selected"';
}
else
{
t_selected = '';
}
t_dropdown_html += '' + t_dropdown_values[t_key] + ' ';
}
t_dropdown_html += ' ';
$('#element_container_' + p_elements_id).append(t_dropdown_html);
if(this.v_elements[p_elements_id].get_show_name() == true)
{
$('#element_show_name_' + p_elements_id).show();
}
}
else if(this.v_elements[p_elements_id].get_type() == 'image')
{
$('#element_container_' + p_elements_id).append('
');
$('#copy_element_container_' + p_elements_id).css({
'width': this.v_elements[p_elements_id].get_width() + 'px',
'height': this.v_elements[p_elements_id].get_height() + 'px'
});
}
this.v_elements[p_elements_id].update_form();
}
this.update_form = function()
{
$('#current_surface_width').val(this.get_width());
$('#current_surface_height').val(this.get_height());
for(t_languages_id in this.get_names())
{
$('#current_surface_language_' + t_languages_id).val(this.get_name(t_languages_id));
}
$('#surface_name_title').html(this.get_name(coo_gprint_configuration.get_languages_id()));
this.set_element_active(this.get_current_elements_id());
}
this.set_size = function(p_width, p_height)
{
$('#surface_' + this.get_surfaces_id()).css({
'width': p_width + 'px',
'height': p_height + 'px'
});
this.set_width(p_width);
this.set_height(p_height);
}
this.set_width = function(p_width)
{
this.v_width = p_width;
}
this.set_height = function(p_height)
{
this.v_height = p_height;
}
this.get_width = function()
{
return this.v_width;
}
this.get_height = function()
{
return this.v_height;
}
this.get_surfaces_id = function()
{
return this.v_surfaces_id;
}
this.set_names = function(p_names)
{
c_names = new Object();
for(t_languages_id in p_names)
{
c_names[t_languages_id] = gm_unescape(p_names[t_languages_id]);
}
this.v_names = c_names;
}
this.get_name = function(p_languages_id)
{
return this.v_names[p_languages_id];
}
this.get_names = function()
{
return this.v_names;
}
this.set_name = function(p_name, p_languages_id)
{
this.v_names[p_languages_id] = gm_unescape(p_name);
}
this.set_element_active = function(p_elements_id)
{
if(p_elements_id != 0 && p_elements_id != '')
{
this.set_current_elements_id(p_elements_id);
$('#current_element_width').val(this.v_elements[p_elements_id].get_width());
$('#current_element_height').val(this.v_elements[p_elements_id].get_height());
$('#current_element_position_x').val(this.v_elements[p_elements_id].get_position_x());
$('#current_element_position_y').val(this.v_elements[p_elements_id].get_position_y());
$('#current_element_z_index').val(this.v_elements[p_elements_id].get_z_index());
$('#current_element_max_characters').val(this.v_elements[p_elements_id].get_max_characters());
if(this.v_elements[p_elements_id].get_show_name() == true)
{
$('#current_element_show_name').attr('checked', 'checked');
}
$('#current_element_allowed_extensions').val(this.v_elements[p_elements_id].get_allowed_extensions());
$('#current_element_minimum_filesize').val(this.v_elements[p_elements_id].get_minimum_filesize());
$('#current_element_maximum_filesize').val(this.v_elements[p_elements_id].get_maximum_filesize());
for(t_languages_id in this.v_elements[p_elements_id].get_names())
{
$('#current_element_name_' + t_languages_id).val(this.v_elements[p_elements_id].get_name(t_languages_id));
}
if(this.v_elements[p_elements_id].get_type() != 'dropdown')
{
for(t_languages_id in this.v_elements[p_elements_id].get_values())
{
$('#edit_element_value_fields_' + t_languages_id).html('
');
$('[name=current_element_language_' + t_languages_id + ']').val(this.v_elements[p_elements_id].get_value(t_languages_id));
}
}
else
{
var t_dropdown_values = new Object();
for(t_languages_id in this.v_elements[p_elements_id].get_values())
{
$('#edit_element_value_fields_' + t_languages_id).html('');
t_dropdown_values = this.v_elements[p_elements_id].v_values[t_languages_id];
for(t_key in t_dropdown_values)
{
$('#edit_element_value_fields_' + t_languages_id).append('
');
}
}
}
$('#element_name_title').html(this.v_elements[p_elements_id].get_name((coo_gprint_configuration.get_languages_id())));
}
else{
$('#current_element_width').val('');
$('#current_element_height').val('');
$('#current_element_position_x').val('');
$('#current_element_position_y').val('');
$('#current_element_z_index').val('');
$('#current_element_max_characters').val('');
$('#current_element_show_name').removeAttr('checked');
$('#current_element_allowed_extensions').val('');
$('#current_element_minimum_filesize').val('');
$('#current_element_maximum_filesize').val('');
for(t_languages_id in this.v_names)
{
$('#current_element_name_' + t_languages_id).val('');
}
for(t_languages_id in this.v_values)
{
$('[name=current_element_language_' + t_languages_id + ']').val('');
}
}
}
this.set_current_elements_id = function(p_elements_id)
{
this.v_current_elements_id = p_elements_id;
}
this.get_current_elements_id = function()
{
return this.v_current_elements_id;
}
this.get_surfaces_id = function()
{
return this.v_surfaces_id;
}
this.get_coo_surfaces_manager = function()
{
return this.v_coo_surfaces_manager;
}
}
function GMGPrintElements(p_elements_id)
{
this.v_width = 0;
this.v_height = 0;
this.v_position_x = 0;
this.v_position_y = 0;
this.v_z_index = 0;
this.v_max_characters = 0;
this.v_show_name = false;
this.v_type = '';
this.v_names = new Object();
this.v_values = new Object();
this.v_selected_dropdown_value = '';
this.v_allowed_extensions = '';
this.v_minimum_filesize = 0;
this.v_maximum_filesize = 0;
this.v_elements_id = p_elements_id;
this.v_download_key = '';
this.update = function(p_width, p_height, p_position_x, p_position_y, p_z_index, p_max_characters, p_show_name, p_names, p_values, p_allowed_extensions, p_minimum_filesize, p_maximum_filesize)
{
var t_values = p_values;
var t_width = p_width;
var t_height = p_height;
if(this.get_type() == 'image')
{
coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].upload_images('edit_element_image_', this.get_elements_id(), p_position_x, p_position_y, p_z_index, p_max_characters, p_show_name, p_names, true, true);
}
else
{
this.set_size(t_width, t_height);
this.set_position(p_position_x, p_position_y);
this.set_element_z_index(p_z_index);
this.set_element_max_characters(p_max_characters);
this.set_element_show_name(p_show_name);
this.set_element_allowed_extensions(p_allowed_extensions);
this.set_element_minimum_filesize(p_minimum_filesize);
this.set_element_maximum_filesize(p_maximum_filesize);
this.set_element_names(p_names);
this.set_element_values(t_values);
}
}
this.update_form = function()
{
$('#current_element_width').val(this.get_width());
$('#current_element_height').val(this.get_height());
$('#current_element_position_x').val(this.get_position_x());
$('#current_element_position_y').val(this.get_position_y());
$('#current_element_z_index').val(this.get_z_index());
$('#current_element_max_characters').val(this.get_max_characters());
if(this.get_show_name() == true)
{
$('#current_element_show_name').attr('checked', 'checked');
}
$('#current_element_allowed_extensions').val(this.get_allowed_extensions());
$('#current_element_minimum_filesize').val(this.get_minimum_filesize());
$('#current_element_maximum_filesize').val(this.get_maximum_filesize());
for(t_languages_id in this.get_names())
{
$('#current_element_name_' + t_languages_id).val(this.get_name(t_languages_id));
}
for(t_languages_id in this.get_values())
{
$('[name=current_element_language_' + t_languages_id + ']').val(this.get_value(t_languages_id));
}
}
this.set_width = function(p_width)
{
this.v_width = p_width;
}
this.set_height = function(p_height)
{
this.v_height = p_height;
}
this.get_width = function()
{
return this.v_width;
}
this.get_height = function()
{
return this.v_height;
}
this.set_position_x = function(p_position_x)
{
this.v_position_x = p_position_x;
}
this.set_position_y = function(p_position_y)
{
this.v_position_y = p_position_y;
}
this.get_position_x = function()
{
return this.v_position_x;
}
this.get_position_y = function()
{
return this.v_position_y;
}
this.set_z_index = function(p_z_index)
{
this.v_z_index = p_z_index;
}
this.get_z_index = function()
{
return this.v_z_index;
}
this.set_max_characters = function(p_max_characters)
{
this.v_max_characters = p_max_characters;
}
this.get_max_characters = function()
{
return this.v_max_characters;
}
this.set_show_name = function(p_show_name)
{
if(p_show_name == '1' || p_show_name == 'true' || p_show_name == 1)
{
this.v_show_name = true;
}
else if(p_show_name == '0' || p_show_name == 'false' || p_show_name == 0)
{
this.v_show_name = false;
}
else if(p_show_name == true)
{
this.v_show_name = true;
}
else
{
this.v_show_name = false;
}
}
this.get_show_name = function()
{
return this.v_show_name;
}
this.set_allowed_extensions = function(p_allowed_extensions)
{
this.v_allowed_extensions = gm_unescape(p_allowed_extensions);
}
this.get_allowed_extensions = function()
{
return this.v_allowed_extensions;
}
this.set_minimum_filesize = function(p_minimum_filesize)
{
this.v_minimum_filesize = gm_unescape(p_minimum_filesize);
}
this.get_minimum_filesize = function()
{
return this.v_minimum_filesize;
}
this.set_maximum_filesize = function(p_maximum_filesize)
{
this.v_maximum_filesize = gm_unescape(p_maximum_filesize);
}
this.get_maximum_filesize = function()
{
return this.v_maximum_filesize;
}
this.get_type = function()
{
return this.v_type;
}
this.set_type = function(p_type)
{
this.v_type = p_type;
}
this.get_name = function(p_languages_id)
{
return this.v_names[p_languages_id];
}
this.get_names = function()
{
return this.v_names;
}
this.set_names = function(p_names)
{
for(t_languages_id in p_names)
{
this.v_names[t_languages_id] = gm_unescape(p_names[t_languages_id]);
}
}
this.get_value = function(p_languages_id)
{
return this.v_values[p_languages_id][0];
}
this.get_values = function()
{
return this.v_values;
}
this.set_values = function(p_values)
{
for(t_languages_id in p_values)
{
if(typeof(this.v_values[t_languages_id]) != 'object')
{
this.v_values[t_languages_id] = new Object();
}
for(t_key in p_values[t_languages_id])
{
this.v_values[t_languages_id][t_key] = gm_unescape(p_values[t_languages_id][t_key]);
}
}
}
this.set_selected_dropdown_value = function(p_value)
{
this.v_selected_dropdown_value = p_value;
}
this.get_selected_dropdown_value = function()
{
return this.v_selected_dropdown_value;
}
this.set_download_key = function(p_download_key)
{
this.v_download_key = p_download_key;
}
this.get_download_key = function()
{
return this.v_download_key;
}
this.get_elements_id = function()
{
return this.v_elements_id;
}
}
function GMGPrintCartWishlistManager()
{
this.get_customers_data = function(p_coo_surfaces_manager, p_target)
{
var t_found_file = false;
var count_passes = 0;
var count_uploads = 0;
var coo_cart_wishlist_manager = this;
$('#cart_quantity input').each(function()
{
if($(this).attr('type') == 'file')
{
count_uploads++;
}
});
$('#cart_quantity input').each(function()
{
if($(this).attr('type') == 'file')
{
t_found_file = true;
t_success = true;
var t_upload_field_id = $(this).attr('id');
var t_element_container = t_upload_field_id.replace(/_/g, '_container_');
var t_products_id = coo_cart_wishlist_manager.get_products_id();
$('#' + t_upload_field_id).hide();
$('#' + t_element_container).append('
');
$.ajaxFileUpload({
url: 'gm_gprint_ajax.php?action=upload&upload_field_id=' + encodeURIComponent(t_upload_field_id)
+ '&products_id=' + encodeURIComponent(t_products_id)
+ '&target=' + encodeURIComponent(p_target)
+ '&mode=' + c_mode
+ '&XTCsid=' + gm_session_id,
secureuri: false,
fileElementId: t_upload_field_id,
dataType: 'json',
success: function(p_filename)
{
if(p_filename['ERROR'] == false)
{
$('#loading_' + p_filename['UPLOAD_FIELD_ID']).remove();
count_passes++;
if(count_passes == count_uploads && t_success == true)
{
$('#'+t_element_container).html('');
if(p_target == 'cart')
{
coo_cart_wishlist_manager.add_cart(p_coo_surfaces_manager);
}
else if(p_target == 'wishlist')
{
coo_cart_wishlist_manager.add_wishlist(p_coo_surfaces_manager);
}
}
else if(t_success == false)
{
$('#' + p_filename['UPLOAD_FIELD_ID']).show();
}
}
else
{
$('.gm_gprint_loading').remove();
$('.gm_gprint_surface input').each(function()
{
if($(this).attr('type') == 'file')
{
$(this).show();
}
});
t_success = false;
alert(gm_unescape(p_filename['ERROR_MESSAGE']));
}
},
error: function()
{
if(fb)console.log("Upload failed: " + t_upload_field_id);
}
});
}
});
if(!t_found_file)
{
if(p_target == 'cart')
{
coo_cart_wishlist_manager.add_cart(p_coo_surfaces_manager);
}
else if(p_target == 'wishlist')
{
coo_cart_wishlist_manager.add_wishlist(p_coo_surfaces_manager);
}
}
}
this.add_cart = function(p_coo_surfaces_manager)
{
var t_user_input = '';
var coo_surface = null;
for(t_surfaces_id in p_coo_surfaces_manager.v_surfaces)
{
coo_surface = p_coo_surfaces_manager.v_surfaces[t_surfaces_id];
for(t_elements_id in coo_surface.v_elements)
{
if(coo_surface.v_elements[t_elements_id].get_type() == 'text_input'
|| coo_surface.v_elements[t_elements_id].get_type() == 'textarea'
|| coo_surface.v_elements[t_elements_id].get_type() == 'dropdown')
{
t_user_input += '&element_' + encodeURIComponent(t_elements_id) + '=' + encodeURIComponent($('#element_' + t_elements_id).val());
}
}
}
var t_products_id = this.get_products_id();
t_products_id = encodeURIComponent(t_products_id);
var t_success = jQuery.ajax({
data: 'action=add_cart' + t_user_input + '&products_id=' + t_products_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).responseText;
if(t_success == 'true')
{
document.cart_quantity.submit();
}
}
this.update_cart = function()
{
var t_success = false;
var t_delete = false;
$('#cart_quantity input').each(function()
{
if($(this).attr('type') == 'checkbox' && $(this).attr('checked') == true)
{
t_delete = true;
var t_products_id = encodeURIComponent($(this).val());
t_success = jQuery.ajax({
data: 'action=update_cart&products_id=' + t_products_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).json;
}
});
if(!t_delete)
{
t_success = true;
}
return t_success;
}
this.add_wishlist = function(p_coo_surfaces_manager)
{
var t_user_input = '';
var coo_surface = null;
for(t_surfaces_id in p_coo_surfaces_manager.v_surfaces)
{
coo_surface = p_coo_surfaces_manager.v_surfaces[t_surfaces_id];
for(t_elements_id in coo_surface.v_elements)
{
if(coo_surface.v_elements[t_elements_id].get_type() == 'text_input'
|| coo_surface.v_elements[t_elements_id].get_type() == 'textarea'
|| coo_surface.v_elements[t_elements_id].get_type() == 'dropdown')
{
t_user_input += '&element_' + t_elements_id + '=' + encodeURIComponent($('#element_' + t_elements_id).val());
}
}
}
var t_products_id = this.get_products_id();
t_products_id = encodeURIComponent(t_products_id);
var t_success = jQuery.ajax({
data: 'action=add_wishlist' + t_user_input + '&products_id=' + t_products_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).responseText;
if(t_success == 'true')
{
submit_to_wishlist();
}
}
this.update_wishlist = function()
{
var t_success = false;
$('.wishlist_checkbox').each(function()
{
if($(this).attr('type') == 'checkbox' && $(this).attr('checked') == true)
{
var t_products_id = encodeURIComponent($(this).val());
t_success = jQuery.ajax({
data: 'action=update_wishlist&products_id=' + t_products_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).json;
}
});
return t_success;
}
this.wishlist_to_cart = function()
{
var t_success = false;
$('.wishlist_checkbox').each(function()
{
if($(this).attr('type') == 'checkbox' && $(this).attr('checked') == true)
{
var t_products_id = encodeURIComponent($(this).val());
t_success = jQuery.ajax({
data: 'action=wishlist_to_cart&products_id=' + t_products_id + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).json;
}
});
return t_success;
}
this.get_products_id = function()
{
var t_option_id = '0';
var t_option_value_id = '0';
var t_ids = $('#gm_products_id').val();
$('.gm_attr_calc_input').each(function()
{
if(($(this).attr('checked') == true && $(this).attr('type') == 'radio') || $(this).attr('type') != 'radio')
{
t_option_id = $(this).attr('name');
t_option_id = t_option_id.replace(/id\[/g, '{');
t_option_id = t_option_id.replace(/\]/g, '}');
t_option_value_id = $(this).val();
t_ids += t_option_id + t_option_value_id;
}
});
t_option_id = $('#gm_gprint_random').attr('name');
t_option_id = t_option_id.replace(/id\[/g, '{');
t_option_id = t_option_id.replace(/\]/g, '}');
t_ids += t_option_id + $('#gm_gprint_random').val();
return t_ids;
}
this.copy_file = function(p_elements_id, p_old_product, p_new_product, p_target, p_source)
{
var c_elements_id = gm_gprint_clear_number(p_elements_id);
var c_old_product = encodeURIComponent(p_old_product);
var c_new_product = encodeURIComponent(p_new_product);
var c_target = encodeURIComponent(p_target);
var c_source = encodeURIComponent(p_source);
if(p_target == 'cart')
{
t_success = jQuery.ajax({
data: 'action=copy_file&elements_id=' + c_elements_id + '&old_product=' + c_old_product + '&new_product=' + c_new_product + '&target=' + c_target + '&source=' + c_source + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).json;
}
else if(p_target == 'wishlist')
{
t_success = jQuery.ajax({
data: 'action=copy_file&elements_id=' + c_elements_id + '&old_product=' + c_old_product + '&new_product=' + c_new_product + '&target=' + c_target + '&source=' + c_source + '&mode=' + c_mode + '&XTCsid=' + gm_session_id,
url: 'gm_gprint_ajax.php',
type: "POST",
async: false
}).json;
}
}
}
function update_current_surface()
{
var f_width = $('#current_surface_width').val();
var f_height = $('#current_surface_height').val();
var c_width = gm_gprint_clear_number(f_width);
var c_height = gm_gprint_clear_number(f_height);
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);
var t_surfaces_names = new Object();
var t_surface_language_id = '';
$('.current_surface_name').each(function()
{
t_surface_language_id = $(this).attr('id');
t_surface_language_id = t_surface_language_id.replace(/current_surface_language_/g, '');
t_surfaces_names[t_surface_language_id] = this.value;
});
coo_surfaces_manager.v_surfaces[coo_surfaces_manager.get_current_surfaces_id()].update_names(coo_surfaces_manager.get_current_surfaces_id(), t_surfaces_names);
coo_surfaces_manager.display_surface(coo_surfaces_manager.get_current_surfaces_id(), coo_gprint_configuration);
$('.gm_gprint_wait').hide();
}
function update_current_element()
{
var f_width = $('#current_element_width').val();
var f_height = $('#current_element_height').val();
var f_position_x = $('#current_element_position_x').val();
var f_position_y = $('#current_element_position_y').val();
var f_z_index = $('#current_element_z_index').val();
var f_max_characters = $('#current_element_max_characters').val();
var f_allowed_extensions = $('#current_element_allowed_extensions').val();
var f_minimum_filesize = $('#current_element_minimum_filesize').val();
var f_maximum_filesize = $('#current_element_maximum_filesize').val();
var c_width = gm_gprint_clear_number(f_width);
var c_height = gm_gprint_clear_number(f_height);
var c_position_x = gm_gprint_clear_number(f_position_x);
var c_position_y = gm_gprint_clear_number(f_position_y);
var c_z_index = gm_gprint_clear_number(f_z_index);
var c_max_characters = gm_gprint_clear_number(f_max_characters);
var t_show_name = 0;
if($('#current_element_show_name:checked').val() == '1')
{
t_show_name = 1;
}
var t_element_language_id = '';
var t_elements_names = new Object();
$('.current_element_name').each(function()
{
t_element_language_id = $(this).attr('id');
t_element_language_id = t_element_language_id.replace(/current_element_name_/g, '');
t_elements_names[t_element_language_id] = this.value;
});
var t_elements_values = new Object();
var count_values_key = 0;
var t_element_language_id_copy = '0';
$('.current_element_value').each(function()
{
t_element_language_id = $(this).attr('name');
t_element_language_id = t_element_language_id.replace(/current_element_language_/g, '');
if(t_element_language_id_copy != t_element_language_id)
{
count_values_key = 0;
}
if(typeof(t_elements_values[t_element_language_id]) != 'object')
{
t_elements_values[t_element_language_id] = new Object();
}
t_elements_values[t_element_language_id][count_values_key] = this.value;
count_values_key++;
t_element_language_id_copy = t_element_language_id;
});
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);
$('.gm_gprint_wait').hide();
}
$(document).ready(function()
{
coo_gprint_configuration = new GMGPrintConfiguration();
coo_gprint_configuration.set_languages_id(2);
coo_cart_wishlist_manager = new GMGPrintCartWishlistManager();
if(t_current_page == 'product_info' && $('#gm_gprint').attr('id') == 'gm_gprint')
{
if($('#gm_wishlist_link').attr('id') == 'gm_wishlist_link')
{
var t_wishlist_href = "javascript:coo_cart_wishlist_manager.get_customers_data(coo_surfaces_manager, 'wishlist');";
$('#gm_wishlist_link').attr('href', t_wishlist_href);
}
$('#gm_wishlist_link').click(function()
{
var t_product = '';
var t_input_name = '';
$('.gm_attr_calc_input').each(function()
{
t_input_name = $(this).attr('name');
if(t_input_name.indexOf('id[') != -1)
{
if($(this).attr('type') == 'radio' && $(this).attr('checked') == true)
{
t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
}
else if($(this).attr('type') != 'radio')
{
t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
}
}
});
t_product_copy = t_product;
t_input_name = $('#gm_gprint_random').attr('name');
var t_product_random = '';
t_product_random = '{' + gm_gprint_clear_number(t_input_name) + '}' + $('#gm_gprint_random').val();
var t_opened_product = '';
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')
{
var t_random_number = Math.random() + '';
t_random_number = t_random_number.substr(2, 6);
if(t_random_number.substr(0, 1) == '0')
{
t_random_number = '1' + t_random_number.substr(1, 5);
}
$('#gm_gprint_random').attr('name', 'id[' + t_random_number + ']');
var delete_file_id = '';
var t_old_product = t_opened_product.replace(/wishlist_/g, '');
t_old_product = t_old_product.replace(/cart_/g, '');
var t_start = t_old_product.indexOf(t_product_random);
var t_end = t_start+t_product_random.length;
var t_new_product_part_1 = t_old_product.substring(0, t_start);
var t_new_product_part_2 = t_old_product.substring(t_end);
var t_new_product = t_new_product_part_1 + '{' + t_random_number + '}' + $('#gm_gprint_random').val() + t_new_product_part_2;
var t_source = 'wishlist';
if(t_opened_product.substr(0, 4) == 'cart')
{
t_source = 'cart';
}
$('.delete_file').each(function()
{
delete_file_id = $(this).attr('id');
delete_file_id = delete_file_id.replace(/delete_file_/g, '');
coo_cart_wishlist_manager.copy_file(delete_file_id, t_old_product, t_new_product, 'wishlist', t_source);
});
}
});
$('#cart_quantity').submit(function()
{
return false;
});
$('#cart_button').click(function()
{
var t_product = '';
var t_input_name = '';
$('.gm_attr_calc_input').each(function()
{
t_input_name = $(this).attr('name');
if(t_input_name.indexOf('id[') != -1)
{
if($(this).attr('type') == 'radio' && $(this).attr('checked') == true)
{
t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
}
else if($(this).attr('type') != 'radio')
{
t_product += '{' + gm_gprint_clear_number(t_input_name) + '}' + $(this).val();
}
}
});
t_product_copy = t_product;
t_input_name = $('#gm_gprint_random').attr('name');
var t_product_random = '';
t_product_random = '{' + gm_gprint_clear_number(t_input_name) + '}' + $('#gm_gprint_random').val();
var t_opened_product = '';
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')
{
var t_random_number = Math.random() + '';
t_random_number = t_random_number.substr(2, 6);
if(t_random_number.substr(0, 1) == '0')
{
t_random_number = '1' + t_random_number.substr(1, 5);
}
$('#gm_gprint_random').attr('name', 'id[' + t_random_number + ']');
var delete_file_id = '';
var t_old_product = t_opened_product.replace(/cart_/g, '');
t_old_product = t_old_product.replace(/wishlist_/g, '');
var t_start = t_old_product.indexOf(t_product_random);
var t_end = t_start+t_product_random.length;
var t_new_product_part_1 = t_old_product.substring(0, t_start);
var t_new_product_part_2 = t_old_product.substring(t_end);
var t_new_product = t_new_product_part_1 + '{' + t_random_number + '}' + $('#gm_gprint_random').val() + t_new_product_part_2;
var t_source = 'cart';
if(t_opened_product.substr(0, 8) == 'wishlist')
{
t_source = 'wishlist';
}
$('.delete_file').each(function()
{
delete_file_id = $(this).attr('id');
delete_file_id = delete_file_id.replace(/delete_file_/g, '');
coo_cart_wishlist_manager.copy_file(delete_file_id, t_old_product, t_new_product, 'cart', t_source);
});
}
coo_gm_qty_ckeck = new GMOrderQuantityChecker();
var t_gm_qty_check = coo_gm_qty_ckeck.check();
if(t_gm_qty_check)
{
coo_cart_wishlist_manager.get_customers_data(coo_surfaces_manager, 'cart');
}
});
}
else if(t_current_page == 'cart')
{
$('#cart_quantity').submit(function(){
return coo_cart_wishlist_manager.update_cart();
});
}
else if(t_current_page == 'wishlist' && $('#gm_update_wishlist').attr('id') == 'gm_update_wishlist' && $('#gm_wishlist_to_cart').attr('id') == 'gm_wishlist_to_cart')
{
var t_wishlist_delete_href = $('#gm_update_wishlist').attr('href');
t_wishlist_delete_href = t_wishlist_delete_href.replace(/:/g, ':coo_cart_wishlist_manager.update_wishlist();');
$('#gm_update_wishlist').attr('href', t_wishlist_delete_href);
var t_wishlist_add_href = $('#gm_wishlist_to_cart').attr('href');
t_wishlist_add_href = t_wishlist_add_href.replace(/:/g, ':coo_cart_wishlist_manager.wishlist_to_cart();');
$('#gm_wishlist_to_cart').attr('href', t_wishlist_add_href);
}
});