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
@@ -62,101 +62,102 | |||
|
62 | 62 | append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission' |
|
63 | 63 | append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index' |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | if GraderConfiguration['right.user_hall_of_fame'] |
|
67 | 67 | append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof' |
|
68 | 68 | end |
|
69 | 69 | append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help' |
|
70 | 70 | |
|
71 | 71 | if GraderConfiguration['system.user_setting_enabled'] |
|
72 | 72 | append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index' |
|
73 | 73 | end |
|
74 | 74 | append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login' |
|
75 | 75 | |
|
76 | 76 | menu_items.html_safe |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | 79 | def append_to(option,label, controller, action) |
|
80 | 80 | option << ' ' if option!='' |
|
81 | 81 | option << link_to_unless_current(label, |
|
82 | 82 | :controller => controller, |
|
83 | 83 | :action => action) |
|
84 | 84 | end |
|
85 | 85 | |
|
86 | 86 | def format_short_time(time) |
|
87 | 87 | now = Time.now.gmtime |
|
88 | 88 | st = '' |
|
89 | 89 | if (time.yday != now.yday) or |
|
90 | 90 | (time.year != now.year) |
|
91 | 91 | st = time.strftime("%x ") |
|
92 | 92 | end |
|
93 | 93 | st + time.strftime("%X") |
|
94 | 94 | end |
|
95 | 95 | |
|
96 | 96 | def format_short_duration(duration) |
|
97 | 97 | return '' if duration==nil |
|
98 | 98 | d = duration.to_f |
|
99 | 99 | return Time.at(d).gmtime.strftime("%X") |
|
100 | 100 | end |
|
101 | 101 | |
|
102 | 102 | def read_textfile(fname,max_size=2048) |
|
103 | 103 | begin |
|
104 | 104 | File.open(fname).read(max_size) |
|
105 | 105 | rescue |
|
106 | 106 | nil |
|
107 | 107 | end |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | - def toggle_button(on,toggle_url,id) | |
|
111 | - link_to (on ? "Yes" : "No"), toggle_url, | |
|
112 | - {class: "btn btn-block btn-xs btn-#{on ? 'success' : 'default'} ajax-toggle", | |
|
113 | - id: id, | |
|
114 | - data: {remote: true, method: 'get'}} | |
|
110 | + def toggle_button(on,toggle_url,id, option={}) | |
|
111 | + btn_size = option[:size] || 'btn-xs' | |
|
112 | + link_to (on ? "Yes" : "No"), toggle_url, | |
|
113 | + {class: "btn btn-block #{btn_size} btn-#{on ? 'success' : 'default'} ajax-toggle", | |
|
114 | + id: id, | |
|
115 | + data: {remote: true, method: 'get'}} | |
|
115 | 116 | end |
|
116 | 117 | |
|
117 | 118 | def user_title_bar(user) |
|
118 | 119 | header = '' |
|
119 | 120 | time_left = '' |
|
120 | 121 | |
|
121 | 122 | # |
|
122 | 123 | # if the contest is over |
|
123 | 124 | if GraderConfiguration.time_limit_mode? |
|
124 | 125 | if user.contest_finished? |
|
125 | 126 | header = <<CONTEST_OVER |
|
126 | 127 | <tr><td colspan="2" align="center"> |
|
127 | 128 | <span class="contest-over-msg">THE CONTEST IS OVER</span> |
|
128 | 129 | </td></tr> |
|
129 | 130 | CONTEST_OVER |
|
130 | 131 | end |
|
131 | 132 | if !user.contest_started? |
|
132 | 133 | time_left = " " + (t 'title_bar.contest_not_started') |
|
133 | 134 | else |
|
134 | 135 | time_left = " " + (t 'title_bar.remaining_time') + |
|
135 | 136 | " #{format_short_duration(user.contest_time_left)}" |
|
136 | 137 | end |
|
137 | 138 | end |
|
138 | 139 | |
|
139 | 140 | # |
|
140 | 141 | # if the contest is in the anaysis mode |
|
141 | 142 | if GraderConfiguration.analysis_mode? |
|
142 | 143 | header = <<ANALYSISMODE |
|
143 | 144 | <tr><td colspan="2" align="center"> |
|
144 | 145 | <span class="contest-over-msg">ANALYSIS MODE</span> |
|
145 | 146 | </td></tr> |
|
146 | 147 | ANALYSISMODE |
|
147 | 148 | end |
|
148 | 149 | |
|
149 | 150 | contest_name = GraderConfiguration['contest.name'] |
|
150 | 151 | |
|
151 | 152 | # |
|
152 | 153 | # build real title bar |
|
153 | 154 | result = <<TITLEBAR |
|
154 | 155 | <div class="title"> |
|
155 | 156 | <table> |
|
156 | 157 | #{header} |
|
157 | 158 | <tr> |
|
158 | 159 | <td class="left-col"> |
|
159 | 160 | #{user.full_name}<br/> |
|
160 | 161 | #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)} |
|
161 | 162 | #{time_left} |
|
162 | 163 | <br/> |
@@ -1,36 +1,36 | |||
|
1 | 1 | %h1 Listing announcements |
|
2 | 2 | |
|
3 | 3 | = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' |
|
4 | 4 | %br |
|
5 | 5 | %br |
|
6 | 6 | |
|
7 | 7 | %table.table.table-striped |
|
8 | 8 | %tr |
|
9 | 9 | %th Updated |
|
10 | 10 | %th Announcement |
|
11 | 11 | %th Author |
|
12 | 12 | %th Published |
|
13 | 13 | %th |
|
14 | 14 | %th |
|
15 | 15 | - for announcement in @announcements |
|
16 | 16 | %tr |
|
17 | 17 | - @announcement = announcement |
|
18 | 18 | %td= time_ago_in_words announcement.updated_at |
|
19 | 19 | %td |
|
20 | 20 | - if !announcement.title.blank? |
|
21 | 21 | %b Title: |
|
22 | 22 | = h announcement.title |
|
23 | 23 | %br/ |
|
24 | 24 | - if !announcement.notes.blank? |
|
25 | 25 | %b |
|
26 | 26 | Notes: #{h announcement.notes} |
|
27 | 27 | %br/ |
|
28 | 28 | = h announcement.body |
|
29 | 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 | 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 | 32 | %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info' |
|
33 | 33 | %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger" |
|
34 | 34 | %br |
|
35 | 35 | |
|
36 | 36 | = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success' |
You need to be logged in to leave comments.
Login now