Created
April 8, 2013 11:44
-
-
Save a-ignatov-parc/5336228 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
| events: { | |
| 'blur input[placeholder], textarea[placeholder]': 'processPlaceholder', | |
| 'focus input[placeholder], textarea[placeholder]': 'processPlaceholder', | |
| 'change input[placeholder], textarea[placeholder]': 'processPlaceholder' | |
| }, | |
| // Метод реализиующий правильное функционирование кастомного плейсхолдера в браузерах которые их | |
| // не поддерживают | |
| processPlaceholder: function(event) { | |
| var alowedEvents = { | |
| 'focus': YES, | |
| 'focusin': YES, | |
| 'change': YES | |
| }; | |
| if (!Modernizr.input.placeholder) { | |
| var target = $(event.currentTarget), | |
| isEmpty = function(event, input) { | |
| var inputData = input.data(), | |
| hasMask = 'rawMaskFn' in inputData, | |
| value = hasMask ? inputData.rawMaskFn() : input.val(); | |
| if (!value.length) { | |
| return YES; | |
| } | |
| return NO; | |
| }; | |
| target | |
| .parent() | |
| .toggleClass('ui-field-hideplaceholder', (alowedEvents[event.type] ? YES : !isEmpty(event, target))); | |
| } | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment