/**
 * HideSeek jQuery plugin
 *
 * @copyright Copyright 2013, Dimitris Krestos
 * @license   Apache License, Version 2.0 (http://www.opensource.org/licenses/apache2.0.php)
 * @link      http://vdw.staytuned.gr
 * @version   v0.1.0
 */

  /* Sample html structure

  <div class='selector'></div>

  */

;(function($, window, undefined) {
  "use strict";

  $.fn.hideseek = function(options) {

    var defaults = {
      datalist:   '.hideseek-list',
      dataattr:   'text',
      highlight:  false
    };

    var options = $.extend(defaults, options);

    $(this).each(function() {

      var $this = $(this);

      $this.keyup(function() {

        var q = $this.val().toLowerCase();

        $(options.datalist).children().each(function() {

          var data = (options.dataattr != 'text') ? $(this).attr(options.dataattr).toLowerCase() : $(this).text().toLowerCase();

          if (data.indexOf(q) == -1) {

            $(this).hide();

          } else {

            $(this).show();

          }

        });

      });

    });

  };

  $(document).ready(function () { $('[data-toggle="hideseek"]').hideseek(); });

})(jQuery);
/**
 * HideSeek jQuery plugin
 *
 * @copyright Copyright 2013, Dimitris Krestos
 * @license   Apache License, Version 2.0 (http://www.opensource.org/licenses/apache2.0.php)
 * @link      http://vdw.staytuned.gr
 * @version   v0.1.0
 *
 * Dependencies are include at the bottom:
 * Highlight v4 by Johann Burkard
 *
 */

  /* Sample html structure

  <div class='selector'></div>

  */

;(function($, window, undefined) {
  "use strict";

  $.fn.hideseek = function(options) {

    var defaults = {
      datalist:   '.hideseek-list',
      dataattr:   'text',
      highlight:  false
    };

    var options = $.extend(defaults, options);

    $(this).each(function() {

      var $this = $(this);

      $this.keyup(function() {

        var q = $this.val().toLowerCase();

        $(options.datalist).children().each(function() {

          var data = (options.dataattr != 'text') ? $(this).attr(options.dataattr).toLowerCase() : $(this).text().toLowerCase();

          if (data.indexOf(q) == -1) {

            $(this).hide();

          } else {

            options.highlight ? $(this).removeHighlight().highlight(q).show() : $(this).show();

          }

        });

      });

    });

  };

  $(document).ready(function () { $('[data-toggle="hideseek"]').hideseek(); });

})(jQuery);


/*

highlight v4

Highlights arbitrary terms.

<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>

MIT license.

Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>

*/
jQuery.fn.highlight=function(t){function e(t,i){var n=0;if(3==t.nodeType){var a=t.data.toUpperCase().indexOf(i);if(a>=0){var s=document.createElement("mark");s.className="highlight";var r=t.splitText(a);r.splitText(i.length);var o=r.cloneNode(!0);s.appendChild(o),r.parentNode.replaceChild(s,r),n=1}}else if(1==t.nodeType&&t.childNodes&&!/(script|style)/i.test(t.tagName))for(var h=0;h<t.childNodes.length;++h)h+=e(t.childNodes[h],i);return n}return this.length&&t&&t.length?this.each(function(){e(this,t.toUpperCase())}):this},jQuery.fn.removeHighlight=function(){return this.find("mark.highlight").each(function(){with(this.parentNode.firstChild.nodeName,this.parentNode)replaceChild(this.firstChild,this),normalize()}).end()};
Add highlight option