Commit 8a179611 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Replace chosen with select2

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 12cb7cee
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
//= require jquery.turbolinks //= require jquery.turbolinks
//= require bootstrap //= require bootstrap
//= require modernizr //= require modernizr
//= require chosen-jquery
//= require select2 //= require select2
//= require raphael //= require raphael
//= require g.raphael-min //= require g.raphael-min
......
...@@ -29,12 +29,10 @@ ...@@ -29,12 +29,10 @@
$('#filter_issue_search').val($('#issue_search').val()) $('#filter_issue_search').val($('#issue_search').val())
initSelects: -> initSelects: ->
$("#update_status").chosen() $("select#update_status").select2()
$("#update_assignee_id").chosen() $("select#update_assignee_id").select2()
$("#update_milestone_id").chosen() $("select#update_milestone_id").select2()
$("#label_name").chosen() $("select#label_name").select2()
$("#assignee_id").chosen()
$("#milestone_id").chosen()
$("#milestone_id, #assignee_id, #label_name").on "change", -> $("#milestone_id, #assignee_id, #label_name").on "change", ->
$(this).closest("form").submit() $(this).closest("form").submit()
......
...@@ -67,8 +67,8 @@ $ -> ...@@ -67,8 +67,8 @@ $ ->
$('.appear-data').fadeIn() $('.appear-data').fadeIn()
e.preventDefault() e.preventDefault()
# Initialize chosen selects # Initialize select2 selects
$('select.chosen').chosen() $('select.select2').select2(width: 'resolve')
# Initialize tooltips # Initialize tooltips
$('.has_tooltip').tooltip() $('.has_tooltip').tooltip()
...@@ -126,12 +126,6 @@ $ -> ...@@ -126,12 +126,6 @@ $ ->
$(@).remove() $(@).remove()
(($) -> (($) ->
_chosen = $.fn.chosen
$.fn.extend chosen: (options) ->
default_options = search_contains: "true"
$.extend default_options, options
_chosen.apply @, [default_options]
# Disable an element and add the 'disabled' Bootstrap class # Disable an element and add the 'disabled' Bootstrap class
$.fn.extend disable: -> $.fn.extend disable: ->
$(@).attr('disabled', 'disabled').addClass('disabled') $(@).attr('disabled', 'disabled').addClass('disabled')
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# * Filter merge requests # * Filter merge requests
# #
@merge_requestsPage = -> @merge_requestsPage = ->
$('#assignee_id').chosen() $('#assignee_id').select2()
$('#milestone_id').chosen() $('#milestone_id').select2()
$('#milestone_id, #assignee_id').on 'change', -> $('#milestone_id, #assignee_id').on 'change', ->
$(this).closest('form').submit() $(this).closest('form').submit()
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
* the top of the compiled file, but it's generally better to create a new file per style scope. * the top of the compiled file, but it's generally better to create a new file per style scope.
*= require jquery.ui.gitlab *= require jquery.ui.gitlab
*= require jquery.atwho *= require jquery.atwho
*= require chosen
*= require select2 *= require select2
*= require_self *= require_self
*/ */
......
/** Chosen.js selectbox style override **/ /** Select2 selectbox style override **/
.chosen-container {
min-width: 100px;
.chosen-single { .select2-container {
height: 26px; .select2-choice {
background: #EEE !important; background: #EEE;
border: 1px solid #DDD !important; border-color: #BBB;
@include box-shadow(none !important);
@include border-radius(4px !important);
} }
.chosen-results li.highlighted {
background: #29b;
}
.chosen-drop {
margin-top: 10px;
border: 1px solid #DDD !important;
@include border-radius(4px !important);
}
.chosen-search input {
border: 1px solid #CCC !important;
@include box-shadow(none !important);
}
}
/** Select2 styling **/
.select2-container .select2-choice {
@include bg-light-gray-gradient;
}
.select2-container .select2-choice div {
border: none;
background: none;
}
.select2-drop {
padding-top: 8px;
}
.select2-no-results, .select2-searching {
padding: 7px;
color: #666;
}
.chosen-container .chosen-single div b {
background-position-y: 0px !important;
}
.chosen-container .chosen-drop .chosen-search input {
background-position-y: -24px !important;
}
.chosen-compact {
max-width: 170px !important;
} }
select { select {
&.chosen { &.select2 {
width: 100px; width: 100px;
} }
&.chosen-sm { &.select2-sm {
width: 100px; width: 100px;
} }
} }
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
select { select {
&.chosen { &.select2 {
width: 150px; width: 150px;
} }
&.chosen-sm { &.select2-sm {
width: 120px; width: 120px;
} }
} }
...@@ -81,10 +31,10 @@ select { ...@@ -81,10 +31,10 @@ select {
/* Medium devices (desktops, 992px and up) */ /* Medium devices (desktops, 992px and up) */
@media (min-width: $screen-md-min) { @media (min-width: $screen-md-min) {
select { select {
&.chosen { &.select2 {
width: 170px; width: 170px;
} }
&.chosen-sm { &.select2-sm {
width: 140px; width: 140px;
} }
} }
...@@ -93,10 +43,10 @@ select { ...@@ -93,10 +43,10 @@ select {
/* Large devices (large desktops, 1200px and up) */ /* Large devices (large desktops, 1200px and up) */
@media (min-width: $screen-lg-min) { @media (min-width: $screen-lg-min) {
select { select {
&.chosen { &.select2 {
width: 200px; width: 200px;
} }
&.chosen-sm { &.select2-sm {
width: 150px; width: 150px;
} }
} }
......
...@@ -77,8 +77,8 @@ input.check_all_issues { ...@@ -77,8 +77,8 @@ input.check_all_issues {
@media (min-width: 800px) { .issues_filters select { width: 160px; } } @media (min-width: 800px) { .issues_filters select { width: 160px; } }
@media (min-width: 1200px) { .issues_filters select { width: 220px; } } @media (min-width: 1200px) { .issues_filters select { width: 220px; } }
@media (min-width: 800px) { .issues_bulk_update .chosen-container { min-width: 120px; } } @media (min-width: 800px) { .issues_bulk_update .select2-container { min-width: 120px; } }
@media (min-width: 1200px) { .issues_bulk_update .chosen-container { min-width: 160px; } } @media (min-width: 1200px) { .issues_bulk_update .select2-container { min-width: 160px; } }
.issues-holder { .issues-holder {
.issues_filters { .issues_filters {
...@@ -105,7 +105,7 @@ input.check_all_issues { ...@@ -105,7 +105,7 @@ input.check_all_issues {
} }
.issues_bulk_update { .issues_bulk_update {
.chosen-container { .select2-container {
text-shadow: none; text-shadow: none;
} }
} }
......
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
font-weight: normal !important; font-weight: normal !important;
} }
.chosen-container .chosen-single { .select2-container .select2-single {
span { span {
font-weight: bold; font-weight: bold;
color: #555; color: #555;
......
...@@ -230,7 +230,7 @@ ul.nav.nav-projects-tabs { ...@@ -230,7 +230,7 @@ ul.nav.nav-projects-tabs {
} }
} }
.transfer-project .chosen-container { .transfer-project .select2-container {
min-width: 200px; min-width: 200px;
} }
...@@ -245,23 +245,23 @@ ul.nav.nav-projects-tabs { ...@@ -245,23 +245,23 @@ ul.nav.nav-projects-tabs {
} }
} }
.project-refs-form .chosen-container { .project-refs-form .select2-container {
position: relative; position: relative;
top: 0; top: 0;
left: 0; left: 0;
margin-right: 10px; margin-right: 10px;
.chosen-single span { .select2-single span {
font-weight: bold; font-weight: bold;
color: #555; color: #555;
} }
&.chosen-container-active { &.select2-container-active {
.chosen-drop { .select2-drop {
min-width: 400px; min-width: 400px;
} }
.chosen-results { .select2-results {
max-height: 400px; max-height: 400px;
} }
} }
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
%div %div
= users_select_tag(:user_ids, multiple: true) = users_select_tag(:user_ids, multiple: true)
%div.prepend-top-10 %div.prepend-top-10
= select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select chosen" = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select select2"
%hr %hr
= submit_tag 'Add users into group', class: "btn btn-create" = submit_tag 'Add users into group', class: "btn btn-create"
.ui-box .ui-box
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
%p 2. Set access level for them %p 2. Set access level for them
.form-group .form-group
= f.label :group_access, "Group Access", class: 'control-label' = f.label :group_access, "Group Access", class: 'control-label'
.col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select chosen" .col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select select2"
.form-actions .form-actions
= f.submit 'Add users into group', class: "btn btn-create" = f.submit 'Add users into group', class: "btn btn-create"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
- if @project.repository.exists? && @project.repository.branch_names.any? - if @project.repository.exists? && @project.repository.branch_names.any?
.form-group .form-group
= f.label :default_branch, "Default Branch", class: 'control-label' = f.label :default_branch, "Default Branch", class: 'control-label'
.col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen select-wide'}) .col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'select2 select-wide'})
= render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project) = render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project)
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
%span Namespace %span Namespace
.col-sm-10 .col-sm-10
.form-group .form-group
= f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'chosen' } = f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'select2' }
%ul %ul
%li Be careful. Changing the project's namespace can have unintended side effects. %li Be careful. Changing the project's namespace can have unintended side effects.
%li You can only transfer the project to namespaces you manage. %li You can only transfer the project to namespaces you manage.
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
%i.icon-user %i.icon-user
Assign to Assign to
.col-sm-10 .col-sm-10
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'}) = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'select2'})
&nbsp; &nbsp;
= link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
.form-group .form-group
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
= f.label :milestone_id, class: 'control-label' do = f.label :milestone_id, class: 'control-label' do
%i.icon-time %i.icon-time
Milestone Milestone
.col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'}) .col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'})
.form-group .form-group
= f.label :label_list, class: 'control-label' do = f.label :label_list, class: 'control-label' do
...@@ -87,6 +87,6 @@ ...@@ -87,6 +87,6 @@
}); });
$('.assign-to-me-link').on('click', function(e){ $('.assign-to-me-link').on('click', function(e){
$('#issue_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); $('#issue_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault(); e.preventDefault();
}); });
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
- if can?(current_user, :modify_issue, @issue) - if can?(current_user, :modify_issue, @issue)
= link_to profile_path(issue.assignee) do = link_to profile_path(issue.assignee) do
= image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'chosen'}) = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'select2'})
- elsif issue.assignee - elsif issue.assignee
= link_to_member(@project, @issue.assignee) = link_to_member(@project, @issue.assignee)
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
%cite.cgray Attached to milestone %cite.cgray Attached to milestone
- if can?(current_user, :modify_issue, @issue) - if can?(current_user, :modify_issue, @issue)
= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen chosen-compact'}) = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'select2 select2-compact'})
= hidden_field_tag :issue_context = hidden_field_tag :issue_context
= f.submit class: 'btn' = f.submit class: 'btn'
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- elsif params[:issue_context] - elsif params[:issue_context]
$('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); $('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}");
$('.issue-box .context').effect('highlight'); $('.issue-box .context').effect('highlight');
$('.chosen').chosen(); $('.select2').select2();
$('.edit-issue.inline-update input[type="submit"]').hide(); $('.edit-issue.inline-update input[type="submit"]').hide();
- if @issue.milestone - if @issue.milestone
$('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>") $('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>")
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
.col-md-5 .col-md-5
.clearfix .clearfix
.pull-left .pull-left
= f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project chosen span3', disabled: @merge_request.persisted? }) = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? })
.pull-left .pull-left
&nbsp; &nbsp;
= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span2'}) = f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'})
.mr_source_commit.prepend-top-10 .mr_source_commit.prepend-top-10
.col-md-2 .col-md-2
.merge-request-angle .merge-request-angle
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
.clearfix .clearfix
.pull-left .pull-left
- projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project] - projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project]
= f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project chosen span3', disabled: @merge_request.persisted? }) = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? })
.pull-left .pull-left
&nbsp; &nbsp;
= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span2'}) = f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'})
.mr_target_commit.prepend-top-10 .mr_target_commit.prepend-top-10
%hr %hr
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
%i.icon-user %i.icon-user
Assign to Assign to
.col-sm-10 .col-sm-10
= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'chosen'}) = f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'select2'})
&nbsp; &nbsp;
= link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
.form-group .form-group
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
= f.label :milestone_id, class: 'control-label' do = f.label :milestone_id, class: 'control-label' do
%i.icon-time %i.icon-time
Milestone Milestone
.col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'}) .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})
.form-actions .form-actions
...@@ -90,6 +90,6 @@ ...@@ -90,6 +90,6 @@
$.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
}); });
$('.assign-to-me-link').on('click', function(e){ $('.assign-to-me-link').on('click', function(e){
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); $('#merge_request_assignee_id').val("#{current_user.id}").trigger("select2:updated");
e.preventDefault(); e.preventDefault();
}); });
:plain :plain
$(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}");
$(".target_branch").trigger("chosen:updated"); $(".target_branch").trigger("select2:updated");
$(".mr_target_commit").html(""); $(".mr_target_commit").html("");
$(".target_branch").trigger("change"); $(".target_branch").trigger("change");
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
= f.label :namespace_id, class: 'control-label' do = f.label :namespace_id, class: 'control-label' do
%span Namespace %span Namespace
.col-sm-10 .col-sm-10
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen', tabindex: 2} = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2}
.form-group .form-group
.col-sm-2 .col-sm-2
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
.entry.clearfix .entry.clearfix
= f.label :name, "Branch" = f.label :name, "Branch"
.col-md-3 .col-md-3
= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"}) = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "select2 span3"})
&nbsp; &nbsp;
= f.submit 'Protect', class: "btn-create btn" = f.submit 'Protect', class: "btn-create btn"
- unless @branches.empty? - unless @branches.empty?
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
.form-group .form-group
= f.label "Lifetime" = f.label "Lifetime"
.col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} .col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'select2 span2'}
.form-group .form-group
.file-editor .file-editor
= f.label :file_name, "File" = f.label :file_name, "File"
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
%p 2. Set access level for them %p 2. Set access level for them
.form-group .form-group
= f.label :project_access, "Project Access", class: 'control-label' = f.label :project_access, "Project Access", class: 'control-label'
.col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select chosen" .col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select select2"
.form-actions .form-actions
= f.submit 'Add users', class: "btn btn-create" = f.submit 'Add users', class: "btn btn-create"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
= form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do = form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do
.form-group .form-group
= label_tag :source_project_id, "Project", class: 'control-label' = label_tag :source_project_id, "Project", class: 'control-label'
.col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "chosen lg", required: true) .col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "select2 lg", required: true)
.form-actions .form-actions
= submit_tag 'Import project members', class: "btn btn-create" = submit_tag 'Import project members', class: "btn btn-create"
......
= form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do
= select_tag "ref", grouped_options_refs, class: "project-refs-select chosen chosen-sm" = select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm"
= hidden_field_tag :destination, destination = hidden_field_tag :destination, destination
- if defined?(path) - if defined?(path)
= hidden_field_tag :path, path = hidden_field_tag :path, path
......
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