Commits

Joel Rivera committed 9397b1d

Add jquery form submition for contact.

Comments (0)

Files changed (7)

joelmx/locale/es/LC_MESSAGES/joelmx.mo

Binary file modified.

joelmx/locale/es/LC_MESSAGES/joelmx.po

 msgstr ""
 "Project-Id-Version: joelmx 0.0\n"
 "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2013-02-12 00:59-0600\n"
-"PO-Revision-Date: 2013-02-12 01:16-0600\n"
+"POT-Creation-Date: 2013-02-12 03:49-0600\n"
+"PO-Revision-Date: 2013-02-12 03:48-0600\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: es <LL@li.org>\n"
 "Plural-Forms: nplurals=2; plural=(n != 1)\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 1.0dev\n"
 
-#: joelmx/templates/home.mako:14
+#: joelmx/templates/home.mako:3
+msgid "Thank you!"
+msgstr "¡Gracias!"
+
+#: joelmx/templates/home.mako:4
+msgid "Unable to send message :(, please use twitter or linkedin."
+msgstr "No se pudo enviar el mensaje :(, por favor usar twitter o linkedin."
+
+#: joelmx/templates/home.mako:18
 msgid "Hi!, my name is Joel Rivera."
 msgstr "¡Hola!, me llamo Joel Rivera."
 
-#: joelmx/templates/home.mako:15
+#: joelmx/templates/home.mako:19
 msgid ""
 "I'm a software developer from Monterrey Mexico with a particular taste to"
 " software libre, python and coffee."
 "Soy un desarrollador de software de Monterrey México con un gusto "
 "particular por el software libre, python y el café."
 
-#: joelmx/templates/home.mako:20
+#: joelmx/templates/home.mako:24
 msgid "Here is my"
 msgstr "Aquí esta mí"
 
-#: joelmx/templates/home.mako:22
+#: joelmx/templates/home.mako:26
 msgid "and a bunch of other links"
 msgstr "y otro puñado de ligas"
 
-#: joelmx/templates/home.mako:50
+#: joelmx/templates/home.mako:54
 msgid "Contact me"
 msgstr "Contacto"
 
-#: joelmx/templates/home.mako:57
+#: joelmx/templates/home.mako:61
 msgid "Name"
 msgstr "Nombre"
 
-#: joelmx/templates/home.mako:61
+#: joelmx/templates/home.mako:65
 msgid "Email"
 msgstr "Email"
 
-#: joelmx/templates/home.mako:65
+#: joelmx/templates/home.mako:69
 msgid "Message"
 msgstr "Mensaje"
 
-#: joelmx/templates/home.mako:72
+#: joelmx/templates/home.mako:76
 msgid "Send"
 msgstr "Enviar"
 

joelmx/locale/joelmx.pot

 msgstr ""
 "Project-Id-Version: joelmx 0.0\n"
 "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2013-02-12 00:59-0600\n"
+"POT-Creation-Date: 2013-02-12 03:49-0600\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: Babel 1.0dev\n"
 
-#: joelmx/templates/home.mako:14
+#: joelmx/templates/home.mako:3
+msgid "Thank you!"
+msgstr ""
+
+#: joelmx/templates/home.mako:4
+msgid "Unable to send message :(, please use twitter or linkedin."
+msgstr ""
+
+#: joelmx/templates/home.mako:18
 msgid "Hi!, my name is Joel Rivera."
 msgstr ""
 
-#: joelmx/templates/home.mako:15
+#: joelmx/templates/home.mako:19
 msgid ""
 "I'm a software developer from Monterrey Mexico with a particular taste to "
 "software libre, python and coffee."
 msgstr ""
 
-#: joelmx/templates/home.mako:20
+#: joelmx/templates/home.mako:24
 msgid "Here is my"
 msgstr ""
 
-#: joelmx/templates/home.mako:22
+#: joelmx/templates/home.mako:26
 msgid "and a bunch of other links"
 msgstr ""
 
-#: joelmx/templates/home.mako:50
+#: joelmx/templates/home.mako:54
 msgid "Contact me"
 msgstr ""
 
-#: joelmx/templates/home.mako:57
+#: joelmx/templates/home.mako:61
 msgid "Name"
 msgstr ""
 
-#: joelmx/templates/home.mako:61
+#: joelmx/templates/home.mako:65
 msgid "Email"
 msgstr ""
 
-#: joelmx/templates/home.mako:65
+#: joelmx/templates/home.mako:69
 msgid "Message"
 msgstr ""
 
-#: joelmx/templates/home.mako:72
+#: joelmx/templates/home.mako:76
 msgid "Send"
 msgstr ""
 

joelmx/static/css/main.css

 #contactme {
     display: none;
     float: left;
-    width: 90%;
+    width: 100%;
     text-align: left;
 
 }
 }
 
 
+.success, .error {
+    padding-bottom: 12px;
+    text-align:center;
+    margin:0 auto;
+}
+.success {
+    color: #73FF00;
+}
+
+.error {
+    color: red;
+}

joelmx/static/js/main.js

 function show_contactme(){
     $('#contactme').slideToggle(1000);
 }
+
+
+function _clear_form($form){
+    $form.find(':input').each(function(){
+	switch(this.type) {
+	case 'password':
+	case 'select-multiple':
+	case 'select-one':
+	case 'text':
+	case 'textarea':
+	    $(this).val('');
+	    break;
+	case 'checkbox':
+	case 'radio':
+	    this.checked = false;
+	}
+    });
+}
+			     
+
+function set_contact_form(){
+    var $form = $('#contact');
+    var $contactme = $('#contactme');
+    $($form).submit(function(){
+	$.post($form.attr('action'), $form.serialize(), 
+	      function(data) {
+		  _clear_form($form);
+		  var $msg = $('<div class="success">' + SUCCESS_MSG + '</div>').hide();
+		  $msg.prependTo($contactme).fadeIn(2000).delay(2000).fadeOut(5000);
+		  $contactme.prepend();
+	      })
+	    .fail(function(){
+		var $msg = $('<div class="error">' + ERROR_MSG +'</div>').hide();
+		$msg.prependTo($contactme).fadeIn(1000);
+	    });
+	return false;
+    });
+}
+
+function setUp(){
+    set_contact_form();
+}
+
+$(document).ready(setUp);

joelmx/templates/home.mako

 <%inherit file="base.mako" />
+<script type="text/javascript">
+  var SUCCESS_MSG = "${_('Thank you!')}";
+  var ERROR_MSG = "${_('Unable to send message :(, please use twitter or linkedin.')}";
+</script>
 
 <div id="content">
 
   </a>
 
   <div id="contactme" class="hide">
-    <form method="POST" id="contact" action="/contact">
+    <form method="POST" id="contact" action="/contact?lang=${request.locale_name}">
       <input type="hidden" name="cidx" value="${cidx}" />
       <div class="formfield">
 	<label for="name">${_("Name")}</label>
       </div> 
       <div class="formfield">
 	<label for="clg">${challenge}</label>
-	<input type="text" name="clg" id="clg" value="" />	
+	<input type="text" name="clg" style="width: 10em" id="clg" value="" />	
       </div>
       <input type="submit" value="${_('Send')}" style="float: right; margin-right: 20px;"/>
     </form>
                ("Did Joel lives in Brazil?", 'no')],
         'es': [('¿Cuál es mí primer nombre?', 'joel'),
                ('¿Cuál es mí apellido?', 'rivera'),
-               ('¿Dos más uno?', ('three', '3')),
+               ('¿Dos más uno?', ('tres', '3')),
                ('¿Joel vive en Brasil?', 'no')],
         }