JSFiddle - React, Tailwind, and code Playground
by Chase Wilson
JavaScript
(function(jq){
var PassShot = {
/*
passShotForm: `Element`
passShotName: `Element`
passShotconfirmAge: `Element`
*/
friendsById: {}
,friendsByName:{}
,friends: []
,friendNames: []
,initialize: function(){
var passShotForm = this.passShotForm = jq('#pass-shot-form');
var passShotname = this.passShotName = jq('#name', passShotForm);
var passShotconfirmAge = this.passShotconfirmAge = jq('#confirm-age',passShotForm);
this.attachEvents();
}
,attachEvents: function(){
this.passShotForm.validate({
"submitHandler":function(){
var value = PassShot.passShotName.attr("value");
PassShot.share(PassShot.friendsByName[value]);
}
,errorElement: "div"
});
this.passShotName
.data("placeholder",this.passShotName.attr("placeholder"))
.bind({
focus: function(event){
var self = $(this);
if(self.value === self.data("placeholder")){
self.value === ""
}
}
,blur: function(event){
var self = $(this);
if(self.value === ""){
self.attr("value",self.data("placeholder"));
}
}
});
}
,share: function(friend){
if(!friend) return;
console.log(friend);
sml.ui.Facebook.share({
message:"Share Message"
,target_id: friend.id
,user_message_prompt: "User Message Prompt"
,action_links: [{
text: "Action link Text"
,href: "http://google.com"
}]
,attachment:{
name: "Share Name"
,caption: "Share Caption"
,href: "http://google.com"
,description: "Share Description"
,media:[{
type: "image"
,src: "{% editable_image name:'soco-shot' src_only:true %}"
,href:"http://google.com"
}]
}
,success: function(post_id) {
sml.log("Success!");
}
,error: function() {
sml.log("Error! ");
}
})
}
};
// Document...