Created
January 16, 2013 10:00
-
-
Save Jacke/4546035 to your computer and use it in GitHub Desktop.
Shake object with tag form w/o jquery
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
| addLoadEvent = function (func) { | |
| if (typeof jQuery != "undefined") jQuery(document).ready(func); | |
| else if (typeof wpOnload != 'function') { | |
| wpOnload = func; | |
| } else { | |
| var oldonload = wpOnload; | |
| wpOnload = function () { | |
| oldonload(); | |
| func(); | |
| } | |
| } | |
| }; | |
| function s(id, pos) { | |
| g(id).left = pos + 'px'; | |
| } | |
| function g(id) { | |
| return document.getElementById(id).style; | |
| } | |
| function shake(id, a, d) { | |
| c = a.shift(); | |
| s(id, c); | |
| if (a.length > 0) { | |
| setTimeout(function () { | |
| shake(id, a, d); | |
| }, d); | |
| } else { | |
| try { | |
| g(id).position = 'static'; | |
| wp_attempt_focus(); | |
| } catch (e) {} | |
| } | |
| } | |
| addLoadEvent(function () { | |
| var p = new Array(15, 30, 15, 0, -15, -30, -15, 0); | |
| p = p.concat(p.concat(p)); | |
| var i = document.forms[0].id; | |
| g(i).position = 'relative'; | |
| shake(i, p, 20); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment