From 68dd65cc7a623b503a025782d680e6af1413c856 Mon Sep 17 00:00:00 2001 From: John McLear Date: Thu, 31 Jan 2013 01:16:34 +0000 Subject: [PATCH] validation --- README.md | 3 ++- client.js | 4 ++++ ep.json | 5 +++-- package.json | 3 ++- static/js/ep_email.js | 34 ++++++++++++++++++++++------------ templates/embedFrame.html | 3 +++ update.js | 16 ++++++++++++++-- 7 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 templates/embedFrame.html diff --git a/README.md b/README.md index 7209e8b..f56b806 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # TODO +* Option in UI to add email without prompt * validation * a point to unsubscribe * stop the ui prompting if already subscribed * send actual emails with content -* +* Clean up all code diff --git a/client.js b/client.js index 7260004..d9660b1 100644 --- a/client.js +++ b/client.js @@ -10,3 +10,7 @@ exports.eejsBlock_toolbarRight = function (hook_name, args, cb) { return cb(); }; +exports.eejsBlock_embedPopup = function (hook_name, args, cb) { + args.content = args.content + eejs.require("ep_email_notifications/templates/embedFrame.html", {}, module); + return cb(); +}; diff --git a/ep.json b/ep.json index 26ebd21..9ee23fc 100644 --- a/ep.json +++ b/ep.json @@ -6,10 +6,11 @@ "padUpdate": "ep_email_notifications/update", "handleMessage": "ep_email_notifications/update", "eejsBlock_scripts": "ep_email_notifications/client", - "eejsBlock_editbarMenuRight": "ep_email_notifications/client:eejsBlock_toolbarRight" + "eejsBlock_editbarMenuRight": "ep_email_notifications/client:eejsBlock_toolbarRight", + "eejsBlock_embedPopup": "ep_email_notifications/client:eejsBlock_embedPopup" }, "client_hooks": { - "postAceInit":"ep_email_notifications/static/js/ep_email", + "documentReady":"ep_email_notifications/static/js/ep_email", "handleClientMessage_emailSubscriptionSuccess":"ep_email_notifications/static/js/ep_email" } } diff --git a/package.json b/package.json index 5ff53dc..a7e74bd 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "contributors": [], "dependencies": { "emailjs": ">= 0.2.7", - "buffertools": ">= 1.0.8" + "buffertools": ">= 1.0.8", + "validator": ">= 0.4.21" }, "engines": { "node": ">= 0.4.1" diff --git a/static/js/ep_email.js b/static/js/ep_email.js index 4889ac4..e8862b1 100644 --- a/static/js/ep_email.js +++ b/static/js/ep_email.js @@ -1,3 +1,15 @@ +exports.documentReady = function(){ + // after 10 seconds if we dont already have an email for this author then prompt them + setTimeout(function(){init()},10000); + + // subscribe by email can be active.. + $('.ep_email_form').submit(function(){ + sendEmailToServer(); + return false; + }); + +} + exports.handleClientMessage_emailSubscriptionSuccess = function(hook, context){ // was subscribing to the email a big win or fail? if(context.payload == false){ showAlreadyRegistered(); @@ -6,16 +18,14 @@ exports.handleClientMessage_emailSubscriptionSuccess = function(hook, context){ } } -exports.postAceInit = function(){ - // after 10 seconds if we dont already have an email for this author then prompt them - setTimeout(function(){init()},10000); -} - function init(){ - if(clientHasAlreadyRegistered){ // if the client has already registered for emails on this pad. - showAlreadyRegistered(); // client has already registered, let em know.. - }else{ - askClientToEnterEmail(); // ask the client to register + var popUpIsAlreadyVisible = $('#ep_email').is(":visible"); + if(!popUpIsAlreadyVisible){ // if the popup isn't already visible + if(clientHasAlreadyRegistered()){ // if the client has already registered for emails on this pad. + // showAlreadyRegistered(); // client has already registered, let em know.. + }else{ + askClientToEnterEmail(); // ask the client to register + } } } @@ -55,16 +65,16 @@ function clientHasAlreadyRegistered(){ // Has the client already registered for function askClientToEnterEmail(){ $.gritter.add({ // (string | mandatory) the heading of the notification - title: "Email notifications for this pad", + title: "Enter your email to recieve an email when someone modifies this pad", // (string | mandatory) the text inside the notification - text: "