diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ #add bootstrap gem 'bootstrap-sass', '~> 3.2.0' +gem 'bootstrap-switch-rails' gem 'autoprefixer-rails' diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,7 @@ railties (>= 3.2) bootstrap-sass (3.2.0.2) sass (~> 3.2) + bootstrap-switch-rails (3.3.3) builder (3.0.4) coffee-rails (3.2.2) coffee-script (>= 2.2.0) @@ -162,6 +163,7 @@ autoprefixer-rails best_in_place (~> 3.0.1) bootstrap-sass (~> 3.2.0) + bootstrap-switch-rails coffee-rails (~> 3.2.2) dynamic_form haml diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,8 +14,9 @@ //= require jquery_ujs //= require jquery.ui.all //= require bootstrap-sprockets +//= require bootstrap-switch +//= require select2 //= require custom -//= require select2 // since this is after blank line, it is not downloaded diff --git a/app/assets/javascripts/custom.js.coffee b/app/assets/javascripts/custom.js.coffee --- a/app/assets/javascripts/custom.js.coffee +++ b/app/assets/javascripts/custom.js.coffee @@ -1,2 +1,26 @@ +$(document).on 'change', '.btn-file :file', -> + input = $(this) + numFiles = if input.get(0).files then input.get(0).files.length else 1 + label = input.val().replace(/\\/g, '/').replace(/.*\//, '') + input.trigger 'fileselect', [ + numFiles + label + ] + return + + +# document ready + $ -> $(".select2").select2() + $(".bootstrap-switch").bootstrapSwitch() + $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> + input = $(this).parents('.input-group').find(':text') + log = if numFiles > 1 then numFiles + ' files selected' else label + if input.length + input.val log + else + if log + alert log + return + return diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -25,14 +25,35 @@ @import jquery-tablesorter/theme.metro-dark @import tablesorter-theme.cafe +//bootstrap @import bootstrap-sprockets @import bootstrap @import select2 @import select2-bootstrap +@import bootstrap3-switch .secondnavbar top: 50px +.btn-file + position: relative + overflow: hidden + +.btn-file input[type=file] + position: absolute + top: 0 + right: 0 + min-width: 100% + min-height: 100% + font-size: 100px + text-align: right + filter: alpha(opacity=0) + opacity: 0 + outline: none + background: white + cursor: inherit + display: block + body background: white image-url("topbg.jpg") repeat-x top center //font-size: 13px diff --git a/app/views/announcements/index.html.erb b/app/views/announcements/index.html.erb --- a/app/views/announcements/index.html.erb +++ b/app/views/announcements/index.html.erb @@ -27,7 +27,8 @@ <%=h announcement.body %> <%=h announcement.author %> - <%= in_place_editor_field :announcement, :published, {}, :rows => 1 %> + <%= check_box_tag :published, 1, announcement.published, class: 'bootstrap-switch', data: {size: 'small'} %> + <%= link_to 'Show', announcement %> <%= link_to 'Edit', edit_announcement_path(announcement) %> <%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %> diff --git a/app/views/main/_submission_box.html.haml b/app/views/main/_submission_box.html.haml --- a/app/views/main/_submission_box.html.haml +++ b/app/views/main/_submission_box.html.haml @@ -1,6 +1,20 @@ -= form_tag({:action => 'submit'}, :multipart => true) do - %b Problem: - = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2' } - %b File: - = file_field_tag 'file' - = submit_tag 'Submit' += form_tag({:action => 'submit'}, :multipart => true, class: 'form-inline') do + - if @submission and @submission.errors.any? + #error_explanation + .alert.alert-danger + %h3= "#{pluralize(@submission.errors.count, "error")} prohibited this user from being saved:" + %ul + - @submission.errors.full_messages.each do |msg| + %li= msg + .form-group + = label_tag :submission, 'Problem:' + = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2 form-control' } + .form-group + = label_tag :file, 'File:' + .input-group + %span.input-group-btn + %span.btn.btn-default.btn-file + Browse + = file_field_tag 'file' + = text_field_tag '' , nil, {readonly: true, class: 'form-control'} + = submit_tag 'Submit', class: 'btn btn-default' diff --git a/app/views/main/list.html.haml b/app/views/main/list.html.haml --- a/app/views/main/list.html.haml +++ b/app/views/main/list.html.haml @@ -11,7 +11,6 @@ - if GraderConfiguration.show_submitbox_to?(@user) .submitbox - = error_messages_for 'submission' = render :partial => 'submission_box' @@ -22,7 +21,7 @@ - if GraderConfiguration.show_tasks_to?(@user) - if not GraderConfiguration.multicontests? - %table.table.table-striped + %table.table.table-striped.table-condensed %thead %tr.info-head %th #