Exemplo n.º 1
0
		enablePullUp: function(){
			this.$puEle = $('<div class="x-pull-up x-content-center"><span class="x-pull-up-label">' + this.pullUpLabel +  '</span></div>');
			this.$scrollEle.append(this.$puEle);
			
			xuiService.getXuiDoc().updateProperties(this.$rootEle);
			xuiService.getXuiDoc().updateNodes(this.$puEle);
		},
Exemplo n.º 2
0
		enablePullDown: function(){
			this.$rootEle.attr('supportPullDown',true);
			this.$pdEle = $('<div class="x-content-center x-pull-down container"><i class="x-pull-down-img glyphicon x-icon-pull-down"></i><span class="x-pull-down-label">'+ this.pullDownLabel + '</span></div>');
			this.$scrollEle.prepend(this.$pdEle);
			
			xuiService.getXuiDoc().updateProperties(this.$rootEle);
			xuiService.getXuiDoc().updateNodes(this.$pdEle);
		},
Exemplo n.º 3
0
		propertyChangedHandler : function(name,oldValue,value){
			this.callParent(name,oldValue,value);
			if(name == "pullDownLabel"){
				var $pdlEle =  this.$scrollEle.find('.x-pull-down-label');
				$pdlEle.text(value);
				xuiService.getXuiDoc().updateText($pdlEle);
			}else if(name == "pullUpLabel"){
				var $pulEle =  this.$scrollEle.find('.x-pull-up-label');
				$pulEle.text(value);
				xuiService.getXuiDoc().updateText($pulEle);
			}
		}
Exemplo n.º 4
0
		addDivider: function(){
			var me = this;
			xuiService.getXuiDoc().createComponent("$UI/system/components/justep/menu/menu#divider", this, {paintComponent:true}, function(node){
				var id = $(node).attr('d_id');
				$('*[d_id='+id+']', me.$el).attr("d_canAddChild", false);
			});
		},
Exemplo n.º 5
0
		disablePullDown: function(){
			var $pdEle = $('.x-pull-down',this.$scrollEle);
			var did = $pdEle.attr('d_id');
			$pdEle.remove();
			xuiService.getXuiDoc().deleteComponent([did]);
			
		},
Exemplo n.º 6
0
define(function(require) {
	require("$UI/system/components/justep/common/res");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	var ViewComponent = require("$UI/system/lib/base/viewComponent");
	
	var Media = ViewComponent.extend({
		init : function() {  
			this.$domNode = $(this.domNode);  
			$(">*", this.$domNode).attr("d_resizable", "false");
		},
		
		addMediaLeft : function(){
			var bodyDid = this.$domNode.children('.media-body').attr('d_id');
			xuiDoc.createComponent("$UI/system/components/bootstrap/media/media(bootstrap)#mediaLeft", this, {
				paintComponent : true,
				before:bodyDid
			});
		},
		addMediaRight : function(){
			xuiDoc.createComponent("$UI/system/components/bootstrap/media/media(bootstrap)#mediaRight", this, {
				paintComponent : true
			});
		},
		addMediaBody : function(){
			xuiDoc.createComponent("$UI/system/components/bootstrap/media/media(bootstrap)#mediaBody", this, {
				paintComponent : true
			});
		}
	});
	return {
		'$UI/system/components/bootstrap/media/media(bootstrap)' : Media
	};
});
Exemplo n.º 7
0
		addItem: function(){
			var me = this;
			xuiService.getXuiDoc().createComponent("$UI/system/components/justep/menu/menu#item", this, {paintComponent:true}, function(node){
				var id = $(node).attr('d_id');
				var li = $('*[d_id='+id+']', me.$el).attr("d_canAddChild", false);
				$('>*', li).attr('d_selectable', false);
			});
		},
Exemplo n.º 8
0
		addWidget: function(){
			xuiService.getXuiDoc().createComponent("$UI/system/components/justep/widgets/widget",
				this, {paintComponent:true}, 
				function(el){
					var id = $(el).attr('d_id');
					$('[d_id=' + id + ']')
						//.attr("d_canAddChild", "true")
						//.attr('d_resizable', false)
						.selectable(true);
				}
			);
		},
Exemplo n.º 9
0
		addPanel: function(){
			var xuiDoc = xuiService.getXuiDoc(), me = this;
	    	xuiDoc.createComponent("$UI/system/components/bootstrap/panel/panel",this,
				{templateContent: panelTemplate, paintComponent:true},
				function(result){
					var d_id = $(result).attr('d_id');
					var comp = justep.Component.getComponent($("[d_id='" + d_id + "']").get(0));
					comp.onAfterSelect = function(){
						me.onPanelSelect(comp);
					}
				}
			);
		},
Exemplo n.º 10
0
define(function(require) {
	var $ = require("jquery");
	var RTWindowDialog = require("../windowDialog");
	require('css!./css/windowDialog').load();
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();

	function create(comp, clz) {
		var $domNode = $(comp.domNode);
		comp.domNode.style.position = "absolute";
		if (!comp.domNode.style.top) {
			comp.domNode.style.top = "10px";
			comp.domNode.style.left = "10px";
		}
		$domNode.addClass(clz);
	}

	var dialog = RTWindowDialog.extend({
		init : function(value, bindingContext) {
			create(this, 'x-window-dialog');
			this.callParent(value, bindingContext);
		},
		editMapping : function(config){
			var src = xuiDoc.get(this,"src");
			if(!src){
				alert("请先设置src属性");
				return;
			}
			var self = this;
			xuiService.openPage("$UI/system/components/justep/windowDialog/designer/editMapping.w", {
				title : "编辑Mapping",
				xml : config.nodeXml,
				modelRoot : config.modelRoot,
				src: src,
				height: '80%',
				width: '80%'
			}, function(result) {
				xuiDoc.replaceChild(self, result.mapping, {
					xpathCondition : "*[local-name()='result']",
					jqCondition : "result",
					paintComponent : false
				});
			});
		}
	});

	return {
		'$UI/system/components/justep/windowDialog/windowDialog' : dialog
	};
});
Exemplo n.º 11
0
define(function (require) {
	var $ = require("jquery"),
		AttachmentSimple = require("../attachmentSimple"),
		Component = require("$UI/system/lib/base/component"),
		justep = require('$UI/system/lib/justep'),
		bind = require("bind"),
		xuiService = require("$UI/system/components/designerCommon/js/xuiService"),
		xuiDoc = xuiService.getXuiDoc();
	
	var AttachmentSimpleDesign = AttachmentSimple.extend({
		init:function(value, bindingContext){
			this.$domNode.find('div').attr('d_selectable',"false");
		}
	});
	
	return {
		'$UI/system/components/justep/attachment/attachmentSimple':AttachmentSimpleDesign
	};
});
Exemplo n.º 12
0
define(function (require) {
	var $ = require("jquery"),
		Bar = require("../titleBar"),
		xuiService = require("$UI/system/components/designerCommon/js/xuiService"),
		xuiDoc = xuiService.getXuiDoc();
	
	var cls = Bar.extend({
		init:function(value, bindingContext){
			this.callParent(value, bindingContext);
			this.$title.attr('d_selectable',false);
		},
		setTitle: function(value){
			this.callParent(value);
			xuiDoc.updateText($('>.x-titlebar-title', this.domNode));
		}
	});

	return {'$UI/system/components/justep/titleBar/titleBar':cls};
});
Exemplo n.º 13
0
define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	//var bizService = require("$UI/system/components/designerCommon/js/bizModelService");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	
	var templateMap = {
	};

	var layoutData;
	var componentName = "$UI/system/components/fragment/list/listTable";
	
	var dataRelationloaded = {};
	
	var Model = function(){
		this.callParent();
		this.update = justep.Bind.observable(false);
		this.inited = justep.Bind.observable(false);
		this.extendIcon = justep.Bind.observable("");
	};
	
	Model.prototype.getRelations = function(dataid){
		var update = this.update.get();
		if(update){
			var ret = [];
			var data = this.comp('relationList');
			data.each(function(param){
				if(param.row.val('data')===dataid)
					ret.push(param.row);
			});
			return ret;
		}else return [];
	};
	
	Model.prototype.getRows = function(){
		var inited = this.inited.get();
		if(!inited) return [];
		var data = this.comp('setting');
		var row = data.getCurrentRow();
		var ret = row?row.children():null;
		return ret?ret:[];
	};
	
	var labelHtml = function(data,col,clz){
		return "<th "+(clz?("class='"+clz+"'"):"")+"><label bind-text=\"$model."+data+".label('"+col+"')\"></label></th>";
	};
	
	var compHtml = function(compType,col){
        return "<td>"+getCompTemplate(compType,' bind-ref="ref(\''+col+'\')"')+"</td>";
	};

	/**获取组件模板***/
	var getCompTemplate = function(compName,appendAttrs){
	   var templateContent = templateMap[compName];
	   if(!templateContent){
	     templateContent =  xuiDoc.getTemplate(compName);
	     templateMap[compName] = templateContent;
	   }
	   if(templateContent){
		   var idx = templateContent.indexOf(">");
		   var idx1 = templateContent.indexOf("/>");
		   if(idx1>0 && idx1<idx){
		      idx = idx1;
		   }
		   if(idx>0){
		      templateContent = templateContent.substring(0,idx)+appendAttrs+templateContent.substring(idx);
		   }
	   }
	   return templateContent;
	};

	var processTemplate = function(extendIcon, row, datas, parantDataID){
	   if(!row) return "";	
	   var data = row.val('data');
	   if(!data) return "";
	   var masterCol = row.val('masterCol');
	   var relations = datas[data];
	   if(!relations) return "";
	   var colSize = relations.length;	
	   var t = '<div component="$UI/system/components/fragment/list/listTable" data="{0}" masterData="{1}" masterCol="{2}">' 
		         +'<div component="$UI/system/components/justep/list/list" class="x-list" data="{3}">'
                   +'<table class="table table-bordered table-hover table-striped table-condensed" component="$UI/system/components/bootstrap/table/table">' 
                  +'<thead>' 
                    +'<tr class="{4}">{5}</tr>' 
                  +'</thead>'  
                  +'<tbody class="x-list-template" bind-click="$model!=$object?$object.data.to($object):null">' 
                    +'<tr class="{6}" {7}>{8}</tr>'
 					+'{9}'	
                  +'</tbody>' 
                +'</table>'
              +'</div>'
            +'</div>';
        var head='',comps='',children='',trBindClick='',isExpand = row.val("expand");

        if(row.hasChildren()){
        	var rows = row.children();
        	$.each(rows,function(i,row){
        		children += processTemplate(extendIcon,row,datas,data);
        	});
        }
        if(row.val("useIndex")){
        	head += "<th width='60px'><label></label></th>";
        	comps += "<td class='text-center' style='vertical-align:middle;'><i class='x-expand-i "+(isExpand||!children?"":extendIcon)+"' style='color:#808080;padding-right:6px;'/><label bind-text='$index()+1'></label></td>";
        	colSize++;
        }
        
        $.each(relations,function(i,v){
        	head += labelHtml(data,v.val('name'));
        	comps += compHtml(v.val('compType'),v.val('name'),parantDataID?data:"");
        });
        
        if(children){
        	var hideClass = isExpand?"":"class='hide'";
        	children = '<tr '+hideClass+'><td colspan="'+colSize+'">'+children+'</td></tr>';
        	trBindClick = 'bind-click="function(){var $e = $($element);$(\'>td>i.x-expand-i\',$e).toggleClass(\''+extendIcon+'\');$e.next().toggleClass(\'hide\');}"';
        }else children = "";
                
	    return justep.String.format(t,
	    		data,
	    		(parantDataID?parantDataID:''),
	    		(masterCol?masterCol:''),
	    		data,
	    		(parantDataID?"danger":"success"),
	    		head,
	    		(parantDataID?"warning":"info"),
	    		trBindClick,
	    		comps,
	    		children);
	};
	
	/**点确定前调用的处理,做校验**/
	Model.prototype.beforeOkAction = function(){
	   var settingData = this.comp("setting");
	   var row = settingData.getCurrentRow();
	   var dataXid = row.val("data");
	   if(!dataXid){
	       return "请选择主data";
	   }
	   
	   var errorDatas = [];
	   var datas = {};   
	   settingData.each(function(param){
		   var data = param.row.val('data');
		   if(data){
			   datas[data]=[];
			   if(row!==param.row && !param.row.val('masterCol'))
				   errorDatas.push(data);
		   }
	   });   
	      
	   if(errorDatas.length > 0){
	       return "从Data["+errorDatas.join(',')+"]请选择关联主数据列";
	   }

	   var relationListData = this.comp("relationList");
		relationListData.each(function(param){
			var data = param.row.val('data');
		    var selected = param.row.val("selected");
		    if(selected){
		      if(undefined!==datas[data])
		    	  datas[data].push(param.row);
		    }
		});

		errorDatas = [];
		$.each(datas, function(n,v){
			if(v.length<=0) errorDatas.push(n); 
		});
		
	   if(errorDatas.length > 0){
	       return "Data["+errorDatas.join(',')+"]请选择关系";
	   }
	
	   layoutData = processTemplate(this.extendIcon.get(), row, datas);
	};
	
	/**
	 * 获取返回值,点击确定后调用的方法,必须是一个json格式的数据 .
	 */
	Model.prototype.getReturnValue = function(){
		return {templateContent:layoutData,componentName:componentName}; 
	};

	Model.prototype.modelLoad = function(event){
	    //获取上下文参数
		this.context = xuiService.getPageParams();
		var data = this.comp("dataList");
	    data.add({col0:""});
		var sNodes = xuiDoc.selectNodes("//*[@component='$UI/system/components/justep/data/bizData' or @component='$UI/system/components/justep/data/data' or @component='$UI/system/components/justep/data/baasData']");
		$(sNodes).each(function(idx){
		   var $this = $(this);  
		   data.add({col0:$this.attr("xid")});
		});
		
		var setingData = this.comp("setting");
		setingData.add({"id":"2","parent":"1","useIndex":true},setingData.getCurrentRow(true),true);
		this.inited.set(true);
	};

    /** 选择数据 **/
	Model.prototype.select2Change = function(event){
		this.update.set(false);
		 var value = event.value;  
		 if(value && !dataRelationloaded[value]){
		   var datasource =  xuiDoc.getEditorDataSource("RuleRelationDatasource.getDatasource","xid",value);
		   for(var i = 0;i<datasource.length;i+=1){
		      datasource[i].compType = "$UI/system/components/justep/input/input";
		   }
		   var rows = this.comp("relationList").loadData({rows:datasource}, true);
		   for(i=0; i<rows.length; i++){
			   rows[i].val('data',value);
		   }
		   
		   dataRelationloaded[value] = true;
		 }
		this.update.set(true);
	};

	Model.prototype.checkAllChange = function(event){
		var dataid;
	   if(this===event.bindingContext.$object) dataid = this.setting.val('data');
	   else dataid = event.bindingContext.$object.val('data');
	   if(dataid){
		   var relationList = this.getRelations(dataid);
		   $.each(relationList,function(i,row){
			   row.val("selected",event.checked);
		   });
	   }
	};

	return Model;
});
Exemplo n.º 14
0
define(function(require) {
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	//var $ = require("jquery");
	var RTProvinceSelect = require("../provinceSelect");
	var RTCitySelect = require("../citySelect");
	var RTDistrictSelect = require("../districtSelect");
	var RTDistpicker =  require("../distpicker");
	
	var PopPicker =  require("$UI/system/components/justep/picker/designer/picker");

	var ProvinceSelect = RTProvinceSelect.extend({
		doInit : function(value, bindingContext, allBindings) {
		},
		doUpdate : function(value, bindingContext, allBindings) {
		}
	});

	var CitySelect = RTCitySelect.extend({
		doInit : function(value, bindingContext, allBindings) {
		},
		doUpdate : function(value, bindingContext, allBindings) {
		}
	});

	var DistrictSelect = RTDistrictSelect.extend({
		doInit : function(value, bindingContext, allBindings) {
		},
		doUpdate : function(value, bindingContext, allBindings) {
		}
	});

	var Distpicker = RTDistpicker.extend({
		doInit : function(value, bindingContext, allBindings) {
			this['bind-provinceRef'] = null;
			this['bind-cityRef'] = null;
			this['bind-districtRef'] = null;
		},
		doUpdate : function(value, bindingContext, allBindings) {
		},
		propertyChangedHandler : function(key, oldVal, value) {
			this.callParent(key, oldVal, value);
			var $select;
			if ('bind-provinceRef' == key) {
				$select = this._get$Select('province');
				if($select.size()>0){
					$select.attr('bind-ref',value);
					xuiDoc.updateProperties($select,['bind-ref']);
				}
			}else if('bind-cityRef' == key){
				$select = this._get$Select('city');
				if($select.size()>0){
					$select.attr('bind-ref',value);
					xuiDoc.updateProperties($select,['bind-ref']);
				}
			}else if('bind-districtRef' == key){
				$select = this._get$Select('district');
				if($select.size()>0){
					$select.attr('bind-ref',value);
					xuiDoc.updateProperties($select,['bind-ref']);
				}
			}
		}
	});

	return {
		'$UI/system/components/justep/distpicker/provinceSelect' : ProvinceSelect,
		'$UI/system/components/justep/distpicker/citySelect' : CitySelect,
		'$UI/system/components/justep/distpicker/districtSelect' : DistrictSelect,
		'$UI/system/components/justep/distpicker/distpicker' : Distpicker,
		'$UI/system/components/justep/distpicker/distpicker2' : PopPicker['$UI/system/components/justep/picker/popPicker']
	};
});
Exemplo n.º 15
0
		addBottom: function(){
			var id = this.$content.attr('d_id'), me = this;
			xuiService.getXuiDoc().createComponent("$UI/system/components/justep/panel/panel#bottom", this, {paintComponent:true}, function(){
        		$('>.x-panel-content', me.$domNode).css('bottom', $('>.x-panel-bottom', me.$domNode).height());
			});
		},
Exemplo n.º 16
0
define(function(require){
	var $ = require("jquery"),
	ViewComponent = require("$UI/system/lib/base/viewComponent");
    var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	var fileSelectorUrl  = "$UI/system/designer/webIde/editors/fileSelector/fileSelector.w";
	
	var loadCss = function(cssItems){
		var values = cssItems.split(",");
		for(var i = 0;i<values.length;i+=1){
			var item = values[i];
			require([item],function(a){
				a.load();
			});	
		}			
	}
	
	var Resource = ViewComponent.extend({
		init: function(value, bindingContext){
			this.callParent(value, bindingContext);
			this.$domNode = $(this.domNode);
			this.$domNode.hide();
		},

		getResource:function(){
	 
			return this.$domNode[0];
		},
		
		/**添加js引用*/
		addJS:function(event){
			var resouce = this.getResource();
			xuiService.openPage(fileSelectorUrl, {
				title : "js文件选择",
				width:480,
				extName:"js"
			}, function(result) {
				var value = result.value;
				if(value){
					var idx = value.lastIndexOf(".");
					if("js" != value.substring(idx+1)){
						alert("必须选择一个js文件");
						return;
					}
					value = value.substring(0,idx);
					var templateContent = '<require   url="'+value+'"></require>';
					xuiDoc.createComponent("$/UI2/system/components/justep/resource#require",resouce.getAttribute("d_id"),{templateContent:templateContent,paintComponent:true});
				}
			});
		},

		/**添加css引用*/
		addCSS:function(event){
			var resouce = this.getResource();
			xuiService.openPage(fileSelectorUrl, {
				title : "css文件选择",
				width:480,
				extName:"css"
			}, function(result) {
				var value = result.value;
				if(value){
					var idx = value.lastIndexOf(".");
					if("css" != value.substring(idx+1)){
						alert("必须选择一个css文件");
						return;
					}
					value = value.substring(0,idx);
					var templateContent = '<require   url="css!'+value+'"></require>';
					xuiDoc.createComponent("$/UI2/system/components/justep/resource#require",resouce.getAttribute("d_id"),{templateContent:templateContent,paintComponent:true});
				}
			});
		},
		
		/**添加Cordova 插件引用*/
		addCordovaPlugin:function(){
			var resouce = this.getResource();
			xuiService.openPage("$UI/system/components/justep/resource/designer/selectCordovaPlugins.w", {
				title : "cordova插件选择"
			}, function(result) {
				var values = result; 
				if(values){
					values = values.split(",");
					var configs = [];
					for(var i = 0;i<values.length;i+=1){
						var templateContent = '<require   url="cordova!'+values[i]+'"></require>';
						xuiDoc.createComponent("$/UI2/system/components/justep/resource#require",resouce.getAttribute("d_id"),{templateContent:templateContent,paintComponent:true});
					}
				}
			});			
		},
		
		/**添加w文件引用*/
		addWFileRef:function(){
			var resouce = this.getResource();
			xuiService.openPage(fileSelectorUrl, {
				title : "w文件选择",
				width:480,
				extName:"w,html"
			}, function(result) {
				var value = result.value;
				if(value){
					var idx = value.lastIndexOf(".");
					if("w" != value.substring(idx+1) && "html" != value.substring(idx+1)){
						alert("必须选择一个w文件");
						return;
					}
					value = value.substring(0,idx);
					var templateContent = '<require   url="w!'+value+'"></require>';
					xuiDoc.createComponent("$/UI2/system/components/justep/resource#require",resouce.getAttribute("d_id"),{templateContent:templateContent,paintComponent:true});
				}
			});
		}
		
	});
	
	var Require = ViewComponent.extend({
		init: function(value, bindingContext){
			this.callParent(value, bindingContext);
			this.$domNode = $(this.domNode);
			this.$domNode.hide(); 
			var url = this.$domNode.attr("url");
			this.set({url:url});
		},
        set: function(values){ 
        	if('url' in values){
        		var url = values['url'];
        		if(url && url.indexOf("css!") !=-1){
        			loadCss(url)
        		}
        	}
        }
		
	});
	
	return {'$/UI2/system/components/justep/resource':Resource,'$/UI2/system/components/justep/resource#require':Require};
});
Exemplo n.º 17
0
define(function(require) {
	require("$UI/system/components/justep/common/res");
	var Tabs = require("../tabs");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	var $ = require("jquery");
	require('css!./css/tabs').load();

	Tabs = Tabs.extend({
		init : function(value, bindingContext) {
			this.callParent(value, bindingContext);
			this._initDesignStatus();
		},

		_initDesignStatus : function() {
			$(">.nav", this.domNode).attr("d_selectable", "false");
			$(">.nav,>.tab-content", this.domNode).attr("d_canRemove", "false")
					.attr("d_resizable", "false");
			$(">.nav>li", this.domNode).attr("d_canRemove", "false").attr(
					"d_selectable", "false").attr("d_resizable", "false");
			$(">.nav>li>a", this.domNode).attr("d_y_resizable", "false");
		},

		set : function(config) {
			for ( var p in config) {
				if (p == 'label') {
					this.domNode.innerHTML = config[p];
				} else if (p == 'row-count') {
					this.buildRows(config[p]);
					this.$domNode.attr("row-count", config[p]);
				}
			}
		},

		addTab : function() {
			var self = this;
			var configs = [];
			var xid = xuiDoc.genaXId("tabContent");
			configs.push({
				componentName : "li",
				paintComponent : true,
				parentElementId : $(">.nav", this.domNode).attr("d_id"),
				autoSelect : false,
				templateContent : '"<li><a content="' + xid
						+ '">tab1</a></li>"'
			});
			configs
					.push({
						componentName : "div",
						paintComponent : true,
						parentElementId : $(">.tab-content", this.domNode)
								.attr("d_id"),
						templateContent : '<div class="tab-pane" xid="' + xid
								+ '"></div>'
					});
			xuiDoc.batchCreateComponent(configs, function() {
				// self.ownerDesigner.setSelection($(">.nav>li:last>a",self.domNode)[0]);
				self.setActiveTab($(">.nav>li:last", self.domNode));
				self._initDesignStatus();
			});
		}
	});

	var TabItem = function(config) {
		this.domNode = this.templateNode = config.templateNode;
		this.domNode.setAttribute("tabindex", '0');
	};

	TabItem.prototype = {
		onRemove : function(event) {
			if ($("li", this.domNode.parentNode.parentNode).length == 1) {
				event.cancel = true;
			} else {
				event.cancel = true;
				var $domNode = $(this.domNode);
				var content = $domNode.attr("content");
				var contentDId = $(">.tab-content>*[xid='" + content + "']",
						$domNode.parent().parent().parent()).attr("d_id");
				xuiDoc.deleteComponent([ contentDId,
						$domNode.parent().attr("d_id") ]);
			}
		},
		set : function(config) {
			for ( var p in config) {
				if (p == 'label') {
					this.domNode.innerHTML = config[p];
				} else if (p == 'content') {
					this.domNode.setAttribute("content", config[p]);
				}
			}
		}
	};

	return {
		'$UI/system/components/bootstrap/tabs/tabs(bootstrap)' : Tabs,
		'$UI/system/components/bootstrap/tabs/tabs(bootstrap)#tabItem' : TabItem
	};

});
Exemplo n.º 18
0
define(function(require) {
	var $ = require("jquery");
	var Util = require("$UI/system/components/justep/common/designer/common");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	var Button = require("../button");
	var ButtonGroup = require("../buttonGroup");
	var Radio = require("../radio");
	var Checkbox = require("../checkbox");
	var RadioPC = require("../radioPC");
	var CheckboxPC = require("../checkboxPC");
	var Toggle = require("../toggle");
	require('css!./css/button').load();

	var _Button = Button.extend({
		init : function(value, bindingContext) {
			var $domNode = $(this.domNode);
			this.callParent(value, bindingContext);
			var cfg = Util.attr2js($domNode, [ 'label', 'icon', 'image' ]);
			if (cfg)
				this.set(cfg); 
			var onclick = xuiDoc.get(this,'onClick');
			if (onclick && 0 < onclick.indexOf('operation')) {
				// 操作感知
				this.on('onClick', onclick);
			}
			$domNode.removeAttr('onclick').off('click');
			this._d_inited_ = true;
			this._getLabelNode().attr('d_selectable', false).attr("d_canRemove", false).attr("d_canAddChild", false);
			this._getIconNode().attr('d_selectable', false).attr("d_canRemove", false).attr("d_canAddChild", false);
			this._getImgNode().attr('d_selectable', false).attr("d_canRemove", false).attr("d_canAddChild", false);
		},
		bindOperation : function(data) {
			if (data && data.eventName)
				this.on(data.eventName, data.value);
		},
		_getImgUrl : function(icon) {// "icon-refresh"/"img:xxx.png|xxx.png"
			if (typeof (icon) === 'string' && 0 === icon.indexOf('img:')) {
				var ipos = icon.indexOf('|');
				if(!this.disabled || ipos < 0){
					if (ipos < 0)
						ipos = icon.length;
					return icon.slice(4, ipos);
				}else	return icon.slice(ipos);
			} 
		},
		propertyChangedHandler : function(key, oldVal, value) {
			var $img,$icon,url,newImg;
			switch (key) {
			case "label":
				this.callParent(key, oldVal, value);
				if (this._d_inited_)
					xuiDoc.updateText(this._getLabelNode());
				break;
			case "disabled":
				if (this.$domNode) {
					if (this.isImgIcon) {
						$img = this._getImgNode();
						$icon = this._getIconNode();
						$icon.removeAttr('class');
						xuiDoc.updateProperties($icon, [ 'class' ]);
						newImg = false;
						if ($img.size() <= 0){
							newImg = true;
							this._getLabelNode().before('<img d_selectable="false" d_canRemove="false"/>');
						}
						$img = this._getImgNode();
						//这个逻辑是为了同步设计时模型,同步后在刷新设计器显示,特殊处理
						url = this._getImgUrl(value);
						$img.attr('src', url?url:'');
						if(newImg) xuiDoc.updateNodes($img);
						else xuiDoc.updateProperties($img, ['src']);
						//这是为了在设计器正常显示
						$img.attr('src', this.imgIcon[this.disabled ? 1 : 0]);
					}
				}
				break;
			case "icon":
				if (oldVal != value) {
					this._setIcon(this.icon || this.opIcon);
					if (this.$domNode) {
						if (!this.isImgIcon) {
							$icon = this._getIconNode();
							if (oldVal)
								$icon.removeClass(oldVal);
							if (this.opIcon)
								$icon.removeClass(this.opIcon);
							if (value)
								$icon.addClass(this.icon || this.opIcon);
							xuiDoc.updateProperties($icon, [ 'class' ]);
							$img = this._getImgNode();
							if ($img.size() > 0) {
								xuiDoc.deleteComponent([ $img.attr('d_id') ]);
								$img.remove();
							}
						} else {
							$img = this._getImgNode();
							if (value) {
								$icon = this._getIconNode();
								$icon.removeAttr('class');
								xuiDoc.updateProperties($icon, [ 'class' ]);
								newImg = false;
								if ($img.size() <= 0){
									newImg = true;
									this._getLabelNode().before('<img d_selectable="false" d_canRemove="false"/>');
								}
								$img = this._getImgNode();
								//这个逻辑是为了同步设计时模型,同步后在刷新设计器显示,特殊处理
								url = this._getImgUrl(value);
								$img.attr('src', url?url:'');
								if(newImg) xuiDoc.updateNodes($img);
								else xuiDoc.updateProperties($img, ['src']);
								//这是为了在设计器正常显示
								$img.attr('src', this.imgIcon[this.disabled ? 1 : 0]);
							}
						}
					}
				}
				break;
			default:
				this.callParent(key, oldVal, value);
			}
		}
	});

	var _ButtonGroup = ButtonGroup.extend({
		init : function(value, bindingContext) {
			var $domNode = $(this.domNode);
			var cfg = Util.attr2js($domNode, [ 'selected' ]);
			this.callParent(value, bindingContext);
			if (cfg)
				this.set(cfg);
			this.$domNode.off('click');
		},
		addButton : function() {
			xuiDoc.createComponent('$UI/system/components/justep/button/button', this, {
				paintComponent : true
			});
		}
	});

	function createRadioButton(button, type) {
		button.$domNode = $(button.domNode);
		button.$domNode.append("<input type='" + type + "'/><label/>");
		var cfg = Util.attr2js(button.$domNode, [ 'label', 'name', 'value' ]);
		if (cfg)
			button.set(cfg);
	}

	var _Radio = Radio.extend({
		init : function(value, bindingContext) {
			createRadioButton(this, 'radio');
			this.callParent(value, bindingContext);
			this._getInput().off('click');
		}
	});

	var _Checkbox = Checkbox.extend({
		init : function(value, bindingContext) {
			createRadioButton(this, 'checkbox');
			this.callParent(value, bindingContext);
			this._getInput().off('click');
		}
	});

	function createRadioPC(button, type) {
		button.$domNode = $(button.domNode);
		button.$domNode.append("<label><input type='" + type + "'/><span/></label>");
		var cfg = Util.attr2js(button.$domNode, [ 'label', 'name', 'value' ]);
		if (cfg)
			button.set(cfg);
	}

	var _RadioPC = RadioPC.extend({
		init : function(value, bindingContext) {
			createRadioPC(this, 'radio');
			this.callParent(value, bindingContext);
			this._getInput().off('click');
		}
	});

	var _CheckboxPC = CheckboxPC.extend({
		init : function(value, bindingContext) {
			createRadioPC(this, 'checkbox');
			this.callParent(value, bindingContext);
			this._getInput().off('click');
		}
	});

	function createToggle(button) {
		button.$domNode = $(button.domNode);
		var type = button.$domNode.attr('type'), onLabel = button.$domNode.attr('ON'), offLabel = button.$domNode.attr('OFF');
		if (!type)
			type = 'radio';
		if (!onLabel)
			onLabel = 'ON';
		if (!offLabel)
			offLabel = 'OFF';
		button.$domNode.append("<input type='" + type + "'/><label data-on='" + onLabel + "' data-off='" + offLabel + "'><span/></label>");
		var cfg = Util.attr2js(button.$domNode, [ 'name', 'value' ]);
		if (!cfg)
			cfg = {};
		cfg['label'] = {
			on : onLabel,
			off : offLabel
		};
		if (cfg)
			button.set(cfg);
	}

	var _Toggle = Toggle.extend({
		init : function(value, bindingContext) {
			createToggle(this);
			this.callParent(value, bindingContext);
			this._getInput().off('click');
			this.ON = this.label.on;
			this.OFF = this.label.off;
		},
		propertyChangedHandler : function(key, oldVal, value) {
			switch (key) {
			case "ON":
			case "OFF":
				if (this._inited) {
					this.set({
						label : {
							on : this.ON,
							off : this.OFF
						}
					});
				}
				break;
			default:
				this.callParent(key, oldVal, value);
			}
		}
	});

	return {
		'$UI/system/components/justep/button/button' : _Button,
		'$UI/system/components/justep/button/buttonGroup' : _ButtonGroup,
		'$UI/system/components/justep/button/radio' : _Radio,
		'$UI/system/components/justep/button/checkbox' : _Checkbox,
		'$UI/system/components/justep/button/radioPC' : _RadioPC,
		'$UI/system/components/justep/button/checkboxPC' : _CheckboxPC,
		'$UI/system/components/justep/button/toggle' : _Toggle
	};
});
Exemplo n.º 19
0
define(function(require) {
	var $ = require("jquery");
	var justep = require('$UI/system/lib/justep');
	var RTDataTables = require("../dataTables");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	
	var DataTables = RTDataTables.extend({
		constructor : function(config) {
			this.callParent(config);
		},
		init : function(value, bindingContext) {
			var $domNode = $(this.domNode);
			this.data = $domNode.attr('data');
			$domNode.html('请设置DataTables的data属性然后增加DataTables列').attr('d_resizable',false);
			var self = this;
			window.setTimeout(function(){
				self.repaintDataTableds();
			},100);
			$domNode.on("childUndoRedo",function(){//撤销重做时重画
				if(self.repaintTimer){
					clearTimeout(self.repaintTimer);
				}
				self.repaintTimer = setTimeout(function(){
					self.repaintTimer = null;
					self.repaintDataTableds();
				},150);
			});
	 
		},
		set: function(value){
			this.callParent(value);
			this.repaintDataTableds();
		},
		appendColumn: function(config) {
			var self = this;
			//获取data的did
			var dataID = this.get('data');
			var data = this.getModel().comp(dataID);
			if(!data){
				alert('请先设置DataTables的data属性');
				return;
			}
			var data_did = data.$domNode.attr('d_id');
			// 获取data列信息
			var cols = xuiDoc.getEditorDataSource("RuleRelationDatasource.getDatasource",null,data_did);
			//打开编辑器
			xuiService.openPage("$UI/system/components/justep/dataTables/designer/appendColumn.w", {
				xml : config.nodeXml,
				cols : cols
			}, function(result) {
				var cols = result.cols;
				if($.isArray(cols)){
					var configs = [];
					for(var i=0;i<cols.length;i++){
						configs.push({
							componentName : "$UI/system/components/justep/dataTables/dataTables#column",
							parentElementId : self.columns_dId,
							templateContent : '<column name="'+cols[i]+'"/>'
						});
					}
					//批量创建列
					xuiDoc.batchCreateComponent(configs, function() {
						self.repaintDataTableds();
					});
				}
				
			});
		},
		repaintDataTableds : function(){
			if(this.isRepainting){
				return;
			}
			var dataID = this.get('data');
			var data = this.getModel().comp(dataID);
			if(!data){
				this.$domNode.html('请设置dataTables的data属性然后增加dataTables列');
				return;
			}
			this.isRepainting = true;
			var xuiNode = xuiDoc.getNodeByDId(this.$domNode.attr('d_id'));
			var self = this;
			//var url = "http://127.0.0.1:8080/x5/UI2/system/components/justep/grid/server/transCfg.j";
			var url = require.toUrl("$UI/system/components/justep/dataTables/server/transDataTablesCfg.j");
			
			$.ajax({
			    async : false,
			    dataType:'json',
			    data: {"define": xuiNode},
			    type : 'POST',
			    url : url, 
			    success : function(cfg) { 
			    	self.createDataTables(cfg,xuiNode); 
			    	self.isRepainting = false;
			    	self.ownerDesigner.setSelection(self.$domNode[0]);
			    },
			    error : function(xhr,status,err) {
			       alert("转换DataTables的定义失败:"+[status,xhr.readyState,err]);
			       self.isRepainting = false;
			    }
			});			
		},
		createDataTables: function(cfg,xuiNode){
			this.cfg = cfg;
			if(!this.cfg.columns||this.cfg.columns.length<1) this.cfg.columns = [{
				"title": '请添加列'
			}];
			//记录原选中组件did
			var dIds = this.ownerDesigner.getSelectionIds();
			
			if(this.__dataTables) this.__dataTables.dispose();
			this.$domNode.empty();
			cfg.parentNode = this.domNode;
			//创建展现的dataTables
			cfg.data = null;
			cfg['class'] = this.$domNode.attr('class');
			cfg['style'] = this.$domNode.attr('style');
			this.__dataTables = new RTDataTables(cfg);
			//分许定义的结构绑定did
			var cols = cfg.columns;
			for(var i=0; i<cols.length; i++){
				//设置设计时的相关属性
				this.__dataTables.$domNode.find('thead tr th:eq('+i+')').attr({"d_id":cols[i]["d_id"],"d_selectable":cols[i]["d_selectable"],"componentName":cols[i]["componentName"]})
				.prop("colDef",cols[i]);
			}
			//bing列头的did
			var $tr = $(xuiNode).find('columns');
			this.columns_dId = $tr.attr("d_id");
			this.$domNode.find('thead tr').attr({"d_id":$tr.attr("d_id"),"d_selectable":false,"componentName":$tr.attr("componentName")});
			//绑定列组件
			this.ownerDesigner.paintChildComponent(this.domNode);
			
			//选中原选中组件
			dIds = eval(dIds);
			if(dIds && dIds.length>0)
				this.ownerDesigner.setSelectionByIds({ids:dIds});
		}
	});
	
	var Column = justep.ViewComponent.extend({
		constructor : function(config) {
			this.callParent(config);
		},
		init : function(value, bindingContext) {

		},
		getOwner: function(){
			var gel = this.$domNode.closest("div[componentName='$UI/system/components/justep/dataTables/dataTables']")[0];
			return this.getModel().comp(gel);
		},
		
		set: function(value){
			var owner = this.getOwner();
			if(owner){
				if(value && value.hasOwnProperty("width")){
					var w = value['width'];
					var colDef = this.$domNode.prop("colDef");
					owner.__grid.setColWidth(colDef['name'],w);
				}else owner.repaintDataTables();
			}
		}
	});
	
	return {
		'$UI/system/components/justep/dataTables/dataTables' : DataTables,
		'$UI/system/components/justep/dataTables/dataTables#column' : Column
	};

});
Exemplo n.º 20
0
define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	var bizService = require("$UI/system/components/designerCommon/js/bizModelService");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	
	var templateMap = {
	
	};
	
	var layoutData;
	var componentName;
	
	var Model = function(){
		this.callParent();
	};
	
	Model.prototype.getCompTemplate = function(compName){
	    return '';
	};
	
	/**获取组件模板***/
	Model.prototype.getCompTemplate = function(compName,appendAttrs){
	   var templateContent = templateMap[compName];
	   if(!templateContent){
	     templateContent =  xuiDoc.getTemplate(compName);
	     templateMap[compName] = templateContent;
	   }
	   if(templateContent){
		   var idx = templateContent.indexOf(">");
		   var idx1 = templateContent.indexOf("/>");
		   if(idx1>0 && idx1<idx){
		      idx = idx1;
		   }
		   if(idx>0){
		      templateContent = templateContent.substring(0,idx)+appendAttrs+templateContent.substring(idx);
		   }
	   }
	   return templateContent;
	}
	
	Model.prototype.addClass = function(templateContent,cls){
		   var idx = templateContent.indexOf(">");
		   var idx1 = templateContent.indexOf("/>");
		   if(idx1>0 && idx1<idx){
		      idx = idx1;
		   }
		   if(idx>0){
		      var str = templateContent.substring(0,idx);
		      var idx2 = str.indexOf(" class");
		      if(idx2>0){
		    	 var idx3 =  templateContent.indexOf('\"',idx2);
		    	 templateContent = templateContent.substring(0,idx3+1)+" "+cls+" "+templateContent.substring(idx3+1);
		      }else{
		    	  templateContent = templateContent.substring(0,idx)+' class="'+cls+'" '+templateContent.substring(idx);
		      }
		   }
	   return templateContent;
	}
		
	
	
	
	/**构建表单布局**/
	Model.prototype.buildFormLayout = function(dataXid/*数据xid*/,rows/*选择的行数据*/,colNumber/*创建的列数*/){
	   layoutData = "";
	   var colSplitMap = {"1":[2,8],"2":[2,4],"3":[2,2],"4":[1,2]};//列数比例映射
	   var buf = [];
	   buf.push('<div class="form-horizontal container-fluid" component="$UI/system/components/bootstrap/form/form">');
	   for(var i = 0,l = rows.length ; i<l ;){
		    buf.push('<div class="form-group">');
		    var colSplitItem = colSplitMap[""+colNumber];
		    for(var j = 0 ; j<colNumber ; j+=1){
		       var row = rows[i++];
		       if(!row){
		          break;
		       }
		       var name = row.val("name");
		     
		       var template = this.getCompTemplate(row.val("compType"),' bind-ref="'+dataXid+'.ref(\''+name+'\')"');
	
			   buf.push('<div class="col-sm-'+colSplitItem[0]+'"><label class="control-label" bind-text="'+dataXid+'.label(\''+name+'\')">'+row.val("label")+'</label> </div>');
			   buf.push('<div class="col-sm-'+colSplitItem[1]+'">'+template+'</div>');
		    }
		    
		    buf.push('</div>');
	   }
	   buf.push('</div>');
	   return buf.join("");
	}
	
	/**构建表格布局**/
	Model.prototype.buildCellLayout = function(dataXid/*数据xid*/,rows/*选择的行数据*/,colNumber/*创建的列数*/){
	   layoutData = "";
	   var layoutContentbuf = [];
	   var controlBuf = [];
	   layoutContentbuf.push('<layout-content xid="default7"><![CDATA[ ');
	   layoutContentbuf.push('<table cellspacing="0" cellpadding="0" rowHeight="22" columnWidth="80" style="border-collapse:collapse;table-layout:fixed;width:1px;">');
	   
	   //创建第一行
	   layoutContentbuf.push('<tr><td/>');
	   for(var j = 0 ; j<colNumber ; j+=1){
	      layoutContentbuf.push('<td style="width: 100px;"/>');
          layoutContentbuf.push('<td style="width: 180px;"/>');
	   }
	   layoutContentbuf.push("</tr>");

	   for(var i = 0,l = rows.length ; i<l ;){
	    	layoutContentbuf.push('<tr><td/>');
		    for(var j = 0 ; j<colNumber ; j+=1){
		       var row = rows[i++];
		       if(!row){
		          break;
		       }
		       var name = row.val("name");
		       var xid1 = "controlLabel_xx"+i;
		       var xid2 = "input_xx"+i;
		       
		        var template = this.getCompTemplate(row.val("compType"),' xid="'+xid2+'"'+' bind-ref="'+dataXid+'.ref(\''+name+'\')"');
		        
		        template = this.addClass(template, "x-cell-control");
		        
		       controlBuf.push('<label xid="'+xid1+'" class="control-label" bind-text="'+dataXid+'.label(\''+name+'\')">'+row.val("label")+'</label>');
		       controlBuf.push(template);
			   
			   layoutContentbuf.push('<td style="width: 100px;"  componentId="'+xid1+'"></td>');
			   layoutContentbuf.push('<td style="width: 180px;"  componentId="'+xid2+'"></td>');
		    }
		    layoutContentbuf.push("</tr>");
	   }
	   
	   layoutContentbuf.push('</table>');
	   layoutContentbuf.push(']]></layout-content>');
	   
	   return '<div class="x-cell-layout" component="$UI/system/components/justep/cellLayout/cellLayout" style="width:100%; height: 100%;">'+layoutContentbuf.join("")+controlBuf.join("")+'</div>';
	}
 
	/**构建Excel布局**/
	Model.prototype.buildExcelLayout = function(rows,colNumber){
	
	}
	
	/**构建绝对布局**/
	Model.prototype.buildAbsoluteLayout = function(dataXid/*数据xid*/,rows/*选择的行数据*/,colNumber/*创建的列数*/){
	   layoutData = "";
 
	   var buf = [];
	   buf.push('<div class="x-absolute-layout" component="$UI/system/components/justep/absoluteLayout/absoluteLayout"  style="width:100%; height: 100%;" >');
	  var offsetTop = 15,colSpace = 40,rowSpace = 50,labelWidth = 120,controlWidth = 160;
	   for(var i = 0,l = rows.length ; i<l ;){
		    var offsetLeft = 15;
		    for(var j = 0 ; j<colNumber ; j+=1){
		       var row = rows[i++];
		       if(!row){
		          break;
		       }
		       var name = row.val("name");
		       var labelStyle = 'style="position:absolute;width:'+labelWidth+'px;left:'+offsetLeft+'px;top:'+(offsetTop+8)+'px;"';
		       offsetLeft = offsetLeft +10 + labelWidth;
		       var controlStyle = ' style="position:absolute;width:'+controlWidth+'px;left:'+offsetLeft+'px;top:'+offsetTop+'px;"';
		       var template = this.getCompTemplate(row.val("compType"),controlStyle+' bind-ref="'+dataXid+'.ref(\''+name+'\')"');
		      
			   buf.push('<label '+labelStyle+' class="control-label" bind-text="'+dataXid+'.label(\''+name+'\')">'+row.val("label")+'</label> ');
			   buf.push(template);
			   
			   offsetLeft =offsetLeft + controlWidth + colSpace;
		    }
		    offsetTop += rowSpace; 
	   }
	   buf.push('</div>');
	   return buf.join("");
	}
	
	/**点确定前调用的处理,做校验**/
	Model.prototype.beforeOkAction = function(){
	   var settingData = this.comp("setting");
	   var dataXid = settingData.val("dataXid");
	   if(!dataXid){
	       return "请选择data";
	   }
	      
	   var rows = [];
	   var relationListData = this.comp("relationList");
		relationListData.each(function(param){
		    var selected = relationListData.getValue("selected",param.row);
		    if(selected){
		      rows.push(param.row);
		    }
		});
	   if(rows.length == 0){
	       return "请选择关系";
	   }
	
	   var layoutType = settingData.val("layoutType");
	   var colNumber = settingData.val("colNumber");
	   	   
	   if(layoutType == 'form'){
	      layoutData = this.buildFormLayout(dataXid,rows, colNumber);
	   }else if(layoutType == 'cellLayout'){
	      layoutData = this.buildCellLayout(dataXid,rows, colNumber);
	   }else if(layoutType == 'absoluteLayout'){
	      layoutData = this.buildAbsoluteLayout(dataXid,rows, colNumber);
	   }
	}
	
	/**
	 * 获取返回值,点击确定后调用的方法,必须是一个json格式的数据 .
	 */
	Model.prototype.getReturnValue = function(){
		return {templateContent:layoutData,componentName:componentName}; 
	};

	Model.prototype.modelLoad = function(event){
	    //获取上下文参数
		this.context = xuiService.getPageParams();
		var data = this.comp("dataList");
		var sNodes = xuiDoc.selectNodes("//*[@component='$UI/system/components/justep/data/bizData' or @component='$UI/system/components/justep/data/data']");
		$(sNodes).each(function(idx){
		   var $this = $(this);  
		   data.add({col0:$this.attr("xid")});
		});
	};

	/** 上移 **/
	Model.prototype.upClick = function(event){

	};

	/** 下移 **/
	Model.prototype.downClick = function(event){

	};

    /** 选择数据 **/
	Model.prototype.select2Change = function(event){
		 var value = event.value;  
		 if(value){
		   var datasource =  xuiDoc.getEditorDataSource("RelationDatasource.getDatasource","xid",value);
		   for(var i = 0;i<datasource.length;i+=1){
		      datasource[i].compType = "$UI/system/components/justep/input/input";
		   }
		  this.comp("relationList").loadData({rows:datasource});
		 }
	};
	
 

	Model.prototype.checkAllChange = function(event){
	   var relationListData = this.comp("relationList");
		relationListData.each(function(param){
			relationListData.setValue("selected",event.value,param.row)
		});
	};
	
 

	return Model;
});
Exemplo n.º 21
0
		init: function(value, bindingContext){
			this.callParent(value,bindingContext);
			this.$rootEle.addClass('x-scroll-view');
			xuiService.getXuiDoc().updateProperties(this.$rootEle);
		},
Exemplo n.º 22
0
define(function(require) {
	var List = require("../list");
	require('css!./css/list').load();
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc(); 
	var ListDesigner = List.extend({
		init : function(value, bindingContext) {
			this.callParent(value, bindingContext);
	        var $domNode = this.$domNode;
			this.$domNode.attr("d_canAddChild", "true").children('div.x-list-head').addClass('x-min-height').attr("d_canAddChild", "true");
			this.$domNode.children('.x-list-content').attr('d_selectable', false);
			this.$domNode.find('.x-list-template').addClass('x-min-height').attr("d_canAddChild", "true").attr(
					'd_selectable', false).children().addClass('x-min-height');
		    
			this.$domNode.on("childChanged",function(event,data){
				if(event.target != $domNode[0]){
					return;
				}
				if(data && data.type == 'styleChanged' && data.attrName =='class'){
					var value = data.value;
					if(value){
						var values = value.split(" ");
						var $template;
						for(var i = 0;i<values.length;i+=1){
							if(values[i] == 'x-cards'){//同步给模板节点加上list-group样式
								$template = $(">.x-list-template",$domNode);
								if($template.length>0){
									if(!$template.hasClass("list-group")){
										$template.addClass("list-group");
										$(">*",$template).addClass("list-group-item");
										xuiDoc.updateNodes($template,null,function(){
											xuiDoc.updateNodes($(">*",$template));											
										});
									}
								}
								return;
							}
						}
						if($domNode.hasClass('x-cards')){
							return;
						}
						$template = $(">.x-list-template",$domNode);
						if($template.length>0){ //同步去掉list-group样式
							$template.removeClass("list-group");
							$(">*",$template).removeClass("list-group-item");
							xuiDoc.updateNodes($template,null,function(){
								xuiDoc.updateNodes($(">*",$template));								
							});
						}
					}
				}	
			});
		},
		addDivTemplate: function(){
			xuiDoc.createComponent("$UI/system/components/justep/list/list#listTemplateDiv", this, {
				paintComponent : true
			});
		},
		addULTemplate: function(){
			xuiDoc.createComponent("$UI/system/components/justep/list/list#listTemplateUl", this, {
				paintComponent : true
			});
		},
		addTableTemplate: function(){
			xuiDoc.createComponent("$UI/system/components/justep/list/list#listTemplateTable", this, {
				paintComponent : true
			});
		}
	});

	return {
		'$UI/system/components/justep/list/list' : ListDesigner
	};
});
Exemplo n.º 23
0
define(function(require) {
	require("$UI/system/components/justep/common/res");
	var Tabs = require("../tabs");
	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc();
	var $ = require("jquery");
	require('css!./css/tabs').load();

	Tabs = Tabs.extend({
		init : function(value, bindingContext) {
			var result = this.callParent(value, bindingContext);
			this._initDesignStatus();
			return result;
		},

		_initDesignStatus : function() {
			$(">.x-panel", this.domNode).attr("d_selectable", "false");
			$(">.x-panel>.x-panel-top", this.domNode).attr("d_selectable", "false");
			$(">.x-panel>.x-panel-top>.nav", this.domNode).attr("d_selectable", "false");
			$(">.x-panel>.x-panel-top>.nav,>.x-panel>.x-panel-content>.x-contents", this.domNode).attr("d_canRemove", "false")
					.attr("d_resizable", "false");
			$(">.x-panel>.x-panel-top>.nav>li", this.domNode).attr("d_canRemove", "false").attr(
					"d_selectable", "false").attr("d_resizable", "false");
			$(">.x-panel>.x-panel-top>.nav>li>a", this.domNode).attr("d_y_resizable", "false");
		},

		set : function(config) {
			for ( var p in config) {
				if (p == 'label') {
					this.domNode.innerHTML = config[p];
					this._doResize();
				} else if (p == 'row-count') {
					this.buildRows(config[p]);
					this.$domNode.attr("row-count", config[p]);
				}
			}
		},

		addTab : function() {
			var self = this;
			var configs = [];
			var xid = xuiDoc.genaXId("tabContent");
			configs.push({
				componentName : "li",
				paintComponent : true,
				parentElementId : $(">.x-panel>.x-panel-top>.nav", this.domNode).attr("d_id"),
				autoSelect : false,
				templateContent : '"<li><a content="' + xid
						+ '">tab1</a></li>"'
			});
			xuiDoc.batchCreateComponent(configs, function() {
				self.setActiveTab($(">.x-panel>.x-panel-top>.nav>li:last", self.domNode));
				self.contents.add();
				self._initDesignStatus();
				self._doResize();
			});
		}
	});

	var TabItem = function(config) {
		this.domNode = this.templateNode = config.templateNode;
		this.domNode.setAttribute("tabindex", '0');
	};

	TabItem.prototype = {
		onRemove : function(event) {
			if ($("li", this.domNode.parentNode.parentNode).length == 1) {
				event.cancel = true;
			} else {
				event.cancel = true;
				var $domNode = $(this.domNode);
				var index = $domNode.parent().index();
				var tabs = this.ownerDesigner.getOwnerComponent(this.domNode.parentNode, '$UI/system/components/justep/tabs/tabs');
				var contentDId = tabs.contents.contents[index].$domNode.attr('d_id'); 
				xuiDoc.deleteComponent([ contentDId,
					$domNode.parent().attr("d_id") ]);
				tabs.contents.remove(index);
				window.setTimeout(function(){
					tabs._doResize();
				}, 10);
			}
		},
		set : function(config) {
			for ( var p in config) {
				if (p == 'label') {
					this.domNode.innerHTML = config[p];
				} else if (p == 'content') {
					this.domNode.setAttribute("content", config[p]);
				}
			}
		}
	};

	return {
		'$UI/system/components/justep/tabs/tabs' : Tabs,
		'$UI/system/components/justep/tabs/tabs#tabItem' : TabItem
	};

});
Exemplo n.º 24
0
		addTop: function(){
			var id = this.$content.attr('d_id'), me = this;
			xuiService.getXuiDoc().createComponent("$UI/system/components/justep/panel/panel#top", this, {before:id, paintComponent:true}, function(){
        		$('>.x-panel-content', me.$domNode).css('top', $('>.x-panel-top', me.$domNode).height());
			});
		},
Exemplo n.º 25
0
define(function(require) {
	var Picker = require("../picker");
	var PopPicker = require("../popPicker");
	require('css!./css/popPicker').load();

	var xuiService = require("$UI/system/components/designerCommon/js/xuiService");
	var xuiDoc = xuiService.getXuiDoc(); 
	var PickerDesigner = Picker.extend({
		init : function(value, bindingContext) {
			this.callParent(value, bindingContext);
	        //var $domNode = this.$domNode;
		}
	});

	function create(comp, clz) {
		var $domNode = $(comp.domNode);
		comp.domNode.style.position = "absolute";
		if (!comp.domNode.style.top) {
			comp.domNode.style.top = "10px";
			comp.domNode.style.left = "10px";
		}
		$domNode.addClass(clz).children().hide();
		$('.x-popPicker-overlay',$domNode).attr("d_canRemove",false);
		$('.x-popPicker-content',$domNode).attr("d_canRemove",false);
		$('.x-poppicker-header',$domNode).attr("d_canRemove",false);
		$domNode.on("childChanged",function(event, data){
			if(data.type=='remove' && $(data.target).hasClass("x-picker")){
				setTimeout(function(){comp.updatePickerClass();},1);
			}
		});
	}
	
	var PopPickerDesigner = PopPicker.extend({
		init : function(value, bindingContext) {
			create(this, 'x-designer-popPicker');
			this.callParent(value, bindingContext);
		},
		updatePickerClass: function(){
	    	var self = this;
			var pickers = self.getInnerPickers();
	    	if($.isArray(pickers)){
	    		var size = pickers.length;
	    		$.each(pickers,function(i,picker){
	    			for(var j=1;j<=size;j++){
	    				picker.$domNode.removeClass('x-picker-'+j);
	    			}
	    			if(size>1){
	    				picker.$domNode.addClass('x-picker-'+size);
	    				xuiDoc.updateProperties(picker.$domNode,['class']);
	    			}
	    		});
	    	}
		},
		addPicker : function(){
		    var templateText = xuiDoc.getTemplate('$UI/system/components/justep/picker/picker');
		    var pId = $('.x-popPicker-content',this.$domNode).attr("d_id");
		    var paintComponent = false;
		    var self = this;
		    
		    xuiDoc.createComponent('$UI/system/components/justep/picker/picker',pId,{paintComponent:paintComponent,templateContent:templateText},function(node){
		    	self.updatePickerClass();
		    });
		}
	});

	return {
		'$UI/system/components/justep/picker/picker' : PickerDesigner,
		'$UI/system/components/justep/picker/popPicker' : PopPickerDesigner
	};
});
Exemplo n.º 26
0
		dispose : function() {
			this.$rootEle.removeClass('x-scroll-view');
			xuiService.getXuiDoc().updateProperties(this.$rootEle);
        	this.callParent();
    	},