Implement embossed speed dial with custom close buttons
The close button position is wrong.
This commit is contained in:
parent
d3dbd33911
commit
5eb5663cf6
3 changed files with 81 additions and 244 deletions
BIN
data/close.png
Normal file
BIN
data/close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -4,166 +4,81 @@
|
||||||
This file is licensed under the terms of the expat license, see the file EXPAT.
|
This file is licensed under the terms of the expat license, see the file EXPAT.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<style>
|
<style>
|
||||||
html, body, #content {
|
* {
|
||||||
margin: 0px;
|
margin: 0;
|
||||||
padding: 0px
|
padding: 0;
|
||||||
|
cursor: default;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #4d4d4d;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
html, body {
|
||||||
text-align: center;
|
|
||||||
background-color: #fefefe;
|
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
#wrap {
|
outline: 0;
|
||||||
width: 660px;
|
|
||||||
height: 500px;
|
|
||||||
margin: 0px auto;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
#content {
|
||||||
margin-top: 40px;
|
width: 100%;
|
||||||
|
height: 95%;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.shortcut {
|
div.shortcut {
|
||||||
|
width: 25%;
|
||||||
|
height: 33%;
|
||||||
float: left;
|
float: left;
|
||||||
border: 1px solid #ccc;
|
|
||||||
position: relative;
|
|
||||||
margin: 20px 20px 0px 0px;
|
|
||||||
background-color: #fff;
|
|
||||||
-webkit-border-radius: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.right {
|
div.shortcut .preview {
|
||||||
margin-right: 0px;
|
width: 70%;
|
||||||
margin-left: 0px;
|
height: 60%;
|
||||||
|
margin: 20% auto;
|
||||||
|
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,.25), 0 0 2px #fff inset;
|
||||||
|
box-shadow: 0 1px 6px rgba(0,0,0,.25), 0 0 2px #fff inset;
|
||||||
|
background-image: -webkit-gradient(
|
||||||
|
linear, center top, center bottom,
|
||||||
|
from(#f6f6f6), to(#e3e3e3));
|
||||||
|
border: 1px solid #bebebe;
|
||||||
|
border-bottom-color: #a0a0a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.top {
|
div.shortcut .preview.new .add {
|
||||||
margin-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 50px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 10px 0px 0px 0px;
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: bold
|
|
||||||
margin: 10px 0px 0px 0px;
|
|
||||||
padding: 10px 5px 0px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 span:before {
|
|
||||||
content: "{click_to_add}";
|
|
||||||
font-size: 11px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 span {
|
|
||||||
font-size: 11px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.shortcut a {
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
display: block;
|
|
||||||
margin: 15px auto 0px;
|
|
||||||
background-color: #fafafa;
|
|
||||||
color: #aaa;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.shortcut a img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: 50%;
|
||||||
|
margin: 0 auto;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.shortcut a:hover {
|
.title {
|
||||||
border: 1px solid #999;
|
text-align: center;
|
||||||
}
|
margin-top: -12%;
|
||||||
|
|
||||||
div.shortcut p {
|
|
||||||
font-size: 12px;
|
|
||||||
margin: 0px;
|
|
||||||
padding: 5px 0px 0px;
|
|
||||||
color: #222;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
cursor: text;
|
||||||
|
|
||||||
div.clear {
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.activated {
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cross {
|
.cross {
|
||||||
height: 16px;
|
display: block;
|
||||||
width: 16px;
|
width: 27px;
|
||||||
margin-bottom: -17px;
|
height: 27px;
|
||||||
margin-top: 2px;
|
top: -14px;
|
||||||
background: url(stock://1/gtk-close) 98% 70% no-repeat;
|
left: -14px;
|
||||||
cursor: pointer;
|
background: url(res://close.png);
|
||||||
z-index: -4;
|
position: relative;
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cross:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.activated p {
|
|
||||||
cursor: text;
|
|
||||||
background: url(stock://1/gtk-edit) 98% 70% no-repeat;
|
|
||||||
opacity: 0.6;
|
|
||||||
color: rgba(0,0,0,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.activated p:hover {
|
|
||||||
opacity: 1;
|
|
||||||
color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.config {
|
|
||||||
position: absolute;
|
|
||||||
top: 0px;
|
|
||||||
padding: 12px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.config span {
|
|
||||||
color: #ccc;
|
|
||||||
margin-right: 10px;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.config span.config_option:hover {
|
|
||||||
color: #999;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.config span.config_label {
|
.box.added {
|
||||||
color: #ccc;
|
display:none;
|
||||||
cursor: default;
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.config span.config_option {
|
|
||||||
margin-left: 0px;
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.osd {
|
div.osd {
|
||||||
|
@ -187,7 +102,7 @@
|
||||||
|
|
||||||
var getAction = function (id)
|
var getAction = function (id)
|
||||||
{
|
{
|
||||||
var host = document.getElementById(id).childNodes[3].host;
|
var host = document.getElementById(id).childNodes[0].childNodes[0].host;
|
||||||
if (host)
|
if (host)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -205,7 +120,7 @@
|
||||||
|
|
||||||
var renameShortcut = function (id)
|
var renameShortcut = function (id)
|
||||||
{
|
{
|
||||||
var old_name = document.getElementById(id).childNodes[5].textContent;
|
var old_name = document.getElementById(id).childNodes[1].textContent;
|
||||||
|
|
||||||
var name = prompt ("{enter_shortcut_name}", old_name);
|
var name = prompt ("{enter_shortcut_name}", old_name);
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
|
@ -221,44 +136,6 @@
|
||||||
console.log ("speed_dial-save-delete " + id);
|
console.log ("speed_dial-save-delete " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
var setSize = function ()
|
|
||||||
{
|
|
||||||
|
|
||||||
var size = prompt ("{enter_dial_size}", columns + 'x' + rows);
|
|
||||||
|
|
||||||
if (!size) return;
|
|
||||||
|
|
||||||
var pos = size.indexOf('x');
|
|
||||||
|
|
||||||
if (pos <= 0)
|
|
||||||
{
|
|
||||||
alert ("{invalid_dial_size}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cols = size.substr(0, pos);
|
|
||||||
rows = size.substr(pos+1);
|
|
||||||
|
|
||||||
if (isNaN (cols) || isNaN (rows) || cols == 0 || rows == 0)
|
|
||||||
{
|
|
||||||
alert ("{invalid_dial_size}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size.indexOf('.') >= 0)
|
|
||||||
{
|
|
||||||
alert ("{invalid_dial_size}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log ("speed_dial-save-size " + cols + " " + rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
var setThumbSize = function (size)
|
|
||||||
{
|
|
||||||
console.log ("speed_dial-save-thumbsize " + size);
|
|
||||||
}
|
|
||||||
|
|
||||||
var key_id = 's';
|
var key_id = 's';
|
||||||
var key_timeout;
|
var key_timeout;
|
||||||
|
|
||||||
|
@ -277,11 +154,11 @@
|
||||||
if (key_id.substr(1) > 9)
|
if (key_id.substr(1) > 9)
|
||||||
{
|
{
|
||||||
if (getAction (key_id))
|
if (getAction (key_id))
|
||||||
document.location = div.childNodes[3].href;
|
document.location = div.childNodes[0].childNodes[0].href;
|
||||||
key_id = 's';
|
key_id = 's';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_timeout = setTimeout ('if (getAction (key_id)) document.location = document.getElementById(key_id).childNodes[3].href; key_id = \'s\'', 1000);
|
key_timeout = setTimeout ('if (getAction (key_id)) document.location = document.getElementById(key_id).childNodes[0].childNodes[0].href; key_id = \'s\'', 1000);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_id = 's';
|
key_id = 's';
|
||||||
|
@ -298,12 +175,4 @@
|
||||||
<div class="osd" >
|
<div class="osd" >
|
||||||
<span id="dialing"></span>
|
<span id="dialing"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="config">
|
<div id="content">
|
||||||
<span onclick="javascript:setSize()" class="config_option">{set_dial_size}</span>
|
|
||||||
<span class="config_label">{set_thumb_size}</span>
|
|
||||||
<span onclick="javascript:setThumbSize(80)" class="config_option">{set_thumb_small}</span>
|
|
||||||
<span onclick="javascript:setThumbSize(160)" class="config_option">{set_thumb_normal}</span>
|
|
||||||
<span onclick="javascript:setThumbSize(240)" class="config_option">{set_thumb_big}</span>
|
|
||||||
</div>
|
|
||||||
<div id="wrap">
|
|
||||||
<div id="content">
|
|
||||||
|
|
|
@ -3674,11 +3674,11 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
GKeyFile* key_file;
|
GKeyFile* key_file;
|
||||||
GString* markup = NULL;
|
GString* markup = NULL;
|
||||||
guint rows, cols, slot = 1;
|
guint rows, cols, slot = 1;
|
||||||
gchar* thumb_size_type;
|
guint slot_count = 1, i, grid_index = 3, slot_size;
|
||||||
gchar* speed_dial_head;
|
gchar* speed_dial_head;
|
||||||
gchar* file_path;
|
gchar* file_path;
|
||||||
gchar* file_name;
|
gchar* file_name;
|
||||||
guint thumb_size = 160;
|
gchar** groups;
|
||||||
|
|
||||||
g_object_get (browser, "speed-dial", &key_file, NULL);
|
g_object_get (browser, "speed-dial", &key_file, NULL);
|
||||||
if (!key_file)
|
if (!key_file)
|
||||||
|
@ -3700,10 +3700,7 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
"{set_dial_size}", _("Set number of columns and rows"),
|
"{set_dial_size}", _("Set number of columns and rows"),
|
||||||
"{enter_dial_size}", _("Enter number of columns and rows:"),
|
"{enter_dial_size}", _("Enter number of columns and rows:"),
|
||||||
"{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
|
"{invalid_dial_size}", _("Invalid input for the size of the speed dial"),
|
||||||
"{set_thumb_size}", _("Thumb size:"),
|
NULL);
|
||||||
"{set_thumb_small}", _("Small"),
|
|
||||||
"{set_thumb_normal}", _("Medium"),
|
|
||||||
"{set_thumb_big}", _("Big"), NULL);
|
|
||||||
|
|
||||||
markup = g_string_new (header);
|
markup = g_string_new (header);
|
||||||
|
|
||||||
|
@ -3719,59 +3716,31 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
|
|
||||||
rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
|
rows = g_key_file_get_integer (key_file, "settings", "rows", NULL);
|
||||||
cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
|
cols = g_key_file_get_integer (key_file, "settings", "columns", NULL);
|
||||||
thumb_size_type = g_key_file_get_string (key_file, "settings", "size", NULL);
|
|
||||||
if (thumb_size_type == NULL)
|
|
||||||
thumb_size_type = g_strdup ("MEDIUM");
|
|
||||||
|
|
||||||
if (g_str_equal (thumb_size_type, "SMALL"))
|
groups = g_key_file_get_groups (key_file, NULL);
|
||||||
thumb_size = 80;
|
for (i = 0; groups[i]; i++)
|
||||||
else if (g_str_equal (thumb_size_type, "MEDIUM"))
|
{
|
||||||
thumb_size = 160;
|
if (g_key_file_has_key (key_file, groups[i], "uri", NULL))
|
||||||
else if (g_str_equal (thumb_size_type, "BIG"))
|
slot_count++;
|
||||||
thumb_size = 240;
|
}
|
||||||
|
|
||||||
g_free (thumb_size_type);
|
|
||||||
|
|
||||||
g_string_append_printf (markup,
|
g_string_append_printf (markup,
|
||||||
"<script>var columns = %d; var rows = %d;"
|
"<script>var columns=%d; var rows=%d;</script>", cols, rows);
|
||||||
"setThumbSize(%d);</script>\n",
|
|
||||||
cols, rows, thumb_size);
|
|
||||||
|
|
||||||
g_string_append_printf (markup,
|
/* try to guess the best X by X grid size */
|
||||||
"<style type=\"text/css\">"
|
while ((grid_index * grid_index) < slot_count)
|
||||||
"#content div.shortcut { width: %dpx; height: %dpx; }\n"
|
grid_index++;
|
||||||
"#content div.shortcut a { width: %dpx; height: %dpx; }\n"
|
|
||||||
"#content div.shortcut .cross { margin-left: %dpx; }\n"
|
|
||||||
"#content div.shortcut h1 { font-size: %dpx; height: %dpx; }\n"
|
|
||||||
"#wrap { width: %dpx; }\n"
|
|
||||||
"#content h4 span:before { visibility: %s; }\n</style>",
|
|
||||||
thumb_size + 40, (int)((thumb_size / 1.5) + 43),
|
|
||||||
thumb_size, (int)(thumb_size / 1.5),
|
|
||||||
thumb_size + 20,
|
|
||||||
(int)((thumb_size / 4) + 10), (int)((thumb_size / 4) - 10),
|
|
||||||
cols * (thumb_size + 60),
|
|
||||||
thumb_size < 160 ? "hidden" : "visible");
|
|
||||||
|
|
||||||
g_string_append (markup,
|
/* percent width size of one slot */
|
||||||
"<noscript><style type=\"text/css\">"
|
slot_size = (100 / grid_index);
|
||||||
"#content h4 span:before { visibility: hidden; }\n"
|
g_string_append_printf (markup,
|
||||||
"div.config { visibility: hidden; }\n"
|
"<style> div.shortcut { height: %d%%; width: %d%%; }</style>\n",
|
||||||
".cross { visibility:hidden; }\n"
|
slot_size + 1, slot_size - 4);
|
||||||
".activated p { background-image: none; }</style></noscript>");
|
|
||||||
|
|
||||||
while (slot <= rows * cols)
|
while (slot <= slot_count)
|
||||||
{
|
{
|
||||||
gchar* dial_entry = g_strdup_printf ("Dial %d", slot);
|
gchar* dial_entry = g_strdup_printf ("Dial %d", slot);
|
||||||
gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL);
|
gchar* uri = g_key_file_get_string (key_file, dial_entry, "uri", NULL);
|
||||||
const gchar* position;
|
|
||||||
if (slot < cols)
|
|
||||||
position = " top";
|
|
||||||
else if (slot == cols)
|
|
||||||
position = " top right";
|
|
||||||
else if (slot > cols && slot % cols == 0)
|
|
||||||
position = " right";
|
|
||||||
else
|
|
||||||
position = "";
|
|
||||||
|
|
||||||
if (uri && *uri && *uri != '#')
|
if (uri && *uri && *uri != '#')
|
||||||
{
|
{
|
||||||
|
@ -3794,13 +3763,13 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
g_free (thumb_file);
|
g_free (thumb_file);
|
||||||
|
|
||||||
g_string_append_printf (markup,
|
g_string_append_printf (markup,
|
||||||
"<div class=\"shortcut%s activated\" id=\"s%d\">\n"
|
"<div class=\"shortcut\" id=\"s%d\"><div class=\"preview\">"
|
||||||
"<div onclick='javascript:clearShortcut(\"s%d\");' "
|
"<a href=\"%s\"><img style=\"width: 100%%;\" "
|
||||||
"class='cross'></div>\n<a href=\"%s\">"
|
"src=\"data:image/png;base64,%s\"></a><a class=\"cross\" "
|
||||||
"<img src=\"data:image/png;base64,%s\"></a>\n"
|
"href=\"#\" onclick='javascript:clearShortcut(\"s%d\");' ></a>"
|
||||||
"<p onclick='javascript:renameShortcut(\"s%d\");'>"
|
"</div><div class=\"title\" "
|
||||||
"%s</p></div>\n",
|
"onclick='javascript:renameShortcut(\"s%d\");'>%s</div></div>\n",
|
||||||
position, slot, slot, uri, encoded, slot, title);
|
slot, uri, encoded, slot, slot, title);
|
||||||
|
|
||||||
g_free (title);
|
g_free (title);
|
||||||
g_free (encoded);
|
g_free (encoded);
|
||||||
|
@ -3808,12 +3777,11 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_string_append_printf (markup,
|
g_string_append_printf (markup,
|
||||||
"<div class=\"shortcut%s\" id=\"s%d\">"
|
"<div class=\"shortcut\" id=\"s%d\"><div class=\"preview new\">"
|
||||||
"\n<a href=\"#\" onclick='javascript:return"
|
"<a class=\"add\" href=\"#\" onclick='javascript:return "
|
||||||
" getAction(\"s%d\");'>"
|
" getAction(\"s%d\");'></a></div>"
|
||||||
"<h1>%d</h1>\n<h4><span></span></h4>"
|
"<div class=\"title\">%s</div></div>\n",
|
||||||
"</a>\n<p></p></div>\n",
|
slot, slot, _("Click to add a shortcut"));
|
||||||
position, slot, slot, slot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
slot++;
|
||||||
|
@ -3821,7 +3789,7 @@ prepare_speed_dial_html (MidoriView* view)
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
g_string_append_printf (markup,
|
g_string_append_printf (markup,
|
||||||
"</div>\n</div>\n</body>\n</html>\n");
|
"</div>\n</body>\n</html>\n");
|
||||||
|
|
||||||
return g_string_free (markup, FALSE);
|
return g_string_free (markup, FALSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue