mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 02:51:25 +00:00
Centralize Algolia methods in a common factory.
This commit is contained in:
parent
444120f8b1
commit
bf67fedc73
2 changed files with 15 additions and 14 deletions
|
@ -1,21 +1,8 @@
|
|||
define [
|
||||
"base"
|
||||
"services/algolia-search"
|
||||
"libs/platform"
|
||||
], (App, platform) ->
|
||||
|
||||
App.factory "algoliaSearch", ->
|
||||
if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki?
|
||||
client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key)
|
||||
wikiIdx = client.initIndex(window.sharelatex.algolia?.indexes?.wiki)
|
||||
kbIdx = client.initIndex(window.sharelatex.algolia?.indexes?.kb)
|
||||
|
||||
service =
|
||||
searchWiki: wikiIdx.search.bind(wikiIdx)
|
||||
searchKB: kbIdx.search.bind(kbIdx)
|
||||
|
||||
return service
|
||||
|
||||
|
||||
App.controller 'ContactModal', ($scope, $modal) ->
|
||||
$scope.contactUsModal = () ->
|
||||
modalInstance = $modal.open(
|
||||
|
|
14
services/web/public/coffee/services/algolia-search.coffee
Normal file
14
services/web/public/coffee/services/algolia-search.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.factory "algoliaSearch", ->
|
||||
if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki?
|
||||
client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key)
|
||||
wikiIdx = client.initIndex(window.sharelatex.algolia?.indexes?.wiki)
|
||||
kbIdx = client.initIndex(window.sharelatex.algolia?.indexes?.kb)
|
||||
|
||||
service =
|
||||
searchWiki: wikiIdx.search.bind(wikiIdx)
|
||||
searchKB: kbIdx.search.bind(kbIdx)
|
||||
|
||||
return service
|
Loading…
Reference in a new issue