Skip to content

Commit

Permalink
New canvas: ability to apply custom CSS, experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
grompe committed Feb 16, 2016
1 parent c86d4eb commit 61f83a4
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Forum:

## CHANGELOG

1.74.2016.2
- New canvas: ability to apply custom CSS, experimental

1.73.2016.1
- New canvas: make Time+ button always visible
- New canvas: add pathseg polyfill for Chrome 48. No thanks to Google!
Expand Down
42 changes: 36 additions & 6 deletions drawception-anbt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @name Drawception ANBT
// @author Grom PE
// @namespace http://grompe.org.ru/
// @version 1.73.2016.1
// @version 1.74.2016.2
// @description Enhancement script for Drawception.com - Artists Need Better Tools
// @downloadURL https://raw.github.com/grompe/Drawception-ANBT/master/drawception-anbt.user.js
// @match http://drawception.com/*
Expand All @@ -14,7 +14,7 @@

function wrapped() {

var SCRIPT_VERSION = "1.73.2016.1";
var SCRIPT_VERSION = "1.74.2016.2";
var NEWCANVAS_VERSION = 24; // Increase to update the cached canvas

// == DEFAULT OPTIONS ==
Expand Down Expand Up @@ -50,6 +50,7 @@ var options =
bookmarkOwnCaptions: 0,
colorDoublePress: 0,
markStalePosts: 1,
newCanvasCSS: "",
};

/*
Expand Down Expand Up @@ -960,6 +961,17 @@ function deeper_main()
alert(e);
};

if (options.newCanvasCSS)
{
var parent = document.getElementsByTagName("head")[0];
if (!parent) parent = document.documentElement;
var style = document.createElement("style");
style.type = "text/css";
var textNode = document.createTextNode(options.newCanvasCSS);
style.appendChild(textNode);
parent.appendChild(style);
}

if (options.enableWacom)
{
var stupidPlugin = document.createElement("object");
Expand Down Expand Up @@ -3140,7 +3152,7 @@ window.updateScriptSettings = updateScriptSettings;
function updateScriptSettings(theForm)
{
var result = {};
$(theForm).find("input").each(function()
$(theForm).find("input,textarea").each(function()
{
if (this.type == "checkbox")
{
Expand All @@ -3162,6 +3174,15 @@ function updateScriptSettings(theForm)
return false;
}

function escapeHTML(t)
{
return t.toString().replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}

function addScriptSettings()
{
var theForm = $('<form class="regForm form-horizontal" action="#" onsubmit="return updateScriptSettings(this);"></form>');
Expand All @@ -3182,11 +3203,15 @@ function addScriptSettings()
}
else if (t == "number")
{
c.append('<b>' + desc + ':</b><input class="form-control" type="text" data-subtype="number" name="' + name + '" value="' + v + '">');
c.append('<b>' + desc + ':</b><input class="form-control" type="text" data-subtype="number" name="' + name + '" value="' + escapeHTML(v) + '">');
}
else if (t == "longstr")
{
c.append('<b>' + desc + ':</b><textarea class="form-control" name="' + name + '">' + escapeHTML(v) + '</textarea>');
}
else
{
c.append('<b>' + desc + ':</b><input class="form-control" type="text" name="' + name + '" value="' + v + '">');
c.append('<b>' + desc + ':</b><input class="form-control" type="text" name="' + name + '" value="' + escapeHTML(v) + '">');
}
div.append(c);
}
Expand Down Expand Up @@ -3237,7 +3262,12 @@ function addScriptSettings()
["markStalePosts", "boolean", "Mark stale forum posts"],
]
);
theForm.append('<div class="control-group"><div class="controls"><input name="submit" type="submit" class="btn btn-primary" value="Apply"> <b id="anbtSettingsOK" class="label label-theme_holiday" style="display:none">Saved!</b></div></div>');
addGroup("Advanced",
[
["newCanvasCSS", "longstr", 'Custom CSS for new canvas (experimental, <a href="https://github.com/grompe/Drawception-ANBT/tree/master/newcanvas_styles">get styles here</a>)'],
]
);
theForm.append('<br><div class="control-group"><div class="controls"><input name="submit" type="submit" class="btn btn-primary" value="Apply"> <b id="anbtSettingsOK" class="label label-theme_holiday" style="display:none">Saved!</b></div></div>');
$("#main").prepend(theForm);

// Extend "location" input to max server-accepted 65 characters
Expand Down
73 changes: 73 additions & 0 deletions newcanvas_styles/compact.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* "Compact" style, Warning: ugly hack */

@media screen and (max-width: 999px) and (min-width: 800px) {
body {
overflow-x: hidden;
}
#bl {
width: 410px;
}
#toolpane {
width: 180px;
height: 500px;
position: absolute;
margin-left: -200px;
}
#toolpane:after {
display: none;
}
#infopane {
width: 1px;
height: 500px;
position: absolute;
margin: 0 0 0 600px;
top: 0;
}
.submit {
position: absolute;
top: 500px;
left: -776px;
width: 156px;
height: 50px;
}
#timer {
width: 176px;
float: left;
-margin-top: 50px;
}
#colors {
width: 100px;
margin-left: 0px;
float: left;
}
#primary, #secondary {
width: 50px;
}
#tools {
width: 68px;
}
#tools button {
margin: 3px 0;
}
#gamemode {
position: absolute;
left: -790px;
top: -100px;
}
#gamebuttons {
width: 300px;
position: absolute;
margin-left: 0;
left: -600px;
top: -100px;
padding: 2px;
}
.sandbox #gamebuttons {
width: 350px;
left: -660px;
top: -62px;
}
.guidelines, #options {
display: none;
}
}
53 changes: 53 additions & 0 deletions newcanvas_styles/retro.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* "Retro" style */
#colors {
padding: 10px;
float: right;
}
.panel {
background: #666;
}
#colors b {
line-height: 30px;
margin: 4px 7px;
width: 32px;
height: 32px;
border: 2px solid #333;
border-radius: 100px;
}
#colors #eraser:before {
content: '';
}
#colors b:before {
opacity: 0;
}
#colors #eraser {
background: #fff url(http://drawception.com/img/draw_eraser.png) center no-repeat;
background-size: 50%;
}
#timer {
font-size: 26pt;
color: #aaa;
width: 120px;
float: right;
}
#tools {
width: 500px;
position: absolute;
left: 300px;
bottom: -70px;
}
#tools hr {
display: inline;
border: none;
margin: 5px;
}
#seekbar {
position: absolute;
bottom: -110px;
}
button, #play {
background-color: #FFFB8D;
}
button:hover, #play:hover {
background-color: #F6F166;
}
108 changes: 108 additions & 0 deletions newcanvas_styles/retrowhite.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* "Retro White" style */
body {
background: #FFF;
}
#myheader {
background: #6EE36E;
color: #FFF;
border-bottom: 1px solid #999;
}
a {
color: #AFE;
}
a.prominent {
color: #FFF;
}
a.prominent:hover {
color: #AFE;
}
#openmenu {
background-color: #6AD16A;
}
#openmenu:hover {
background-color: #6BCB6B;
}
#newcanvasyo {
background: #FFF;
}
.panel {
-background: #eee;
-border-color: #ddd;
background: transparent;
border: 1px solid #e3e3e3;
}
#colors b {
line-height: 30px;
margin: 4px 7px;
width: 32px;
height: 32px;
border: 2px solid #333;
border-radius: 100px;
}
#colors #eraser:before {
content: '';
}
#colors b:before {
opacity: 0;
}
#colors #eraser {
background: #fff url(http://drawception.com/img/draw_eraser.png) center no-repeat;
background-size: 50%;
}
#timer, #drawthis {
color: #333;
}
button, #play {
background-color: #FFFB8D;
}
button:hover, #play:hover {
background-color: #F6F166;
}
#palettename {
color: #eee;
background: #888;
border-radius: 5px;
}
#svgContainer {
border: 1px solid #c0c0c0;
}
#seekbar {
background: #DDD;
border: 10px solid #DDD;
}
.headerbutton {
background: #6ad16a;
color: #ded;
}
.headerbutton.active {
background: #337ab7;
color: #fff;
}
.headerbutton.active:hover {
background: #286090;
}
@media screen and (min-width: 1000px) {
#colors {
padding: 10px;
float: right;
}
#timer {
width: 120px;
float: right;
}
#tools {
width: 500px;
position: absolute;
left: 300px;
bottom: -70px;
}
#tools hr {
display: inline;
border: none;
margin: 5px;
}
#seekbar {
position: absolute;
bottom: -110px;
}
}
Loading

0 comments on commit 61f83a4

Please sign in to comment.