| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- MWF.xApplication.FindDesigner.options.multitask = false;
- MWF.xApplication.FindDesigner.Main = new Class({
- Extends: MWF.xApplication.Common.Main,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "name": "FindDesigner",
- "mvcStyle": "style.css",
- "icon": "icon.png",
- "width": "1200",
- "height": "800",
- "isResize": true,
- "isMax": true,
- "layout": {
- "type": "leftRight",
- "percent": 0.3
- },
- "title": MWF.xApplication.FindDesigner.LP.title
- },
- onQueryLoad: function(){
- this.lp = MWF.xApplication.FindDesigner.LP;
- this.filterOption = {
- "keyword": "",
- "designerTypes": [],
- "caseSensitive": false,
- "matchWholeWord": false,
- "matchRegExp": false,
- "moduleList": []
- }
- this.selectedModules = [];
- this.selectedRange = [];
- o2.UD.getDataJson("findDesignerLayout", function(json){
- this.setOptions(json);
- }.bind(this), false);
- },
- loadApplication: function(callback){
- var url = this.path+this.options.style+"/view.html";
- this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
- this.setSizeNode();
- if (callback) callback();
- }.bind(this));
- },
- initLayout: function(){
- this.listNode.set("style", "");
- this.previewNode.set("style", "");
- if (this.resizeDrag) this.resizeDrag.detach();
- if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun);
- if (this.options.layout.type=="leftRight"){
- this.toLeftRight();
- }else{
- this.toTopBottom();
- }
- },
- setSizeNode: function(){
- this.initLayout();
- this["sizeNode_"+this.options.layout.type]();
- this["setResizeNode_"+this.options.layout.type]();
- this.sizeNodeFun = null;
- this.sizeNodeFun = this["sizeNode_"+this.options.layout.type].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.options.layout.percent;
- this.listNode.setStyle("height", ""+listHeight+"px");
- var previewHeight = h*(1-this.options.layout.percent);
- 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");
- },
- sizeNode_leftRight: function(){
- var h = this.sizeResultNode();
- var w = this.resultNode.getSize().x;
- var listWidth = w*this.options.layout.percent;
- 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");
- },
- 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.options.layout.percent = height/size.y;
- if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
- if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
- this.sizeNode_topBottom();
- }.bind(this),
- "onComplete": function(){
- o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
- }.bind(this)
- });
- }
- },
- 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.options.layout.percent = width/size.x;
- if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
- if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
- this.sizeNode_leftRight();
- }.bind(this),
- "onComplete": function(){
- o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
- }.bind(this)
- });
- }
- },
- checkFilter: function(e){
- if (e.target.hasClass("filterNode_item")) e.target.getElement("input").click();
- e.stopPropagation();
- },
- checkRange: function(e){
- if (e.target.hasClass("rangeType_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);
- },
- layoutAddClass: function(flag){
- flag = flag || "";
- this.listNode.addClass("listNode"+flag);
- this.previewNode.addClass("previewNode"+flag);
- this.previewSeparatorNode.addClass("previewNode_separator"+flag);
- this.previewTitleNode.addClass("previewNode_title"+flag);
- this.previewTitleActionNode.addClass("previewNode_title_action"+flag);
- this.previewContentNode.addClass("previewNode_content"+flag);
- },
- layoutRemoveClass: function(flag){
- flag = flag || "";
- this.listNode.removeClass("listNode"+flag);
- this.previewNode.removeClass("previewNode"+flag);
- this.previewSeparatorNode.removeClass("previewNode_separator"+flag);
- this.previewTitleNode.removeClass("previewNode_title"+flag);
- this.previewTitleActionNode.removeClass("previewNode_title_action"+flag);
- this.previewContentNode.removeClass("previewNode_content"+flag);
- },
- toLeftRight: function(){
- this.layoutAddClass("_lr");
- this.layoutRemoveClass();
- this.options.layout.type="leftRight";
- },
- toTopBottom: function(){
- this.layoutAddClass();
- this.layoutRemoveClass("_lr");
- this.options.layout.type="topBottom";
- },
- changeLayout: function(){
- if (this.options.layout.type=="leftRight"){
- this.options.layout.type="topBottom";
- }else{
- this.options.layout.type="leftRight";
- }
- this.setSizeNode();
- o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
- },
- getSelectedRange: function(){
- this.selectedRange = [];
- var rangeInputs = this.rangeContentNode.getElements("input");
- rangeInputs.each(function(input){
- if (input.checked) this.selectedRange.push(input.get("value"));
- }.bind(this));
- },
- setSelectedRange: function(){
- if (this.selectedRange && this.selectedRange.length){
- var rangeInputs = this.rangeContentNode.getElements("input");
- rangeInputs.each(function(input){
- if (this.selectedRange.indexOf(input.get("value"))!=-1) input.set("checked", true);
- }.bind(this));
- }
- },
- removeRangeItem: function(item){
- item.destroy();
- var itemNodes = this.rangeSelectedContentNode.getChildren();
- if (!itemNodes.length) this.setSelectedRange();
- },
- selectFindRange: function(){
- o2.requireApp("Selector", "package", function(){
- new o2.O2Selector(this.content, {
- "values": this.selectedModules,
- "type": "PlatApp",
- "selectAllEnable": true,
- "onComplete": function(list){
- this.rangeSelectedContentNode.empty();
- //this.selectedModules = [];
- if (list.length){
- this.getSelectedRange();
- this.rangeContentNode.getElements("input").set("checked", false);
- o2.require("o2.widget.O2Identity", function(){
- list.each(function(app){
- //this.selectedModules.push(app.data);
- app.data.name = this.lp.service + "-" + app.data.name;
- var item = new o2.widget.O2Other(app.data, this.rangeSelectedContentNode, {"canRemove": true, "style": "find", "onRemove": function(item){this.removeRangeItem(item);}.bind(this)});
- item.node.store("data", item.data);
- }.bind(this));
- }.bind(this));
- }else{
- this.setSelectedRange();
- }
- }.bind(this)
- });
- }.bind(this));
- },
- getFindOption: function(){
- var filterTypes = [];
- filterItems = this.filterNode.getElements("input");
- filterItems.each(function(item){
- if (item.checked) filterTypes.push(item.get("value"));
- }.bind(this));
- var keyword = this.keywordInputNode.get("value");
- var moduleList = [];
- var itemNodes = this.rangeSelectedContentNode.getChildren();
- if (!itemNodes.length){
- this.getSelectedRange();
- this.selectedRange.each(function(type){
- moduleList.push({"moduleType": type, "flagList": []});
- });
- }else{
- var rangeApp = {};
- itemNodes.each(function(node){
- var data = node.retrieve("data");
- if (!rangeApp[data.moduleType]) rangeApp[data.moduleType] = [];
- rangeApp[data.moduleType].push(data.id);
- }.bind(this));
- Object.keys(rangeApp).each(function(k){
- moduleList.push({"moduleType": k, "flagList": rangeApp[k]});
- });
- }
- this.filterOption.keyword = keyword;
- this.filterOption.designerTypes = filterTypes;
- this.filterOption.moduleList = moduleList;
- return this.filterOption;
- }
- });
|