topical media & game development

talk show tell print

mobile-query-three-www-jsinside-bootstrap-srcannotate.js / js



  
For Source Annotations ala angularjs

  
  jQuery(function(){
          jQuery('pre + script[type="text/codeannotation"]').each(function(){
                  var annotJSON        = jQuery(this).text();
                  var annotations        = JSON.parse(annotJSON);
                  var preElement        = jQuery(this).prev()
                  Object.keys(annotations).forEach(function(text){
                          jQuery("*:contains('"+text+"')", preElement).last().each(function(){
                                  if( jQuery(this).hasClass('hasAnnotation') )        return;
                                  jQuery(this).addClass('hasAnnotation');
                                  if( typeof annotations[text] === "string"){
                                          jQuery(this).popover({
                                                  title        : text,
                                                  content        : annotations[text]
                                          });
                                  }else{
                                          jQuery(this).popover(annotations[text]);
                                  }
                          });
                  })
          })
  });


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.