-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working with form to send kindle book.
- Loading branch information
1 parent
3e11bad
commit 3b2e2ce
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//= require_self | ||
function Kindle() { | ||
var _this = this; | ||
|
||
_this.init = function() { | ||
document.getElementById("send-kindle").onclick = function(event) { | ||
event.preventDefault(); | ||
_this.getForm(); | ||
|
||
}; | ||
}; | ||
|
||
_this.openDialog = function(html) { | ||
var overlay = document.getElementById('overlay-kindle'); | ||
overlay.innerHTML = html; | ||
_this.setSendButton(); | ||
}; | ||
|
||
_this.setSendButton = function() { | ||
var button = document.getElementById('send-kindle-button'); | ||
button.onclick = function(event) { | ||
event.preventDefault(); | ||
}; | ||
} | ||
|
||
_this.sendData = function() { | ||
}; | ||
|
||
_this.getForm = function() { | ||
|
||
var xmlhttp = new XMLHttpRequest(); | ||
var url = "/kindle/new"; | ||
|
||
xmlhttp.onreadystatechange = function() { | ||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | ||
console.log(xmlhttp.responseText); | ||
_this.openDialog(xmlhttp.responseText); | ||
} | ||
}; | ||
xmlhttp.open("GET", url, true); | ||
xmlhttp.send(); | ||
}; | ||
|
||
}; | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- content_for(:javascript) do | ||
= javascript_include_tag 'kindle' | ||
%script | ||
var kindle = new Kindle(); | ||
kindle.init(); | ||
|
||
- content_for(:stylesheet) do | ||
= stylesheet_link_tag 'kindle' | ||
|
||
%a#send-kindle{href: '#'} | ||
Enviar Para Kindle | ||
|
||
#overlay-kindle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%h3 | ||
Enviar artigo para o Kindle | ||
|
||
Para que o arquivo possa ser enviado é preciso autorizar o email: | ||
= ActionMailer::Base.smtp_settings[:user_name] | ||
|
||
%form{action: '/kindle', method: 'post'} | ||
%label | ||
Seu email kindle: | ||
%input{type: 'email', placeholder: 'user@kindle.com'} | ||
%input#send-kindle-button{type: 'submit'} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
gallery.css gallery.js | ||
|
||
kindle.css kindle.js | ||
|
||
presentation.css presentation.js | ||
comments.js | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters