optimization - Refactoring animations in jQuery login script -
I am using jQuery to create simple animations for login forms in my CMS. JQuery Toggles the visibility of two forms, a login form and reset password form.
The script works perfectly well, but I have to figure out how to minimize it, because most code is redundant.
Note: The .click
function is said twice in each case so that the animation can be implemented concurrently.
$ (function () {var recover_text = "password recovery $ (" # forgot "). $ (" Input ") $ $ (" Label (class: "label", labeled "inside"}); $ ("# forgot"). ("#cms_login") .Fedote ("fast" (Function () {$ ("#dialog h2") .FadeOut (function) ($ ("# pw_recover"). FadeIn ();});}); $ ("# forgot"). "Fast", function () {$ (this) .html ("+ + retrieve_text +" "). FadeIn ();}); document.title = '' + recover_text + (" # "); $ (" # Login ") (function () {$ (" # pw_recover "). Feeds (" fast ", function () {$ (" # cms_login "). FadeIn ();});}); $ (" # Login ") cl Fade (("+ + login_text +" "). $ FadeIn ();}) Fade (" Action ") ($ (" # Dialog H2 "). Fadeaut (" fast ", function () {$ (this) ; Document.title = '' + login_text + '';});});
and (abridged) HTML:
forgot password went? & Lt; / A & gt; & Lt; / Form & gt; & Lt; Form id = "pw_recover" & gt; ... Reset Password Fields ... & lt; An id = "login" href = "#" & gt; To log back in & lt; / A & gt; & Lt; / Form & gt; & Lt; / Div & gt; #pw_recover {display: none; } How can I optimize / retire this script? any idea?
something like that?
$ (function () {function switch box (out, in_strack) {return function () {$ (outside). FadeOut ("fast", function () {$ (in_str). ();}}}}}} Function switch_text (out, text) {return work () {$ (outside). Fadeaut ("fast", function () {$ (this) .html (text) .FadeIn () ;}); Document.title = '' + + + text + '';};} ("Forgot"); $ ("# Forgotten"););) "Recovery" $ ("# Login ") (" # Cms_login "," #pw_recover "); $ ("# Forgot"). Click (switch_text ("# dialog h2", request_text)); $ ("#in Login"). Click (switchbacks) ("#pw_recover", "#cms_login")); $ ("#in Login"). Click (switch_text ("# dialog h2", login_text)););
Comments
Post a Comment