Skip to content

Instantly share code, notes, and snippets.

@mramsden
Created February 4, 2010 14:20
Show Gist options
  • Save mramsden/294659 to your computer and use it in GitHub Desktop.
Save mramsden/294659 to your computer and use it in GitHub Desktop.
<div id="manageable_id_2" class="ep_manageable">
<div class="ep_manageable_data">
<input id="manageable_id_2_check" type="checkbox"> <a href="http://wlbr.local/2/">ZeroWIN Vision Conference</a>
</div>
<div class="ep_manageable_controls">
<ul>
<li>Manage Bookmark</li>
<li>Edit Resource</li>
<li>Delete Resource</li>
</ul>
</div>
<div style="clear: both;"></div>
</div>
window.resourceSelection = new Array();
window.resourceSelected = function(element) {
return resourceSelection.find(function(n) { return n == element; });
}
window.updateResourceSelection = function(event) {
var element = event.element();
// There is an issue with event bubbling this is a temporary hack to fix it.
if (element.hasClassName('ep_manageable')) {
//event.stop();
if (resourceSelected(element)) {
resourceSelection = resourceSelection.reject(function(n) { return n.readAttribute('id') == element.readAttribute('id'); });
element.removeClassName('ep_manageable_selected');
$(element.readAttribute('id')+'_check').writeAttribute('checked', false);
} else {
resourceSelection.push(element);
element.addClassName('ep_manageable_selected');
$(element.readAttribute('id')+'_check').writeAttribute('checked', true);
}
}
};
document.observe('dom:loaded', function() {
$$('.ep_manageable').each(function(element) {
element.observe('click', updateResourceSelection);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment