Merge branch 'develop' into feature/admin-gpm-dependencies

This commit is contained in:
Flavio Copes
2016-03-26 18:00:19 +01:00
14 changed files with 78 additions and 37 deletions

View File

@@ -107,7 +107,22 @@ class AdminController
} else { } else {
$nonce = $this->grav['uri']->param('admin-nonce'); $nonce = $this->grav['uri']->param('admin-nonce');
} }
if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) {
if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form'))
{
if ($this->task == 'addmedia') {
$message = sprintf($this->admin->translate('PLUGIN_ADMIN.FILE_TOO_LARGE', null, true), ini_get('post_max_size'));
//In this case it's more likely that the image is too big than POST can handle. Show message
$this->admin->json_response = [
'status' => 'error',
'message' => $message
];
return false;
}
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error'); $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
$this->admin->json_response = [ $this->admin->json_response = [
'status' => 'error', 'status' => 'error',

View File

@@ -484,6 +484,7 @@ PLUGIN_ADMIN:
FILE_ERROR_UPLOAD: "An error occurred while trying to upload the file" FILE_ERROR_UPLOAD: "An error occurred while trying to upload the file"
FILE_UNSUPPORTED: "Unsupported file type" FILE_UNSUPPORTED: "Unsupported file type"
ADD_ITEM: "Add item" ADD_ITEM: "Add item"
FILE_TOO_LARGE: "The file is too large to be uploaded, maximum allowed is %s according <br>to your PHP settings. Increase your `post_max_size` PHP setting"
INSTALLING: "Installing" INSTALLING: "Installing"
LOADING: "Loading.." LOADING: "Loading.."
DEPENDENCIES_NOT_MET_MESSAGE: "The following dependencies need to be fulfilled first:" DEPENDENCIES_NOT_MET_MESSAGE: "The following dependencies need to be fulfilled first:"

View File

@@ -4,6 +4,7 @@ form:
- name: username - name: username
type: text type: text
label: PLUGIN_ADMIN.USERNAME label: PLUGIN_ADMIN.USERNAME
autofocus: true
placeholder: "lowercase chars only, e.g. 'admin'" placeholder: "lowercase chars only, e.g. 'admin'"
validate: validate:
required: true required: true

View File

@@ -149,12 +149,19 @@ export default class ColorpickerField {
} }
reposition() { reposition() {
let ct = $('.content-wrapper')[0];
let offset = this.element[0].getBoundingClientRect(); let offset = this.element[0].getBoundingClientRect();
let ct = $('.content-wrapper')[0].getBoundingClientRect(); let ctOffset = ct.getBoundingClientRect();
let delta = { x: 0, y: 0 };
if (this.options.offset) {
delta.x = this.options.offset.x || 0;
delta.y = this.options.offset.y || 0;
}
this.wrapper.css({ this.wrapper.css({
top: offset.top + offset.height - ct.top, top: offset.top + offset.height + ct.scrollTop - ctOffset.top + delta.y,
left: offset.left - ct.left left: offset.left + ct.scrollLeft - ctOffset.left + delta.x
}); });
} }
@@ -206,9 +213,10 @@ export default class ColorpickerField {
let phi; let phi;
// Touch support // Touch support
if (event && event.changedTouches) { let touchEvents = event.changedTouches || (event.originalEvent && event.originalEvent.changedTouches);
x = (event.changedTouches ? event.changedTouches[0].pageX : 0) - offsetX; if (event && touchEvents) {
y = (event.changedTouches ? event.changedTouches[0].pageY : 0) - offsetY; x = (touchEvents ? touchEvents[0].pageX : 0) - offsetX;
y = (touchEvents ? touchEvents[0].pageY : 0) - offsetY;
} }
if (event && event.manualOpacity) { if (event && event.manualOpacity) {

View File

@@ -6,20 +6,16 @@ $('[name="task"][value="saveas"], [name="task"][value="switchlanguage"]').on('mo
let form = $(`#${element.attr('form')}`); let form = $(`#${element.attr('form')}`);
if (!form.length) { return; } if (!form.length) { return; }
fields.forEach((field) => { fields.forEach((field) => {
let value = element.attr(field); let value = element.attr(field);
if (!value) { return; } if (!value) { return; }
let input = form.find(`[name="data[${field}]"]`);
let input = form.find(`[name="${field}"]`);
if (!input.length) { if (!input.length) {
input = $(`<input type="hidden" name="${field}" value="" />`); input = $(`<input type="hidden" name="data[${field}]" value="" />`);
form.append(input); form.append(input);
} }
input.val(value); input.val(value);
}); });
return true; return true;

View File

@@ -1 +1,3 @@
@font-face{font-family:"Montserrat";font-weight:400;font-style:normal;src:url("../fonts/Montserrat-regular/Montserrat-regular.eot");src:url("../fonts/Montserrat-regular/Montserrat-regular.eot?#iefix") format("embedded-opentype"),local("Montserrat-regular"),url("../fonts/Montserrat-regular/Montserrat-regular.woff2") format("woff2"),url("../fonts/Montserrat-regular/Montserrat-regular.woff") format("woff"),url("../fonts/Montserrat-regular/Montserrat-regular.ttf") format("truetype"),url("../fonts/Montserrat-regular/Montserrat-regular.svg#Montserrat") format("svg")}@font-face{font-family:"Lato";font-weight:300;font-style:normal;src:url("../fonts/Lato-300/Lato-300.eot");src:url("../fonts/Lato-300/Lato-300.eot?#iefix") format("embedded-opentype"),local("Lato-300"),url("../fonts/Lato-300/Lato-300.woff2") format("woff2"),url("../fonts/Lato-300/Lato-300.woff") format("woff"),url("../fonts/Lato-300/Lato-300.ttf") format("truetype"),url("../fonts/Lato-300/Lato-300.svg#Lato") format("svg")}@font-face{font-family:"Lato";font-weight:400;font-style:normal;src:url("../fonts/Lato-regular/Lato-regular.eot");src:url("../fonts/Lato-regular/Lato-regular.eot?#iefix") format("embedded-opentype"),local("Lato-regular"),url("../fonts/Lato-regular/Lato-regular.woff2") format("woff2"),url("../fonts/Lato-regular/Lato-regular.woff") format("woff"),url("../fonts/Lato-regular/Lato-regular.ttf") format("truetype"),url("../fonts/Lato-regular/Lato-regular.svg#Lato") format("svg")}@font-face{font-family:"Lato";font-weight:700;font-style:normal;src:url("../fonts/Lato-700/Lato-700.eot");src:url("../fonts/Lato-700/Lato-700.eot?#iefix") format("embedded-opentype"),local("Lato-700"),url("../fonts/Lato-700/Lato-700.woff2") format("woff2"),url("../fonts/Lato-700/Lato-700.woff") format("woff"),url("../fonts/Lato-700/Lato-700.ttf") format("truetype"),url("../fonts/Lato-700/Lato-700.svg#Lato") format("svg")}@font-face{font-family:"Inconsolata";font-weight:400;font-style:normal;src:url("../fonts/Inconsolata-regular/Inconsolata-regular.eot");src:url("../fonts/Inconsolata-regular/Inconsolata-regular.eot?#iefix") format("embedded-opentype"),local("Inconsolata-regular"),url("../fonts/Inconsolata-regular/Inconsolata-regular.woff2") format("woff2"),url("../fonts/Inconsolata-regular/Inconsolata-regular.woff") format("woff"),url("../fonts/Inconsolata-regular/Inconsolata-regular.ttf") format("truetype"),url("../fonts/Inconsolata-regular/Inconsolata-regular.svg#Inconsolata") format("svg")}@font-face{font-family:"Inconsolata";font-weight:700;font-style:normal;src:url("../fonts/Inconsolata-700/Inconsolata-700.eot");src:url("../fonts/Inconsolata-700/Inconsolata-700.eot?#iefix") format("embedded-opentype"),local("Inconsolata-700"),url("../fonts/Inconsolata-700/Inconsolata-700.woff2") format("woff2"),url("../fonts/Inconsolata-700/Inconsolata-700.woff") format("woff"),url("../fonts/Inconsolata-700/Inconsolata-700.ttf") format("truetype"),url("../fonts/Inconsolata-700/Inconsolata-700.svg#Inconsolata") format("svg")}body,h5,h6,.badge,.note,.grav-mdeditor-preview,input,select,textarea,button,.selectize-input{font-family:"Lato","Helvetica","Tahoma","Geneva","Arial",sans-serif}h1,h2,h3,h4,#admin-menu li,.form-tabs>label,.label{font-family:"Montserrat","Helvetica","Tahoma","Geneva","Arial",sans-serif}code,kbd,pre,samp,body .CodeMirror{font-family:"Inconsolata","Monaco","Consolas","Lucida Console",monospace !important} @font-face{font-family:"Montserrat";font-weight:400;font-style:normal;src:url("../fonts/Montserrat-regular/Montserrat-regular.eot");src:url("../fonts/Montserrat-regular/Montserrat-regular.eot?#iefix") format("embedded-opentype"),local("Montserrat-regular"),url("../fonts/Montserrat-regular/Montserrat-regular.woff2") format("woff2"),url("../fonts/Montserrat-regular/Montserrat-regular.woff") format("woff"),url("../fonts/Montserrat-regular/Montserrat-regular.ttf") format("truetype"),url("../fonts/Montserrat-regular/Montserrat-regular.svg#Montserrat") format("svg")}@font-face{font-family:"Lato";font-weight:300;font-style:normal;src:url("../fonts/Lato-300/Lato-300.eot");src:url("../fonts/Lato-300/Lato-300.eot?#iefix") format("embedded-opentype"),local("Lato-300"),url("../fonts/Lato-300/Lato-300.woff2") format("woff2"),url("../fonts/Lato-300/Lato-300.woff") format("woff"),url("../fonts/Lato-300/Lato-300.ttf") format("truetype"),url("../fonts/Lato-300/Lato-300.svg#Lato") format("svg")}@font-face{font-family:"Lato";font-weight:400;font-style:normal;src:url("../fonts/Lato-regular/Lato-regular.eot");src:url("../fonts/Lato-regular/Lato-regular.eot?#iefix") format("embedded-opentype"),local("Lato-regular"),url("../fonts/Lato-regular/Lato-regular.woff2") format("woff2"),url("../fonts/Lato-regular/Lato-regular.woff") format("woff"),url("../fonts/Lato-regular/Lato-regular.ttf") format("truetype"),url("../fonts/Lato-regular/Lato-regular.svg#Lato") format("svg")}@font-face{font-family:"Lato";font-weight:700;font-style:normal;src:url("../fonts/Lato-700/Lato-700.eot");src:url("../fonts/Lato-700/Lato-700.eot?#iefix") format("embedded-opentype"),local("Lato-700"),url("../fonts/Lato-700/Lato-700.woff2") format("woff2"),url("../fonts/Lato-700/Lato-700.woff") format("woff"),url("../fonts/Lato-700/Lato-700.ttf") format("truetype"),url("../fonts/Lato-700/Lato-700.svg#Lato") format("svg")}@font-face{font-family:"Inconsolata";font-weight:400;font-style:normal;src:url("../fonts/Inconsolata-regular/Inconsolata-regular.eot");src:url("../fonts/Inconsolata-regular/Inconsolata-regular.eot?#iefix") format("embedded-opentype"),local("Inconsolata-regular"),url("../fonts/Inconsolata-regular/Inconsolata-regular.woff2") format("woff2"),url("../fonts/Inconsolata-regular/Inconsolata-regular.woff") format("woff"),url("../fonts/Inconsolata-regular/Inconsolata-regular.ttf") format("truetype"),url("../fonts/Inconsolata-regular/Inconsolata-regular.svg#Inconsolata") format("svg")}@font-face{font-family:"Inconsolata";font-weight:700;font-style:normal;src:url("../fonts/Inconsolata-700/Inconsolata-700.eot");src:url("../fonts/Inconsolata-700/Inconsolata-700.eot?#iefix") format("embedded-opentype"),local("Inconsolata-700"),url("../fonts/Inconsolata-700/Inconsolata-700.woff2") format("woff2"),url("../fonts/Inconsolata-700/Inconsolata-700.woff") format("woff"),url("../fonts/Inconsolata-700/Inconsolata-700.ttf") format("truetype"),url("../fonts/Inconsolata-700/Inconsolata-700.svg#Inconsolata") format("svg")}body,h5,h6,.badge,.note,.grav-mdeditor-preview,input,select,textarea,button,.selectize-input{font-family:"Lato","Helvetica","Tahoma","Geneva","Arial",sans-serif}h1,h2,h3,h4,#admin-menu li,.form-tabs>label,.label{font-family:"Montserrat","Helvetica","Tahoma","Geneva","Arial",sans-serif}code,kbd,pre,samp,body .CodeMirror{font-family:"Inconsolata","Monaco","Consolas","Lucida Console",monospace !important}
/*# sourceMappingURL=fonts.css.map */

File diff suppressed because one or more lines are too long

View File

@@ -15,7 +15,7 @@
"dependencies": { "dependencies": {
"bootstrap": "^3.3.6", "bootstrap": "^3.3.6",
"chartist": "^0.9.7", "chartist": "^0.9.7",
"codemirror": "^5.12.0", "codemirror": "^5.13.0",
"cookies-js": "^1.2.2", "cookies-js": "^1.2.2",
"debounce": "^1.0.0", "debounce": "^1.0.0",
"dropzone": "^4.3.0", "dropzone": "^4.3.0",
@@ -24,7 +24,7 @@
"gemini-scrollbar": "^1.3.2", "gemini-scrollbar": "^1.3.2",
"immutable": "^3.7.6", "immutable": "^3.7.6",
"immutablediff": "^0.4.2", "immutablediff": "^0.4.2",
"js-yaml": "^3.5.3", "js-yaml": "^3.5.5",
"mout": "^0.12.0", "mout": "^0.12.0",
"remodal": "^1.0.6", "remodal": "^1.0.6",
"selectize": "^0.12.1", "selectize": "^0.12.1",
@@ -35,12 +35,12 @@
"whatwg-fetch": "^0.11.0" "whatwg-fetch": "^0.11.0"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "^6.6.4", "babel-core": "^6.7.2",
"babel-loader": "^6.2.4", "babel-loader": "^6.2.4",
"babel-polyfill": "^6.6.1", "babel-polyfill": "^6.7.2",
"babel-preset-es2015": "^6.6.0", "babel-preset-es2015": "^6.6.0",
"css-loader": "^0.23.1", "css-loader": "^0.23.1",
"eslint": "^2.2.0", "eslint": "^2.4.0",
"eslint-loader": "^1.3.0", "eslint-loader": "^1.3.0",
"exports-loader": "^0.6.3", "exports-loader": "^0.6.3",
"gulp": "^3.9.1", "gulp": "^3.9.1",

View File

@@ -1,11 +1,9 @@
.g-colorpicker { .g-colorpicker {
@extend %g-transparent-bg;
position: relative; position: relative;
border-radius: $core-border-radius; border-radius: $core-border-radius;
max-width: 100%; max-width: 100%;
input { input {
color: #333;
width: 100% !important; width: 100% !important;
} }
@@ -30,18 +28,12 @@
.g-colorpicker-preview { .g-colorpicker-preview {
position: absolute; position: absolute;
top: -1px; top: 0px;
right: -1px; right: 0px;
bottom: -1px; bottom: 0px;
left: -1px; left: 0px;
border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0;
} }
&.light-text {
input, i {
color: $white;
}
}
} }
.cp-sprite { .cp-sprite {
@@ -52,7 +44,7 @@
.cp-wrapper { .cp-wrapper {
position: absolute; position: absolute;
width: 173px; width: 173px;
height: 208px; height: 211px;
background: white; background: white;
border: solid 1px #CCC; border: solid 1px #CCC;
box-shadow: 0 0 20px rgba(0, 0, 0, .2); box-shadow: 0 0 20px rgba(0, 0, 0, .2);

View File

@@ -0,0 +1,26 @@
{% extends "forms/field.html.twig" %}
{% set default_php_dateformat = "d-m-Y H:i" %}
{% set php_dateformat = config.system.pages.dateformat.default ?: default_php_dateformat %}
{% set js_dateformat = admin.dateformatToMomentJS(php_dateformat) %}
{% set value = (value is null ? field.default : value) %}
{% set value = (value is null ? value : value|date(php_dateformat)) %}
{% block input %}
<div class="form-input-wrapper datetime-picker-wrapper {{ field.size }}">
<input
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|e('html_attr')|join(', ') }}"
{% block input_attributes %}
type="text"
data-grav-datetime="{{ {'format': js_dateformat} | json_encode | e('html_attr') }}"
{% if field.validate.min %}min="{{ (field.validate.min is null ? field.validate.min : field.validate.min|date(php_dateformat)) }}"{% endif %}
{% if field.validate.max %}max="{{ (field.validate.max is null ? field.validate.max : field.validate.max|date(php_dateformat)) }}"{% endif %}
{{ parent() }}
{% endblock %}
/>
<span class="field-icons">
<i class="fa fa-fw fa-calendar"></i>
</span>
</div>
{% endblock %}

View File

@@ -17,7 +17,7 @@
{% for page in pages.children %} {% for page in pages.children %}
{% if page.routable() or field.show_all %} {% if page.routable() or field.show_all %}
<option {% if page.route == value %}selected="selected"{% endif %} value="{{ page.route }}"> <option {% if page.route == value or (field.multiple and page.route in value) %}selected="selected"{% endif %} value="{{ page.route }}">
{{indent}} {{ page.menu }} {{indent}} {{ page.menu }}
</option> </option>
{% endif %} {% endif %}

View File

@@ -1,8 +1,6 @@
<div class="form-field grid user-details"> <div class="form-field grid user-details">
<div class="form-label block size-1-3"> <div class="form-label block size-1-3">
<label><img src="https://www.gravatar.com/avatar/{{ data.email|md5 }}?s=128" /></label> <label><img src="https://www.gravatar.com/avatar/{{ data.email|md5 }}?s=128" /></label>
</div> </div>
<div class="form-data block size-2-3"> <div class="form-data block size-2-3">
<h2>{{ data.fullname }}</h2> <h2>{{ data.fullname }}</h2>