Last active
December 25, 2015 14:57
-
-
Save igara/fae1bed6a679907b9bcf to your computer and use it in GitHub Desktop.
OnsenUIでスマホアプリみたいなサイトを作ってみる ref: http://qiita.com/igara/items/92d0b58c4df21141429a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="../../../../css/lib/onsenui/onsenui.css" rel="stylesheet" type="text/css"> | |
<link href="../../../../css/lib/onsenui/onsen-css-components-dark-theme.css" rel="stylesheet" type="text/css"> | |
<script type="text/javascript" src="../../../../js/lib/systemjs/system.js"></script> | |
<script type="text/javascript" src="../../../../js/lib/angular/angular.min.js"></script> | |
<script type="text/javascript" src="../../../../js/lib/onsenui/onsenui.min.js"></script> | |
<script> | |
ons.bootstrap(); | |
</script> | |
</head> | |
<body> | |
<ng-include src="'../../common/design/design_menu.html'"></ng-include> | |
</body> | |
</html> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ヘッダー --> | |
<ons-toolbar> | |
<div class="left"> | |
<!-- サイドメニューを表示する三表示 --> | |
<ons-toolbar-button ng-click="menu.toggleMenu()"> | |
<ons-icon icon="bars"></ons-icon> | |
</ons-toolbar-button> | |
</div> | |
<!-- タイトル --> | |
<div class="center">SyoNet</div> | |
</ons-toolbar> | |
<!-- /ヘッダー --> | |
<!-- フッターを呼び出す --> | |
<ng-include src="'../../common/design/design_footer.html'"></ng-include> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install gulp --save-dev | |
npm install angular --save-dev | |
npm install onsenui --save-dev | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# プロジェクトのディレクトリ配下にいるときに下記実行 | |
./node_modules/.bin/gulp import | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
これでサイドナビゲーションとタブバーの実装ができる | |
# 所感 | |
今回はサーバ側で各コンテンツのテンプレートを全て静的に取得したが、 | |
せっかくAngularJS使っているのならば「ng-include」を用いてボタンタップ時にhtmlの内容を動的に取得しに行くのもいいなと感じた。 | |
初期で表示する部分はサーバで作成し、タップ後の処理はクライアントに任せてしまうのが良さそう。 | |
次世代バージョンでOnsenUI2やAngular2とかでているがどちらもalpha版、beta版である。 | |
OnsenUIの一部コンポーネントはAngularを用いなくても使えるようだがサイドナビゲーションなどはangularを用いらないといけないようである。 | |
http://onsen.io/2/reference/javascript.html | |
2015/12/5時点 | |
OnsenUI2ではまだサイドナビゲーションが使えない模様 | |
https://github.com/OnsenUI/OnsenUI/issues/1038 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
gulp.task('import', function() { | |
// onsenUIをpublic下に設置する。 | |
var onsenUIPath = 'node_modules/onsenui'; | |
gulp.src(onsenUIPath + '/css/**') | |
.pipe(gulp.dest('public/css/lib/onsenui')); | |
gulp.src(onsenUIPath + '/js/**') | |
.pipe(gulp.dest('public/js/lib/onsenui')); | |
// AngularJSをpublic下に設置する。 | |
var angularJSPath = 'node_modules/angular'; | |
gulp.src(angularJSPath + '/angular.min.js') | |
.pipe(gulp.dest('public/js/lib/angular')); | |
gulp.src(angularJSPath + '/angular-csp.css') | |
.pipe(gulp.dest('public/css/lib/angular')); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ヘッダー --> | |
<ons-template id="header.html"> | |
<ons-toolbar> | |
<div class="left"> | |
<!-- サイドメニューを表示する三表示 --> | |
<ons-toolbar-button ng-click="menu.toggleMenu()"> | |
<ons-icon icon="bars"></ons-icon> | |
</ons-toolbar-button> | |
</div> | |
<!-- タイトル --> | |
<div class="center">SyoNet</div> | |
</ons-toolbar> | |
<!-- フッターを呼び出す --> | |
<ng-include src="'tabbar.html'"></ng-include> | |
</ons-template> | |
<!-- /ヘッダー --> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="../css/lib/onsenui/onsenui.css" rel="stylesheet" type="text/css"> | |
<link href="../css/lib/onsenui/onsen-css-components-dark-theme.css" rel="stylesheet" type="text/css"> | |
<script type="text/javascript" src="../js/lib/systemjs/system.js"></script> | |
<script type="text/javascript" src="../js/lib/angular/angular.min.js"></script> | |
<script type="text/javascript" src="../js/lib/onsenui/onsenui.min.js"></script> | |
<script> | |
ons.bootstrap(); | |
</script> | |
</head> | |
<body> | |
@include('welcome.common.header') | |
@include('welcome.common.menu') | |
@include('welcome.common.footer') | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment