summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor/Collaborators.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/editor/Collaborators.js')
-rw-r--r--public/assets/javascripts/ui/editor/Collaborators.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/public/assets/javascripts/ui/editor/Collaborators.js b/public/assets/javascripts/ui/editor/Collaborators.js
index c27dbe0..eee412a 100644
--- a/public/assets/javascripts/ui/editor/Collaborators.js
+++ b/public/assets/javascripts/ui/editor/Collaborators.js
@@ -29,6 +29,7 @@ var Collaborators = ModalFormView.extend({
},
populate: function(collaborators){
+ this.loaded = true
collaborators.forEach(function(collab){
var $el = $( this.template )
$el.data("collaborator-id", collab._id)
@@ -74,12 +75,30 @@ var Collaborators = ModalFormView.extend({
}, 100)
}
},
+
+ validate: function(){
+ var errors = []
+
+ var email = this.$("[name=email]").val()
+ if (! email.length) {
+ errors.push("Please enter an email address");
+ }
+ else if (email.indexOf("@") === -1) {
+ errors.push("Please enter a valid email address");
+ }
+
+ return errors
+ },
success: function(data){
this.reset()
this.populate([data])
+ // weird! this.$("#collaborator-url") not working here, but works without this
+ $("#collaborator-url").val("http://vvalls.com/join/" + data.nonce)
+ this.$("#collaborator-dummy-email").html(data.email)
+ this.$("#collaborator-url-rapper").slideDown(300)
},
-
+
destroy: function(e){
var $el = $(e.currentTarget).closest("li")
var _id = $el.data("collaborator-id")