Skip to content

Instantly share code, notes, and snippets.

@ghigt
Last active December 20, 2015 23:28
Show Gist options
  • Save ghigt/6212222 to your computer and use it in GitHub Desktop.
Save ghigt/6212222 to your computer and use it in GitHub Desktop.
Post Blog Markus [do not touch!]
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {
users_table = new FilterTable({
[...]
});
});
new Ajax.Request('<%=populate_students_path()%>',
{asynchronous:true, evalScripts:true,
onComplete:function(request){$('loading_list').hide();},
parameters: 'authenticity_token=' + AUTH_TOKEN})
//]]>
</script>
function add_annotation_category(path) {
var category_prompt = jQuery('#add_annotation_category_prompt');
if (category_prompt.size()) {
category_prompt.select();
category_prompt.focus();
} else {
jQuery.ajax({
url: path,
type: 'GET'
});
var info = jQuery('#no_annotation_categories_info');
if(info.size()) {
info.hide();
}
}
}
jQuery.ajax({
url: "<%= populate_students_path() %>",
data: 'authenticity_token=' + AUTH_TOKEN,
type: "POST",
async: true,
dataType: 'json'
}).done(function (data) {
jQuery('#loading_list').hide();
populate(JSON.stringify(data));
});
<%= link_to_function t("annotations.add_annotation_category"), %| if($('add_annotation_category_prompt') != null) {
$('add_annotation_category_prompt').select();
$('add_annotation_category_prompt').focus();
} else {
#{remote_function :url => {:action => "add_annotation_category", :id => @assignment.id}, :method => 'get', :after => "if($('no_annotation_categories_info') != null) { $('no_annotation_categories_info').hide();}" }
}|%>
var ModalMarkus = function (elem) {
this.elem = elem;
this.modal_dialog = jQuery(this.elem).dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 'auto',
dialogClass: 'no-close'
});
};
ModalMarkus.prototype = {
open: function () {
this.modal_dialog.dialog('open');
},
close: function () {
this.modal_dialog.dialog('close');
}
};
respond_to do |format|
format.json { render :json => @students }
end
jQuery('#add_annotation_text').replaceWith("<%= escape_javascript(render :partial => 'annotation_text', :locals => { :annotation_text => @annotation_text }).html_safe %>");
jQuery('#annotation_category_pane_list').prepend("<%= escape_javascript("#{render :partial => 'new_annotation_category', :locals => { :assignment_id => @assignment.id }}").html_safe %>");
jQuery('#add_annotation_category_prompt').select();
page.replace 'add_annotation_category', :partial => 'annotation_category', :locals => {:annotation_category => @annotation_category}
page.insert_html :top,
'annotation_category_pane_list',
:partial => 'new_annotation_category',
:locals => {:assignment_id => @assignment.id}
page['add_annotation_category_prompt'].focus
get_as @admin, :get_annotations,
:assignment_id => @assignment.id,
:id => @category.id,
:format => :js
result[:filter_table_row_contents] =
render_to_string :partial => 'users/table_row/filter_table_row.html.erb',
:locals => {:user => user, [...]}
<script type="text/javascript">
<%= render :partial => 'boot.js.erb' %>
</script>
<%= button_to_function t('download'), 'modal_download.open();' %>
jQuery(document).ready(function () {
window.modal_download = new ModalMarkus('#download_dialog');
});
.no-close .ui-dialog-titlebar,
.no-close .ui-dialog-buttonpane {
display: none;
}
<% path = add_annotation_category_assignment_annotation_categories_path(
:id => @assignment.id) %>
<%= link_to_function t('annotations.add_annotation_category'),
:onclick => "add_annotation_category('#{path}')" %>
<script type="text/javascript">
//<![CDATA[
var modalUpload = null;
var modalDownload = null;
function upload_annotation_categories(){
modalUpload.open();
return false;
}
function download_annotation_categories(){
modalDownload.open();
return false;
}
document.observe("dom:loaded", function(){
modalUpload = new Control.Modal($('upload_dialog'),
{
overlayOpacity: 0.75,
className: 'modalUpload',
fade: false
});
modalDownload = new Control.Modal($('download_dialog'),
{
overlayOpacity: 0.75,
className: 'modalDownload',
fade: false
});
});
//]]>
</script>
page.call "populate", @students.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment