Files
ionic-framework/docs/templates/demo_index.template.html
2014-05-20 06:12:30 -06:00

192 lines
5.4 KiB
HTML

<!doctype html>
<html ng-app="<@ if doc.demoData @><$ doc.demoData.module $><@ else @>demoApp<@ endif @>" ng-controller="IonicDemoCtrl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://code.ionicframework.com/<$ version.current.name $>/css/ionic.min.css">
<@ if doc.demoData and doc.demoData.css @>
<link rel="stylesheet" href="/<$ doc.demoData.css.path $>">
<@ endif @>
<script src="http://code.ionicframework.com/<$ version.current.name $>/js/ionic.bundle.min.js"></script>
<@ if doc.demoData and doc.demoData.javascript @>
<script src="/<$ doc.demoData.javascript.path $>"></script>
<@ endif @>
</head>
<body>
<@ if doc.demoData @>
<div class="demo-content-pane">
<$ doc.demoData.html.content $>
</div>
<div class="bar bar-footer bar-light demo-footer" ng-click="$demoModal.show()">
<div class="demo-footer-icon" ng-hide="$demoModal.isShown()">
<i class="icon ion-chevron-up"></i>
</div>
<h1 class="title" style="right:auto;">
<$ doc.name $>: <$ doc.demoData.name | capital $>
</h1>
<div class="buttons right-buttons">
<a class="button" ng-click="demoScratch($demo); $event.stopPropagation()">
<i class="icon ion-code"></i>
Source
</a>
</div>
<@ else @>
<div class="pane">
<div ng-include="'demo-list.html'">
</div>
</div>
<@ endif @>
<script type="text/ng-template" id="ionic-demo-modal.html">
<div class="modal">
<div ng-include="'demo-list.html'">
</div>
</div>
</script>
<script type="text/ng-template" id="demo-list.html">
<ion-header-bar class="bar-light">
<a class="button" ng-click="$demoModal.hide()" ng-if="$demo">
Cancel
</a>
<h1 class="title">All Demos</h1>
</ion-header-bar>
<ion-content>
<div class="list">
<div class="item item-input-inset">
<label class="item-input-wrapper">
<input type="text" placeholder="Filter Demos..." ng-model="demoFilter" autofocus>
</label>
<button class="button button-small" ng-click="demoFilter = ''">
Clear
</button>
</div>
<a class="item item-icon-right"
ng-class="{active: demo.module == $demo.module }"
ng-repeat="demo in $demos | filter:demoFilter"
ng-href="{{demo.href}}">
{{demo.docName}}: {{demo.name | capitalize}}
<i class="icon icon-accessory ion-chevron-right"></i>
</a>
</div>
</ion-content>
</script>
<script>
var DEMOS = <$ demos | json $>;
var DEMO;
<@ if doc.demoData @>
DEMO = <$ doc.demoData | json $>;
<@ endif @>
</script>
<script>
angular.module(<@ if doc.demoData @>'<$ doc.demoData.module $>'<@ else @>'demoApp', ['ionic']<@ endif @>)
.controller('IonicDemoCtrl', function($scope, $ionicModal, $ionicLoading) {
$scope.$demos = DEMOS;
$scope.$demo = DEMO;
<@ if doc.demoData @>
$ionicModal.fromTemplateUrl('ionic-demo-modal.html', {
scope: $scope
}).then(function(modal) {
$scope.$demoModal = modal;
});
//don't try this at home
ionic.onGesture('dragup', function(e) {
if (e.gesture.distance > 35 && !$scope.$demoModal.isShown()) {
$scope.$apply(function(e) {
$scope.$demoModal.show();
});
}
}, document.querySelector('.demo-footer'));
$scope.demoScratch = function(demo) {
var form = angular.element('<form method="POST" action="http://scratch.ionicsdk.com/embed">');
var htmlInput = angular.element('<textarea type="text" name="html">')
.val(['<html ng-app="<$ doc.demoData.module $>">',
'<head>',
' <meta charset="utf-8">',
' <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">',
' <link rel="stylesheet" href="http://code.ionicframework.com/<$ version.current.name $>/css/ionic.css">',
' <script src="http://code.ionicframework.com/<$ version.current.name $>/js/ionic.bundle.js"><'+'/script>',
'</head>',
'<body>',
(demo.html && demo.html.content || ''),
'</body>',
'</html>'].join('\n'));
var cssInput = angular.element('<textarea type="text" name="css">')
.val(demo.css && demo.css.content || '');
var jsInput = angular.element('<textarea type="text" name="js">')
.val(demo.javascript && demo.javascript.content || '');
form
.css('display','none')
.append(htmlInput)
.append(cssInput)
.append(jsInput);
document.body.appendChild(form[0]);
form[0].submit();
$ionicLoading.show({
template: 'Opening in Scratchpad...'
});
};
<@ endif @>
})
.filter('capitalize', function() {
return function(input) {
return input.charAt(0).toLowerCase() + input.substring(1);
};
});
</script>
<style>
body {
margin-bottom: 44px;
}
.demo-content-pane {
position: absolute;
top: 0;
right: 0;
bottom: 44px;
left: 0;
width: 100%;
overflow: hidden;
}
.demo-footer-icon {
position: absolute;
left: 0;
right: 0;
top: -3px;
margin: auto;
text-align: center;
-webkit-transform: scaleX(1.3);
-moz-transform: scaleX(1.3);
transform: scaleX(1.3);
}
.demo-footer-icon .icon {
color: #CCC;
font-size: 18px;
}
</style>
</body>
</html>