diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-11 12:11:54 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-11 12:11:54 +0200 |
commit | 8a179611262221f6f3cf2f8737d4340d74f0b282 (patch) | |
tree | 289c47436a82b018fd104b77c1f02def6c6b833b /app | |
parent | 12cb7cee2669502843a17331cb04ada904ff6f81 (diff) | |
download | gitlab-ce-8a179611262221f6f3cf2f8737d4340d74f0b282.tar.gz |
Replace chosen with select2
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
23 files changed, 55 insertions, 115 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0767b82032d..aa2db1fc93c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -19,7 +19,6 @@ //= require jquery.turbolinks //= require bootstrap //= require modernizr -//= require chosen-jquery //= require select2 //= require raphael //= require g.raphael-min diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 43571409bc5..5e60b2775a6 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -29,12 +29,10 @@ $('#filter_issue_search').val($('#issue_search').val()) initSelects: -> - $("#update_status").chosen() - $("#update_assignee_id").chosen() - $("#update_milestone_id").chosen() - $("#label_name").chosen() - $("#assignee_id").chosen() - $("#milestone_id").chosen() + $("select#update_status").select2() + $("select#update_assignee_id").select2() + $("select#update_milestone_id").select2() + $("select#label_name").select2() $("#milestone_id, #assignee_id, #label_name").on "change", -> $(this).closest("form").submit() diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 5add7541a73..64fe7bd2d5a 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -67,8 +67,8 @@ $ -> $('.appear-data').fadeIn() e.preventDefault() - # Initialize chosen selects - $('select.chosen').chosen() + # Initialize select2 selects + $('select.select2').select2(width: 'resolve') # Initialize tooltips $('.has_tooltip').tooltip() @@ -126,12 +126,6 @@ $ -> $(@).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 $.fn.extend disable: -> $(@).attr('disabled', 'disabled').addClass('disabled') diff --git a/app/assets/javascripts/merge_requests.js.coffee b/app/assets/javascripts/merge_requests.js.coffee index 2eef7df1c64..047683f00b2 100644 --- a/app/assets/javascripts/merge_requests.js.coffee +++ b/app/assets/javascripts/merge_requests.js.coffee @@ -2,8 +2,8 @@ # * Filter merge requests # @merge_requestsPage = -> - $('#assignee_id').chosen() - $('#milestone_id').chosen() + $('#assignee_id').select2() + $('#milestone_id').select2() $('#milestone_id, #assignee_id').on 'change', -> $(this).closest('form').submit() diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 56ef73a2a45..eb8bc0d63c0 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,7 +4,6 @@ * 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.atwho - *= require chosen *= require select2 *= require_self */ diff --git a/app/assets/stylesheets/generic/selects.scss b/app/assets/stylesheets/generic/selects.scss index 31a1d49e334..bd9fc211ce5 100644 --- a/app/assets/stylesheets/generic/selects.scss +++ b/app/assets/stylesheets/generic/selects.scss @@ -1,78 +1,28 @@ -/** Chosen.js selectbox style override **/ -.chosen-container { - min-width: 100px; +/** Select2 selectbox style override **/ - .chosen-single { - height: 26px; - background: #EEE !important; - border: 1px solid #DDD !important; - @include box-shadow(none !important); - @include border-radius(4px !important); +.select2-container { + .select2-choice { + background: #EEE; + border-color: #BBB; } - - .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 { - &.chosen { + &.select2 { width: 100px; } - &.chosen-sm { + &.select2-sm { width: 100px; } } @media (min-width: $screen-sm-min) { select { - &.chosen { + &.select2 { width: 150px; } - &.chosen-sm { + &.select2-sm { width: 120px; } } @@ -81,10 +31,10 @@ select { /* Medium devices (desktops, 992px and up) */ @media (min-width: $screen-md-min) { select { - &.chosen { + &.select2 { width: 170px; } - &.chosen-sm { + &.select2-sm { width: 140px; } } @@ -93,10 +43,10 @@ select { /* Large devices (large desktops, 1200px and up) */ @media (min-width: $screen-lg-min) { select { - &.chosen { + &.select2 { width: 200px; } - &.chosen-sm { + &.select2-sm { width: 150px; } } diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 10add561c36..81d945a9b3c 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -77,8 +77,8 @@ input.check_all_issues { @media (min-width: 800px) { .issues_filters select { width: 160px; } } @media (min-width: 1200px) { .issues_filters select { width: 220px; } } -@media (min-width: 800px) { .issues_bulk_update .chosen-container { min-width: 120px; } } -@media (min-width: 1200px) { .issues_bulk_update .chosen-container { min-width: 160px; } } +@media (min-width: 800px) { .issues_bulk_update .select2-container { min-width: 120px; } } +@media (min-width: 1200px) { .issues_bulk_update .select2-container { min-width: 160px; } } .issues-holder { .issues_filters { @@ -105,7 +105,7 @@ input.check_all_issues { } .issues_bulk_update { - .chosen-container { + .select2-container { text-shadow: none; } } diff --git a/app/assets/stylesheets/sections/merge_requests.scss b/app/assets/stylesheets/sections/merge_requests.scss index b7f7c61597f..d3462d6aaa7 100644 --- a/app/assets/stylesheets/sections/merge_requests.scss +++ b/app/assets/stylesheets/sections/merge_requests.scss @@ -95,7 +95,7 @@ font-weight: normal !important; } - .chosen-container .chosen-single { + .select2-container .select2-single { span { font-weight: bold; color: #555; diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index 7c1c8122fa7..8749c7458c3 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -230,7 +230,7 @@ ul.nav.nav-projects-tabs { } } -.transfer-project .chosen-container { +.transfer-project .select2-container { min-width: 200px; } @@ -245,23 +245,23 @@ ul.nav.nav-projects-tabs { } } -.project-refs-form .chosen-container { +.project-refs-form .select2-container { position: relative; top: 0; left: 0; margin-right: 10px; - .chosen-single span { + .select2-single span { font-weight: bold; color: #555; } - &.chosen-container-active { - .chosen-drop { + &.select2-container-active { + .select2-drop { min-width: 400px; } - .chosen-results { + .select2-results { max-height: 400px; } } diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 235588fe367..252111875fa 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -57,7 +57,7 @@ %div = users_select_tag(:user_ids, multiple: true) %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 = submit_tag 'Add users into group', class: "btn btn-create" .ui-box diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index 54e010ad2d9..5801139a9f2 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -12,7 +12,7 @@ %p 2. Set access level for them .form-group = 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 = f.submit 'Add users into group', class: "btn btn-create" diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 997bdbe985c..79234fe4fa9 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -26,7 +26,7 @@ - if @project.repository.exists? && @project.repository.branch_names.any? .form-group = 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) @@ -145,7 +145,7 @@ %span Namespace .col-sm-10 .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 %li Be careful. Changing the project's namespace can have unintended side effects. %li You can only transfer the project to namespaces you manage. diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml index 0935d386129..c95e8178594 100644 --- a/app/views/projects/issues/_form.html.haml +++ b/app/views/projects/issues/_form.html.haml @@ -24,7 +24,7 @@ %i.icon-user Assign to .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'}) = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' .form-group @@ -32,7 +32,7 @@ = f.label :milestone_id, class: 'control-label' do %i.icon-time 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 = f.label :label_list, class: 'control-label' do @@ -87,6 +87,6 @@ }); $('.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(); }); diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index d31b20b8815..7ddf470b6a0 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -6,7 +6,7 @@ - if can?(current_user, :modify_issue, @issue) = link_to profile_path(issue.assignee) do = 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 = link_to_member(@project, @issue.assignee) @@ -17,7 +17,7 @@ %cite.cgray Attached to milestone - 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 = f.submit class: 'btn' diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml index 7e26cb77c4e..59524e0f224 100644 --- a/app/views/projects/issues/update.js.haml +++ b/app/views/projects/issues/update.js.haml @@ -5,7 +5,7 @@ - elsif params[:issue_context] $('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); $('.issue-box .context').effect('highlight'); - $('.chosen').chosen(); + $('.select2').select2(); $('.edit-issue.inline-update input[type="submit"]').hide(); - 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>") diff --git a/app/views/projects/merge_requests/_form.html.haml b/app/views/projects/merge_requests/_form.html.haml index 87611c08db0..67cb5ccd72d 100644 --- a/app/views/projects/merge_requests/_form.html.haml +++ b/app/views/projects/merge_requests/_form.html.haml @@ -10,10 +10,10 @@ .col-md-5 .clearfix .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 - = 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 .col-md-2 .merge-request-angle @@ -22,10 +22,10 @@ .clearfix .pull-left - 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 - = 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 %hr @@ -47,7 +47,7 @@ %i.icon-user Assign to .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'}) = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' .form-group @@ -55,7 +55,7 @@ = f.label :milestone_id, class: 'control-label' do %i.icon-time 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 @@ -90,6 +90,6 @@ $.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){ - $('#merge_request_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); + $('#merge_request_assignee_id').val("#{current_user.id}").trigger("select2:updated"); e.preventDefault(); }); diff --git a/app/views/projects/merge_requests/update_branches.js.haml b/app/views/projects/merge_requests/update_branches.js.haml index dfccb586ec7..6a21551e811 100644 --- a/app/views/projects/merge_requests/update_branches.js.haml +++ b/app/views/projects/merge_requests/update_branches.js.haml @@ -1,5 +1,5 @@ :plain $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); - $(".target_branch").trigger("chosen:updated"); + $(".target_branch").trigger("select2:updated"); $(".mr_target_commit").html(""); $(".target_branch").trigger("change"); diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 4f81f050f60..f21cef6f2e3 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -27,7 +27,7 @@ = f.label :namespace_id, class: 'control-label' do %span Namespace .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 .col-sm-2 diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml index 3533d4d23bc..e0d058de79e 100644 --- a/app/views/projects/protected_branches/index.html.haml +++ b/app/views/projects/protected_branches/index.html.haml @@ -22,7 +22,7 @@ .entry.clearfix = f.label :name, "Branch" .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"}) = f.submit 'Protect', class: "btn-create btn" - unless @branches.empty? diff --git a/app/views/projects/snippets/_form.html.haml b/app/views/projects/snippets/_form.html.haml index 68ba227045c..c4664a58a01 100644 --- a/app/views/projects/snippets/_form.html.haml +++ b/app/views/projects/snippets/_form.html.haml @@ -14,7 +14,7 @@ .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true .form-group = 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 .file-editor = f.label :file_name, "File" diff --git a/app/views/projects/team_members/_form.html.haml b/app/views/projects/team_members/_form.html.haml index 01218090ff0..dd059fb99d3 100644 --- a/app/views/projects/team_members/_form.html.haml +++ b/app/views/projects/team_members/_form.html.haml @@ -17,7 +17,7 @@ %p 2. Set access level for them .form-group = 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 = f.submit 'Add users', class: "btn btn-create" diff --git a/app/views/projects/team_members/import.html.haml b/app/views/projects/team_members/import.html.haml index d3b516e05a2..d3e4a762018 100644 --- a/app/views/projects/team_members/import.html.haml +++ b/app/views/projects/team_members/import.html.haml @@ -6,7 +6,7 @@ = form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do .form-group = 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 = submit_tag 'Import project members', class: "btn btn-create" diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index e02b615a4cd..4d9534f49b1 100644 --- a/app/views/shared/_ref_switcher.html.haml +++ b/app/views/shared/_ref_switcher.html.haml @@ -1,5 +1,5 @@ = 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 - if defined?(path) = hidden_field_tag :path, path |