(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 ); })();