topical media & game development

talk show tell print

lib-jquery-plugin-charts-include-js-lib-ycodaslider-2.0.rc2-plugins-code-ycodaslider-2.0.js / js



  /*
   * 
   * YCodaCode plugin 2.0
   * Date: 2008-05-18 16:08:16 +0200 (dom, 18 mag 2008) 
   * Rev: 92 
   * @requires jQuery v1.2.3
   * @requires YCodaSlider v2.0
   * @requires jQuery Chili Plugin v1.9 
   * 
   * Copyright (c) 2008 Massimiliano Balestrieri
   * Examples and docs at: http://maxb.net/blog/
   * Licensed GPL licenses:
   * http://www.gnu.org/licenses/gpl.html
   * 
   */
  YCodaSlider.Code = {
      init     : function(options, options_yslider)
      {
          
          options = jQuery.extend({
                }, options);
          var cnt = this.size();
          var j = this.parent();
          return this.each(
              function(nr)
              {
                      var that = this;
                      var js = jQuery("a",this);
                  var j = jQuery(this).parent();
                      js.each(function(nr){
                         var href = jQuery(this).attr("href");
                         var self = this;
                         var html = '<div class="yslider-panelwrapper" title="'+ jQuery(self).text() +'">';
                         jQuery(self).wrap(html);
                     var panel = jQuery(self).parent();
                     //console.log(panel);
                     panel.empty();
                     jQuery.get(href, function(data){
                                    panel.html('<pre><code class="javascript">'+(YCodaSlider.Code.html_encode(data))+'</code></pre>');
                                    jQuery("code", panel).chili();
                         });
                         
                      });
  
              }
          );
      },
      html_encode : function (s) {
          var str = new String(s);
          str = str.replace(/&/g, "&amp;");
          str = str.replace(/</g, "&lt;");
          str = str.replace(/>/g, "&gt;");
          str = str.replace(/"/g, "&quot;");
          return str;
      }
  };
  jQuery.fn.ycodacode = YCodaSlider.Code.init;


(C) Æliens 20/2/2008

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.