2016/10/01 : IE 用に 縦スクロールバー用の設定を basic.css に追加しましたデモページBootstrap の css 部分のみ使用しています。なので、スマホでそのまま大差無く使用可能です。他ページへの移動や簡単な処理オプションの為、mmenu を使用して、スマホでも動作します。
ログイン情報の保持について Firebase の ログイン情報は localStorage に保存される為、ブラウザを閉じてもログインは保持されます。 テンプレートの mmenu と ハンバーガーアイコン部分 直接の動作とは関係無いので省いても問題はありません ( ソースコードの 13 〜 14 行, 118 〜 129 行, 142 〜 146 行, 220 〜 235 行 ) Firebase 実装部分 自分のコントロールパネルから『ウェブアプリに Firebase を追加』で取得可能な firebase.js と firebase.initializeApp( config ) 部分を該当部分に貼り付け直すだけです。 ( ソースコードの 17 〜 28 行 ) テンプレートの構造と機能の概要を印刷する PDF テンプレートの構造と機能の概要を印刷する PDF(ソースコードレベル) ソースコード
<!DOCTYPE html>
<html lang="ja">
<head>
<meta content="width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no" name="viewport">
<meta charset="utf-8">
<title>1会話・テンプレート(ログイン)</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<link id="link" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.mmenu/5.5.3/core/js/jquery.mmenu.min.all.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jQuery.mmenu/5.5.3/core/css/jquery.mmenu.all.css">
<link rel="stylesheet" href="std/mmenu.css">
<link rel="stylesheet" href="std/basic.css">
<script src="https://www.gstatic.com/firebasejs/3.4.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyD9vub84g_ckSvglTzMdLjXe1TV6WC8LCo",
authDomain: "lightbox-1c915.firebaseapp.com",
databaseURL: "https://lightbox-1c915.firebaseio.com",
storageBucket: "lightbox-1c915.appspot.com",
messagingSenderId: "694762121907"
};
firebase.initializeApp(config);
</script>
<style>
.fields {
width: 120px;
font-size: 12px;
vertical-align: middle!important;
}
legend {
font-size: 18px;
padding-left: 6px;
}
</style>
<script>
var options = {
row1 : { title : "ユーザ", css: { "background-color": "azure", "font-weight": "bold" } },
row2 : { title : "パスワード" },
row3 : { title : "" },
row_last : { title :"メッセージ" },
rrow1 : { title : "uid" },
rrow2 : { title : "email" },
rrow3 : { title : "emailVerified" },
rrow4 : { title : "displayName" },
rrow5 : { title : "isAnonymous" },
erow1 : { title : "code" },
erow2 : { title : "message" }
};
var login_user_info = null;
$(function(){
// 1) options による行とフィールドの設定
// 2) Bootstrap 用 form-control クラスの追加
$(".fields").each(function(){
$(this).text( options[ $(this).prop("id") ].title );
if ( options[ $(this).prop("id") ].css ) {
$(this).next().find("input,select").css( options[ $(this).prop("id") ].css );
}
$(this).next().find("input,select").addClass("form-control");
});
// 初期フォーカス
setTimeout( function(){$('#row1_fld').focus();}, 100 );
// ログイン処理
$("#login").on("click", function(){
// 結果の表示エリアを全てクリア
$(".result").next().text( "" );
// 入力チェック
if ( $("#row1_fld").val().trim() == "" ) {
$("#row_last").next().text("ユーザを入力して下さい");
return;
}
// **************************************
// Firebase ログイン
// **************************************
var auth = firebase.auth();
auth.signInWithEmailAndPassword($("#row1_fld").val(), $("#row2_fld").val())
.then(
// ログイン成功
function( user ) {
login_user_info = user;
$(".result").each(function(){
$(this).next().text( user[ options[ $(this).prop("id") ].title ] );
});
console.dir( user );
},
// ログイン失敗
function( error ) {
error["メッセージ"] = "ログインに失敗しました";
$(".error").each(function(){
$(this).next().text( error[ options[ $(this).prop("id") ].title ] );
});
console.dir( error );
}
);
} );
// **************************************
// mmenu
// **************************************
$("#mmenu_left").mmenu({
navbar: {
title: "メニュー"
},
offCanvas: {
position : "left",
zposition : "next"
}
});
});
</script>
</head>
<body>
<div id="wrapper">
<div id="head">
<a id="hamburger" href="#mmenu_left">
<span class="top-bar"></span>
<span class="middle-bar"></span>
<span class="bottom-bar"></span>
</a>
<div id="title">1会話・テンプレート(ログイン)</div>
</div>
<div id="body">
<form class="form-inline">
<fieldset>
<legend>ログイン</legend>
<table class="table table-condensed">
<tr>
<td class="fields" id="row1"></td>
<td>
<input type="text" id="row1_fld" name="row1_fld" value="abc@test.jp">
</td>
</tr>
<tr>
<td class="fields" id="row2"></td>
<td>
<input type="text" id="row2_fld" name="row2_fld" value="20160828">
</td>
</tr>
<tr>
<td class="fields" id="row3"></td>
<td>
<input id="login" type="button" class="btn btn-primary btn-sm" value="送信">
</td>
</tr>
<tr>
<td class="fields error" id="row_last"></td>
<td></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>結果</legend>
<table class="table table-condensed">
<tr><td class="fields result" id="rrow1"></td><td></td></tr>
<tr><td class="fields result" id="rrow2"></td><td></td></tr>
<tr><td class="fields result" id="rrow3"></td><td></td></tr>
<tr><td class="fields result" id="rrow4"></td><td></td></tr>
<tr><td class="fields result" id="rrow5"></td><td></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Firebase エラー</legend>
<table class="table table-condensed">
<tr><td class="fields result error" id="erow1"></td><td></td></tr>
<tr><td class="fields result error" id="erow2"></td><td></td></tr>
</table>
</fieldset>
</form>
</div>
<div id="comment">
ようこそ jQuery + Bootstrap(css) + mmenu + Firebase </div>
</div>
<div id="mmenu_left">
<ul>
<li class="mm_user_title">ページ選択</li>
<li><a class="mm_link_left" href="#" onclick="location='index.php';void(0)">リセット</a></li>
<li><a class="mm_link_left"
href="http://getbootstrap.com/css/"
onclick="location='entry.php';void(0)"
target="_blank"
>Bootstrap(css)</a></li>
<li><a class="mm_link_left"
href="http://api.jquery.com/"
onclick="location='entry.php';void(0)"
target="_blank"
>jQuery ドキュメント</a></li>
</ul>
</div>
</body>
</html>
mmenu と hamburger アイコン設定 ( mmenu.css )
#hamburger {
vertical-align: bottom;
border: 1px solid #999;
display: inline-block;
width: 50px;
padding: 5px 10px;
margin: 0 20px 0 8px;
}
#hamburger span {
background: #999;
display: block;
height: 3px;
margin: 5px 0;
}
html.mm-opened #hamburger span.top-bar {
transform: rotate( 45deg );
top: 8px;
}
html.mm-opened #hamburger span.middle-bar {
opacity: 0;
left: -40px;
}
html.mm-opened #hamburger span.bottom-bar {
transform: rotate( -45deg );
top: -8px;
}
#hamburger {
overflow: hidden;
}
#hamburger span {
position: relative;
transform: rotate( 0 );
top: 0;
left: 0;
opacity: 1;
transition: none 0.5s ease;
transition-property: transform, top, left, opacity;
}
.mm-menu {
background-color: #DAEEF2;
color: #444444;
}
.mm-title {
color: #222222!important;
font-size: 16px;
font-weight: bold;
}
.mm_user_title {
padding: 20px!important;
}
テンプレート用 CSS ( basic.css )
@charset "UTF-8";
* {
font-family: Arial, Helvetica, Verdana, "ヒラギノ角ゴPro W3", "Hiragino Kaku Gothic Pro", Osaka, "メイリオ", Meiryo, "MS Pゴシック", sans-serif!important;
}
#head {
background-color: #404040;
}
#title {
color: white;
display: inline-block;
line-height:40px;
}
#body {
margin: 20px 0 0 0;
}
td {
word-break: break-all;
}
.error {
background-color: #FFE8EC;
}
#comment {
padding: 20px;
border: solid 1px #ccc;
margin: 40px;
border-radius: 10px;
}
@-ms-viewport {
width: auto;
}
関連する記事 jQuery + Bootstrap(css) + mmenu : Firebase Database 新規登録テンプレート
|
|
【Googleの最新記事】
- Google 共有ドライブの容量の上限について
- Google Classroom は無料の G Suite for Education アカウントが必要
- 教室と一対一のフォルダより新しく登録されたフォルダの中にあるZoom動画ファイルを該当するClassroom の コース内の該当するトピックに登録する
- Google Apps Script : 動画を添付して Classroom の指定のトピックへ課題として投稿する
- Google Classroom のテーマ画像のサイズと既存画像をテーマ画像として使用してみた手順
- Google Chrome でスマホのソースコードをごく普通に表示して利用する
- Gmail に 実行可能なファイルの拡張子を持つファイルを格納した zip 書庫は送れません
- Gmail で添付できないファイルをエクスプローラで検索する為の文字列
- jQuery で既存 table より Firebase Database のデータを作成する
- jQuery + Bootstrap(css) + mmenu : Firebase Database 参照と更新サンプル( 新規登録テンプレートより )
- jQuery + Bootstrap(css) + mmenu : Firebase Database 新規登録テンプレート
- Google ドライブの WEBホスティングが無くなったので、Google の Firebase をとりあえず使う方法
- Google サイト内検索の FORM 要素による設置
- ブラウザの geolocation で Google MAP に現在地を表示。ライブラリでさらに詳細情報。API の geocoder で名称・住所から Google MAP を表示して、ライブラリで..
- Google+ に投稿するテキスト内の文字列を太字(ボールド)にしたりイタリックにしたりする方法
- Google の Plus API を使って Google+ 投稿データを jQuery UI のアコーディオン(accordion)で表示する
- Google の タスク API(ToDoリスト) を使ってタスクリストとタスクのタイトルを jQuery のプラグインでメニュー化する
- Google API の中でも単純な Task API を使って、アクセストークン取得のテンプレートを整備しました
- GitHub の google-api-php-client( PHP ) を使って、Gmail でメールを送る( 添付ファイル付き )
- GitHub の google-api-php-client( PHP ) を使って、Gmail でメールを送る



ログイン情報の保持について
Firebase の ログイン情報は localStorage に保存される為、ブラウザを閉じてもログインは保持されます。
テンプレートの mmenu と ハンバーガーアイコン部分
直接の動作とは関係無いので省いても問題はありません
( ソースコードの 13 〜 14 行, 118 〜 129 行, 142 〜 146 行, 220 〜 235 行 )
Firebase 実装部分
自分のコントロールパネルから『ウェブアプリに Firebase を追加』で取得可能な firebase.js と firebase.initializeApp( config ) 部分を該当部分に貼り付け直すだけです。
( ソースコードの 17 〜 28 行 )




