Commits

Branko Vukelic committed 7cc2287

Initial commit

Comments (0)

Files changed (8)

+Copyright (c) 2012 Monwara LLC.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+    3. All advertising materials mentioning features or use of this software
+    must display the following acknowledgement: This product includes software
+    developed by Monwara LLC.
+
+    4. Neither the name of Monwara LLC nor the names of its contributors may be
+    used to endorse or promote products derived from this software without
+    specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY MONWARA LLC ''AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL MONWARA LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+include README.rst
+include LICENSE
+include NEWS
+include autohide_help/static/js/*.js
+2012-11-21 Released 0.0.1
+=========================
+
++ Changed djangoAutohideHelp to autohideHelp
++ Packaged as pluggable app
++ Released to PyPI
+====================
+django-autohide-help
+====================
+
+django-autohide-help is a jQuery_ plugin packaged as a Django_ app for easy
+installation. It's a plugin that allows frontend developers to hide help blocks
+generated by `crispy forms`_.
+
+Installation
+============
+
+Install using pip::
+
+    pip install django-autohide-help
+
+After adding ``autohide_help`` to ``INSTALLED_APPS``, ``autohide-help.js`` will
+be avalable at ``{{ STATIC_URL }}js/autohide-help.js``.
+
+If you are using RequireJS_, you can add ``autohide-help`` to dependencies, as
+it is packages with RequireJS support.
+
+If you want to use it via a simple script tag, you can add the script tag as
+usual::
+
+    <script src="{{ STATIC_URL}}js/autohide-help.js``"></script>
+
+This plugin requires jQuery (obviously).
+
+Basic usage
+===========
+
+Select a form (or forms), and call ``autohideHelp`` on it::
+
+    $('form').autohideHelp()
+
+As user enters the fields the help block is slid out, and slid back in as user
+leaves the field.
+
+Using without crispy forms
+==========================
+
+Crispy forms are not absolutely required. It is just convenient to use them
+since they automatically generate the help blocks.
+
+If you want to use django-autohide-help without the crispy forms, make sure
+that your help blocks have an id in the following format: ``help_FIELD_ID``
+where ``FIELD_ID`` is the id of the field to which the help block belongs. For
+example, if you field has an id of ``id_name``, the help block must have the
+id of ``help_id_name``. Future releases of ``django-authide-help`` may make
+this configurable.
+
+Reporting bugs
+==============
+
+Please report bugs to Bitbucket `issue tracker`_.
+
+.. _jQuery: http://jquery.com/
+.. _Django: http://www.djangoproject.com/
+.. _crispy forms: http://django-crispy-forms.readthedocs.org/en/d-0/
+.. _issue tracker: https://bitbucket.org/brankovukelic/django-autohide-help/issues

autohide_help/__init__.py

Empty file added.

autohide_help/models.py

Empty file added.

autohide_help/static/js/autohide-help.js

+/**
+ * Copyright (c)2012 Monwara LLC <branko@monwara.com>
+ * All rights reserved.
+ *
+ * @author Monwara LLC <branko@monwara.com>
+ * @version 0.0.1
+ * @license BSD
+ */
+
+(function(root, factory) {
+
+  if (typeof define === 'function' && define.amd) {
+    define(['jquery'], factory);
+  } else {
+    factory(root.jQuery);
+  }
+
+})(this, function($) {
+
+  (function() {
+  
+    $.fn.autohideHelp = function() {
+      $(this).each(function(idx, elem) {
+        var $form = $(elem);
+        var inputs;
+
+        inputs = $form.find(':input');
+        if (inputs.length) {
+          inputs.each(function(idx, elem) {
+            var $input = $(elem);
+            var input_id = $input.attr('id');
+            var help_id = '#hint_' + $input.attr('id');
+            var $help = $(help_id);
+
+            $help.hide();
+
+            function show() { $help.slideDown(300); }
+            function hide() { $help.slideUp(300); }
+
+            $input.on('focus', show);
+            $input.on('blur', hide);
+
+          });
+        }
+      });
+    }
+
+  })();
+
+});
+from distutils.core import setup
+
+setup(
+    name='django-autohide-help',
+    description='jQuery plugin that auto-hides form field help blocks as '
+    'pluggable Django app',
+    long_description=open('README.rst').read(),
+    version='0.0.1',
+    packages=['autohide_help'],
+    author='Monwara LLC',
+    author_email='branko@monwara.com',
+    url='https://bitbucket.org/monwara/django-autohide-help',
+    download_url='https://bitbucket.org/monwara/django-autohide-help/downloads',
+    license='BSD',
+    classifiers = [
+        'Development Status :: 2 - Pre-Alpha',
+        'Framework :: Django',
+        'Environment :: Web Environment',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved :: BSD License',
+    ],
+)
+
+