Last active
January 18, 2017 11:25
-
-
Save davebowker/c52d37aba303f3edbced292cd3b010b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Set interaction class on body | |
| */ | |
| $(function () { | |
| $('input, textarea').focus(function() { | |
| // ID | |
| var action_id = $(this).attr('id'); | |
| if (action_id) { | |
| $('body').data('action_id', 'action-' + action_id) | |
| .addClass($('body').data('action_id')); | |
| } | |
| // Class(es) | |
| var class_id = $(this).attr('class'); | |
| if (class_id) { | |
| $('body').data('action_class', class_id.split(' ')); | |
| var action_class = $('body').data('action_class'); | |
| for (var i = 0; i < action_class.length; i++) { | |
| $('body').addClass('action-' + action_class[i]); | |
| } | |
| } | |
| }).blur(function() { | |
| // ID | |
| if ($('body').data('action_id')) { | |
| $('body').removeClass($('body').data('action_id')) | |
| .removeData('action_id'); | |
| } | |
| // Class(es) | |
| if ($('body').data('action_class')) { | |
| var action_class = $('body').data('action_class'); | |
| for (var i = 0; i < action_class.length; i++) { | |
| $('body').removeClass('action-' + action_class[i]).removeData('action_class'); | |
| } | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment