-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
132 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
;(function() { | ||
// Check for changes before navigating away if there are unsubmitted changes. | ||
// TODO: This script won't recognize text that has been changed twice | ||
// resulting in no net effect to the input. | ||
|
||
var changes = false; | ||
|
||
$(document).ready(function() { | ||
$('input').on('change', function(e) { | ||
changes = true; | ||
}); | ||
$('textarea').on('change', function(e) { | ||
changes = true; | ||
}); | ||
|
||
window.onbeforeunload = function() { | ||
if (changes) { | ||
return 'It looks like you might have unsubmitted changes. Are you sure you want to continue?'; | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
|
||
$('form').on('submit', function() { | ||
changes = false; | ||
}); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
<table class="verticalTable"> | ||
<tr> | ||
<th>Title:</th> | ||
<td><%= f.text_field :title %></td> | ||
</tr> | ||
<tr> | ||
<th>Description:</th> | ||
<td><%= f.text_area :description %></td> | ||
</tr> | ||
<tr> | ||
<th>Start Date:</th> | ||
<td><%= f.datetime_select :start_date, step: 1 %></td> | ||
</tr> | ||
<tr> | ||
<th>End Date:</th> | ||
<td><%= f.datetime_select :end_date, step: 1 %></td> | ||
</tr> | ||
<tr> | ||
<th>Persistent Announcement?</th> | ||
<td><%= f.check_box (:persistent) %></td> | ||
</tr> | ||
<% if @cud.administrator? then %> | ||
<tr> | ||
<th>System Announcement?</th> | ||
<td><%= f.check_box (:system) %></td> | ||
</tr> | ||
<% end %> | ||
<tr> | ||
<td colspan=2><%= f.submit 'Submit' , {:class=>"btn primary"} %></td> | ||
</tr> | ||
</table> | ||
<% content_for :javascripts do %> | ||
<%= javascript_include_tag "initialize_datetimepickers" %> | ||
<%= javascript_include_tag "confirm_discard_changes" %> | ||
<% end %> | ||
|
||
<%= f.text_field :title, | ||
help_text: "The best titles are short and sweet." %> | ||
|
||
<%= f.text_area :description, | ||
help_text: "There'll also be limited space for the description text. If you need something long-form, perhaps link to a longer announcement posted on external media." %> | ||
|
||
<%= f.datetime_select :start_date, | ||
help_text: "When should the announcement appear?", | ||
less_than: "announcement_end_date" %> | ||
|
||
<%= f.datetime_select :end_date, | ||
help_text: "When should the announcement come down?", | ||
greater_than: "announcement_start_date" %> | ||
|
||
<!-- TODO: custom title 'Persistent Announcement?' --> | ||
<%= f.check_box :persistent, | ||
help_text: "A persistent announcement is shown on every page in the course." %> | ||
|
||
<% if @cud.administrator? then %> | ||
<%= f.check_box :system, | ||
help_text: "Check this to make a system-wide announcement." %> | ||
<% end %> | ||
|
||
<%= f.submit 'Submit' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<h2>Edit Announcement</h2> | ||
<%= form_for :announcement, url: course_announcement_path(@course, @announcement), method: :patch do |f| %> | ||
<%= render partial:'announcementFields', locals:{f:f} %> | ||
<% end %> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<%= form_for @announcement, url: course_announcement_path(@course, @announcement), method: :patch, builder: FormBuilderWithDateTimeInput do |f| %> | ||
<%= render partial: 'announcementFields', locals: {f:f} %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<h2>Create Announcement</h2> | ||
<%= form_for :announcement, url:{action:"create"} do |f| %> | ||
<%= render partial:'announcementFields', locals:{f:f} %> | ||
<% end %> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<%= form_for @announcement, url:{action:"create"}, builder: FormBuilderWithDateTimeInput do |f| %> | ||
<%= render partial: 'announcementFields', locals: {f:f} %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters