Merge branch 'release/1.0.3'

This commit is contained in:
Ghislain Loaec 2015-10-15 10:23:40 +02:00
commit cdfeafecd1
10 changed files with 818 additions and 51 deletions

452
Gruntfile.js Normal file
View File

@ -0,0 +1,452 @@
/**
* Gruntfile
*
* If you created your Sails app with `sails new foo --linker`,
* the following files will be automatically injected (in order)
* into the EJS and HTML files in your `views` and `assets` folders.
*
* At the top part of this file, you'll find a few of the most commonly
* configured options, but Sails' integration with Grunt is also fully
* customizable. If you'd like to work with your assets differently
* you can change this file to do anything you like!
*
* More information on using Grunt to work with static assets:
* http://gruntjs.com/configuring-tasks
*/
module.exports = function (grunt) {
var cssFilesToInject = [
// Vendors
'styles/vendor/**/*.css',
// All of the rest of your app styles imported here
'styles/**/*.css'
];
var jsFilesToInject = [
// Below, as a demonstration, you'll see the built-in dependencies
// linked in the proper order order
// Bring in the socket.io client
//'scripts/vendor/socket.io.js',
// A simpler boilerplate library for getting you up and running w/ an
// automatic listener for incoming messages from Socket.io.
//'scripts/vendor/app.js',
// Vendors
'scripts/vendor/**/*.js',
// Marionnette Application
'scripts/config/**/*.js',
'scripts/app.js',
'scripts/controllers/**/*.js',
'scripts/entities/**/*.js',
'scripts/views/**/*.js',
'scripts/components/**/*.js',
'scripts/apps/**/*.js',
// All of the rest of your app scripts imported here
'scripts/**/*.js'
];
var templateFilesToInject = [
'templates/**/*.html',
];
var ecoFilesToInject = [
'templates/**/*.eco',
'scripts/**/*.eco',
'scripts/apps/**/**/templates/*.eco'
];
// Modify css file injection paths to use
cssFilesToInject = cssFilesToInject.map(function (path) {
return 'www/' + path;
});
// Modify js file injection paths to use
jsFilesToInject = jsFilesToInject.map(function (path) {
return 'www/' + path;
});
templateFilesToInject = templateFilesToInject.map(function (path) {
return 'assets/' + path;
});
ecoFilesToInject = ecoFilesToInject.map(function (path) {
return 'assets/' + path;
});
// Get path to core grunt dependencies
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-sails-linker');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-eco');
grunt.loadNpmTasks('grunt-groc');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
reload: {
files: [
{
expand: true,
cwd: './assets',
src: ['templates/core/reload.html'],
dest: 'www',
rename: function(dest, src) {
return dest + '/index.html'
}
}
]
},
dev: {
files: [
{
expand: true,
cwd: './assets',
src: ['**/*.!(coffee|scss|sass|eco|haml)'],
dest: 'www'
}
]
},
build: {
files: [
{
expand: true,
cwd: 'www',
src: ['**/*'],
dest: 'www'
}
]
}
},
clean: {
dev: [
'www/scripts',
'www/styles',
'www/images',
'www/fonts',
'www/templates',
'www/index.html',
'www/templates.js'
],
build: ['www']
},
jst: {
dev: {
// To use other sorts of templates, specify the regexp below:
// options: {
// templateSettings: {
// interpolate: /\{\{(.+?)\}\}/g
// }
// },
files: {
// 'www/jst.js': templateFilesToInject
}
}
},
eco: {
dev: {
files: {
'www/templates.js': ecoFilesToInject
}
}
},
less: {
dev: {
files: [
{
expand: true,
cwd: 'assets/styles/',
src: ['*.less'],
dest: 'www/styles/',
ext: '.css'
}
]
}
},
sass: {
dev: {
files: [
{
expand: true,
cwd: 'assets/styles/',
src: ['*.scss', '*.sass'],
dest: 'www/styles/',
ext: '.css'
}
]
}
},
groc: {
markdown: [
"README.md"
],
coffeescript: [
"assets/scripts/*.coffee",
"assets/scripts/**/*.coffee"
],
javascript: [
],
stylesheet: [
"assets/styles/*.scss",
"assets/styles/**/*.scss"
],
options: {
"out": "assets/doc/",
"strip": "assets/",
"index": "README.md",
'index-page-title': "BambooJS Documentation"
}
},
coffee: {
dev: {
options:{
bare:true
},
files: [
{
expand: true,
cwd: 'assets/scripts/',
src: ['**/*.coffee'],
dest: 'www/scripts/',
ext: '.js'
}
]
}
},
concat: {
js: {
src: jsFilesToInject,
dest: 'www/concat/production.js'
},
css: {
src: cssFilesToInject,
dest: 'www/concat/production.css'
}
},
uglify: {
dist: {
src: ['www/concat/production.js'],
dest: 'www/min/production.js'
}
},
cssmin: {
dist: {
src: ['www/concat/production.css'],
dest: 'www/min/production.css'
}
},
'sails-linker': {
devJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: 'www/'
},
files: {
'www/**/*.html': jsFilesToInject
}
},
prodJs: {
options: {
startTag: '<!--SCRIPTS-->',
endTag: '<!--SCRIPTS END-->',
fileTmpl: '<script src="%s"></script>',
appRoot: 'www/'
},
files: {
'www/**/*.html': ['www/min/production.js']
}
},
devStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: 'www/'
},
// cssFilesToInject defined up top
files: {
'www/**/*.html': cssFilesToInject
}
},
prodStyles: {
options: {
startTag: '<!--STYLES-->',
endTag: '<!--STYLES END-->',
fileTmpl: '<link rel="stylesheet" href="%s">',
appRoot: 'www/'
},
files: {
'www/index.html': ['www/min/production.css']
}
},
// Bring in JST template object
devTpl: {
options: {
startTag: '<!--TEMPLATES-->',
endTag: '<!--TEMPLATES END-->',
fileTmpl: '<script type="text/javascript" src="%s"></script>',
appRoot: 'www/'
},
files: {
'www/index.html': ['www/templates.js']
}
},
},
watch: {
assets: {
// Assets to watch:
files: ['assets/**/*'],
// When assets are changed:
tasks: ['compileAssets', 'linkAssets']
}
},
connect: {
options: {
port: process.env.PORT || 3131,
base: 'dist/',
},
all: {},
},
concurrent: {
options: {
logConcurrentOutput: true
},
dev: {
tasks: ["run:phonegap", "watch"]
}
},
run: {
options: {
wait: true//false
},
phonegap: {
cmd: 'phonegap',
args: ['serve', '--no-autoreload', '-p', 3001]
}
}
});
//require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.registerTask('server', [
'compileAssets',
'linkAssets',
'concurrent:dev',
]);
// When Sails is lifted:
grunt.registerTask('default', ['server']);
grunt.registerTask('compileAssets', [
'clean:dev',
'copy:reload',
'jst:dev',
'eco:dev',
'less:dev',
'sass:dev',
'coffee:dev',
'copy:dev'
]);
grunt.registerTask('linkAssets', [
// Update link/script/template references in `assets` index.html
'sails-linker:devJs',
'sails-linker:devStyles',
'sails-linker:devTpl'
]);
// Build the assets into a web accessible folder.
// (handy for phone gap apps, chrome extensions, etc.)
grunt.registerTask('build', [
'compileAssets',
'linkAssets',
'clean:build',
'copy:build'
]);
// When sails is lifted in production
grunt.registerTask('prod', [
'clean:dev',
'eco:dev',
'jst:dev',
'less:dev',
'sass:dev',
'copy:dev',
'coffee:dev',
'concat',
'uglify',
'cssmin',
'sails-linker:prodJs',
'sails-linker:prodStyles',
'sails-linker:devTpl'
]);
grunt.registerTask('doc', ['groc']);
// When API files are changed:
// grunt.event.on('watch', function(action, filepath) {
// grunt.log.writeln(filepath + ' has ' + action);
// // Send a request to a development-only endpoint on the server
// // which will reuptake the file that was changed.
// var baseurl = grunt.option('baseurl');
// var gruntSignalRoute = grunt.option('signalpath');
// var url = baseurl + gruntSignalRoute + '?action=' + action + '&filepath=' + filepath;
// require('http').get(url)
// .on('error', function(e) {
// console.error(filepath + ' has ' + action + ', but could not signal the Sails.js server: ' + e.message);
// });
// });
};

View File

@ -0,0 +1,39 @@
class Momo
manifest:
meta:
manifestUrl: "index.json"
contructor: (args...) ->
@bindEvents()
bindEvents: ->
# Navigation Handler
xindow.addEventListener "hashchange", @onHashChange, false
document.addEventListener "deviceready", @onDeviceReady, false
init: ->
@initFileSystem()
@initIndex()
@backupAssets()
@loadLocalManifest()
@checkForUpdate(app.start, app.start)
@updateTimeout = setTimeout( app.checkForLastUpdateCheck, app.manifest.meta.updateFreq )
initFileSystem: ->
FastClick.attach(document.body)
start: ->
@loadManifest()
loadManifest: ->
manifest = JSON.parse
update: ->
updateAvailable: (y, n, f) ->

View File

@ -11,7 +11,7 @@
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />

42
package.json Normal file
View File

@ -0,0 +1,42 @@
{
"name": "momo",
"private": true,
"version": "1.0.3",
"description": "Simple cross-platform application implementing self-update mechanisms",
"dependencies": {
"ejs": "0.8.4",
"optimist": "0.3.4"
},
"scripts": {
"debug": "node debug app.js",
"grunt": "node_modules/.bin/grunt",
"start": "node_modules/.bin/grunt"
},
"main": "app.js",
"repository": "http://git.pwr.link/ghis/momo.git",
"author": "Ghislain Loaec",
"license": "",
"devDependencies": {
"font-awesome": "^4.3.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-concurrent": "^2.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-coffee": "^0.13.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-connect": "^0.10.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-jst": "^0.6.0",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-eco": "~0.1.2",
"grunt-groc": "~0.5.0",
"grunt-run": "^0.3.0",
"grunt-sails-linker": "^0.10.1",
"matchdep": "^0.3.0",
"weinre": "^2.0.0-pre-I0Z7U9OV"
}
}

26
www/assets/bp.svg Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="50.000000pt" height="50.000000pt" viewBox="0 0 50.000000 50.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.10, written by Peter Selinger 2001-2011
</metadata>
<g transform="translate(0.000000,50.000000) scale(0.100000,-0.100000)"
fill="#ffffff" stroke="none">
<path d="M20 480 c-19 -19 -20 -35 -20 -230 0 -197 1 -211 20 -230 19 -19 33
-20 230 -20 197 0 211 1 230 20 19 19 20 33 20 230 0 197 -1 211 -20 230 -19
19 -33 20 -231 20 -195 -1 -211 -2 -229 -20z m218 -96 c32 -22 30 -76 -3 -102
l-26 -20 24 -26 23 -25 13 62 c6 34 17 77 22 95 11 32 11 32 78 32 54 0 74 -4
95 -21 65 -51 8 -164 -86 -171 -42 -3 -42 -3 -53 -53 l-10 -50 -44 -3 c-47 -4
-47 -3 -25 65 3 10 -3 4 -14 -13 -11 -17 -35 -36 -53 -43 -40 -14 -169 -15
-169 -1 0 9 57 251 65 278 6 18 135 16 163 -4z"/>
<path d="M146 338 c-13 -41 -13 -58 -1 -58 18 0 37 26 33 46 -4 22 -27 30 -32
12z"/>
<path d="M367 333 c-10 -18 -18 -73 -10 -73 22 0 54 33 51 53 -3 22 -32 35
-41 20z"/>
<path d="M111 194 c-13 -46 -9 -51 25 -36 20 10 25 18 22 39 -5 44 -35 42 -47
-3z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

50
www/assets/eole.svg Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="150.000000pt" height="150.000000pt" viewBox="0 0 150.000000 150.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.10, written by Peter Selinger 2001-2011
</metadata>
<g transform="translate(0.000000,150.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M568 1459 c-15 -11 -51 -28 -80 -37 -40 -13 -54 -22 -56 -39 -8 -53
134 -263 178 -263 36 0 39 18 33 184 -7 185 -14 201 -75 155z m53 -155 c4 -76
5 -142 2 -146 -11 -20 -35 -3 -77 52 -91 120 -111 190 -53 190 12 0 40 11 62
25 22 13 45 23 50 21 6 -1 13 -63 16 -142z"/>
<path d="M772 1131 c-63 -22 -156 -108 -195 -180 -35 -65 -46 -223 -22 -307
27 -93 50 -129 106 -165 28 -19 57 -45 64 -60 18 -33 134 -95 197 -104 84 -13
183 33 277 126 57 57 81 97 81 134 0 17 14 57 30 90 16 33 30 75 30 93 0 41
-36 105 -87 154 -48 46 -161 108 -197 108 -47 0 -139 -57 -191 -117 -42 -48
-49 -63 -53 -108 -3 -43 1 -65 22 -112 39 -85 70 -113 122 -113 51 0 75 21
100 86 13 35 14 49 4 79 -21 65 -95 76 -88 13 4 -39 -24 -51 -42 -18 -9 17 -7
28 7 57 25 50 62 75 120 80 62 5 103 -19 132 -79 26 -54 26 -81 2 -133 -43
-95 -139 -149 -262 -150 -63 0 -67 2 -118 44 -83 69 -120 161 -102 255 11 61
74 154 110 163 14 3 37 14 50 25 13 10 31 18 40 18 9 0 44 14 78 32 69 36 81
64 41 92 -33 23 -186 21 -256 -3z m232 -7 c9 -3 16 -14 16 -23 0 -18 -55 -49
-164 -93 -66 -26 -104 -60 -144 -126 -37 -64 -38 -173 -2 -245 23 -45 98 -125
140 -147 25 -14 123 -13 174 2 205 59 273 280 117 380 -55 34 -78 35 -139 4
-54 -27 -76 -49 -92 -90 -13 -36 2 -82 30 -91 26 -8 62 16 56 37 -5 23 11 33
29 18 38 -31 1 -143 -50 -156 -40 -10 -71 10 -104 68 -25 43 -31 64 -31 115 0
58 3 65 41 110 41 48 139 113 171 113 26 0 131 -57 177 -97 77 -65 103 -160
62 -227 -11 -17 -22 -49 -26 -71 -11 -66 -31 -99 -97 -160 -76 -71 -150 -107
-219 -107 -68 1 -167 47 -204 95 -15 20 -46 49 -70 64 -76 48 -105 125 -106
281 -1 120 14 160 87 241 58 64 103 92 167 101 67 10 161 12 181 4z"/>
<path d="M214 1095 c-4 -8 1 -43 10 -78 8 -34 20 -86 27 -115 12 -56 30 -73
58 -54 9 7 46 30 84 53 73 45 81 63 45 96 -26 22 -192 113 -208 113 -6 0 -13
-7 -16 -15z m112 -56 c44 -23 87 -50 98 -59 18 -17 16 -19 -51 -64 -39 -25
-75 -46 -81 -46 -5 0 -17 35 -26 78 -9 42 -21 87 -26 99 -7 17 -5 33 5 33 2 0
38 -19 81 -41z"/>
<path d="M177 664 c-13 -13 28 -244 46 -256 8 -5 19 1 32 18 39 51 85 92 147
132 105 68 105 68 90 84 -9 9 -47 13 -135 13 -67 1 -133 4 -147 8 -14 5 -29 5
-33 1z m128 -35 c22 1 48 4 58 7 10 3 36 3 57 -1 l40 -7 -86 -61 c-48 -34 -98
-76 -111 -94 -14 -18 -29 -30 -34 -27 -5 3 -7 9 -5 12 2 4 -2 34 -10 67 -7 33
-14 73 -14 88 0 27 2 28 33 21 17 -4 50 -6 72 -5z"/>
<path d="M514 287 c-52 -52 -94 -102 -94 -111 0 -18 39 -40 90 -51 19 -4 61
-18 94 -32 66 -27 109 -27 114 1 2 10 -10 48 -27 85 -17 36 -34 95 -38 131
-12 94 -25 92 -139 -23z m120 2 c4 -34 19 -87 34 -118 15 -31 28 -59 30 -63 7
-15 -58 -8 -100 11 -24 10 -65 25 -92 33 -27 7 -51 18 -53 24 -4 13 147 174
163 174 7 0 14 -27 18 -61z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -133,6 +133,16 @@ body {
/*height: 100% !important;*/
display: block;
}
.momo-frame-spinner {
display: table;
position: absolute;
top: 0;
left: 0;
bottom:60px;
right: 0;
width:100%;
height:100%;
}
.momo-frame-overlay {
display: block;
position: absolute;
@ -269,8 +279,11 @@ img {
.navbar .col-xs-8 {
display: table;
}
.navbar-header {
/*min-width: 300px;*/
}
.parent-navbar-brand {
display: block;
display: table;
height: 60px;
overflow: hidden;
}
@ -282,6 +295,7 @@ img {
vertical-align: middle;
width: 100%;
line-height: 18px;
min-width: 100px;
}
.navbar .navbar-btn {
@ -324,6 +338,9 @@ h1 {
overflow:visible;
padding:0px;
}
h5 {
font-size: 16px;
}
@keyframes fade {
from { opacity: 1.0; }
@ -363,15 +380,26 @@ pre .boolean { color: #7587A6; }
pre .null { color: #828282; }
pre .key { color: #CDA869; }
.top-0 {
margin-top: 0px;
}
.top-10 {
margin-top: 10px;
}
.top-20 {
margin-top: 20px;
}
.bottom-0 {
margin-bottom: 0px;
}
.bottom-10 {
margin-bottom: 10px;
}
.bottom-20 {
margin-bottom: 20px;
}
@media (min-width: 768px) {
.navbar .navbar-btn {
padding-left: 0;
}
}

View File

@ -71,41 +71,41 @@
</script>
<script type="text/x-tmpl" id="momo-header-tmpl">
<div class="navbar-btn pull-left">
{% if(o.id && o.id != 'home'){ %}
<a href="#" class="btn btn-default pull-left momo-back-btn" onclick="window.history.back(); return false;">
<span class="sr-only"> History back </span>
<i class="fa fa-chevron-left"></i>
</a>
{% } %}
</div>
<div class="parent-navbar-brand">
<span class="navbar-brand" href="#home">
{% if(!(o.titlePersistent || o.meta.titlePersistent || o.id == 'home')){ %}
{%# (o.titleSeparator || o.meta.titleSeparator) %}
{% } %}
<span class="momo-icon">
{% var icon = (o.titlePersistent || o.meta.titlePersistent || o.id == 'home') ? o.meta.icon : o.icon || o.meta.icon; %}
{% if(icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: icon, size: 20, header: true }) %}
<div class="navbar-btn">
{% if(o.id && o.id != 'home'){ %}
<a href="#" class="btn btn-default pull-left momo-back-btn" onclick="window.history.back(); return false;">
<span class="sr-only"> History back </span>
<i class="fa fa-chevron-left"></i>
</a>
{% } %}
</span>
<span class="momo-title">
{% if(o.titlePersistent || o.meta.titlePersistent || o.id == 'home'){ %}
{%= o.meta.title %}
</div>
<span class="navbar-brand" href="#home">
{% if(!(o.titlePersistent || o.meta.titlePersistent || o.id == 'home')){ %}
{%# (o.titleSeparator || o.meta.titleSeparator) %}
<small>
{% if(o.meta.icon && o.icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20, header: true }) %}
{% } %}
{%# o.title %}
</small>
{% } else { %}
{%# (o.title || o.meta.title) %}
{% } %}
<span class="momo-icon">
{% var icon = (o.titlePersistent || o.meta.titlePersistent || o.id == 'home') ? o.meta.icon : o.icon || o.meta.icon; %}
{% if(icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: icon, size: 20, header: true }) %}
{% } %}
</span>
<span class="momo-title">
{% if(o.titlePersistent || o.meta.titlePersistent || o.id == 'home'){ %}
{%= o.meta.title %}
{%# (o.titleSeparator || o.meta.titleSeparator) %}
<small>
{% if(o.meta.icon && o.icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20, header: true }) %}
{% } %}
{%# o.title %}
</small>
{% } else { %}
{%# (o.title || o.meta.title) %}
{% } %}
</span>
</span>
</span>
</div>
</div>
</script>
<!-- Main Template -->
@ -150,7 +150,7 @@
</div>
</div>
</form>
<ul id="momo-menu" class="nav navbar-nav navbar-left"></ul>
<ul id="momo-menu" class="nav navbar-nav navbar-right"></ul>
</div>
</div>
</nav>
@ -161,7 +161,7 @@
</script>
<script type="text/x-tmpl" id="momo-list-item-tmpl">
<a href="#{%= o.id %}" class="{% if(!o.header){ %} list-group-item {% } %} clearfix">
<a href="#{%= o.id %}" class="{% if(!o.header){ %} list-group-item {% } %} clearfix {%= o.external ? 'offline-disable' : '' %}">
{% if(o.header){ %}
<span class="pull-left">
{% if(o.icon){ %}
@ -179,16 +179,28 @@
<i class="fa fa-angle-right pull-right visible-xs-inline"></i>
{% } %}
{% } else { %}
<span class="pull-left">
{% if(o.icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20 }) %}
{% if(o.external) { %}
<i class="fa fa-external-link pull-right"></i>
{% } else { %}
<i class="fa fa-angle-right pull-right"></i>
{% } %}
{%# o.title %}
</span>
{% if(o.external) { %}
<i class="fa fa-external-link pull-right"></i>
{% if(o.description){ %}
<h5 class="list-group-item-heading">
{% if(o.icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20 }) %}
{% } %}
{%# o.title %}
</h5>
<p class="list-group-item-text">
{%# o.description %}
</p>
{% } else { %}
<i class="fa fa-angle-right pull-right"></i>
<h5 class="pull-left bottom-0 top-0">
{% if(o.icon){ %}
{%# tmpl('momo-icon-tmpl', { icon: o.icon, size: 20 }) %}
{% } %}
{%# o.title %}
</h5>
{% } %}
{% } %}
</a>
@ -196,7 +208,7 @@
<script type="text/x-tmpl" id="momo-icon-item-tmpl">
<div class="col-xs-{%= o.colxs %} col-sm-{%= o.colsm %} col-md-{%= o.colmd %} col-lg-{%= o.collg %}">
<a href="#{%= o.id %}" class="btn btn-block text-center {%= o.className || 'btn-default' %}">
<a href="#{%= o.id %}" class="btn btn-block text-center {%= o.className || 'btn-default' %} {%= o.external ? 'offline-disable' : '' %}">
{% if(o.external){ %}
<i class="fa fa-external-link top-right"></i>
{% } %}
@ -236,19 +248,44 @@
<div class="clearfix"></div>
</script>
<!-- Offline template -->
<script type="text/x-tmpl" id="momo-offline-tmpl">
<div class="alert alert-warning">
<i class="fa fa-warning"></i>
Application hors-ligne
</div>
</script>
<!-- Page template -->
<script type="text/x-tmpl" id="momo-page-tmpl">
{% var displayFooter = true; %}
<div class="{% if(o.url){ %}{% } else { %}momo-page-wrapper{% } %} clearfix">
{% if(o.url && !o.url.isImage()){ %}
<div class="momo-frame-spinner offline-hidden">
<div class="momo-loading text-muted">
<i class="fa fa-spinner fa-pulse fa-3x"></i>
<p class="momo-loading-text">
Chargement du contenu
</p>
</div>
</div>
{% } %}
{% if(!(o.url && o.url.isImage())){ %}
<div class="offline-visible">
{%# tmpl('momo-offline-tmpl', o) %}
</div>
<div class="momo-flash-messages"></div>
<div class="container-fluid">
<section class="momo-page-content">{%# o.content %}</section>
</div>
{% } else { %}
<div class="momo-image-viewer" style="background-image: url('{%# o.url %}');">
<div class="offline-visible hidden">
{%# tmpl('momo-offline-tmpl', o) %}
</div>
<div class="momo-flash-messages"></div>
<div class="container-fluid momo-page-content-parent">
<section class="momo-page-content">{%# o.content %}</section>
@ -265,7 +302,6 @@
{% if(o.url && !o.url.isImage()){ %}
<iframe src="{%= o.url %}" class="momo-iframe"></iframe>
<!--div class="momo-frame-overlay"></div-->
{% } %}
{% if(o.pages){ %}

View File

@ -2,7 +2,7 @@
"title": "Ma ville au quotidien (Local)",
"icon": "icon.png",
"contact": "info@example.net",
"updateFreq": 5,
"updateFreq": 5000,
"manifestUrl": "http://pwr.link/entrouvert/index.json",
"assetsUrl": "http://pwr.link/entrouvert/assets.zip"
},

View File

@ -28,6 +28,7 @@ var ANIMATION_IN_CLASS = 'pt-page-moveFromRight';
var ANIMATION_BACK_OUT_CLASS = 'pt-page-moveToRightEasing pt-page-ontop';
var ANIMATION_BACK_IN_CLASS = 'pt-page-moveFromLeft';
var ON_PULL = 'checkForUpdate'; // || 'update'
var CHECK_FOR_CONNECTION_INTERVAL = 3000;
// Application
var app = {
@ -69,6 +70,7 @@ var app = {
},
// Misc Data
online : false,
current : 0,
isAnimating : false,
endCurrPage : false,
@ -130,13 +132,19 @@ var app = {
app.loadLocalManifest();
// Check for new updates
app.checkForUpdate(app.start, app.start);
//app.checkForUpdate(app.start, app.start);
// Regulary check for connection
setInterval( app.checkConnection, CHECK_FOR_CONNECTION_INTERVAL );
// Update Reminder
app.updateTimeout = setTimeout( app.checkForLastUpdateCheck, app.manifest.meta.updateFreq );
// Touch events faster response patch
FastClick.attach(document.body);
// Start Application
app.start();
},
initFileSystem: function(){
@ -197,11 +205,78 @@ var app = {
});
},
checkConnection: function(resolve, reject){
try {
switch(navigator.network.connection.type){
case Connection.ETHERNET:
case Connection.WIFI:
case Connection.CELL_4G:
case Connection.CELL_3G:
case Connection.CELL_2G:
app.online = true;
if(typeof resolve === "function"){
resolve();
}
break;
case Connection.NONE:
case Connection.UNKNOWN:
default:
app.online = false;
if(typeof reject === "function"){
reject();
}
break;
}
} catch(e) {
if(navigator.onLine){
app.online = true;
if(typeof resolve === "function"){
resolve();
}
} else {
app.online = false;
if(typeof reject === "function"){
reject();
}
}
}
// Hide offline specific elements
var i, elements;
elements = document.getElementsByClassName("offline-hidden");
for (i = 0; i < elements.length; i++){
if(app.online){
elements[i].classList.remove('hidden');
} else {
elements[i].classList.add('hidden');
}
}
// Show offline specific elements
var i, elements;
elements = document.getElementsByClassName("offline-visible");
for (i = 0; i < elements.length; i++){
if(app.online){
elements[i].classList.add('hidden');
} else {
elements[i].classList.remove('hidden');
}
}
// Disable offline specific elements
elements = document.getElementsByClassName("offline-disable");
for (i = 0; i < elements.length; i++){
if(app.online){
elements[i].classList.remove('disabled');
} else {
elements[i].classList.add('disabled');
}
}
return app.online;
},
// Check for last update check
checkForLastUpdateCheck: function(resolve, reject){
// Checklast Update
var lastUpdate = localStorage.getItem("momo-timestamp") ? new Date(localStorage.getItem("momo-timestamp")) : new Date(0);
var timeDiff = ((new Date()).getTime() - lastUpdate.getTime()) / 1000;
var timeDiff = ((new Date()).getTime() - lastUpdate.getTime());
var updateRequired = timeDiff > app.manifest.meta.updateFreq;
if(updateRequired){
@ -215,16 +290,25 @@ var app = {
checkForUpdate: function(resolve, reject) {
app.utils.setLoadingMsg("Vérification des mises à jour");
app.checkConnection();
var manifestReady = false;
var assetsReady = false;
var updateAvailable = false;
var updateError = false;
if(!app.online){
app.utils.setLoadingMsg("L'application est hors-ligne");
if(typeof resolve === 'function'){
resolve(false);
}
return;
}
var onGetMtime = function(key, mtime, ready){
var old_mtime = localStorage.getItem("momo-"+key+"-mtime");
if (mtime) {
if(mtime !== old_mtime) {
if(mtime != old_mtime) {
updateAvailable = true;
}
} else {
@ -237,6 +321,9 @@ var app = {
if(typeof reject === 'function'){
reject();
}
if(typeof resolve === 'function'){
resolve(false);
}
} else {
if(updateAvailable){
app.flash(tmpl('momo-update-available-tmpl', { mtime: app.utils.formatDate(mtime) }), 'success');
@ -885,6 +972,9 @@ var app = {
// Render page (with small hack, so it doesn't mess up the display)
$inpage.innerHTML = app.renderPage(page_obj, force);
// Check for connection
app.checkConnection();
// Pull to update binder
app.bindPagePull($inpage);
@ -992,7 +1082,7 @@ var app = {
prev, next;
console.warn(app.previousPage + " -> " + page);
//console.warn(app.previousPage + " -> " + page);
// Hack of the century ?
if(app.ignoreHash){ return false; }
@ -1089,7 +1179,7 @@ var app = {
var back = page === 'home';
console.log(app.pageHistory.join(',')+ " (index = "+app.pageIndex+")");
//console.log(app.pageHistory.join(',')+ " (index = "+app.pageIndex+")");
if (app.pageHistory.length/* && app.historyLength == length*/) {
// Goind Back
@ -1116,7 +1206,11 @@ var app = {
}
if(app.currentPage !== page){
app.navigate(page, back);
if(!app.pages[page].external || app.pages[page].external && app.online){
app.navigate(page, back);
} else {
window.history.go(-1);
}
}
app.parentPage = page;
app.previousPage = page;