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
@@ -51,12 +51,13 | |||
|
51 | 51 | #syntax highlighter |
|
52 | 52 | gem 'rouge' |
|
53 | 53 | |
|
54 | 54 | #add bootstrap |
|
55 | 55 | gem 'bootstrap-sass', '~> 3.2.0' |
|
56 | 56 | gem 'bootstrap-switch-rails' |
|
57 | + gem 'bootstrap-toggle-rails' | |
|
57 | 58 | gem 'autoprefixer-rails' |
|
58 | 59 | |
|
59 | 60 | |
|
60 | 61 | gem 'haml' |
|
61 | 62 | gem 'mail' |
|
62 | 63 | gem 'rdiscount' |
@@ -43,12 +43,13 | |||
|
43 | 43 | best_in_place (3.0.3) |
|
44 | 44 | actionpack (>= 3.2) |
|
45 | 45 | railties (>= 3.2) |
|
46 | 46 | bootstrap-sass (3.2.0.2) |
|
47 | 47 | sass (~> 3.2) |
|
48 | 48 | bootstrap-switch-rails (3.3.3) |
|
49 | + bootstrap-toggle-rails (2.2.1.0) | |
|
49 | 50 | builder (3.0.4) |
|
50 | 51 | coffee-rails (3.2.2) |
|
51 | 52 | coffee-script (>= 2.2.0) |
|
52 | 53 | railties (~> 3.2.0) |
|
53 | 54 | coffee-script (2.3.0) |
|
54 | 55 | coffee-script-source |
@@ -161,12 +162,13 | |||
|
161 | 162 | |
|
162 | 163 | DEPENDENCIES |
|
163 | 164 | autoprefixer-rails |
|
164 | 165 | best_in_place (~> 3.0.1) |
|
165 | 166 | bootstrap-sass (~> 3.2.0) |
|
166 | 167 | bootstrap-switch-rails |
|
168 | + bootstrap-toggle-rails | |
|
167 | 169 | coffee-rails (~> 3.2.2) |
|
168 | 170 | dynamic_form |
|
169 | 171 | haml |
|
170 | 172 | in_place_editing |
|
171 | 173 | jquery-rails |
|
172 | 174 | jquery-tablesorter |
@@ -11,13 +11,14 | |||
|
11 | 11 | // GO AFTER THE REQUIRES BELOW. |
|
12 | 12 | // |
|
13 | 13 | //= require jquery |
|
14 | 14 | //= require jquery_ujs |
|
15 | 15 | //= require jquery.ui.all |
|
16 | 16 | //= require bootstrap-sprockets |
|
17 | - //= require bootstrap-switch | |
|
17 | + //x= require bootstrap-switch | |
|
18 | + //= require bootstrap-toggle | |
|
18 | 19 | //= require select2 |
|
19 | 20 | //= require custom |
|
20 | 21 | |
|
21 | 22 | |
|
22 | 23 | // since this is after blank line, it is not downloaded |
|
23 | 24 | //x= require prototype |
@@ -10,13 +10,14 | |||
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | # document ready |
|
13 | 13 | |
|
14 | 14 | $ -> |
|
15 | 15 | $(".select2").select2() |
|
16 | - $(".bootstrap-switch").bootstrapSwitch() | |
|
16 | + #$(".bootstrap-switch").bootstrapSwitch() | |
|
17 | + $(".bootstrap-toggle").bootstrapToggle() | |
|
17 | 18 | $('.btn-file :file').on 'fileselect', (event, numFiles, label) -> |
|
18 | 19 | input = $(this).parents('.input-group').find(':text') |
|
19 | 20 | log = if numFiles > 1 then numFiles + ' files selected' else label |
|
20 | 21 | if input.length |
|
21 | 22 | input.val log |
|
22 | 23 | else |
@@ -27,13 +27,14 | |||
|
27 | 27 | |
|
28 | 28 | //bootstrap |
|
29 | 29 | @import bootstrap-sprockets |
|
30 | 30 | @import bootstrap |
|
31 | 31 | @import select2 |
|
32 | 32 | @import select2-bootstrap |
|
33 | - @import bootstrap3-switch | |
|
33 | + //@import bootstrap3-switch | |
|
34 | + @import bootstrap-toggle | |
|
34 | 35 | |
|
35 | 36 | .secondnavbar |
|
36 | 37 | top: 50px |
|
37 | 38 | |
|
38 | 39 | .btn-file |
|
39 | 40 | position: relative |
@@ -66,20 +66,30 | |||
|
66 | 66 | @announcement = Announcement.find(params[:id]) |
|
67 | 67 | |
|
68 | 68 | respond_to do |format| |
|
69 | 69 | if @announcement.update_attributes(params[:announcement]) |
|
70 | 70 | flash[:notice] = 'Announcement was successfully updated.' |
|
71 | 71 | format.html { redirect_to(@announcement) } |
|
72 | + format.js {} | |
|
72 | 73 | format.xml { head :ok } |
|
73 | 74 | else |
|
74 | 75 | format.html { render :action => "edit" } |
|
76 | + format.js {} | |
|
75 | 77 | format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } |
|
76 | 78 | end |
|
77 | 79 | end |
|
78 | 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 | 90 | # DELETE /announcements/1 |
|
81 | 91 | # DELETE /announcements/1.xml |
|
82 | 92 | def destroy |
|
83 | 93 | @announcement = Announcement.find(params[:id]) |
|
84 | 94 | @announcement.destroy |
|
85 | 95 |
@@ -5,12 +5,13 | |||
|
5 | 5 | |
|
6 | 6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
7 | 7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
|
8 | 8 | |
|
9 | 9 | # Returns the current logged-in user (if any). |
|
10 | 10 | def current_user |
|
11 | + return nil unless session[:user_id] | |
|
11 | 12 | @current_user ||= User.find(session[:user_id]) |
|
12 | 13 | end |
|
13 | 14 | |
|
14 | 15 | def admin_authorization |
|
15 | 16 | return false unless authenticate |
|
16 | 17 | user = User.find(session[:user_id], :include => ['roles']) |
@@ -24,13 +24,13 | |||
|
24 | 24 | <% if !announcement.notes.blank? %> |
|
25 | 25 | <b>Notes: <%=h announcement.notes %></b><br/> |
|
26 | 26 | <% end %> |
|
27 | 27 | <%=h announcement.body %> |
|
28 | 28 | </td> |
|
29 | 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 | 31 | <!-- <td><%= in_place_editor_field :announcement, :published, {}, :rows => 1 %></td> --> |
|
32 | 32 | <td><%= link_to 'Show', announcement %></td> |
|
33 | 33 | <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td> |
|
34 | 34 | <td><%= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete %></td> |
|
35 | 35 | </tr> |
|
36 | 36 | <% end %> |
@@ -3,12 +3,14 | |||
|
3 | 3 | |
|
4 | 4 | get "report/login" |
|
5 | 5 | |
|
6 | 6 | resources :contests |
|
7 | 7 | |
|
8 | 8 | resources :announcements |
|
9 | + match 'announcements/toggle/:id' => 'announcements#toggle', via: :put | |
|
10 | + | |
|
9 | 11 | resources :sites |
|
10 | 12 | |
|
11 | 13 | resources :grader_configuration, controller: 'configurations' |
|
12 | 14 | |
|
13 | 15 | match 'tasks/view/:file.:ext' => 'tasks#view' |
|
14 | 16 | match 'tasks/download/:id/:file.:ext' => 'tasks#download' |
You need to be logged in to leave comments.
Login now