-#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
-#   licensed under the Affero General Public License version 3 or later.  See
-#   the COPYRIGHT file.

- if in_mobile_view?
  = javascript_include_tag :jquery
  = javascript_include_tag :mobile

:javascript
  $(document).ready(function () {
    var data = $.parseJSON( "#{escape_javascript(@contacts_json)}" ),
        autocompleteInput = $("#contact_autocomplete");

    autocompleteInput.autoSuggest(data, {
      selectedItemProp: "name",
      searchObjProps: "name",
      asHtmlID: "contact_ids",
      retrieveLimit: 10,
      minChars: 1,
      keyDelay: 0,
      startText: '',
      emptyText: '#{t('no_results')}',
      preFill: [{name : "#{h params[:name]}",
                 value : "#{@contact_ids}"}]
      });
    autocompleteInput.focus();
  });

.span6#new_conversation_pane
  .span5#facebox_header
    %h3
      = t('conversations.index.new_conversation')

  = form_for Conversation.new, html: {class: "new_conversation form_do_not_clear"}, remote: true do |conversation|

    .span1
      %h4
        = t('.to')
    .span4
      = text_field_tag "contact_autocomplete"
    .clearfix
    %br
    .span1
      %h4
        = t('.subject')
    .span4
      = conversation.text_field :subject
    %br
    .span4.offset1
      = text_area_tag "conversation[text]", '', :rows => 5
    .clearfix
    .bottom_submit_section
      = conversation.submit t('.send'), 'data-disable-with' => t('.sending'), :class => 'button creation'