Permalink
Browse files

Added bounds to page_size

  • Loading branch information...
davidmerfield committed Nov 16, 2018
1 parent 8871492 commit 754b72c0b4ec730a76d9778e2573416391a98e54
@@ -33,45 +33,56 @@ module.exports = function(req, res, next) {
);
}
function desnake(str) {
str = str.split("_").join(" ");
str = str[0].toUpperCase() + str.slice(1);
return str;
}
// Determine which HTML input we should show for each local
// on the settings page.
// on the settings page. It would be nice to be able to mark
// this up in package.json somehow for future Blot developers.
template.locals = arrayify(template.locals).map(function(local) {
if (local.name.indexOf("size") > -1 || local.name.indexOf("height") > -1) {
// show the number picker component for this local
local.label = local.name.split('_').join(' ');
local.label = local.label[0].toUpperCase() + local.label.slice(1);
if (local.label === 'Page size') local.label = 'Number of posts per page';
if (["page_size"].indexOf(local.name) > -1) {
// Show the number picker component for this local
local.range = true;
} else if (local.name.indexOf("color") > -1) {
local.label = local.name.split('_').join(' ');
local.label = desnake(local.name);
if (local.label === "Page size") {
local.label = "Number of posts per page";
local.min = 1;
local.max = 1000;
}
} else if (["background_color"].indexOf(local.name) > -1) {
// Show the color picker component for this local
local.label = local.name.split("_").join(" ");
local.label = local.label[0].toUpperCase() + local.label.slice(1);
// show the color picker component for this local
local.color = true;
} else if (local.name.indexOf("font") > -1) {
// show the font picker component for this local
local.font = true;
local.label = local.name.split('_').join(' ');
local.label = local.label[0].toUpperCase() + local.label.slice(1);
local.fonts = [
{
label: "Charter",
value: "charter",
selected: local.content === "charter" ? "selected" : ""
},
{
label: "Helvetica",
value: "Helvetica",
selected: local.content === "Helvetica" ? "selected" : ""
},
{
label: "Times New Roman",
value: "times",
selected: local.content === "times" ? "selected" : ""
}
];
} else {
}
// } else if (local.name.indexOf("font") > -1) {
// Show the font picker component for this local
// local.font = true;
// local.label = local.name.split('_').join(' ');
// local.label = local.label[0].toUpperCase() + local.label.slice(1);
// local.fonts = [
// {
// label: "Charter",
// value: "charter",
// selected: local.content === "charter" ? "selected" : ""
// },
// {
// label: "Helvetica",
// value: "Helvetica",
// selected: local.content === "Helvetica" ? "selected" : ""
// },
// {
// label: "Times New Roman",
// value: "times",
// selected: local.content === "times" ? "selected" : ""
// }
// ];
// }
else {
// use default template
local.default = true;
}
@@ -1,25 +1,15 @@
<div>
<b>{{label}}</b><br>
<label style="width:25%;float:left;margin-right:3.5%">
<input class="name" placeholder="e.g. background" type="hidden" value="{{name}}"/>
</label>
<label style="width:55.5%;float:left">
<input class="value" name="locals.{{name}}" placeholder="e.g. #FFFFFF" type="hidden" value="{{content}}"/>
</label>
<label>{{label}}</label>
<input class="name" placeholder="e.g. background" type="hidden" value="{{name}}"/>
<input class="value" name="locals.{{name}}" placeholder="e.g. #FFFFFF" type="hidden" value="{{content}}"/>
<div class="color-picker"></div>
<!-- <a style="margin-top:1.5rem" class="button right small secondary delete" class="right">Delete</a>
--><span class="clear"></span>
</div>
<hr style="margin-bottom:0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pickr-widget/dist/pickr.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/pickr-widget/dist/pickr.min.js"></script>
<style type="text/css">
.pcr-app.visible {z-index: 1} /* fixes bug with sidebar */
</style>
<script>// Simple example, see optional options for more configuration.
var pickr{{name}} = Pickr.create({
el: '.color-picker',
@@ -1,11 +1,7 @@
<div>
<b>{{label}}</b><br>
<input class="value" name="locals.{{name}}" placeholder="e.g. #FFFFFF" type="number" value="{{content}}"/>
<input class="name" placeholder="e.g. background" type="hidden" value="{{name}}"/>
<!-- <a style="margin-top:1.5rem" class="button right small secondary delete" class="right">Delete</a>
--><span class="clear"></span>
</div>
<label>{{label}}</label>
<input class="value" name="locals.{{name}}" type="number" min="{{min}}" max="{{max}}" value="{{content}}"/>
<input class="name" placeholder="e.g. background" type="hidden" value="{{name}}"/>
</div>
<hr>
@@ -5,6 +5,7 @@
<div id="variable-list" style="width:140%">
{{#locals}}
{{^default}}
{{#color}}
{{> color}}
{{/color}}
@@ -14,6 +15,15 @@
{{#font}}
{{> font}}
{{/font}}
{{/default}}
{{/locals}}
<input type="submit" class="button left" value="Save changes">
<hr><p>Variables: <a id="variable-add" style="float:right" class="button secondary">Add a variable</a>
</p>
{{#locals}}
{{#default}}
{{> default}}
{{/default}}
@@ -22,6 +32,4 @@
<input name="has_locals" type="hidden" value="true">
</div>
<div class="clear"></div>
<a id="variable-add" class="button secondary">Add a variable</a>
<div class="clear"></div>
<div class="clear"></div><br>

0 comments on commit 754b72c

Please sign in to comment.