Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Add ability to push vars and events in form submits
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Sage committed May 26, 2015
1 parent 4ae4f0c commit 7a829df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
14 changes: 10 additions & 4 deletions build/picreel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
this.emailSelector = this.emailSelector || "input[name='email']";
this.errorClass = this.errorClass || "subscriber-error";
this.loadingClass = this.loadingClass || "subscriber-loading";
this.onerror = this.onerror || function() {};
this.onsuccess = this.onsuccess || function() {};
this.oncomplete = this.oncomplete || function() {};
this.onerror = this.onerror || noop;
this.onsuccess = this.onsuccess || noop;
this.oncomplete = this.oncomplete || noop;
this.vars = this.vars || [];
this.event = this.event || null;
this.action = this.action || "/";
this.carrier = null;

Expand Down Expand Up @@ -84,6 +86,8 @@
var data = {};

data['email'] = this.$(this.emailSelector).val();
if(this.vars.length) data['vars'] = this.vars;
if(this.event) data['event'] = this.event;

if (this.lists.length) {
data['lists'] = [];
Expand Down Expand Up @@ -141,14 +145,16 @@
});
};

getTopWindow = function() {
var getTopWindow = function() {
var topWindow = window;
while (topWindow !== topWindow.parent) {
topWindow = topWindow.parent;
}
return topWindow;
};

var noop = function() {};

return APLSubscriber;

})();
Expand Down
2 changes: 1 addition & 1 deletion build/picreel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/picreel.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions lib/factories/subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
this.emailSelector = this.emailSelector || "input[name='email']";
this.errorClass = this.errorClass || "subscriber-error";
this.loadingClass = this.loadingClass || "subscriber-loading";
this.onerror = this.onerror || function() {};
this.onsuccess = this.onsuccess || function() {};
this.oncomplete = this.oncomplete || function() {};
this.onerror = this.onerror || noop;
this.onsuccess = this.onsuccess || noop;
this.oncomplete = this.oncomplete || noop;
this.vars = this.vars || [];
this.event = this.event || null;
this.action = this.action || "/";
this.carrier = null;

Expand Down Expand Up @@ -83,6 +85,8 @@
var data = {};

data['email'] = this.$(this.emailSelector).val();
if(this.vars.length) data['vars'] = this.vars;
if(this.event) data['event'] = this.event;

if (this.lists.length) {
data['lists'] = [];
Expand Down Expand Up @@ -140,14 +144,16 @@
});
};

getTopWindow = function() {
var getTopWindow = function() {
var topWindow = window;
while (topWindow !== topWindow.parent) {
topWindow = topWindow.parent;
}
return topWindow;
};

var noop = function() {};

return APLSubscriber;

})();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "picreel",
"version": "0.3.0",
"version": "0.4.0",
"private": true,
"author": {
"name": "Brian Sage",
Expand Down
Loading

0 comments on commit 7a829df

Please sign in to comment.