Various bug fixes & Preferred option for SiteFile

This commit is contained in:
斟酌 鵬兄 2015-10-27 07:50:11 +08:00
parent 1b11a1dff0
commit 07ceb117da
9 changed files with 153 additions and 83 deletions

View File

@ -13,6 +13,8 @@
/** @type {Components.MessageBox} */ /** @type {Components.MessageBox} */
var MessageBox = __import( "Components.MessageBox" ); var MessageBox = __import( "Components.MessageBox" );
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
var image = function( insertSnippet, snippetWrap, createContext, override ) var image = function( insertSnippet, snippetWrap, createContext, override )
{ {
var temp, i, j var temp, i, j
@ -25,12 +27,15 @@
) )
, input_a = Dand.wrap( , input_a = Dand.wrap(
"input", null, "v_snippet_input_single", null, new IKey( "type", "text" ) "input", null, "v_snippet_input_single", null, new IKey( "type", "text" )
); )
, input_preferred = Dand.wrapna('input', new IKey("type", "checkbox"))
;
if (this._stage) if (this._stage)
{ {
input_url.value = this._url; input_url.value = this._url;
input_a.value = this._href; input_a.value = this._href;
input_preferred.checked = (this._preferred == "on");
} }
// Popup MessageBox // Popup MessageBox
@ -41,27 +46,30 @@
, input_url , input_url
, Dand.wrapc( "v_instruction flsf", "Ancohr link(optional):" ) , Dand.wrapc( "v_instruction flsf", "Ancohr link(optional):" )
, input_a , input_a
, Dand.wrape([ input_preferred, Dand.textNode( "Preferred" ) ])
] ]
) )
, "OK", "Cancel" , "OK", "Cancel"
, visualizer.bind({ url:input_url, href:input_a, stage: this._stage }) , visualizer.bind({ url:input_url, href:input_a, stage: this._stage, preferred: input_preferred })
).show(); ).show();
} }
, visualizer = function ( submitted, override ) , visualizer = function ( submitted, override )
{ {
var src, href var src, href, preferred
, stage = this.stage; , stage = this.stage;
if ( override ) if ( override )
{ {
src = override.value; src = override.value;
href = override.href; href = override.href;
preferred = override.preferred ? "on" : "";
} }
else else
{ {
src = this.url.value; src = this.url.value;
href = this.href.value; href = this.href.value;
preferred = this.preferred.checked ? "on" : "";
} }
if ( submitted && src ) if ( submitted && src )
@ -82,16 +90,17 @@
Dand.wrapna( Dand.wrapna(
"img" "img"
, [ , [
new IKey("src", src) new IKey( "src", src )
, new IKey("style", "max-width: 100%") , new IKey( "style", "max-width: 100%" )
] ]
) )
// caption // caption
, Dand.wrapc( "v_description", i ) , Dand.wrapc( "v_description", i )
] ]
, [ , [
new DataKey("value", src) new DataKey( "value", src )
, new DataKey("href", href) , new DataKey( "href", href )
, new DataKey( "preferred", preferred )
] ]
); );
insertSnippet( j = snippetWrap( "Image", temp ), Boolean( override ) ); insertSnippet( j = snippetWrap( "Image", temp ), Boolean( override ) );
@ -102,6 +111,7 @@
([ ([
new DataKey( "value", src ) new DataKey( "value", src )
, new DataKey( "href", href ) , new DataKey( "href", href )
, new DataKey( "preferred", preferred )
]); ]);
stage.firstChild.setAttribute("src", src); stage.firstChild.setAttribute("src", src);
@ -114,7 +124,12 @@
temp = stage; temp = stage;
} }
i = { _url: src, _href: href, _stage: temp }; i = {
_url: src
, _href: href
, _preferred: preferred || "off"
, _stage: temp
};
// Set context menu // Set context menu
createContext( i, j, handler ); createContext( i, j, handler );
@ -138,10 +153,10 @@
{ {
// [img href=\"" + this.href.value + "\"]" + this.url.value + "[/img] // [img href=\"" + this.href.value + "\"]" + this.url.value + "[/img]
var element = IDOMElement( stage ) var element = IDOMElement( stage )
, href = element.getDAttribute( "href" ); , props = [ "href", "preferred" ]
return "[img" return "[img"
+ ( href ? (" href=\"" + href + "\"") : "" ) + compileProp( element, props )
+ "]" + "]"
+ element.getDAttribute( "value" ) + "[/img]" + element.getDAttribute( "value" ) + "[/img]"
; ;

View File

@ -19,8 +19,8 @@
/** @type {Astro.utils.Date} */ /** @type {Astro.utils.Date} */
var XDate = __import( "Astro.utils.Date" ); var XDate = __import( "Astro.utils.Date" );
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" ); var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
var getData = __import( "System.Net.getData" ); var getData = __import( "System.Net.getData" );
@ -37,10 +37,27 @@
, handler = function () , handler = function ()
{ {
// Input fields // Input fields
var v_snippetInput = Dand.wrap("input", null, "v_snippet_input_single", null, new IKey("type", "text")); var v_snippetInput = Dand.wrap("input", null, "v_snippet_input_single", null, new IKey("type", "text"))
, input_preferred = Dand.wrapna('input', new IKey("type", "checkbox"))
;
if ( this._stage )
{
v_snippetInput.value = this._content;
input_preferred.checked = ( this._preferred == "on" );
}
// Popup MessageBox // Popup MessageBox
new MessageBox("Insert site file", v_snippetInput, "OK", "Cancel", visualizer.bind({code: v_snippetInput})).show(); new MessageBox("Insert site file"
, Dand.wrape([
v_snippetInput
, Dand.wrape([ input_preferred, Dand.textNode( "Preferred" ) ])
])
, "OK", "Cancel", visualizer.bind({
code: v_snippetInput
, preferred: input_preferred
, stage: this._stage
})).show();
} }
, __applyData = function (e) , __applyData = function (e)
@ -143,33 +160,66 @@
, visualizer = function ( submitted, override ) , visualizer = function ( submitted, override )
{ {
var hash = override ? override.value : this.code.value var hash, _obj, stage = this.stage;
, _obj = {file: hash};
if( override )
{
hash = override.value;
preferred = override.preferred ? "on" : "";
}
else
{
hash = this.code.value;
preferred = this.preferred.checked ? "on" : "";
}
_obj = { file: hash };
if ( submitted && hash ) if ( submitted && hash )
{ {
// Visualize component // Visualize component
if (!stage)
{
temp = Dand.wrapc("v_box"
, [
Dand.wrape("Getting information from Server ...")
, Dand.wrapc("v_description", "Site file (hash): " + hash)
]
, [
new DataKey( "value", hash )
, new DataKey( "size", ( override && override.size ) || "large" )
, new IKey( "style", "max-height: 150px;" )
, new DataKey( "preferred", preferred )
]
);
temp = Dand.wrapc("v_box" // Get data from site library
, [ getData( config.path.info + hash, __applyData.bind({stage: temp, hash: hash}), loadFailed );
Dand.wrape("Getting information from Server ...")
, Dand.wrapc("v_description", "Site file (hash): " + hash) insertSnippet(
] j = snippetWrap( "SiteFile", temp )
, [ , !!override
);
}
else
{
IDOMElement( stage ).setAttribute([
new DataKey( "value", hash ) new DataKey( "value", hash )
, new DataKey( "size", ( override && override.size ) || "large" ) , new DataKey( "preferred", preferred )
, new IKey( "style", "max-height: 150px;" ) ]);
] getData( config.path.info + hash, __applyData.bind({stage: temp, hash: hash}), loadFailed );
); }
// Get data from site library
getData( config.path.info + hash, __applyData.bind({stage: temp, hash: hash}), loadFailed );
insertSnippet(j = snippetWrap("SiteFile", temp), Boolean(override));
// Set context menu
createContext(null, j);
} }
i = {
_content: hash
, _preferred: preferred || "off"
, _stage: temp
};
// Set context menu
createContext( i, j, handler );
}; };
if (override) if (override)
@ -199,6 +249,10 @@
{ {
options += " size=\"" + opt + "\""; options += " size=\"" + opt + "\"";
} }
if( opt = stage.getDAttribute( "preferred" ) )
{
options += " preferred=\"" + opt + "\"";
}
return "[sitefile" + options + "]" return "[sitefile" + options + "]"
+ escapeStr( stage.getDAttribute( "value" ) ) + escapeStr( stage.getDAttribute( "value" ) )

View File

@ -92,13 +92,11 @@
else else
{ {
IDOMElement(stage).setAttribute IDOMElement(stage).setAttribute
( ([
[ new DataKey("value", content)
new DataKey("value", content) , new DataKey("title", title)
, new DataKey("title", title) , new DataKey("expanded", expanded)
, new DataKey("expanded", expanded) ]);
]
);
temp = stage.firstChild; temp = stage.firstChild;
temp.removeChild(temp.firstChild); temp.removeChild(temp.firstChild);

View File

@ -1,3 +1,7 @@
.b_entry img {
max-width: 100%;
}
.b_entry { .b_entry {
background-color: #FAFAFA; background-color: #FAFAFA;
/* box-shadow: 0 0 8px -2px black; */ /* box-shadow: 0 0 8px -2px black; */

View File

@ -1,36 +1,35 @@
.m_title { .it-shucks > a {
font-size: 2.5em; float: right;
color: #444;
} }
.m_more { .mega-entry {
color: #76400C;
}
.mega_entry span {
display: block;
}
.mega_entry {
border: 6px solid white; border: 6px solid white;
background: white; background: white;
color: black; color: black;
position: relative; position: relative;
margin: 1em; margin: 0.5em;
display: block; display: block;
word-wrap: break-word; word-wrap: break-word;
box-shadow: 0 0 0 1px #D4D7C9; box-shadow: 0 0 0 1px #D4D7C9;
max-width: 80%;
width: 600px;
} }
.mega_entry:hover { .mega-entry:hover {
text-decoration: none; text-decoration: none;
} }
.mega_entry:after { .mega-entry .cCont > img {
position: absolute;
max-width: 100%;
}
.mega-entry .cCont:after {
content: attr(data-content); content: attr(data-content);
width: 100%; width: 100%;
@ -39,7 +38,6 @@
top: 100%; top: 100%;
position: absolute; position: absolute;
overflow: hidden;
color: white; color: white;
background: rgba(0, 0, 0, 0.65); background: rgba(0, 0, 0, 0.65);
@ -65,13 +63,13 @@
transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */ transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */
} }
.mega_entry:focus:after, .mega_entry:hover:after { .mega-entry .cCont:focus:after, .mega-entry .cCont:hover:after {
top: 50%; top: 50%;
height: 50%; height: 50%;
padding: 0.5em; padding: 0.5em;
} }
.mega_entry > #noteTag { .mega-entry > #noteTag {
background: black; background: black;
} }
@ -90,35 +88,21 @@
top: 10px; top: 10px;
} }
.mega_entry > .cCont { .mega-entry > .cCont {
position: relative; position: relative;
color: white;
overflow: hidden;
height: 130px; height: 130px;
background-position: center top;
background-repeat: no-repeat;
background-color: #EEE;
background-image: url('http://file.astropenguin.net/blog/layout-images/archived.png');
} }
.mega_entry > .cCont:before { .mega-entry .cCont > h2 {
content: attr(data-content); position: absolute;
position: absolute;
line-height: 100%;
font-size: 2.5em;
padding: 0.1em;
padding: 0 0.2em;
text-shadow: 2px 2px 8px black; text-shadow: 2px 2px 8px black;
color: white;
width: 100%; z-index: 1;
height: 100%;
box-sizing: border-box;
background-color: rgba( 0, 0, 0, 0.2 );
} }
.cDate { .cDate {

View File

@ -15,9 +15,20 @@
.section-buttons > a[data-name="blog"] { .section-buttons > a[data-name="blog"] {
background-color: purple; background-color: purple;
} }
.section-buttons > a[data-name="wenku8"] { .section-buttons > a[data-name="works"] {
background-color: royalblue; background-color: royalblue;
} }
.section-buttons > a[data-name="album"] {
background-color: crimson;
background-image:
repeating-linear-gradient(
45deg, transparent
, transparent 2px, rgba(0,0,0,.2) 2px
, rgba(0,0,0,.2) 3px, transparent 3px
, transparent 5px, rgba(0,0,0,.2) 5px
);
}
.section-buttons > a > span { .section-buttons > a > span {
padding: 0.75em 0.5em; padding: 0.75em 0.5em;
} }

View File

@ -1,6 +1,3 @@
.site_file {
margin: 0.5em 0;
}
.sf_regular sup { vertical-align: baseline; } .sf_regular sup { vertical-align: baseline; }
.sf_regular { .sf_regular {

View File

@ -1,6 +1,8 @@
(function(){ (function(){
var ns = __namespace( "Astro.Blog.Components" ); var ns = __namespace( "Astro.Blog.Components" );
/** @type {System.Debug} */
var debug = __import( "System.Debug" );
/** @type {System.utils.IKey} */ /** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" ); var IKey = __import( "System.utils.IKey" );
/** @type {Dandelion} */ /** @type {Dandelion} */
@ -23,6 +25,11 @@
if( !config ) throw new Error( "config is not defined" ); if( !config ) throw new Error( "config is not defined" );
// TODO: Make a trigger for downloading from server // TODO: Make a trigger for downloading from server
var stage = Dand.id( id ); var stage = Dand.id( id );
if( !stage )
{
debug.Info( "[SiteFile] id not found: " + id );
return;
}
this.id = id; this.id = id;
this.hash = hash; this.hash = hash;
this.type = IDOMElement( stage ).getDAttribute( "type" ); this.type = IDOMElement( stage ).getDAttribute( "type" );

View File

@ -63,7 +63,7 @@ h6, .h6 { font-size: 0.5em; }
} }
.right { text-align: right; } .right { text-align: right; }
.panel { padding: 1.2em; } .panel { padding: 0.5em 1.2em 1.2em 1.2em; }
/* transition properties */ /* transition properties */
div#header, div#mbody, div#contact, div#horizon { div#header, div#mbody, div#contact, div#horizon {