Description:
wip: bootstrap toggle switch
todo: add javascript that thisable button until reponse arrived
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r556:b4cf182747cd - - 9 files changed: 23 inserted, 4 deleted
@@ -45,24 +45,25 | |||||
|
45 | # jquery addition |
|
45 | # jquery addition |
|
46 | gem 'jquery-rails' |
|
46 | gem 'jquery-rails' |
|
47 | gem 'jquery-ui-sass-rails' |
|
47 | gem 'jquery-ui-sass-rails' |
|
48 | gem 'jquery-timepicker-addon-rails' |
|
48 | gem 'jquery-timepicker-addon-rails' |
|
49 | gem 'jquery-tablesorter' |
|
49 | gem 'jquery-tablesorter' |
|
50 |
|
50 | ||
|
51 | #syntax highlighter |
|
51 | #syntax highlighter |
|
52 | gem 'rouge' |
|
52 | gem 'rouge' |
|
53 |
|
53 | ||
|
54 | #add bootstrap |
|
54 | #add bootstrap |
|
55 | gem 'bootstrap-sass', '~> 3.2.0' |
|
55 | gem 'bootstrap-sass', '~> 3.2.0' |
|
56 | gem 'bootstrap-switch-rails' |
|
56 | gem 'bootstrap-switch-rails' |
|
|
57 | + gem 'bootstrap-toggle-rails' | ||
|
57 | gem 'autoprefixer-rails' |
|
58 | gem 'autoprefixer-rails' |
|
58 |
|
59 | ||
|
59 |
|
60 | ||
|
60 | gem 'haml' |
|
61 | gem 'haml' |
|
61 | gem 'mail' |
|
62 | gem 'mail' |
|
62 | gem 'rdiscount' |
|
63 | gem 'rdiscount' |
|
63 | gem 'test-unit' |
|
64 | gem 'test-unit' |
|
64 | gem 'will_paginate', '~> 3.0.7' |
|
65 | gem 'will_paginate', '~> 3.0.7' |
|
65 | gem 'dynamic_form' |
|
66 | gem 'dynamic_form' |
|
66 | gem 'in_place_editing' |
|
67 | gem 'in_place_editing' |
|
67 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
68 | gem 'verification', :git => 'https://github.com/sikachu/verification.git' |
|
68 |
|
69 |
@@ -37,24 +37,25 | |||||
|
37 | i18n (~> 0.6, >= 0.6.4) |
|
37 | i18n (~> 0.6, >= 0.6.4) |
|
38 | multi_json (~> 1.0) |
|
38 | multi_json (~> 1.0) |
|
39 | arel (3.0.3) |
|
39 | arel (3.0.3) |
|
40 | autoprefixer-rails (6.0.3) |
|
40 | autoprefixer-rails (6.0.3) |
|
41 | execjs |
|
41 | execjs |
|
42 | json |
|
42 | json |
|
43 | best_in_place (3.0.3) |
|
43 | best_in_place (3.0.3) |
|
44 | actionpack (>= 3.2) |
|
44 | actionpack (>= 3.2) |
|
45 | railties (>= 3.2) |
|
45 | railties (>= 3.2) |
|
46 | bootstrap-sass (3.2.0.2) |
|
46 | bootstrap-sass (3.2.0.2) |
|
47 | sass (~> 3.2) |
|
47 | sass (~> 3.2) |
|
48 | bootstrap-switch-rails (3.3.3) |
|
48 | bootstrap-switch-rails (3.3.3) |
|
|
49 | + bootstrap-toggle-rails (2.2.1.0) | ||
|
49 | builder (3.0.4) |
|
50 | builder (3.0.4) |
|
50 | coffee-rails (3.2.2) |
|
51 | coffee-rails (3.2.2) |
|
51 | coffee-script (>= 2.2.0) |
|
52 | coffee-script (>= 2.2.0) |
|
52 | railties (~> 3.2.0) |
|
53 | railties (~> 3.2.0) |
|
53 | coffee-script (2.3.0) |
|
54 | coffee-script (2.3.0) |
|
54 | coffee-script-source |
|
55 | coffee-script-source |
|
55 | execjs |
|
56 | execjs |
|
56 | coffee-script-source (1.9.0) |
|
57 | coffee-script-source (1.9.0) |
|
57 | diff-lcs (1.2.5) |
|
58 | diff-lcs (1.2.5) |
|
58 | dynamic_form (1.1.4) |
|
59 | dynamic_form (1.1.4) |
|
59 | erubis (2.7.0) |
|
60 | erubis (2.7.0) |
|
60 | execjs (2.3.0) |
|
61 | execjs (2.3.0) |
@@ -155,24 +156,25 | |||||
|
155 | execjs (>= 0.3.0) |
|
156 | execjs (>= 0.3.0) |
|
156 | json (>= 1.8.0) |
|
157 | json (>= 1.8.0) |
|
157 | will_paginate (3.0.7) |
|
158 | will_paginate (3.0.7) |
|
158 |
|
159 | ||
|
159 | PLATFORMS |
|
160 | PLATFORMS |
|
160 | ruby |
|
161 | ruby |
|
161 |
|
162 | ||
|
162 | DEPENDENCIES |
|
163 | DEPENDENCIES |
|
163 | autoprefixer-rails |
|
164 | autoprefixer-rails |
|
164 | best_in_place (~> 3.0.1) |
|
165 | best_in_place (~> 3.0.1) |
|
165 | bootstrap-sass (~> 3.2.0) |
|
166 | bootstrap-sass (~> 3.2.0) |
|
166 | bootstrap-switch-rails |
|
167 | bootstrap-switch-rails |
|
|
168 | + bootstrap-toggle-rails | ||
|
167 | coffee-rails (~> 3.2.2) |
|
169 | coffee-rails (~> 3.2.2) |
|
168 | dynamic_form |
|
170 | dynamic_form |
|
169 | haml |
|
171 | haml |
|
170 | in_place_editing |
|
172 | in_place_editing |
|
171 | jquery-rails |
|
173 | jquery-rails |
|
172 | jquery-tablesorter |
|
174 | jquery-tablesorter |
|
173 | jquery-timepicker-addon-rails |
|
175 | jquery-timepicker-addon-rails |
|
174 | jquery-ui-sass-rails |
|
176 | jquery-ui-sass-rails |
|
175 |
|
177 | ||
|
176 | mysql2 |
|
178 | mysql2 |
|
177 | prototype-rails |
|
179 | prototype-rails |
|
178 | rails (= 3.2.21) |
|
180 | rails (= 3.2.21) |
@@ -5,23 +5,24 | |||||
|
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. |
|
5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. |
|
6 | // |
|
6 | // |
|
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the |
|
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the |
|
8 | // the compiled file. |
|
8 | // the compiled file. |
|
9 | // |
|
9 | // |
|
10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD |
|
10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD |
|
11 | // GO AFTER THE REQUIRES BELOW. |
|
11 | // GO AFTER THE REQUIRES BELOW. |
|
12 | // |
|
12 | // |
|
13 | //= require jquery |
|
13 | //= require jquery |
|
14 | //= require jquery_ujs |
|
14 | //= require jquery_ujs |
|
15 | //= require jquery.ui.all |
|
15 | //= require jquery.ui.all |
|
16 | //= require bootstrap-sprockets |
|
16 | //= require bootstrap-sprockets |
|
17 | - //= require bootstrap-switch |
|
17 | + //x= require bootstrap-switch |
|
|
18 | + //= require bootstrap-toggle | ||
|
18 | //= require select2 |
|
19 | //= require select2 |
|
19 | //= require custom |
|
20 | //= require custom |
|
20 |
|
21 | ||
|
21 |
|
22 | ||
|
22 | // since this is after blank line, it is not downloaded |
|
23 | // since this is after blank line, it is not downloaded |
|
23 | //x= require prototype |
|
24 | //x= require prototype |
|
24 | //x= require prototype_ujs |
|
25 | //x= require prototype_ujs |
|
25 | //x= require effects |
|
26 | //x= require effects |
|
26 | //x= require dragdrop |
|
27 | //x= require dragdrop |
|
27 | //x= require controls |
|
28 | //x= require controls |
@@ -4,23 +4,24 | |||||
|
4 | label = input.val().replace(/\\/g, '/').replace(/.*\//, '') |
|
4 | label = input.val().replace(/\\/g, '/').replace(/.*\//, '') |
|
5 | input.trigger 'fileselect', [ |
|
5 | input.trigger 'fileselect', [ |
|
6 | numFiles |
|
6 | numFiles |
|
7 | label |
|
7 | label |
|
8 | ] |
|
8 | ] |
|
9 | return |
|
9 | return |
|
10 |
|
10 | ||
|
11 |
|
11 | ||
|
12 | # document ready |
|
12 | # document ready |
|
13 |
|
13 | ||
|
14 | $ -> |
|
14 | $ -> |
|
15 | $(".select2").select2() |
|
15 | $(".select2").select2() |
|
16 | - $(".bootstrap-switch").bootstrapSwitch() |
|
16 | + #$(".bootstrap-switch").bootstrapSwitch() |
|
|
17 | + $(".bootstrap-toggle").bootstrapToggle() | ||
|
17 | $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> |
|
18 | $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> |
|
18 | input = $(this).parents('.input-group').find(':text') |
|
19 | input = $(this).parents('.input-group').find(':text') |
|
19 | log = if numFiles > 1 then numFiles + ' files selected' else label |
|
20 | log = if numFiles > 1 then numFiles + ' files selected' else label |
|
20 | if input.length |
|
21 | if input.length |
|
21 | input.val log |
|
22 | input.val log |
|
22 | else |
|
23 | else |
|
23 | if log |
|
24 | if log |
|
24 | alert log |
|
25 | alert log |
|
25 | return |
|
26 | return |
|
26 | return |
|
27 | return |
@@ -21,25 +21,26 | |||||
|
21 | @import jquery.ui.theme |
|
21 | @import jquery.ui.theme |
|
22 | @import jquery.ui.datepicker |
|
22 | @import jquery.ui.datepicker |
|
23 | @import jquery.ui.slider |
|
23 | @import jquery.ui.slider |
|
24 | @import jquery-ui-timepicker-addon |
|
24 | @import jquery-ui-timepicker-addon |
|
25 | @import jquery-tablesorter/theme.metro-dark |
|
25 | @import jquery-tablesorter/theme.metro-dark |
|
26 | @import tablesorter-theme.cafe |
|
26 | @import tablesorter-theme.cafe |
|
27 |
|
27 | ||
|
28 | //bootstrap |
|
28 | //bootstrap |
|
29 | @import bootstrap-sprockets |
|
29 | @import bootstrap-sprockets |
|
30 | @import bootstrap |
|
30 | @import bootstrap |
|
31 | @import select2 |
|
31 | @import select2 |
|
32 | @import select2-bootstrap |
|
32 | @import select2-bootstrap |
|
33 | - @import bootstrap3-switch |
|
33 | + //@import bootstrap3-switch |
|
|
34 | + @import bootstrap-toggle | ||
|
34 |
|
35 | ||
|
35 | .secondnavbar |
|
36 | .secondnavbar |
|
36 | top: 50px |
|
37 | top: 50px |
|
37 |
|
38 | ||
|
38 | .btn-file |
|
39 | .btn-file |
|
39 | position: relative |
|
40 | position: relative |
|
40 | overflow: hidden |
|
41 | overflow: hidden |
|
41 |
|
42 | ||
|
42 | .btn-file input[type=file] |
|
43 | .btn-file input[type=file] |
|
43 | position: absolute |
|
44 | position: absolute |
|
44 | top: 0 |
|
45 | top: 0 |
|
45 | right: 0 |
|
46 | right: 0 |
@@ -60,32 +60,42 | |||||
|
60 | end |
|
60 | end |
|
61 | end |
|
61 | end |
|
62 |
|
62 | ||
|
63 | # PUT /announcements/1 |
|
63 | # PUT /announcements/1 |
|
64 | # PUT /announcements/1.xml |
|
64 | # PUT /announcements/1.xml |
|
65 | def update |
|
65 | def update |
|
66 | @announcement = Announcement.find(params[:id]) |
|
66 | @announcement = Announcement.find(params[:id]) |
|
67 |
|
67 | ||
|
68 | respond_to do |format| |
|
68 | respond_to do |format| |
|
69 | if @announcement.update_attributes(params[:announcement]) |
|
69 | if @announcement.update_attributes(params[:announcement]) |
|
70 | flash[:notice] = 'Announcement was successfully updated.' |
|
70 | flash[:notice] = 'Announcement was successfully updated.' |
|
71 | format.html { redirect_to(@announcement) } |
|
71 | format.html { redirect_to(@announcement) } |
|
|
72 | + format.js {} | ||
|
72 | format.xml { head :ok } |
|
73 | format.xml { head :ok } |
|
73 | else |
|
74 | else |
|
74 | format.html { render :action => "edit" } |
|
75 | format.html { render :action => "edit" } |
|
|
76 | + format.js {} | ||
|
75 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
77 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
76 | end |
|
78 | end |
|
77 | end |
|
79 | end |
|
78 | end |
|
80 | end |
|
79 |
|
81 | ||
|
|
82 | + def toggle | ||
|
|
83 | + @announcement = Announcement.find(params[:id]) | ||
|
|
84 | + @announcement.update_attributes( published: params[:published] == 1) | ||
|
|
85 | + respond_to do |format| | ||
|
|
86 | + format.js {} | ||
|
|
87 | + end | ||
|
|
88 | + end | ||
|
|
89 | + | ||
|
80 | # DELETE /announcements/1 |
|
90 | # DELETE /announcements/1 |
|
81 | # DELETE /announcements/1.xml |
|
91 | # DELETE /announcements/1.xml |
|
82 | def destroy |
|
92 | def destroy |
|
83 | @announcement = Announcement.find(params[:id]) |
|
93 | @announcement = Announcement.find(params[:id]) |
|
84 | @announcement.destroy |
|
94 | @announcement.destroy |
|
85 |
|
95 | ||
|
86 | respond_to do |format| |
|
96 | respond_to do |format| |
|
87 | format.html { redirect_to(announcements_url) } |
|
97 | format.html { redirect_to(announcements_url) } |
|
88 | format.xml { head :ok } |
|
98 | format.xml { head :ok } |
|
89 | end |
|
99 | end |
|
90 | end |
|
100 | end |
|
91 | end |
|
101 | end |
@@ -1,22 +1,23 | |||||
|
1 | class ApplicationController < ActionController::Base |
|
1 | class ApplicationController < ActionController::Base |
|
2 | protect_from_forgery |
|
2 | protect_from_forgery |
|
3 |
|
3 | ||
|
4 | before_filter :current_user |
|
4 | before_filter :current_user |
|
5 |
|
5 | ||
|
6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
|
7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
|
8 |
|
8 | ||
|
9 | # Returns the current logged-in user (if any). |
|
9 | # Returns the current logged-in user (if any). |
|
10 | def current_user |
|
10 | def current_user |
|
|
11 | + return nil unless session[:user_id] | ||
|
11 | @current_user ||= User.find(session[:user_id]) |
|
12 | @current_user ||= User.find(session[:user_id]) |
|
12 | end |
|
13 | end |
|
13 |
|
14 | ||
|
14 | def admin_authorization |
|
15 | def admin_authorization |
|
15 | return false unless authenticate |
|
16 | return false unless authenticate |
|
16 | user = User.find(session[:user_id], :include => ['roles']) |
|
17 | user = User.find(session[:user_id], :include => ['roles']) |
|
17 | unless user.admin? |
|
18 | unless user.admin? |
|
18 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
19 | flash[:notice] = 'You are not authorized to view the page you requested' |
|
19 | redirect_to :controller => 'main', :action => 'login' unless user.admin? |
|
20 | redirect_to :controller => 'main', :action => 'login' unless user.admin? |
|
20 | return false |
|
21 | return false |
|
21 | end |
|
22 | end |
|
22 | return true |
|
23 | return true |
@@ -18,24 +18,24 | |||||
|
18 | <% @announcement = announcement %> |
|
18 | <% @announcement = announcement %> |
|
19 | <td><%= time_ago_in_words announcement.updated_at %></td> |
|
19 | <td><%= time_ago_in_words announcement.updated_at %></td> |
|
20 | <td> |
|
20 | <td> |
|
21 | <% if !announcement.title.blank? %> |
|
21 | <% if !announcement.title.blank? %> |
|
22 | <b>Title:</b> <%=h announcement.title %><br/> |
|
22 | <b>Title:</b> <%=h announcement.title %><br/> |
|
23 | <% end %> |
|
23 | <% end %> |
|
24 | <% if !announcement.notes.blank? %> |
|
24 | <% if !announcement.notes.blank? %> |
|
25 | <b>Notes: <%=h announcement.notes %></b><br/> |
|
25 | <b>Notes: <%=h announcement.notes %></b><br/> |
|
26 | <% end %> |
|
26 | <% end %> |
|
27 | <%=h announcement.body %> |
|
27 | <%=h announcement.body %> |
|
28 | </td> |
|
28 | </td> |
|
29 | <td><%=h announcement.author %></td> |
|
29 | <td><%=h announcement.author %></td> |
|
30 | - <td><%= check_box_tag :published, 1, announcement.published, class: 'bootstrap-switch', data: {size: 'small'} %></td> |
|
30 | + <td><%= check_box_tag :published, 1, announcement.published, { class: 'bootstrap-toggle', id: "published-#{announcement.id}", data: {remote: true, method: 'PUT', url: url_for(controller: :announcements, action: :toggle, id: announcement), size: 'small', toggle: 'toggle' } } %></td> |
|
31 | <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> --> |
|
31 | <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> --> |
|
32 | <td><%= link_to 'Show', announcement %></td> |
|
32 | <td><%= link_to 'Show', announcement %></td> |
|
33 | <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td> |
|
33 | <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td> |
|
34 | <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td> |
|
34 | <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td> |
|
35 | </tr> |
|
35 | </tr> |
|
36 | <% end %> |
|
36 | <% end %> |
|
37 | </table> |
|
37 | </table> |
|
38 |
|
38 | ||
|
39 | <br /> |
|
39 | <br /> |
|
40 |
|
40 | ||
|
41 | <%= link_to 'New announcement', new_announcement_path %> |
|
41 | <%= link_to 'New announcement', new_announcement_path %> |
@@ -1,20 +1,22 | |||||
|
1 | CafeGrader::Application.routes.draw do |
|
1 | CafeGrader::Application.routes.draw do |
|
2 | root :to => 'main#login' |
|
2 | root :to => 'main#login' |
|
3 |
|
3 | ||
|
4 | get "report/login" |
|
4 | get "report/login" |
|
5 |
|
5 | ||
|
6 | resources :contests |
|
6 | resources :contests |
|
7 |
|
7 | ||
|
8 | resources :announcements |
|
8 | resources :announcements |
|
|
9 | + match 'announcements/toggle/:id' => 'announcements#toggle', via: :put | ||
|
|
10 | + | ||
|
9 | resources :sites |
|
11 | resources :sites |
|
10 |
|
12 | ||
|
11 | resources :grader_configuration, controller: 'configurations' |
|
13 | resources :grader_configuration, controller: 'configurations' |
|
12 |
|
14 | ||
|
13 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
15 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
14 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
16 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
15 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
17 | match 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
16 |
|
18 | ||
|
17 | #main |
|
19 | #main |
|
18 | get "main/list" |
|
20 | get "main/list" |
|
19 |
|
21 | ||
|
20 | # See how all your routes lay out with "rake routes" |
|
22 | # See how all your routes lay out with "rake routes" |
You need to be logged in to leave comments.
Login now