﻿(function (c) { var a = c.scrollTo = function (f, e, d) { c(window).scrollTo(f, e, d) }; a.defaults = { axis: "y", duration: 1 }; a.window = function (d) { return c(window).scrollable() }; c.fn.scrollable = function () { return this.map(function () { var g = this.parentWindow || this.defaultView, e = this.nodeName == "#document" ? g.frameElement || g : this, f = e.contentDocument || (e.contentWindow || e).document, d = e.setInterval; return e.nodeName == "IFRAME" || d && c.browser.safari ? f.body : d ? f.documentElement : this }) }; c.fn.scrollTo = function (f, e, d) { if (typeof e == "object") { d = e; e = 0 } if (typeof d == "function") { d = { onAfter: d} } d = c.extend({}, a.defaults, d); e = e || d.speed || d.duration; d.queue = d.queue && d.axis.length > 1; if (d.queue) { e /= 2 } d.offset = b(d.offset); d.over = b(d.over); return this.scrollable().each(function () { var m = this, k = c(m), l = f, j, h = {}, n = k.is("html,body"); switch (typeof l) { case "number": case "string": if (/^([+-]=)?\d+(px)?$/.test(l)) { l = b(l); break } l = c(l, this); case "object": if (l.is || l.style) { j = (l = c(l)).offset() } } c.each(d.axis.split(""), function (r, s) { var t = s == "x" ? "Left" : "Top", v = t.toLowerCase(), q = "scroll" + t, o = m[q], p = s == "x" ? "Width" : "Height", u = p.toLowerCase(); if (j) { h[q] = j[v] + (n ? 0 : o - k.offset()[v]); if (d.margin) { h[q] -= parseInt(l.css("margin" + t)) || 0; h[q] -= parseInt(l.css("border" + t + "Width")) || 0 } h[q] += d.offset[v] || 0; if (d.over[v]) { h[q] += l[u]() * d.over[v] } } else { h[q] = l[v] } if (/^\d+$/.test(h[q])) { h[q] = h[q] <= 0 ? 0 : Math.min(h[q], g(p)) } if (!r && d.queue) { if (o != h[q]) { i(d.onAfterFirst) } delete h[q] } }); i(d.onAfter); function i(o) { k.animate(h, e, d.easing, o && function () { o.call(this, f, d) }) } function g(p) { var o = "scroll" + p, q = m.ownerDocument; return n ? Math.max(q.documentElement[o], q.body[o]) : m[o] } }).end() }; function b(d) { return typeof d == "object" ? d : { top: d, left: d} } })(jQuery); (function ($) { $.extend({ metadata: { defaults: { type: "class", name: "metadata", cre: /({.*})/, single: "metadata" }, setType: function (type, name) { this.defaults.type = type; this.defaults.name = name }, get: function (elem, opts) { var settings = $.extend({}, this.defaults, opts); if (!settings.single.length) { settings.single = "metadata" } var data = $.data(elem, settings.single); if (data) { return data } data = "{}"; if (settings.type == "class") { var m = settings.cre.exec(elem.className); if (m) { data = m[1] } } else { if (settings.type == "elem") { if (!elem.getElementsByTagName) { return } var e = elem.getElementsByTagName(settings.name); if (e.length) { data = $.trim(e[0].innerHTML) } } else { if (elem.getAttribute != undefined) { var attr = elem.getAttribute(settings.name); if (attr) { data = attr } } } } if (data.indexOf("{") < 0) { data = "{" + data + "}" } data = eval("(" + data + ")"); $.data(elem, settings.single, data); return data } } }); $.fn.metadata = function (opts) { return $.metadata.get(this[0], opts) } })(jQuery); var modalDialog = { visible: false, width: 300, subscriptionData: null, subscriptionDataType: null, toggleVisibility: function (a) { if (!this.visible) { $("#" + a).show(); $(".modal-overlay").show(); $(".modal-wrapper").show(); $(".modal-wrapper").css({ width: this.width + "px", marginLeft: ((this.width / 2) * -1) + "px", marginTop: (($(".modal-wrapper").height() / 2) * -1) + "px" }); this.visible = true } else { $(".validation-container").hide(); $(".modal-content-container").hide(); $(".modal-overlay").hide(); $(".modal-wrapper").hide(); this.visible = false } }, submitSubscribe: function (a) { var e = true; var d = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; var b = 0; var c = 42; if ($(a).val() == "" || !d.test($(a).val())) { e = false; $(".validation-container").show(); $(".validation-container").css({ top: $(a).position().top + c, left: $(a).position().left + b }) } else { e = true; $(".validation-container").hide() } if (e) { $(".modal-content-container").hide(); $(".modal-loading").show(); PageMethods.AddSubscriptionDetail($(a).val(), this.subscriptionDataType, this.subscriptionData, this.AddSubscriptionDetail_Added, this.AddSubscriptionDetail_Added, $(a).val()) } }, deleteSubscription: function (a, b) { $(b).find("td").find(".subscription-name-container").css("background-image", "url(/images/subscription-delete-loader.gif)"); PageMethods.DeleteSubscriptionDetail(a, this.DeleteSubscriptionDetail_Deleted, this.DeleteSubscriptionDetail_Error, b) }, resendConfirmation: function () { $(".resend-tooltip-header").hide(); $(".resend-tooltip-description").hide(); $(".resend-tooltip-loading").show(); PageMethods.SendConfirmationEmail(subscriptionUser, this.SendConfirmationEmail_Sent, this.SendConfirmationEmail_Error) }, AddSubscriptionDetail_Added: function (a, b) { $(".modal-loading").hide(); CreateSubscriptionCookie(b); $("#SubManagerLink").html("Manage My Subscriptions"); $("#SubManagerLink").unbind("click"); $("#SubManagerLink").click(function () { modalDialog.subscriptionData = null; modalDialog.subscriptionDataType = null; modalDialog.toggleVisibility("divSubscriptionManagement") }); modalDialog.width = 400; subscriptionUser = b; $("#SubscriptionUser").html(b); if (!a.IsActive) { $(".confirmed-link").html("Not confirmed"); $(".description").html("You've been successfully subscribed! To start receiving your subscriptions, we need you to confirm your email address by following the instructions in your confirmation email.") } $("#divSubscriptionManagement").show(); $(".modal-wrapper").css({ width: modalDialog.width + "px", marginLeft: ((modalDialog.width / 2) * -1) + "px", marginTop: (($(".modal-wrapper").height() / 2) * -1) + "px" }); modalDialog.addRows(a); userIsSubscribed = true }, addRows: function (a) { if ($(".subscription-mgmt-table").length == 0) { $("#divSubscriptionManagement").find(".description").after($(document.createElement("table")).addClass("subscription-mgmt-table")); $(".subscription-mgmt-empty").hide() } else { $(".subscription-mgmt-table").find("tr").remove() } for (var b in a) { $(".subscription-mgmt-table").append($(document.createElement("tr")).addClass("subscription-mgmt-row").append($(document.createElement("td")).append($(document.createElement("div")).addClass("subscription-name-container").append(document.createTextNode(a[b].SubscriptionName)))).append($(document.createElement("td")).addClass("subscription-link-container").append($(document.createElement("div")).append($(document.createElement("a")).attr("id", a[b].SubscriptionDetailId).attr("href", "javascript:void(0);").addClass("unsubscribe-link").click(function () { modalDialog.deleteSubscription($(this).attr("id"), $(this).parent().parent().parent()) }).append(document.createTextNode("Unsubscribe")))))) } }, DeleteSubscriptionDetail_Deleted: function (a, b) { if ($(".subscription-mgmt-row").length == 1) { $(".subscription-mgmt-table").remove(); $("#divSubscriptionManagement").find(".description").after($(document.createElement("div")).addClass("subscription-mgmt-empty").append(document.createTextNode("- No active subscriptions found -"))) } $(b).remove() }, SendConfirmationEmail_Sent: function (a) { $(".resend-tooltip-loading").hide(); $(".resend-tooltip-header").html("Your confirmation email has been resent").show(); $(".resend-tooltip-description").html("Please check your inbox and follow the instructions to confirm you subscription.").show() }, AddSubscriptionDetail_Error: function (a) { $(".modal-loading").hide() }, DeleteSubscriptionDetail_Error: function (a) { }, SendConfirmationEmail_Error: function (a) { $(".resend-tooltip-loading").hide(); $(".resend-tooltip-header").html("Confirmation email failure.").show(); $(".resend-tooltip-description").html("Please consult CouponTweet support if you feel that this is an error.").show() } }; function TweetModal() { this.Container; this.Overlay; this.Visible = false; this.ShowModal = function (b, a) { var c = this; this.Container.css({ display: "block", width: b, height: a, top: this.GetPositionTop(a), left: this.GetPositionLeft(b) }); this.Overlay.css({ display: "block", height: $(document).height() }); if ($.browser.msie && $.browser.version.substr(0, 1) < 7) { $(document).find("select").css("visibility", "hidden") } this.Visible = true }; this.HideModal = function () { this.Container.css("display", "none"); this.Overlay.css("display", "none"); if ($.browser.msie && $.browser.version.substr(0, 1) < 7) { $(document).find("select").css("visibility", "visible") } this.Visible = false }; this.GetPositionTop = function (a) { return (($(window).height() - a) / 2) }; this.GetPositionLeft = function (a) { return (($(window).width() - a) / 2) } } $(document).ready(function () { var a = 0; var b = 50; $("#lnkMore").hover(function () { $("#divMoreCategoriesHover").css({ display: "block", top: $("#nav").position().top + $("#nav").height() + b, left: $("#nav").position().left + a }); $("#divMoreCategoriesHover").hover(function () { $("#divMoreCategoriesHover").css("display", "block"); $("#lnkMore").css("background-color", "#736765") }, function () { $("#divMoreCategoriesHover").css("display", "none"); $("#lnkMore").css("background-color", "#5D5650") }); $("#lnkMore").css("background-color", "#736765") }, function () { $("#divMoreCategoriesHover").css("display", "none"); $("#lnkMore").css("background-color", "#5D5650") }) }); function TweetUi() { this.tweetData; this.container; this.twitterForm; this.replyContainer; this.tweetControls; this.clip; this.copied = false; this.tweetThisDialogVisible = false; this.replyDialogVisible = false; this.repliesContainerVisible = false; this.shareDialogVisible = false; this.voteDialogVisible = false; this.hasTwitterForm = false; this.init = function () { var c = this; this.tweetData = this.container.metadata({ type: "elem", name: "script" }); var b = new TweetControls(); b.Subscribe = this.container.find(".coupon-subscribe-link"); b.TweetThis = this.container.find(".coupon-tweet-this-link"); b.Reply = this.container.find(".coupon-reply-link"); b.VoteUp = this.container.find(".coupon-vote-up"); b.VoteDown = this.container.find(".coupon-vote-down"); b.Share = this.container.find(".coupon-share-link"); b.VoteReason = this.container.find(".coupon-vote-reason-btn"); this.tweetControls = b; if (this.tweetData.Curl != "") { this.container.click(function () { c.container.append($(document.createElement("img")).attr("src", c.tweetData.Curl).css("display", "none")) }) } this.tweetControls.Subscribe.click(function () { c.subscribeToProvider(c.tweetData.ProviderId) }); this.tweetControls.TweetThis.click(function () { c.toggleTweetThisDialog() }); this.tweetControls.Reply.click(function () { c.toggleRepliesContainer() }); this.tweetControls.VoteUp.click(function () { if (!$(this).hasClass("coupon-vote-up-inactive")) { c.voteUp() } }); this.tweetControls.VoteDown.click(function () { c.voteDown(-1) }); this.tweetControls.Share.click(function () { c.toggleShareDialog() }); this.tweetControls.VoteReason.click(function () { c.toggleReasonsDialog() }); if (this.tweetData.HasReplies == "true") { this.tweetData.HasReplies = true } else { this.tweetData.HasReplies = false } var a = this.tweetData.TweetId + "_copy"; if (this.tweetData.CouponCode != "") { this.clip = new ZeroClipboard.Client(); this.clip.setText(this.tweetData.CouponCode); this.clip.addEventListener("onMouseOver", function (d) { c.CodeHoverIn(d) }); this.clip.addEventListener("onMouseOut", function (d) { c.CodeHoverOut(d) }); this.clip.addEventListener("onMouseUp", function (d) { c.CodeCopied(d) }); this.clip.glue(a, this.container.attr("id")) } }; this.CodeHoverIn = function (a) { $(a.domElement).after($(document.createElement("div")).addClass("HoverText").html(!this.copied ? "< Click to Copy and Open Site" : "< Click to Copy")) }; this.CodeHoverOut = function (a) { $(a.domElement).siblings(".HoverText").remove() }; this.CodeCopied = function (a) { if (!this.copied) { this.copied = true; $(a.domElement).css("background-color", "#FEBF01"); window.open(this.tweetData.OutboundUrl, "_blank") } }; this.appendTwitterForm = function () { var a = this; $("#divReplyContainer").clone().appendTo(this.container).attr("id", ""); $("#divDialogWrapper").clone().appendTo(this.container).attr("id", ""); var c = new TwitterForm(); c.Wrapper = this.container.find(".dialog-wrapper"); c.TextArea = this.container.find(".dialog-textarea"); c.CharCount = this.container.find(".dialog-char-count"); c.SubmitButton = this.container.find(".dialog-submit-btn"); c.UserTextBox = this.container.find(".dialog-username"); c.PasswordTextBox = this.container.find(".dialog-password"); c.ValidationSummary = this.container.find(".dialog-valid-summary"); this.twitterForm = c; var b = new ReplyContainer(); b.Wrapper = this.container.find(".replies-container"); b.Replies = this.container.find(".replies"); b.ReplyButton = this.container.find(".replies-controls-reply"); this.replyContainer = b; this.twitterForm.SubmitButton.click(function () { a.postDialogForm() }); this.twitterForm.TextArea.keyup(function () { charCount(a.twitterForm.TextArea, a.twitterForm.CharCount) }); this.replyContainer.ReplyButton.click(function () { a.toggleReplyDialog() }); this.hasTwitterForm = true }; this.toggleTweetThisDialog = function () { var b = this; var a = "Check out the great " + this.tweetData.ProviderName + " deal I just found on Coupon Tweet " + this.tweetData.ShareUrl; if (!this.hasTwitterForm) { this.appendTwitterForm() } if (this.repliesContainerVisible || this.replyDialogVisible) { this.hideAll() } if (this.tweetThisDialogVisible) { this.twitterForm.Wrapper.slideUp(animeTime); $.scrollTo(this.container, scrollTime, { offset: { top: -10, left: 0} }); this.tweetThisDialogVisible = false } else { this.twitterForm.Wrapper.slideDown(animeTime, function () { b.twitterForm.TextArea.val(a); b.twitterForm.CharCount.html(b.twitterForm.TextArea.val().length) }); $.scrollTo(this.container, scrollTime, { offset: { top: -10, left: 0} }); this.tweetThisDialogVisible = true } }; this.toggleRepliesContainer = function () { if (!this.hasTwitterForm) { this.appendTwitterForm() } if (this.tweetThisDialogVisible) { this.hideAll() } if (this.tweetData.HasReplies && this.repliesContainerVisible) { this.hideAll() } else { if (this.tweetData.HasReplies && !this.repliesContainerVisible) { this.tweetControls.Reply.addClass("coupon-reply-link-loading"); PageMethods.getReplies(this.tweetData.TweetId, null, this.getReplies_Loaded, this.getReplies_Error, this); this.repliesContainerVisible = true } else { this.toggleReplyDialog() } } }; this.toggleReplyDialog = function () { var b = this; var a = "@" + b.tweetData.TwitterUserName; if (!this.hasTwitterForm) { this.appendTwitterForm() } if (this.replyDialogVisible) { this.twitterForm.Wrapper.slideUp(animeTime); this.replyContainer.ReplyButton.removeClass("reply-controls-reply-active"); $.scrollTo(this.container, scrollTime, { offset: { top: -10, left: 0} }); this.replyDialogVisible = false } else { this.twitterForm.Wrapper.slideDown(animeTime, function () { b.twitterForm.TextArea.val(a); b.twitterForm.CharCount.html(b.twitterForm.TextArea.val().length) }); b.replyContainer.ReplyButton.addClass("reply-controls-reply-active"); if (this.repliesContainerVisible) { $.scrollTo(this.container, scrollTime, { offset: { top: 200, left: 0} }) } else { $.scrollTo(this.container, scrollTime, { offset: { top: -10, left: 0} }) } this.replyDialogVisible = true } }; this.hideAll = function () { if (this.tweetThisDialogVisible || this.replyDialogVisible) { this.twitterForm.Wrapper.slideUp(animeTime); this.tweetThisDialogVisible = false; this.replyDialogVisible = false } if (this.repliesContainerVisible) { this.replyContainer.Wrapper.slideUp(animeTime); this.replyContainer.ReplyButton.removeClass("reply-controls-reply-active"); this.repliesContainerVisible = false } this.twitterForm.TextArea.val(""); $.scrollTo(this.container, scrollTime, { offset: { top: -10, left: 0} }) }; this.toggleShareDialog = function () { var g = $(".share-container"); var h = 15; var d = "http://www.digg.com/submit?url=" + this.tweetData.LocalUrl; var a = "http://www.facebook.com/share.php?u=" + this.tweetData.LocalUrl; var c = "http://www.myspace.com/Modules/PostTo/Pages/?u=" + this.tweetData.LocalUrl; var f = "http://delicious.com/save?url=" + this.tweetData.LocalUrl; var b = "http://www.mixx.com/submit?page_url=" + this.tweetData.LocalUrl; if (!this.shareDialogVisible) { for (var e = 0; e < tweetArray.length; ++e) { tweetArray[e].shareDialogVisible = false } g.find(".share-digg").attr("href", d); g.find(".share-facebook").attr("href", a); g.find(".share-myspace").attr("href", c); g.find(".share-delicious").attr("href", f); g.find(".share-mixx").attr("href", b); g.css({ display: "block", left: this.container.find(".coupon-share-link").position().left, top: this.container.find(".coupon-share-link").position().top + h }); this.shareDialogVisible = true } else { g.css("display", "none"); this.shareDialogVisible = false } }; this.toggleReasonsDialog = function () { var c = this; var d = $(".vote-reasons-container"); var e = this.container.find(".coupon-vote-reason-btn"); var b = 18; var f = 3; if (!this.voteDialogVisible) { for (var a = 0; a < tweetArray.length; ++a) { tweetArray[a].voteDialogVisible = false } d.find("a").each(function () { var g = $(this).attr("id"); $(this).unbind("click").click(function () { c.voteDown(g) }) }); d.css({ display: "block", top: e.position().top + $(e).height() + f, left: (e.position().left - d.width()) + e.width() + b }); this.voteDialogVisible = true } else { d.css("display", "none"); this.voteDialogVisible = false } }; this.showUrlPreview = function (g) { var e = -15; var h = 0; var f = $(".screen-shot-container"); var a = $(".screen-shot-wrapper").find("a"); var d = $(".screen-shot"); var b = this.tweetData.DestinationUrl; var c = "http://images.websnapr.com/?size=s&key=UrhNdS34AS90&url=" + b; a.attr("href", b); f.css({ display: "block", top: g.position().top + g.height() + h, left: g.position().left + e }).hover(function () { $(this).css("display", "block") }, function () { $(this).css("display", "none") }); d.css("background-image", "url(" + c + ")") }; this.hideUrlPreview = function () { $(".screen-shot-container").hide() }; this.subscribeToProvider = function (a) { if (userIsSubscribed) { var b = this.container.find(".coupon-subscribe-link")[0]; var d = $(b).position().left + 6; var c = $(b).position().top - 5; var e = $(document.createElement("div")).addClass("subscription-added-fader").css({ top: c, left: d }).append(document.createTextNode("Subscribed")).appendTo("body").fadeOut(3500, function () { $(this).remove() }); $(b).css("visibility", "hidden"); PageMethods.AddSubscriptionDetail(subscriptionUser, "provider", a, this.AddSubscriptionDetail_Added, this.AddSubscriptionDetail_Error, this) } else { $("#ModalTargetTitle").html(this.tweetData.ProviderName); modalDialog.width = 300; modalDialog.subscriptionData = a; modalDialog.subscriptionDataType = "provider"; modalDialog.toggleVisibility("divSubscribe") } }; this.postDialogForm = function () { var a = true; if (!validateRequiredField(this.twitterForm.UserTextBox) | !validateRequiredField(this.twitterForm.PasswordTextBox) | !validateTweetField(this.twitterForm.TextArea)) { $(this.twitterForm.ValidationSummary).show().html("Your Twitter Username, Password, and a Tweet are required."); a = false } if (a) { $(this.twitterForm.ValidationSummary).hide(); if (this.tweetThisDialogVisible) { PageMethods.PostToTwitter(this.tweetData.TweetId, this.twitterForm.UserTextBox.val(), this.twitterForm.PasswordTextBox.val(), this.twitterForm.TextArea.val(), "Retweet", this.PostToTwitter_Posted, this.PostToTwitter_Error, this) } else { PageMethods.PostToTwitter(this.tweetData.TweetId, this.twitterForm.UserTextBox.val(), this.twitterForm.PasswordTextBox.val(), this.twitterForm.TextArea.val(), "Reply", this.PostToTwitter_Posted, this.PostToTwitter_Error, this) } this.twitterForm.Wrapper.find(".dialog").css("display", "none"); this.twitterForm.Wrapper.find(".dialog-loading").css("display", "block") } }; this.voteUp = function () { var a = parseInt(this.container.find(".vote-total").html()); this.container.find(".coupon-vote-up").addClass("coupon-vote-up-inactive"); this.container.find(".coupon-vote-down").addClass("coupon-vote-down-change"); this.container.find(".coupon-vote-up").unbind("click"); this.container.find(".vote-total").fadeOut(500, function () { $(this).html(a + 1); $(this).fadeIn(500) }); $.ajax({ type: "POST", url: "/Json/PostVote", data: { tweetId: this.tweetData.TweetId, voteReasonId: 0, ipAddress: GetIp() }, success: function (b) { this.PostVote_Posted(b) } }) }; this.voteDown = function (a) { this.toggleReasonsDialog(); if (this.tweetThisDialogVisible || this.replyDialogVisible) { this.twitterForm.Wrapper.hide() } if (this.repliesContainerVisible) { this.replyContainer.Wrapper.hide() } this.container.find(".coupon-text > a > span").removeClass().html(""); this.container.find(".coupon-tool-list").hide(); this.container.find(".coupon-controls-wrapper").hide(); this.container.find(".coupon-avatar").fadeTo(1, 0.25); this.container.find(".coupon-body").addClass("body-downvoted"); this.container.find(".coupon-user-link").css("color", "#ADAD91"); this.container.find(".coupon-time").css("color", "#ADAD91"); this.container.find(".coupon-subscribe-link").hide(); $.ajax({ type: "POST", url: "/Json/PostVote", data: { tweetId: this.tweetData.TweetId, voteReasonId: a, ipAddress: GetIp() }, success: function (b) { this.PostVote_Posted(b) } }) }; this.getReplies_Loaded = function (a, c) { c.replyContainer.Replies.html(""); for (var b in a) { c.replyContainer.Replies.append($(document.createElement("div")).addClass("comment-wrapper").append($(document.createElement("a")).attr({ href: "http://www.twitter.com/" + a[b].TwitterUserName, target: "blank" }).append($(document.createElement("img")).addClass("comment-avatar").attr({ src: a[b].TwitterUserImageUrl }))).append($(document.createElement("div")).addClass("comment-carrot")).append($(document.createElement("div")).addClass("comment-body").append($(document.createElement("p")).append($(document.createElement("a")).addClass("comment-user-link").attr({ href: "http://www.twitter.com/" + a[b].TwitterUserName, target: "blank" }).html(a[b].TwitterUserName)).append(document.createTextNode(" - " + a[b].TweetText))).append($(document.createElement("p")).append($(document.createElement("span")).addClass("comment-time-info").html(a[b].TweetTime))))) } c.replyContainer.Wrapper.slideDown(animeTime, function () { c.tweetControls.Reply.removeClass("coupon-reply-link-loading") }); $.scrollTo(c.container, scrollTime, { offset: { top: -10, left: 0} }) }; this.PostVote_Posted = function (a) { }; this.PostToTwitter_Posted = function (a, b) { b.twitterForm.Wrapper.find(".dialog").css("display", "block"); b.twitterForm.Wrapper.find(".dialog-loading").css("display", "none"); if (b.tweetThisDialogVisible) { b.hideAll(); b.container.find(".coupon-tweet-this-link").html("Tweeted!") } else { b.hideAll(); b.replyContainer.Wrapper.find(".comment-wrapper").size() == 0 ? b.tweetControls.Reply.html("1 reply") : b.tweetControls.Reply.html((commentCount + 1) + " replies"); b.hasReplies = true; b.toggleRepliesContainer() } }; this.AddSubscriptionDetail_Added = function (a, b) { if (a) { modalDialog.addRows(a) } }; this.getReplies_Error = function () { }; this.PostVote_Error = function () { }; this.PostToTwitter_Error = function (a, b) { b.twitterForm.Wrapper.find(".dialog").css("display", "block"); b.twitterForm.Wrapper.find(".dialog-loading").css("display", "block"); if (a._message.indexOf("401") != -1) { $(b.twitterForm.ValidationSummary).show().html("Your Twitter username or password was incorrect."); b.twitterForm.UserTextBox.css("background-color", invalidColor); b.twitterForm.PasswordTextBox.css("background-color", invalidColor) } else { $(b.twitterForm.ValidationSummary).show().html("There was an error submitting to Twitter, please try again.") } }; this.AddSubscriptionDetail_Error = function () { } } function TweetControls() { this.Subscribe; this.TweetThis; this.Reply; this.VoteUp; this.VoteDown; this.Share; this.VoteReason } function TwitterForm() { this.Wrapper; this.TextArea; this.CharCount; this.SubmitButton; this.UserTextBox; this.PasswordTextBox; this.ValidationSummary } function ReplyContainer() { this.Wrapper; this.Replies; this.ReplyButton } var scrollTime = 400; var animeTime = 600; var searchTxt = "Store name, keyword, or category"; var invalidColor = "#E4573F"; var validColor = "#736765"; var userIsSubscribed = false; var subscriptionUser = null; var tweetArray = new Array(); $(document).ready(function () { $(".tweetContainer").each(function (a) { tweetArray[a] = new TweetUi(); tweetArray[a].container = $(this); tweetArray[a].init() }); CreateIpCookie(); subscriptionUser = $("#SubscriptionUser").html(); $(".modal-overlay").click(function () { modalDialog.toggleVisibility() }); $(".modal-close-btn").click(function () { modalDialog.toggleVisibility() }); $(".subscribe-button").click(function () { modalDialog.submitSubscribe($(this).parent().find(".email-field")) }); $(".confirmed-link").click(function () { $(".resend-tooltip-container").css({ top: $(".confirmed-link").position().top + 15, left: $(".confirmed-link").position().left }).show() }); $(".validation-close-btn").click(function () { $(this).parent().parent().hide() }); $(".resend-tooltip-close-btn").click(function () { $(this).parent().parent().hide() }); $(".resend-link").click(function () { modalDialog.resendConfirmation() }); $(".email-field").bind("keydown", (function (b) { var a = b.charCode ? b.charCode : b.keyCode ? b.keyCode : 0; if (a == 13) { modalDialog.submitSubscribe($(this)); return false } })); $(".subscription-mgmt-done-btn").click(function () { modalDialog.toggleVisibility() }); $(".unsubscribe-link").click(function () { modalDialog.deleteSubscription($(this).attr("id"), $(this).parent().parent().parent()) }); $(".modal-wrapper").click(function (b) { var a = $(b.target); if (a.is(".resend-tooltip-container") || a.parents().is(".resend-tooltip-container") || a.is(".confirmed-link")) { } else { $(".resend-tooltip-container").hide() } }); if (userIsSubscribed) { $("#SubManagerLink").click(function () { modalDialog.width = 400; modalDialog.subscriptionData = null; modalDialog.subscriptionDataType = null; modalDialog.toggleVisibility("divSubscriptionManagement") }) } else { $("#SubManagerLink").click(function () { modalDialog.width = 300; modalDialog.subscriptionData = 1; modalDialog.subscriptionDataType = "newsletter"; modalDialog.toggleVisibility("divNewsletterSubscribe") }) } $("#searchtxt").attr({ value: searchTxt }).focus(function () { if ($(this).val() == searchTxt) { $(this).val("") } }).blur(function () { if ($(this).val() == "") { $(this).val(searchTxt) } }); $(document).bind("click", function (c) { var a = $(c.target); if (a.is("#liveSearchResults") || a.parents().is("#liveSearchResults") || a.is("#searchtxt")) { for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].shareDialogVisible = false } for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].voteDialogVisible = false } $(".share-container").css("display", "none"); $(".vote-reasons-container").css("display", "none") } else { if (a.is(".share-container") || a.parents().is(".share-container") || a.is(".coupon-share-link")) { $("#liveSearchResults").css("display", "none"); for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].voteDialogVisible = false } $(".vote-reasons-container").css("display", "none") } else { if (a.is(".vote-reasons-container") || a.parents().is(".vote-reasons-container") || a.is(".coupon-vote-reason-btn")) { $("#liveSearchResults").css("display", "none"); for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].shareDialogVisible = false } $(".share-container").css("display", "none") } else { for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].shareDialogVisible = false } for (var b = 0; b < tweetArray.length; ++b) { tweetArray[b].voteDialogVisible = false } $("#liveSearchResults").css("display", "none"); $(".share-container").css("display", "none"); $(".vote-reasons-container").css("display", "none") } } } }); $(".list-footer-add-coupon-link").click(function () { if ($(".empty-page-dialog").css("display") == "none") { $(".empty-page-dialog").slideDown(animeTime) } else { $(".empty-page-dialog").slideUp(animeTime) } }); $(".list-footer-new-search-link").click(function () { $.scrollTo({ top: 0, left: 0 }, 600, { onAfter: function () { $("#searchtxt").focus() } }) }); $("html").css("background-image", "url('/images/bg-scene-extension.gif')"); $("body").css("background-image", "url('/images/bg-scene.gif')"); $("#AutoTweetLink").click(function () { modalDialog.width = 400; modalDialog.subscriptionData = null; modalDialog.subscriptionDataType = null; modalDialog.toggleVisibility("divAutoTweet") }); $(".tweetit-button").click(function () { function a(c) { $("#twtResult").html(c.Message) } function b(c) { $("#twtResult").html("Your login information was not correct; please try again.") } $("#twtResult").show().html("submitting..."); PageMethods.PostToTwitter($("#twtUsername").val(), $("#twtPassword").val(), $("#twtTweet").html(), a, b) }) }); window.onload = function () { $(".coupon-avatar").each(function () { if (imageCheck(this) == false) { $(this).attr("src", "http://static.twitter.com/images/default_profile_normal.png") } }) }; function CreateSubscriptionCookie(c) { var a = new Date(); a.setDate(a.getDate() + 365); var b = "CouponTweetSubscriptionUser=" + c + ";path=/; expires=" + a.toGMTString(); document.cookie = b } function CreateIpCookie() { var a = new Date(); a.setDate(a.getDate() + 365); var b = "CouponTweetIpAddress=" + GetClientIp() + ";path=/; expires=" + a.toGMTString(); document.cookie = b } function charCount(b, a) { $(a).html(140 - $(b).val().length) } function imageCheck(a) { if (!a.complete) { return false } if (typeof a.naturalWidth != "undefined" && a.naturalWidth == 0) { return false } return true } function encodeHtml(b) { var c = document.createElement("div"); var a = document.createTextNode(b); c.appendChild(a); return c.innerHTML } function doSearch() { var a = $("#searchtxt").val().trim(); a = a.replace("+", "plus"); a = a.replace("&", "and"); a = a.replace("/", "-"); a = a.replace("%", " "); a = a.replace(" ", "-"); if (a == searchTxt || !isValidSearch(a)) { return true } else { window.location = "/coupons/search/" + encodeURIComponent(a) + "/" } } String.prototype.trim = function () { return this.replace(/^\screen+/, "").replace(/\screen+$/, "") }; function isValidSearch(b) { if (b == "") { return false } for (var a = 0; a < b.length; ++a) { if (b.toString().charAt(a) != " ") { return true } } return false } var searchBusy = false; function liveSearch(a) { if (a == "") { $("#liveSearchResults").css("display", "none") } else { if (searchBusy == false) { $("#liveSearchResults").css("display", "block"); searchBusy = true; $.ajax({ type: "GET", url: "/Json/LiveSearch", data: { queryString: a }, success: function (b) { getLiveSearchResults_Success(b) } }) } } } function getLiveSearchResults_Success(a, c, b) { searchBusy = false; $("#liveSearchResults").html(a); $("#liveSearchResults > ul > li > a").mouseover(function () { $(this).addClass("searchHover") }); $("#liveSearchResults > ul > li > a").mouseout(function () { $(".searchHover").removeClass("searchHover"); $(this).removeClass("searchHover") }) } function getLiveSearchResults_Error(c, b, a) { } function submitarrow(g, f) { var a; if (window.event) { a = window.event.keyCode } else { if (f) { a = f.which } else { return true } } if (a == 38) { var c = $(".searchHover"); c.removeClass("searchHover"); var d = c.parent(); var b = d.prev(); if (b.length == 0) { d = d.parent().prev().prev(); if (d.length == 0) { return } else { b = d.children(":last") } } b.children().addClass("searchHover"); return } else { if (a == 40) { var c = $(".searchHover"); c.removeClass("searchHover"); if (c.length == 0) { $currNode = $("#liveSearchResults"); $currNode = $currNode.children(":first").next().children(":first").children().addClass("searchHover"); return } var d = c.parent(); var b = d.next(); if (b.length == 0) { d = d.parent().next().next(); if (d.length == 0) { c.addClass("searchHover"); return } else { b = d.children(":first") } } b.children().addClass("searchHover"); return } } return } function submitenter(d, c) { var a; if (window.event) { a = window.event.keyCode } else { if (c) { a = c.which } else { return true } } if (a == 13) { var b = $(".searchHover"); if (b.length != 0) { window.location = b.attr("href"); return false } doSearch(); return false } else { if (a < 37 || a > 40) { liveSearch($("#searchtxt").val()); return } } } function liveSearchHover(a) { alert(a) } function tweetLinkCallback(a) { PageMethods.linkCallback(a) } function GetIp() { var a = "IP Unresolved"; if (typeof GetClientIp == "function") { a = GetClientIp() } return a } function validateRequiredField(a) { if ($(a).val() == "") { $(a).css("background-color", invalidColor); return false } else { $(a).css("background-color", validColor); return true } } function validateTweetField(a) { if ($(a).val().length > 140 || $(a).val() == "") { $(a).css("background-color", invalidColor); return false } else { $(a).css("background-color", validColor); return true } } function postCoupon(a, d) { var c = $(a).parents().filter(".empty-page-dialog"); var e = $(c).find(".dialog-username"); var b = $(c).find(".dialog-password"); var g = $(c).find(".dialog-textarea"); var f = true; if (!validateRequiredField(e) | !validateRequiredField(b) | !validateTweetField(g)) { f = false; $(c).find(".dialog-valid-summary").html("Your Twitter Username, Password, and a Coupon are required.") } if (f) { PageMethods.PostCoupon($(e).val(), $(b).val(), $(g).val(), d, postCoupon_Posted, postCoupon_Error, c); $(c).find(".empty-page-dialog-controls").css("display", "none"); $(c).find(".empty-page-dialog-loading").css("display", "block") } } function postCoupon_Posted(a, b) { window.location = a } function postCoupon_Error(b, a) { $(a).find(".empty-page-dialog-controls").css("display", "block"); $(a).find(".empty-page-dialog-loading").css("display", "none"); var c = $(a).find(".dialog-valid-summary"); if (b._message.indexOf("401") != -1) { $(c).show().html("Your Twitter username or password was incorrect."); $(a).find(".dialog-username").css("background-color", invalidColor); $(a).find(".dialog-password").css("background-color", invalidColor) } else { $(c).show().html("There was an error submitting to Twitter, please try again.") } };
