Centralize Algolia methods in a common factory.

This commit is contained in:
Paulo Reis 2016-07-11 12:24:48 +01:00
parent 444120f8b1
commit bf67fedc73
2 changed files with 15 additions and 14 deletions

View file

@ -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(

View 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