Commit 92f04733 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move search autocomplete call to dispatcher

parent 0b981eb9
@Admin =
init: ->
class Admin
constructor: ->
$('input#user_force_random_password').on 'change', (elem) ->
elems = $('#user_password, #user_password_confirmation')
......@@ -26,3 +26,5 @@
$('.change-owner-cancel-link').bind "click", ->
modal.hide()
$('.change-owner-link').show()
@Admin = Admin
......@@ -3,6 +3,10 @@ $ ->
class Dispatcher
constructor: () ->
@initSearch()
@initPageScripts()
initPageScripts: ->
page = $('body').attr('data-page')
project_id = $('body').attr('data-project-id')
......@@ -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
......@@ -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 }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment