This commit is contained in:
Henrique Dias
2015-09-19 14:25:35 +01:00
parent d8c619dd3c
commit 9773f5908b
21 changed files with 394 additions and 340 deletions

143
assets/src/js/app.js Normal file
View File

@@ -0,0 +1,143 @@
$(document).ready(function() {
$(document).pjax('a', '#main');
});
$(document).on('ready pjax:success', function() {
// Starts the perfect scroolbar plugin
$('.scroll').perfectScrollbar();
// Log out the user sending bad credentials to the server
$("#logout").click(function(e) {
e.preventDefault();
$.ajax({
type: "GET",
url: "/admin",
async: false,
username: "username",
password: "password",
headers: {
"Authorization": "Basic xxx"
}
}).fail(function() {
window.location = "/";
});
return false;
});
// If it's editor page
if ($(".editor")[0]) {
editor = false;
preview = $("#preview-area");
textarea = $("#content-area");
if (textarea[0]) {
options = {
mode: 'markdown',
theme: 'mdn-like',
lineWrapping: true,
lineNumbers: true,
scrollbarStyle: null
}
if (textarea.data("extension") == "markdown") {
options.lineNumbers = false
}
editor = CodeMirror.fromTextArea(textarea[0], options);
}
codemirror = $('.CodeMirror');
// Toggles between preview and editing mode
$("#preview").click(function(event) {
event.preventDefault();
// If it currently in the preview mode, hide the preview
// and show the editor
if ($(this).data("previewing") == "true") {
preview.hide();
codemirror.fadeIn();
$(this).data("previewing", "false");
notification({
text: "Think, relax and do the better you can!",
type: 'information',
timeout: 2000
});
} else {
// Copy the editor content to texteare
editor.save()
// If it's in editing mode, convert the markdown to html
// and show it
var converter = new showdown.Converter(),
text = textarea.val(),
html = converter.makeHtml(text);
// Hide the editor and show the preview
codemirror.hide();
preview.html(html).fadeIn();
$(this).data("previewing", "true");
notification({
text: "This is how your post looks like.",
type: 'information',
timeout: 2000
});
}
return false;
});
// Submites any form in the page in JSON format
$('form').submit(function(event) {
event.preventDefault();
var data = JSON.stringify($(this).serializeJSON()),
button = $(this).find("input[type=submit]:focus");
console.log(data)
$.ajax({
type: 'POST',
url: window.location,
data: data,
headers: {
'X-Regenerate': button.data("regenerate"),
'X-Content-Type': button.data("type")
},
dataType: 'json',
encode: true,
}).done(function(data) {
notification({
text: button.data("message"),
type: 'success',
timeout: 5000
});
}).fail(function(data) {
notification({
text: 'Something went wrong.',
type: 'error'
});
console.log(data);
});
});
// Adds one more field to the current group
// TODO: improve this function. add group/field/array/obj
$(".add").click(function(e) {
e.preventDefault();
fieldset = $(this).closest("fieldset");
fieldset.append("<input name=\"" + fieldset.attr("name") + "\" id=\"" + fieldset.attr("name") + "\" value=\"\"></input><br>");
return false;
});
}
});
$(document).on('pjax:send', function() {
$('#loading').fadeIn()
})
$(document).on('pjax:complete', function() {
$('#loading').fadeOut()
})

View File

@@ -0,0 +1,71 @@
$.noty.themes.admin = {
name: 'admin',
helpers: {},
modal: {
css: {
position: 'fixed',
width: '100%',
height: '100%',
backgroundColor: '#000',
zIndex: 10000,
opacity: 0.6,
display: 'none',
left: 0,
top: 0
}
}
};
$.noty.defaults = {
layout: 'topRight',
theme: 'admin',
dismissQueue: true,
animation: {
open: 'animated bounceInRight',
close: 'animated fadeOut',
easing: 'swing',
speed: 500 // opening & closing animation speed
},
timeout: false, // delay for closing event. Set false for sticky notifications
force: false, // adds notification to the beginning of queue when set to true
modal: false,
maxVisible: 5, // you can set max visible notification for dismissQueue true option,
killer: false, // for close all notifications before show
closeWith: ['click'], // ['click', 'button', 'hover', 'backdrop'] // backdrop click will close all notifications
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {},
onCloseClick: function() {},
},
buttons: false // an array of buttons
};
notification = function(options) {
var icon;
switch (options.type) {
case "success":
icon = '<i class="fa fa-check"></i>';
break;
case "error":
icon = '<i class="fa fa-times"></i>';
break;
case "warning":
icon = '<i class="fa fa-exclamation"></i>';
break;
case "information":
icon = '<i class="fa fa-info"></i>';
break;
default:
icon = '<i class="fa fa-bell"></i>';
}
var defaults = {
template: '<div class="noty_message"><span class="noty_icon">' + icon + '</span><span class="noty_text"></span></div>'
}
options = $.extend({}, defaults, options);
noty(options);
}

View File

@@ -0,0 +1,62 @@
#loading {
position : fixed;
height : calc(100% - 3em);
width : 100%;
top : 3em;
background-color: rgba(0,0,0,0.6);
z-index : 99999999;
display : none;
}
.double-bounce {
width : 5em;
height : 5em;
margin : 0 auto;
position : relative;
top : 50%;
transform: translateY(-50%);
}
.double-bounce .child {
width : 100%;
height : 100%;
border-radius : 50%;
background-color : #fff;
opacity : .6;
position : absolute;
top : 0;
left : 0;
-webkit-animation: doubleBounce 2s infinite ease-in-out;
animation : doubleBounce 2s infinite ease-in-out;
}
.double-bounce .double-bounce2 {
-webkit-animation-delay: -1.0s;
animation-delay : -1.0s;
}
@-webkit-keyframes doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform : scale(0);
}
50% {
-webkit-transform: scale(1);
transform : scale(1);
}
}
@keyframes doubleBounce {
0%,
100% {
-webkit-transform: scale(0);
transform : scale(0);
}
50% {
-webkit-transform: scale(1);
transform : scale(1);
}
}

View File

@@ -0,0 +1,160 @@
/* EDITOR GENERAL STYLES */
.editor .sidebar {
overflow-y : auto;
overflow-x : hidden;
color : #37474f;
box-sizing : border-box;
background-color: #ddd;
}
.editor .container {
overflow : hidden;
width : 100%;
box-sizing: border-box;
}
.full .container {
position: fixed;
top : 3em;
right : 0;
width : 75%;
height : calc(100% - 6em);
}
.editor .sidebar h2 {
margin-top: 0;
}
.editor #preview-area,
.editor textarea,
.CodeMirror {
position : relative;
box-sizing: border-box;
height : 100%;
width : 100%;
border : 0;
padding : 1.5em 10%;
font-size : 1.05em;
}
.CodeMirror {
padding: 0;
}
.cm-s-mdn-like.CodeMirror {
background: none;
}
.editor #preview-area *:first-child {
margin-top: 0;
}
.editor textarea {
resize : none;
font-family: monospace;
}
.editor textarea:focus {
outline: 0;
}
.editor input {
width : 100%;
background-color: rgba(0, 0, 0, 0.25);
color : rgba(255, 255, 255, 0.3);
border : 0;
border-radius : 5px;
padding : .5em 1em;
box-sizing : border-box;
}
.editor input:focus {
color : rgba(255, 255, 255, 0.7);
border: 0;
}
.editor h3 {
font-size : 1em;
margin : 0 0 .25em;
font-weight: bold;
}
.action-bar {
position : fixed;
bottom : 0;
right : 0;
width : 100%;
background-color: #455a64;
height : 3em;
display : flex;
padding : .5em 1em;
box-sizing : border-box;
z-index : 999;
}
.action-bar .left {
margin-right: auto;
}
.action-bar *:last-child {
margin-left: 1em;
}
/* EDITOR FRONTMATTER ONLY STYLES */
.frontmatter-only .box,
.content-only .box {
height: calc(100% - 6em);
}
.frontmatter-only .sidebar {
width: 100%;
}
.frontmatter-only input {
color: rgba(255,255,255,.4);
}
.frontmatter-only input:focus {
color: rgba(255,255,255,.85);
}
.frontmatter-only .action-bar input,
.frontmatter-only .action-bar input:focus {
color: #fff;
}
.frontmatter-only fieldset {
border-top: 1px solid rgba(0,0,0,.1);
}
.frontmatter-only h3 {
font-size: 1.5em;
}
/* EDITOR CONTENT ONLY STYLES */
.content-only #content-area,
.content-only #preview-area {
padding: 0;
}
/* EDITOR FULL STYLES */
.full .sidebar {
position : fixed;
left : 0;
top : 3em;
width : 25%;
padding : 1.5em 1em;
background-color: #37474f;
color : #ddd;
height : calc(100% - 3em);
}
.full .action-bar {
width: 75%;
}
.full .cm-s-mdn-like.CodeMirror {
width : auto;
margin: 3em 10%;
height: calc(100% - 6em);
}

View File

@@ -0,0 +1,98 @@
/* FORMS ELEMENTS */
form input {
color : rgba(0, 0, 0, 0.41);
width : 15em;
line-height : 1.25em;
margin : .5em 0;
border : 1px solid #fff;
transition : .5s ease-out all;
background-color: transparent;
}
form input:focus {
color : inherit;
outline : 0;
border-bottom: 1px solid #2196f3;
}
form label {
width : 10.5em;
display: inline-block;
margin : .1em 0 0;
}
form fieldset {
border : 0;
margin : 1em 0 0;
padding : 1em 0 0;
border-top: 1px solid rgba(255, 255, 255, 0.25);
}
form legend {
font-size: 1.5em;
}
input[type="file"] {
display: none;
}
button,
input[type="submit"] {
border : 0;
color : #fff;
margin : 0;
padding : .5em 1em;
border-radius : 10px;
font-size : .9em;
width : auto;
line-height : 1em;
background-color: #bbb;
transition : .3s ease all;
}
button,
input[type="submit"],
button:active,
input[type="submit"]:active,
button:hover,
input[type="submit"]:hover,
button:focus,
input[type="submit"]:focus {
outline: 0;
}
button:hover,
input[type="submit"]:hover,
button:active,
input[type="submit"]:active,
button:focus,
input[type="submit"]:focus {
background-color: #999;
color : #fff;
}
button.default,
input[type="submit"].default {
background-color: #2196f3;
}
button.default:hover,
input[type="submit"].default:hover,
button.default:active,
input[type="submit"].default:active {
background-color: #1e88e5;
}
button.add {
vertical-align: middle;
border-radius : 50%;
height : 1.5em;
width : 1.5em;
font-size : .7em;
padding : 0;
opacity : 0;
}
h3:hover > button.add {
opacity: 1;
}

View File

@@ -0,0 +1,67 @@
#noty_topRight_layout_container {
font-family : sans-serif;
top : 3.5em !important;
right : .5em !important;
position : fixed !important;
width : 310px;
height : auto;
margin : 0;
padding : 0;
list-style-type: none;
z-index : 10000000;
}
#noty_topRight_layout_container li {
overflow: hidden;
margin : 0 0 .25em;
}
.noty_bar {
color : #fff;
background-color: #cfd8dc;
border-radius : .3em;
}
.noty_message {
font-size : .75em;
font-weight: bold;
line-height: 1.2em;
text-align : left;
padding : 1em;
width : auto;
position : relative;
}
.noty_icon {
padding : 1em;
margin-left : -1em;
margin-right : .9em;
background-color : rgba(0,0,0,0.1);
border-top-left-radius : .3em;
border-bottom-left-radius: .3em;
text-align : center;
}
.noty_icon .fa {
width: 1em !important;
}
.noty_type_alert {
}
.noty_type_success {
background-color: #00c853;
}
.noty_type_error {
background-color: #ff5252;
}
.noty_type_warning {
background-color: #ffd600;
}
.noty_type_information {
background-color: #448aff;
}

View File

@@ -0,0 +1,146 @@
/* perfect-scrollbar v0.6.5 */
.ps-container {
-ms-touch-action: none;
overflow: hidden !important;
}
.ps-container.ps-active-x > .ps-scrollbar-x-rail, .ps-container.ps-active-y > .ps-scrollbar-y-rail {
display: block;
}
.ps-container.ps-in-scrolling {
pointer-events: none;
}
.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail {
background-color: #eee;
opacity: 0.9;
}
.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x {
background-color: #999;
}
.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail {
background-color: #eee;
opacity: 0.9;
}
.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y {
background-color: #999;
}
.ps-container > .ps-scrollbar-x-rail {
display: none;
position: absolute;
/* please don't change 'position' */
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
opacity: 0;
-webkit-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
-o-transition: background-color .2s linear, opacity .2s linear;
transition: background-color .2s linear, opacity .2s linear;
bottom: 3px;
/* there must be 'bottom' for ps-scrollbar-x-rail */
height: 8px;
}
.ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x {
position: absolute;
/* please don't change 'position' */
background-color: #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
-webkit-transition: background-color .2s linear;
-moz-transition: background-color .2s linear;
-o-transition: background-color .2s linear;
transition: background-color .2s linear;
bottom: 0;
/* there must be 'bottom' for ps-scrollbar-x */
height: 8px;
}
.ps-container > .ps-scrollbar-y-rail {
display: none;
position: absolute;
/* please don't change 'position' */
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
opacity: 0;
-webkit-transition: background-color .2s linear, opacity .2s linear;
-moz-transition: background-color .2s linear, opacity .2s linear;
-o-transition: background-color .2s linear, opacity .2s linear;
transition: background-color .2s linear, opacity .2s linear;
right: 3px;
/* there must be 'right' for ps-scrollbar-y-rail */
width: 8px;
}
.ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y {
position: absolute;
/* please don't change 'position' */
background-color: #aaa;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
-webkit-transition: background-color .2s linear;
-moz-transition: background-color .2s linear;
-o-transition: background-color .2s linear;
transition: background-color .2s linear;
right: 0;
/* there must be 'right' for ps-scrollbar-y */
width: 8px;
}
.ps-container:hover.ps-in-scrolling {
pointer-events: none;
}
.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail {
background-color: #eee;
opacity: 0.9;
}
.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x {
background-color: #999;
}
.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail {
background-color: #eee;
opacity: 0.9;
}
.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y {
background-color: #999;
}
.ps-container:hover > .ps-scrollbar-x-rail, .ps-container:hover > .ps-scrollbar-y-rail {
opacity: 0.6;
}
.ps-container:hover > .ps-scrollbar-x-rail:hover {
background-color: #eee;
opacity: 0.9;
}
.ps-container:hover > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x {
background-color: #999;
}
.ps-container:hover > .ps-scrollbar-y-rail:hover {
background-color: #eee;
opacity: 0.9;
}
.ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y {
background-color: #999;
}

160
assets/src/sass/main.scss Normal file
View File

@@ -0,0 +1,160 @@
body {
font-family: 'Roboto', sans-serif;
color : #212121;
height : 100%;
width : 100%;
}
h2 {
margin: .83em 0;
}
nav {
position : fixed;
top : 0;
left : 0;
height : 3em;
width : 100%;
background-color: #263238;
padding : 0 1em;
box-sizing : border-box;
z-index : 999;
color : #eee;
}
nav ul {
margin : 0;
padding: 0;
display: -webkit-box;
/* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box;
/* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox;
/* TWEENER - IE 10 */
display: -webkit-flex;
/* NEW - Chrome */
display: flex;
}
nav ul li {
list-style-type: none;
display : inline-block;
vertical-align : middle;
}
nav ul li:last-child {
margin-left: auto;
}
nav img {
height: 2em;
}
nav ul li a {
padding : .5em;
line-height : 2em;
display : block;
text-decoration: none;
color : inherit;
transition : .5s ease background-color;
}
nav ul li a:hover {
background-color: rgba(255, 255, 255, 0.57);
}
.box {
position: fixed;
top : 3em;
left : 0;
width : 100%;
height : calc(100% - 3em);
overflow: hidden;
}
header {
color : #fff;
background-color: #37474f;
padding : .67em 0;
}
header h1 {
margin: 0;
}
footer {
background-color: #ddd;
padding : 1.5em 0;
text-align : center;
color : rgba(0,0,0,0.5);
}
footer a {
text-decoration: none;
color : inherit;
}
footer p {
margin: 0;
}
main {
width: 100%;
}
.content {
margin : 1.5em auto;
width : 80%;
max-width: 800px;
}
.hidden {
display: none;
}
@import 'editor';
@import 'forms';
/* BROWSE */
.left {
text-align: left;
}
.right {
text-align: right;
}
.browse a {
color : inherit;
text-decoration: none;
}
.browse table {
width: 100%;
}
.browse .actions {
background-color: #455a64;
color : #fff;
padding : 1.5em 0;
}
.actions .content {
margin : 0 auto;
display: flex;
}
.actions .fa {
vertical-align: middle;
}
.actions .go-right {
margin-left: auto;
}
.browse tr {
line-height : 2em;
border-bottom: 1px solid rgba(0,0,0,0.03);
}
@import "scrollbar";
@import "notifications";
@import "animations";