Browse files

more sane groups highlighing

  • Loading branch information...
1 parent 3ec8c0f commit c1be14c0928504485126c8a8719a722da7603786 @yko yko committed Nov 16, 2011
Showing with 32 additions and 33 deletions.
  1. +32 −33 htdocs/static/js/jquery-relaxer-popovers.js
View
65 htdocs/static/js/jquery-relaxer-popovers.js
@@ -1,37 +1,5 @@
(function($) {
- function activate_popovers(e) {
- // Activate popovers and deny live event on this object
- $('.group', this).twipsy({
- live: true,
- title: get_popover_text,
- offset: 5,
- html: true
- });
- $('.group', this).mouseover(highlight_group);
- $('.group', this).mouseout(unhighlight_group);
-
- $(this).addClass('twipsed');
- $(this).trigger(e);
- };
-
- function highlight_group(e) {
- $(this).addClass('highlighted');
- }
-
- function unhighlight_group(e) {
- $(this).removeClass('highlighted');
- }
-
- function get_popover_text(item) {
- var classes = $(this).attr('class');
- var match = classes.match(/(^|\s)num_(\d+)/);
- if (match) {
- return "Text matched by group.<br />Content in variable $" + match[2];
- }
- return "JavaScript error";
- }
-
function display_match_error(e) {
alert("Relaxer error: " + e.message);
}
@@ -63,12 +31,43 @@
$("#result").append(output);
$("#result").append('<br />');
}
+
+ // Install popovers on created elements
+ activate_popovers($('#result'));
+ }
+
+ function activate_popovers(obj) {
+ $('.group', obj).twipsy({
+ live: true,
+ title: get_popover_text,
+ offset: 5,
+ html: true
+ });
+
+ $('.group', obj).mouseover(highlight_group);
+ $('.group', obj).mouseout(unhighlight_group);
+ };
+
+ function highlight_group(e) {
+ $(this).addClass('highlighted');
+ }
+
+ function unhighlight_group(e) {
+ $(this).removeClass('highlighted');
+ }
+
+ function get_popover_text(item) {
+ var classes = $(this).attr('class');
+ var match = classes.match(/(^|\s)num_(\d+)/);
+ if (match) {
+ return "Text matched by group.<br />Content in variable $" + match[2];
+ }
+ return "JavaScript error";
}
$(function() {
$(document).bind('relaxer_match_done', display_match_results);
$(document).bind('relaxer_match_error', display_match_error);
- $(document).on("mouseover", ".match:not(.twipsed)", activate_popovers);
});
})(jQuery);

0 comments on commit c1be14c

Please sign in to comment.