DG MS; fixed tags autocomplete styling and js
This commit is contained in:
parent
32f1b61719
commit
882c0c2170
7 changed files with 80 additions and 41 deletions
|
|
@ -17,20 +17,8 @@ class TagsController < ApplicationController
|
|||
if params[:q] && params[:q].length > 1 && request.format.json?
|
||||
params[:q].gsub!("#", "")
|
||||
params[:limit] = !params[:limit].blank? ? params[:limit].to_i : 10
|
||||
@tags = ActsAsTaggableOn::Tag.named_like(params[:q]).limit(params[:limit] - 1)
|
||||
@tags.map! do |obj|
|
||||
{ :name => ("#"+obj.name),
|
||||
:value => ("#"+obj.name),
|
||||
:url => tag_path(obj.name)
|
||||
}
|
||||
end
|
||||
|
||||
@tags << {
|
||||
:name => ('#' + params[:q]),
|
||||
:value => ("#" + params[:q]),
|
||||
:url => tag_path(params[:q].downcase)
|
||||
}
|
||||
@tags.uniq!
|
||||
@tags = ActsAsTaggableOn::Tag.autocomplete(params[:q]).limit(params[:limit] - 1)
|
||||
prep_tags_for_javascript
|
||||
|
||||
respond_to do |format|
|
||||
format.json{
|
||||
|
|
@ -77,4 +65,20 @@ class TagsController < ApplicationController
|
|||
end
|
||||
@tag_followed
|
||||
end
|
||||
|
||||
def prep_tags_for_javascript
|
||||
@tags.map! do |obj|
|
||||
{ :name => ("#"+obj.name),
|
||||
:value => ("#"+obj.name),
|
||||
:url => tag_path(obj.name)
|
||||
}
|
||||
end
|
||||
|
||||
@tags << {
|
||||
:name => ('#' + params[:q]),
|
||||
:value => ("#" + params[:q]),
|
||||
:url => tag_path(params[:q].downcase)
|
||||
}
|
||||
@tags.uniq!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,8 @@ class ActsAsTaggableOn::Tag
|
|||
def followed_count
|
||||
@followed_count ||= TagFollowing.where(:tag_id => self.id).count
|
||||
end
|
||||
|
||||
def self.autocomplete(name)
|
||||
where("name LIKE ?", "#{name.downcase}%")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,32 +13,42 @@
|
|||
%h3
|
||||
= t('profiles.edit.your_private_profile')
|
||||
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_bio')
|
||||
= text_area_tag 'profile[bio]', profile.bio, :rows => 5, :placeholder => t('fill_me_out')
|
||||
= text_area_tag 'profile[bio]', profile.bio, :rows => 5, :placeholder => t('fill_me_out')
|
||||
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_location')
|
||||
%br
|
||||
= text_field_tag 'profile[location]', profile.location, :placeholder => t('fill_me_out')
|
||||
|
||||
= text_field_tag 'profile[location]', profile.location, :placeholder => t('fill_me_out')
|
||||
|
||||
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_gender')
|
||||
%br
|
||||
= text_field_tag 'profile[gender]', profile.gender, :placeholder => t("fill_me_out")
|
||||
= text_field_tag 'profile[gender]', profile.gender, :placeholder => t("fill_me_out")
|
||||
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_birthday')
|
||||
%br
|
||||
= select_date profile.birthday, :prompt => true,
|
||||
:default => true, :order => t('date.order'), :start_year => 2000, :end_year => 1930, :prefix => 'profile[date]'
|
||||
= select_date profile.birthday, :prompt => true,
|
||||
:default => true, :order => t('date.order'), :start_year => 2000, :end_year => 1930, :prefix => 'profile[date]'
|
||||
|
||||
%br
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('search')
|
||||
%p{:class=>"checkbox_select"}
|
||||
= label_tag 'profile[searchable]', t('profiles.edit.allow_search')
|
||||
= check_box_tag 'profile[searchable]', true, profile.searchable
|
||||
|
||||
%p{:class=>"checkbox_select"}
|
||||
= label_tag 'profile[searchable]', t('profiles.edit.allow_search')
|
||||
= check_box_tag 'profile[searchable]', true, profile.searchable
|
||||
|
||||
%br
|
||||
%br
|
||||
|
||||
.submit_block
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
autocompleteInput = $("#profile_tag_string");
|
||||
|
||||
|
||||
|
||||
autocompleteInput.autoSuggest("#{tags_path}", {
|
||||
selectedItemProp: "name",
|
||||
searchObjProps: "name",
|
||||
|
|
@ -21,13 +20,14 @@
|
|||
selectionLimit: 5,
|
||||
minChars: 2,
|
||||
keyDelay: 200,
|
||||
startText: "#{t('profiles.edit.your_tags_placeholder')}",
|
||||
startText: "",
|
||||
emptyText: "#{t('no_results')}",
|
||||
preFill: data
|
||||
});
|
||||
|
||||
autocompleteInput.bind('keydown', function(evt){
|
||||
if(evt.keyCode == 13 || evt.keyCode == 9 || evt.keyCode == 32){
|
||||
evt.preventDefault();
|
||||
if( $('li.as-result-item.active').length == 0 ){
|
||||
$('li.as-result-item').first().click();
|
||||
}
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
%h3
|
||||
= t('profiles.edit.your_public_profile')
|
||||
|
||||
|
|
@ -43,13 +42,23 @@
|
|||
|
||||
%h4
|
||||
= t('profiles.edit.your_name')
|
||||
= text_field_tag 'profile[first_name]', profile.first_name, :placeholder => t('profiles.edit.first_name')
|
||||
= text_field_tag 'profile[last_name]', profile.last_name, :placeholder => t('profiles.edit.last_name')
|
||||
= text_field_tag 'profile[first_name]', profile.first_name, :placeholder => t('profiles.edit.first_name')
|
||||
= text_field_tag 'profile[last_name]', profile.last_name, :placeholder => t('profiles.edit.last_name')
|
||||
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_tags')
|
||||
= text_field_tag 'profile[tag_string]', ""
|
||||
|
||||
= text_field_tag 'profile[tag_string]', ""
|
||||
%p{:style => "color:#777;font-style:italic"}
|
||||
= t('profiles.edit.your_tags_placeholder')
|
||||
|
||||
%br
|
||||
|
||||
%h4
|
||||
= t('profiles.edit.your_photo')
|
||||
= render 'photos/new_profile_photo', :aspect => aspect, :person => person
|
||||
%br
|
||||
|
||||
= render 'photos/new_profile_photo', :aspect => aspect, :person => person
|
||||
|
||||
%br
|
||||
|
|
|
|||
|
|
@ -275,11 +275,6 @@ ul.dropdown
|
|||
//hacks for tagging plugin...
|
||||
ul.as-selections
|
||||
:width 100% !important
|
||||
>li.as-original
|
||||
:width 100% !important
|
||||
>input
|
||||
:width 100% !important
|
||||
:color #999
|
||||
//////////////////////////////////
|
||||
|
||||
.unread
|
||||
|
|
@ -835,7 +830,7 @@ a.paginate, #infscr-loading
|
|||
:size 16px
|
||||
:color #333
|
||||
|
||||
input:not([type='submit']):not([type='reset']):not([type='hidden']),
|
||||
input:not([type='submit']):not([type='reset']):not([type='hidden']):not(.as-input),
|
||||
textarea
|
||||
@include border-radius(2px)
|
||||
|
||||
|
|
|
|||
2
public/stylesheets/vendor/autoSuggest.css
vendored
2
public/stylesheets/vendor/autoSuggest.css
vendored
|
|
@ -16,7 +16,7 @@ ul.as-selections {
|
|||
}
|
||||
|
||||
ul.as-selections.loading {
|
||||
background-color: #eee;
|
||||
background: url("/images/ajax-loader.gif") right center no-repeat;
|
||||
}
|
||||
|
||||
ul.as-selections li {
|
||||
|
|
|
|||
17
spec/models/acts_as_taggable_on_tag_spec.rb
Normal file
17
spec/models/acts_as_taggable_on_tag_spec.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ActsAsTaggableOn::Tag do
|
||||
describe '.autocomplete' do
|
||||
before do
|
||||
@tag = ActsAsTaggableOn::Tag.create(:name => "cats")
|
||||
end
|
||||
it 'downcases the tag name' do
|
||||
ActsAsTaggableOn::Tag.autocomplete("CATS").should == [@tag]
|
||||
|
||||
end
|
||||
|
||||
it 'does an end where on tags' do
|
||||
ActsAsTaggableOn::Tag.autocomplete("CAT").should == [@tag]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue