Skip to content
This repository was archived by the owner on Mar 19, 2020. It is now read-only.

Commit 44574cd

Browse files
author
YuSan(ゆ~さん)
authored
Merge pull request #45 from CoderDojo-Konan-Okayama/add/beta-alert-modal
[FIX REVERT] Add Beta alert modal.
2 parents d9bc8cd + 33816e5 commit 44574cd

File tree

7 files changed

+203
-0
lines changed

7 files changed

+203
-0
lines changed

app/assets/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
//= require scrollreveal.min.js
1919
//= require toastr
2020
//= require jquery.magnific-popup.min.js
21+
//= require js.cookie
2122

2223
//= require_tree .

app/assets/javascripts/beta-alert.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$(function() {
2+
if(Cookies.get('access') == undefined) {
3+
Cookies.set('access', 'on', { expires: 7 });
4+
$('#beta-alert-modal').modal()
5+
}
6+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.modal{:role => "dialog", :tabindex => "-1", :id => "beta-alert-modal" }
2+
.modal-dialog{:role => "document"}
3+
.modal-content
4+
.modal-header
5+
%h5.modal-title 〜 お知らせ 〜
6+
%button.close{"aria-label" => "閉じる", "data-dismiss" => "modal", :type => "button"}
7+
%span{"aria-hidden" => "true"} ×
8+
.modal-body
9+
%p
10+
このサイトは、まだテスト公開中の段階です。
11+
%br
12+
十分注意はしていますが、予期しないバグなどが発生する場合があります。
13+
%p
14+
また、このサイトは人間と同じく、 6時間以上睡眠を取らないと動かなくなるようになっています。
15+
%br
16+
そのため、以下の時間帯は、このサイトにアクセスすることはできなくしています。
17+
%ul
18+
%li 1:00 AM ~ 7:00 AM
19+
20+
%p ご迷惑を色々とおかけしますが、よろしくお願いします。
21+
22+
%p
23+
なお、旧サイトは
24+
= link_to 'こちら', 'https://www.coderdojo.jp/'
25+
です。
26+
27+
.modal-footer
28+
%button.btn.btn-secondary{"data-dismiss" => "modal", :type => "button"} 閉じる

app/views/layouts/application.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
%meta{:coderdojo => "1881439892127060", :property => "fb:pages"}/
2323
%meta{:content => "CoderDojo 岡山 岡南", :name => "author"}/
2424
%body
25+
= render 'beta_alert_modal'
2526
= render 'header'
2627
= yield
2728
= render 'footer'

app/views/layouts/pages.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
%link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/
2828

2929
%body#page-top
30+
= render 'beta_alert_modal'
3031
= render 'header'
3132
%article
3233
%section#page-content

app/views/layouts/staticpages.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
%link{:href => "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800", :rel => "stylesheet", :type => "text/css"}/
2525
%link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/
2626
%body#page-top
27+
= render 'beta_alert_modal'
2728
= render 'header'
2829
= yield
2930
= render 'footer'
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/*!
2+
* JavaScript Cookie v2.2.0
3+
* https://github.com/js-cookie/js-cookie
4+
*
5+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
6+
* Released under the MIT license
7+
*/
8+
;(function (factory) {
9+
var registeredInModuleLoader = false;
10+
if (typeof define === 'function' && define.amd) {
11+
define(factory);
12+
registeredInModuleLoader = true;
13+
}
14+
if (typeof exports === 'object') {
15+
module.exports = factory();
16+
registeredInModuleLoader = true;
17+
}
18+
if (!registeredInModuleLoader) {
19+
var OldCookies = window.Cookies;
20+
var api = window.Cookies = factory();
21+
api.noConflict = function () {
22+
window.Cookies = OldCookies;
23+
return api;
24+
};
25+
}
26+
}(function () {
27+
function extend () {
28+
var i = 0;
29+
var result = {};
30+
for (; i < arguments.length; i++) {
31+
var attributes = arguments[ i ];
32+
for (var key in attributes) {
33+
result[key] = attributes[key];
34+
}
35+
}
36+
return result;
37+
}
38+
39+
function init (converter) {
40+
function api (key, value, attributes) {
41+
var result;
42+
if (typeof document === 'undefined') {
43+
return;
44+
}
45+
46+
// Write
47+
48+
if (arguments.length > 1) {
49+
attributes = extend({
50+
path: '/'
51+
}, api.defaults, attributes);
52+
53+
if (typeof attributes.expires === 'number') {
54+
var expires = new Date();
55+
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
56+
attributes.expires = expires;
57+
}
58+
59+
// We're using "expires" because "max-age" is not supported by IE
60+
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
61+
62+
try {
63+
result = JSON.stringify(value);
64+
if (/^[\{\[]/.test(result)) {
65+
value = result;
66+
}
67+
} catch (e) {}
68+
69+
if (!converter.write) {
70+
value = encodeURIComponent(String(value))
71+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
72+
} else {
73+
value = converter.write(value, key);
74+
}
75+
76+
key = encodeURIComponent(String(key));
77+
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
78+
key = key.replace(/[\(\)]/g, escape);
79+
80+
var stringifiedAttributes = '';
81+
82+
for (var attributeName in attributes) {
83+
if (!attributes[attributeName]) {
84+
continue;
85+
}
86+
stringifiedAttributes += '; ' + attributeName;
87+
if (attributes[attributeName] === true) {
88+
continue;
89+
}
90+
stringifiedAttributes += '=' + attributes[attributeName];
91+
}
92+
return (document.cookie = key + '=' + value + stringifiedAttributes);
93+
}
94+
95+
// Read
96+
97+
if (!key) {
98+
result = {};
99+
}
100+
101+
// To prevent the for loop in the first place assign an empty array
102+
// in case there are no cookies at all. Also prevents odd result when
103+
// calling "get()"
104+
var cookies = document.cookie ? document.cookie.split('; ') : [];
105+
var rdecode = /(%[0-9A-Z]{2})+/g;
106+
var i = 0;
107+
108+
for (; i < cookies.length; i++) {
109+
var parts = cookies[i].split('=');
110+
var cookie = parts.slice(1).join('=');
111+
112+
if (!this.json && cookie.charAt(0) === '"') {
113+
cookie = cookie.slice(1, -1);
114+
}
115+
116+
try {
117+
var name = parts[0].replace(rdecode, decodeURIComponent);
118+
cookie = converter.read ?
119+
converter.read(cookie, name) : converter(cookie, name) ||
120+
cookie.replace(rdecode, decodeURIComponent);
121+
122+
if (this.json) {
123+
try {
124+
cookie = JSON.parse(cookie);
125+
} catch (e) {}
126+
}
127+
128+
if (key === name) {
129+
result = cookie;
130+
break;
131+
}
132+
133+
if (!key) {
134+
result[name] = cookie;
135+
}
136+
} catch (e) {}
137+
}
138+
139+
return result;
140+
}
141+
142+
api.set = api;
143+
api.get = function (key) {
144+
return api.call(api, key);
145+
};
146+
api.getJSON = function () {
147+
return api.apply({
148+
json: true
149+
}, [].slice.call(arguments));
150+
};
151+
api.defaults = {};
152+
153+
api.remove = function (key, attributes) {
154+
api(key, '', extend(attributes, {
155+
expires: -1
156+
}));
157+
};
158+
159+
api.withConverter = init;
160+
161+
return api;
162+
}
163+
164+
return init(function () {});
165+
}));

0 commit comments

Comments
 (0)