Procházet zdrojové kódy

设计搜索应用

huqi před 5 roky
rodič
revize
d45ec2b03e

+ 1 - 0
o2web/gulpfile.js

@@ -50,6 +50,7 @@ function setOptions(op1, op2){
     options.remotePath = op1.remotePath || op2.remotePath || "";
     options.dest = op1.dest || op2.dest || "dest";
     options.lp = op1.lp || op2.lp || "zh-cn";
+    options.src = op1.src || op2.src || "";
 }
 var options = {};
 setOptions(o_options, getEvOptions(o_options.ev));

+ 3 - 1
o2web/source/o2_core/o2.js

@@ -762,7 +762,9 @@ if (!window.Promise){
             var el = els.item(i);
             var name = el.getAttribute("data-o2-element");
             if (name) _bindToModule(op.module, el, name.toString());
+            debugger;
             if (el.hasAttribute("data-o2-events")){
+
                 var events = el.getAttribute("data-o2-events").toString();
                 if (events) _bindToEvents(op.module, el, events);
             }
@@ -1832,7 +1834,7 @@ if (!window.Promise){
     //     return Object.appendChain(asyncGeneratorPrototype, "if (this.success) this.success.apply(this, arguments);");
     // }
     //
-    // //@todo
+    //
     // _AsyncGenerator.all = function(arr){
     //     var result = [];
     //     var ag = function (){

binární
o2web/source/x_component_FindDesigner/$Main/default/icons/dockBottom.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/dockRight.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/enter.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-case-gray.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-case.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-regex-gray.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-regex.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-word-gray.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/op-word.png


binární
o2web/source/x_component_FindDesigner/$Main/default/icons/search.png


+ 198 - 10
o2web/source/x_component_FindDesigner/$Main/default/style.css

@@ -1,22 +1,210 @@
-.o2_findDesigner_content{
+.content{
     height: 100%;
 }
-.o2_findDesigner_filterNode {
+.filterNode {
+    height: 20px;
+    line-height: 20px;
+    padding: 10px 0;
+    border-bottom: 1px solid #cccccc;
+    background-color: #f0f0f0;
+}
+.keywordNode {
     height: 30px;
+    line-height: 30px;
+    padding: 2px 0;
+    background-color: #ffffff;
+}
+.rangeNode {
+    height: 20px;
+    padding: 10px 0;
+    line-height: 20px;
+    border-top: 1px solid #cccccc;
+    border-bottom: 1px solid #cccccc;
+    background-color: #f0f0f0;
+}
+.resultNode {
+    overflow: auto;
+}
+.listNode {
+    background-color: #ffffff;
+}
+.previewNode {
+    background-color: #f0f0f0;
+}
+
+.listNode_lr {
+    background-color: #ffffff;
+    height: 100%;
+    float: left;
 }
-.o2_findDesigner_keywordNode {
+.previewNode_lr {
+    background-color: #f0f0f0;
+    height: 100%;
+}
+
+.filterNode_title {
+    float: left;
+    padding: 0 10px;
+    text-align: center;
+    width: 75px;
+    font-size: 12px;
+    font-weight: bold;
+    height: 20px;
+}
+.filterNode_content {
+    margin-left: 80px;
+    font-size: 12px;
+    color: #666666;
+    height: 20px;
+}
+.filterNode_item {
+    margin-left: 5px;
+    float: left;
+    display: inline-flex;
+    cursor: default;
+}
+.keywordNode_inputArea {
+    margin-left: 95px;
     height: 30px;
 }
-.o2_findDesigner_rangeNode {
+.keywordNode_optionArea {
+    width: 85px;
+    float: left;
+    height: 24px;
+    border-right: 1px solid #cccccc;
+    padding: 3px 5px;
+}
+.keywordNode_optionItem {
+    height: 24px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    float: left;
+    margin-left: 3px;
+    cursor: pointer;
+    border-radius: 3px;
+}
+.optionItem_over {
+    background-color: #eeeeee;
+}
+.caseSensitiveNode_false {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-case-gray.png");
+}
+.matchWholeWordNode_false {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-word-gray.png");
+}
+.matchRegExpNode_false {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-regex-gray.png");
+}
+.caseSensitiveNode_true {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-case.png");
+}
+.matchWholeWordNode_true {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-word.png");
+}
+.matchRegExpNode_true {
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/op-regex.png");
+}
+.keywordNode_icon {
+    height: 30px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    float: left;
+    margin-left: 3px;
+    cursor: pointer;
+    border-radius: 3px;
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/search.png");
+}
+.keywordNode_action {
+    height: 30px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    float: right;
+    margin-left: 3px;
+    cursor: pointer;
+    border-radius: 3px;
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/enter.png");
+}
+.keywordNode_area {
+    margin-left: 24px;
+    margin-right: 24px;
     height: 30px;
 }
-.o2_findDesigner_resultNode {
-    overflow: hidden;
+.keywordNode_input {
+    border: 0;
+    width: 90%;
+    height: 26px;
+    line-height: 26px;
+    color: #888888;
+    font-size: 14px;
+}
+.keywordNode_input::placeholder {
+    color: #bbbbbb;
+}
+
+.previewNode_separator {
+    border-top: 1px solid #cccccc;
+    height: 10px;
+    cursor: row-resize;
 }
-.o2_findDesigner_listNode {
-    min-height: 300px;
+.previewNode_separator_lr {
+    border-left: 1px solid #cccccc;
+    height: 100%;
+    background-color: #f0f0f0;
+    width: 10px;
+    cursor: col-resize;
+    float: left;
+}
+
+.previewNode_title {
+    height: 20px;
+    padding: 0 5px 5px 5px;
+    background-color: #f0f0f0;
+    border-bottom: 1px solid #cccccc;
+}
+.previewNode_title_lr {
+    height: 20px;
+    padding: 5px;
+    background-color: #f0f0f0;
+    border-bottom: 1px solid #cccccc;
+}
+
+.previewNode_content {
     background-color: #ffffff;
 }
-.o2_findDesigner_previewNode {
-    min-height: 300px;
+.previewNode_content_lr {
+    background-color: #ffffff;
+}
+.previewNode_title_icon {
+    height: 20px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    float: left;
+}
+.previewNode_title_action {
+    float: right;
+    height: 20px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/dockRight.png");
+    cursor: pointer;
+}
+.previewNode_title_action_lr {
+    float: right;
+    height: 20px;
+    width: 24px;
+    background-position: center center;
+    background-repeat: no-repeat;
+    background-image: url("../x_component_FindDesigner/$Main/default/icons/dockBottom.png");
+    cursor: pointer;
+}
+.previewNode_title_content {
+    height: 20px;
+    line-height: 20px;
+    margin-left: 24px;
+    margin-right: 24px;
 }

+ 44 - 10
o2web/source/x_component_FindDesigner/$Main/default/view.html

@@ -1,13 +1,47 @@
-<div class="o2_findDesigner_content" data-o2-element="contentNode">
-    <div class="o2_findDesigner_filterNode" data-o2-element="filterNode" data-o2-events=""></div>
-    <div class="o2_findDesigner_keywordNode" data-o2-element="keywordNode" data-o2-events=""></div>
-    <div class="o2_findDesigner_rangeNode" data-o2-element="rangeNode" data-o2-events=""></div>
-    <div class="o2_findDesigner_resultNode" data-o2-element="resultNode" data-o2-events="">
-        <div class="o2_findDesigner_listNode" data-o2-element="listNode" data-o2-events=""></div>
-        <div class="o2_findDesigner_previewNode" data-o2-element="previewNode" data-o2-events="">
-            <div class="o2_findDesigner_previewNode_separator" data-o2-element="previewSeparatorNode" data-o2-events=""></div>
-            <div class="o2_findDesigner_previewNode_title" data-o2-element="previewTitleNode" data-o2-events=""></div>
-            <div class="o2_findDesigner_previewNode_content" data-o2-element="previewContentNode" data-o2-events=""></div>
+<div class="content" data-o2-element="contentNode">
+    <div class="filterNode" data-o2-element="filterNode">
+        <div class="filterNode_title">{{$.lp.filter}}</div>
+        <div class="filterNode_content" data-o2-events="click:checkFilter">
+            <div class="filterNode_item"><input checked type="checkbox" value="script" />{{$.lp.script}}(script)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="form" />{{$.lp.form}}(form)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="process" />{{$.lp.process}}(process)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="page" />{{$.lp.page}}(page)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="widget" />{{$.lp.widget}}(widget)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="view" />{{$.lp.view}}(view)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="statement" />{{$.lp.statement}}(statement)</div>
+            <div class="filterNode_item"><input checked type="checkbox" value="stat" />{{$.lp.stat}}(stat)</div>
+        </div>
+    </div>
+    <div class="keywordNode" data-o2-element="keywordNode">
+        <div class="keywordNode_optionArea" data-o2-events="mouseover:overKeywordOption;mouseout:outKeywordOption">
+            <div class="keywordNode_optionItem caseSensitiveNode_false" data-o2-element="caseSensitiveNode" data-o2-events="click:setCaseSensitive" title="区分大小写"></div>
+            <div class="keywordNode_optionItem matchWholeWordNode_false" data-o2-element="matchWholeWordNode" data-o2-events="click:setMatchWholeWord" title="全字匹配"></div>
+            <div class="keywordNode_optionItem matchRegExpNode_false" data-o2-element="matchRegExpNode" data-o2-events="click:setMatchRegExp" title="正则表达式"></div>
+        </div>
+        <div class="keywordNode_inputArea">
+            <div class="keywordNode_icon"></div>
+            <div class="keywordNode_action"></div>
+            <div class="keywordNode_area">
+                <input class="keywordNode_input" type="text" placeholder="{{$.lp.search_placeholder}}"/>
+            </div>
+
+        </div>
+    </div>
+    <div class="rangeNode" data-o2-element="rangeNode">
+        <div class="rangeContentNode" data-o2-element="rangeContentNode">
+
+        </div>
+    </div>
+    <div class="resultNode" data-o2-element="resultNode">
+        <div class="listNode_lr" data-o2-element="listNode"></div>
+        <div class="previewNode_lr" data-o2-element="previewNode">
+            <div class="previewNode_separator_lr" data-o2-element="previewSeparatorNode"></div>
+            <div class="previewNode_title_lr" data-o2-element="previewTitleNode">
+                <div class="previewNode_title_icon"></div>
+                <div class="previewNode_title_action_lr" data-o2-element="previewTitleActionNode" title="{{$.lp.dockToBottom}}" data-o2-events="click:changeLayout"></div>
+                <div class="previewNode_title_content"></div>
+            </div>
+            <div class="previewNode_content_lr" data-o2-element="previewContentNode"></div>
         </div>
     </div>
 

+ 191 - 15
o2web/source/x_component_FindDesigner/Main.js

@@ -11,37 +11,213 @@ MWF.xApplication.FindDesigner.Main = new Class({
 		"width": "1200",
 		"height": "800",
 		"isResize": true,
-		"isMax": false,
+		"isMax": true,
+		"layoutType": "leftRight",
 		"title": MWF.xApplication.FindDesigner.LP.title
 	},
 	onQueryLoad: function(){
 		this.lp = MWF.xApplication.FindDesigner.LP;
+		this.filterOption = {
+			"keyword": "",
+			"type": [],
+			"caseSensitive": false,
+			"matchWholeWord": false,
+			"matchRegExp": false,
+			"moduleList": []
+		}
+		this.heightPercent = {
+			"list": 0.4,
+			"preview": 0.6
+		}
 	},
 	loadApplication: function(callback){
-		//1var url = "../x_component_Empty/$Main/default/view.html";
 		var url = this.path+this.options.style+"/view.html";
-
 		this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
-			this.doSomething();
+			this.setSizeNode();
 
 			if (callback) callback();
 		}.bind(this));
 	},
-	doSomething: function(){
+	initLayout: function(){
+		if (this.options.layoutType=="leftRight"){
+			this.listNode.setStyles({
+				"height":"100%",
+				"width": "auto"
+			});
+			this.previewNode.setStyles({
+				"height": "100%",
+				"margin-left": ""
+			});
+			this.previewContentNode.setStyle("height", "auto");
+		}else {
+			this.listNode.setStyles({
+				"height":"auto",
+				"width": "auto"
+			});
+			this.previewNode.setStyles({
+				"height": "auto",
+				"margin-left": ""
+			});
+			this.previewContentNode.setStyle("height", "auto");
+		}
+	},
+	setSizeNode: function(){
+		debugger;
+		this.initLayout();
+		this["sizeNode_"+this.options.layoutType]();
+		this["setResizeNode_"+this.options.layoutType]();
+
+		this.sizeNodeFun = this["sizeNode_"+this.options.layoutType].bind(this);
+		this.addEvent("resize", this.sizeNodeFun);
+	},
+	sizeResultNode: function(){
+		var size = this.content.getSize();
+		var filterSzie = this.filterNode.getSize();
+		var keywordSize = this.keywordNode.getSize();
+		var rangeSize = this.rangeNode.getSize();
+		var h = size.y-filterSzie.y-keywordSize.y-rangeSize.y;
+		this.resultNode.setStyle("height", ""+h+"px");
+		return h;
+	},
+	sizeNode_topBottom: function(){
+		var h = this.sizeResultNode();
+
+		var listHeight = h*this.heightPercent.list;
+		this.listNode.setStyle("height", ""+listHeight+"px");
+		var previewHeight = h*this.heightPercent.preview;;
+		this.previewNode.setStyle("height", ""+previewHeight+"px");
 
+		var previewSeparatorSize = this.previewSeparatorNode.getSize();
+		var previewTitleSize = this.previewTitleNode.getSize();
+		var previewContentHeight = previewHeight - previewSeparatorSize.y - previewTitleSize.y;
+		this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
 	},
-	loadTask: function(){
-		alert("loadTask");
+	sizeNode_leftRight: function(){
+		var h = this.sizeResultNode();
+		var w = this.resultNode.getSize().x;
+
+		var listWidth = w*this.heightPercent.list;
+		this.listNode.setStyle("width", ""+listWidth+"px");
+		this.previewNode.setStyle("margin-left", ""+listWidth+"px");
+
+		//var previewSeparatorSize = this.previewSeparatorNode.getSize();
+		var previewTitleSize = this.previewTitleNode.getSize();
+		var previewContentHeight = h - previewTitleSize.y;
+		this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
 	},
-	tabover: function(){
-		//alert("tabover");
-		this.myNode.addClass("mainColor_bg");
+
+	setResizeNode_topBottom: function(){
+		if (this.previewSeparatorNode){
+			this.resizeDrag = new Drag(this.previewSeparatorNode, {
+				"onStart": function(el, e){
+					el.store("position", o2.eventPosition(e));
+					el.store("initialSize", this.listNode.getSize());
+				}.bind(this),
+				"onDrag": function(el, e){
+					var p = o2.eventPosition(e);
+					var position = el.retrieve("position");
+					var initialSize = el.retrieve("initialSize");
+					var dy = position.y.toFloat()-p.y.toFloat();
+					var height = initialSize.y-dy;
+
+					var size = this.resultNode.getSize();
+					this.heightPercent.list = height/size.y;
+					if (this.heightPercent.list<0.1) this.heightPercent.list = 0.1;
+					if (this.heightPercent.list>0.85) this.heightPercent.list = 0.85;
+					this.heightPercent.preview = 1-this.heightPercent.list;
+					this.sizeNode_topBottom();
+				}.bind(this)
+			});
+		}
 	},
-	tabout: function(){
-		//alert("tabout")
-		this.myNode.removeClass("mainColor_bg");
+	setResizeNode_leftRight: function(){
+		if (this.previewSeparatorNode){
+			this.resizeDrag = new Drag(this.previewSeparatorNode, {
+				"onStart": function(el, e){
+					el.store("position", o2.eventPosition(e));
+					el.store("initialSize", this.listNode.getSize());
+				}.bind(this),
+				"onDrag": function(el, e){
+					var p = o2.eventPosition(e);
+					var position = el.retrieve("position");
+					var initialSize = el.retrieve("initialSize");
+					var dx = position.x.toFloat()-p.x.toFloat();
+					var width = initialSize.x-dx;
+
+					var size = this.resultNode.getSize();
+					this.heightPercent.list = width/size.x;
+					if (this.heightPercent.list<0.1) this.heightPercent.list = 0.1;
+					if (this.heightPercent.list>0.85) this.heightPercent.list = 0.85;
+					this.heightPercent.preview = 1-this.heightPercent.list;
+					this.sizeNode_leftRight();
+				}.bind(this)
+			});
+		}
 	},
-	clickNode: function(e, data){
-		alert(data.title);
+
+	checkFilter: function(e){
+		if (e.target.hasClass("o2_findDesigner_filterNode_item")) e.target.getElement("input").click();
+		e.stopPropagation();
+	},
+	overKeywordOption: function(e){
+		if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")){
+			if (!e.target.hasClass("optionItem_over")) e.target.addClass("optionItem_over");
+		}
+	},
+	outKeywordOption: function(e){
+		if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")) e.target.removeClass("optionItem_over");
+	},
+
+	setCaseSensitive: function(e){
+		this.filterOption.caseSensitive = !this.filterOption.caseSensitive;
+		this.caseSensitiveNode.removeClass("caseSensitiveNode_"+!this.filterOption.caseSensitive);
+		this.caseSensitiveNode.addClass("caseSensitiveNode_"+this.filterOption.caseSensitive);
+	},
+	setMatchWholeWord: function(e){
+		this.filterOption.matchWholeWord = !this.filterOption.matchWholeWord;
+		this.matchWholeWordNode.removeClass("matchWholeWordNode_"+!this.filterOption.matchWholeWord);
+		this.matchWholeWordNode.addClass("matchWholeWordNode_"+this.filterOption.matchWholeWord);
+	},
+	setMatchRegExp: function(e){
+		this.filterOption.matchRegExp = !this.filterOption.matchRegExp;
+		this.matchRegExpNode.removeClass("matchRegExpNode_"+!this.filterOption.matchRegExp);
+		this.matchRegExpNode.addClass("matchRegExpNode_"+this.filterOption.matchRegExp);
+	},
+	changeLayout: function(){
+		if (this.options.layoutType=="leftRight"){
+			this.listNode.addClass("listNode");
+			this.previewNode.addClass("previewNode");
+			this.previewSeparatorNode.addClass("previewNode_separator");
+			this.previewTitleNode.addClass("previewNode_title");
+			this.previewTitleActionNode.addClass("previewNode_title_action");
+			this.previewContentNode.addClass("previewNode_content");
+
+			this.listNode.removeClass("listNode_lr");
+			this.previewNode.removeClass("previewNode_lr");
+			this.previewSeparatorNode.removeClass("previewNode_separator_lr");
+			this.previewTitleNode.removeClass("previewNode_title_lr");
+			this.previewTitleActionNode.removeClass("previewNode_title_action_lr");
+			this.previewContentNode.removeClass("previewNode_content_lr");
+
+			this.options.layoutType="topBottom";
+		}else{
+			this.listNode.removeClass("listNode");
+			this.previewNode.removeClass("previewNode");
+			this.previewSeparatorNode.removeClass("previewNode_separator");
+			this.previewTitleNode.removeClass("previewNode_title");
+			this.previewTitleActionNode.removeClass("previewNode_title_action");
+			this.previewContentNode.removeClass("previewNode_content");
+
+			this.listNode.addClass("listNode_lr");
+			this.previewNode.addClass("previewNode_lr");
+			this.previewSeparatorNode.addClass("previewNode_separator_lr");
+			this.previewTitleNode.addClass("previewNode_title_lr");
+			this.previewTitleActionNode.addClass("previewNode_title_action_lr");
+			this.previewContentNode.addClass("previewNode_content_lr");
+
+			this.options.layoutType="leftRight";
+		}
+		if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun);
+		this.setSizeNode();
 	}
 });

+ 15 - 1
o2web/source/x_component_FindDesigner/lp/zh-cn.js

@@ -1,3 +1,17 @@
 MWF.xApplication.FindDesigner.LP = {
-	"title": "在设计中查找"
+	"title": "在设计中查找",
+
+	"filter": "在设计中查找",
+	"script": "脚本",
+	"form": "表单",
+	"process": "流程",
+	"page": "页面",
+	"widget": "部件",
+	"view": "视图",
+	"statement": "脚本",
+	"stat": "统计",
+
+	"search_placeholder": "请输入搜索内容",
+	"dockToBottom": "固定到下方",
+	"dockToRight": "固定到右侧"
 };