Diferencia entre revisiones de «Usuario:Juanda/phonegap/jquerymobile»
De WikiEducator
(→Estructura aplicación) |
|||
| (14 revisiones intermedias por el mismo usuario no mostrado) | |||
| Línea 26: | Línea 26: | ||
:[http://m.stanford.edu/ Universidad de Stanford] | :[http://m.stanford.edu/ Universidad de Stanford] | ||
:[http://www.jqmgallery.com/ Y muchos más] | :[http://www.jqmgallery.com/ Y muchos más] | ||
| + | *Para ver las páginas correctamente: | ||
| + | :Instala la extensión para Chrome Google Chrome to Phone para ver las páginas en el móvil | ||
| + | :Cambia el user-agent del navegador (lo más fácil es mediante las Chrome Developer Tools). | ||
</div> | </div> | ||
| − | |||
<div class="slide"> | <div class="slide"> | ||
| Línea 83: | Línea 85: | ||
<div class="slide"> | <div class="slide"> | ||
| − | == | + | ==Aplicación Web con jQueryMobile== |
</div> | </div> | ||
<div class="slide"> | <div class="slide"> | ||
| Línea 172: | Línea 174: | ||
</source> | </source> | ||
</div> | </div> | ||
| − | |||
| − | |||
<div class="slide"> | <div class="slide"> | ||
*Mira el siguiente código y [http://www.media.formandome.es/phonegap/ejemplo2.html analiza su comportamiento]: | *Mira el siguiente código y [http://www.media.formandome.es/phonegap/ejemplo2.html analiza su comportamiento]: | ||
<source lang="html4strict"> | <source lang="html4strict"> | ||
| − | |||
<!DOCTYPE html> | <!DOCTYPE html> | ||
<html> | <html> | ||
| Línea 326: | Línea 325: | ||
</body> | </body> | ||
</html> | </html> | ||
| − | |||
</source> | </source> | ||
| − | |||
</div> | </div> | ||
| − | |||
| − | |||
<div class="slide"> | <div class="slide"> | ||
*[http://www.media.formandome.es/phonegap/ejemplo4.html Otro ejemplo] de formulario: | *[http://www.media.formandome.es/phonegap/ejemplo4.html Otro ejemplo] de formulario: | ||
| Línea 445: | Línea 440: | ||
</div> | </div> | ||
</div> | </div> | ||
| − | |||
</body> | </body> | ||
</html> | </html> | ||
| − | + | </source> | |
| + | </div> | ||
| + | <div class="slide"> | ||
| + | ==Eventos en jQueryMobile== | ||
| + | </div> | ||
| + | <div class="slide"> | ||
| + | ====Sin jQuery Mobile==== | ||
| + | *Normalmente definimos los eventos mediante algún framework, por ejemplo jQuery. | ||
| + | *Evitamos el uso de javascript directamente debido a las diferencias entre navegadores. | ||
| + | *Mira el siguiente código y [http://www.media.formandome.es/phonegap/eventojquery.html analiza su comportamiento]: | ||
| + | <source lang="html4strict" | ||
| + | <!DOCTYPE html> | ||
| + | <html> | ||
| + | <head> | ||
| + | <style> | ||
| + | p { color:red; margin:5px; cursor:pointer; } | ||
| + | p:hover { background:yellow; } | ||
| + | </style> | ||
| + | <script src="http://code.jquery.com/jquery-1.9.1.js"></script> | ||
| + | </head> | ||
| + | <body> | ||
| + | <p>First Paragraph</p> | ||
| + | |||
| + | <p>Second Paragraph</p> | ||
| + | <p>Yet one more Paragraph</p> | ||
| + | <script> | ||
| + | $("p").click(function () { | ||
| + | $(this).slideUp(); | ||
| + | }); | ||
| + | </script> | ||
| + | |||
| + | </body> | ||
| + | </html> | ||
| + | </source> | ||
| + | </div> | ||
| + | <div class="slide"> | ||
| + | ====Con jQuery Mobile==== | ||
| + | *Los touch events son distintos a los [http://api.jquery.com/category/events/mouse-events/ eventos tradicionales del ratón]: | ||
| + | *Tap | ||
| + | *Taphold (al menos 1s) | ||
| + | *Swipe (Swipeleft y Swiperight) | ||
| + | *Mira el siguiente código y [http://www.media.formandome.es/phonegap/eventojqmobile.html analiza su comportamiento] (es útil la extensión para'' Chrome Google Chrome to Phone''). | ||
| + | <source lang="html4strict"> | ||
| + | <!DOCTYPE html> | ||
| + | <html> | ||
| + | <head> | ||
| + | <meta charset="utf-8"> | ||
| + | <title>Eventos con jQueryMobile</title> | ||
| + | <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" /> | ||
| + | <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | ||
| + | <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> | ||
| + | <script> | ||
| + | $(document).ready(function() { | ||
| + | $("#tap").on("tap", function() { | ||
| + | alert("TapEvent"); | ||
| + | }); | ||
| + | $("#taphold").on("taphold", function() { | ||
| + | alert("Tap Hold Event"); | ||
| + | }); | ||
| + | $("#swipe").on("swipe", function() { | ||
| + | alert("Swipe Event"); | ||
| + | }); | ||
| + | $("#swipeleft").on("swipeleft", function() { | ||
| + | alert("Swipe Left Event"); | ||
| + | }); | ||
| + | $("#swiperight").on("swiperight", function() { | ||
| + | alert("Swipe Right Event"); | ||
| + | }); | ||
| + | $(window).on('orientationchange', function(event){ | ||
| + | $("#placeholder").html("Se ha cambiado la orientación a: "+event.orientation); | ||
| + | }); | ||
| + | }); | ||
| + | </script> | ||
| + | </head> | ||
| + | <body> | ||
| + | <div data-role="page" id="main"> | ||
| + | <div data-role="header"> | ||
| + | <h1> | ||
| + | Eventos en jQueryMobile | ||
| + | </h1> | ||
| + | </div> | ||
| + | <div data-role="content"> | ||
| + | <h3> | ||
| + | Eventos de cambio de orientación: | ||
| + | </h3> | ||
| + | <h3> | ||
| + | Eventos táctiles: | ||
| + | </h3> | ||
| + | <p id="tap"> | ||
| + | Pulsa aquí | ||
| + | </p> | ||
| + | <p id="taphold"> | ||
| + | Pulsa y manten el dedo al menos 1s | ||
| + | </p> | ||
| + | <p id="swipe"> | ||
| + | Desliza el dedo | ||
| + | </p> | ||
| + | <p id="swipeleft"> | ||
| + | Desliza el dedo hacia la izqda | ||
| + | </p> | ||
| + | <p id="swiperight"> | ||
| + | Desliza el dedo hacia la dcha. | ||
| + | </p> | ||
| + | </div> | ||
| + | <div data-role="footer" class="ui-bar"> | ||
| + | <h1> | ||
| + | Footer | ||
| + | </h1> | ||
| + | </div> | ||
| + | </div> | ||
| + | </body> | ||
| + | </html> | ||
</source> | </source> | ||
</div> | </div> | ||
Última revisión de 15:20 20 feb 2014
| Trabajo en proceso, espera cambios frecuentes. Tu ayuda y retroalimentación son bienvenidos. Ver página de charlas. |