ck2uk_wev8.js 30.9 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 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
function getUEInstance (editorid) {
	return UE.getEditor(editorid);
}
var CkeditorExt = {
	NO_IMAGE : 1,
	//获取content
	getHtml : function (editorid) {
		return getUEInstance(editorid).getContent();
	},
	//获取content(不包含html)
	getText : function (editorid) {
		var __contentText = getUEInstance(editorid).getContentTxt();
		if (__contentText != "") {
			return __contentText;
		}

		var _html = getUEInstance(editorid).getContent()
		if (_html.indexOf("<img src=") != -1) {
			return _html;
		}
		return __contentText;
	},
	//设置html
	setHtml : function (html, editorid) {
		getUEInstance(editorid).setContent(html);
	},
	getTextNew : function (editorid) {
		return CkeditorExt.getText(editorid);
	},
	editorName : [], 
	initEditor : function (formid, editorid, languageid, type, height) {
		return UEUtil.initEditor(editorid);
	},
	checkText : function (arg0, editorid) {
		UEUtil.checkRequired(editorid);
	},
	initParse : function (formid, editorid, languageid, type, height) {
		return UEUtil.initParse(editorid);
	},
	updateContent : function (editorid) {
		for(var key in UE.instants){
			try {
				var _ue = UE.instants[key];
				var _html = _ue.getContent();
				_html = _html.replace(/<p><br\/><\/p>/,"").replace(/&nbsp;/,""); 
				_html = _html.replace(/<p>/g, "<p style=\"font-family:'微软雅黑','Microsoft YaHei';font-size:12px;\">");
			    _ue.setContent(_html);
				_ue.sync();
			} catch (_e98) {}
		}
	}, 
	toolbarExpand : function () {}
};

var FCKEditorExt = CkeditorExt;

var UEUtil = {
	initEditor : function (editorid, objparam, width) {
		try {
			var editortgt = jQuery("textarea[name=" + editorid + "]")[0];
			var h = parseInt(editortgt.getAttribute("rows"));
			jQuery(editortgt).css("height", h*30 + "px");
			jQuery(editortgt).css("margin", "5px 5px");
		} catch (e9) {alert(e9);}
		if (window.__ueditready == undefined) {
			 window.__ueditready = 1;
		} else {
			window.__ueditready++;
		}
		if (!!!objparam) {
			objparam = {
				autoFloatEnabled:false,//不保持工具栏位置
				toolbars: [[
		            'fullscreen', 'source', '|',
		            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|', 
		            'fontfamily', 'fontsize', 'forecolor', 'backcolor','|', 
		            'insertorderedlist', 'insertunorderedlist',
		            'lineheight', 'indent','paragraph', '|',
		            'justifyleft', 'justifycenter', 'justifyright', '|',
		            'insertimage', 'inserttable', '|',
		            'link', 'unlink', 'anchor', '|', 
		            'map', 'insertframe', 'background', 'horizontal',  'spechars', '|',
		            'removeformat', 'formatmatch','pasteplain', '|',
		            'undo', 'redo', '|', 
		        ]], initialStyle : "p{font-family:Microsoft YaHei; font-size:12px;}"
			};
		}	
		var _ue = UE.getEditor(editorid, objparam);
		//只有必填的字段才去绑定事件
			this.bindEvent(editorid);
		jQuery("div#" + editorid).css("width", "");
		jQuery("div#" + editorid).children("div .edui-default").css("width", "");
		
		_ue.addListener('ready', function(){
			try {
				__insertimage(_ue, "insertimage");
			} catch(e_i) {}
			window.__ueditready--;
			if (window.__ueditready == 0) {
				window.__htmlhasuedit = false;
			}
		});
		return _ue;
	},
	initHtmlEditor : function (editorid, objparam, width) {
		try {
			var editortgt = jQuery("textarea[name=" + editorid + "]")[0];
			var h = parseInt(editortgt.getAttribute("rows"));
			jQuery(editortgt).css("height", h*30 + "px");
		} catch (e9) {alert(e9);}
		
		if (!!!objparam) {
			objparam = {
				autoFloatEnabled:false,//不保持工具栏位置
				toolbars: [[
		            'fullscreen', 'source', '|',
		            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|', 
		            'fontfamily', 'fontsize', 'forecolor', 'backcolor','|', 
		            'insertorderedlist', 'insertunorderedlist',
		            'lineheight', 'indent','paragraph', '|',
		            ,'justifyleft', 'justifycenter', 'justifyright', '|',
		            'link', 'unlink', 'anchor', '|', 
		            'insertimage', 'map', 'insertframe', 'background', 'horizontal',  'spechars', '|',
		            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol','|',
		            'removeformat', 'formatmatch','pasteplain', '|',
		            'undo', 'redo', '|'
		        ]], initialStyle : "p{font-family:Microsoft YaHei; font-size:12px;}"
			};
		}	
		var _ue = UE.getEditor(editorid, objparam);
			this.bindEvent(editorid);
		jQuery("div#" + editorid).css("width", "");
		jQuery("div#" + editorid).children("div .edui-default").css("width", "");
		
		_ue.addListener('ready', function(){
			try {
				__insertimage(_ue, "insertimage");
			} catch(e_i) {}
		});
		
		return _ue;
	},
	bindEvent : function (editorid) {
		var _ue = getUEInstance(editorid);
        _ue.addListener('contentChange', function(){
        	var editortgt = jQuery("textarea[name=" + editorid + "]")[0];
        	if(editortgt.getAttribute("viewtype") == "1"){
		   		UEUtil.checkRequired(editorid);
        	}
		});
	},
	initRemark : function (editorid) {
		//转发页面特殊处理
		if (window.__isremarkPage == true) {
			jQuery("#"+editorid).css("height", "170px");
		}
		var _ue = UE.getEditor(editorid, {
			 autoFloatEnabled:false,//不保持工具栏位置
			 allowDivTransToP:false,//不把div自动转为p
			 disabledTableInTable:false,//允许table嵌套
			 autoHeightEnabled : (window.__isremarkPage == true ? false : true),
       		 toolbars: [[
	            'fullscreen', 'source', '|',
	            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|', 
	            'fontfamily', 'fontsize', 'forecolor', 'backcolor','|', 
	            'insertorderedlist', 'insertunorderedlist','indent', '|',
	            ,'justifyleft', 'justifycenter', 'justifyright', '|',
	            'link', 'unlink', 'insertimage', 'inserttable', '|',  'undo', 'redo','|'
	        ]], theme : "metro", initialStyle : "p{font-family:Microsoft YaHei; font-size:12px;}"
       	});
       	this.bindEvent(editorid);
       	_ue.addListener('ready', function(){
			try {
				__insertimage(_ue, "insertimage");
				var fieldannexuploadname = jQuery("#field-annexupload-name").val();
				if(fieldannexuploadname == "" || fieldannexuploadname == null){
					__fileupload(_ue, "wfannexbutton");
				}
				jQuery(".edui-for-wfphrasebutton").children("div").children("div").children("div").children(".edui-label").html("<span style='cursor:pointer;line-height:20px;color:#949292!important;'>"+SystemEnv.getHtmlNoteName(3998)+"</span>");
				var fieldannexuploadcount = jQuery("#field-annexupload-count").val();
				
				if( fieldannexuploadcount > 0)
				{
					try {
			   			var _targetobj = jQuery(".edui-for-wfannexbutton").children("div").children("div").children("div").children(".edui-metro");
			        	if (document.getElementById("field-annexupload").value != '') {
			        		_targetobj.addClass("wfres_1_slt");
			        		_targetobj.removeClass("wfres_1");
			        	} else {
			        		_targetobj.addClass("wfres_1");
			        		_targetobj.removeClass("wfres_1_slt");
			        	}
			        } catch (e) {}
			        jQuery("#fsUploadProgressfileuploaddiv").attr("banfold","0");
				}
				
				
			} catch (e_4) {}
			window._isremarkcomp = true;
		});
       	_ue.addListener('selectionchange', function(){
       		try {
	        	if (jQuery("#_signinputphraseblock").is(":visible")) {
					jQuery("#_signinputphraseblock").hide();
					jQuery("#_addPhrasebtn").show()
					jQuery("#cg_splitline").show();
					jQuery("#addphraseblock").hide();
				}
	        	var showfor = jQuery("#_fileuploadphraseblock").attr("showfor");
	        	var banfold = jQuery("#fsUploadProgressfileuploaddiv").attr("banfold");
	        	var _filetop = jQuery("#_fileuploadphraseblock").offset().top;
	        	if (_filetop > 0 && showfor != "1" && banfold != "1") {
	        		jQuery("#_fileuploadphraseblock").css("top","-500px");
	        		jQuery("#fsUploadProgressfileuploaddiv").css("top","-500px");
				}else{
					jQuery("#_fileuploadphraseblock").attr("showfor","0");
				}
			} catch (e45) {
			}
		});
       	
       	return _ue;
	},
	checkRequired : function (editorid){
		try {
			var sImg='<img src="/images/BacoError_wev8.gif" align="absMiddle">'; 
			var editortgt = jQuery("textarea[name=" + editorid + "]")[0];
			if(editortgt.getAttribute("viewtype")=="1"){
				var html = getUEInstance(editorid).getContent();
				if(jQuery.trim(html) == "") {
					if ($G(editorid + "span")) {
						$G(editorid + "span").innerHTML = sImg;
					} else {
						$G(editorid + "Span").innerHTML = sImg;
					}
				} else {
					if ($G(editorid + "span")) {
						$G(editorid + "span").innerHTML = "";
					} else {
						$G(editorid + "Span").innerHTML = "";
					}
				}
			}
		} catch (e) {}
	},
	initParse : function (editorid, objparam, width) {
		//
		try {
			var editortgt = jQuery("textarea[name=" + editorid + "]")[0];
			var h = parseInt(editortgt.getAttribute("rows"));
			jQuery(editortgt).css("height", h*30 + "px");
		} catch (e9) {alert(e9);}
		
		if (!!!objparam) {
			 objparam = {
			 autoFloatEnabled:false,//不保持工具栏位置
			 allowDivTransToP:false,//不把div自动转为p
			 disabledTableInTable:false,//允许table嵌套
       		 toolbars: [[
	            'fullscreen', 'source', '|',
	            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|', 
	            'fontfamily', 'fontsize', 'forecolor', 'backcolor','|', 
	            'insertorderedlist', 'insertunorderedlist','indent', '|'
	            ,'justifyleft', 'justifycenter', 'justifyright', '|',
	            'link', 'unlink', 'insertimage', 'inserttable', '|'
	         ]], theme : "metro", initialStyle : "p{font-family:Microsoft YaHei; font-size:12px;}"
			};
		}	
		var _ue = UE.getEditor(editorid, objparam);
		jQuery("div#" + editorid).css("width", "");
		this.bindEvent('phraseDesc');
		jQuery("div#" + editorid).children("div .edui-default").css("width", "");
		_ue.addListener('ready', function(){
			try {
				__insertimage(_ue, "insertimage");
			} catch(e_i) {}
		});
		return _ue;
	}
};


function __insertimage(editor,uiName){
   //唯一标识uuid对象
   function UUID() {
     this.id = this.createUUID();
	}
	UUID.prototype.valueOf = function () {
		return this.id;
	}
	UUID.prototype.toString = function () {
		return this.id;
	}
    UUID.prototype.createUUID = function () {
		var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
		var dc = new Date();
		var t = dc.getTime() - dg.getTime();
		var h = '-';
		var tl = UUID.getIntegerBits(t, 0, 31);
		var tm = UUID.getIntegerBits(t, 32, 47);
		var thv = UUID.getIntegerBits(t, 48, 59) + '1'; // version 1, security version is 2
		var csar = UUID.getIntegerBits(UUID.rand(4095), 0, 7);
		var csl = UUID.getIntegerBits(UUID.rand(4095), 0, 7);
		var n = UUID.getIntegerBits(UUID.rand(8191), 0, 7) +
			UUID.getIntegerBits(UUID.rand(8191), 8, 15) +
			UUID.getIntegerBits(UUID.rand(8191), 0, 7) +
			UUID.getIntegerBits(UUID.rand(8191), 8, 15) +
			UUID.getIntegerBits(UUID.rand(8191), 0, 15); // this last number is two octets long
		return tl + h + tm + h + thv + h + csar + csl + h + n;
	}
	UUID.getIntegerBits = function (val, start, end) {
		var base16 = UUID.returnBase(val, 16);
		var quadArray = new Array();
		var quadString = '';
		var i = 0;
		for (i = 0; i < base16.length; i++) {
			quadArray.push(base16.substring(i, i + 1));
		}
		for (i = Math.floor(start / 4); i <= Math.floor(end / 4); i++) {
			if (!quadArray[i] || quadArray[i] == '') quadString += '0';
			else quadString += quadArray[i];
		}
		return quadString;
	}
	UUID.returnBase = function (number, base) {
		var convert = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
		if (number < base) var output = convert[number];
		else {
			var MSD = '' + Math.floor(number / base);
			var LSD = number - MSD * base;
			if (MSD >= base) var output = this.returnBase(MSD, base) + convert[LSD];
			else var output = convert[MSD] + convert[LSD];
		}
		return output;
	}
	UUID.rand = function (max) {
		return Math.floor(Math.random() * max);
	}

    //swf上传对象
	var swfu;
    var splitcharImg = "////~~weaversplit~~////"
	function init(uuid) {
		var language = "7";
		var btnwidth = language==8?86:35;
		var settings = {
			flash_url : "/js/swfupload/swfupload.swf",
			upload_url: "/docs/reply/upload/UploadForReplyImage.jsp",
			post_params:{"method":"uploadFile"},
			use_query_string : true,//要传递参数用到的配置
			file_size_limit : "100 MB",
			file_types : "*.jpg;*.gif;*.png;",
			file_types_description : "image file,flash file,flv file,mp3 file",
			file_upload_limit : 50,
			file_queue_limit : 0,
			custom_settings : {
				progressTarget : "fsUploadProgress_"+uuid,
				cancelButtonId : "btnCancel"
			},
			debug: false,

			// Button settings
		button_image_url : "",
		secid : window._secid,
		button_placeholder_id : uuid,
		button_width: 19,
		button_height: 19,
		button_text: '',
		button_text_style: '',
		button_text_top_padding: 0,
		button_text_left_padding: 0,
		button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
		button_cursor: SWFUpload.CURSOR.HAND,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : function(numFilesSelected, numFilesQueued){		
			var editoroffset = jQuery(editor.iframe).offset();
			if (numFilesSelected > 0) {		
				if(editor.queryCommandState("source")===0){	
				   var process = jQuery("#fsUploadProgress_"+uuid);
				   if(process.length===0){
					   process=jQuery("<div  style='position:absolute;left:10px;top:10px;z-index: 100;'  id='fsUploadProgress_"+uuid+"'></div>");
					   jQuery(document.body).append(process);
				   }
                   process.css("left",editoroffset.left);
				   process.css("top",editoroffset.top);
				   process.show();
				   this.startUpload();
				}else
				   window.top.Dialog.alert("请将编辑器切换到可视化模式!");
			}
		},
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : function (file, server_data) {
			var img="<img style='max-width: 60px; max-height: 60px;' onclick='playImgs(this);' src='/weaver/weaver.docs.docs.reply.FileDownload?docid="+docid+"&fileid="+jQuery.trim(server_data)+"' alt='"+jQuery.trim(file.name)+"'/>";
			//插入图片
			editor.execCommand('inserthtml',img);
			$("#imgFileids").val($("#imgFileids").val()+","+jQuery.trim(server_data));
			$("#imgFilenames").val($("#imgFilenames").val()+splitcharImg+jQuery.trim(file.name));
		},
		upload_complete_handler : function(){
		     var process = jQuery("#fsUploadProgress_"+uuid);
             process.html("");
		},
		queue_complete_handler : function(){
		
		}	// Queue plugin event
		};
		
		swfu = new SWFUpload(settings);
	}
	
	function showImgDialog(path)
	{
		
	}

	 //创建上传按钮
	function createUploader(){
      var flag=false;
	  var container = jQuery(editor.container);
      var crmbutton=container.find(".edui-for-insertimage");
	  
      if(crmbutton.length===0){
	     setTimeout(function(){createUploader();},200);
	  }else{
         if(crmbutton.length>1){
         	var len=crmbutton.length,buttons=crmbutton;
         	 crmbutton=jQuery(crmbutton.eq(0));
             for(var i=1;i<len;i++){
                 //jQuery(buttons[i]).remove();
             	 jQuery(buttons[i]).html('');
                 jQuery(buttons[i]).hide();
             }
         }
          jQuery("#remarkShadowDivInnerDiv").click(function(){
		      if(container.parents(".remarkDiv").is(":visible")){
			      position=crmbutton.position();
		          placehoder.css("left",position.left+4);
		          placehoder.css("top",position.top+3);
			  }
		  });

		 if(container.parents(".remarkDiv").length===1  &&  !container.parents(".remarkDiv").is(":visible")){
			 container.parents(".remarkDiv").show();
			 flag=true;
		 }
        var position=crmbutton.position();
        if(position.left < 0)
	    {
	      	createUploader();
	    }
		crmbutton.css("visibility","hidden");
		var uuid = new UUID();
        var placehoder=jQuery("<div title="+SystemEnv.getHtmlNoteName(3568)+" style='width:20px;height:20px;position:absolute;z-index:10000;background-image:url(/ueditor/themes/metro/images/icons_wev8.png);background-position: -726px -77px;border:1px solid transparent;'><span id='"+uuid+"'></span></div>");
        placehoder.css("left",position.left+4);
		placehoder.css("top",position.top+3);
		placehoder.addClass("e8fileupload")
	 	container.append(placehoder);

		placehoder.hover(function hoverin(){
            placehoder.css("background-color","#fff5d4");
            placehoder.css("border-color","#dcac6c");
		},function hoverout(){
		    placehoder.css("background-color","");
            placehoder.css("border-color","transparent");
		});
		init(uuid);
        
		//窗口大小变化
        jQuery(window).resize(function(){
		     position=crmbutton.position();
		     placehoder.css("left",position.left+4);
		     placehoder.css("top",position.top+3);
		});

		if(flag){
		   container.parents(".remarkDiv").hide();
		}

	  }
	}
	
	setTimeout(function(){createUploader();},200);
}

function initremarkat(ifr) {
	var initat = function (ifr) {
		try {
			var datas = window.__atdata;
			if (window.__atdataready != true || !!!datas) {
				setTimeout(function () {
					initat(ifr);
				}, 1000);
				return ;
			}
			
			var allatids = ",";
	        var names = jQuery.map(datas, function(value, i) {
	        	if (allatids.indexOf("," + value.uid + ",") == -1) { 
		        	allatids += value.uid + ",";
		            return {'id':value.uid,'name':value.data, 'py':value.datapy};
	            }
	        });
		    var at_config = {
		        at: "@",
		        data: names,
		        tpl: "<li data-value='@${name}'>${name}</li>",
		        insert_tpl: "<a href='/hrm/HrmTab.jsp?_fromURL=HrmResource&id=${id}' atsome='@${id}' contenteditable='false' style='cursor:pointer;text-decoration:none !important;margin-right:8px;' target='_blank'>${atwho-data-value}</a>", 
		        limit: 200,
		        show_the_at: true,
		        start_with_space : false,
		        with_repeat_matcher : false,
		        search_key_py : 'py'
		    }
		
			ifrBody = ifr.contentDocument.body
		    jQuery(ifrBody).atwho('setIframe', ifr).atwho(at_config)
		    var atwhoblockobj = jQuery(".atwho-view");
		    atwhoblockobj.perfectScrollbar({horizrailenabled:false,zindex:11111});
		    //atwhoblockobj.addClass("ac_results");
		    //atwhoblockobj.css("width", "150px!important");
		    //atwhoblockobj.removeClass("atwho-view");
	    } catch (e) {}
	}
	
	if (window.location.href.indexOf("AddRequestIframe.jsp") == -1) {
		initat(ifr);
	}
}
var x=0;
function __fileupload(editor,uiName){
	   //唯一标识uuid对象
	   function UUID() {
	     this.id = this.createUUID();
		}
		UUID.prototype.valueOf = function () {
			return this.id;
		}
		UUID.prototype.toString = function () {
			return this.id;
		}
	    UUID.prototype.createUUID = function () {
			var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
			var dc = new Date();
			var t = dc.getTime() - dg.getTime();
			var h = '-';
			var tl = UUID.getIntegerBits(t, 0, 31);
			var tm = UUID.getIntegerBits(t, 32, 47);
			var thv = UUID.getIntegerBits(t, 48, 59) + '1'; // version 1, security version is 2
			var csar = UUID.getIntegerBits(UUID.rand(4095), 0, 7);
			var csl = UUID.getIntegerBits(UUID.rand(4095), 0, 7);
			var n = UUID.getIntegerBits(UUID.rand(8191), 0, 7) +
				UUID.getIntegerBits(UUID.rand(8191), 8, 15) +
				UUID.getIntegerBits(UUID.rand(8191), 0, 7) +
				UUID.getIntegerBits(UUID.rand(8191), 8, 15) +
				UUID.getIntegerBits(UUID.rand(8191), 0, 15); // this last number is two octets long
			return tl + h + tm + h + thv + h + csar + csl + h + n;
		}
		UUID.getIntegerBits = function (val, start, end) {
			var base16 = UUID.returnBase(val, 16);
			var quadArray = new Array();
			var quadString = '';
			var i = 0;
			for (i = 0; i < base16.length; i++) {
				quadArray.push(base16.substring(i, i + 1));
			}
			for (i = Math.floor(start / 4); i <= Math.floor(end / 4); i++) {
				if (!quadArray[i] || quadArray[i] == '') quadString += '0';
				else quadString += quadArray[i];
			}
			return quadString;
		}
		UUID.returnBase = function (number, base) {
			var convert = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
			if (number < base) var output = convert[number];
			else {
				var MSD = '' + Math.floor(number / base);
				var LSD = number - MSD * base;
				if (MSD >= base) var output = this.returnBase(MSD, base) + convert[LSD];
				else var output = convert[MSD] + convert[LSD];
			}
			return output;
		}
		UUID.rand = function (max) {
			return Math.floor(Math.random() * max);
		}

	    //swf上传对象
		var oUploadannexupload;
		
		var splitchar = "////~~weaversplit~~////"
		function init(uuid) {
			var annexmainId = jQuery("#annexmainId").val();
			var annexsubId = jQuery("#annexsubId").val();
			var annexsecId = jQuery("#annexsecId").val();
			var fileuserid = jQuery("#fileuserid").val();
			var fileloginyype = jQuery("#fileloginyype").val();
			var language = "7";
			var btnwidth = language==8?86:35;
			var settings = {
				flash_url : "/js/swfupload/swfupload.swf",
				upload_url: "/docs/reply/upload/UploadForReplyImage.jsp",
				post_params:{"method":"uploadFile",
					"mainId": annexmainId,
					"subId": annexsubId,
					"secId": annexsecId,
					"userid": fileuserid,
					"logintype": fileloginyype
				},
				use_query_string : true,//要传递参数用到的配置
				file_size_limit : "100 MB",
				file_types : "*.*",
				file_types_description : "All Files",
				file_upload_limit : 50,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : "fsUploadProgressfileupload",
					cancelButtonId : "fileCancel"
				},
				debug: false,

				// Button settings
			button_image_url : "",
			secid : window._secid,
			button_placeholder_id : uuid,
			button_width: 18,
			button_height: 18,
			button_text: '',
			button_text_style: '',
			button_text_top_padding: 0,
			button_text_left_padding: 0,
			button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
			button_cursor: SWFUpload.CURSOR.HAND,
				
			file_queued_handler : fileQueued,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : function(numFilesSelected, numFilesQueued){		
				var editoroffset = jQuery(editor.iframe).offset();
				if (numFilesSelected > 0) {		
					if(editor.queryCommandState("source")===0){	
					   var container = jQuery(editor.container);
					   container.find(".edui-for-wfannexbutton").css("visibility","visible");
					   container.find(".edui-for-wfannexbutton").css("cursor","pointer");
					   container.find(".edui-for-wfannexbutton").css("z-index","101");
					   jQuery("#promptinformation").html("");
					   var el = jQuery(".edui-for-wfannexbutton");
			           var px=el.offset().left;
				       var py=el.offset().top + 17;
				       jQuery("#fsUploadProgressfileuploaddiv").css({"top":py + "px", "left":px+"px"});
					   jQuery("#field-annexupload-count").val(numFilesQueued);
					   jQuery("#fsUploadProgressfileuploaddiv").attr("banfold","1");
					   enableAllmenu();
					   this.startUpload();
					}else
					   window.top.Dialog.alert("请将编辑器切换到可视化模式!");
				}
			},
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : function (file, server_data) {
				var rtvids = "";
				var rtvnames = "";
				var rtvsizes = "";
				if (!!file) {
					if (rtvids == "") {
						rtvids = jQuery.trim(server_data);
						rtvnames = jQuery.trim(file.name);
						rtvsizes = file.size;
					} else {
						rtvids += "," + jQuery.trim(server_data);
						rtvnames += splitchar + jQuery.trim(file.name);
						rtvsizes += splitchar + file.size;
					}
				}
				var fieldannexuploadid = jQuery.trim(jQuery("#field-annexupload").val());
				var fieldannexuploadidname = jQuery.trim(jQuery("#field-annexupload-name").val());
				if(fieldannexuploadid != "" && fieldannexuploadid !=null){
					jQuery("#field-annexupload").val(fieldannexuploadid+","+jQuery.trim(rtvids));
					jQuery("#field-annexupload-name").val(fieldannexuploadidname+splitchar+jQuery.trim(rtvnames));
				}else{
					jQuery("#field-annexupload").val(jQuery.trim(rtvids));
					jQuery("#field-annexupload-name").val(jQuery.trim(rtvnames));
				}
			},
			upload_complete_handler : function(){
				
				var fieldannexuploadcount = jQuery("#field-annexupload-count").val();
				x++;
				if(x == fieldannexuploadcount){
					jQuery("#fsUploadProgressfileupload").html("");
					jQuery("#fsUploadProgressfileuploaddiv").css("top","-500px");
					try {
	           			var _targetobj = jQuery(".edui-for-wfannexbutton").children("div").children("div").children("div").children(".edui-metro");
		            	if (document.getElementById("field-annexupload").value != '') {
		            		_targetobj.addClass("wfres_1_slt");
		            		_targetobj.removeClass("wfres_1");
		            	} else {
		            		_targetobj.addClass("wfres_1");
		            		_targetobj.removeClass("wfres_1_slt");
		            	}
		            } catch (e) {}
		            jQuery("#fsUploadProgressfileuploaddiv").attr("banfold","0");
		            addli();
		            
					displayAllmenu();
				}
			},
			queue_complete_handler : function(){
			
			}
			};
			
			oUploadannexupload = new SWFUpload(settings);
		}

		 //创建附件上传按钮
		function createFieldUploader(){
	      var flag=false;
		  var container = jQuery(editor.container);
	      var crmbutton=container.find(".edui-for-wfannexbutton");
	      if(crmbutton.length===0){
	    	  setTimeout(function(){
	    		  try {
	    			  createUploader();
	    		  } catch (e) {}
	    	  },200);
		  }else{
	         if(crmbutton.length>1){
	         	var len=crmbutton.length,buttons=crmbutton;
	         	 crmbutton=jQuery(crmbutton.eq(0));
	             for(var i=1;i<len;i++){
	                 //jQuery(buttons[i]).remove();
	             	 jQuery(buttons[i]).html('');
	                 jQuery(buttons[i]).hide();
	             }
	         }
	          jQuery("#remarkShadowDivInnerDiv").click(function(){
			      if(container.parents(".remarkDiv").is(":visible")){
				      position=crmbutton.position();
			          placehoder.css("left",position.left+3);
			          placehoder.css("top",position.top+3);
				  }
			  });

			 if(container.parents(".remarkDiv").length===1  &&  !container.parents(".remarkDiv").is(":visible")){
				 container.parents(".remarkDiv").show();
				 flag=true;
			 }
	        var position=crmbutton.position();
	        if(position.left < 0)
	        {
	        	createUploader();
	        }
			crmbutton.css("visibility","hidden");
			var uuid = new UUID();
			$("#placehoderDiv").remove();
	        var placehoder=jQuery("<div id='placehoderDiv' title="+SystemEnv.getHtmlNoteName(3457)+" style='width:18px;height:18px;position:absolute;z-index:100;background-image:url(/ueditor/custbtn/images/wf_annex_wev8.png);border:1px solid transparent;'><span id='"+uuid+"'></span></div>");
	        placehoder.css("left",position.left+3);
			placehoder.css("top",position.top+3);
			placehoder.addClass("e8fileupload")
		 	container.append(placehoder);

			placehoder.hover(function hoverin(){
	            placehoder.css("background-color","#fff5d4");
	            placehoder.css("border-color","#dcac6c");
			},function hoverout(){
			    placehoder.css("background-color","");
	            placehoder.css("border-color","transparent");
			});
			
			init(uuid);
	        
			//窗口大小变化
	        jQuery(window).resize(function(){
			     position=crmbutton.position();
			     placehoder.css("left",position.left+3);
			     placehoder.css("top",position.top+3);
			});

			if(flag){
			   container.parents(".remarkDiv").hide();
			}

		  }
		}
		

		function enableAllmenu()
		{
			
		}

		function displayAllmenu()
		{
		}
		
		function addli(){
			var el = jQuery(".edui-for-wfannexbutton");
	        var px=el.offset().left;
		    var py=el.offset().top + 17;
		    jQuery("#_fileuploadphraseblock").css("z-index","999");
		    jQuery("#_fileuploadphraseblock").css({"top":py + "px", "left":px+"px"});
			//jQuery("#_fileuploadphraseblock").show();
				var ids = jQuery.trim(jQuery("#field-annexupload").val());
				var names = jQuery.trim(jQuery("#field-annexupload-name").val());
				var _ul = jQuery("#_fileuploadphraseblock").find("#_filecontentblock ul");
				if(ids != "" && ids != null){
					var fieldcancle = jQuery("#field-cancle").val();
					jQuery("#promptinformation").html("").css("padding","2px");
					if(ids.indexOf(",") > -1){
						var idArray = ids.split(",");
						var nameArray = names.split(splitchar);
						for (var i=0; i<idArray.length; i++) {
					    	var curid = jQuery.trim(idArray[i]);
			                var curname = jQuery.trim(nameArray[i]);
			                if(!checkliid(jQuery.trim(curid))){
			                	_ul.append("<li id='li_"+curid+"' onclick=\"onAddUploadFile("+curid+",'"+curname+"')\" class=\"cg_item\"><span class='cg_detail' style='width:130px;' title='" + curname + "' >" + curname + "</span><a onmouseover=\"showBt("+curid+")\" onmouseout=\"hiddenBt("+curid+")\" onclick=\"deletefile("+curid+",'"+curname+"')\" style=\"float:right;width:10px;height:10px;margin-right:5px;margin-top:8px;background-image:url(/images/ecology8/workflow/annexdel_wev8.png);\" class=\"e8_delClass1\" title='"+fieldcancle+"' ></a></li>");
			                }
					    }
					}else{
						if(!checkliid(jQuery.trim(ids))){
		                	_ul.append("<li id='li_"+ids+"' onclick=\"onAddUploadFile("+ids+",'"+names+"')\" class=\"cg_item\"><span class='cg_detail' style='width:130px;' title='" + names + "'>" + names + "</span><a onmouseover=\"showBt("+ids+")\" onmouseout=\"hiddenBt("+ids+")\" onclick=\"deletefile("+ids+",'"+names+"')\" style=\"float:right;width:10px;height:10px;margin-right:5px;margin-top:8px;background-image:url(/images/ecology8/workflow/annexdel_wev8.png);\" class=\"e8_delClass1\" title='"+fieldcancle+"' ></a></li>");
						}
					}
				}
		    	var _outdiv = jQuery("#_filecontentblock");
		    	var _li = jQuery("#_filecontentblock ul li");
		    	if (_li.length > 4)  {
					jQuery("#_filecontentblock").css("height", "124px");
					jQuery("#_filecontentblock").css("overflow", "hidden");
					jQuery("#_filecontentblock").perfectScrollbar({horizrailenabled:false,zindex:1000});
					_li.show();
				}
		    	if (_li.length == 4)  {
					jQuery("#_filecontentblock").css("height", "94px");
					jQuery("#_filecontentblock").css("overflow","");
				}
		    	if (_li.length == 3)  {
					jQuery("#_filecontentblock").css("height", "64px");
					jQuery("#_filecontentblock").css("overflow","");
				}
		    	if (_li.length == 2)  {
					jQuery("#_filecontentblock").css("height", "34px");
					jQuery("#_filecontentblock").css("overflow","");
				}
		    	if (_li.length == 1)  {
					jQuery("#_filecontentblock").css("height", "34px");
					jQuery("#_filecontentblock").css("overflow","");
				}
		}
		
		setTimeout(function(){createFieldUploader();},200);
}