forked from Botanical/BotanJS
Various bug fixes & Preferred option for SiteFile
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
/** @type {Astro.utils.Date} */
|
||||
var XDate = __import( "Astro.utils.Date" );
|
||||
|
||||
|
||||
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
|
||||
var compileProp = ns[ NS_INVOKE ]( "compileProp" );
|
||||
|
||||
var getData = __import( "System.Net.getData" );
|
||||
|
||||
@@ -37,10 +37,27 @@
|
||||
, handler = function ()
|
||||
{
|
||||
// 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
|
||||
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)
|
||||
@@ -143,33 +160,66 @@
|
||||
, visualizer = function ( submitted, override )
|
||||
{
|
||||
|
||||
var hash = override ? override.value : this.code.value
|
||||
, _obj = {file: hash};
|
||||
var hash, _obj, stage = this.stage;
|
||||
|
||||
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 )
|
||||
{
|
||||
// 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"
|
||||
, [
|
||||
Dand.wrape("Getting information from Server ...")
|
||||
, Dand.wrapc("v_description", "Site file (hash): " + hash)
|
||||
]
|
||||
, [
|
||||
// Get data from site library
|
||||
getData( config.path.info + hash, __applyData.bind({stage: temp, hash: hash}), loadFailed );
|
||||
|
||||
insertSnippet(
|
||||
j = snippetWrap( "SiteFile", temp )
|
||||
, !!override
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
IDOMElement( stage ).setAttribute([
|
||||
new DataKey( "value", hash )
|
||||
, new DataKey( "size", ( override && override.size ) || "large" )
|
||||
, new IKey( "style", "max-height: 150px;" )
|
||||
]
|
||||
);
|
||||
, new DataKey( "preferred", preferred )
|
||||
]);
|
||||
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)
|
||||
@@ -199,6 +249,10 @@
|
||||
{
|
||||
options += " size=\"" + opt + "\"";
|
||||
}
|
||||
if( opt = stage.getDAttribute( "preferred" ) )
|
||||
{
|
||||
options += " preferred=\"" + opt + "\"";
|
||||
}
|
||||
|
||||
return "[sitefile" + options + "]"
|
||||
+ escapeStr( stage.getDAttribute( "value" ) )
|
||||
|
||||
Reference in New Issue
Block a user