Skip to content
Snippets Groups Projects
Commit 92f04733 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Move search autocomplete call to dispatcher

parent 0b981eb9
No related branches found
No related tags found
No related merge requests found
@Admin =
init: ->
class Admin
constructor: ->
$('input#user_force_random_password').on 'change', (elem) ->
elems = $('#user_password, #user_password_confirmation')
 
Loading
Loading
@@ -26,3 +26,5 @@
$('.change-owner-cancel-link').bind "click", ->
modal.hide()
$('.change-owner-link').show()
@Admin = Admin
Loading
Loading
@@ -3,6 +3,10 @@ $ ->
class Dispatcher
constructor: () ->
@initSearch()
@initPageScripts()
initPageScripts: ->
page = $('body').attr('data-page')
project_id = $('body').attr('data-project-id')
 
Loading
Loading
@@ -25,6 +29,9 @@ class Dispatcher
new Wall(project_id)
 
switch path.first()
when 'admin' then Admin.init()
when 'admin' then new Admin()
when 'wikis' then new Wikis()
 
initSearch: ->
autocomplete_json = $('.search-autocomplete-json').data('autocomplete-opts')
new SearchAutocomplete(autocomplete_json)
class SearchAutocomplete
constructor: (json) ->
$("#search").autocomplete
source: json
select: (event, ui) ->
location.href = ui.item.url
@SearchAutocomplete = SearchAutocomplete
Loading
Loading
@@ -3,11 +3,4 @@
= text_field_tag "search", nil, placeholder: "Search", class: "search-input"
= hidden_field_tag :group_id, @group.try(:id)
= hidden_field_tag :project_id, @project.try(:id)
:javascript
$(function(){
$("#search").autocomplete({
source: #{raw search_autocomplete_source},
select: function(event, ui) { location.href = ui.item.url }
});
});
.search-autocomplete-json.hide{:'data-autocomplete-opts' => search_autocomplete_source }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment