/** * We offer the best and most useful modules PrestaShop and modifications for your online store. * * We are experts and professionals in PrestaShop * * @author PresTeamShop.com * @copyright 2011-2020 PresTeamShop * @license see file: LICENSE.txt * @category PrestaShop * @category Module */ $(function () { $('#pts_register_product') .on('click', '.register-button', function() { $('#pts_register_product .form-register').removeClass('hidden').slideDown(); $('#pts_register_product .form-validate').slideUp(); }) .on('click', '.validate-button', function() { $('#pts_register_product .form-register').slideUp(); $('#pts_register_product .form-validate').removeClass('hidden').slideDown(); }) .on('click', '#btn_send_register', function() { $('#sent_register').submit(); }) .on('click', '#btn_validate_license', function() { $('#validate_license').submit(); }); $(document).on('input change', '.tooltip-title-value', function(event) { $(event.currentTarget).attr('title', $(event.currentTarget).val()); }); $('.tooltip-title-value').trigger('change'); //remove focus for elements $('.pts a, .pts .btn, .pts input:checkbox').click(function (e) { $(e.currentTarget).blur(); }); //change language of helper languages templates $('.pts').on('click', '.change-language', $.changeLanguage); //range $('input[type="range"]') .on('click', function(event) { $(event.currentTarget).trigger('blur'); }) .on('change', function(event) { $(event.currentTarget).attr('title', $(event.currentTarget).val()); }); $('.panel-heading-actions').find('a').each(function(i, a) { if ($(a).hasClass('add')) { var tab = $(a).data('tab'); $(a).on('click', function() { $('#pts_content #tab-' + tab + ' #form-' + tab).slideDown(); }); } else { $(a).on('click', function() { eval($(a).data('action')); }); } }); }); jQuery.extend( jQuery.expr[ ":" ], {reallyvisible: function (a) { return !(jQuery(a).css('display') == 'none'); }} ); jQuery.extend({ isEmpty: function () { var count = 0; $.each(arguments, function (i, data) { if (typeof data !== typeof undefined && data !== null && data !== '' && (typeof data !== 'number' || (typeof data === 'number' && parseInt(data) !== 0))) { count++; } else return false }); return (arguments).length == count ? false : true; }, isEmail: function (val) { var regExp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; return regExp.exec(val); }, isJson: function (str) { try { JSON.parse(str); } catch (e) { return false; } return true; }, htmlEncode: function (value) { return $('
').text(value).html(); }, htmlDecode: function (value) { return $('
').html(value).text(); }, tinyMCEInit: function (element) { $().ready(function () { $(element).tinymce({ // General options theme: "advanced", plugins: "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen", // Theme options theme_advanced_buttons1: "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor", theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak", theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", theme_advanced_statusbar_location: "bottom", theme_advanced_resizing: true, content_css: tiny_content_css, document_base_url: tiny_doc_base_url, template_external_list_url: "lists/template_list.js", external_link_list_url: "lists/link_list.js", external_image_list_url: "lists/image_list.js", media_external_list_url: "lists/media_list.js", elements: "nourlconvert", convert_urls: false, language: tiny_lang, width: "600" }); }); }, getList: function (table, action, parameters, callback) { var $table = table; if (typeof table === 'string') { $table = $('#'+table); } else { table = $table.attr('id'); } var div_loading = '#' + table + ' tbody'; var data = { action: action, page: 1 }; $.extend(data, parameters); var _json = { data: data, beforeSend: function (request) { $('#' + table).addClass('table-loading'); }, success: function (json) { $('#' + table + ' thead').empty(); $('#' + table + ' tbody').empty(); $('#' + table).removeClass('table-loading'); var $tr_head = $(''); if (typeof json.masive !== typeof undefined && typeof json.masive.actions !== typeof undefined && Object.keys(json.masive.actions).length > 0) { var $chk_masive = $('').attr({type: 'checkbox'}).addClass('masive-check-all'); $chk_masive.on('change', function(e) { $('#' + table + ' tbody').find('.td_masive input').prop('checked', $(e.currentTarget).prop('checked')); }); var $th_masive = $('').addClass('text-center').appendTo($tr_head); $chk_masive.appendTo($th_masive); } $.each(json.headers, function (field, name_field) { var $th_head = $(''); if (field === 'actions' || (typeof json.status !== typeof undefined && json.status instanceof Array && (json.status.indexOf(field) !== -1) || field in json.status)) { $th_head.addClass('text-center'); } if (typeof name_field === 'object') { if (name_field.type === 'icon') { var $span_th = $(''); $('').addClass('fa-pts fa-pts-'+name_field['class']).css({cursor:'default'}).appendTo($span_th); if (typeof name_field.title !== typeof undefined) { $span_th.attr({title:name_field.title}); } $th_head.append($span_th).appendTo($tr_head); } } else { $th_head.html(name_field).appendTo($tr_head); } }); $tr_head.appendTo($('#' + table + ' thead')); $.each(json.content, function (i, data) { var $tr = $(''); if (typeof json.prefix_row !== typeof undefined && !$.isEmpty(json.prefix_row) && ((typeof data.id !== typeof undefined && !$.isEmpty(data.id)) || (typeof data['id_'+json.prefix_row] !== typeof undefined && !$.isEmpty(data['id_'+json.prefix_row]))) ) { $tr.attr('id', json.prefix_row + '_' + (typeof data.id !== typeof undefined ? data.id : data['id_'+json.prefix_row])); } if (typeof json.color !== typeof undefined) { $.each(Object.values(json.color).reverse() ,function(index, color){ if (typeof data[color.by] !== typeof undefined) { if (typeof color.colors[data[color.by]] !== typeof undefined) { if (color.colors[data[color.by]] !== $tr.attr('class')) { $tr.removeClass(); } } $tr.addClass(color.colors[data[color.by]]); } }); } //masive actions if (typeof json.masive !== typeof undefined && typeof json.masive.actions !== typeof undefined && Object.keys(json.masive.actions).length > 0) { var $td_masive = $('').addClass('td_masive text-center'); $('').attr({type: 'checkbox'}).addClass('masive-check').appendTo($td_masive) .data({tr: $tr, data: data}); $td_masive.appendTo($tr); } $.each(json.headers, function (field, name_field) { var $td = $(''); if (field == 'actions') { $td.addClass('actions text-center'); var $button_group_actions = $('
').addClass('btn-group').appendTo($td); $button_group_actions.append( $('