1/* global $ */ 2/* global Bloodhound */ 3 4// FUNCIONES FAQS 5 6$(document).ready(function () { 7 // Question&Select more info 8 $('.js-faq-info').click(function (event) { 9 $('.box-expForm').addClass('hidden') 10 $('.box-expCtd').toggleClass('hidden') 11 $('.js-faq-contact').removeClass('hidden') 12 13 if ($('.box-expCtd').hasClass('hidden')) { 14 $('.js-faq-info i').removeClass('icf-info-minus') 15 $('.js-faq-info i').addClass('icf-info-plus') 16 } else { 17 $('.js-faq-info i').removeClass('icf-info-plus') 18 $('.js-faq-info i').addClass('icf-info-minus') 19 } 20 }) 21 22 // Question&Contact 23 $('.js-faq-contact').click(function (event) { 24 $(this).addClass('hidden') 25 $('.js-faq-info i').removeClass('icf-info-minus') 26 $('.js-faq-info i').addClass('icf-info-plus') 27 $('.box-expCtd').addClass('hidden') 28 29 if ($('.box-expForm').hasClass('hidden')) { 30 $('.box-expForm').removeClass('hidden') 31 } else { 32 $('.box-expForm').addClass('hidden') 33 } 34 }) 35 36 // Contact Form 37 $('#form-category-select').change(function (e) { 38 if ($(this).val() > 0) { 39 $('#faq-p2').removeClass('hidden') 40 } else { 41 $('#faq-p2').addClass('hidden') 42 } 43 $('#faq-form').addClass('hidden') 44 45 $.ajax({ 46 url: $('#form-question-select').attr('ajaxvalues') + '&id_faq_category=' + $('#form-category-select').val(), 47 contentType: 'application/json', 48 dataType: 'json', 49 success: function (questions) { 50 $('#form-question-select').find('option:not(#form-question-default-option)').remove() 51 $.each(questions, function (id_question, q) { 52 $('#form-question-select').append('<option value="' + id_question + '" form_image_input="' + q.form_image_input + '" form_order_input="' + q.form_order_input + '" form_product_input="' + q.form_product_input + '" >' + q.short_question + '</option>') 53 }) 54 var url = new URL(window.location.href) 55 $('#form-question-select').val(url.searchParams.get('id')) 56 if (Object.keys(questions).length === 0) { 57 $('#form-question-select').change() 58 } 59 } 60 }) 61 var cat_name = $(this).find('option:selected').text() 62 $('label[for=\'form-question-select\']').text($('label[for=\'form-question-select\']').attr('sprintf').replace(/%s/g, cat_name)) 63 }) 64 65 if (!$('#form-question-select').val()) { 66 $('#form-category-select').change() 67 } 68 69 $('.form-group.has-error input, .form-group.has-error select, .form-group.has-error textarea').change(function () { 70 $(this).parents('.has-error').removeClass('has-error') 71 }) 72 73 $('#form-question-select').change(function () { 74 if ($(this).val() > 0 || ($('#form-category-select').val() > 0 && $('#form-question-select option').size() === 1)) { 75 $('#faq-form').removeClass('hidden') 76 $('#form_image_input').addClass('hidden') 77 78 if ($(this).attr('form_order_input') > 0 || $('#form-question-select option').size() === 1) { 79 $('#form_order_input').removeClass('hidden') 80 } else { 81 $('#form_order_input').addClass('hidden') 82 } 83 84 if ($(this).attr('form_product_input') > 0 || $('#form-question-select option').size() === 1) { 85 $('#form_product_input').removeClass('hidden') 86 } else { 87 $('#form_product_input').addClass('hidden') 88 } 89 } else { 90 $('#faq-form').addClass('hidden') 91 } 92 }) 93 94 // Search suggestions 95 var local_faqsMatcher = [] 96 $('.resp-tabs-container ul.lst-links li a').each(function () { 97 local_faqsMatcher.push({ 98 href: $(this).attr('href'), 99 answerchunk: $(this).text().trim(), 100 name: $(this).attr('title') 101 }) 102 }) 103 104 // Search suggestions 105 var faqsMatcher = new Bloodhound({ 106 datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'answerchunk']), 107 queryTokenizer: Bloodhound.tokenizers.whitespace, 108 local: local_faqsMatcher, 109 identify: function (obj) { return obj.name }, 110 remote: { 111 url: '/newfront/index.php?r=faq/ajax-search-question&query=%QUERY', 112 wildcard: '%QUERY' 113 } 114 }) 115 116 $('#searchForm-query-faq').typeahead({ 117 hint: true, 118 highlight: true, 119 minLength: 3, 120 limit: 10 121 }, {
122 name: 'faqs', 123 source: faqsMatcher, 124 display: function (item) { 125 return item.name 126 }, 127 templates: { 128 header: ['<div class="tt-header">' + $('#searchForm-query-faq').attr('hinttitle') + '</div>'].join('\n'), 129 suggestion: function (item) { 130 var result = '<span class="txt">' + item.name + '</span>' 131 if (item.answerchunk) { 132 result += '<br /><span class="txt-sb">' + item.answerchunk + '</span>' 133 } 134 return '<div class="tt-suggestion tt-selectable">' + result + '</div>' 135 } 136 } 137 }).bind('typeahead:select', function (ev, item) { 138 window.location.href = item.href 139 }) 140 141 $('form#faqContactForm').submit(function (e) { 142 var $image_inputs = $('#faq_contact_images') 143 var stack_image_count = 0 144 if ($image_inputs.is(':visible')) { 145 stack_image_count = $image_inputs.fileinput('getFileStack').length 146 if (stack_image_count) { 147 $image_inputs.fileinput('upload') 148 setTimeout(function () { $('form#faqContactForm').submit() }, 500) 149 } 150 } 151 if (stack_image_count) { 152 e.preventDefault() 153 } 154 }) 155 156 $('#faq_contact_images').fileinput({ 157 language: $('#faq_contact_images').attr('language'), 158 uploadUrl: $('#faq_contact_images').attr('uploadUrl'), // server upload action 159 uploadExtraData: function (previewId, index) { 160 return { previewId: previewId, index: index } 161 }, 162 uploadAsync: true, 163 dropZoneEnabled: false, 164 showUpload: false, 165 showCaption: false, 166 maxImageHeight: 1600, 167 maxImageWidth: 1600, 168 resizeImage: true, 169 browseIcon: '<i class=" icf-file"></i> ', 170 browseClass: 'btn btn-mini', 171 removeIcon: '<i class="icf-trash"></i> ', 172 removeClass: 'btn btn-mini', 173 cancelIcon: '<i class="icf-incorrect-circle"></i> ', 174 cancelClass: 'btn btn-mini', 175 uploadIcon: '<i class=" icf-file"></i> ', 176 uploadClass: 'btn btn-mini', 177 fileType: 'image', 178 allowedFileTypes: ['image'], 179 // eslint-disable-next-line 180 initialPreview: typeof prevImages === 'undefined' ? [] : prevImages, 181 maxFileCount: 5, 182 allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif'], 183 autoReplace: true, 184 overwriteInitial: false, 185 previewFileIcon: '<i class="icf-image"></i>' 186 }).on('fileuploaded', function (event, data, previewId, index) { 187 if (data.response.success) { 188 $('#images').val(($('#images').val() ? $('#images').val() + ',' : '') + data.response.path) 189 $('form#faqContactForm').submit() 190 } 191 }) 192})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.