Astro Classes

This commit is contained in:
2015-08-14 21:06:23 +08:00
parent d3f924adf3
commit 0a25f87965
157 changed files with 11676 additions and 2 deletions

View File

@@ -0,0 +1,107 @@
(function ()
{
var ns = __namespace( "Astro.Blog.AstroEdit.Visualizer.Snippet" );
/** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" );
/** @type {System.utils.DataKey} */
var DataKey = __import( "System.utils.DataKey" );
/** @type {Dandelion.IDOMElement} */
var IDOMElement = __import( "Dandelion.IDOMElement" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Components.MessageBox} */
var MessageBox = __import( "Components.MessageBox" );
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
var html = function (insertSnippet, snippetWrap, createContext, override)
{
var temp, i, j
, handler = function ()
{
// Input fields
var v_snippetInput = Dand.wrap( "textarea", null, "v_snippet_input" );
if ( this._stage )
{
v_snippetInput.value = this._code;
}
// Popup MessageBox
new MessageBox(
"Insert Html snippet"
, v_snippetInput
, "OK", "Cancel"
, visualizer.bind({ code: v_snippetInput, stage: this._stage })
).show();
}
, visualizer = function (submitted, override)
{
var code, stage = this.stage;
code = override ? override.value : this.code.value;
if (submitted && code)
{
if (!stage)
{
// Visualize component
temp = Dand.wrapc(
"v_box"
, [
Dand.wrapne( "pre", code )
, Dand.wrapc( "v_description", "Raw Html Codes" )
]
, [
new DataKey( "value", code )
, new IKey( "style", "max-height: 150px;" )
]
);
insertSnippet(j = snippetWrap("Html", temp), Boolean(override));
}
else
{
IDOMElement( stage ).setAttribute(new DataKey( "value", code ));
temp = stage.firstChild;
temp.removeChild(temp.firstChild);
stage.firstChild.appendChild(Dand.textNode( code ));
temp = stage;
}
i = { _code: code, _stage: temp };
// Set context menu
createContext( i, j, handler );
}
};
if ( override )
{
visualizer( true, override );
override = false;
}
else
{
return handler;
}
return true;
};
var compile = function (stage)
{
// [html][/html]
return "[html]" + escapeStr( IDOMElement(stage).getDAttribute("value") ) + "[/html]";
};
__static_method( html, "compile", compile );
ns[ NS_EXPORT ]( EX_CLASS, "Html", html );
})();