Current File : /home/k/a/r/karenpetzb/www/items/category/TinyNav.tar
tinynav.js000060400000004316150711372400006572 0ustar00/*! http://tinynav.viljamis.com v1.1 by @viljamis */
(function ($, window, i) {
  $.fn.tinyNav = function (options) {

    // Default settings
    var settings = $.extend({
      'active' : 'selected', // String: Set the "active" class
      'header' : '', // String: Specify text for "header" and show header instead of the active item
      'label'  : '' // String: sets the <label> text for the <select> (if not set, no label will be added)
    }, options);

    return this.each(function () {

      // Used for namespacing
      i++;

      var $nav = $(this),
        // Namespacing
        namespace = 'tinynav',
        namespace_i = namespace + i,
        l_namespace_i = '.l_' + namespace_i,
        $select = $('<select/>').attr("id", namespace_i).addClass(namespace + ' ' + namespace_i);

      if ($nav.is('ul,ol')) {

        if (settings.header !== '') {
          $select.append(
            $('<option/>').text(settings.header)
          );
        }

        // Build options
        var options = '';

        $nav
          .addClass('l_' + namespace_i)
          .find('a')
          .each(function () {
            options += '<option value="' + $(this).attr('href') + '">';
            var j;
            for (j = 0; j < $(this).parents('ul, ol').length - 1; j++) {
              options += '- ';
            }
            options += $(this).text() + '</option>';
          });

        // Append options into a select
        $select.append(options);

        // Select the active item
        if (!settings.header) {
          $select
            .find(':eq(' + $(l_namespace_i + ' li')
            .index($(l_namespace_i + ' li.' + settings.active)) + ')')
            .attr('selected', true);
        }

        // Change window location
        $select.change(function () {
          window.location.href = $(this).val();
        });

        // Inject select
        $(l_namespace_i).after($select);

        // Inject label
        if (settings.label) {
          $select.before(
            $("<label/>")
              .attr("for", namespace_i)
              .addClass(namespace + '_label ' + namespace_i + '_label')
              .append(settings.label)
          );
        }

      }

    });

  };
})(jQuery, this, 0);
demo.html000060400000003504150711372400006354 0ustar00<!DOCTYPE html>
<html lang="en">
<head>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>TinyNav.js &middot; Convert navigation to a tiny select box on small screen</title>

  <style>
    /* styles for desktop */
    .tinynav { display: none }
    #nav .selected a, #nav2 .selected a { color: red }
    /* styles for mobile */
    @media screen and (max-width: 600px) {
      .tinynav { display: block }
      #nav, #nav2 { display: none }
    }
  </style>

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script src="tinynav.min.js"></script>
  <script>
    $(function () {

      // TinyNav.js 1
      $('#nav').tinyNav({
        active: 'selected',
        label: 'Menu'
      });
      
      // TinyNav.js 2
      $('#nav2').tinyNav({
        header: 'Navigation' // Writing any title with this option triggers the header
      });

    });
  </script>

</head>
<body>

    <h1>TinyNav.js</h1>

    <ul id="nav">
      <li><a href="http://google.com">Google</a></li>
      <li class="selected"><a href="demo.html">Demo page</a></li>
      <li><a href="http://bing.com">Bing</a>
        <ul>
          <li><a href="http://google.com">Google</a></li>
          <li><a href="demo.html">Demo page</a></li>
          <li><a href="http://bing.com">Bing</a></li>
          <li><a href="http://yahoo.com">Yahoo</a></li>
        </ul>
      </li>
      <li><a href="http://yahoo.com">Yahoo</a></li>
    </ul>
    
    
    <ul id="nav2">
      <li><a href="http://google.com">Google</a></li>
      <li><a href="demo.html">Demo page</a></li>
      <li class="selected"><a href="http://bing.com">Bing</a></li>
      <li><a href="http://yahoo.com">Yahoo</a></li>
    </ul>

    <p><a href="http://tinynav.viljamis.com/">See the documentation</a></p>

</body>
</html>tinynav.min.js000060400000001501150711372400007345 0ustar00/*! http://tinynav.viljamis.com v1.1 by @viljamis */
(function(a,i,g){a.fn.tinyNav=function(j){var b=a.extend({active:"selected",header:"",label:""},j);return this.each(function(){g++;var h=a(this),d="tinynav"+g,f=".l_"+d,e=a("<select/>").attr("id",d).addClass("tinynav "+d);if(h.is("ul,ol")){""!==b.header&&e.append(a("<option/>").text(b.header));var c="";h.addClass("l_"+d).find("a").each(function(){c+='<option value="'+a(this).attr("href")+'">';var b;for(b=0;b<a(this).parents("ul, ol").length-1;b++)c+="- ";c+=a(this).text()+"</option>"});e.append(c);
b.header||e.find(":eq("+a(f+" li").index(a(f+" li."+b.active))+")").attr("selected",!0);e.change(function(){i.location.href=a(this).val()});a(f).after(e);b.label&&e.before(a("<label/>").attr("for",d).addClass("tinynav_label "+d+"_label").append(b.label))}})}})(jQuery,this,0);README.md000060400000005630150711372400006023 0ustar00# TinyNav.js
### Responsive navigation plugin that weighs just 443 bytes

[TinyNav.js](http://tinynav.viljamis.com/) is a tiny jQuery plugin (443 bytes minified and gzipped) that converts `<ul>` and `<ol>` navigations to a select boxes for small screen. It also automatically selects the current page and adds `selected="selected"` for that item. There's also a Wordpress plugin available, [here](http://wordpress.org/extend/plugins/tinynav/).

This isn't the first plugin to do this and it doesn't provides a lot of options, but it might be the smallest (file size).

Check out also the new version called [Responsive Nav](http://responsive-nav.com).

Usage Instructions and demo
======

For instructions and demo go to [http://tinynav.viljamis.com](http://tinynav.viljamis.com/)


License
======

Licensed under the MIT license.

Copyright (c) 2011-2012 Viljami Salminen, http://viljamis.com/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Changelog
======

v1.1 (2012-11-14) - Adds an optional "label" tag before the "select" tag, thanks to [@larcher](https://github.com/larcher)

v1.05 (2012-10-19) - Adds the support for multiple navigation depths, thanks to [@nicoandrade](https://github.com/nicoandrade)

v1.04 (2012-10-19) - Adds the possibility to change the text of the header. Notice that there seems to be a bug in jQuery 1.8.0 which prevents this script from working correctly if there is no selected item in the navigation (the plugin does work with older and newer versions correctly though, currently tested up to 1.8.2).

v1.03 (2012-03-15) - Adds new option called "header", thanks to [@jorde](https://github.com/jorde)

v1.02 (2012-03-07) - Some performance improvements and a bug fix

v1.01 (2012-01-04) - Code Refactoring

v1.00 (2011-12-31) - Release


Want to do a pull request?
======

Great! New ideas are more than welcome, but please check the [Pull Request Guidelines](https://github.com/viljamis/TinyNav.js/wiki/Pull-Request-Guidelines) first before doing so.