algoliasearch.zendesk-hc
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -17,3 +17,3 @@ 'use strict'; | ||
} | ||
head.appendChild(styleTag); | ||
return head.appendChild(styleTag); | ||
}; |
@@ -15,14 +15,10 @@ 'use strict'; | ||
var _defaultsDeep = require('lodash/defaultsDeep'); | ||
var _addCSS = require('./addCSS.js'); | ||
var _defaultsDeep2 = _interopRequireDefault(_defaultsDeep); | ||
var _addCSS2 = _interopRequireDefault(_addCSS); | ||
var _every = require('lodash/every'); | ||
var _autocomplete = require('./autocomplete.js'); | ||
var _every2 = _interopRequireDefault(_every); | ||
var _autocomplete2 = _interopRequireDefault(_autocomplete); | ||
var _isString = require('lodash/isString'); | ||
var _isString2 = _interopRequireDefault(_isString); | ||
var _translations = require('./translations.js'); | ||
@@ -32,6 +28,2 @@ | ||
var _autocomplete = require('./autocomplete.js'); | ||
var _autocomplete2 = _interopRequireDefault(_autocomplete); | ||
var _instantsearch = require('./instantsearch.js'); | ||
@@ -41,2 +33,6 @@ | ||
var _removeCSS = require('./removeCSS.js'); | ||
var _removeCSS2 = _interopRequireDefault(_removeCSS); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -48,3 +44,3 @@ | ||
return val >= 1 && val <= 20 || 'should be between 1 and 20'; | ||
}; | ||
} | ||
var optionsStructure = { required: true, type: 'Object', children: { | ||
@@ -66,2 +62,4 @@ applicationId: { type: 'string', required: true }, | ||
enabled: { type: 'boolean', value: true }, | ||
paginationSelector: { type: 'string', value: '.pagination' }, | ||
selector: { type: 'string', value: '.search-results' }, | ||
tagsLimit: { type: 'number', value: 15 } | ||
@@ -81,2 +79,4 @@ } }, | ||
var genericHiding = (0, _addCSS2.default)('\n ' + options.autocomplete.inputSelector + ' { display: none; }\n ' + options.instantsearch.selector + ' { display: none; }\n ' + options.instantsearch.paginationSelector + ' { display: none; }\n '); | ||
// once the DOM is initialized | ||
@@ -86,9 +86,13 @@ (0, _jQuery2.default)(document).ready(function () { | ||
// autocompletion menu | ||
_this.autocomplete = (0, _autocomplete2.default)(options); | ||
var instantsearchPage = (0, _jQuery2.default)(options.instantsearch.selector).length !== 0; | ||
// instant search result page | ||
if (options.instantsearch.enabled) { | ||
_this.autocomplete = (0, _instantsearch2.default)(options); | ||
if (instantsearchPage) { | ||
// instant search result page | ||
_this.instantsearch = (0, _instantsearch2.default)(options); | ||
} else { | ||
// autocompletion menu | ||
_this.autocomplete = (0, _autocomplete2.default)(options); | ||
} | ||
(0, _removeCSS2.default)(genericHiding); | ||
}); | ||
@@ -95,0 +99,0 @@ }; |
@@ -47,2 +47,11 @@ 'use strict'; | ||
var $input = (0, _jQuery2.default)(inputSelector); | ||
var inputWidth = $input.outerWidth(); | ||
var sizeModifier = null; | ||
if (inputWidth < 400) sizeModifier = 'xs';else if (inputWidth < 600) sizeModifier = 'sm'; | ||
var nbSnippetWords = sizeModifier === 'xs' ? 0 : 10 + Math.floor((inputWidth - 400) / 30); | ||
// initialize API client | ||
@@ -64,2 +73,3 @@ var client = (0, _algoliasearch2.default)(applicationId, apiKey); | ||
highlightPostTag: '</span>', | ||
attributesToSnippet: ['body_safe:' + nbSnippetWords], | ||
snippetEllipsisText: '...' | ||
@@ -74,2 +84,4 @@ }).then(function (content) { | ||
hit.sizeModifier = sizeModifier; | ||
if (!groupedHits.has(category)) { | ||
@@ -113,3 +125,3 @@ hit.isCategoryHeader = true; | ||
// autocomplete.js initialization | ||
return (0, _jQuery2.default)(inputSelector).attr('placeholder', translations.placeholder_autocomplete).autocomplete({ | ||
return $input.attr('placeholder', translations.placeholder_autocomplete).autocomplete({ | ||
hint: false, | ||
@@ -116,0 +128,0 @@ debug: process.env.NODE_ENV === 'development', |
@@ -7,6 +7,2 @@ 'use strict'; | ||
var _addCSS = require('./addCSS.js'); | ||
var _addCSS2 = _interopRequireDefault(_addCSS); | ||
var _toFactory = require('to-factory'); | ||
@@ -22,4 +18,2 @@ | ||
(0, _addCSS2.default)('\n.search-results h1:first-child {\n display: none !important;\n}\n.search-results-column {\n display: none;\n visibility: hidden;\n}'); | ||
exports.default = (0, _toFactory2.default)(_AlgoliasearchZendeskHC2.default); |
@@ -22,9 +22,7 @@ 'use strict'; | ||
exports.default = function (options) { | ||
var $searchResults = (0, _jquery2.default)('.search-results'); | ||
if ($searchResults.length === 0) { | ||
return; | ||
} | ||
var $container = $searchResults.find('.search-results-column'); | ||
$container.html('\n <div>\n <input type="text" id="algolia-query" autofocus="autofocus" />\n <div id="algolia-stats"></div>\n <div id="algolia-facets">\n <div id="algolia-categories"></div>\n <div id="algolia-labels"></div>\n </div>\n <div id="algolia-hits"></div>\n <div class="clearfix"></div>\n <div id="algolia-pagination"></div>\n </div>'); | ||
if (!options.instantsearch.enabled) return; | ||
var $container = (0, _jquery2.default)(options.instantsearch.selector); | ||
$container.html('\n <div>\n <input type="text" id="algolia-query"/>\n <div id="algolia-stats"></div>\n <div id="algolia-facets">\n <div id="algolia-categories"></div>\n <div id="algolia-labels"></div>\n </div>\n <div id="algolia-hits"></div>\n <div class="clearfix"></div>\n <div id="algolia-pagination"></div>\n </div>'); | ||
function displayTimes() { | ||
@@ -55,11 +53,17 @@ var _this = this; | ||
var $q = (0, _jquery2.default)(options.autocomplete.inputSelector || '#query'); | ||
var query = $q.val(); | ||
if ($q.autocomplete) { | ||
$q.autocomplete('val', ''); | ||
} else { | ||
$q.val(''); | ||
var $autocompleteInput = (0, _jquery2.default)(options.autocomplete.inputSelector); | ||
var query = $autocompleteInput.val(); | ||
// Hide autocomplete block | ||
var $elt = $autocompleteInput.closest('form'); | ||
var $tmp = $elt.parent(); | ||
while ($tmp.children.length === 1) { | ||
$elt = $tmp; | ||
$tmp = $elt.parent(); | ||
} | ||
$q.attr('autofocus', null); | ||
$elt.hide(); | ||
var $paginationContainer = (0, _jquery2.default)(options.instantsearch.paginationSelector); | ||
$paginationContainer.hide(); | ||
var search = (0, _instantsearch2.default)({ | ||
@@ -84,2 +88,3 @@ appId: options.applicationId, | ||
// Filter by language | ||
helper.toggleRefine('locale.locale', I18n.locale); | ||
@@ -86,0 +91,0 @@ } |
@@ -19,3 +19,3 @@ 'use strict'; | ||
// Autocompletion template for an article | ||
article: _hogan2.default.compile('<div\n class="\n aa-article-hit\n {{# isCategoryHeader }}aa-article-hit__category-first{{/ isCategoryHeader }}\n {{# isSectionHeader }}aa-article-hit__section-first{{/ isSectionHeader }}\n "\n >\n <div class="aa-article-hit--category">\n {{ category.title }}\n </div>\n <div class="aa-article-hit--line">\n <div class="aa-article-hit--section">\n <div class="aa-article-hit--section--inside">{{ section.title }}</div>\n </div>\n <div class="aa-article-hit--content">\n <div class="aa-article-hit--title">\n {{{ _highlightResult.title.value }}}\n </div>\n {{# _snippetResult.body_safe.value }}\n <div class="aa-article-hit--body">{{{ _snippetResult.body_safe.value }}}</div>\n {{/ _snippetResult.body_safe.value }}\n </div>\n </div>'), | ||
article: _hogan2.default.compile('<div\n class="\n aa-article-hit\n {{# isCategoryHeader }}aa-article-hit__category-first{{/ isCategoryHeader }}\n {{# isSectionHeader }}aa-article-hit__section-first{{/ isSectionHeader }}\n {{# sizeModifier }}aa-article-hit__{{ sizeModifier }}{{/ sizeModifier}}\n "\n >\n <div class="aa-article-hit--category">\n {{ category.title }}\n </div>\n <div class="aa-article-hit--line">\n <div class="aa-article-hit--section">\n <div class="aa-article-hit--section--inside">{{ section.title }}</div>\n </div>\n <div class="aa-article-hit--content">\n <div class="aa-article-hit--title">\n {{{ _highlightResult.title.value }}}\n </div>\n {{# _snippetResult.body_safe.value }}\n <div class="aa-article-hit--body">{{{ _snippetResult.body_safe.value }}}</div>\n {{/ _snippetResult.body_safe.value }}\n </div>\n </div>'), | ||
@@ -22,0 +22,0 @@ // Powered By |
{ | ||
"name": "algoliasearch.zendesk-hc", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Algolia Search for Zendesk's Help Center", | ||
@@ -68,2 +68,3 @@ "author": "Algolia <support@algolia.com>", | ||
"gulp-util": "^3.0.7", | ||
"instantsearch.js": "^1.2.2", | ||
"isparta": "^4.0.0", | ||
@@ -70,0 +71,0 @@ "jquery": "^2.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10950905
20
43
4213