Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- if (!this.require) {
- var e = {}
- , t = {}
- , n = function(o, s) {
- var a, u, d = r(s, o), l = r(d, "./index");
- if (a = t[d] || t[l]) {
- if (a.__define_in_progress)
- throw new Error("Circular dependency: " + o + " already required.");
- return a
- }
- if (u = e[d] || e[d = l])
- return a = {
- id: d,
- exports: {
- __define_in_progress: !0
- }
- },
- t[d] = a.exports,
- u(a.exports, function(e) {
- return n(e, i(d))
- }, a),
- delete a.exports.__define_in_progress,
- t[d] = a.exports;
- throw "module " + o + " not found"
- }
- , r = function(e, t) {
- var n, r, i = [];
- n = /^\.\.?(\/|$)/.test(t) ? [e, t].join("/").split("/") : t.split("/");
- for (var o = 0, s = n.length; o < s; o++)
- r = n[o],
- ".." == r ? i.pop() : "." != r && "" != r && i.push(r);
- return i.join("/")
- }
- , i = function(e) {
- return e.split("/").slice(0, -1).join("/")
- };
- this.require = function(e) {
- return n(e, "")
- }
- ,
- this.require.define = function(t) {
- for (var n in t)
- e[n] = t[n]
- }
- ,
- this.require.modules = e,
- this.require.cache = t
- }
- return this.require
- }
- ).call(this),
- function() {
- null == window.W && (window.W = {})
- }
- .call(this),
- function() {
- W.GoogleAnalyticsEvent = {
- raise: function(e, t, n, r) {
- return null == n && (n = null),
- null == r && (r = null),
- ga("send", "event", {
- eventCategory: e,
- eventAction: t,
- eventLabel: n,
- hitCallback: r
- })
- },
- raiseWithOutboundLink: function(e, t, n, r) {
- return null == r && (r = null),
- this.raise(t, n, r, function() {
- return window.location = e
- })
- }
- },
- $(document).ready(function() {
- return $("body").on("submit", "[data-ga-event=submit]", function(e) {
- var t, n, r, i;
- return e.preventDefault(),
- r = 2e3,
- t = $(this),
- n = this,
- i = window.setTimeout(function() {
- return n.submit()
- }, r),
- W.GoogleAnalyticsEvent.raise(t.data("ga-category"), t.data("ga-action"), t.data("ga-label"), function() {
- return clearTimeout(i),
- n.submit()
- })
- }),
- $("body").on("click", "[data-ga-action]", function(e) {
- var t, n, r;
- if (t = $(this),
- "click" === (n = $.trim(t.data("ga-event"))) || "" === n)
- return "_blank" === t.attr("target") ? W.GoogleAnalyticsEvent.raise(t.data("ga-category"), t.data("ga-action"), t.data("ga-label")) : (e.preventDefault(),
- r = t.attr("href"),
- r || (r = window.location.hash || "#"),
- W.GoogleAnalyticsEvent.raiseWithOutboundLink(r, t.data("ga-category"), t.data("ga-action"), t.data("ga-label")))
- })
- })
- }
- .call(this),
- function() {
- $(function() {
- if (null != $("body").data("remove-external-links"))
- return $("a[href^=http]").attr("href", "/")
- })
- }
- .call(this),
- function() {
- $.fn.serializeHash = function() {
- var e, t, n, r, i;
- for (e = {},
- i = this.serializeArray(),
- t = 0,
- n = i.length; t < n; t++)
- r = i[t],
- e[r.name] = r.value;
- return e
- }
- ,
- $.fn.validatePresenceOf = function(e) {
- var t;
- return t = this.find("[name=" + e + "]"),
- /^ *$/.test(t.val()) ? (t.addErrorMessage("Please enter a value"),
- !1) : (t.removeErrorMessage(),
- !0)
- }
- ,
- $.fn.validateEquals = function(e, t, n) {
- var r;
- return null == n && (n = ""),
- r = this.find("[name=" + e + "]"),
- r.val() !== t ? (r.addErrorMessage(n),
- !1) : (r.removeErrorMessage(),
- !0)
- }
- ,
- $.fn.validateEmailAddress = function(e) {
- var t;
- return t = this.find("[name=" + e + "]"),
- /\S+@\S+\.\S+/.test(t.val())
- }
- ,
- $.fn.addErrorMessage = function(e) {
- var t;
- if (this.closest(".form-group").addClass("has-error"),
- t = this.siblings(".help-block"),
- 0 === t.length)
- return $("<span>").addClass("help-block").text(e).insertAfter(this)
- }
- ,
- $.fn.removeErrorMessage = function() {
- return this.closest(".form-group").removeClass("has-error"),
- this.siblings(".help-block").remove()
- }
- ,
- $.fn.removeAllErrors = function() {
- return this.find(".help-block").remove(),
- this.find(".form-group.has-error").removeClass("has-error")
- }
- }
- .call(this),
- function() {
- W.Recaptcha = function() {
- function e(e) {
- this.el = e,
- this.el instanceof $ && (this.el = this.el[0]),
- this.captchaId = null
- }
- return e.SITEKEY = "6LdQBgcTAAAAAHNSmTJ5n43d5fIaWw7BmkAwcxXn",
- e.URL = "https://www.google.com/recaptcha/api.js?render=explicit&onload=onRecaptchaLoad&hl=" + I18n.locale,
- e.loaded = $.Deferred(),
- e.ready = function() {
- return "resolved" === this.loaded.state()
- }
- ,
- e.load = function() {
- return this.ready() || $.getScript(this.URL),
- this.loaded.promise()
- }
- ,
- e.onload = function() {
- return this.loaded.resolve()
- }
- ,
- e.prototype.show = function() {
- return this.constructor.load().done(function(e) {
- return function() {
- return e.captchaId = grecaptcha.render(e.el, {
- sitekey: e.constructor.SITEKEY
- })
- }
- }(this))
- }
- ,
- e.prototype.reset = function() {
- if (null != this.captchaId)
- return grecaptcha.reset(this.captchaId)
- }
- ,
- e.prototype.getResponse = function() {
- return null != this.captchaId ? grecaptcha.getResponse(this.captchaId) : ""
- }
- ,
- e
- }(),
- window.onRecaptchaLoad = function() {
- return W.Recaptcha.onload()
- }
- }
- .call(this),
- function() {
- var e, t;
- t = 500,
- e = 300,
- W.ShareButton = function() {
- function n(e) {
- this.el = e,
- this.el.click(function(e) {
- return function(t) {
- return "function" == typeof t.preventDefault && t.preventDefault(),
- e._openShareWindow()
- }
- }(this))
- }
- return n.prototype._openShareWindow = function() {
- var e;
- return e = this.el.attr("href"),
- window.open(e, "", this._getWindowOptions())
- }
- ,
- n.prototype._getWindowOptions = function() {
- var n, r;
- return r = this.el.data("width") || t,
- n = this.el.data("height") || e,
- "width=" + r + ",height=" + n + ",toolbar=no,menubar=no,location=no"
- }
- ,
- n
- }(),
- $.fn.shareButton = function() {
- return this.each(function() {
- var e;
- if (e = $(this),
- null == e.data("shareButton") && "_blank" === e.attr("target"))
- return e.data("shareButton", new W.ShareButton(e))
- })
- }
- ,
- $(function() {
- return $("a[role=share-button]").shareButton()
- })
- }
- .call(this),
- function() {
- "undefined" != typeof $ && null !== $ && ($.fn.oneTransitionEnd = function(e) {
- var t;
- return t = "webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",
- $(this).one(t, e)
- }
- ,
- $.fn.oneAnimationEnd = function(e) {
- var t;
- return t = "webkitAnimationEnd oanimationend oAnimationEnd msAnimationEnd animationend",
- $(this).one(t, e)
- }
- )
- }
- .call(this),
- function() {
- W.YouTubePlayer = function() {
- function e(e, t) {
- this.id = e,
- this.options = null != t ? t : {},
- this._initOptions(),
- this._createPlayer()
- }
- return e.prototype._initOptions = function() {
- return this.options.playerVars = _.defaults(this.options.playerVars || {}, {
- wmode: "transparent",
- modestbranding: 1,
- rel: 0,
- showinfo: 0,
- showsearch: 0,
- autohide: 1,
- controls: 1
- }),
- _.defaults(this.options, {
- height: "481",
- width: "800",
- events: {
- onReady: $.proxy(this._onPlayerReady, this),
- onStateChange: $.proxy(this._onPlayerStateChanged, this)
- }
- })
- }
- ,
- e.prototype._createPlayer = function() {
- return $.when(W.YouTubePlayer.initialize()).then(function(e) {
- return function() {
- return e._player = new YT.Player(e.id,e.options)
- }
- }(this))
- }
- ,
- e.prototype._onPlayerReady = function() {}
- ,
- e.prototype._onPlayerStateChanged = function() {}
- ,
- e
- }(),
- W.YouTubePlayer._deferred = null,
- W.YouTubePlayer.initialize = function() {
- return this._promise || (this._promise = this._loadAPI())
- }
- ,
- W.YouTubePlayer._loadAPI = function() {
- var e;
- return e = $.Deferred(),
- $.getScript("https://www.youtube.com/player_api"),
- window.onYouTubePlayerAPIReady = function() {
- return function() {
- return delete window.onYouTubePlayerAPIReady,
- e.resolve()
- }
- }(),
- e.promise()
- }
- }
- .call(this),
- function() {
- W.DeleteAccountView = function() {
- function e(e) {
- this.el = $(e),
- this.ui = this._findUiElements(),
- this.params = W_.QueryParams.all(),
- this._checkAuthenticationType(),
- this.ui.form.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.onSubmit()
- }
- }(this)),
- this.useRTSession ? this._removeLoading() : W.userService.ensureLoggedIn().done(function(e) {
- return function() {
- return e._removeLoading()
- }
- }(this)),
- this.ui.proceedButton.on("click", function(e) {
- return function() {
- return e._moveToStep(e.STEPS.VALIDATION)
- }
- }(this))
- }
- return e.prototype.STEPS = {
- EXPLANATION: 1,
- VALIDATION: 2,
- CONFIRMATION: 3
- },
- e.prototype.ERROS_CODES = {
- 422: "invalid-credentials",
- 423: "invalid-captcha",
- 500: "general-error"
- },
- e.prototype.DEFAULT_ERROR_CODE = 500,
- e.prototype.params = null,
- e.prototype.useRTSession = !1,
- e.prototype.requireUsername = !0,
- e.prototype.requirePassword = !0,
- e.prototype.userActivated = !0,
- e.prototype.idToEnv = {
- 1: null,
- 2: "usa",
- 3: "row",
- 4: "il",
- il: "il",
- usa: "usa",
- row: "row"
- },
- e.prototype.confirmationMessageDelay = 5e3,
- e.prototype._removeLoading = function() {
- return this.ui.loading.remove(),
- this.ui.username.toggle(this.requireUsername),
- this.ui.password.toggle(this.requirePassword),
- this.ui.mainView.removeClass("hidden"),
- this._moveToStep(this.STEPS.EXPLANATION),
- this._createCaptcha()
- }
- ,
- e.prototype._createCaptcha = function() {
- return Recaptcha.create("6LdJPuESAAAAAHLXqxOvZIYxyUzSMJv2U31HXqsA", "recaptcha", {
- theme: "clean",
- callback: Recaptcha.focus_response_field
- })
- }
- ,
- e.prototype._findUiElements = function() {
- return {
- form: this.el.find("form"),
- loading: this.el.find(".main-loading"),
- mainView: this.el.find(".delete-account-view"),
- submitButton: this.el.find(".step2 button"),
- proceedButton: this.el.find(".proceed"),
- username: this.el.find("input[name=username]"),
- password: this.el.find("input[name=password]"),
- errorMessages: this.el.find(".error-message"),
- spinner: this.el.find(".loading")
- }
- }
- ,
- e.prototype._moveToStep = function(e) {
- return $(".step").addClass("hidden"),
- this.el.find(".step" + e).removeClass("hidden")
- }
- ,
- e.prototype.validate = function() {
- var e;
- return e = 1,
- this.requireUsername && (e &= this.ui.form.validatePresenceOf("username")),
- this.requirePassword && (e &= this.ui.form.validatePresenceOf("password")),
- 1 === e
- }
- ,
- e.prototype._getErrorCode = function(e) {
- try {
- return JSON.parse(e.responseText).code
- } catch (e) {
- return this.DEFAULT_ERROR_CODE
- }
- }
- ,
- e.prototype._checkAuthenticationType = function() {
- return this.useRTSession = this.params.sessionid && this.params.cookie,
- this.userActivated = "T" === this.params.activated,
- this.requireUsername = !this.useRTSession,
- this.requirePassword = !this.useRTSession || this.userActivated
- }
- ,
- e.prototype._getUsersProfileURL = function() {
- var e, t;
- return this.useRTSession ? (t = "",
- e = this.idToEnv[this.params.env],
- "usa" !== e && null != e && (t = e + "-"),
- "/" + t + "UsersProfile/account/delete_mobile") : "/UsersProfile/account/delete"
- }
- ,
- e.prototype._getRTSessionParams = function() {
- return _(this.params).pick("sessionid", "cookie", "rtserver-id")
- }
- ,
- e.prototype.onSubmit = function() {
- var e;
- if (!this.ui.submitButton.hasClass("disabled") && this.validate() && confirm(this.ui.submitButton.data("alert-message")))
- return this.ui.spinner.removeClass("hidden"),
- this.ui.submitButton.addClass("disabled"),
- this.ui.errorMessages.addClass("hidden"),
- e = {
- username: this.ui.username.val(),
- password: this.ui.password.val(),
- recaptcha_challenge_field: $("#recaptcha_challenge_field").val(),
- recaptcha_response_field: $("#recaptcha_response_field").val()
- },
- this.useRTSession && (e = _.extend(e, this._getRTSessionParams())),
- $.post(this._getUsersProfileURL(), e).done(function(e) {
- return function() {
- if (e.useRTSession || (W.userService.clearSession(),
- W.loginView.hideLoggedInUser()),
- e._moveToStep(e.STEPS.CONFIRMATION),
- e.useRTSession)
- return window.setTimeout(function() {
- return e._notifyClient()
- }, e.confirmationMessageDelay)
- }
- }(this)).fail(function(e) {
- return function(t) {
- var n, r;
- return n = e._getErrorCode(t),
- r = e.ERROS_CODES[n] || e.ERROS_CODES[e.DEFAULT_ERROR_CODE],
- e.el.find(".error-message." + r).removeClass("hidden"),
- Recaptcha.reload()
- }
- }(this)).always(function(e) {
- return function() {
- return e.ui.spinner.addClass("hidden"),
- e.ui.submitButton.removeClass("disabled")
- }
- }(this))
- }
- ,
- e.prototype._notifyClient = function() {
- return this.params.rider ? null != ("undefined" != typeof androidInterface && null !== androidInterface ? androidInterface.clientCallback : void 0) ? androidInterface.clientCallback(this.params.token) : "undefined" != typeof iosInterface_deleteAccountToken && null !== iosInterface_deleteAccountToken ? iosInterface_deleteAccountToken(this.params.token) : void 0 : W.Util.redirect("waze://?delete_account=" + this.params.token + "&nl=T")
- }
- ,
- e
- }(),
- document.querySelector("body#user-delete_account") && document.addEventListener("DOMContentLoaded", function() {
- return W.view = new W.DeleteAccountView(".container")
- })
- }
- .call(this),
- function() {
- W.DownloadRedirectorView = function() {
- function e(e) {
- var t;
- null == e && (e = {}),
- _.defaults(e, this.defaults()),
- t = W_.QueryParams.all(),
- (e.redirect || "true" === t.auto_redirect) && this._redirect(t, e)
- }
- return e.prototype.defaults = function() {
- return {
- redirect: !1,
- desktop_destination: "/" + W.LocaleService.getPageLocale(),
- mobile_destinations: gon.data.links.download_urls
- }
- }
- ,
- e.prototype._redirect = function(e, t) {
- var n;
- return delete e.auto_redirect,
- n = this._getDeviceUrl(t),
- null != n ? (this._sanitizeParams(e),
- n = this._addParams(n, e),
- setTimeout(function() {
- return W.Util.redirect(t.desktop_destination)
- }, 1e3),
- W.Util.redirect(n)) : W_.isBlank(t.desktop_destination) ? void 0 : W.Util.redirect(t.desktop_destination)
- }
- ,
- e.prototype._getDeviceUrl = function(e) {
- var t;
- return t = W_.Browser.getDeviceType(),
- "other" !== t ? e.mobile_destinations[t] : null
- }
- ,
- e.prototype._addParams = function(e, t) {
- return t = $.param(t),
- 0 === t.length ? e : -1 !== e.indexOf("?") ? e + "&" + t : e + "?" + t
- }
- ,
- e.prototype._sanitizeParams = function(e) {
- var t, n, r, i, o;
- for (i = ["appid", "mt", "id", "fake_device", "noop"],
- o = [],
- t = 0,
- r = i.length; t < r; t++)
- n = i[t],
- o.push(delete e[n]);
- return o
- }
- ,
- e
- }(),
- document.querySelector("body#home-download") && (W.view = new W.DownloadRedirectorView)
- }
- .call(this),
- function() {
- var e, t = function(e, t) {
- return function() {
- return e.apply(t, arguments)
- }
- }, n = function(e, t) {
- function n() {
- this.constructor = e
- }
- for (var i in t)
- r.call(t, i) && (e[i] = t[i]);
- return n.prototype = t.prototype,
- e.prototype = new n,
- e.__super__ = t.prototype,
- e
- }, r = {}.hasOwnProperty;
- W.ForgotPasswordView = function(e) {
- function r() {
- return this.resendSmsOnSuccess = t(this.resendSmsOnSuccess, this),
- this.sendSmsOnSuccess = t(this.sendSmsOnSuccess, this),
- this.sendEmailOnSuccess = t(this.sendEmailOnSuccess, this),
- r.__super__.constructor.apply(this, arguments)
- }
- return n(r, e),
- r.prototype.sendSmsUrl = "/UsersProfile/password/change_on_mobile",
- r.prototype.sendEmailUrl = "/UsersProfile/password/reset",
- r.prototype.countryCodesUrl = "/UsersProfile/info/countryCodes",
- r.prototype.environment = "web",
- r.prototype.template = function() {}
- ,
- r.prototype.initialize = function() {
- return this.ajaxInProgress = !1,
- this.phoneData = null,
- this.countryCodes = []
- }
- ,
- r.prototype.ui = {
- loading: ".main-loading",
- sendSmsForm: ".send-sms-form",
- resendSmsForm: ".resend-sms-form",
- sendEmailForm: ".send-email-form",
- forgotPassStep1: ".forgot-password-step1",
- forgotPassStep2: ".forgot-password-step2",
- resendSms: ".resend-sms",
- openApp: ".open-app",
- countryCodesSelect: "#country-codes",
- phone: "#phone",
- email: "[name=email]",
- register: ".register"
- },
- r.prototype.onRender = function() {
- return this.isStartedFromWazeApp() ? this.renderForWazeApp() : this.buildCountriesList(),
- this.ui.sendSmsForm.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.sendSms()
- }
- }(this)),
- this.ui.resendSmsForm.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.resendSms()
- }
- }(this)),
- this.ui.sendEmailForm.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.sendEmail()
- }
- }(this))
- }
- ,
- r.prototype.isStartedFromWazeApp = function() {
- return W_.QueryParams.has("from_app")
- }
- ,
- r.prototype.renderForWazeApp = function() {
- return this.$el.addClass("from-app"),
- this._removeLoading()
- }
- ,
- r.prototype.buildCountriesList = function() {
- return gon.countryCodes ? (this.countryCodes = gon.countryCodes,
- this.parseCoutriesList(),
- this._removeLoading()) : this.loadCountriesList()
- }
- ,
- r.prototype.loadCountriesList = function() {
- return $.get(this.countryCodesUrl).done(function(e) {
- return function(t) {
- return e.countryCodes = t,
- e.parseCoutriesList()
- }
- }(this)).always(function(e) {
- return function() {
- return e._removeLoading()
- }
- }(this))
- }
- ,
- r.prototype.parseCoutriesList = function() {
- var e, t, n, r, i, o, s, a;
- for (t = W.location.attributes.name,
- o = [],
- s = this.countryCodes,
- n = 0,
- r = s.length; n < r; n++)
- e = s[n],
- a = e[0] + " (+" + e[1] + ")",
- i = $("<option>").text(a).val(e[2]),
- t === e[0] && i.attr("selected", !0),
- o.push(i);
- return this.ui.countryCodesSelect.append(o)
- }
- ,
- r.prototype.isValidEmail = function() {
- return this.ui.sendEmailForm.validateEmailAddress("email")
- }
- ,
- r.prototype._removeLoading = function() {
- return this.ui.loading.addClass("hidden"),
- this.ui.forgotPassStep1.removeClass("hidden"),
- this.ui.register.removeClass("hidden")
- }
- ,
- r.prototype.disableForm = function(e) {
- return e.find(".loading").removeClass("hidden"),
- e.find("button").addClass("disabled"),
- e.find(".error-message").addClass("hidden"),
- e.find(".success-message").addClass("hidden")
- }
- ,
- r.prototype.enableForm = function(e) {
- return e.find(".loading").addClass("hidden"),
- e.find("button").removeClass("disabled")
- }
- ,
- r.prototype.showSuccessMessage = function(e) {
- return e.find(".success-message").removeClass("hidden"),
- e.find(".error-message").addClass("hidden")
- }
- ,
- r.prototype.showErrorMessage = function(e) {
- return e.find(".success-message").addClass("hidden"),
- e.find(".error-message").removeClass("hidden")
- }
- ,
- r.prototype.sendEmail = function() {
- var e;
- return this.isValidEmail() ? (e = {
- email: this.ui.email.val(),
- env: this.environment
- },
- this.submitForm(this.ui.sendEmailForm, e, this.sendEmailOnSuccess, this.sendEmailUrl)) : void this.showErrorMessage(this.ui.sendEmailForm)
- }
- ,
- r.prototype.sendEmailOnSuccess = function() {
- return this.showSuccessMessage(this.ui.sendEmailForm)
- }
- ,
- r.prototype.sendSms = function() {
- return this.phoneData = {
- region: this.ui.countryCodesSelect.val(),
- phone: this.ui.phone.val()
- },
- this.submitForm(this.ui.sendSmsForm, this.phoneData, this.sendSmsOnSuccess, this.sendSmsUrl)
- }
- ,
- r.prototype.sendSmsOnSuccess = function() {
- return this.ui.forgotPassStep1.addClass("hidden"),
- this.ui.forgotPassStep2.removeClass("hidden")
- }
- ,
- r.prototype.resendSms = function() {
- return this.submitForm(this.ui.resendSmsForm, this.phoneData, this.resendSmsOnSuccess, this.sendSmsUrl)
- }
- ,
- r.prototype.resendSmsOnSuccess = function() {
- return this.ui.resendSms.addClass("hidden"),
- this.ui.openApp.removeClass("hidden")
- }
- ,
- r.prototype.submitForm = function(e, t, n, r) {
- if (!this.ajaxInProgress)
- return this.disableForm(e),
- this.ajaxInProgress = !0,
- t.locale = I18n.locale,
- $.post(r, t).done(function() {
- return function() {
- return n()
- }
- }()).fail(function(t) {
- return function() {
- return t.showErrorMessage(e)
- }
- }(this)).always(function(t) {
- return function() {
- return t.ajaxInProgress = !1,
- t.enableForm(e)
- }
- }(this))
- }
- ,
- r
- }(Marionette.ItemView),
- document.querySelector("body#user-forgot_password") && (e = $(".forgot-password-page"),
- e.length && (W.forgotPasswordView = new W.ForgotPasswordView({
- el: e
- }),
- W.forgotPasswordView.render()))
- }
- .call(this),
- function() {
- var e = function(e, n) {
- function r() {
- this.constructor = e
- }
- for (var i in n)
- t.call(n, i) && (e[i] = n[i]);
- return r.prototype = n.prototype,
- e.prototype = new r,
- e.__super__ = n.prototype,
- e
- }
- , t = {}.hasOwnProperty;
- W.HeaderView = function(t) {
- function n() {
- return n.__super__.constructor.apply(this, arguments)
- }
- return e(n, t),
- n.prototype.el = ".waze-header",
- n.prototype.ui = {
- togglable: ".waze-caret, .waze-header-menu"
- },
- n.prototype.events = {
- "click .waze-header-brand": "onHeaderClicked"
- },
- n.prototype.initialize = function() {
- return this.bindUIElements()
- }
- ,
- n.prototype.onHeaderClicked = function() {
- return this._toggleMenu()
- }
- ,
- n.prototype._toggleMenu = function() {
- return this.ui.togglable.toggleClass("opened closed")
- }
- ,
- n
- }(Backbone.Marionette.ItemView),
- W.HeaderView_v2 = function(t) {
- function n() {
- return n.__super__.constructor.apply(this, arguments)
- }
- return e(n, t),
- n.prototype.el = ".wz-header",
- n.prototype.events = {
- "click .wz-header__hamburger": "onHeaderClicked"
- },
- n.prototype.onHeaderClicked = function() {
- return this._toggleMenu()
- }
- ,
- n.prototype._toggleMenu = function() {
- return this.$el.toggleClass("wz-header--opened")
- }
- ,
- n
- }(Backbone.Marionette.ItemView),
- $(function() {
- return new W.HeaderView,
- new W.HeaderView_v2
- })
- }
- .call(this),
- function() {
- W.LoginView = function() {
- function e(e) {
- this.captcha = null,
- this.el = $(e),
- this.ui = this._findUiElements(),
- this.ui.form.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.onSubmit()
- }
- }(this)),
- this.ui.loginButton.click(function(e) {
- return function() {
- return setTimeout($.proxy(e.focusUsername, e), 0)
- }
- }(this))
- }
- return e.CAPTCHA_ERROR_CODE = 429,
- e.prototype.focusUsername = function() {
- if (this.ui.username.is(":visible"))
- return this.ui.username.focus()
- }
- ,
- e.prototype._findUiElements = function() {
- return {
- form: this.el.find("form"),
- loading: this.el.find(".loading"),
- submitButton: this.el.find("button"),
- username: this.el.find("input[name=username]"),
- password: this.el.find("input[name=password]"),
- loginButton: this.el.find(".login-button"),
- loggedInUser: this.el.find(".logged-in-user"),
- errorMessage: this.el.find(".error-message"),
- logoutButton: this.el.find(".logout-button"),
- dashboardButton: this.el.find(".dashboard-button"),
- loggedInItems: this.el.find(".logged-in-items"),
- captchaContainer: this.el.find(".captcha-container")
- }
- }
- ,
- e.prototype.validate = function() {
- return 1 === (this.ui.form.validatePresenceOf("username") & this.ui.form.validatePresenceOf("password"))
- }
- ,
- e.prototype.onSubmit = function() {
- var e;
- if (!this.ui.submitButton.hasClass("disabled"))
- return this.validate() ? (this.ui.loading.removeClass("wz-hidden"),
- this.ui.submitButton.addClass("disabled"),
- this.ui.errorMessage.text("").addClass("wz-hidden"),
- W.userService.login(this.ui.username.val(), this.ui.password.val(), null != (e = this.captcha) ? e.getResponse() : void 0).always(function(e) {
- return function() {
- return e.ui.loading.addClass("wz-hidden"),
- e.ui.submitButton.removeClass("disabled")
- }
- }(this)).done(function(e) {
- return function(t) {
- return e.shouldUseRedirect() ? e.redirect() : e.showLoggedInUser(t)
- }
- }(this)).fail(function(e) {
- return function(t) {
- return t.code === e.constructor.CAPTCHA_ERROR_CODE ? e.createCaptcha() : (e.showLoginError(t.message),
- null != e.captcha ? e.captcha.reset() : void 0)
- }
- }(this))) : void 0
- }
- ,
- e.prototype.shouldUseRedirect = function() {
- return this.el.hasClass("login-page") || this.el.hasClass("login-after-reset")
- }
- ,
- e.prototype.showLoggedInUser = function(e) {
- return this.ui.loginButton.addClass("wz-hidden"),
- this.ui.loggedInUser.text(this._getWelcomeText(e)),
- this.ui.loggedInItems.removeClass("wz-hidden"),
- this.ui.username.val(""),
- this.ui.password.val(""),
- this.ui.submitButton.removeClass("disabled"),
- this.ui.loading.addClass("wz-hidden")
- }
- ,
- e.prototype._getWelcomeText = function(e) {
- return I18n.t("application.header_login.hi", {
- user: e.getFullName()
- })
- }
- ,
- e.prototype.redirect = function() {
- var e;
- return e = W_.QueryParams.get("redirect") || "/",
- "/" !== e.charAt(0) && (e = "/" + e),
- this._redirectToUrl(e)
- }
- ,
- e.prototype._redirectToUrl = function(e) {
- return window.location.href = e
- }
- ,
- e.prototype.showLoginError = function(e) {
- return e = this.localizeErrorMessage(e),
- this.ui.errorMessage.text(e).removeClass("wz-hidden"),
- this.ui.loading.addClass("wz-hidden"),
- this.ui.submitButton.removeClass("disabled")
- }
- ,
- e.prototype.createCaptcha = function() {
- if (!this.captcha)
- return this.captcha = new W.Recaptcha(this.ui.captchaContainer),
- this.captcha.show()
- }
- ,
- e.prototype.checkIfAlreadyLoggedIn = function() {
- var e;
- return e = W.userService.getCurrent(),
- $.when(e).done(function(e) {
- return function(t) {
- return null != t ? e.showLoggedInUser(t) : e.ui.loginButton.removeClass("wz-hidden")
- }
- }(this))
- }
- ,
- e.prototype.getErrorKey = function(e) {
- return null != e && e.length > 0 ? e.toLowerCase().replace(/\ +/g, "_").replace(/[^a-zA-Z_]/g, "").replace(/^_*/, "").replace(/_*$/, "") : "unknown_error"
- }
- ,
- e.prototype.localizeErrorMessage = function(e) {
- var t;
- return t = this.getErrorKey(e),
- I18n.t("application.header_login.errors." + t, {
- defaultValue: e
- })
- }
- ,
- e
- }(),
- $(function() {
- var e;
- if (e = $(".login-page"),
- e.length > 0 && (W.loginPage = new W.LoginView(e),
- W.loginPage.checkIfAlreadyLoggedIn()),
- e = $(".login-after-reset"),
- e.length > 0)
- return W.loginPage = new W.LoginView(e),
- W.loginPage.checkIfAlreadyLoggedIn()
- })
- }
- .call(this),
- function() {
- var e;
- W.ResetPasswordView = function() {
- function e(e) {
- this.el = $(e),
- this.ui = this._findUiElements(),
- this.ui.form.submit(function(e) {
- return function(t) {
- return t.preventDefault(),
- e.onSubmit()
- }
- }(this)),
- this.passwordReset = !1,
- this.verifyToken()
- }
- return e.prototype._findUiElements = function() {
- return {
- form: this.el.find("form"),
- loading: this.el.find(".loading"),
- submitButton: this.el.find("button"),
- tokenExpiredErrorMessage: this.el.find(".token-expired-error-message"),
- errorMessage: this.el.find(".error-message"),
- successMessage: this.el.find(".success-message"),
- pageLoad: this.el.find(".main-loading"),
- view: this.el.find(".reset-password-view")
- }
- }
- ,
- e.prototype.verifyToken = function() {
- return this.token = W_.QueryParams.get("uuid"),
- $.get("/UsersProfile/password/testuuid", {
- uuid: this.token
- }).done(function(e) {
- return function() {
- return e.ui.view.removeClass("hidden")
- }
- }(this)).error(function(e) {
- return function() {
- return e.ui.tokenExpiredErrorMessage.removeClass("hidden")
- }
- }(this)).always(function(e) {
- return function() {
- return e.ui.pageLoad.addClass("hidden")
- }
- }(this))
- }
- ,
- e.prototype.validate = function() {
- return 1 == (this.ui.form.validatePresenceOf("password") & this.ui.form.validatePresenceOf("password_confirmation") & this.ui.form.validateEquals("password_confirmation", this.getPassword(), I18n.t("home.reset_password.errors.match")))
- }
- ,
- e.prototype.getPassword = function() {
- return this.ui.form.find("input[name=password]").val()
- }
- ,
- e.prototype.getForceLogin = function() {
- return this.ui.form.find("#force_logins").is(":checked")
- }
- ,
- e.prototype.onSubmit = function() {
- var e, t;
- if (this.validate() && !this.passwordReset)
- return this.ui.loading.removeClass("hidden"),
- this.ui.submitButton.addClass("disabled"),
- this.ui.errorMessage.addClass("hidden"),
- t = this.getPassword(),
- e = this.getForceLogin(),
- $.post("/UsersProfile/password/update", {
- password: t,
- uuid: this.token,
- force_logins: e
- }).done(function(e) {
- return function() {
- return e.passwordReset = !0,
- e.ui.successMessage.removeClass("hidden"),
- e.ui.view.remove()
- }
- }(this)).fail(function(e) {
- return function(t) {
- var n;
- return n = 406 === t.status ? I18n.t("home.change_password.responses.incorrect_new") : I18n.t("home.reset_password.errors.general"),
- e.ui.errorMessage.removeClass("hidden").text(n)
- }
- }(this)).always(function(e) {
- return function() {
- return e.ui.loading.addClass("hidden"),
- e.ui.submitButton.removeClass("disabled")
- }
- }(this))
- }
- ,
- e
- }(),
- document.querySelector("body#user-reset_password") && (e = $(".reset-password-page"),
- W.resetPasswordView = new W.ResetPasswordView(e))
- }
- .call(this),
- function() {
- var e = function(e, n) {
- function r() {
- this.constructor = e
- }
- for (var i in n)
- t.call(n, i) && (e[i] = n[i]);
- return r.prototype = n.prototype,
- e.prototype = new r,
- e.__super__ = n.prototype,
- e
- }
- , t = {}.hasOwnProperty
- , n = function(e, t) {
- return function() {
- return e.apply(t, arguments)
- }
- };
- W.SelectView = function(t) {
- function n() {
- return n.__super__.constructor.apply(this, arguments)
- }
- return e(n, t),
- n.prototype.tagName = "select",
- n.prototype.itemView = W.SelectView,
- n.prototype.events = {
- change: "_onChange"
- },
- n.prototype.onShow = function() {
- return this.trigger("select:show")
- }
- ,
- n.prototype._onChange = function() {
- var e, t;
- return e = this.$el.val(),
- t = this.children.filter(function(t) {
- return t.getValue() === e
- }),
- this._selectedView = t[0]
- }
- ,
- n.prototype.getSelectedView = function() {
- return null == this._selectedView && this._setSelectedView(),
- this._selectedView
- }
- ,
- n
- }(Marionette.CollectionView),
- W.SelectOptionView = function(t) {
- function r() {
- return this.template = n(this.template, this),
- r.__super__.constructor.apply(this, arguments)
- }
- return e(r, t),
- r.prototype.tagName = "option",
- r.prototype.template = function() {
- return this.getText()
- }
- ,
- r.prototype.getText = function() {
- return this.model.get("text")
- }
- ,
- r.prototype.getValue = function() {
- return this.model.get("value")
- }
- ,
- r.prototype.onRender = function() {
- return this.$el.attr({
- value: this.getValue()
- })
- }
- ,
- r
- }(Marionette.ItemView)
- }
- .call(this),
- function() {
- W.VideosView = function() {
- function e(e) {
- this.$el = $(e),
- this.ui = {
- iframe: this.$el.find("iframe"),
- guidedTourButton: this.$el.find(".guided-tour-button")
- },
- null != this.$el.data("video-id") && this.showVideo(this.$el.data("video-id"), {
- autoplay: 0
- }),
- this.$el.on("click", ".guided-tour-button, .screenshot", function(e) {
- return function(t) {
- return t.preventDefault(),
- t.stopPropagation(),
- e.showVideo(e.ui.guidedTourButton.data("video-id"))
- }
- }(this))
- }
- return e.prototype.showVideo = function(e, t) {
- return null == t && (t = {}),
- this.$el.addClass("playing"),
- this.ui.iframe.removeClass("hidden"),
- this.ui.iframe.prop("src", this.getVideoUrl(e, t))
- }
- ,
- e.prototype.getVideoUrl = function(e, t) {
- var n;
- return null == t && (t = {}),
- n = _.defaults(t, {
- feature: "player_embedded",
- autoplay: 1,
- modestbranding: 1,
- showinfo: 0,
- showsearch: 0,
- wmode: "transparent",
- autohide: 1,
- controls: 1
- }),
- "https://www.youtube.com/embed/" + e + "?" + $.param(n)
- }
- ,
- e
- }(),
- $(function() {
- var e;
- if (e = $(".videos-view"),
- e.length)
- return W.videosView = new W.VideosView(e)
- })
- }
- .call(this),
- function() {
- W_.Browser.addDeviceTypeClassToBody()
- }
- .call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement