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

#2 Add Beta alert modal. #42

Merged
merged 2 commits into from
Sep 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/assets/javascripts/beta-alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$(function() {
if(Cookies.get('access') == undefined) {
Cookies.set('access', 'on', { expires: 7 });
$('#beta-alert-modal').modal()
}
});
28 changes: 28 additions & 0 deletions app/views/application/_beta_alert_modal.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.modal{:role => "dialog", :tabindex => "-1", :id => "beta-alert-modal" }
.modal-dialog{:role => "document"}
.modal-content
.modal-header
%h5.modal-title 〜 お知らせ 〜
%button.close{"aria-label" => "閉じる", "data-dismiss" => "modal", :type => "button"}
%span{"aria-hidden" => "true"} ×
.modal-body
%p
このサイトは、まだテスト公開中の段階です。
%br
十分注意はしていますが、予期しないバグなどが発生する場合があります。
%p
また、このサイトは人間と同じく、 6時間以上睡眠を取らないと動かなくなるようになっています。
%br
そのため、以下の時間帯は、このサイトにアクセスすることはできなくしています。
%ul
%li 1:00 AM ~ 7:00 AM

%p ご迷惑を色々とおかけしますが、よろしくお願いします。

%p
なお、旧サイトは
= link_to 'こちら', 'https://www.coderdojo.jp/'
です。

.modal-footer
%button.btn.btn-secondary{"data-dismiss" => "modal", :type => "button"} 閉じる
1 change: 1 addition & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
%meta{:coderdojo => "1881439892127060", :property => "fb:pages"}/
%meta{:content => "CoderDojo 岡山 岡南", :name => "author"}/
%body
= render 'beta_alert_modal'
= render 'header'
= yield
= render 'footer'
1 change: 1 addition & 0 deletions app/views/layouts/pages.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
%link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/

%body#page-top
= render 'beta_alert_modal'
= render 'header'
%article
%section#page-content
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/staticpages.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
%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"}/
%link{:href => "https://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic", :rel => "stylesheet", :type => "text/css"}/
%body#page-top
= render 'beta_alert_modal'
= render 'header'
= yield
= render 'footer'
165 changes: 165 additions & 0 deletions vendor/assets/javascripts/js.cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*!
* JavaScript Cookie v2.2.0
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}

function init (converter) {
function api (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}

// Write

if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);

if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}

// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';

try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}

if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}

key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);

var stringifiedAttributes = '';

for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += '=' + attributes[attributeName];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
}

// Read

if (!key) {
result = {};
}

// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;

for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');

if (!this.json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}

try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);

if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}

if (key === name) {
result = cookie;
break;
}

if (!key) {
result[name] = cookie;
}
} catch (e) {}
}

return result;
}

api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};

api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};

api.withConverter = init;

return api;
}

return init(function () {});
}));