Description:
* add button size option to toggle_button helper
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r563:589243c81dda - - 2 files changed: 7 inserted, 6 deleted
@@ -86,53 +86,54 | |||||
|
86 | def format_short_time(time) |
|
86 | def format_short_time(time) |
|
87 | now = Time.now.gmtime |
|
87 | now = Time.now.gmtime |
|
88 | st = '' |
|
88 | st = '' |
|
89 | if (time.yday != now.yday) or |
|
89 | if (time.yday != now.yday) or |
|
90 | (time.year != now.year) |
|
90 | (time.year != now.year) |
|
91 | st = time.strftime("%x ") |
|
91 | st = time.strftime("%x ") |
|
92 | end |
|
92 | end |
|
93 | st + time.strftime("%X") |
|
93 | st + time.strftime("%X") |
|
94 | end |
|
94 | end |
|
95 |
|
95 | ||
|
96 | def format_short_duration(duration) |
|
96 | def format_short_duration(duration) |
|
97 | return '' if duration==nil |
|
97 | return '' if duration==nil |
|
98 | d = duration.to_f |
|
98 | d = duration.to_f |
|
99 | return Time.at(d).gmtime.strftime("%X") |
|
99 | return Time.at(d).gmtime.strftime("%X") |
|
100 | end |
|
100 | end |
|
101 |
|
101 | ||
|
102 | def read_textfile(fname,max_size=2048) |
|
102 | def read_textfile(fname,max_size=2048) |
|
103 | begin |
|
103 | begin |
|
104 | File.open(fname).read(max_size) |
|
104 | File.open(fname).read(max_size) |
|
105 | rescue |
|
105 | rescue |
|
106 | nil |
|
106 | nil |
|
107 | end |
|
107 | end |
|
108 | end |
|
108 | end |
|
109 |
|
109 | ||
|
110 | - def toggle_button(on,toggle_url,id) |
|
110 | + def toggle_button(on,toggle_url,id, option={}) |
|
111 | - link_to (on ? "Yes" : "No"), toggle_url, |
|
111 | + btn_size = option[:size] || 'btn-xs' |
|
112 | - {class: "btn btn-block btn-xs btn-#{on ? 'success' : 'default'} ajax-toggle", |
|
112 | + link_to (on ? "Yes" : "No"), toggle_url, |
|
113 | - id: id, |
|
113 | + {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle", |
|
114 | - data: {remote: true, method: 'get'}} |
|
114 | + id: id, |
|
|
115 | + data: {remote: true, method: 'get'}} | ||
|
115 | end |
|
116 | end |
|
116 |
|
117 | ||
|
117 | def user_title_bar(user) |
|
118 | def user_title_bar(user) |
|
118 | header = '' |
|
119 | header = '' |
|
119 | time_left = '' |
|
120 | time_left = '' |
|
120 |
|
121 | ||
|
121 | # |
|
122 | # |
|
122 | # if the contest is over |
|
123 | # if the contest is over |
|
123 | if GraderConfiguration.time_limit_mode? |
|
124 | if GraderConfiguration.time_limit_mode? |
|
124 | if user.contest_finished? |
|
125 | if user.contest_finished? |
|
125 | header = <<CONTEST_OVER |
|
126 | header = <<CONTEST_OVER |
|
126 | <tr><td colspan="2" align="center"> |
|
127 | <tr><td colspan="2" align="center"> |
|
127 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
128 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
128 | </td></tr> |
|
129 | </td></tr> |
|
129 | CONTEST_OVER |
|
130 | CONTEST_OVER |
|
130 | end |
|
131 | end |
|
131 | if !user.contest_started? |
|
132 | if !user.contest_started? |
|
132 | time_left = " " + (t 'title_bar.contest_not_started') |
|
133 | time_left = " " + (t 'title_bar.contest_not_started') |
|
133 | else |
|
134 | else |
|
134 | time_left = " " + (t 'title_bar.remaining_time') + |
|
135 | time_left = " " + (t 'title_bar.remaining_time') + |
|
135 | " #{format_short_duration(user.contest_time_left)}" |
|
136 | " #{format_short_duration(user.contest_time_left)}" |
|
136 | end |
|
137 | end |
|
137 | end |
|
138 | end |
|
138 |
|
139 |
@@ -6,31 +6,31 | |||||
|
6 |
|
6 | ||
|
7 | %table.table.table-striped |
|
7 | %table.table.table-striped |
|
8 | %tr |
|
8 | %tr |
|
9 | %th Updated |
|
9 | %th Updated |
|
10 | %th Announcement |
|
10 | %th Announcement |
|
11 | %th Author |
|
11 | %th Author |
|
12 | %th Published |
|
12 | %th Published |
|
13 | %th |
|
13 | %th |
|
14 | %th |
|
14 | %th |
|
15 | - for announcement in @announcements |
|
15 | - for announcement in @announcements |
|
16 | %tr |
|
16 | %tr |
|
17 | - @announcement = announcement |
|
17 | - @announcement = announcement |
|
18 | %td= time_ago_in_words announcement.updated_at |
|
18 | %td= time_ago_in_words announcement.updated_at |
|
19 | %td |
|
19 | %td |
|
20 | - if !announcement.title.blank? |
|
20 | - if !announcement.title.blank? |
|
21 | %b Title: |
|
21 | %b Title: |
|
22 | = h announcement.title |
|
22 | = h announcement.title |
|
23 | %br/ |
|
23 | %br/ |
|
24 | - if !announcement.notes.blank? |
|
24 | - if !announcement.notes.blank? |
|
25 | %b |
|
25 | %b |
|
26 | Notes: #{h announcement.notes} |
|
26 | Notes: #{h announcement.notes} |
|
27 | %br/ |
|
27 | %br/ |
|
28 | = h announcement.body |
|
28 | = h announcement.body |
|
29 | %td= h announcement.author |
|
29 | %td= h announcement.author |
|
30 | - %td= toggle_button(announcement.published?, toggle_announcement_url(@announcement), "announcement_toggle_#{@announcement.id}") |
|
30 | + %td= toggle_button(announcement.published?, toggle_announcement_url(@announcement), "announcement_toggle_#{@announcement.id}", {size: 'btn-sm'}) |
|
31 | //%td= link_to (announcement.published? ? "Yes" : "No"), url_for(controller: :announcements, action: :toggle, id: announcement), { class: "btn btn-block btn-sm btn-#{(announcement.published? ? 'success' : 'default')} ajax-toggle", id: "published-#{announcement.id}", data: {remote: true, method: 'post' } } |
|
31 | //%td= link_to (announcement.published? ? "Yes" : "No"), url_for(controller: :announcements, action: :toggle, id: announcement), { class: "btn btn-block btn-sm btn-#{(announcement.published? ? 'success' : 'default')} ajax-toggle", id: "published-#{announcement.id}", data: {remote: true, method: 'post' } } |
|
32 | %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info' |
|
32 | %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info' |
|
33 | %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger" |
|
33 | %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger" |
|
34 | %br |
|
34 | %br |
|
35 |
|
35 | ||
|
36 | = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' |
|
36 | = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' |
You need to be logged in to leave comments.
Login now