Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function s(e) {
- e.preventDefault(), o.remClass("is-selected"), c.remClass("is-selected"), l.remClass("selected"), a.addClass("is-visible"), i.addClass("is-selected"), r.addClass("selected")
- }
- function n(e) {
- e.preventDefault(), i.remClass("is-selected"), c.remClass("is-selected"), r.remClass("selected"), a.addClass("is-visible"), o.addClass("is-selected"), l.addClass("selected")
- }
- var a = t(".cd-user-modal"),
- i = t("#cd-login", a),
- o = t("#cd-signup", a),
- c = t("#cd-reset-password", a),
- e = t(".cd-switcher"),
- r = t("a", e)[0],
- l = t("a", e)[1],
- d = t(".cd-form-bottom-message a", i),
- p = t(".cd-form-bottom-message a", c),
- g = t(".top-bar-right");
- g.onclick = function (e) {
- e.target === g && t("ul", g).forEach(function (e) {
- e.toggleClass("is-visible")
- })
- }, t(".cd-signup").onclick = n, $(".cd-signin").on("click", s), a.onclick = function (e) {
- (e.target == a || e.target.classList.contains(".cd-close-form")) && a.remClass("is-visible")
- }, document.addEventListener("keyup", function (e) {
- "27" == e.which && a.remClass("is-visible")
- }), e.onclick = function (e) {
- e.target === r ? s(e) : n(e)
- }, t(".hide-password").forEach(function (e) {
- e.onclick = function () {
- var e = this.previousElementSibling;
- "password" == e.getAttribute("type") ? e.setAttribute("type", "text") : e.setAttribute("type", "password"), this.innerHTML = this.innerHTML == Lang.get("show") ? Lang.get("hide") : Lang.get("show")
- }
- }), d.onclick = function (e) {
- e.preventDefault(), i.remClass("is-selected"), o.remClass("is-selected"), c.addClass("is-selected")
- }, p.onclick = s
- }();
- var s = App.Path.Func,
- n = function (e, t) {
- switch (e) {
- case "error":
- App.Info("error", Lang.get("an_error_occured"), t);
- break;
- case "errors":
- App.Info("error", Lang.get("notification"), t);
- break;
- case "logging":
- App.Info("success", Lang.get("please_wait"), Lang.get("logging_in"), 3e3);
- break;
- case "activated":
- App.xModal.show(Lang.get("account_activated"), Lang.get("account_activated_msg"));
- break;
- case "passreset":
- App.xModal.show(Lang.get("notification"), Lang.get("pass_changed"));
- break;
- case "welcome":
- App.xModal.show(Lang.get("vfc_head"), Lang.get("vfc_body"));
- break;
- case "passform":
- App.xModal.show(Lang.get("check_email"), Lang.get("activation_send"));
- break;
- case "reset_info":
- App.xModal.show(Lang.get("check_email"), Lang.get("forgot_send"))
- }
- },
- a = function (e, t) {
- return t || App.Loading(Lang.get("please_wait")), App.Request("post", s, e)
- },
- i = function (e, t) {
- for (var s in t) e[s] = t[s];
- return e
- },
- t = {
- Modal: App.Find(".cd-user-modal")
- },
- o = function (e) {
- t.Modal.click(), e.target.reset()
- };
- ({
- init: function () {
- document.addEventListener("submit", this, !1), -1 !== window.location.href.indexOf("/auth?") && this.Activate()
- },
- handleEvent: function (e) {
- if ("submit" === e.type) {
- e.preventDefault();
- var t = App.ParseForm.call(e.target);
- switch (e.target.id) {
- case "logForm":
- this.Login(e, i(t.Data, {
- auth_type: "login"
- }));
- break;
- case "regForm":
- this.Register(e, i(t.Data, {
- auth_type: "signup"
- }));
- break;
- case "resetForm":
- this.Reset(e, i(t.Data, {
- auth_type: "reset"
- }));
- break;
- case "newPass":
- this.NewPass(e, i(t.Data, {
- auth_type: "newpass"
- }))
- }
- }
- },
- NewPass: function (e, t) {
- a(t).then(function (e) {
- App.Loading("close"), 1 == e ? n("passreset") : n("errors", e)
- })
- },
- Register: function (t, e) {
- a(e).then(function (e) {
- App.Loading("close"), 1 == e ? (n("welcome"), o(t)) : n("errors", e)
- })
- },
- Reset: function (t, e) {
- a(e).then(function (e) {
- App.Loading("close"), 2 == e ? (n("passform"), o(t)) : 1 == e ? (n("reset_info"), o(t)) : n("errors", e)
- })
- },
- Login: function (t, e) {
- a(e).then(function (e) {
- App.Loading("close"), 1 == e ? (o(t), n("logging"), setTimeout(function () {
- location.reload()
- }, 2500)) : n("error", e)
- })
- },
- Activate: function () {
- a({
- auth_type: "activation",
- code: window.location.href.split("?").pop()
- }, 1).then(function (e) {
- "success" == e ? n("activated") : "active" == e && (window.location.href = Conf.get("app_url"))
- })
- }
- }).init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement