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 %>