diff options
Diffstat (limited to 'files/fr/archive/b2g_os/quickstart/votre_premier_application')
-rw-r--r-- | files/fr/archive/b2g_os/quickstart/votre_premier_application/index.html | 261 |
1 files changed, 0 insertions, 261 deletions
diff --git a/files/fr/archive/b2g_os/quickstart/votre_premier_application/index.html b/files/fr/archive/b2g_os/quickstart/votre_premier_application/index.html deleted file mode 100644 index fb7aee2781..0000000000 --- a/files/fr/archive/b2g_os/quickstart/votre_premier_application/index.html +++ /dev/null @@ -1,261 +0,0 @@ ---- -title: Votre première application -slug: Archive/B2G_OS/Quickstart/Votre_premier_application -tags: - - Applications - - Débutant - - Guide -translation_of: Archive/B2G_OS/Quickstart/Your_first_app ---- -<article class="brush: js"> -<div class="summary"> -<p><span id="result_box" lang="fr">Les Open Web apps <span class="hps">donnent aux développeurs</span> <span class="hps">web</span> <span class="hps">ce qu'ils ont</span> attendu <span class="hps">pendant des années</span><span>:</span> </span><span lang="fr"><span class="hps">un environnement</span> <span class="hps">multi-plateforme</span> <span class="hps">dédié</span> <span class="hps">aux applications</span> <span class="hps">installables</span> <span class="hps">créées</span> avec <span class="hps">HTML</span><span>,</span> <span class="hps">CSS et JavaScript</span> <span class="hps">-</span> <span class="hps">avec Firefox</span> <span class="hps">OS</span> <span class="hps">qui est</span> <span class="hps">la première</span> <span class="hps">plate-forme ouverte</span> <span class="hps">dédiée</span> <span class="hps">aux</span> <span class="hps">applications web</span><span>.</span> <span class="hps">Ce guide</span> <span class="hps">vous</span> <span class="hps">permet de démarrer</span> <span class="hps">rapidement avec</span> <span class="hps">une</span> <span class="hps">architecture de base</span> <span class="hps">ainsi que les premières instructions</span>. Vous pourrez ainsi <span class="hps">créer la prochaine</span> <span class="hps">application</span><span> révolutionnaire!</span></span></p> -</div> - -<p><span id="result_box" lang="fr"><span class="hps">Si vous</span> <span class="hps">souhaitez</span> <span class="hps">suivre ce</span> <span class="hps">guide,</span> <span class="hps">vous pouvez télécharger nos</span> <span class="hps">modèle</span>s <span class="hps">d'applications</span> <span class="hps">de <a href="https://github.com/chrisdavidmills/mdn-app-template">démarrage rapide</a></span><span>.</span> <span class="hps">Vous trouverez plus d'informations à propos de ce dernier</span> <span class="hps">en lisant notre</span> <span class="hps">guide sur les <a href="/fr/docs/Project:MDN/Style_guide/Sample_app_coding_guidelines#Apps_template">modèle</a></span><a href="/fr/docs/Project:MDN/Style_guide/Sample_app_coding_guidelines#Apps_template">s</a> <span class="hps">d'applications.</span></span></p> - -<h2 id="Structure_de_l'application">Structure de l'application</h2> - -<h3 id="Packaged_vs._Hosted_Apps">Packaged vs. Hosted Apps</h3> - -<p>Il y a deux types d'applications web : <code>packaged(empaquetées)</code> et <code>hosted(hébergées)</code> . Les applications empaquetées sont essentiellement des fichiers <code>zip</code> contenant toutes les ressources de l'application : HTML, CSS, JavaScript, images, manifeste, etc. Les applications hébergées sont exécutées à partir d'un serveur avec un domaine donné, comme les sites web standards. Les deux types d'application nécessitent un manifeste valide. Quand vous êtes prêt à soumettre votre application au Firefox Marketplace, vous devrez soit uploader votre application sous forme de zip, soit fournir l'URL où votre application est hébergée.</p> - -<div><div class="intrinsic-wrapper"><div class="intrinsic-container "><iframe src="https://www.youtube.com/embed/Q7x-B13y33Q?rel=0&html5=1"></iframe></div></div> -<div class="video-caption"> -<p>Réalisé en partenariat avec Treehouse: <a class="button" href="http://teamtreehouse.com/?cid=1154">PASSEZ CHEZ EUX !</a></p> -</div> -</div> - -<p>Pour les besoins de ce tutoriel, vous allez créer une application qui sera hébergée sur votre adresse <code>localhost</code>. Une fois votre application prête à être postée dans le Firefox Marketplace, vous pourrez choisir la forme que prendra votre application : packaged app ou hosted app.</p> - -<h3 id="App_Manifests">App Manifests</h3> - -<p>Chaque application Firefox requiert un fichier manifest.webapp dans l'application racine. Le fichier <a href="/en-US/docs/Web/Apps/Manifest"><code>manifest.webapp</code></a> produit d'importantes informations sur l'application, comme la version, le nom, la description, les logos, les chaines locales, les domaines auquels l'application peut être installé, et beaucoup d'autres. Seulement le nom et la description sont requis. Le simple manifest inclus dans les modèles d'application est similaire à celui ci-dessous:</p> - -<pre class="brush: js">{ - "version": "0.1", - "name": "Open Web App", - "description": "Your new awesome Open Web App", - "launch_path": "/app-template/index.html", - "icons": { - "16": "/app-template/app-icons/icon-16.png", - "48": "/app-template/app-icons/icon-48.png", - "128": "/app-template/app-icons/icon-128.png" - }, - "developer": { - "name": "Your Name", - "url": "http://yourawesomeapp.com" - }, - "locales": { - "es": { - "description": "Su nueva aplicación impresionante Open Web", - "developer": { - "url": "http://yourawesomeapp.com" - } - }, - "it": { - "description": "Il vostro nuovo fantastico Open Web App", - "developer": { - "url": "http://yourawesomeapp.com" - } - } - }, - "default_locale": "en" -}</pre> - -<div><div class="intrinsic-wrapper"><div class="intrinsic-container "><iframe src="https://www.youtube.com/embed/dgAUgHQOm8M#t?rel=0&html5=1"></iframe></div></div> -<div class="video-caption"> -<p>Fait en partenariat avec Treehouse: <a class="button" href="http://teamtreehouse.com/?cid=1154">PASSER CHEZ EUX</a></p> -</div> -</div> - -<p> </p> - -<p>Un manifest basique est tout ce dont vous avez besoin pour commencer. Pour plus de détails a propos des manifests, lire <a href="/en-US/docs/Web/Apps/Manifest">App Manifest</a>.</p> - -<h2 id="Disposition_et_Design_de_l'application">Disposition et Design de l'application</h2> - -<p>Le Responsive design est devenu de plus en plus important comme plusieurs résolutions d'écrans deviennent des standards sur différents appareils. Même si le principal objectif de votre application sont les plateformes mobiles comme Firefox OS, d'autres appareils y auront aussi probablement accès. <a href="//developer.mozilla.org/docs/CSS/Media_queries">CSS media queries</a> vous autorise à l'adapter selon la disposition de votre appareil, comme le montre ce petit exemple CSS:</p> - -<pre class="brush: css">/* The following are examples of different CSS media queries */ - -/* Basic desktop/screen width sniff */ -@media only screen and (min-width : 1224px) { - /* styles */ -} - -/* Traditional iPhone width */ -@media - only screen and (-webkit-min-device-pixel-ratio : 1.5), - only screen and (min-device-pixel-ratio : 1.5) { - /* styles */ -} - -/* Device settings at different orientations */ -@media screen and (orientation:portrait) { - /* styles */ -} -@media screen and (orientation:landscape) { - /* styles */ -}</pre> - -<p>Il ya beaucoup de Frameworks JavaScript et CSS frameworks disponibles pour aider dans le responsive design et dans le développement d'application mobile (<a href="http://twitter.github.com/bootstrap">Bootstrap</a>, etc.) Choisissez le/les framework(s) qui est(sont) le(s) mieux adapté(s) à votre application et votre style de développement.</p> - -<h2 id="APIs_du_Web">APIs du Web</h2> - -<p>Des APIs JavaScript ont été créés et augmentés rapidement comme les appareils. L'effort <a href="https://wiki.mozilla.org/WebAPI">WebAPI</a> de Mozilla <span id="result_box" lang="fr"><span>apporte des dizaines de fonctionnalités mobiles standard aux APIs JavaScript</span></span> . Une liste des supports et status de périphérique est disponible sur la page <a href="https://wiki.mozilla.org/WebAPI">WebAPI</a>. La détection de fonctionnalités JavaScript est encore aujourd'hui un bon usage, comme montré dans l'exemple suivant :</p> - -<pre class="brush: js">// If this device supports the vibrate API... -if('vibrate' in navigator) { - // ... vibrate for a second - navigator.vibrate(1000); -}</pre> - -<p>Dans l'exemple suivant, la méthode d'affichage d'un <code><div></code> est modifiée en fonction de l'état de la batterie du périphérique :</p> - -<pre class="brush: java">// Create the battery indicator listeners -(function() { - var battery = navigator.battery || navigator.mozBattery || navigator.webkitBattery, - indicator, indicatorPercentage; - - if(battery) { - indicator = document.getElementById('indicator'), - indicatorPercentage = document.getElementById('indicator-percentage'); - - // Set listeners for changes - battery.addEventListener('chargingchange', updateBattery); - battery.addEventListener('levelchange', updateBattery); - - // Update immediately - updateBattery(); - } - - function updateBattery() { - // Update percentage width and text - var level = (battery.level * 100) + '%'; - indicatorPercentage.style.width = level; - indicatorPercentage.innerHTML = 'Battery: ' + level; - // Update charging status - indicator.className = battery.charging ? 'charging' : ''; - } -})();</pre> - -<p>Dans le code ci-dessus, une fois qu'il est confirmé que l'<a href="https://developer.mozilla.org/en-US/docs/DOM/window.navigator.battery">API Battery</a> est supporté, vous pouvez ajoutez des event listeners pour <code>chargingchange</code> et <code>levelchange</code> afin d'actualiser l'affichage de l'élément. Essayez d'ajouter ce qui suit au modèle de démarrage rapide, et voyez si vous pouvez le faire fonctionner.</p> - -<p>Référez-vous fréquemment à la page <a href="https://wiki.mozilla.org/WebAPI">WebAPI</a> pour vous mettre à jour avec les états d'API du périphérique.</p> - -<h3 id="Installer_la_fonctionnalité_API">Installer la fonctionnalité API</h3> - -<p>In our sample quickstart app template, we've implemented an install button that you can click when viewing the app as a standard Web page, to install that site on Firefox OS as an app. The button markup is nothing special:</p> - -<pre class="brush: html"><button id="install-btn">Install app</button></pre> - -<p>This button's functionality is implemented using the Install API (see install.js):</p> - -<pre class="brush: js">var manifest_url = location.href + 'manifest.webapp'; - -function install(ev) { - ev.preventDefault(); - // define the manifest URL - // install the app - var installLocFind = navigator.mozApps.install(manifest_url); - installLocFind.onsuccess = function(data) { - // App is installed, do something - }; - installLocFind.onerror = function() { - // App wasn't installed, info is in - // installapp.error.name - alert(installLocFind.error.name); - }; -}; - -// get a reference to the button and call install() on click if the app isn't already installed. If it is, hide the button. -var button = document.getElementById('install-btn'); - -var installCheck = navigator.mozApps.checkInstalled(manifest_url); - -installCheck.onsuccess = function() { - if(installCheck.result) { - button.style.display = "none"; - } else { - button.addEventListener('click', install, false); - }; -}; -</pre> - -<p>Let's run through briefly what is going on:</p> - -<ol> - <li>We get a reference to the install button and store it in the variable <code>button</code>.</li> - <li>We use <code>navigator.mozApps.checkInstalled</code> to check whether the app defined by the manifest at <code>http://people.mozilla.com/~cmills/location-finder/manifest.webapp</code> is already installed on the device. This test is stored in the variable <code>installCheck</code>.</li> - <li>When the test is successfully carried out, its success event is fired, therefore <code>installCheck.onsuccess = function() { ... }</code> is run.</li> - <li>We then test for the existence of <code>installCheck.result</code> using an <code>if</code> statement. If it does exist, meaning that the app is installed, we hide the button. An install button isn't needed if it is already installed.</li> - <li>If the app isn't installed, we add a click event listener to the button, so the <code>install()</code> function is run when the button is clicked.</li> - <li>When the button is clicked and the <code>install()</code> function is run, we store the manifest file location in a variable called <code>manifest_url</code>, and then install the app using <code>navigator.mozApps.install(manifest_url)</code>, storing a reference to that installation in the <code>installLocFind</code> variable. You'll notice that this installation also fires success and error events, so you can run actions dependent on whether the install happened successfully or not.</li> -</ol> - -<p>You may want to verify the <a href="/en-US/docs/Web/Apps/JavaScript_API">implementation state of the API</a> when first coming to Installable web apps.</p> - -<div class="note"> -<p>Note: Installable open web apps have a "single app per origin" security policy; basically, you can't host more than one installable app per origin. This makes testing a bit more tricky, but there are still ways around this, such as creating different sub-domains for apps, testing them using the Firefox OS Simulator, or testing the install functionality on Firefox Aurora/Nightly, which allows you to install installable web apps on the desktop. See <a href="/en-US/docs/Web/Apps/FAQs/About_app_manifests">FAQs about apps manifests</a> for more information on origins.</p> -</div> - -<h2 id="WebRT_APIs_(Permissions-based_APIs)">WebRT APIs (Permissions-based APIs)</h2> - -<p>There are a number of WebAPIs that are available but require permissions for that specific feature to be enabled. Apps may register permission requests within the <code>manifest.webapp</code> file like so:</p> - -<pre class="brush: js">// New key in the manifest: "permissions" -// Request access to any number of APIs -// Here we request permissions to the systemXHR API -"permissions": { - "systemXHR": {} -}</pre> - -<p>The three levels of permission are as follows:</p> - -<ul> - <li>Normal — APIs that don't need any kind of special access permissions.</li> - <li>Privileged — APIs available to developers to use in their applications, as long as they set access permissions in the app manifest files, and distribute them through a trusted source.</li> - <li>Certified — APIs that control critical functions on a device, such as the call dialer and messaging services. These are generally not available for third party developers to use.</li> -</ul> - -<p>For more information on app permission levels, read <a href="https://developer.mozilla.org/en-US/docs/Web/Apps/Packaged_apps#Types_of_packaged_apps" title="/en-US/docs/Web/Apps/Packaged_apps#Types_of_packaged_apps">Types of packaged apps</a>. You can find out more information about what APIs require permissions, and what permissions are required, at <a href="/en-US/docs/Web/Apps/App_permissions">App permissions</a>.</p> - -<div class="note"> -<p>It's important to note that not all Web APIs have been implemented within the Firefox OS Simulator.</p> -</div> - -<h2 id="Tools_Testing">Tools & Testing</h2> - -<p>Testing is incredibly important when supporting mobile devices. There are many options for testing installable open web apps.</p> - -<h3 id="Firefox_OS_Simulator">Firefox OS Simulator</h3> - -<p>Installing and using the <a href="https://marketplace.firefox.com/developers/docs/firefox_os_simulator">Firefox OS Simulator</a> is the easiest way to get up and running with your app. After you install the simulator, it is accessible from the Tools -> Web Developer -> Firefox OS Simulator menu. The simulator launches with a JavaScript console so you can debug your application from within the simulator.</p> - -<h3 id="App_Manager">App Manager</h3> - -<p>The new kid on the block with regards to testing tools is called the <a href="/en-US/docs/Mozilla/Firefox_OS/Using_the_App_Manager">App Manager</a>. This tool allows you to connect desktop Firefox to a compatible device via USB (or a Firefox OS simulator), push apps straight to the device, validate apps, and debug them as they run on the device.</p> - -<h3 id="Unit_Testing">Unit Testing</h3> - -<p>Unit tests are extremely valuable when testing on different devices and builds. jQuery's <a href="http://qunitjs.com">QUnit</a> is a popular client-side testing utility, but you can use any set of testing tools you'd like.</p> - -<h3 id="Installing_Firefox_OS_on_a_Device">Installing Firefox OS on a Device</h3> - -<p>Since Firefox OS is an open source platform, code and tools are available to build and install Firefox OS on your own device. Build and installation instructions, as well as notes on what devices it can be installed on, can be found on <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox_OS/Platform">MDN</a>.</p> - -<p>Dedicated Firefox OS developer preview devices are also available: read our <a href="https://marketplace.firefox.com/developers/dev_phone">Developer preview phone page</a> for more information.</p> - -<h2 id="App_Submission_and_Distribution">App Submission and Distribution</h2> - -<p>Once your app is complete, you can host it yourself like a standard web site or app (read <a href="/en-US/docs/Web/Apps/Publishing/Self-publishing_Apps">Self-publishing apps</a> for more information), or it can be <a href="https://marketplace.firefox.com/developers/submit/app/manifest">submitted</a> to the <a href="https://marketplace.firefox.com">Firefox Marketplace</a>. Your app's manifest will be validated and you may choose which devices your app will support (e.g. Firefox OS, Desktop Firefox, Firefox Mobile, Firefox Tablet). Once validated, you can add additional details about your app (screenshots, descriptions, price, etc.) and officially submit the app for listing within the Marketplace. Once approved, your app is available to the world for purchase and installation.</p> - -<h3 id="More_Marketplace_Listing_Information">More Marketplace & Listing Information</h3> - -<ol> - <li><a href="/en-US/docs/Web/Apps/Publishing/Submitting_an_app">Submitting an App to the Firefox OS Marketplace </a></li> - <li><a href="/en-US/docs/Web/Apps/Publishing/Marketplace_review_criteria">Marketplace Review Criteria </a></li> - <li><a href="http://s.vid.ly/embeded.html?link=8k2n4w&autoplay=false">App Submission Video Walkthrough </a></li> -</ol> -</article> |