Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ group :development do | |
end | ||
|
||
group :development, :test do | ||
gem 'puma' | ||
gem 'pry' | ||
gem 'pry-rails' | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,85 @@ | ||
/* | ||
.form-tabs <- data-init-tab = default tab | ||
.nav-tabs | ||
.li a ... <- click this | ||
.tab-pane ... <- to find these | ||
.form-group <- and swap these, so only one exists at at a time | ||
Both "a" and ".tab-pane" should be marked with matching data-tab attrs. | ||
*/ | ||
|
||
|
||
window.form_tabs_init = function (tabs_div) { | ||
var top = $(tabs_div); | ||
var val0 = top.data('type'); | ||
var val0 = top.data('init-tab'); | ||
var tabs = {}; | ||
|
||
function show_tab(ty) { | ||
function show_tab(tab) { | ||
console.log("show", tab); | ||
|
||
top.find('.nav-tabs a').each(function (_ii, lnk) { | ||
if (ty == $(lnk).data('type')) { | ||
$(lnk).addClass('active'); | ||
var this_tab = $(lnk).data('tab'); | ||
var item = $($(lnk).closest('li')); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
if (tab == this_tab) { | ||
item.addClass('active'); | ||
} | ||
else { | ||
$(lnk).removeClass('active'); | ||
item.removeClass('active'); | ||
} | ||
}); | ||
|
||
FIXME: Finish this plan. | ||
top.find('.tab-pane') | ||
|
||
var tp = $($(tlnk).data('target'))[0]; | ||
console.log("hide", tp); | ||
|
||
var uuid = $(tp).closest(".form-tabs-pane").data("uuid"); | ||
tabs[uuid] = tabs[uuid] || {}; | ||
|
||
var pid = tp.id; | ||
var fmg = $(tp).find(".form-group")[0]; | ||
if (fmg) { | ||
console.log("Storing to", uuid, pid); | ||
tabs[uuid][pid] = fmg; | ||
$(fmg).detach(); | ||
} | ||
} | ||
|
||
function show_tab(tlnk) { | ||
var tp = $($(tlnk).data('target'))[0]; | ||
console.log("show", tp); | ||
|
||
var uuid = $(tp).closest(".form-tabs-pane").data("uuid"); | ||
tabs[uuid] = tabs[uuid] || {}; | ||
top.find('.tab-pane').each(function (_ii, div) { | ||
var this_tab = $(div).data('tab'); | ||
This comment has been minimized.
Sorry, something went wrong.
blerner
|
||
|
||
var pid = tp.id; | ||
var fmg = tabs[uuid][pid]; | ||
$(tp).append(fmg); | ||
if (tab == this_tab) { | ||
$(div).addClass('active'); | ||
$(div).show(); | ||
if (tabs[this_tab]) { | ||
console.log("restored", tabs[tab]); | ||
$(div).append(tabs[tab]); | ||
} | ||
} | ||
else { | ||
var fg = $(div).find('.form-group'); | ||
if (fg[0]) { | ||
console.log("saved", fg[0]); | ||
tabs[this_tab] = fg[0]; | ||
$(fg[0]).detach(); | ||
} | ||
$(div).removeClass('active'); | ||
$(div).hide(); | ||
} | ||
}); | ||
} | ||
|
||
top.find(".nav-tabs a").each(function(_ii, lnk) { | ||
if (val0 == $(lnk).data('type')) { | ||
$(lnk).click(); | ||
} | ||
}); | ||
// Match height before we hide anything. | ||
var panes = top.find('.tab-pane'); | ||
panes.matchHeight({byRow: false, property: 'height'}); | ||
|
||
top.find(".nav-tabs a").each(function(_ii, lnk) { | ||
if (val0 != $(lnk).data('type')) { | ||
hide_tab(lnk); | ||
var tab = $(lnk).data('tab'); | ||
if (tab == val0) { | ||
show_tab(tab); | ||
} | ||
|
||
$(lnk).on("show.bs.tab", function(evt) { | ||
show_tab(evt.target); | ||
}); | ||
$(lnk).on("hide.bs.tab", function(evt) { | ||
hide_tab(evt.target); | ||
$(lnk).on("click", function(evt) { | ||
evt.preventDefault(); | ||
show_tab(tab); | ||
}); | ||
}); | ||
|
||
}; | ||
|
||
$(function() { | ||
$('.form-tabs-pane').each(function (_ii, el) { | ||
window.form_tabs_init_all = function (thing) { | ||
$(thing).find('.form-tabs').each(function (_ii, el) { | ||
form_tabs_init(el); | ||
}); | ||
}; | ||
|
||
$(function() { | ||
form_tabs_init_all('body'); | ||
}); | ||
|
2 comments
on commit 04f258f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irony: the remove buttons work for existing graders, but do not work for the new ones generated by the add-grader button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, actually, the remove button for existing graders does not delete the <li>
items, which means the numbers stay screwed up. Additionally, the remove buttons allow you to remove the final grader and update the assignment, but no assignment should be permitted to have zero graders.
The outer
$(...)
is redundant: jQuery always returns you a query object