Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
satorumurmur committed Jul 22, 2017
2 parents deda190 + 05db48c commit aa16c4a
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 102 deletions.
2 changes: 1 addition & 1 deletion bib/i/presets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Bibi.Preset = {
{ "name": "Unzipper", "src": "extensions/unzipper/unzipper.js" },
{ "name": "Analytics", "src" : "extensions/analytics/analytics.js", "tracking-id": "" }, // "tracking-id": Your own Google Analytics tracking id, as "UA-********-*"
{ "name": "FontSize", "src": "extensions/fontsize/fontsize.js", "base": "auto", "scale-per-step": 1.25 }, // "base": "auto" or pixel-number (if you want to change the default font-size based on the size used most frequently in each HTML)
{ "name": "Share", "src" : "extensions/share/share.js", "allow-embedding-in-other-webpages": true },
{ "name": "Share", "src" : "extensions/share/share.js" },
//{ "name": "EPUBCFI", "src": "extensions/epubcfi/epubcfi.js" },
//{ "name": "OverReflow", "src": "extensions/overreflow/overreflow.js" },
//{ "name": "JaTEx", "src": "extensions/jatex/jatex.js" },
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bibi",
"version": "0.999.9-r6",
"version": "0.999.9-r7",
"authors": [
"Satoru MATSUSHIMA"
],
Expand Down
100 changes: 49 additions & 51 deletions dev-bib/i.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,64 +32,62 @@
// Anchor
var Anchor = Bibi.Anchor = As[i];
if(!/ bibi-anchor /.test(" " + Anchor.className + " ")) Anchor.className = "bibi-anchor" + (Anchor.className ? " " + Anchor.className : "");
var Src = Href = Anchor.getAttribute("href");
var Class = Anchor.getAttribute("data-bibi-class");
var ID = Anchor.getAttribute("data-bibi-id");
var Style = Anchor.getAttribute("data-bibi-style");
var RVM = Anchor.getAttribute("data-bibi-reader-view-mode");
var FixRVM = Anchor.getAttribute("data-bibi-fix-reader-view-mode");
var Autostart = Anchor.getAttribute("data-bibi-autostart");
var NewWindow = Anchor.getAttribute("data-bibi-start-in-new-window");
var UseNombre = Anchor.getAttribute("data-bibi-use-nombre");
var UseSlider = Anchor.getAttribute("data-bibi-use-slider");
var UseArrows = Anchor.getAttribute("data-bibi-use-arrows");
var UseKeys = Anchor.getAttribute("data-bibi-use-keys");
var UseSwipe = Anchor.getAttribute("data-bibi-use-swipe");
var UseCookie = Anchor.getAttribute("data-bibi-use-cookie");
var To = Anchor.getAttribute("data-bibi-to");
var Nav = Anchor.getAttribute("data-bibi-nav");
var BibiLabel = Anchor.innerHTML;
if(Anchor.origin != location.origin) Pipi.TrustworthyOrigins.push(Anchor.origin);
Anchor.addEventListener("bibi:loaded", function(Eve) { console.log("BiB/i: Loaded. - #" + Eve.detail.Number + ": " + Eve.detail.Anchor.href); }, false);
Pipi.Anchors.push(Anchor);
// Holder
var BibiClass = Anchor.getAttribute("data-bibi-class");
var BibiID = Anchor.getAttribute("data-bibi-id");
var BibiStyle = Anchor.getAttribute("data-bibi-style");
var Holder = Bibi.Holder = Pipi.create("span", {
className: "bibi-holder",
id: "bibi-holder-" + (i + 1),
className: "bibi-holder" + (BibiClass ? " " + BibiClass : ""),
id: (BibiID ? BibiID : "bibi-holder-" + (i + 1)),
title: (Anchor.innerText ? Anchor.innerText + " " : "") + "(powered by BiB/i)"
});
if(Class) Holder.className += " " + Class;
if(ID) Holder.id = ID;
if(Style) Holder.setAttribute("style", Style);
if(BibiStyle) Holder.setAttribute("style", BibiStyle);
Pipi.Holders.push(Holder);
// Fragment
var Fragment = new Pipi.Fragment();
Fragment.add("parent-title", Pipi.encode(document.title));
Fragment.add("parent-uri", Pipi.encode(location.href));
Fragment.add("parent-origin", Pipi.encode(location.origin));
Fragment.add("parent-pipi-path", Pipi.encode(Pipi.Path));
Fragment.add("parent-bibi-label", Pipi.encode(BibiLabel));
Fragment.add("parent-holder-id", Holder.id);
if( /^(horizontal|vertical|paged)$/.test(RVM)) Fragment.add("reader-view-mode", RVM);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(FixRVM)) Fragment.add("fix-reader-view-mode", FixRVM);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(Autostart)) Fragment.add("autostart", Autostart);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(NewWindow)) Fragment.add("start-in-new-window", NewWindow);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseNombre)) Fragment.add("use-nombre", UseNombre);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseSlider)) Fragment.add("use-slider", UseSlider);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseArrows)) Fragment.add("use-arrows", UseArrows);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseKeys)) Fragment.add("use-keys", UseKeys);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseSwipe)) Fragment.add("use-swipe", UseSwipe);
if(/^(true|false|yes|no|mobile|desktop)?$/.test(UseCookie)) Fragment.add("use-cookie", UseCookie);
if( /^[1-9][\d\-\.]*$/.test(To)) Fragment.add("to", To);
if( /^[1-9]\d*$/.test(Nav)) Fragment.add("nav", Nav);
// Fragments
var Fragments = new Pipi.Fragments();
Fragments.add("parent-title", document.title);
Fragments.add("parent-uri", location.href);
Fragments.add("parent-origin", location.origin);
Fragments.add("parent-pipi-path", Pipi.Path);
Fragments.add("parent-bibi-label", Anchor.innerHTML);
Fragments.add("parent-holder-id", Holder.id);
[
"to",
"nav",
"reader-view-mode",
"fix-reader-view-mode",
"autostart",
"start-in-new-window",
"use-nombre",
"use-slider",
"use-arrows",
"use-keys",
"use-swipe",
"use-cookie"
].forEach(function(PresetKey) {
var PresetValue = Anchor.getAttribute("data-bibi-" + PresetKey);
if(!PresetValue) return;
var RE;
switch(PresetKey) {
case "to": RE = /^[1-9][\d\-\.]*$/; break;
case "nav": RE = /^[1-9]\d*$/; break;
case "reader-view-mode": RE = /^(horizontal|vertical|paged)$/; break;
default: RE = /^(true|false|yes|no|mobile|desktop)?$/; break;
}
if(RE.test(PresetValue)) Fragments.add(PresetKey, PresetValue);
});
// Frame
var BibiSrc = Anchor.getAttribute("href");
var Frame = Bibi.Frame = Holder.appendChild(
Pipi.create("iframe", {
className: "bibi-frame",
frameborder: "0",
scrolling: "auto",
allowfullscreen: "true",
src: Src + (/#/.test(Src) ? "," : "#") + Fragment.make()
src: BibiSrc + (/#/.test(BibiSrc) ? "," : "#") + Fragments.make()
})
);
Frame.addEventListener("load", function() {
Expand Down Expand Up @@ -143,13 +141,13 @@
for(var Attribute in Properties) Ele[Attribute] = Properties[Attribute];
return Ele;
};
Pipi.Fragment = function() {
this.Fragment = [];
Pipi.Fragments = function() {
this.Fragments = [];
this.add = function(Key, Value) {
this.Fragment.push([Key, Value].join(":"));
this.Fragments.push(Key + ":" + Pipi.encode(Value));
};
this.make = function() {
return this.Fragment.length ? "pipi(" + this.Fragment.join(",") + ")" : "";
return this.Fragments.length ? "pipi(" + this.Fragments.join(",") + ")" : "";
};
return this;
};
Expand Down Expand Up @@ -177,8 +175,8 @@
}
}, false);
document.getElementsByTagName("head")[0].appendChild(Pipi.create("link", { rel: "stylesheet", id: "bibi-css", href: Pipi.Path.replace(/\.js$/, ".css") }));
document.addEventListener("bibi:readied", function(Eve) { console.log("BiB/i: Readied. - " + Eve.detail.Bibis.length + " Bibi(s)."); }, false);
document.addEventListener("bibi:loaded", function(Eve) { console.log("BiB/i: Loaded. - " + Eve.detail.Bibis.length + " Bibi(s)."); }, false);
document.addEventListener("bibi:timed-out", function(Eve) { console.log("BiB/i: Timed Out."); }, false);
document.addEventListener("DOMContentLoaded", Pipi.embed, false);
document.addEventListener("bibi:readied", function(Eve) { console.log("BiB/i: Readied. - " + Eve.detail.Bibis.length + " Bibi" + (Eve.detail.Bibis.length > 1 ? "s" : "") + "."); }, false);
document.addEventListener("bibi:loaded", function(Eve) { console.log("BiB/i: Loaded. - " + Eve.detail.Bibis.length + " Bibi" + (Eve.detail.Bibis.length > 1 ? "s" : "") + "."); }, false);
document.addEventListener("bibi:timed-out", function(Eve) { console.log("BiB/i: Timed Out."); }, false);
document.addEventListener("DOMContentLoaded", Pipi.embed, false);
})();
28 changes: 11 additions & 17 deletions dev-bib/i/extensions/share/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Bibi.x({

})(function() {

var ShareButtonGroup = I.createButtonGroup({ Area: I.Menu.R });
var ShareButtonGroup = I.createButtonGroup({ Area: I.Menu.R, Sticky: true });

// Share
var ShareButton = ShareButtonGroup.addButton({
Expand Down Expand Up @@ -108,26 +108,20 @@ Bibi.x({
}
}).querySelector(".bibi-h-label").appendChild(sML.create("small", { className: "book-title" }));
}
/*
if(X.Presets.Share["allow-embedding-in-other-webpages"]) {
var EmbedCode = [
'<a href="' + O.RequestedURL + '" data-bibi="embed">' + (U["parent-bibi-label"] ? U["parent-bibi-label"] : document.title) + '</a>',
'<script src="' + (U["parent-pipi-path"] ? U["parent-pipi-path"] : O.RootPath.replace(/\/$/, ".js")) + '"></script>'
].join("").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
ShareSubPanel.addSection({
ButtonGroup: {
Buttons: [
{
Labels: { default: { default: 'Get the Embed-Code of This Book', ja: 'この本の埋め込みコードを取得' } },
Icon: '<span class="bibi-icon bibi-icon-code"></span>',
on: {
click: function() {
alert([
'<a href="' + O.RequestedURL + '" data-bibi="embed">' + (U["parent-bibi-label"] ? U["parent-bibi-label"] : document.title) + '</a>',
'<script src="' + (U["parent-pipi-path"] ? U["parent-pipi-path"] : O.RootPath.replace(/\/$/, ".js")) + '"></script>'
].join(""));
}
}
}
]
}
Labels: { default: { default: 'Embed-Code of This Book', ja: 'この本の埋め込みコード' } },
Notes: [
{ default: { default: '<input class="code block" value="' + EmbedCode.replace(/[""]/g, "&quot;") + '" onclick="this.select();" />' } }
]
});
}
*/
O.Head.appendChild(sML.create("script", { async: "async", src: "//platform.twitter.com/widgets.js" }));

});
18 changes: 15 additions & 3 deletions dev-bib/i/res/scripts/bibi.heart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3132,14 +3132,26 @@ I.createSubPanel.addSection = function(Par) { // classifies of Subpanel / classi
// HGroup
if(SubPanelSection.Labels) {
SubPanelSection.Labels = I.distillLabels(SubPanelSection.Labels);
SubPanelSection.Label = SubPanelSection.appendChild(
SubPanelSection.appendChild(
sML.create("div", { className: "bibi-hgroup" })
).appendChild(
sML.create("p", { className: "bibi-h" })
).appendChild(
sML.create("span", { className: "bibi-h-label", innerHTML: SubPanelSection.Labels["default"][O.Language] })
);
}
// PGroup
if(SubPanelSection.Notes) {
var PGroup = SubPanelSection.appendChild(
sML.create("div", { className: "bibi-pgroup" })
);
SubPanelSection.Notes.forEach(function(Note) {
Note = I.distillLabels(Note);
PGroup.appendChild(
sML.create("p", { className: "bibi-p", innerHTML: Note["default"][O.Language] })
);
});
}
// ButtonGroup
SubPanelSection.addButtonGroup = I.createSubPanel.addSection.addButtonGroup;
if(SubPanelSection.ButtonGroup) SubPanelSection.addButtonGroup(SubPanelSection.ButtonGroup);
Expand Down Expand Up @@ -3347,8 +3359,8 @@ I.createSlider = function() {
I.Slider.flip();
},
startSliding: function(Eve) {
Eve.preventDefault();
if(!Eve.target || !Eve.target.id || !/^bibi-slider-/.test(Eve.target.id)) return;
Eve.preventDefault();
I.Slider.Sliding = true;
I.Slider.Status = {
StartPageIndex: R.Current.Pages.StartPage.PageIndex,
Expand Down Expand Up @@ -4140,6 +4152,7 @@ U.initialize = function() { // formerly O.readExtras
case "parent-origin":
case "parent-pipi-path":
case "parent-bibi-label":
case "parent-holder-id":
PnV[1] = U.decode(PnV[1]);
break;
case "reader-view-mode":
Expand All @@ -4152,7 +4165,6 @@ U.initialize = function() { // formerly O.readExtras
PnV[1] = /^[1-9]\d*$/.test(PnV[1]) ? PnV[1] * 1 : undefined;
break;
case "preset":
case "parent-holder-id":
break;
default:
if(O.SettingTypes.YesNo.includes(PnV[0])) {
Expand Down
80 changes: 66 additions & 14 deletions dev-bib/i/res/styles/_bibi-controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ div.bibi-subpanel {
}
& {
position: fixed;
//overflow: auto; -webkit-overflow-scrolling: touch;
z-index: $z-index_subpanel;
right: $subpanel-margin;
top: $top-bar-height + $subpanel-margin;
Expand All @@ -715,6 +714,31 @@ div.bibi-subpanel {
border-radius: 4px;
background: $subpanel-background-color;
}
& {
overflow: auto; -webkit-overflow-scrolling: touch;
$scrollbar-track-size: 6px;
$scrollbar-thumb-size: 2px;
$scrollbar-thumb-background-color: rgb(128,128,128);
$scrollbar-track-background-color: rgb(248,248,248);
&::-webkit-scrollbar { // scrollbar
height: $scrollbar-track-size;
width: $scrollbar-track-size;
}
&::-webkit-scrollbar-track { // scrollbar track
background: $scrollbar-track-background-color;
}
&::-webkit-scrollbar-thumb { // scrollbar thumb
border-radius: $scrollbar-track-size * 0.5;
border: solid (($scrollbar-track-size - $scrollbar-thumb-size) * 0.5) $scrollbar-track-background-color;
background: $scrollbar-thumb-background-color;
&:hover {
background: $scrollbar-thumb-background-color_hover;
}
&:active {
background: $scrollbar-thumb-background-color_active;
}
}
}
& span.bibi-subpanel-bit {
display: block;
position: absolute;
Expand Down Expand Up @@ -749,23 +773,22 @@ div.bibi-subpanel {
strong {
font-weight: bold;
}
.bibi-hgroup, .bibi-buttongroup {
.bibi-hgroup, .bibi-pgroup, .bibi-buttongroup {
}
.bibi-h, .bibi-buttonbox,
.bibi-h-label,
.bibi-button {
.bibi-h, .bibi-p, .bibi-buttonbox,
.bibi-h-label, .bibi-button {
display: block;
box-sizing: border-box;
}
.bibi-h-label,
.bibi-button {
padding-left: ($button-group-margin * 2);
padding-right: ($button-group-margin * 2);
}
.bibi-h, .bibi-p,
.bibi-button {
padding-left: ($button-group-margin * 2);
padding-right: ($button-group-margin * 2);
}
a.bibi-button {
text-decoration: none;
}
.bibi-hgroup, {
.bibi-hgroup {
}
.bibi-h {
}
Expand Down Expand Up @@ -795,15 +818,44 @@ div.bibi-subpanel {
}
}
}
.bibi-buttongroup {
.bibi-pgroup {
border: solid rgba(black, 0.1); border-width: 1px 0;
overflow: hidden;
color: rgb(64,64,64);
background: white;//rgba(white, 0.9);
}
.bibi-buttonbox {
.bibi-p {
margin: 8px 0;
line-height: 1.5;
font-size: 14px;
small {
font-size: 10px;
}
.code {
font-size: 12px;
font-family: monospace;
word-break: break-all;
color: rgb(96,96,96);
}
.block {
box-sizing: border-box;
display: block;
width: 100%;
}
input.block {
border: solid 1px rgb(234,234,234);
padding: .5em;
}
}
.bibi-buttongroup { // ul
border: solid rgba(black, 0.1); border-width: 1px 0;
overflow: hidden;
}
.bibi-buttonbox { // li
line-height: 1.2;
font-size: 14px;
}
.bibi-button {
.bibi-button { // a, span
position: relative;
z-index: 1;
margin: -1px 0;
Expand Down
Loading

0 comments on commit aa16c4a

Please sign in to comment.