<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
        <link rel="stylesheet" href="../../dist/css/phonon.css" />
        <title>App</title>
    </head>
    <body>
        <!-- Panel tags go here -->
        <!-- Side Panel tags go here -->
        <!-- Notification tags go here -->
        <!-- Dialog tags go here -->
        <!-- Popover tags go here -->
        <!-- the home page is the default one. This page does not require to call its content because we define on its tag.-->
        <home data-page="true">
            <header class="header-bar">
                <div class="center">
                    <h1 class="title">Phonon Example</h1>
                </div>
            </header>
            <div class="content">
                <ul class="list">
                    <li class="divider">Select a pizza</li>
                    <li><a class="padded-list" href="#!pagetwo/margherita">Margherita</a></li>
                    <li><a class="padded-list" href="#!pagetwo/calzone">Cheese Calzone</a></li>
                    <li><a class="padded-list" href="#!pagetwo/pesto">Pesto Pizza</a></li>
                    <li><a class="padded-list" href="#!pagetwo/roma">Roma</a></li>
                    <li><a class="padded-list" href="#!pagetwo/prosciutto">Prosciutto</a></li>
                    <li><a class="padded-list" href="#!pagetwo/funghi">Funghi</a></li>
                </ul>
            </div>
        </home>
        <!-- for the second page, Phonon will load its content. -->
        <pagetwo data-page="true"></pagetwo>
        <!-- scripts -->
        <script src="../../dist/js/phonon.js"></script>
        <!-- our app config -->
        <script src="app.js"></script>
    </body>
</html>
					 
					
						phonon.options({
    navigator: {
        defaultPage: 'home',
        animatePages: true,
        enableBrowserBackButton: true,
        templateRootDirectory: './tpl'
    },
    i18n: null // for this example, we do not use internationalization
});
var app = phonon.navigator();
/**
 * The activity scope is not mandatory.
 * For the home page, we do not need to perform actions during
 * page events such as onCreate, onReady, etc
*/
app.on({page: 'home', preventClose: false, content: null});
/**
 * However, on the second page, we want to define the activity scope.
 * [1] On the create callback, we add tap events on buttons. The OnCreate callback is called once.
 * [2] If the user does not tap on buttons, we cancel the page transition. preventClose => true
 * [3] The OnReady callback is called every time the user comes on this page,
 * here we did not implement it, but if you do, you can use readyDelay to add a small delay
 * between the OnCreate and the OnReady callbacks
*/
app.on({page: 'pagetwo', preventClose: true, content: 'pagetwo.html', readyDelay: 1}, function(activity) {
    var action = null;
    var onAction = function(evt) {
        var target = evt.target;
        action = 'ok';
        if(target.getAttribute('data-order') === 'order') {
            phonon.alert('Thank you for your order!', 'Dear customer');
        } else {
            phonon.alert('Your order has been canceled.', 'Dear customer');
        }
    };
    activity.onCreate(function() {
        document.querySelector('.order').on('tap', onAction);
        document.querySelector('.cancel').on('tap', onAction);
    });
    activity.onClose(function(self) {
        if(action !== null) {
            self.close();
        } else {
            phonon.alert('Before leaving this page, you must perform an action.', 'Action required');
        }
    });
    activity.onHidden(function() {
        action = null;
    });
    activity.onHashChanged(function(pizza) {
        document.querySelector('.pizza').textContent = pizza;
    });
});
// Let's go!
app.start();
					 
					
						<pagetwo class="app-page">
    <header class="header-bar">
        <div class="left">
            <button class="btn pull-left icon icon-arrow-back" data-navigation="$previous-page"></button>
            <h1 class="title">Page Two</h1>
        </div>
    </header>
    <div class="content">
        <div class="padded-full">
            <h2>Order</h2>
            <p>1x Pizza: <span class="pizza"></span></p>
            <p class="message"></p>
            <button class="btn negative cancel" data-order="cancel">Cancel</button>
            <button class="btn btn-flat primary order" data-order="order">Order</button>
        </div>
    </div>
</pagetwo>
<script>
	/*
	 * JavaScript code can be executed when the template is loaded
	 */
</script>