├── README.md
├── assets
├── img
│ ├── book-illustration
│ │ ├── 1.1-device-toolbar.jpg
│ │ ├── 1.1-galaxy.png
│ │ ├── 1.2-detail-page.png
│ │ └── 1.2-file-structure.png
│ ├── calendar.png
│ ├── happy-h.png
│ ├── happy.png
│ ├── happy_dragon.png
│ ├── home.png
│ ├── na-h.png
│ ├── na.png
│ ├── sad-h.png
│ └── sad.png
└── sketch
│ └── dragon.sketch
└── ionic2
└── toothy-dragon
├── .gitignore
├── app
├── app.ts
├── pages
│ ├── detail
│ │ ├── detail.html
│ │ ├── detail.scss
│ │ └── detail.ts
│ └── home
│ │ ├── home.html
│ │ ├── home.scss
│ │ ├── home.ts
│ │ └── img
│ │ ├── happy.png
│ │ ├── happy_dragon.png
│ │ ├── happy_h.png
│ │ ├── neutral.png
│ │ ├── neutral_h.png
│ │ ├── sad.png
│ │ └── sad_h.png
└── theme
│ ├── app.common.scss
│ ├── app.core.scss
│ ├── app.ios.scss
│ ├── app.md.scss
│ ├── app.variables.scss
│ └── app.wp.scss
├── config.xml
├── gulpfile.js
├── hooks
├── README.md
└── after_prepare
│ └── 010_add_platform_class.js
├── ionic.config.json
├── ionic.project
├── package.json
├── resources
├── android
│ ├── icon
│ │ ├── drawable-hdpi-icon.png
│ │ ├── drawable-ldpi-icon.png
│ │ ├── drawable-mdpi-icon.png
│ │ ├── drawable-xhdpi-icon.png
│ │ ├── drawable-xxhdpi-icon.png
│ │ └── drawable-xxxhdpi-icon.png
│ └── splash
│ │ ├── drawable-land-hdpi-screen.png
│ │ ├── drawable-land-ldpi-screen.png
│ │ ├── drawable-land-mdpi-screen.png
│ │ ├── drawable-land-xhdpi-screen.png
│ │ ├── drawable-land-xxhdpi-screen.png
│ │ ├── drawable-land-xxxhdpi-screen.png
│ │ ├── drawable-port-hdpi-screen.png
│ │ ├── drawable-port-ldpi-screen.png
│ │ ├── drawable-port-mdpi-screen.png
│ │ ├── drawable-port-xhdpi-screen.png
│ │ ├── drawable-port-xxhdpi-screen.png
│ │ └── drawable-port-xxxhdpi-screen.png
├── icon.png
├── ios
│ ├── icon
│ │ ├── icon-40.png
│ │ ├── icon-40@2x.png
│ │ ├── icon-50.png
│ │ ├── icon-50@2x.png
│ │ ├── icon-60.png
│ │ ├── icon-60@2x.png
│ │ ├── icon-60@3x.png
│ │ ├── icon-72.png
│ │ ├── icon-72@2x.png
│ │ ├── icon-76.png
│ │ ├── icon-76@2x.png
│ │ ├── icon-small.png
│ │ ├── icon-small@2x.png
│ │ ├── icon-small@3x.png
│ │ ├── icon.png
│ │ └── icon@2x.png
│ └── splash
│ │ ├── Default-568h@2x~iphone.png
│ │ ├── Default-667h.png
│ │ ├── Default-736h.png
│ │ ├── Default-Landscape-736h.png
│ │ ├── Default-Landscape@2x~ipad.png
│ │ ├── Default-Landscape~ipad.png
│ │ ├── Default-Portrait@2x~ipad.png
│ │ ├── Default-Portrait~ipad.png
│ │ ├── Default@2x~iphone.png
│ │ └── Default~iphone.png
└── splash.png
├── tsconfig.json
├── typings.json
├── typings
├── browser.d.ts
├── browser
│ └── ambient
│ │ └── es6-shim
│ │ └── index.d.ts
├── main.d.ts
└── main
│ └── ambient
│ └── es6-shim
│ └── index.d.ts
└── www
└── index.html
/README.md:
--------------------------------------------------------------------------------
1 | # Hybrid Frameworks Tutorial
2 |
3 | Hi, visitors. How do you feel today?
4 |
5 | Here's a book for you to get started with hybrid solutions like [ionic](http://ionicframework.com), [react native](https://facebook.github.io/react-native), [crosswalk](https://crosswalk-project.org/) and so on. This is a project to guide you through the whole process of making an app, who keeps asking *How do you feel today*.
6 |
7 | Through the tutorial, we are going to build a simple app to record your everyday mood. By the end of the tutorial, we will have an app with two pages, one for recording today's mood, the other for calendar.
8 |
9 | 
10 | 
11 |
12 | I hope to learn these frameworks better through practice, and deepen impression towards them through writing this book. You're welcomed to contribute code or help edit this book if you wish. Leave comment about your thoughts!
13 |
14 | I'm writing a book at [GitBook](https://www.gitbook.com/book/ovilia/hybrid-framework-tutorial/details) along with updating this project.
15 |
--------------------------------------------------------------------------------
/assets/img/book-illustration/1.1-device-toolbar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/book-illustration/1.1-device-toolbar.jpg
--------------------------------------------------------------------------------
/assets/img/book-illustration/1.1-galaxy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/book-illustration/1.1-galaxy.png
--------------------------------------------------------------------------------
/assets/img/book-illustration/1.2-detail-page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/book-illustration/1.2-detail-page.png
--------------------------------------------------------------------------------
/assets/img/book-illustration/1.2-file-structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/book-illustration/1.2-file-structure.png
--------------------------------------------------------------------------------
/assets/img/calendar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/calendar.png
--------------------------------------------------------------------------------
/assets/img/happy-h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/happy-h.png
--------------------------------------------------------------------------------
/assets/img/happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/happy.png
--------------------------------------------------------------------------------
/assets/img/happy_dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/happy_dragon.png
--------------------------------------------------------------------------------
/assets/img/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/home.png
--------------------------------------------------------------------------------
/assets/img/na-h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/na-h.png
--------------------------------------------------------------------------------
/assets/img/na.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/na.png
--------------------------------------------------------------------------------
/assets/img/sad-h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/sad-h.png
--------------------------------------------------------------------------------
/assets/img/sad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/img/sad.png
--------------------------------------------------------------------------------
/assets/sketch/dragon.sketch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/assets/sketch/dragon.sketch
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | www/build/
3 | platforms/
4 | plugins/
5 | .DS_Store
6 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/app.ts:
--------------------------------------------------------------------------------
1 | import {Component} from '@angular/core';
2 | import {Platform, ionicBootstrap} from 'ionic-angular';
3 | import {StatusBar} from 'ionic-native';
4 | import {HomePage} from './pages/home/home';
5 |
6 |
7 | @Component({
8 | template: ''
9 | })
10 | export class MyApp {
11 | rootPage: any = HomePage;
12 |
13 | constructor(platform: Platform) {
14 | platform.ready().then(() => {
15 | // Okay, so the platform is ready and our plugins are available.
16 | // Here you can do any higher level native things you might need.
17 | StatusBar.styleDefault();
18 | });
19 | }
20 | }
21 |
22 | ionicBootstrap(MyApp);
23 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/detail/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Detail
4 |
5 |
6 |
7 |
8 | Button Clicked:
9 | {{color}}
10 |
11 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/detail/detail.scss:
--------------------------------------------------------------------------------
1 | .detail {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/detail/detail.ts:
--------------------------------------------------------------------------------
1 | import {Component} from "@angular/core";
2 | import {NavController, NavParams} from 'ionic-angular';
3 |
4 | @Component({
5 | templateUrl: 'build/pages/detail/detail.html'
6 | })
7 | export class DetailPage {
8 | color: string;
9 |
10 | constructor(private _navController: NavController, private _navParams: NavParams) {
11 | this.color = _navParams.get('color');
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |

5 |
6 |
7 |
How do you feel today?
8 |
13 |
14 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/home.scss:
--------------------------------------------------------------------------------
1 | .home {
2 |
3 | .main {
4 | $mainHeight: 205px;
5 | width: 70%;
6 | height: $mainHeight;
7 | position: absolute;
8 | top: 50%;
9 | left: 15%;
10 | margin: 0 auto;
11 | margin-top: -$mainHeight / 2;
12 |
13 | text-align: center;
14 | }
15 |
16 | .mood-question {
17 | margin: 20px 0 5px 0;
18 |
19 | color: map-get($colors, 'textLight');
20 | font-size: 0.9em;
21 | }
22 |
23 | .mood-option {
24 | $moodOptionSize: 32px;
25 | width: $moodOptionSize;
26 | max-width: 30%;
27 | height: $moodOptionSize;
28 | display: inline-block;
29 |
30 | background-repeat: no-repeat;
31 | background-size: 100%;
32 |
33 | + .mood-option {
34 | margin-left: 5px;
35 | }
36 | }
37 |
38 | @each $mood in happy, neutral, sad {
39 | .mood-#{$mood} {
40 | background-image: url('../img/#{$mood}.png');
41 |
42 | &.selected {
43 | background-image: url('../img/#{$mood}_h.png');
44 | }
45 | }
46 | }
47 |
48 | .icon-panel a {
49 | font-size: 32px;
50 | color: #eee;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/home.ts:
--------------------------------------------------------------------------------
1 | import {Component} from "@angular/core";
2 | import {NavController} from 'ionic-angular';
3 | import {DetailPage} from '../detail/detail';
4 |
5 | @Component({
6 | templateUrl: 'build/pages/home/home.html'
7 | })
8 | export class HomePage {
9 | constructor(private _navController: NavController) {
10 |
11 | }
12 |
13 | pushPage() {
14 | this._navController.push(DetailPage);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/happy.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/happy_dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/happy_dragon.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/happy_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/happy_h.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/neutral.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/neutral.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/neutral_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/neutral_h.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/sad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/sad.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/pages/home/img/sad_h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ovilia/Hybrid-Frameworks-Tutorial/197a936f38e14aadc083dff7da94f97a74bb4fa4/ionic2/toothy-dragon/app/pages/home/img/sad_h.png
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.common.scss:
--------------------------------------------------------------------------------
1 | img {
2 | max-width: 100%;
3 | }
4 |
5 | .top-right {
6 | position: absolute;
7 | display: inline-block;
8 | right: $padding;
9 | top: $padding-lg;
10 | }
11 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.core.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 | // App Shared Imports
4 | // --------------------------------------------------
5 | // These are the imports which make up the design of this app.
6 | // By default each design mode includes these shared imports.
7 | // App Shared Sass variables belong in app.variables.scss.
8 |
9 | @import "./app.common.scss";
10 |
11 | @import "../pages/home/home";
12 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.ios.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // Shared Sass variables go in the app.variables.scss file
7 | @import "app.variables";
8 |
9 |
10 | // App iOS Variables
11 | // --------------------------------------------------
12 | // iOS only Sass variables can go here
13 |
14 |
15 | // Ionic iOS Sass
16 | // --------------------------------------------------
17 | // Custom App variables must be declared before importing Ionic.
18 | // Ionic will use its default values when a custom variable isn't provided.
19 | @import "ionic.ios";
20 |
21 |
22 | // App Shared Sass
23 | // --------------------------------------------------
24 | // All Sass files that make up this app goes into the app.core.scss file.
25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS.
26 | @import "app.core";
27 |
28 |
29 | // App iOS Only Sass
30 | // --------------------------------------------------
31 | // CSS that should only apply to the iOS app
32 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.md.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // Shared Sass variables go in the app.variables.scss file
7 | @import "app.variables";
8 |
9 |
10 | // App Material Design Variables
11 | // --------------------------------------------------
12 | // Material Design only Sass variables can go here
13 |
14 |
15 | // Ionic Material Design Sass
16 | // --------------------------------------------------
17 | // Custom App variables must be declared before importing Ionic.
18 | // Ionic will use its default values when a custom variable isn't provided.
19 | @import "ionic.md";
20 |
21 |
22 | // App Shared Sass
23 | // --------------------------------------------------
24 | // All Sass files that make up this app goes into the app.core.scss file.
25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS.
26 | @import "app.core";
27 |
28 |
29 | // App Material Design Only Sass
30 | // --------------------------------------------------
31 | // CSS that should only apply to the Material Design app
32 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.variables.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 | // Ionic Shared Functions
4 | // --------------------------------------------------
5 | // Makes Ionic Sass functions available to your App
6 |
7 | @import "globals.core";
8 |
9 | // App Shared Variables
10 | // --------------------------------------------------
11 | // To customize the look and feel of this app, you can override
12 | // the Sass variables found in Ionic's source scss files. Setting
13 | // variables before Ionic's Sass will use these variables rather than
14 | // Ionic's default Sass variable values. App Shared Sass imports belong
15 | // in the app.core.scss file and not this file. Sass variables specific
16 | // to the mode belong in either the app.ios.scss or app.md.scss files.
17 |
18 |
19 | // App Shared Color Variables
20 | // --------------------------------------------------
21 | // It's highly recommended to change the default colors
22 | // to match your app's branding. Ionic uses a Sass map of
23 | // colors so you can add, rename and remove colors as needed.
24 | // The "primary" color is the only required color in the map.
25 | // Both iOS and MD colors can be further customized if colors
26 | // are different per mode.
27 |
28 | $colors: (
29 | primary: #387ef5,
30 | secondary: #32db64,
31 | danger: #f53d3d,
32 | light: #f4f4f4,
33 | dark: #222,
34 | favorite: #69BB7B,
35 |
36 | text: #333,
37 | textLight: #777
38 | );
39 |
40 | $padding: 10px;
41 | $padding-lg: 20px;
42 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/app/theme/app.wp.scss:
--------------------------------------------------------------------------------
1 | // http://ionicframework.com/docs/v2/theming/
2 |
3 |
4 | // App Shared Variables
5 | // --------------------------------------------------
6 | // Shared Sass variables go in the app.variables.scss file
7 | @import "app.variables";
8 |
9 |
10 | // App Windows Variables
11 | // --------------------------------------------------
12 | // Windows only Sass variables can go here
13 |
14 |
15 | // Ionic Windows Sass
16 | // --------------------------------------------------
17 | // Custom App variables must be declared before importing Ionic.
18 | // Ionic will use its default values when a custom variable isn't provided.
19 | @import "ionic.wp";
20 |
21 |
22 | // App Shared Sass
23 | // --------------------------------------------------
24 | // All Sass files that make up this app goes into the app.core.scss file.
25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS.
26 | @import "app.core";
27 |
28 |
29 | // App Windows Only Sass
30 | // --------------------------------------------------
31 | // CSS that should only apply to the Windows app
32 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | toothy-dragon
4 | An Ionic Framework and Cordova project.
5 | Ionic Framework Team
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp'),
2 | gulpWatch = require('gulp-watch'),
3 | gulpCopy = require('gulp-copy'),
4 | del = require('del'),
5 | runSequence = require('run-sequence'),
6 | argv = process.argv;
7 |
8 |
9 | /**
10 | * Ionic hooks
11 | * Add ':before' or ':after' to any Ionic project command name to run the specified
12 | * tasks before or after the command.
13 | */
14 | gulp.task('serve:before', ['watch']);
15 | gulp.task('emulate:before', ['build']);
16 | gulp.task('deploy:before', ['build']);
17 | gulp.task('build:before', ['build']);
18 |
19 | // we want to 'watch' when livereloading
20 | var shouldWatch = argv.indexOf('-l') > -1 || argv.indexOf('--livereload') > -1;
21 | gulp.task('run:before', [shouldWatch ? 'watch' : 'build']);
22 |
23 | /**
24 | * Ionic Gulp tasks, for more information on each see
25 | * https://github.com/driftyco/ionic-gulp-tasks
26 | *
27 | * Using these will allow you to stay up to date if the default Ionic 2 build
28 | * changes, but you are of course welcome (and encouraged) to customize your
29 | * build however you see fit.
30 | */
31 | var buildBrowserify = require('ionic-gulp-browserify-typescript');
32 | var buildSass = require('ionic-gulp-sass-build');
33 | var copyHTML = require('ionic-gulp-html-copy');
34 | var copyFonts = require('ionic-gulp-fonts-copy');
35 | var copyScripts = require('ionic-gulp-scripts-copy');
36 |
37 | var isRelease = argv.indexOf('--release') > -1;
38 |
39 | gulp.task('watch', ['clean'], function(done){
40 | runSequence(
41 | ['sass', 'html', 'fonts', 'scripts', 'resource'],
42 | function(){
43 | gulpWatch('app/**/*.scss', function(){ gulp.start('sass'); });
44 | gulpWatch('app/**/*.html', function(){ gulp.start('html'); });
45 | buildBrowserify({ watch: true }).on('end', done);
46 | }
47 | );
48 | });
49 |
50 | gulp.task('build', ['clean'], function(done){
51 | runSequence(
52 | ['sass', 'html', 'fonts', 'scripts', 'resource'],
53 | function(){
54 | buildBrowserify({
55 | minify: isRelease,
56 | browserifyOptions: {
57 | debug: !isRelease
58 | },
59 | uglifyOptions: {
60 | mangle: false
61 | }
62 | }).on('end', done);
63 | }
64 | );
65 | });
66 |
67 | gulp.task('sass', buildSass);
68 | gulp.task('html', copyHTML);
69 | gulp.task('fonts', copyFonts);
70 | gulp.task('scripts', copyScripts);
71 | gulp.task('clean', function(){
72 | return del('www/build');
73 | });
74 |
75 | gulp.task('resource', function() {
76 | return gulp.src('app/**/img/**')
77 | .pipe(gulpCopy('www/build/img', {
78 | prefix: 4
79 | }));
80 | });
81 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/hooks/README.md:
--------------------------------------------------------------------------------
1 |
21 | # Cordova Hooks
22 |
23 | Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. Hook scripts could be defined by adding them to the special predefined folder (`/hooks`) or via configuration files (`config.xml` and `plugin.xml`) and run serially in the following order:
24 | * Application hooks from `/hooks`;
25 | * Application hooks from `config.xml`;
26 | * Plugin hooks from `plugins/.../plugin.xml`.
27 |
28 | __Remember__: Make your scripts executable.
29 |
30 | __Note__: `.cordova/hooks` directory is also supported for backward compatibility, but we don't recommend using it as it is deprecated.
31 |
32 | ## Supported hook types
33 | The following hook types are supported:
34 |
35 | after_build/
36 | after_compile/
37 | after_docs/
38 | after_emulate/
39 | after_platform_add/
40 | after_platform_rm/
41 | after_platform_ls/
42 | after_plugin_add/
43 | after_plugin_ls/
44 | after_plugin_rm/
45 | after_plugin_search/
46 | after_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed
47 | after_prepare/
48 | after_run/
49 | after_serve/
50 | before_build/
51 | before_compile/
52 | before_docs/
53 | before_emulate/
54 | before_platform_add/
55 | before_platform_rm/
56 | before_platform_ls/
57 | before_plugin_add/
58 | before_plugin_ls/
59 | before_plugin_rm/
60 | before_plugin_search/
61 | before_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed
62 | before_plugin_uninstall/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being uninstalled
63 | before_prepare/
64 | before_run/
65 | before_serve/
66 | pre_package/ <-- Windows 8 and Windows Phone only.
67 |
68 | ## Ways to define hooks
69 | ### Via '/hooks' directory
70 | To execute custom action when corresponding hook type is fired, use hook type as a name for a subfolder inside 'hooks' directory and place you script file here, for example:
71 |
72 | # script file will be automatically executed after each build
73 | hooks/after_build/after_build_custom_action.js
74 |
75 |
76 | ### Config.xml
77 |
78 | Hooks can be defined in project's `config.xml` using `` elements, for example:
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | ...
89 |
90 |
91 |
92 |
93 |
94 |
95 | ...
96 |
97 |
98 | ### Plugin hooks (plugin.xml)
99 |
100 | As a plugin developer you can define hook scripts using `` elements in a `plugin.xml` like that:
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | ...
109 |
110 |
111 | `before_plugin_install`, `after_plugin_install`, `before_plugin_uninstall` plugin hooks will be fired exclusively for the plugin being installed/uninstalled.
112 |
113 | ## Script Interface
114 |
115 | ### Javascript
116 |
117 | If you are writing hooks in Javascript you should use the following module definition:
118 | ```javascript
119 | module.exports = function(context) {
120 | ...
121 | }
122 | ```
123 |
124 | You can make your scipts async using Q:
125 | ```javascript
126 | module.exports = function(context) {
127 | var Q = context.requireCordovaModule('q');
128 | var deferral = new Q.defer();
129 |
130 | setTimeout(function(){
131 | console.log('hook.js>> end');
132 | deferral.resolve();
133 | }, 1000);
134 |
135 | return deferral.promise;
136 | }
137 | ```
138 |
139 | `context` object contains hook type, executed script full path, hook options, command-line arguments passed to Cordova and top-level "cordova" object:
140 | ```json
141 | {
142 | "hook": "before_plugin_install",
143 | "scriptLocation": "c:\\script\\full\\path\\appBeforePluginInstall.js",
144 | "cmdLine": "The\\exact\\command\\cordova\\run\\with arguments",
145 | "opts": {
146 | "projectRoot":"C:\\path\\to\\the\\project",
147 | "cordova": {
148 | "platforms": ["wp8"],
149 | "plugins": ["com.plugin.withhooks"],
150 | "version": "0.21.7-dev"
151 | },
152 | "plugin": {
153 | "id": "com.plugin.withhooks",
154 | "pluginInfo": {
155 | ...
156 | },
157 | "platform": "wp8",
158 | "dir": "C:\\path\\to\\the\\project\\plugins\\com.plugin.withhooks"
159 | }
160 | },
161 | "cordova": {...}
162 | }
163 |
164 | ```
165 | `context.opts.plugin` object will only be passed to plugin hooks scripts.
166 |
167 | You can also require additional Cordova modules in your script using `context.requireCordovaModule` in the following way:
168 | ```javascript
169 | var Q = context.requireCordovaModule('q');
170 | ```
171 |
172 | __Note__: new module loader script interface is used for the `.js` files defined via `config.xml` or `plugin.xml` only.
173 | For compatibility reasons hook files specified via `/hooks` folders are run via Node child_process spawn, see 'Non-javascript' section below.
174 |
175 | ### Non-javascript
176 |
177 | Non-javascript scripts are run via Node child_process spawn from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:
178 |
179 | * CORDOVA_VERSION - The version of the Cordova-CLI.
180 | * CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
181 | * CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
182 | * CORDOVA_HOOK - Path to the hook that is being executed.
183 | * CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
184 |
185 | If a script returns a non-zero exit code, then the parent cordova command will be aborted.
186 |
187 | ## Writing hooks
188 |
189 | We highly recommend writing your hooks using Node.js so that they are
190 | cross-platform. Some good examples are shown here:
191 |
192 | [http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)
193 |
194 | Also, note that even if you are working on Windows, and in case your hook scripts aren't bat files (which is recommended, if you want your scripts to work in non-Windows operating systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter it needs to use to launch the script. The shebang line should match the following example:
195 |
196 | #!/usr/bin/env [name_of_interpreter_executable]
197 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/hooks/after_prepare/010_add_platform_class.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | // Add Platform Class
4 | // v1.0
5 | // Automatically adds the platform class to the body tag
6 | // after the `prepare` command. By placing the platform CSS classes
7 | // directly in the HTML built for the platform, it speeds up
8 | // rendering the correct layout/style for the specific platform
9 | // instead of waiting for the JS to figure out the correct classes.
10 |
11 | var fs = require('fs');
12 | var path = require('path');
13 |
14 | var rootdir = process.argv[2];
15 |
16 | function addPlatformBodyTag(indexPath, platform) {
17 | // add the platform class to the body tag
18 | try {
19 | var platformClass = 'platform-' + platform;
20 | var cordovaClass = 'platform-cordova platform-webview';
21 |
22 | var html = fs.readFileSync(indexPath, 'utf8');
23 |
24 | var bodyTag = findBodyTag(html);
25 | if(!bodyTag) return; // no opening body tag, something's wrong
26 |
27 | if(bodyTag.indexOf(platformClass) > -1) return; // already added
28 |
29 | var newBodyTag = bodyTag;
30 |
31 | var classAttr = findClassAttr(bodyTag);
32 | if(classAttr) {
33 | // body tag has existing class attribute, add the classname
34 | var endingQuote = classAttr.substring(classAttr.length-1);
35 | var newClassAttr = classAttr.substring(0, classAttr.length-1);
36 | newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
37 | newBodyTag = bodyTag.replace(classAttr, newClassAttr);
38 |
39 | } else {
40 | // add class attribute to the body tag
41 | newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
42 | }
43 |
44 | html = html.replace(bodyTag, newBodyTag);
45 |
46 | fs.writeFileSync(indexPath, html, 'utf8');
47 |
48 | process.stdout.write('add to body class: ' + platformClass + '\n');
49 | } catch(e) {
50 | process.stdout.write(e);
51 | }
52 | }
53 |
54 | function findBodyTag(html) {
55 | // get the body tag
56 | try{
57 | return html.match(/])(.*?)>/gi)[0];
58 | }catch(e){}
59 | }
60 |
61 | function findClassAttr(bodyTag) {
62 | // get the body tag's class attribute
63 | try{
64 | return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
65 | }catch(e){}
66 | }
67 |
68 | if (rootdir) {
69 |
70 | // go through each of the platform directories that have been prepared
71 | var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
72 |
73 | for(var x=0; x
2 |
--------------------------------------------------------------------------------
/ionic2/toothy-dragon/typings/browser/ambient/es6-shim/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/es6-shim/es6-shim.d.ts
3 | // Type definitions for es6-shim v0.31.2
4 | // Project: https://github.com/paulmillr/es6-shim
5 | // Definitions by: Ron Buckton
6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7 |
8 | declare type PropertyKey = string | number | symbol;
9 |
10 | interface IteratorResult {
11 | done: boolean;
12 | value?: T;
13 | }
14 |
15 | interface IterableShim {
16 | /**
17 | * Shim for an ES6 iterable. Not intended for direct use by user code.
18 | */
19 | "_es6-shim iterator_"(): Iterator;
20 | }
21 |
22 | interface Iterator {
23 | next(value?: any): IteratorResult;
24 | return?(value?: any): IteratorResult;
25 | throw?(e?: any): IteratorResult;
26 | }
27 |
28 | interface IterableIteratorShim extends IterableShim, Iterator {
29 | /**
30 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code.
31 | */
32 | "_es6-shim iterator_"(): IterableIteratorShim;
33 | }
34 |
35 | interface StringConstructor {
36 | /**
37 | * Return the String value whose elements are, in order, the elements in the List elements.
38 | * If length is 0, the empty string is returned.
39 | */
40 | fromCodePoint(...codePoints: number[]): string;
41 |
42 | /**
43 | * String.raw is intended for use as a tag function of a Tagged Template String. When called
44 | * as such the first argument will be a well formed template call site object and the rest
45 | * parameter will contain the substitution values.
46 | * @param template A well-formed template string call site representation.
47 | * @param substitutions A set of substitution values.
48 | */
49 | raw(template: TemplateStringsArray, ...substitutions: any[]): string;
50 | }
51 |
52 | interface String {
53 | /**
54 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
55 | * value of the UTF-16 encoded code point starting at the string element at position pos in
56 | * the String resulting from converting this object to a String.
57 | * If there is no element at that position, the result is undefined.
58 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos.
59 | */
60 | codePointAt(pos: number): number;
61 |
62 | /**
63 | * Returns true if searchString appears as a substring of the result of converting this
64 | * object to a String, at one or more positions that are
65 | * greater than or equal to position; otherwise, returns false.
66 | * @param searchString search string
67 | * @param position If position is undefined, 0 is assumed, so as to search all of the String.
68 | */
69 | includes(searchString: string, position?: number): boolean;
70 |
71 | /**
72 | * Returns true if the sequence of elements of searchString converted to a String is the
73 | * same as the corresponding elements of this object (converted to a String) starting at
74 | * endPosition – length(this). Otherwise returns false.
75 | */
76 | endsWith(searchString: string, endPosition?: number): boolean;
77 |
78 | /**
79 | * Returns a String value that is made from count copies appended together. If count is 0,
80 | * T is the empty String is returned.
81 | * @param count number of copies to append
82 | */
83 | repeat(count: number): string;
84 |
85 | /**
86 | * Returns true if the sequence of elements of searchString converted to a String is the
87 | * same as the corresponding elements of this object (converted to a String) starting at
88 | * position. Otherwise returns false.
89 | */
90 | startsWith(searchString: string, position?: number): boolean;
91 |
92 | /**
93 | * Returns an HTML anchor element and sets the name attribute to the text value
94 | * @param name
95 | */
96 | anchor(name: string): string;
97 |
98 | /** Returns a HTML element */
99 | big(): string;
100 |
101 | /** Returns a