Skip to content

Commit 249f422

Browse files
Merge branch 'develop' into bugfix/MAGE-207
2 parents fc55e20 + 49befee commit 249f422

File tree

2 files changed

+54
-66
lines changed

2 files changed

+54
-66
lines changed

view/adminhtml/templates/query/edit/merchandising.phtml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,6 @@ $isConfig = [
191191
algoliaAdminBundle.$(function ($) {
192192
var config = <?php echo json_encode($isConfig); ?>;
193193
config.searchFunction = function(helper) {
194-
if (helper.state.query !== '') {
195-
algoliaEventsTracking.postEvent('Searched Keyword', {
196-
source: 'magento2.querymerch.edit',
197-
search: helper.state.query
198-
});
199-
}
200194
helper.search();
201195
};
202196

view/adminhtml/web/js/support.js

Lines changed: 54 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
22
algoliaBundle.$(function ($) {
33
handleLatestVersion($);
4-
4+
55
if ($('#search_box').length > 0) {
66
initDocSearch();
77
initDiscourseSearch();
88
}
9-
9+
1010
if ($('.algolia_contact_form #subject').length > 0) {
1111
initContactDocSearch();
1212
}
@@ -25,18 +25,12 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
2525
hitsPerPage: 10
2626
},
2727
searchFunction: function(helper) {
28-
if (helper.state.query !== '') {
29-
algoliaEventsTracking.postEvent('Performed Search', {
30-
source: 'magento2.help.search',
31-
search: helper.state.query
32-
});
33-
}
3428
helper.search();
3529
}
3630
});
37-
31+
3832
documentationSearch.addWidget(getSearchBoxWidget(false));
39-
33+
4034
documentationSearch.addWidget(
4135
algoliaBundle.instantsearch.widgets.hits({
4236
container: '.doc.links',
@@ -52,7 +46,7 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
5246
}
5347
})
5448
);
55-
49+
5650
documentationSearch.addWidget(
5751
algoliaBundle.instantsearch.widgets.stats({
5852
container: '.doc.stats',
@@ -61,13 +55,13 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
6155
}
6256
})
6357
);
64-
58+
6559
documentationSearch.addWidget(
6660
algoliaBundle.instantsearch.widgets.stats({
6761
container: '.doc.footer',
6862
transformData: function(hit) {
6963
hit['morePages'] = hit.nbPages > 1;
70-
64+
7165
return hit;
7266
},
7367
templates: {
@@ -81,10 +75,10 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
8175
}
8276
})
8377
);
84-
78+
8579
documentationSearch.start();
8680
}
87-
81+
8882
function initDiscourseSearch() {
8983
const discourseSearch = algoliaBundle.instantsearch({
9084
appId: 'G25OKIW19Q',
@@ -96,9 +90,9 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
9690
},
9791
searchFunction: searchFunction
9892
});
99-
93+
10094
discourseSearch.addWidget(getSearchBoxWidget(true));
101-
95+
10296
discourseSearch.addWidget(
10397
algoliaBundle.instantsearch.widgets.hits({
10498
container: '.links.forum',
@@ -117,15 +111,15 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
117111
hit.content = escapeHighlightedString(
118112
hit._snippetResult.content.value
119113
);
120-
114+
121115
hit.tags = hit._highlightResult.topic.tags;
122-
116+
123117
return hit;
124118
}
125119
}
126120
})
127121
);
128-
122+
129123
discourseSearch.addWidget(
130124
algoliaBundle.instantsearch.widgets.stats({
131125
container: '.forum.stats',
@@ -134,13 +128,13 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
134128
}
135129
})
136130
);
137-
131+
138132
discourseSearch.addWidget(
139133
algoliaBundle.instantsearch.widgets.stats({
140134
container: '.forum.footer',
141135
transformData: function(hit) {
142136
hit['morePages'] = hit.nbPages > 1;
143-
137+
144138
return hit;
145139
},
146140
templates: {
@@ -154,16 +148,16 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
154148
}
155149
})
156150
);
157-
151+
158152
discourseSearch.on('render', function() {
159153
// Loop over every containers
160154
document.querySelectorAll(".ais-hits--item a").forEach(container => {
161155
const content = container.querySelector('.content');
162-
156+
163157
// 186 - 3 lines, each line 62 chars max
164158
if (content.textContent.replace(/\s/g, "").length >= 186) {
165-
166-
159+
160+
167161
var style = document.createElement("style");
168162
style.innerHTML = `
169163
#${container.id} .content:after {
@@ -175,17 +169,17 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
175169
background:#FFF;
176170
padding: 0 0.5ch;
177171
}`;
178-
172+
179173
// And then insert this before the current container
180174
container.parentNode.insertAdjacentElement("afterbegin", style);
181175
}
182176
});
183-
177+
184178
});
185-
179+
186180
discourseSearch.start();
187181
}
188-
182+
189183
function initContactDocSearch() {
190184
const documentationSearch = algoliaBundle.instantsearch({
191185
appId: 'BH4D9OD16A',
@@ -196,7 +190,7 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
196190
hitsPerPage: 3
197191
}
198192
});
199-
193+
200194
documentationSearch.addWidget(
201195
algoliaBundle.instantsearch.widgets.searchBox({
202196
container: '#subject',
@@ -205,7 +199,7 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
205199
magnifier: false
206200
})
207201
);
208-
202+
209203
documentationSearch.addWidget(
210204
algoliaBundle.instantsearch.widgets.hits({
211205
container: '.contact_results',
@@ -215,23 +209,23 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
215209
}
216210
})
217211
);
218-
212+
219213
documentationSearch.start();
220214
}
221-
215+
222216
function searchFunction(helper) {
223217
const $results = $('#results');
224218
const $landing = $('#landing');
225-
219+
226220
if (helper.state.query === '') {
227221
$results.hide();
228222
$landing.show();
229-
223+
230224
return;
231225
}
232-
226+
233227
helper.search();
234-
228+
235229
$results.show();
236230
$landing.hide();
237231
}
@@ -260,23 +254,23 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
260254
});
261255
}
262256
});
263-
257+
264258
function handleLatestVersion($) {
265259
$.getJSON('https://api.github.com/repos/algolia/algoliasearch-magento-2/releases/latest', function(payload) {
266260
const latestVersion = payload.name;
267-
261+
268262
if(compareVersions(algoliaSearchExtentionsVersion, latestVersion) > 0) {
269263
const ghLink = 'https://github.com/algolia/algoliasearch-magento-2/releases/tag/' + latestVersion;
270264
const latestVersionLink = '<a href="' + ghLink + '" target="_blank">' + latestVersion + '</a>';
271-
265+
272266
$('#current_version').text(algoliaSearchExtentionsVersion);
273267
$('.version.latest_version').html(latestVersionLink);
274-
268+
275269
$('.legacy_version').show();
276270
}
277271
});
278272
}
279-
273+
280274
function getSearchBoxWidget(showIcons = false) {
281275
return algoliaBundle.instantsearch.widgets.searchBox({
282276
container: '#search_box',
@@ -285,78 +279,78 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
285279
magnifier: showIcons
286280
});
287281
}
288-
282+
289283
function getDocumentationTemplate() {
290284
return `
291285
<a href="{{url}}?utm_source=magento&utm_medium=extension&utm_campaign=support-page" target="_blank" id="doc_{{objectID}}">
292286
<span class="heading">
293287
{{#hierarchy.lvl0}}
294288
{{{_highlightResult.hierarchy.lvl0.value}}}
295289
{{/hierarchy.lvl0}}
296-
290+
297291
{{#hierarchy.lvl1}}
298292
> {{{_highlightResult.hierarchy.lvl1.value}}}
299293
{{/hierarchy.lvl1}}
300-
294+
301295
{{#hierarchy.lvl2}}
302296
> {{{_highlightResult.hierarchy.lvl2.value}}}
303297
{{/hierarchy.lvl2}}
304-
298+
305299
{{#hierarchy.lvl3}}
306300
> {{{_highlightResult.hierarchy.lvl3.value}}}
307301
{{/hierarchy.lvl3}}
308-
302+
309303
{{#hierarchy.lvl4}}
310304
> {{{_highlightResult.hierarchy.lvl4.value}}}
311305
{{/hierarchy.lvl4}}
312306
</span>
313-
307+
314308
<span class="content">
315309
{{{#content}}}
316310
{{{_highlightResult.content.value}}}
317311
{{{/content}}}
318312
</span>
319313
</div>`;
320314
}
321-
315+
322316
function getDiscourseTemplate() {
323317
return `
324318
<a href="https://discourse.algolia.com{{url}}/?utm_source=magento&utm_medium=extension&utm_campaign=support-page" target="_blank" id="disc_{{objectID}}">
325319
<span class="heading">
326320
{{{ _highlightResult.topic.title.value }}}
327321
</span>
328-
322+
329323
<span class="content">
330324
{{{content}}}
331325
</span>
332326
</a>`;
333327
}
334-
328+
335329
function escapeHighlightedString(str, highlightPreTag, highlightPostTag) {
336330
highlightPreTag = highlightPreTag || '<em>';
337331
var pre = document.createElement('div');
338332
pre.appendChild(document.createTextNode(highlightPreTag));
339-
333+
340334
highlightPostTag = highlightPostTag || '</em>';
341335
var post = document.createElement('div');
342336
post.appendChild(document.createTextNode(highlightPostTag));
343-
337+
344338
var div = document.createElement('div');
345339
div.appendChild(document.createTextNode(str));
346-
340+
347341
return div.innerHTML
348342
.replace(RegExp(escapeRegExp(pre.innerHTML), 'g'), highlightPreTag)
349343
.replace(RegExp(escapeRegExp(post.innerHTML), 'g'), highlightPostTag)
350344
}
351-
345+
352346
function escapeRegExp(str) {
353347
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
354348
}
355-
349+
356350
function compareVersions(left, right) {
357351
left = sanitizeVersion(left);
358352
right = sanitizeVersion(right);
359-
353+
360354
for (var i = 0; i < Math.max(left.length, right.length); i++) {
361355
if (left[i] > right[i]) {
362356
return -1;
@@ -365,10 +359,10 @@ requirejs(['algoliaAdminBundle'], function(algoliaBundle) {
365359
return 1;
366360
}
367361
}
368-
362+
369363
return 0;
370364
}
371-
365+
372366
function sanitizeVersion(input) {
373367
return input.split('.').map(function (n) {
374368
return parseInt(n, 10);

0 commit comments

Comments
 (0)