webEditor.jsp 13.8 KB
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="com.weaver.formmodel.mobile.utils.MobileCommonUtil"%>
<%@ include file="/mobilemode/admin/init.jsp"%>
<%
String theme = "";
Cookie[] cookies = request.getCookies();
for(int i = 0; cookies != null && i < cookies.length; i++){
	Cookie c = cookies[i];
	if(c != null && "webeditor_theme".equals(c.getName())){
		theme = Util.null2String(c.getValue());
	}
}
if(theme.equals("")){theme = "light";}
String mode = Util.null2String(request.getParameter("mode"), "run");
%>
<html>
<head>
	<title>Web Editor</title>
	<meta charset="utf-8" />
	<link type="text/css" rel="stylesheet" href="/mobilemode/admin/src/common/css/common.css">
	<link type="text/css" rel="stylesheet" href="/mobilemode/admin/src/webEditor/webEditor.css">
</head>
<body class="<%=theme%>">
	<div id="main-container" class="mode-<%=mode%>">
		<div id="code-container">
			<div id="box-html" class="split editor-wrapper">
				<div class="editor-header" data-index="0">
					<div class="config">HTML</div>
				</div>
				<div id="html-editor" data-type="html" class="editor-self"></div>
			</div>
			<div id="box-css" class="split editor-wrapper">
				<div class="editor-header" data-index="1">
					<div class="config">CSS</div>
					<div class="help">?</div>
				</div>
				<div id="css-editor" data-type="css" class="editor-self"></div>
			</div>
			<div id="box-javascript" class="split editor-wrapper">
				<div class="editor-header" data-index="2">
					<div class="config">JavaScript</div>
				</div>
				<div id="javascript-editor" data-type="javascript" class="editor-self"></div>
			</div>
		</div>
		<div id="result-container">
			<div class="iphone">
                <div class="header">
                    <span class="camera"></span>
                    <!-- 传感器 -->
                    <span class="sensor"></span>
                    <span class="speaker"></span>
                </div>
                <div class="buttons power-button"></div>
                <div class="buttons voice-toogle"></div>
                <div class="buttons voice-plus"></div>
                <div class="buttons voice-minus"></div>
                <div class="screen">
                	<iframe id="preview-frame" class="empty"></iframe>                        
                </div>
                <div class="home-button"><span></span></div>
			</div>
		</div>
		<div id="settings-container">
			<div id="settings-tabs-title">
				<ul>
					<li data-href="settings-html">HTML</li>
					<li data-href="settings-css">CSS</li>
					<li data-href="settings-javascript">JavaScript</li>
					<li data-href="settings-behavior" style="display: none;">Behavior</li>
				</ul>
			</div>
			<div id="settings-tabs-content">
				<div id="settings-html">
					<form name="settings-form">
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385700,user.getLanguage(),"HTML预处理器")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385701,user.getLanguage()," HTML预处理器可以使编写html更方便。例如,你可以在HTML中使用Markdown标记语言,选择对应的预处理器即可。 ")%>">?</div>
					</div>
					<div class="field-content">
						<select class="form-control" id="htmlPreprocessor">
							<option value="none">None</option>
							<option value="markdown">Markdown</option>
						</select>
					</div>
					
					<div class="field-label">
						DOCTYPE
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385702,user.getLanguage(),"文档类型,此处选择的文档类型将直接应用于生成的html中。")%>">?</div>
					</div>
					<div class="field-content">
						<select class="form-control" id="htmlDoctype">
							<option value="XHTML 1.0 Strict">XHTML 1.0 Strict</option>
							<option value="XHTML 1.0 Transitional">XHTML 1.0 Transitional</option>
							<option value="HTML 4.01 Strict">HTML 4.01 Strict</option>
							<option value="HTML 4.01 Transitional">HTML 4.01 Transitional</option>
							<option value="HTML 4.01 Frameset">HTML 4.01 Frameset</option>
							<option value="HTML 5" selected="selected">HTML 5</option>
						</select>
					</div>
					
					<div class="field-label">
						Stuff for  &lt;head&gt;
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385703,user.getLanguage(),"此处填写的内容会直接嵌入在head标签中。")%>">?</div>
					</div>
					<div class="field-content">
						<textarea id="htmlStuffForHead" class="area-control" placeholder="e.g. &lt;meta&gt;, &lt;link&gt;, &lt;script&gt;"></textarea>
					</div>
					</form>
				</div>
				<div id="settings-css">
					<form name="settings-form">
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385704,user.getLanguage()," CSS预处理器")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385705,user.getLanguage(),"CSS预处理器可以处理传统css之外的写法,例如,LESSSCSS,选择对应的预处理器即可。")%>">?</div>
					</div>
					<div class="field-content">
						<select class="form-control" id="cssPreprocessor">
							<option value="none">None</option>
							<option value="less">LESS</option>
							<option value="scss">SCSS</option>
							<option value="sass">Sass</option>
						</select>
					</div>
					
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385706,user.getLanguage(),"浏览器兼容性")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385707,user.getLanguage()," 为了获得最好的跨浏览器支持,在特定的CSS属性和值前面增加前缀是常见的做法。例如,-webkit- or -moz- ")%>">?</div>
					</div>
					<div class="field-content">
						<select class="form-control" id="cssAutoprefixer">
							<option value="0"><%=MobileCommonUtil.getHtmlLabelName(385708,user.getLanguage(),"不做兼容性处理")%></option>
							<option value="1"><%=MobileCommonUtil.getHtmlLabelName(385709,user.getLanguage(),"自动加前缀")%></option>
						</select>
					</div>
					
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385710,user.getLanguage()," 添加外部CSS")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385711,user.getLanguage(),"这些样式将会按照显示顺序依次添加在页面上(在编辑器里写的css代码之前)。")%>">?</div>
					</div>
					<div class="field-content">
						<table id="css-resource-table" class="settings-table">
							<tbody>
								<tr>
									<td width="18px" align="left" class="bemove"></td>
									<td width="412px"><input type="text" name="externalCss" value="" class="form-control" placeholder="http://yourwebsite.com/style.css"></td>
									<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
								</tr>
								<tr>
									<td width="18px" align="left" class="bemove"></td>
									<td width="412px"><input type="text" name="externalCss" value="" class="form-control" placeholder="http://yourwebsite.com/style.css"></td>
									<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
								</tr>
							</tbody>
						</table>
						<div class="external-resource-actions">
							<%=MobileCommonUtil.getHtmlLabelName(385712,user.getLanguage()," 快速添加:")%>
							<select class="form-control quick-add-select" data-for="css-resource-table">
								<option value="">---</option>
								<option value="/mobilemode/mobile/dist/css/mobilemode_wev8.css">Mobilemode</option>
								<option value="/mobilemode/mobile/dist/css/lib/mobilebone/mobilebone_wev8.css">Mobilebone</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css">Bootstrap 4</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">Bootstrap 3</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/css/foundation.min.css">Foundation</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">Animate.css</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css">Materialize</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.2/css/bulma.min.css">Bulma</option>
							</select>
							<div class="add-resource" data-for="css-resource-table">+<%=MobileCommonUtil.getHtmlLabelName(384113,user.getLanguage(),"添加")%></div>
						</div>
					</div>
					</form>
				</div>
				<div id="settings-javascript">
					<form name="settings-form">
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385713,user.getLanguage(),"JavaScript预处理器")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385714,user.getLanguage(),"JavaScript预处理器可以处理传统js之外的写法,例如,CoffeeScriptLiveScript,选择对应的预处理器即可。")%>">?</div>
					</div>
					<div class="field-content">
						<select class="form-control" id="jsPreprocessor">
							<option value="none">None</option>
							<option value="coffeescript">CoffeeScript</option>
							<option value="livescript">LiveScript</option>
							<option value="typescript">TypeScript</option>
							<option value="babel">Babel</option>
						</select>
					</div>
					
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385715,user.getLanguage()," 添加外部JavaScript")%>
						<div class="settings-help" data-tips="<%=MobileCommonUtil.getHtmlLabelName(385716,user.getLanguage(),"这些脚本将会按照显示顺序依次添加在页面上(在编辑器里写的JavaScript代码之前)。")%>">?</div>
					</div>
					<div class="field-content">
						<table id="javascript-resource-table" class="settings-table">
							<tbody>
								<tr>
									<td width="18px" align="left" class="bemove"></td>
									<td width="412px"><input type="text" name="externalJS" value="" class="form-control" placeholder="http://yourwebsite.com/script.js"></td>
									<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
								</tr>
								<tr>
									<td width="18px" align="left" class="bemove"></td>
									<td width="412px"><input type="text" name="externalJS" value="" class="form-control" placeholder="http://yourwebsite.com/script.js"></td>
									<td width="22px" align="right"><span class="del-after2 del-resource"></span></td>
								</tr>
							</tbody>
						</table>
						<div class="external-resource-actions">
							<%=MobileCommonUtil.getHtmlLabelName(385712,user.getLanguage()," 快速添加:")%>
							<select class="form-control quick-add-select" data-for="javascript-resource-table">
								<option value="">---</option>
								<option value="/mobilemode/mobile/dist/js/lib/require/require.min_wev8.js">Mobilemode.require</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">jQuery</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js">jQuery UI</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js">Zepto</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js">React</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js">React DOM</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js">Angular</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js">Backbone</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js">Bootstrap 3</option>
								<option value="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js">Bootstrap 4</option>
							</select>
							<div class="add-resource" data-for="javascript-resource-table">+<%=MobileCommonUtil.getHtmlLabelName(384113,user.getLanguage(),"添加")%></div>
						</div>
					</div>
					</form>
				</div>
				<div id="settings-behavior">
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385652,user.getLanguage()," 代码缩进")%>
					</div>
					<div class="field-content">
						<input type="range" min="1" max="6" id="behaviorTabSize" value="4" list="tab-width-options">
						<datalist id="tab-width-options">
							<option>1</option>
							<option>2</option>
							<option>3</option>
							<option>4</option>
							<option>5</option>
							<option>6</option>
					    </datalist>
					</div>
					<div class="field-label">
						<%=MobileCommonUtil.getHtmlLabelName(385654,user.getLanguage(),"自动更新预览")%>
					</div>
					<div class="field-content">
						<input type="checkbox" id="behaviorAutoRun" checked="checked"/><span style="top: 0px;"><%=MobileCommonUtil.getHtmlLabelName(31676,user.getLanguage(),"启用")%></span>
						<div class="field-checkbox-desc"><%=MobileCommonUtil.getHtmlLabelName(385717,user.getLanguage(),"如果启用,预览面板会自动更新为您的代码。如果禁用,请使用“运行”按钮更新。")%></div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
<script type="text/javascript">
var _mode = "<%=mode%>";

requirejs.config({
	paths: {
		'webEditor': './webEditor/webEditor',
		'parser': './webEditor/parser/parser',
		'parser/html': './webEditor/parser/html',
		'parser/css': './webEditor/parser/css',
		'parser/js': './webEditor/parser/javascript',
		'parser/preprocessor': './webEditor/parser/preprocessor'
	}
});

window.onEditorLoad = function() {}; // 供顶层父页面重写

require(["webEditor"], function (CodeEditor) {
	window.codeEditor = new CodeEditor();
	window.onEditorLoad(window.codeEditor);
});

</script>
</body>
</html>