Button_wev8.js 19.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
if(typeof(MEC_NS) == 'undefined'){
	MEC_NS = {};
}

MEC_NS.Button = function(type, id, mecJson){
	this.type = type;
	if(!id){
		id = new UUID().toString();
	}
	this.id = id;
	if(!mecJson){
		mecJson = this.getDefaultMecJson();
	}
	this.mecJson = mecJson;
	
};

/*获取id。 必需的方法*/
MEC_NS.Button.prototype.getID = function(){
	return this.id;
};

MEC_NS.Button.prototype.runWhenPageOnLoad = function(){
    this.afterDesignHtmlBuild(true);
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.Button.prototype.getDesignHtml = function(){
	return getDesignHtml(this);
};

MEC_NS.Button.prototype.afterDesignHtmlBuild = function(){
    var theId = this.id;
    var isFixedBottom = this.mecJson["isFixedBottom"] || '0';
    if(isFixedBottom == "1"){
        if(!Mec_IsInBottomContainer(theId)){
            Mec_MoveContentFromEditorToBorder(theId);
        }
    }else{
        if(Mec_IsInBottomContainer(theId)){
            Mec_MoveContentFromBorderToEditor(theId);
        }
    }
};

/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.Button.prototype.getAttrDlgHtml = function(){
	var theId = this.id;
	var htm = "<div id=\"MADButton_" + theId + "\">" //单击右上角的添加按钮以添加内容
				+ "<div class=\"title\">"+SystemEnv.getHtmlNoteName(4650)+"<div class=\"add-before\" data-autobind data-scroll=\"bottom\" onclick=\"MADButton_AddOne('"+theId+"')\">"+SystemEnv.getHtmlNoteName(3518)+"</div></div>"
				+ "<div class=\"form-group\">"
					+ "<div class=\"row\">"
						+ "<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(4481)+"</span>"  //按钮布局:
						+ "<div class=\"col-8 multi-checkbox\">"
							+ "<span class=\"cbboxEntry\">"
								+ "<input type=\"checkbox\" name=\"rightActionType_"+theId+"\" value=\"1\" onclick=\"MADButton_ChangeRAT(this, '"+theId+"');\">"
								+ "<span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4482)+"</span>"	//固定
							+ "</span>"	
							+ "<span class=\"cbboxEntry\">"
								+ "<input type=\"checkbox\" name=\"rightActionType_"+theId+"\" value=\"2\" onclick=\"MADButton_ChangeRAT(this, '"+theId+"');\">"
								+ "<span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4483)+"</span>" //自适应
							+ "</span>"	
						+ "</div>"
					+ "</div>"
					
					+ "<div class=\"row\">"
						+ "<div class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5022)+"</div>" //固定底部:
						+ "<div class=\"col-m-8\">"
							+ "<input type=\"checkbox\" id=\"isFixedBottom_"+theId+"\"  value=\"1\"/>"
							+ "<span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(5023)+"</span>"	//显示时固定在页面底部
						+ "</div>"
					+ "</div>"
				+ "</div>"
				
				//+ "<div class=\"title\">"+SystemEnv.getHtmlNoteName(5067)+"</div>"
				+ "<div class=\"form-group MADButton_Content\">"
					+ "<table class=\"table\" style=\"margin:0\">"  
						+ "<thead>"
						+ "<tr>"
						+ "<td style=\"width:20px;\"></td>"
						+ "<td style=\"width:calc(100% - 160px);\">"+SystemEnv.getHtmlNoteName(4141)+"</td>" //名称
						+ "<td style=\"width:62px;\">"+SystemEnv.getHtmlNoteName(5477)+"</td>"//宽度占比
						+ "<td style=\"width:50px;\">"+SystemEnv.getHtmlNoteName(3763)+"</td>"//背景色
						+ "<td style=\"width:35px;\">"+SystemEnv.getHtmlNoteName(4634)+"</td>" //脚本
						+ "</tr>"
						+ "</thead>"
					+"</table>" 
					+ "<div class=\"tip-control button_empty_tip\">"+SystemEnv.getHtmlNoteName(4159)+"</div>"  //单击右上角的添加按钮以添加内容
					+ "<ul class=\"normal-list button_ul_root\">"
					+ "</ul>"
				+ "</div>"
			
				+ "<div class=\"bottom\"><div class=\"save-btn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>"  //确定
			+ "</div>"
			+ "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>";  //已生成到布局
	return htm;
};

/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Button.prototype.afterAttrDlgBuild = function(){
	var theId = this.id;
	var $attrContainer = $("#MADButton_" + theId);
	var mecHandler = MECHandlerPool.getHandler(theId);
	
	var isFixedBottom = this.mecJson["isFixedBottom"];
	if(isFixedBottom == "1"){
		$("#isFixedBottom_"+theId).checked();
	}
	
	var button_datas = this.mecJson["button_datas"];
	if(button_datas.length == 0){
		$(".button_empty_tip", $attrContainer).show();
	}
	for(var i = 0; i < button_datas.length; i++){
		MADBUTTON_AddButtonEntryToPage(theId, button_datas[i]);
	}
	
	var rightActionTypeV = this.mecJson["rightActionType"];
	var $rightActionType = $("input[type='checkbox'][name='rightActionType_" + theId + "'][value='" + rightActionTypeV + "']");
	if($rightActionType.length > 0){
		$rightActionType.checked();
	}
	
	$("#MADButton_" + theId).checkbox({
		onClick: function () { 
			mecHandler.autobind && mecHandler.autobind.update();
		}
	});//调用表单插件
	$("#MADButton_" + theId + " .MADButton_Content > ul").sortable({
		revert: false,
		axis: "y",
		items: "li",
		handle: ".bemove",
		update: function(){
			mecHandler.autobind.update();
		}
	});
};

/*获取JSON*/
MEC_NS.Button.prototype.getMecJson = function(){
	var theId = this.id;
	var $attrContainer = $("#MADButton_" + theId);
	this.mecJson["id"] = theId;
	this.mecJson["mectype"]= this.type;
	//获取按钮布局设置值
	var $rightAction = $("input[type='checkbox'][name='rightActionType_"+theId+"']:checked");
	if($rightAction.length > 0){
		var rightActionType = $rightAction.val();
		this.mecJson["rightActionType"] = rightActionType;
	}
	if($attrContainer.length > 0){
		var button_datas = this.mecJson["button_datas"];
		
		this.mecJson["isFixedBottom"] = $("#isFixedBottom_"+theId).is(":checked") ? "1" : "0";
		
		for(var i = 0; i < button_datas.length; i++){
			var button_data = button_datas[i];
			var rowId = button_data["id"];
			button_data["btn_width"] = $("#btnWidthInput_"+rowId).val();
			//button_data["btn_style"] = $("#btn_style_"+rowId).attr('btn-style');
			button_data["isfillbgcolor"] = $("#btn_isfillbgcolor_"+rowId).is(':checked') ? "1" : "0";
			button_data["isremind"] = $("#remindcBox_"+rowId).is(':checked') ? "1" : "0";
			button_data["icon_type"] = $("#icon_type_"+rowId).val();
			button_data["icon_style"] = $("#icon_style_"+rowId).val();
			button_data["icon_path"] = $("#icon_path_"+rowId).val();
			button_data["buttonName"] = MLanguage.getValue($("#btnNameInput_"+rowId));
			button_data["script"] = $("#btnScript_"+rowId).val();
			var $iconPosition = $("input[type='checkbox'][name='iconPosition_"+button_data["id"]+"']:checked");
			if($iconPosition.length > 0){
				button_data["icon_position"] = $iconPosition.val();
			}else{
				button_data["icon_position"] = "1";
			}
		}

		var datasTemp = [];
		$(".MADButton_Content > ul > li", $attrContainer).each(function(i){
			var liId = $(this).attr("id").substring(12);//buttonEntry_CE。。。。。AB
			for(var i = 0; i < button_datas.length; i++){
				var button_data = button_datas[i];
				if(liId == button_data["id"]){
					datasTemp.push(button_data);
				}
			}
		});
		this.mecJson["button_datas"] = datasTemp;
		
	}
	
	return this.mecJson;
};

MEC_NS.Button.prototype.getCopyMecJson = function (mecJson) {
	var mec = require("mec");

	mec.changeMecJsonUUid(mecJson.button_datas);
};

MEC_NS.Button.prototype.getDefaultMecJson = function(){
	return {
		id: this.id,
		mectype: this.type,
		rightActionType: 2,
		button_datas: [{
			id: new UUID().toString(),
			isfillbgcolor:"1",
			buttonName: SystemEnv.getHtmlNoteName(4635) // 按钮
		}]
	};
};

function MADButton_AddOne(mec_id){
	var id = new UUID().toString();
	var mecHandler = MECHandlerPool.getHandler(mec_id);
	var button_datas = mecHandler.mecJson["button_datas"];
	var result = { id: id };
	var len = button_datas.push(result);

	MADBUTTON_AddButtonEntryToPage(mec_id, result);
	$("#btnNameInput_" + id).focus();
}

function MADBUTTON_AddButtonEntryToPage(mec_id, result){
	var $attrContainer = $("#MADButton_" + mec_id);
	$(".button_empty_tip", $attrContainer).hide();
	var id = result["id"];
	var buttonName = result["buttonName"] || "";
	var className = result["className"];
	var script = result["script"] || "";
	var style = result["style"];
	
	var isremind = result["isremind"] == undefined ? "0" : result["isremind"];
	var remindtype = result["remindtype"] == undefined ? "" : result["remindtype"];
	var remindsql = result["remindsql"] || "";
	var reminddatasource = result["reminddatasource"] == undefined ? "" : result["reminddatasource"];
	var remindjavafilename = result["remindjavafilename"] == undefined ? "" : result["remindjavafilename"];
	
	var icon_type = result["icon_type"] == undefined ? "" : result["icon_type"];
	var icon_style = result["icon_style"] == undefined ? "" : result["icon_style"];
	var icon_path = result["icon_path"] == undefined ? "" : result["icon_path"];
	var icon_position = result["icon_position"] == undefined ? "1" : result["icon_position"];
	
	var btn_width = result["btn_width"];

	var btn_isfillbgcolor = result["isfillbgcolor"] === undefined ? "1" :result["isfillbgcolor"];

	var $buttonEntry = $("<li id=\"buttonEntry_" + id + "\" style=\"padding-bottom: 0;\"></li>");
	$buttonEntry.html(
		  "<div class=\"button_table_wrap\">"
			+ "<table class='table' style='margin:0'>"
				+ "<tr>"
					+ "<td class=\"bemove\" width=\"20px\"></td>"
					+ "<td width=\"calc(100% - 160px)\">"
						+ 	"<input type='text' class=\"form-control\" style='width:calc(100% - 1px)' data-autobind placeholder='"+SystemEnv.getHtmlNoteName(4177)+"' class='form-control' id='btnNameInput_" + id + "' "+MLanguage.ATTR+"/>"
					+ "</td>"
					+ "<td width=\"50px;\" >"
						+ 	"<input  class=\"form-control button_dis_buttonWidth\" data-autobind type='number' min='1' max='5' oninput='if(this.value > 5)this.value=5;if(this.value<1)this.value=1' style='width:50px;'  id='btnWidthInput_" + id + "' />"
					+ "</td>"
					+ "<td width=\"50px;\" style=\"padding-left:18px\">"
						+ "<input  type=\"checkbox\" value=\"1\"" +  (btn_isfillbgcolor == "1"?"checked":"")  +" data-autobind id=\"btn_isfillbgcolor_"+id+"\"/>"
					+ "</td>"
					+ "<td width=\"25px\" style=\"position:relative;\">"
						+ "<div class='click-control active' style='border:0;height: 29px' onclick='MADBUTTON_ClickScript(this)'>"
						+	"<input name='btnScript' id='btnScript_"+ id +"' type='hidden' />"
						+ "</div>"
						+ "<span class='del-before delFlag' style='right: 10px;' onclick=\"MADButton_DeleteButtonEntry('" + mec_id + "', '" + id + "')\"></span>"
					+ "</td>"
					+ "<td width=\"40px\" style=\"position: relative;display:none;\">"
						+ "<span><input type=\"checkbox\" id=\"remindcBox_"+id+"\" value=\"1\" onclick=\"MADBUTTON_IsremindChange('"+id+"');\"></span>"
						+ "<span id=\"numremindEditFlag_"+id+"\" class=\"numremindEditFlag\" onclick=\"MADBUTTON_NumremindEdit('"+id+"', '"+mec_id+"');\" style=\"display:none;\"></span>"
						+ "<input type=\"hidden\" id=\"remindtype_"+id+"\" value=\""+remindtype+"\"/>"
						+ "<input type=\"hidden\" id=\"remindsql_"+id+"\" value=\""+remindsql+"\"/>"
						+ "<input type=\"hidden\" id=\"reminddatasource_"+id+"\" value=\""+reminddatasource+"\"/>"
						+ "<input type=\"hidden\" id=\"remindjavafilename_"+id+"\" value=\""+remindjavafilename+"\"/>"
					+ "</td>"
					+ "<td width=\"95px\" style=\"position:relative;display:none;\">"
						+ "<div class=\"button_dis_icon inline\" title=\""+SystemEnv.getHtmlNoteName(4486)+"\" onclick=\"MADBUTTON_IconSet('"+id+"', '"+mec_id+"')\">"  //点击修改图片
							+ "<img id=\"buttonIcon_"+id+"\" class=\"btn-icon-img\" src=\"/mobilemode/images/mec/add-img-btn_wev8.png\">"
							+ "<input type=\"hidden\" id=\"icon_type_"+id+"\" value=\""+icon_type+"\"/>"
							+ "<input type=\"hidden\" id=\"icon_style_"+id+"\" value=\""+icon_style+"\"/>"
							+ "<input type=\"hidden\" id=\"icon_path_"+id+"\" value=\""+icon_path+"\"/>"
						+ "</div>"
						+ "<div class=\"del-before icon-img-del\" title=\""+SystemEnv.getHtmlNoteName(4487)+"\"></div>"  //删除图标
						//+ "<div class='del-before delFlag' style='top:3px' onclick=\"MADButton_DeleteButtonEntry('" + mec_id + "', '" + id + "')\"></div>"
						+ "<span id='btnIconPos_"+id+"' style='position: relative;top: -1px;' class='multi-checkbox'>"
							+ "<span><input type=\"checkbox\" name=\"iconPosition_"+id+"\" value=\"1\" onclick=\"MADBUTTON_IsIconPositionChange(this, '"+id+"')\"/>"
							+ "<span>"+SystemEnv.getHtmlNoteName(4488)+"</span></span>"  //左
							+ "<span><input type=\"checkbox\" name=\"iconPosition_"+id+"\" value=\"2\" onclick=\"MADBUTTON_IsIconPositionChange(this, '"+id+"')\"/>"
							+ "<span>"+SystemEnv.getHtmlNoteName(4489)+"</span></span>"  //右
						+ "</span>"
					+ "</td>"
				+ "</tr>"
			+ "</table>"
		+ "</div>"
	);
	$(".button_ul_root", $attrContainer).append($buttonEntry);
	MLanguage.setValue($("#btnNameInput_" + id), buttonName);
	
	SL_ChangeStyle($("#btnScript_"+id).parent(), script);
	if(isremind == "1"){
		$("#remindcBox_"+id).checked();
	}
	$("#btnScript_"+id).val(script);
	$("#btnWidthInput_"+id).val(btn_width);
	if(btn_isfillbgcolor == "1"){
		$("#btn_isfillbgcolor_"+id).checked();
	}
	//$("#btn_style_"+id).val(btn_style).attr('btn-style',btn_style).text(btn_style.replace('btn-outline-','').replace('btn-','')).removeClass().addClass('style_picker_btn').addClass(btn_style);

	MADBUTTON_ChangeIconPosition(id, icon_position);
	MADBUTTON_SetIconPath(id, icon_path);
	MADBUTTON_ToggleIconPosition(id, icon_path);
	$buttonEntry.hover(function(){
		if($("#icon_path_"+id).val() != ""){
			$(".icon-img-del", $(this)).bind("click", function(){
				$("#icon_type_"+id).val("");
				$("#icon_style_"+id).val("");
				$("#icon_path_"+id).val("");
				MADBUTTON_SetIconPath(id, "");
				MADBUTTON_ChangeIconPosition(id, "1");
				MADBUTTON_ToggleIconPosition(id, false);
				$(this).hide();
			}).show();
		}
	}, function(){
		$(".icon-img-del", $(this)).unbind("click").hide();
	});

	$buttonEntry.checkbox().MLanguage();
	MADBUTTON_BtnWidthSetEnable(mec_id,$buttonEntry);
}



function MADBUTTON_BtnWidthSetEnable(mecid){
	var $panel = $("#MADButton_" + mecid);
	var rightActionType = $("input[type='checkbox'][name='rightActionType_" + mecid + "']:checked").val();
	$('.button_dis_buttonWidth',$panel).attr('disabled',rightActionType != 2);
}


function MADBUTTON_ClickScript(ele) {
	var $el = $(ele),
		$input = $el.find("input");

	SL_AddScriptToField($input);
}

function MADBUTTON_ChangeIconPosition(rowId, value){
	var $icon_position = $("input[type='checkbox'][name='iconPosition_" + rowId + "'][value='"+value+"']");
	if($icon_position.length > 0){
		$icon_position.checked();
	}
}

function MADBUTTON_ToggleIconPosition(rowId, picpath) {
	// $("#btnIconPos_"+rowId).toggleClass("inline", !!picpath);
	$("#btnIconPos_"+rowId).toggle(!!picpath);
}

function MADBUTTON_IconSet(rowId, mec_id){
	
	var pic_typeV = $("#icon_type_"+rowId).val() == "" ? "0" : $("#icon_type_"+rowId).val();
	var pic_styleV = $("#icon_style_"+rowId).val() == "" ? "1" : $("#icon_style_"+rowId).val();
	var pic_pathV = $("#icon_path_"+rowId).val();
	var params = "pic_type=" + pic_typeV + "&pic_style=" + pic_styleV + "&pic_path=" + encodeURIComponent(pic_pathV);

	showPicsetModal(params, function(result){
		var picPath = result["pic_path"];
		
		$("#icon_type_"+rowId).val(result["pic_type"]);
		$("#icon_style_"+rowId).val(result["pic_style"]);
		$("#icon_path_"+rowId).val(picPath);
		
		MADBUTTON_SetIconPath(rowId, picPath);
		MADBUTTON_ToggleIconPosition(rowId, picPath)
	});
};
function MADBUTTON_SetIconPath(rowId, picPath){
	var $IconImg = $("#buttonIcon_"+rowId);
	if(picPath && picPath != ""){
		$IconImg[0].src = picPath;
	}else{
		$IconImg[0].src = "/mobilemode/images/mec/add-img-btn_wev8.png";
	}
}

function MADBUTTON_IsremindChange(rowId){
	setTimeout(function(){	//checkbox用了插件,不延时checkbox的checked状态获取不准确
		var $numremindEditFlag = $("#numremindEditFlag_"+rowId);
		$("#remindcBox_"+rowId).is(':checked') ? $numremindEditFlag.css("display", "inline-block") : $numremindEditFlag.css("display", "none");
	},100);
}

function MADBUTTON_NumremindEdit(rowId, mecId){
	var mecHandler = MECHandlerPool.getHandler(mecId);
	if(mecHandler == null) return;
	var button_datas = mecHandler.mecJson["button_datas"];
	var button_data = null;
	for(var i = 0; i < button_datas.length; i++){
		var data = button_datas[i];
		if(data["id"] == rowId){
			button_data = data;
			break;
		}
	}
	if(button_data == null) return;
	var remindtypeV = $("#remindtype_"+rowId).val();
	
	var remindsqlV = $("#remindsql_"+rowId).val();
	remindsqlV = $m_encrypt(remindsqlV);
	
	var reminddatasourceV = $("#reminddatasource_"+rowId).val();
	var remindjavafilenameV = $("#remindjavafilename_"+rowId).val();
	
	var url = "/mobilemode/admin/dialog/numremind.jsp?remindtype="+remindtypeV+"&reminddatasource="+reminddatasourceV+"&remindsql="+remindsqlV+"&remindjavafilename="+remindjavafilenameV;
	
	var dlg = top.createTopDialog();//获取Dialog对象
	dlg.Model = true;
	dlg.normalDialog = false;
	dlg.Width = 500;//定义长度
	dlg.Height = 255;
	dlg.URL = url;
	dlg.Title = SystemEnv.getHtmlNoteName(4116)  //数字提醒;
	dlg.show();
	dlg.hookFn = function(result){
		result = result || {};

		var newValue = {
			isremind: $("#remindcBox_"+rowId).is(':checked') ? "1" : "0",
			remindtype: $("#remindtype_"+rowId).val(result["remindtype"]).val(),
			remindsql: $("#remindsql_"+rowId).val(result["remindsql"]).val(),
			reminddatasource: $("#reminddatasource_"+rowId).val(result["reminddatasource"]).val(),
			remindjavafilename: $("#remindjavafilename_"+rowId).val(result["remindjavafilename"]).val()
		};

		$.extend(button_data, newValue);
	};
};

function MADButton_DeleteButtonData(mec_id, id){
	var mecHandler = MECHandlerPool.getHandler(mec_id);
	var button_datas = mecHandler.mecJson["button_datas"];
	var index = -1;
	for(var i = 0; i < button_datas.length; i++){
		var data = button_datas[i];
		if(data["id"] == id){
			index = i;
			break;
		}
	}
	if(index != -1){
		button_datas.splice(index, 1);
	}
}

function MADButton_DeleteButtonEntry(mec_id, id){
	var mecHandler = MECHandlerPool.getHandler(mec_id);

	MADButton_DeleteButtonData(mec_id, id);
	var $attrContainer = $("#MADButton_" + mec_id);
	$("#buttonEntry_" + id, $attrContainer).remove();
	var mecHandler = MECHandlerPool.getHandler(mec_id);
	var button_datas = mecHandler.mecJson["button_datas"];
	if(button_datas.length == 0){
		$(".button_empty_tip", $attrContainer).show();
	}	
	mecHandler.autobind.update();
}

function MADButton_ChangeRAT(cbObj, mec_id){
	setTimeout(function(){
		var objV = cbObj.value;
		if(!cbObj.checked){
			changeCheckboxStatus(cbObj, true);
		}else{
			$("input[type='checkbox'][name='rightActionType_" + mec_id + "']").each(function(){
				if(this.value != objV){
					changeCheckboxStatus(this, false);
				}
			});
		}
		MADBUTTON_BtnWidthSetEnable(mec_id);
	}, 100);
}

function MADBUTTON_IsIconPositionChange(cbObj, rowId){
	setTimeout(function(){
		var objV = cbObj.value;
		if(!cbObj.checked){
			changeCheckboxStatus(cbObj, true);
		}else{
			$("input[type='checkbox'][name='iconPosition_" + rowId + "']").each(function(){
				if(this.value != objV){
					changeCheckboxStatus(this, false);
				}
			});
		}
	}, 100);
}