var asaEditorConfig = {
	debug : false

	, languages : { ko:'%ED%95%9C%EA%B8%80', zh:'%E4%B8%AD%E6%96%87', ja:'%E6%97%A5%E6%9C%AC%E8%AA%9E', en:'English' }

	, imageUpload : {
		use : false,
		url : 'asaEditor_image_upload.php',
		params : {}
	}

	, color : { 
					'red': ['#000000', '#0a0000', '#140000', '#1e0000', '#280000', '#320000', '#3c0000', '#460000', '#500000', '#5a0000', '#640000', '#6e0000', '#780000', '#820000', '#8c0000', '#960000', '#a00000', '#aa0000', '#b40000', '#be0000', '#c80000', '#d20000', '#dc0000', '#e60000', '#f00000', '#fa0000'],
					'green' : ['#000000', '#000a00', '#001400', '#001e00', '#002800', '#003200', '#003c00', '#004600', '#005000', '#005a00', '#006400', '#006e00', '#007800', '#008200', '#008c00', '#009600', '#00a000', '#00aa00', '#00b400', '#00be00', '#00c800', '#00d200', '#00dc00', '#00e600', '#00f000', '#00fa00'],
					'' : ['#000000', '#00000a', '#000014', '#00001e', '#000028', '#000032', '#00003c', '#000046', '#000050', '#00005a', '#000064', '#00006e', '#000078', '#000082', '#00008c', '#000096', '#0000a0', '#0000aa', '#0000b4', '#0000be', '#0000c8', '#0000d2', '#0000dc', '#0000e6', '#0000f0', '#0000fa']
	}

	, bB : ['edit|icon01', 'source|icon02', 'view|icon03']

	, tB : [
			 'fontname|FontName'
			, '-'
			, 'fontsize|FontSize'
			, '-'
			, 'formatblock|FormatBlock'
			, '-'
			, 'bold|Bold'
			, 'under|Underline'
			, 'italic|Italic'
			, 'strike|StrikeThrough'
			, 'fontcolor|forecolor'
			, 'backcolor|BackColor'
			, ['superscript|SuperScript'
			, 'subscript|SubScript']
			, '-'
			, 'align_left|JustifyLeft'
			, 'align_center|JustifyCenter'
			, 'align_right|JustifyRight'
			, 'undo|undo'
			, 'redo|redo'
			, ['num_list|InsertOrderedList'
			, 'list|InsertUnorderedList'
			, 'indent_short|Outdent'
			, 'indent_long|Indent']
			, '-'			
			, 'new|new'
			, 'cut|cut'
			, 'copy|copy'
			, 'paste|paste'
			, 'link|CreateLink'
			, 'table|table'
			, 'pic|InsertImage'
			, ['blockquote|BlockQuote'
			, 'lineheight|LineHeight'
			, 'line|InsertHorizontalRule'
			, 'character|Character'
			, 'find|find'
			, 'linebreak|LineBreak'
			, 'flash|flash'
			, 'movie|movie']
			, '-'
			/*, 'cellmerge|CellMerge'
			, 'colsplit|colSplit'
			, 'rowsplit|RowSplit'*/
			, 'languages|Languages']

	, isReturnFullHtml : false

	, newLine : 'br'

	, baseDir : './js'

	, useMultiLanguage : false

	, fontStyle : {
		fontSize:'10pt',
		lineHeight:'1.5'
	}
};
	
var viewLayer = '';var asaEditor_lang = {};var asaEditorGlobal = {};var asaEditorLib = { ce : function(tagName, cssText){ var obj = document.createElement(tagName); if( cssText ) obj.style.cssText = cssText; return obj; }, ce2 : function(type, name, cssText) { var element = null; try { element = document.createElement('<'+type+' name="'+name+'">'); } catch (e) { } if (!element || element.nodeName != type.toUpperCase()) { element = document.createElement(type); element.name = name; } return element; }, create : function(name, attr){ var e = document.createElement(name); asaEditorLib.each(attr, function(v, i){ e.setAttribute(i, v); }); return e; }, $ : function(id){ return document.getElementById(id); }, A : function(o){ var a = []; for(var i=0; i<o.length; i++){ a.push(o[i]); } return a; }, extend : function(source, append) { var obj = source || {}; for(var x in append) { if(typeof append[x] == 'object'){ if(append[x].constructor == Array){ obj[x] = []; } obj[x] = asaEditorLib.extend(obj[x], append[x]); } else { obj[x] = append[x]; } } return obj; }, getCharset:function(){ if(document.charset){ return document.charset; } if(document.defaultCharset){ return document.defaultCharset; } if(document.characterSet){ return document.characterSet; } if(document.inputEncoding){ return document.inputEncoding; } var metas = document.getElementsByTagName('meta'); for(var i=0, len=metas.length; i<len; i++){ if(metas[i].getAttribute('http-equiv') && metas[i].getAttribute('http-equiv').toLowerCase() =="content-type"){ var x = (metas[i].getAttribute('content') || ';').split(';'); if(x.length>1){ var y = x[1].split('='); if(y.length>1){ return y[1].replace(/^\s|\s$/g, ''); } } } } return ""; }, decode_lang:function(str){ if(!str){ return ''; } var cache = asaEditorLib.$('asaEditor_cache'); if( !cache ){ cache = asaEditorLib.ce('div'); cache.id = 'asaEditor_cache'; } cache.innerHTML = str; return cache.innerHTML; }, getRelativeURL:function(){ var href = location.href.replace(location.protocol + '//' + location.host, ''), qs = href.indexOf('?'); if(qs >= 0){ href = href.substring(0, qs); } return href; }, Ajax : { _xmlHttpRequest: function(req) { if(window.XMLHttpRequest) { try { req = new XMLHttpRequest(); } catch(e) { req = false; } } else if(window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { req = false; } } } return req; }, _updateDiv: function(div, req) { document.getElementById(div).innerHTML = req.responseText; }, _handler : function(req, configs) { if (req.readyState == 4) { if ((typeof req.status == 'undefined' && navigator.userAgent.match(/Safari/)) || req.status == 200) { if (configs['updateDiv']){ asaEditorLib.Ajax._updateDiv(configs['updateDiv'], req); } if(configs['onSuccess']){ configs['onSuccess'](req); } } } }, _request: function(url, configs) { if(configs['onBegining']) configs['onBegining'](); var req = asaEditorLib.Ajax._xmlHttpRequest(); try { if (req) { if(document.all){ req.onreadystatechange = function(){ asaEditorLib.Ajax._handler(req, configs); } } else { req.onload = req.onerror = req.onabort = function(){ asaEditorLib.Ajax._handler(req, configs); } } } if (configs['method'] != 'POST') { if (configs['parameters'] != '') { url += '?' + configs['parameters']; } } req.open(configs['method'], url, configs['asynch']); req.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); if (configs['method'] == 'POST') req.setRequestHeader('Content-Type', configs['contentType']); req.setRequestHeader('Connection', 'close'); req.send((configs['method'] == 'POST') ? configs['parameters'] : null); } catch(e){ if(configs['onFailure']) configs['onFailure'](req); } if(configs['onComplete']) configs['onComplete'](); }, _setOptions: function(configs) { _options = { method: 'POST', contentType: 'application/x-www-form-urlencoded', asynch:true, parameters: '', onBegining: function(){}, onComplete: function() {}, onSuccess: function() {}, onFailure: function() {}, updateDiv: '' }; for (var property in configs) { if (property == 'method') _options[property] = configs[property].toUpperCase(); else _options[property] = configs[property]; } return _options; }, Updater: function(div, url, configs) { configs['updateDiv'] = div; asaEditorLib.Ajax._request(url, asaEditorLib.Ajax._setOptions(configs)); }, Request: function(url, configs) { asaEditorLib.Ajax._request(url, asaEditorLib.Ajax._setOptions(configs)); } }, getAbsPos : function(obj){ if(obj == null || obj.parentNode==null || obj.style.display=='none') { return false } var parent=null, pos=[], box; if(document.getBoxObjectFor) { box = document.getBoxObjectFor(obj); pos = [box.x, box.y]; } else { pos = [obj.offsetLeft, obj.offsetTop]; parent = obj.offsetParent; if(parent!=obj) { while(parent) { pos[0] += parent.offsetLeft; pos[1] += parent.offsetTop; parent = parent.offsetParent; } } if(navigator.appName.indexOf('opera')!=-1 || navigator.appName.indexOf('safari')!=-1 && obj.getStyle('position')=='absolute') { pos[1] -= document.body.offsetTop } } parent = (obj.parentNode) ? obj.parentNode : null; while(parent && parent.tagName!='BODY' && parent.tagName!='HTML') { pos[0] -= parent.scrollLeft; pos[1] -= parent.scrollTop; parent = (parent.parentNode) ? parent.parentNode : null; } return {x: pos[0], y: pos[1], left:pos[0], top:pos[1]}; }, getMouseXY:function(e){ if(document.all){ tempX = event.clientX + document.body.scrollLeft; tempY = event.clientY + document.body.scrollTop; } else { tempX = e.pageX; tempY = e.pageY; } return {x:tempX, y:tempY}; }, getHeight : function(element){ var display = element.style.display; if (display != 'none' && display != null){ if(element.offsetHeight){ return element.offsetHeight; } if(element.style.pixelHeight){ return element.style.pixelHeight; } if(element.clip){ return element.clip.height; } } var els = element.style; var originalVisibility = els.visibility; var originalPosition = els.position; var originalDisplay = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = 'block'; var originalHeight = element.clientHeight; els.display = originalDisplay; els.position = originalPosition; els.visibility = originalVisibility; return originalHeight; }, getWidth : function(element){ var display = element.style.display; if (display != 'none' && display != null){ if(element.offsetWidth){ return element.offsetWidth; } if(element.style.pixelWidth){ return element.style.pixelWidth; } if(element.clip){ return element.clip.width;} } var els = element.style; var originalVisibility = els.visibility; var originalPosition = els.position; var originalDisplay = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = 'block'; var originalWidth = element.clientWidth; els.display = originalDisplay; els.position = originalPosition; els.visibility = originalVisibility; return originalWidth; }, getAbsSize : function(obj){ return { width:asaEditorLib.getWidth(obj), height:asaEditorLib.getHeight(obj) }; }, addEvent : function( obj, type, fn, bubble ) { if( !obj ){ return; } bubble = bubble || false; if (obj.addEventListener) obj.addEventListener( type, fn, bubble ); else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }; obj.attachEvent( "on"+type, obj[type+fn] ); } }, removeEvent : function ( obj, type, fn ) { if( !obj ){ return; } if (obj.removeEventListener) obj.removeEventListener( type, fn, false ); else if (obj.detachEvent) { obj.detachEvent( "on"+type, obj[type+fn] ); obj[type+fn] = null; obj["e"+type+fn] = null; } }, cancelEvent : function(e){ if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }, getBaseDir : function(fileName){ var scripts = document.getElementsByTagName('script'); for(var i=0, len=scripts.length; i<len; i++){ var paths = scripts[i].src.split('/'); if(paths[paths.length-1].indexOf(fileName) >= 0){ paths = paths.slice(0, paths.length-2); return paths.join('/'); } } return ''; }, each : function(o, cb, s) { var n, l; if (!o) return 0; s = s || o; if (typeof(o.length) != 'undefined') { for (n=0, l = o.length; n<l; n++) { if (cb.call(s, o[n], n, o) === false) return 0; } } else { for (n in o) { if(typeof o[n] == 'function') continue; if (o.hasOwnProperty(n)) { if (cb.call(s, o[n], n, o) === false) return 0; } } } return 1; }, enc : { _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = asaEditorLib.enc._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + asaEditorLib.enc._keyStr.charAt(enc1) + asaEditorLib.enc._keyStr.charAt(enc2) + asaEditorLib.enc._keyStr.charAt(enc3) + asaEditorLib.enc._keyStr.charAt(enc4); } return output; }, decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = asaEditorLib.enc._keyStr.indexOf(input.charAt(i++)); enc2 = asaEditorLib.enc._keyStr.indexOf(input.charAt(i++)); enc3 = asaEditorLib.enc._keyStr.indexOf(input.charAt(i++)); enc4 = asaEditorLib.enc._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = asaEditorLib.enc._utf8_decode(output); return output; }, _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }, classNames: function(el) { return el.className.split(' '); }, hasClassName: function(el, c) { var exist = false; if (!el.className) { return false; } var tmp = el.className.split(' '); for (var i in tmp) { if (tmp[i] == c) { exist = true; break; } } return exist; }, addClassName: function(el, c) { if (!asaEditorLib.hasClassName(el, c)) el.className += ' ' + c; }, removeClassName: function(el, c) { var tmp = el.className.split(' '); for (var i in tmp) { if (tmp[i] == c) { tmp.splice(i, 1); break; } } el.className = tmp.join(' '); }, replaceClassName: function(el, c){ if(asaEditorLib.hasClassName(el, c)){ asaEditorLib.removeClassName(el, c); } asaEditorLib.addClassName(el, c); }, setCookie: function(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; }, getCookie : function(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); }, removeCookie : function(name, path, domain) { if (getCookie(name)) { document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") +"; expires=Thu, 01-Jan-70 00:00:01 GMT"; } }, loadScript : function(url, callback){ var script, id; /*if (asaEditorLib.Browser.isIE6) { asaEditorLib.Ajax.Request(url, { asynch:true, onSuccess : function(res) { var content = res.responseText; var script = asaEditorLib.create('script', { type : 'text/javascript' }); script.text = content; (document.getElementsByTagName('head')[0] || document.body).appendChild(script); } }); if(callback) { callback(); } return; }*/ var script = asaEditorLib.create('script', { type : 'text/javascript' }); if (script.readyState){ /*//IE*/ script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; if(callback){ callback(); } } }; } else { /*//Others*/ script.onload = function(){ if(callback){ callback(); } }; } script.src = url; (document.getElementsByTagName('head')[0] || document.body).appendChild(script); }, loadCSS : function(url){ var link = asaEditorLib.create('link', { rel : 'stylesheet', type : 'text/css', href : url }); (document.getElementsByTagName('head')[0] || document.body).appendChild(link); }, escapeHTMLText : function(str){ return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }, fixLang:function(lang){ if( !lang ){ return 'ko'; } if(lang == 'jp'){ return 'ja'; } else if(lang == 'cn'){ return 'zh'; } else if(lang == 'kr'){ return 'ko'; } return lang; }};asaEditorLib.extend(Array.prototype, { indexOf : function(v){ for(var i=0, len=this.length; i<len; i++){ if(v == this[i]) return i; } return -1; }});(function(){ var xx = {Browser:{}}; xx.Browser.isOpera = window.opera && window.opera.buildNumber; xx.Browser.isWebKit = /WebKit/.test(navigator.userAgent); xx.Browser.isIE = !xx.Browser.isWebKit && !xx.Browser.isOpera && (/MSIE/gi).test(navigator.userAgent) && (/Explorer/gi).test(navigator.appName); xx.Browser.isIE6 = xx.Browser.isIE && /MSIE [56]/.test(navigator.userAgent); xx.Browser.isIE7 = xx.Browser.isIE && /MSIE [7]/.test(navigator.userAgent); xx.Browser.isGecko = !xx.Browser.isWebKit && /Gecko/.test(navigator.userAgent); xx.Browser.isMac = navigator.userAgent.indexOf('Mac') != -1; xx.Browser.isAir = /adobeair/i.test(navigator.userAgent); xx.Browser.isNS = (/Netscape6\//.test(navigator.userAgent) || /Gecko/.test(navigator.userAgent)); asaEditorLib.extend(asaEditorLib, xx);})();if(typeof asaEditorGlobal.baseDir == 'undefined'){ asaEditorGlobal.baseDir = asaEditorLib.getBaseDir('asaEditor');};var asaEd = function (oldText, configs){ configs = configs || {}; this.editorId = oldText; this.timeVal = (new Date()).getTime(); this.fn = []; this.loadEditorConfig(configs); this.loadLibrary(); var editor = this; var waitTime = 0; setTimeout(function(){ if(asaEditorConfig && asaEditor_lang[editor.lang]){ asaEditorGlobal.pageLoaded = true; editor.init(); editor.createEditor(); editor.setAPI(); asaEditorLib.$(editor.editorId + '_textareaBox').style.display = 'none'; editor.oOriTO.style.display='none'; editor.containerObj.style.display = ''; if(editor.oTO.disabled){ editor.isDisabled = editor.oTO.disabled; editor.setDisabled(true); } } else { if(waitTime > 100){ alert('no library file.'); return; } waitTime += 1; setTimeout(arguments.callee, 100); } }, 100);};asaEd.prototype.loadEditorConfig = function(configs){ var editor=this, c = asaEditorLib.extend({}, asaEditorConfig); if( !(configs.imageUpload && configs.imageUpload.url) ){ c.imageUpload.url = asaEditorGlobal.baseDir + '/' + c.imageUpload.url; } editor.lang = asaEditorLib.fixLang(configs['lang']); editor.configs = asaEditorLib.extend(c, configs); if(typeof asaEditorGlobal['charset'] == 'undefined'){ asaEditorGlobal['charset'] = asaEditorLib.getCharset().toLowerCase(); } };asaEd.prototype.setHtmlBegin = function(html){ if (this.modes != 'edit') { alert(this.decode_lang('confirm.notEditMode')); return false; } this.configs.htmlBegin = html; var body = this.oFO.contentWindow.document.body.innerHTML; this.showEditorFrame(body); this.setFocus(); this.setSelection();};asaEd.prototype.setHtmlEnd = function(html){ if (this.modes != 'edit') { alert(this.decode_lang('confirm.notEditMode')); return false; } this.configs.htmlEnd = html; var body = this.oFO.contentWindow.document.body.innerHTML; this.showEditorFrame(body); this.setFocus(); this.setSelection();};asaEd.prototype.createIFrame = function(){ debug('createIFrame'); var ifrm = document.createElement('IFRAME'); ifrm.src = 'about:blank'; ifrm.frameBorder = 0; ifrm.style.cssText = 'border: 0; margin: 0px; padding: 0px; border:1px solid #D0D0D0;width:100%;height:100%;'; return ifrm;};asaEd.prototype.init = function(){ debug('init'); var cfg = this.configs['fontStyle'] || {}; this.editorDoc = {}; this.focusObj = {}; this.modes = 'edit'; this.tB = this.configs.tB; this.bB = this.configs.bB; this.toolbarObj = null; this.bottomObj = null; this.modeEditClick = ''; this.modeHtmlClick = ''; this.isDisabled = ( this.configs.isDisabled === true ? true : false ); this.fontStyle = (cfg['fontSize'] ? 'font-size:'+cfg['fontSize']+';' : ''); this.fontStyle += (cfg['lineHeight'] ? 'line-height:'+cfg['lineHeight']+';' : ''); this.fontStyle += 'font-family:'+(this.decode_lang('common.defaultFont')||'arial')+';'; var begin = '<html><head>'; begin += '<meta http-equiv="Content-Type" content="text/html; charset='+asaEditorGlobal['charset']+'" />'; if( this.configs['baseHref'] ){ begin += '<base href="'+this.configs['baseHref']+'" />'; } if( this.configs['cssUrl'] ){ begin += '<link href="'+this.configs['cssUrl']+'" rel="stylesheet" type="text/css"/>'; } if( this.configs['cssText'] ){ begin += '<style type="text/css">' + this.configs['cssText'] + '</style>'; } begin += '</head>'; if( this.configs['bodyAttributes'] ){ begin += '<body '; for(var item in this.configs['bodyAttributes']){ if( typeof this.configs['bodyAttributes'][item] != 'string' ) continue; begin += (item + '="'+this.configs['bodyAttributes'][item]+'" '); } begin += ">"; } else { var tm = 4, lm = 4, mw = 0, mh = 0; if( typeof(this.configs['topMargin']) != 'undefined') tm = this.configs['topMargin']; if( typeof(this.configs['leftMargin']) != 'undefined') lm = this.configs['leftMargin']; if( typeof(this.configs['marginWidth']) != 'undefined') mw = this.configs['marginWidth']; if( typeof(this.configs['marginHeight']) != 'undefined') mh = this.configs['marginHeight']; begin += '<body topmargin="'+tm+'" leftmaegin="'+lm+'" marginwidth="'+mw+'" marginheight="'+mh+'" style="'+this.fontStyle+'">'; } asaEditorLib.extend(this.configs, { htmlBegin : this.configs['htmlBegin'] || begin , htmlBody : this.configs['htmlBody'] || '<div>&nbsp;</div>' , htmlEnd : this.configs['htmlEnd'] || '</body></html>' + "\n" , imgDir : (this.configs.imageDir ? this.configs.imageDir : asaEditorGlobal.baseDir + '/image') }); (function(editor){ var imgs = ['ok','cancel','preview','input','upload']; asaEditorLib.each(imgs, function(i){ var img = new Image(); img.src = editor.configs.imgDir+'/btn_'+i+'.gif?'+editor.timeVal; }); })(this); asaEditorGlobal.asaEditorContextMenuObj = null;};asaEd.prototype.setDisabled = function(val){ debug('setDisabled'); this.isDisabled = val === true ? true : false; this.oTO.disabled = this.isDisabled; this.showEditorFrame(); };asaEd.prototype.onEditorFocus = function(e){ debug('onEditorFocus'); this.hideLayer();};asaEd.prototype._canHide = function(parent){ while(parent && parent.tagName!='BODY' && parent.tagName!='HTML') { if(parent.getAttribute('_dropmenu') != null || parent.getAttribute('_cmd') != null) { return false; } parent = (parent.parentNode) ? parent.parentNode : null; } return true;};asaEd.prototype.hideLayer = function(e){ debug('hideLayer'); e = e || window.event; var w = asaEditorGlobal, mo; if( e ){ var src = e.srcElement || e.target; if(!this._canHide(src)) return; } if(!this._destroyDialog()){ return; } if( mo = w.asaEditorDropMenuObj ) { mo.style.display = 'none'; mo = null; }};asaEd.prototype.forceHideLayer = function(isMenuInDrop){ debug('forceHideLayer'); var w = asaEditorGlobal, mo; if(!this._destroyDialog()){ return; } if(isMenuInDrop){ return; } if(mo = w.asaEditorDropMenuObj) { mo.style.display = 'none'; mo = null; }};asaEd.prototype._destroyDialog = function(){ var w = asaEditorGlobal, mo = w.asaEditorContextMenuObj; if( mo ) { if(mo.getAttribute('_autohide') == 'false') return false; try{ mo.parentNode.removeChild(mo); } catch(e){} mo = null; } w.activeEditor = null; return true;};asaEd.prototype.createEditor = function (){ debug('creatEditor'); var d = document; this.oOriTO = asaEditorLib.$(this.editorId); this.containerObj = asaEditorLib.ce('table', 'display:none'); this.containerObj.id = this.editorId+'_box'; this.containerObj.cellPadding = this.containerObj.cellSpacing = this.containerObj.border = 0; if( this.configs['width'] ){ this.containerObj.style.width = this.configs['width']; } else { if(this.oOriTO.style.width.indexOf('%') > -1){ this.containerObj.width = this.oOriTO.style.width; } else { var w = 0; if(this.oOriTO.style.width){ this.containerObj.style.width = this.oOriTO.style.width; } else { w = asaEditorLib.getWidth(this.oOriTO); this.containerObj.style.width = w + 'px'; } } } var h = 0; if( this.configs['height'] ){ this.containerObj.style.height = this.configs['height']; } else { if(this.oOriTO.style.height.indexOf('%') > -1){ h = this.oOriTO.style.height; this.containerObj.style.height = h; } else { if(this.oOriTO.style.height){ this.containerObj.style.height = this.oOriTO.style.height; } else { h = asaEditorLib.getHeight(this.oOriTO); if(parseInt(h)>0){ this.containerObj.style.height = h+'px'; } } } } this.toolbarObj = this.createToolbar(); this.oFO = this.createIFrame(); this.bottomObj = this.createModeButton(); var r = this.containerObj.insertRow(this.containerObj.rows.length); r.id = this.editorId + '_toolbarBox'; var c = r.insertCell(r.cells.length); c.appendChild(this.toolbarObj); r = this.containerObj.insertRow(this.containerObj.rows.length); r.id = this.editorId + '_editorBox'; c = r.insertCell(r.cells.length); c.style.height = "100%"; c.style.textAlign = 'left'; c.appendChild(this.oFO); r = this.containerObj.insertRow(this.containerObj.rows.length); r.id = this.editorId + '_textareaBox'; c = r.insertCell(r.cells.length); c.style.height = "100%"; c.style.textAlign = 'left'; var tmp = this.oOriTO.value; var n = this.oOriTO.cloneNode(false); n.value = tmp; n.removeAttribute('name'); n.removeAttribute('id'); c.appendChild(n); r = this.containerObj.insertRow(this.containerObj.rows.length); r.id = this.editorId + '_bottombarBox'; c = r.insertCell(r.cells.length); c.style.textAlign='left'; c.appendChild(this.bottomObj); this.oOriTO.parentNode.insertBefore(this.containerObj, this.oOriTO); this.oTO = n; this.setTextareaStyle(); this.showEditorFrame(); this.oFO.style.width = this.oTO.style.width = '99%'; if(asaEditorLib.Browser.isIE6 || asaEditorLib.Browser.isIE7){ this.oTO.style.margin = '-1px 0 -1px 0'; } var editor = this; asaEditorLib.addEvent(d.body, 'mousedown', function(e){ editor.hideLayer.call(editor, e); } );};asaEd.prototype.loadLibrary = function(){ debug('loadLibrary'); var x = asaEditorLib, ed = this; if(!asaEditorGlobal.pageLoaded){ if(!asaEditorGlobal.cssUrls){ asaEditorGlobal.cssUrls = []; } if(asaEditorGlobal.cssUrls.indexOf('editor.css')<0){ x.loadCSS(asaEditorGlobal.baseDir+'/css/editor.css?'+this.timeVal); asaEditorGlobal.cssUrls.push('editor.css'); } } x.loadScript(asaEditorGlobal.baseDir+'/js/ierange.js?'+this.timeVal); if(typeof asaEditor_lang[ed.lang] == 'undefined' ){ if(ed.configs.useMultiLanguage && asaEditorGlobal['charset'] == 'utf-8'){ ed.loadConfig(); } x.loadScript(asaEditorGlobal.baseDir+'/js/lang/character.js'); x.loadScript(asaEditorGlobal.baseDir+'/js/lang/'+ed.lang+'.js?'+this.timeVal); }};asaEd.prototype.reload = function(configs){ debug('reload'); for(var p in window){ if(window[p] == this){ if('lang' in configs){ this.lang = asaEditorLib.fixLang(configs.lang); } if('imageDir' in configs){ this.configs.imageDir = configs.imageDir; } this.loadLibrary(); var editor = this; setTimeout(function(){ if(asaEditorConfig && asaEditor_lang[editor.lang]){ editor.toolbarObj.parentNode.removeChild(editor.toolbarObj); editor.bottomObj.parentNode.removeChild(editor.bottomObj); editor.toolbarObj = editor.createToolbar(); editor.bottomObj = editor.createModeButton(); editor.containerObj.rows[0].cells[0].appendChild(editor.toolbarObj); editor.containerObj.rows[3].cells[0].appendChild(editor.bottomObj); editor.getContentMsg(); editor.showEditorFrame(); } else { setTimeout(arguments.callee, 100); } }, 100); break; } } };asaEd.prototype.loadConfig = function(){ debug('loadConfig'); var editor = this; var url = asaEditorGlobal.baseDir+'/js/asaEditor_configManager.php'; asaEditorLib.Ajax.Request(url, { asynch : false, method:'post', parameters : 'act=get&key='+encodeURIComponent(asaEditorLib.getRelativeURL()+'#'+editor.editorId)+'&section=language', onSuccess : function(res) { if(res.responseText in editor.configs.languages){ editor['lang'] = asaEditorLib.fixLang(res.responseText); } } });};asaEd.prototype.saveConfig = function(o){ debug('saveConfig'); function removeBaseURL(href){ return href.substring(0, href.lastIndexOf('/')); }; var editor = this; var url = asaEditorGlobal.baseDir+'/js/asaEditor_configManager.php'; asaEditorLib.Ajax.Request(url, { asynch : false, method:'post', parameters : 'act=save&key='+encodeURIComponent(asaEditorLib.getRelativeURL()+'#'+editor.editorId)+'&section=language&value='+o.lang, success : function(res) { } });};asaEd.prototype.onKeyPress = function(e){ if( this.configs.newLine != 'br' ){ return; } debug('onKeyPress'); e = e || this.oFO.contentWindow.event; var key=(e.charCode)?e.charCode:((e.keyCode)?e.keyCode:((e.which)?e.which:0)); if(key == 13){ var d = this.oFO.contentWindow.document; var shiftPassed = false; if(e.shiftKey){ shiftPassed = e.shiftKey; } else { var s = (e.modifiers+32).toString(2).substring(3, 6); shiftPassed = (s.charAt(0) == '1'); } if (shiftPassed){ return; } var n, s = d.selection; var r = s.createRange(); if( s.type != 'None' ) return true; if( r.text ) d.execCommand('Delete', false, null); r.pasteHTML('<br id="__" />'); var n = d.getElementById('__'); n.removeAttribute('id'); r.select(n); r.collapse(); asaEditorLib.cancelEvent(e); return false; }};asaEd.prototype.showEditorFrame = function (body){ debug('showEditorFrame'); this.reloadFromTextbox(body); this.setDesignMode(true); this.initEditorDoc();};(function(){ var e = asaEditorLib.enc.decode; var asaUtil = asaEditorLib; eval(e('YXNhRWRpdG9yID0gYXNhRWQ7IAlhc2FVdGlsLmFkZEV2ZW50KHdpbmRvdywgJ2xvYWQnLCBmdW5jdGlvbigpewl2YXIgZCA9IGRvY3VtZW50OyB2YXIgaW8gPSBkLmNyZWF0ZUVsZW1lbnQoImltZyIpOyBpby5zdHlsZS5jc3NUZXh0PSJkaXNwbGF5Om5vbmU7d2lkdGg6MXB4O2hlaWdodDoxcHg7IjsgaW8uc3JjPSJodHRwOi8vd3d3LmFzYWRhbC5jb20vfkFzYVByb2dyYW0vbW9kdWxlL2VkaXQvbGljZW5zZV9jaGVjay5waHA/dT0iK2VuY29kZVVSSUNvbXBvbmVudChsb2NhdGlvbi5ocmVmKTsgZG9jdW1lbnQuYm9keS5hcHBlbmRDaGlsZChpbyk7IH0pOw=='));})();asaEd.prototype.createToolbar = function (){ debug('createToolbar'); var zone = {}; zone['imgArr' ] = {}; zone['imgs' ] = ''; zone['mode' ] = ''; zone['cnt' ] = this.tB.length; zone['top' ] = asaEditorLib.ce("div", 'padding-top: 2px; padding-bottom: 2px;text-align:left;float:left;'); zone['top' ].id = 'toolbar_'+this.editorId; var globalButtons = ['formatblock', 'fontname', 'fontsize', 'bold', 'under', 'italic' ,'strike','fontcolor', 'backcolor']; var createBandBox = function(){ var tbl = asaEditorLib.ce('TABLE'); tbl.cellPadding = tbl.cellSpacing = tbl.border = 0; return tbl; }; var curTbl = null, curTr = null, curTd = null; var curBand = asaEditorLib.ce('SPAN'); curTbl = createBandBox(); curTr = curTbl.insertRow(curTbl.rows.length); asaEditorLib.each(this.tB, function(v, i){ if(typeof v == 'string'){ zone['imgArr' ] = v.split('|'); zone['imgs' ] = asaEditorLib.ce("img"); if( v == '-' ) { zone['imgs' ].setAttribute('src', this.configs.imgDir + '/split.gif?'+this.timeVal); zone['imgs' ].style.cssText = 'vertical-align: middle;width:4px;margin-bottom:1px;'; curTd = curTr.insertCell(curTr.cells.length); curTd.appendChild(zone['imgs']); curBand.appendChild(curTbl); curBand.style.cssText = 'float:left;'; zone['top' ].appendChild(curBand); curBand = asaEditorLib.ce('SPAN'); curTbl = createBandBox(); curTr = curTbl.insertRow(curTbl.rows.length); } else { if(zone['imgArr'][1] == 'Languages'){ /*//if(!this.configs.useMultiLanguage || asaEditorGlobal['charset'] != 'utf-8'){ return; }*/ } else if(zone['imgArr'][1] == 'LineBreak'){ zone['imgArr'][0] += (this.configs.newLine == 'br' ? '' : '_no'); } zone['mode' ] = zone['imgArr'][1]; zone['imgs' ].setAttribute('src', this.configs.imgDir + '/' + (this.lang!='ko' && globalButtons.indexOf(zone['imgArr'][0])>=0 ? this.lang+'/' : '') + zone['imgArr'][0] + '.gif?'+this.timeVal); zone['imgs' ].setAttribute('id', this.editorId+'_btn_'+zone['imgArr'][1]); zone['imgs' ].style.cssText = 'vertical-align: middle; cursor: '+(this.isDisabled ? 'no-drop' : 'hand')+';margin-top:1px;margin-bottom:1px;'; zone['imgs' ].setAttribute('alt', this.decode_lang('Cmd.'+zone['imgArr'][1]) || zone['imgArr'][1]); zone['imgs' ].setAttribute('title', this.decode_lang('Cmd.'+zone['imgArr'][1]) || zone['imgArr'][1]); zone['imgs' ].setAttribute('_cmd', zone['imgArr'][1]); this.attachEventControl(zone['imgs'], 'click', 'practiceExec', zone['mode'], null); curTd = curTr.insertCell(curTr.cells.length); curTd.appendChild(zone['imgs']); } } else { curTd = curTr.insertCell(curTr.cells.length); /*curTd.style.position = 'relative';*/ zone['dropmenu'] = asaEditorLib.ce('div', 'display:none;position:absolute;width:48px;margin:0;padding:0;'); zone['dropmenu'].setAttribute('_dropmenu', 'true'); zone['dropimg'] = asaEditorLib.ce("img", 'cursor:hand;'); zone['dropimg'].src = this.configs.imgDir + '/expand.gif?'+this.timeVal; for(var i=0, l=v.length; i<l; i++){ zone['imgArr' ] = v[i].split('|'); zone['imgs'] = asaEditorLib.ce("img", ""); zone['mode' ] = zone['imgArr'][1]; zone['imgs' ].setAttribute('src', this.configs.imgDir + '/' + (this.lang!='ko' && globalButtons.indexOf(zone['imgArr'][0])>=0 ? this.lang+'/' : '') + zone['imgArr'][0] + '.gif?'+this.timeVal); zone['imgs' ].setAttribute('id', this.editorId+'_btn_'+zone['imgArr'][1]); zone['imgs' ].style.cssText = 'vertical-align: middle; cursor: '+(this.isDisabled ? 'no-drop' : 'hand')+';margin:0;padding:0;'; zone['imgs' ].setAttribute('alt', this.decode_lang('Cmd.'+zone['imgArr'][1]) || zone['imgArr'][1]); zone['imgs' ].setAttribute('title', this.decode_lang('Cmd.'+zone['imgArr'][1]) || zone['imgArr'][1]); zone['imgs' ].setAttribute('_cmd', zone['imgArr'][1]); this.attachEventControl(zone['imgs'], 'click', 'practiceExec', zone['mode'], 'menuindrop'); zone['dropmenu'].appendChild(zone['imgs']); } (function(dropmenu){ zone['dropimg'].onclick = function(e){ if(dropmenu.style.display == 'none'){ e = e || window.event; var pos = asaEditorLib.getAbsPos(e.srcElement||e.target); dropmenu.style.top = (pos.top+20)+'px'; dropmenu.style.left = pos.left+'px'; dropmenu.style.display = ''; asaEditorGlobal.asaEditorDropMenuObj = dropmenu; } }; })(zone['dropmenu']); curTd.appendChild(zone['dropimg']); curTd.appendChild(zone['dropmenu']); } }, this); curBand.appendChild(curTbl); curBand.style.cssText = 'float:left;'; zone['top' ].appendChild(curBand); return zone['top'];};asaEd.prototype.createFontDialog = function (sender, command){ debug('createFontDialog'); this.setFocus(); this.setSelection(); if( command.toLowerCase() == 'fontname' ) {this.createFontFamilyBox();} else if( command.toLowerCase() == 'fontsize' ) {this.createFontSizeBox();} else if( command.toLowerCase() == 'formatblock' ) {this.createFormatBlockBox();} else if( command.toLowerCase() == 'lineheight' ) {this.createLineHeightBox();}};asaEd.prototype.createModeButton = function (){ debug('createModeButton'); var zone = {}; var editor = this; zone['imgs' ] = ''; zone['styles' ] = ''; zone['button' ] = asaEditorLib.ce("div"); zone['button' ].style.cssText = 'padding-top: 3px;padding-bottom:3px;'; zone['button' ].style.width = this.oFO.style.width; asaEditorLib.each(this.bB, function(v, i){ i = parseInt(i, 10); var item = v.split('|'); zone['styles' ] = (i != 0) ? 'margin-left: 3px;' : ''; zone['imgs' ] = asaEditorLib.ce('img'); zone['imgs' ].style.cssText = 'cursor: '+(this.isDisabled ? 'no-drop' : 'hand')+';' + zone['styles']; zone['imgs' ].setAttribute('src', this.configs.imgDir + '/' + (this.lang!='ko' ? this.lang+'/' : '') + item[1] + '.gif?'+editor.timeVal); zone['imgs' ].setAttribute('alt', this.decode_lang('common.'+item[0])); zone['imgs' ].setAttribute('title', this.decode_lang('common.'+item[0])); this.attachEventControl(zone['imgs'], 'click', 'toggleMode', (i+1), null); zone['button' ].appendChild(zone['imgs']); }, this); return zone['button' ];};asaEd.prototype.decode_lang = function(n){ var sa = n.split('.'), w = asaEditor_lang[this.lang]; for(var i=0, l=sa.length; i<l; i++){ w = w[sa[i]]; } return asaEditorLib.decode_lang(w);};asaEd.prototype.practiceExec = function (command, codes, sender){ debug('practiceExec'); if( this.isDisabled ) { alert(this.decode_lang('confirm.editorIsDisabled')); return false; } if (this.modes == 'html') { alert(this.decode_lang('confirm.notEditMode')); return false; } this.forceHideLayer('menuindrop'==codes); switch (command) { case 'new' : this.newDocument(); break; case 'find' : this.createFindDialog(); this.showLayer(sender); break; case 'CreateLink' : this.createLinkDialog(); this.showLayer(sender); asaEditorLib.$('asaEditor$selectLink').focus(); break; case 'InsertImage' : this.createImageDialog(); this.showLayer(sender); break; case 'flash' : case 'movie' : this.createMediaDialog(command); this.showLayer(sender); asaEditorLib.$(command+'Input').focus(); break; case 'table' : this.createTableDialog(); this.showLayer(sender); asaEditorLib.$('tableWidth').focus(); break; case 'forecolor' : case 'BackColor' : this.createColorDialog(sender, command); this.showLayer(sender); break; case 'FontName': case 'FormatBlock': case 'FontSize': case 'LineHeight': this.createFontDialog(sender, command); this.showLayer(sender); break; case 'Languages': this.createLanguagesDialog(sender, command); this.showLayer(sender); break; case 'LineBreak': this.setLineBreak(sender); break; case 'Character': this.createCharacterDialog(sender); this.showLayer(sender); break; case 'BlockQuote': this.createBlockQuoteDialog(sender); this.showLayer(sender); break; default : try { this.execCommand(command, false, null); }catch(e){} break; }};asaEd.prototype.showLayer = function(sender){ debug('showLayer'); if( asaEditorGlobal.asaEditorContextMenuObj ) { var pos = asaEditorLib.getAbsPos(sender); var size = asaEditorLib.getAbsSize(sender); var ifrmWidth = asaEditorLib.getWidth(this.oFO); var ifrmPos = asaEditorLib.getAbsPos(this.oFO); var layerWidth = asaEditorLib.getWidth(asaEditorGlobal.asaEditorContextMenuObj); if(ifrmWidth >= layerWidth) { if( (ifrmPos.left + ifrmWidth) < (pos.left + layerWidth) ) { pos.left = ifrmPos.left + ifrmWidth - layerWidth; } } else { pos.left = ifrmPos.left - ((layerWidth - ifrmWidth)/2); } asaEditorGlobal.asaEditorContextMenuObj.style.position = 'absolute'; asaEditorGlobal.asaEditorContextMenuObj.style.left = pos.left+'px'; asaEditorGlobal.asaEditorContextMenuObj.style.top = (pos.top + size.height)+'px'; asaEditorGlobal.asaEditorContextMenuObj.style.display = 'block'; asaEditorGlobal.asaEditorContextMenuObj.focus(); asaEditorGlobal.activeEditor = this; }};asaEd.prototype.toggleMode = function (mode){ debug('toggleMode'); if( this.isDisabled ){ alert(this.decode_lang('confirm.editorIsDisabled')); return; } asaEditorLib.$(this.editorId + '_toolbarBox').style.display = asaEditorLib.$(this.editorId + '_bottombarBox').display = ''; switch (mode) { case 1 : asaEditorLib.$(this.editorId + '_textareaBox').style.display = 'none'; this.setEditorMode(); asaEditorLib.$(this.editorId + '_editorBox').style.display = ''; /*this.setFocus();*/ break; case 2 : var editor = this; if(asaEditorLib.Browser.isIE){ var size = asaEditorLib.getAbsSize(asaEditorLib.$(editor.editorId + '_editorBox')); if(parseInt(size.height)>10){ asaEditorLib.$(editor.editorId + '_textareaBox').style.height = size.height+'px'; editor.oTO.style.height = size.height+'px'; } } asaEditorLib.$(this.editorId + '_editorBox').style.display = 'none'; this.setHtmlMode(); asaEditorLib.$(this.editorId + '_textareaBox').style.display = ''; try{ this.oTO.focus(); } catch(e){} break; case 3 : asaEditorLib.$(this.editorId + '_textareaBox').style.display = 'none'; this.setViewMode(); asaEditorLib.$(this.editorId + '_editorBox').style.display = ''; break; case 4: this.modes = 'text'; asaEditorLib.$(this.editorId + '_editorBox').style.display = asaEditorLib.$(this.editorId + '_toolbarBox').style.display = asaEditorLib.$(this.editorId + '_bottombarBox').style.display = 'none'; asaEditorLib.$(this.editorId + '_textareaBox').style.display = ''; break; }};asaEd.prototype.setEditorMode = function (){ if (this.modeEditClick) { return; } debug('setEditorMode'); this.getContentMsg(false); this.setDesignMode(true); this.initEditorDoc(); this.modes = 'edit'; this.modeEditClick = true; this.modeHtmlClick = false;};asaEd.prototype.setHtmlMode = function (){ debug('setHtmlMode'); if (this.modeHtmlClick) { return; } var value = this.getContentMsg(true); this.modes = 'html'; this.modeEditClick = false; this.modeHtmlClick = true;};asaEd.prototype.setViewMode = function (){ debug('setViewMode'); var value = this.getContentMsg(true); this.reloadFromTextbox(value); this.setDesignMode(false); this.initEditorDoc(); this.modes = 'view'; this.modeEditClick = false; this.modeHtmlClick = false;};asaEd.prototype.attachEventControl = function (obj, mode, fnc, com, code){ var objs = this; if (obj.addEventListener) { obj.addEventListener(mode, function (objs) { var fncs = fnc; var coms = com; var codes = code; var sender = obj; return function () { eval('objs.' + fncs + '(coms, codes, sender)'); }; }(this), false); } else if (obj.attachEvent) { obj.attachEvent('on' + mode, function (objs) { var fncs = fnc; var coms = com; var codes = code; var sender = obj; return function () { eval('objs.' + fncs + '(coms, codes, sender)'); }; }(this)); }};asaEd.prototype.insertHTML = function (html){ debug('insertHTML'); this.setFocus(); if (asaEditorLib.Browser.isIE) { this.focusObj.pasteHTML(html); this.focusObj.select(); } else { this.execCommand('insertHTML', false, html); }};asaEd.prototype.execCommand = function (command, userUi, value){ debug('execCommand'); this.forceHideLayer(); this.setFocus(); this.oFO.contentWindow.document.execCommand(command, userUi, value); debug(command+':'+value);};function debug(msg){ if(typeof asaEditorConfig == 'undefined' || !asaEditorConfig.debug) { return; } var div = asaEditorLib.$('debug'); if(div == null){ div = asaEditorLib.ce('div'); div.id = 'debug'; document.body.appendChild(div); } div.innerHTML += msg+"<br/>";};asaEd.prototype.setFocus = function () { debug('setFocus'); try{ this.oFO.contentWindow.focus(); } catch(e){}};asaEd.prototype.setCarretPos = function(pThis,pPos) { if(pThis.setSelectionRange) { pThis.focus(); pThis.setSelectionRange(pPos,pPos); } else if (pThis.createTextRange) { var range = pThis.createTextRange(); range.collapse(true); range.moveEnd('character', pPos); range.moveStart('character', pPos); range.select(); }};asaEd.prototype.setSelection = function (){ debug('setSelection'); if (asaEditorLib.Browser.isIE) { this.focusObj = this.oFO.contentWindow.document.selection.createRange(); }};asaEd.prototype.execCommandEx = function (select, mode){ debug('execCommandEx'); if(document.all){ this.focusObj.select();} this.execCommand(mode, false, select); this.forceHideLayer();};asaEd.prototype.getContentMsg = function (returns){ debug('getContentMsg'); if (this.modes == 'edit') { this.setTextValue(this.getBodyHTML()); } else if (this.modes == 'html') { this.reloadFromTextbox(); try { var d = this.oFO.contentWindow.document; var as = d.getElementsByTagName('A'); for(var i=0, len=as.length; i<len; i++){ if(as[i].href.indexOf('#')>=0){ as[i].href = as[i].href.replace(location.href, ''); } } } catch(e){} } if (returns) { return this.oTO.value; }};asaEd.prototype.contentSameCheck = function (isFull){ debug('contentSameCheck'); isFull = isFull || asaEditorConfig.isReturnFullHtml; if(this.modes == 'text'){ return true; } var value = ( isFull === true ? this.getFullHTML() : this.getContentMsg(true)); this.oOriTO.value = value; if (value.toLocaleLowerCase() == this.configs.htmlBody || value.toLocaleLowerCase() == '<div>%s</div>' ||value == '') { return false; } return true;};asaEd.prototype.getWin = function(){ debug('getWin'); return this.oFO.contentWindow;};asaEd.prototype.getDocument = function(){ debug('getDocument'); return this.oFO.contentWindow.document;};asaEd.prototype.getTextareaText = function () { debug('getTextareaText'); var v = ((this.oTO.value == '') ? this.configs.htmlBody : this.oTO.value); return v;};asaEd.prototype.getDoc = function() { var d = this.oFO.contentWindow.document; return d;};asaEd.prototype.setDesignMode = function (mode){ debug('setDesignMode'); if( this.isDisabled === true ){ mode = false; } var t = this, d = t.getDoc(); d.designMode = (mode) ? 'On' : 'Off'; if (d.body && d.body.contentEditable) { d.body.contentEditable = (mode) ? true : false; } };asaEd.prototype.reloadFromTextbox = function(body){ body = body || this.getTextareaText(); var begin = this.configs.htmlBegin, end = this.configs.htmlEnd; if(body.toLowerCase().indexOf("<body")>=0 || body.toLowerCase().indexOf("&lt;body")>=0){ begin = end = ''; } this.editorDoc = this.oFO.contentWindow.document; this.editorDoc.open(); this.editorDoc.write(begin); this.editorDoc.write(body); this.editorDoc.write(end); this.editorDoc.close(); /*this.oFO.contentWindow.document.body.innerHTML = this.getTextareaText();*/};asaEd.prototype.reloadFromEditorbox = function(){ this.setTextValue(this.getBodyHTML());};asaEd.prototype.setCreateElement = function (zone, cnt, name, element){ for (var i=1; i<=cnt; i++) { zone[name + i] = asaEditorLib.ce(element); }};asaEd.prototype.getStyleInto = function (ie, etc){ return (asaEditorLib.Browser.isIE) ? ie : etc;};asaEd.prototype.setText = function (obj, text){ (asaEditorLib.Browser.isIE) ? obj.innerText = text : obj.textContent = text;};asaEd.prototype.setTextareaStyle = function (){ this.oTO.style.fontSize = '9pt'; this.oTO.style.fontFamily = 'Tahoma, '+this.decode_lang('common.defaultFont'); this.oTO.style.borderTop = '1px solid #D0D0D0'; this.oTO.style.borderLeft = '1px solid #D0D0D0'; this.oTO.style.borderRight = '1px solid #D0D0D0'; this.oTO.style.borderBottom = '1px solid #D0D0D0'; this.oTO.style.width = '100%'; this.oTO.style.height = '100%'; this.oTO.style.margin = '0'; this.oTO.style.display = '';};asaEd.prototype.getImages = function(){ var imgs = this.oFO.contentWindow.document.getElementsByTagName('IMG'); var names = []; if(imgs && imgs.length){ for(var i=0; i<imgs.length; i++) { var parseUri = imgs[i].src.split('/'); var imgName = parseUri[parseUri.length-1]; names.push({'src':imgs[i].src, 'imgName':imgName}); } } return names;};asaEd.prototype.initEditorDoc = function (){ (function(editor){ var doc = editor.oFO.contentWindow.document; if(doc.body){ if('ok' == doc.body.getAttribute('__init__')){ return; } debug('initEditorDoc'); /* doc.body.setAttribute('__init__', 'ok'); doc.body.style.fontSize = '9pt'; doc.body.style.fontFamily = 'Tahoma, '+asaEditor_lang[editor.lang].common.defaultFont; doc.body.style.marginTop = 4+'px'; doc.body.style.marginLeft = 4+'px'; */ if( editor.isDisabled ) { doc.body.style.backgroundColor = "#DDDDDD"; doc.body.style.cursor = "no-drop"; return; } if(asaEditorLib.Browser.isIE || asaEditorLib.Browser.isOpera){ doc.onkeypress = function(e){ editor.onKeyPress.call(editor, e); } } asaEditorLib.addEvent(doc.body, 'mousedown', function(e){ editor.onEditorFocus.call(editor, e); }); if(editor.configs['handlers'] && editor.configs['handlers']['onLoaded']){ editor.configs['handlers']['onLoaded'].call(editor); } } else { setTimeout(function(){ editor.initEditorDoc() }, 50); } })(this);};asaEd.prototype.newDocument = function (){ if( ! confirm(this.decode_lang('confirm.newDoc')) ) return; this.reloadFromTextbox('<div>&nbsp;</div>'); this.initEditorDoc(); this.toggleMode(1);};asaEd.prototype.getSelection = function(){ var w = this.getWin(); return w.getSelection ? w.getSelection() : window.getSelection(this.getDoc());};asaEd.prototype.createFindDialog = function (){ try { this.setFocus(); this.setSelection(); var box = asaEditorLib.ce('div', 'padding:4px 4px 4px 4px;text-align:left;'); this.createContextBox({ attr : { id : 'asaEditor_findDialog', _cmd : 'FindBox', autohide:false }, appendChild : box, style : { width : '240px' } }); var titleDiv = asaEditorLib.ce('div', 'font-weight:bold;text-align:left;padding-left:2px;height:20px;'); titleDiv.id = 'findDialogTitle'; titleDiv.innerHTML = "Find & Replace"; var tabDiv = asaEditorLib.ce('div','display:block;margin:0;padding:0;text-align:left;cursor:arrow;'); tabDiv.innerHTML = '<ul style="list-style:none;margin:0;left:0;padding:0;"><li class="tab" style="cursor:hand;margin:0;list-style-type:none;float:left;border:1px solid #afafaf;padding:2px 4px 2px 4px;">Find</li><li class="tab" style="cursor:hand;list-style-type:none;float:left;border:1px solid #afafaf;padding:2px 4px 2px 4px;margin-left:2px;background:#eeeeee;">Replace</li></ul>'; var findDiv = asaEditorLib.ce('div', 'clear:both;display:block;margin:-1 0 0 0;border:1px solid #afafaf;'); findDiv.innerHTML = '<ul style="list-style:none;margin:0;padding:4px;">' + ' <li id="asaEditor_findCell" style="margin:0;"><div style="width:60px;float:left;padding:4px 0 0 4px;">Find : </div><input type="text" id="asaEditor_Txt_Keyword" style="width:90px;"><input type="button" id="asaEditor_Btn_Next" class="btn_default" style="width:60px;" value="Next"></li>' + ' <li id="asaEditor_replCell" style="display:none"><div style="width:60px;float:left;padding:4px 0 0 4px;">Replace : </div><input type="text" id="asaEditor_Txt_Replace" style="width:90px;"><input type="button" id="asaEditor_Btn_Replace" class="btn_default" style="width:60px;" value="Replace"></li>' + '</ul>'; var buttonDiv = asaEditorLib.ce('div','padding:0;padding:4px 0 0 0;width:100%;'); buttonDiv.innerHTML = ' <ul style="list-style:none;margin:0;padding:0;text-align:center;">' + ' <li style="list-style-type:none;float:left;margin-bottom:5px;"><input type="button" id="asaEditor_Btn_ReplaceAll" class="btn_default" style="display:none;;width:80px;" value="Replace All"></li>' + ' <li style="list-style-type:none;float:right;"><input type="button" id="asaEditor_Btn_Cancel" class="btn_default" value="Cancel"></li>' + ' </ul>'; box.appendChild(titleDiv); box.appendChild(tabDiv); box.appendChild(findDiv); box.appendChild(buttonDiv); var tabs = tabDiv.getElementsByTagName('li'); for(var i=0; i<tabs.length; i++){ (function(i, a, b){ tabs[i].onclick = function(){ a.style.backgroundColor = (i == 0 ? '#fff' : '#eeeeee'); b.style.backgroundColor = (i == 1 ? '#fff' : '#eeeeee'); var e = null; if(e = asaEditorLib.$('asaEditor_replCell')){ e.style.display = (i == 1 ? '' : 'none'); } if(e = asaEditorLib.$('asaEditor_Btn_ReplaceAll')){ e.style.display = (i == 1 ? '' : 'none'); } }; }(i, tabs[0], tabs[1])); } var btn = null; var editor = this; if( !editor.searcher ){ editor.searcher = new DHTMLSearcher(this); } if(btn = asaEditorLib.$('asaEditor_Btn_Next')){ btn.onclick = function(){ editor.searcher.Search(asaEditorLib.$('asaEditor_Txt_Keyword').value); }; } if(btn = asaEditorLib.$('asaEditor_Btn_Replace')){ btn.onclick = function(){ editor.searcher.Replace(asaEditorLib.$('asaEditor_Txt_Keyword').value, asaEditorLib.$('asaEditor_Txt_Replace').value); }; } if(btn = asaEditorLib.$('asaEditor_Btn_ReplaceAll')){ btn.onclick = function(){ editor.searcher.ReplaceAll(asaEditorLib.$('asaEditor_Txt_Keyword').value, asaEditorLib.$('asaEditor_Txt_Replace').value); }; } if(btn = asaEditorLib.$('asaEditor_Btn_Cancel')){ btn.onclick = function(){ editor.forceHideLayer(); editor.setFocus(); }; } if(btn = asaEditorLib.$('findDialogTitle')){ btn.style.cursor = 'move'; btn.onselectstart = btn.ondragstart = null; btn.onmousedown = function(e){ asaEditorDrager.dragStart(e, 'asaEditor_findDialog'); }; } } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.createContextBox = function(opt){ if( asaEditorGlobal.asaEditorContextMenuObj ){ this.hideLayer(); } var w=window, d=document, o; asaEditorGlobal.asaEditorContextMenuObj = o = asaEditorLib.ce('div'); if( opt.attr ){ for(var i in opt.attr){ o.setAttribute(i, opt.attr[i]); } } if( opt.style ){ if( !('padding' in opt.style) ){ opt.padding = 0; } if( !('backgroundColor' in opt.style) ){ opt.style.backgroundColor = '#f9f9f9'; } for(var i in opt.style){ o.style[i] = opt.style[i]; } } /*, ''+(opt.width ? 'width:'+opt.width+'px;' : '')+(opt.height ? 'height:'+opt.height+'px;' : '')+' background-color: '+(opt.backColor || '#f9f9f9')+';display:none;padding:'+(opt.padding || '0')+'px;'); */ o.className = 'asaeditor_dialog'; /* o.setAttribute('id', opt.id); o.setAttribute('_cmd', opt.cmd); o.setAttribute('align', 'center'); o.setAttribute('_autohide', (opt['autohide'] === false ? 'false' : 'true')); */ if( opt.innerHTML ){ o.innerHTML = opt.innerHTML } if( opt.appendChild ){ o.appendChild(opt.appendChild); } d.body.appendChild(o); return o;};asaEd.prototype.createLinkDialog = function (){ try { var zone = {}; viewLayer = 'linkDiv'; this.setFocus(); this.setSelection(); var div2 = asaEditorLib.ce('div', 'padding: 8px 8px 2px 8px;'); var div3 = asaEditorLib.ce('div', 'padding: 0; '); var div4 = asaEditorLib.ce('div', 'padding: 0 0 2px 0;'); var div5 = asaEditorLib.ce('div'); var div7 = asaEditorLib.ce('div', 'padding:2px 0 0 0;text-align:left;'); div7.innerHTML = 'Link tareget : <select id="asaEditor$linkTarget"><option value="_blank">New window</option><option value="_self">Self window</option><option value="_top">Top window</option><option value="_parent">Parent window</option><option value="">None</option></select>'; var div6 = asaEditorLib.ce('div', 'padding-top: 2px; margin-top:4px;margin-bottom:4px;text-align:center;'); var span1 = asaEditorLib.ce('div', 'text-align:left;margin:'); this.setText(span1, this.decode_lang('confirm.inputUrl')); var input1 = asaEditorLib.ce('input', 'font-size: 12px; border: 1px solid #c9c9c9; width: 100%;'); input1.setAttribute('id', 'asaEditor$selectLink'); input1.setAttribute('type', 'text'); input1.setAttribute('value', 'http://'); var input2 = asaEditorLib.ce('input', 'width: 80px;'); input2.setAttribute('type', 'button'); input2.className = 'btn_ok'; input2.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_ok.gif);'; input2.setAttribute('value', this.decode_lang('common.ok')); var input3 = asaEditorLib.ce('input', 'width: 80px;margin-left:4px;'); input3.setAttribute('type', 'button'); input3.className = 'btn_cancel'; input3.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_cancel.gif);'; input3.setAttribute('value', this.decode_lang('common.cancel')); this.attachEventControl(input2, 'click', 'execCreateLink', null, null); this.attachEventControl(input3, 'click', 'forceHideLayer', null, null); div2.appendChild(span1); div2.appendChild(div3); div3.appendChild(div4); div4.appendChild(div5); div5.appendChild(input1); div4.appendChild(div7); div4.appendChild(div6); div6.appendChild(input2); div6.appendChild(input3); this.createContextBox({ attr : { id : viewLayer, _cmd : 'CreateLink' }, appendChild : div2, style : { width : '240px' } }); } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.execCreateLink = function (){ var objects = asaEditorLib.$('asaEditor$selectLink'); var selects = ''; if (objects.value == 'http://') { alert(this.decode_lang('confirm.inputUrl')); objects.focus(); return false; } if(asaEditorLib.Browser.isIE){ if(this.focusObj) { this.focusObj.execCommand('CreateLink', false, objects.value); try { var newLink = this.focusObj.parentElement(); if(newLink.tagName && newLink.tagName.toUpperCase()=='A'){ var to = asaEditorLib.$('asaEditor$linkTarget'); if(to.value){ newLink.setAttribute('target', to.value); } } } catch(e){} } } else { this.execCommand('CreateLink', false, objects.value); try { var newLink = this.oFO.contentWindow.getSelection().focusNode.parentNode; if(newLink.tagName && newLink.tagName.toUpperCase()=='A'){ var to = asaEditorLib.$('asaEditor$linkTarget'); if(to.value){ newLink.setAttribute('target', to.value); } } } catch(e){} } this.forceHideLayer();};asaEd.prototype.execImageInsert = function (){ this.insertHTML(asaEditorLib.$('imgPreview').innerHTML); this.forceHideLayer();};asaEd.prototype.createLanguagesDialog = function(sender, command){ this.setFocus(); this.setSelection(); var box = this.createContextBox({ attr : { id : 'languagesDiv', _cmd : 'Languages' }, style : { width : '100px', padding : '5px' } }); var div = asaEditorLib.ce('div', ''); var div1 = asaEditorLib.ce('div'); var html = ' <form id="languagesFrm" style="margin:0;" onsubmit="return false"><ol style="font-size:9pt;text-align:left;list-style-type:none;margin:0;padding:0;" id="languagesBox"></ol></form>'; div1.innerHTML = html; div.appendChild(div1); box.appendChild(div); var ol = asaEditorLib.$('languagesBox'); for(var lang in asaEditorConfig.languages){ (function(ed, o){ var li = asaEditorLib.ce('li'); var input = asaEditorLib.ce2('input', 'asaEditor_languages'); input.setAttribute('type', 'radio'); input.setAttribute('id', 'asaEditor_languages_'+lang+''); input.setAttribute('value', lang); li.appendChild(input); var label = asaEditorLib.ce('label'); label.setAttribute('for', 'asaEditor_languages_'+lang+''); label.innerHTML = decodeURIComponent(asaEditorConfig.languages[lang]); li.appendChild(label); o.appendChild(li); ed.attachEventControl(input, 'click', 'toggleEditorLanguage', null, null); if(ed.lang == lang){ input.checked = true; } })(this, ol); }};asaEd.prototype.createCharacterDialog = function(sender){ var chars = [], h = '', x = asaEditorLib, ed = this, lang = asaEditor_lang[this.lang];/* chars.push("｛｝〔〕〈〉《》「」『』【】‘’“”、。·‥…§※☆★○●◎◇◆□■△▲▽▼◁◀▷▶♤♠♡♥♧♣⊙◈▣◐◑▒▤▥▨▧▦▩±×÷≠≤≥∞∴°′″∠⊥⌒∂≡≒≪≫√∽∝∵∫∬∈∋⊆⊇⊂⊃∪∩∧∨￢⇒⇔∀∃´～ˇ˘˝˚˙¸˛¡¿ː∮∑∏♭♩♪♬㉿→←↑↓↔↕↗↙↖↘㈜№㏇™㏂㏘℡♨☏☎☜☞¶†‡®ªº♂♀".split('')); chars.push("½⅓⅔¼¾⅛⅜⅝⅞¹²³⁴ⁿ₁₂₃₄ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹ￦$￥￡€℃Å℉￠¤‰㎕㎖㎗ℓ㎘㏄㎣㎤㎥㎦㎙㎚㎛㎜㎝㎞㎟㎠㎡㎢㏊㎍㎎㎏㏏㎈㎉㏈㎧㎨㎰㎱㎲㎳㎴㎵㎶㎷㎸㎹㎀㎁㎂㎃㎄㎺㎻㎼㎽㎾㎿㎐㎑㎒㎓㎔Ω㏀㏁㎊㎋㎌㏖㏅㎭㎮㎯㏛㎩㎪㎫㎬㏝㏐㏓㏃㏉㏜㏆".split('')); chars.push("㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩㉪㉫㉬㉭㉮㉯㉰㉱㉲㉳㉴㉵㉶㉷㉸㉹㉺㉻ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮㈀㈁㈂㈃㈄㈅㈆㈇㈈㈉㈊㈋㈌㈍㈎㈏㈐㈑㈒㈓㈔㈕㈖㈗㈘㈙㈚㈛⒜⒝⒞⒟⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵⑴⑵⑶⑷⑸⑹⑺⑻⑼⑽⑾⑿⒀⒁⒂".split('')); chars.push("ㄱㄲㄳㄴㄵㄶㄷㄸㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅃㅄㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣㅥㅦㅧㅨㅩㅪㅫㅬㅭㅮㅯㅰㅱㅲㅳㅴㅵㅶㅷㅸㅹㅺㅻㅼㅽㅾㅿㆀㆁㆂㆃㆄㆅㆆㆇㆈㆉㆊㆋㆌㆍㆎ".split('')); chars.push("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωÆÐĦĲĿŁØŒÞŦŊæđðħIĳĸŀłłœßþŧŋŉБГДЁЖЗИЙЛПЦЧШЩЪЫЬЭЮЯбвгдёжзийлпфцчшщъыьэюя".split('')); chars.push("ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ".split(''));*/ chars.push(asaEditor_chars['a'].split(',')); chars.push(asaEditor_chars['b'].split(',')); /*//if(asaEditorGlobal['charset'] == 'utf-8'){*/ chars.push(asaEditor_chars['c'].split(',')); chars.push(asaEditor_chars['d'].split(',')); chars.push(asaEditor_chars['e'].split(',')); chars.push(asaEditor_chars['f'].split(',')); /*//}*/ ed.setFocus(); ed.setSelection(); h += '<ul id="asaEditor_characterTab">'; h += '<li class="itemActive"><a href="#chars1">'+lang['character']['normal']+'</a></li>'; h += '<li><a href="#chars2">'+lang['character']['number']+'</a></li>'; h += '<li><a href="#chars3">'+lang['character']['circle']+'</a></li>'; h += '<li><a href="#chars4">'+lang['character']['korean']+'</a></li>'; h += '<li><a href="#chars5">'+lang['character']['greece']+'</a></li>'; h += '<li><a href="#chars6">'+lang['character']['japanese']+'</a></li>'; h += '</ul>'; h += '<ul id="asaEditor_characterList1" class="characterList" style="display:block;"></ul>'; h += '<ul id="asaEditor_characterList2" class="characterList" style="display:none;"></ul>'; h += '<ul id="asaEditor_characterList3" class="characterList" style="display:none;"></ul>'; h += '<ul id="asaEditor_characterList4" class="characterList" style="display:none;"></ul>'; h += '<ul id="asaEditor_characterList5" class="characterList" style="display:none;"></ul>'; h += '<ul id="asaEditor_characterList6" class="characterList" style="display:none;"></ul>'; var box = this.createContextBox({ attr : { id : 'characterDiv', _cmd : 'Character' }, innerHTML:h, style : { width : '433px', height : '242px', padding : 0, overflow: 'hidden', margin:0 } }); var p = x.ce('p'), t = x.ce('input', {'type':'text'}), lbl = x.ce('label'), setBtn = x.ce('button', {'type':'button'}); setBtn.innerHTML = "<span>"+lang['common']['input']+"</span>"; lbl.innerHTML = lang['character']['selected']; p.appendChild(lbl); p.appendChild(t); p.appendChild(setBtn); box.appendChild(p); x.addEvent(setBtn, 'click', function(){ ed.insertHTML(t.value); ed.forceHideLayer(); }); function setCharacter(o, val){ o.value += val; } for(var i = 0; i<chars.length; i++){ var b = x.$('asaEditor_characterList'+(i+1)); for(var j=0; j<180; j++){ var l = x.ce('li'); if(j < chars[i].length ){ var bw = x.ce('button'); bw.innerHTML = '<span>' + chars[i][j] + '</span>'; bw.setAttribute('_value', asaEditorLib.decode_lang(chars[i][j])); x.addEvent(bw, 'click', function(){ setCharacter(t, this.getAttribute('_value')); }); l.appendChild(bw); } b.appendChild(l); } } var btns = x.$('asaEditor_characterTab').getElementsByTagName('a'); x.each(btns, function(b, i){ x.addEvent(b, 'click', function(e){ e = e || event; x.each(btns, function(b2, i2){ x.removeClassName(b2.parentNode, 'itemActive'); x.$('asaEditor_characterList'+(i2+1)).style.display='none'; }); x.addClassName(this.parentNode, 'itemActive'); x.$('asaEditor_characterList'+(i+1)).style.display='block'; x.cancelEvent(e); }); });};asaEd.prototype.createBlockQuoteDialog = function(sender){ var ed = this, x = asaEditorLib, o, o2; var box = this.createContextBox({ attr : { id : 'blockquoteDiv', _cmd : 'BlockQuote' }, style : { width : '253px', height : '48px', padding : 0, __overflow: 'hidden', margin:0 } }); o = x.ce('ul'); var createButton = function(s, css){ var o = x.ce('li'), o2 = x.ce('button', 'background:url('+ed.configs.imgDir+'/blockquote_'+s+'.gif)'); x.addEvent(o2, 'click', function(){ ed.setBlockQuote(sender, css); ed.forceHideLayer(); ed.setFocus(); }); o2.innerHTML = '<span> </span>'; o.appendChild(o2); return o; }; o.appendChild(createButton('1', {'margin':'0 15px', 'border-left':'#cccccc 3px solid', 'padding':'0 10px 0 10px'})); o.appendChild(createButton('2', {'padding':'10px 10px 10px 10px', 'margin':'0 15px', 'border':'#D9D9D9 1px solid'})); o.appendChild(createButton('3', {'padding':'10px 10px 10px 10px', 'margin':'0 15px', 'border':'#D9D9D9 1px solid', 'background':'#fbfbfb'})); o.appendChild(createButton('4', {'padding':'10px 10px 10px 10px', 'margin':'0 15px', 'border':'#707070 2px solid'})); o.appendChild(createButton('5', {'padding':'10px 10px 10px 10px', 'margin':'0 15px', 'border':'#707070 1px dashed'})); o.appendChild(createButton('6', {'padding':'10px 10px 10px 10px', 'margin':'0 15px', 'border':'#707070 1px dashed', 'background':'#fbfbfb'})); box.appendChild(o); };asaEd.prototype.setBlockQuote = function(sender, css){ var ed = this, x = asaEditorLib; ed.setFocus(); ed.setSelection(); var s = ed.getSelection(); if( s == '' ) { return; } var r = s.getRangeAt(0); var pq = ed.getDoc().createElement('blockquote'); if(css){ for(var i in css){ pq.style[i] = css[i]; } } pq.appendChild(r.extractContents()); r.insertNode(pq); r.setEndAfter(pq);};asaEd.prototype.toggleEditorLanguage = function(){ var frm = asaEditorLib.$('languagesFrm'); var ips = frm['asaEditor_languages']; for(var i=0, len=ips.length; i<len; i++){ var e = ips[i]; if(e.checked == true){ if(this.lang == e.value){ break; } if(this.configs.useMultiLanguage && asaEditorGlobal['charset'] == 'utf-8'){ this.saveConfig({'lang':e.value}); } this.reload({lang:e.value}); break; } } this.forceHideLayer();};asaEd.prototype.setLineBreak = function(sender){ this.setFocus(); this.setSelection(); var btn = asaEditorLib.$(this.editorId+'_btn_LineBreak'); if(this.configs.newLine == 'br'){ btn.src = this.configs.imgDir+'/linebreak_no.gif?'+this.timeVal; this.configs.newLine = ''; } else { btn.src = this.configs.imgDir+'/linebreak.gif?'+this.timeVal; this.configs.newLine = 'br'; }};asaEd.prototype.createImageDialog = function (){ try { var zone = {}; viewLayer = 'imgDiv'; this.setFocus(); this.setSelection(); var div2 = asaEditorLib.ce('div', 'padding: 0 0 3px 0; font-size:9pt;text-align:left;margin-top:5px;'); var div3 = asaEditorLib.ce('div', 'padding: 2px; border: 1px solid #c9c9c9; background: ; font-size:9pt;display:'+(this.configs.imageUpload.use ? '' : 'none')+';'); var div4 = asaEditorLib.ce('div', 'padding: 2px; border: 1px solid #c9c9c9; background: ; font-size:9pt;display:'+(this.configs.imageUpload.use ? 'none' : '')+';'); var div5 = asaEditorLib.ce('div', 'padding: 2px; border: 1px solid #c9c9c9; background: ; font-size:9pt;display:none;'); var div6 = asaEditorLib.ce('div', 'font-size:9pt;margin-top:4px;'); var div7 = asaEditorLib.ce('div', 'padding: 2px; margin-top:2px;text-align:center;'); var input1 = asaEditorLib.ce('input', 'width: 60px;'); var input3 = asaEditorLib.ce('input', 'width: 60px;margin-left:4px;'); this.createContextBox({ attr : { id : viewLayer, _cmd : 'InsertImage' }, innerHTML : '<form action="'+this.configs.imageUpload.url+'" method="post" target="imageUploadFrame" name="asaEditorImageForm" id="'+this.editorId+'_asaEditorImageForm" enctype="multipart/form-data" style="margin:0;padding:0;"></form>', style : { width : '240px', padding : '6px' } }); input1.setAttribute('type', 'button'); input1.className = 'btn_ok'; input1.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_ok.gif);'; input1.setAttribute('value', this.decode_lang('common.ok')); input3.setAttribute('type', 'button'); input3.className = 'btn_cancel'; input3.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_cancel.gif);'; input3.setAttribute('value', this.decode_lang('common.cancel')); this.attachEventControl(input1, 'click', 'execImageInsert', null, null); this.attachEventControl(input3, 'click', 'forceHideLayer', null, null); div2.innerHTML = '<span style="margin-right:1px;cursor:hand;padding:3px;background-color:;border: 1px solid #c9c9c9;' + (this.configs.imageUpload.use ? '' : 'display:none;') + '" onclick="return false">'+this.decode_lang('image.upload')+'</span>' + '<span style="margin-right:1px;cursor:hand;padding:3px;background-color:'+(this.configs.imageUpload.use ? '#ddd' : '')+';border: 1px solid #c9c9c9;" onclick="return false">'+this.decode_lang('image.imageLink')+'</span>' + '<span style="cursor:hand;padding:3px;background-color:#ddd;border: 1px solid #c9c9c9;" onclick="return false">'+this.decode_lang('image.layout')+'</span>'; div3.innerHTML = ' <div class="asaEditorPanel">' + ' <input type="file" size="10" name="imgFile" id="imgFile" value="" style="width: 150px; font-size: 12px;border: 1px solid #c9c9c9;">' + ' <input type="button" class="btn_upload" value="'+this.decode_lang('common.upload')+'" style="background-image:url('+this.configs.imgDir+'/btn_upload.gif)"/>' + ' </div>' + ' <div class="asaEditorPanel">' + ' '+this.decode_lang('confirm.fileSelectAndUpload')+'' + ' </div>'; div4.innerHTML = ' <div class="asaEditorPanel">' + ' <span>'+this.decode_lang('image.path')+' : </span>' + ' <input type="text" id="imgUrl" value="http://" style="width: 160px; font-size: 12px; margin-left: 5px;border: 1px solid #c9c9c9;">' + ' </div>' + ' <div class="asaEditorPanel">' + ' '+this.decode_lang('common.ex')+') http://abc.com/image/logo.gif' + ' </div>'; div5.innerHTML = '' + ' <table width="220" border="0" cellpadding="0" cellspacing="0">' + ' <caption class="asaEditorTitle">'+this.decode_lang('image.imageAlign')+'</caption>' + ' <colgroup><col width="80"/><col width="*"/></colgroup>' + ' <tr height="23">' + ' <td style="padding-left:10px;" >'+this.decode_lang('image.alignType')+' : </td>' + ' <td>' + this.createAlignSelectBox() + '</td>' + ' </tr>' + ' <tr height="23">' + ' <td style="padding-left:10px;" >'+this.decode_lang('image.border')+' : </td>' + ' <td><input type="text" id="imageBorder" style="width:100px; font-size: 9pt;border: 1px solid #c9c9c9;"></td>' + ' </tr>' + ' </table></div>' + ' <div>' + ' <table width="220" border="0" cellpadding="0" cellspacing="0">' + ' <caption class="asaEditorTitle">'+this.decode_lang('image.imageSize')+'</caption>' + ' <colgroup><col width="80"/><col width="*"/></colgroup>' + ' <tr height="23">' + ' <td style="padding-left:10px;" >'+this.decode_lang('common.width')+' : </td>' + ' <td ><input type="text" id="imageWidth" style="width:100px; font-size: 9pt;border: 1px solid #c9c9c9;"></td>' + ' </tr>' + ' <tr height="23">' + ' <td style="padding-left:10px;" >'+this.decode_lang('common.height')+' : </td>' + ' <td><input type="text" id="imageHeight" style="width:100px; font-size: 9pt;border: 1px solid #c9c9c9;" ></td>' + ' </tr>' + ' </table>'; div6.innerHTML = '<fieldset style="padding-bottom: 5px; text-align: left;">' + ' <legend>'+this.decode_lang('common.preview')+'</legend>' + ' <div align="center">' + ' <div id="imgPreview" style="width:200px;height:80px;overflow-x:auto;overflow-y:auto;text-align:center;"></div>' + ' </div>' + '</fieldset>'; div7.innerHTML = '<iframe id="imageUploadFrame" name="imageUploadFrame" src="about:blank" style="width:200px;height:200px;display:none;"></iframe>'; var tabs = div2.getElementsByTagName('SPAN'); for(var i=0; i<tabs.length; i++) { (function(i, a, b, c){ tabs[i].onclick = function(){ a.style.backgroundColor = (i == 0 ? '#fff' : '#ddd'); b.style.backgroundColor = (i == 1 ? '#fff' : '#ddd'); c.style.backgroundColor = (i == 2 ? '#fff' : '#ddd'); div3.style.display = (i==0?'':'none'); div4.style.display = (i==1?'':'none'); div5.style.display = (i==2?'':'none'); } }(i, tabs[0], tabs[1], tabs[2])); } var inputs = div3.getElementsByTagName('INPUT'); for(var i=0; i<inputs.length; i++){ if(inputs[i].type.toLowerCase() == 'button'){ this.attachEventControl(inputs[i], 'click', 'uploadImageFile', null, null); break; } } var form = asaEditorLib.$(this.editorId + '_asaEditorImageForm'); for(var i in this.configs.imageUpload.params){ var hidden = asaEditorLib.ce('input'); hidden.setAttribute('type', 'hidden'); hidden.setAttribute('name', i); hidden.setAttribute('value', this.configs.imageUpload.params[i]); form.appendChild(hidden); } form.appendChild(div2); form.appendChild(div3); form.appendChild(div4); form.appendChild(div5); form.appendChild(div6); form.appendChild(div7); div7.appendChild(input1); div7.appendChild(input3); asaEditorLib.addEvent(asaEditorLib.$('imgUrl'), 'blur', this.previewUploadedImage); asaEditorLib.addEvent(asaEditorLib.$('imageBorder'), 'blur', this.previewUploadedImage); asaEditorLib.addEvent(asaEditorLib.$('imageWidth'), 'blur', this.previewUploadedImage); asaEditorLib.addEvent(asaEditorLib.$('imageHeight'), 'blur', this.previewUploadedImage); asaEditorLib.addEvent(asaEditorLib.$('imageAlign'), 'change', this.previewUploadedImage); } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.uploadImageFile = function (){ var zone = {}; zone['obj' ] = asaEditorLib.$('imgFile'); if (!zone['obj'].value) { alert(this.decode_lang('confirm.noneImage')); return; } var lastDot = zone['obj'].value.lastIndexOf('.'); if(lastDot < 0) { alert(this.decode_lang('confirm.invalidExt')); return; } var fileExt = zone['obj'].value.substring(lastDot + 1).toLowerCase(); var validExt = false; (function(){ var validExts = ['gif', 'jpg', 'jpeg', 'png']; for(var i=0; i<validExts.length; i++) { if(validExts[i] == fileExt){ validExt = true; break; } } }()); if( ! validExt ){ alert(this.decode_lang('confirm.invalidExt')); return; } var frm = asaEditorLib.$(this.editorId + '_asaEditorImageForm'); frm.submit();};asaEd.prototype.createAlignSelectBox = function (){ var zone = {}; zone['arr' ] = { '' : this.decode_lang('common.defaultValue'), 'left' : this.decode_lang('common.left'), 'right' : this.decode_lang('common.right'), 'top' : this.decode_lang('common.top'), 'texttop' : this.decode_lang('common.texttop'), 'middle' : this.decode_lang('common.middle'), 'absmiddle' : this.decode_lang('common.absmiddle'), 'baseline' : this.decode_lang('common.baseline'), 'bottom' : this.decode_lang('common.bottom'), 'absbottom' : this.decode_lang('common.absbottom'), 'center' : this.decode_lang('common.center') }; zone['option' ] = ''; for (var i in zone['arr']) { zone['option'] += '<option value="' + i + '">' + zone['arr'][i] + '</option>'; } zone['select' ] = '<select id="imageAlign" style="font-size: 9pt; width: ' + this.getStyleInto(100, 96) + 'px;">' + zone['option'] + '</select>'; return zone['select'];};asaEd.prototype.createMediaDialog = function (command){ try { var zone = {}; var names = this.decode_lang('common.flash'); var example = this.decode_lang('common.ex')+') http://abc.com/flash/flash.swf'; viewLayer = command + 'Box'; this.setFocus(); this.setSelection(); var div2 = asaEditorLib.ce('div', 'padding:0;text-align:left;'); var div3 = asaEditorLib.ce('div', ''); var div4 = asaEditorLib.ce('div', 'margin-bottom: 4px;text-align:left;'); var div5 = asaEditorLib.ce('div', 'margin-top: 4px;margin-bottom:10px; text-align:center;'); var div7 = asaEditorLib.ce('div', 'margin-top: 3px;'); var fieldset = asaEditorLib.ce('fieldset'); var legend = asaEditorLib.ce('legend'); legend.innerHTML = this.decode_lang('common.preview'); fieldset.appendChild(legend); var div8 = asaEditorLib.ce('div', 'margin:0;padding:0;'); fieldset.appendChild(div8); var div9 = asaEditorLib.ce('div', 'padding:0;margin-top: 4; margin-bottom:2px; text-align: center;'); if (command == 'movie') { names = this.decode_lang('common.media'); example = this.decode_lang('common.ex')+') http://abc.com/movie/movie.avi'; div8.style.cssText = 'width: 100%; height: 160px'; div8.innerHTML = this.getMovieObject('100%', '160', ''); } else { div8.style.cssText ='width: 100%; height: 120px'; } var span1 = asaEditorLib.ce('span', 'font-size: 12px; color: #757575; font-weight: bold;'); var span2 = asaEditorLib.ce('span'); var span3 = asaEditorLib.ce('span'); var span4 = asaEditorLib.ce('span'); var span5 = asaEditorLib.ce('span'); var span6 = asaEditorLib.ce('span', 'font-size: 12px; color: #ffffff; font-weight: bold;padding:4px 2px 0 2px;width:210px;'); var input1 = asaEditorLib.ce('input', 'font-size: 12px; border: 1px solid #c9c9c9; width: 100%;'); var input2 = asaEditorLib.ce('input', 'font-size: 12px; border: 1px solid #c9c9c9; width: 50px;'); var input3 = asaEditorLib.ce('input', 'font-size: 12px; border: 1px solid #c9c9c9; width: 50px;'); var input4 = asaEditorLib.ce('input', 'width: 70px;'); var input5 = asaEditorLib.ce('input', 'width: 70px;margin-left:2px;'); var input6 = asaEditorLib.ce('input', 'width: 70px;margin-left:2px;'); input4.setAttribute('type', 'button'); input4.className = 'btn_ok'; input4.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_ok.gif);'; input4.setAttribute('value', ' '+this.decode_lang('common.ok')+' '); input5.setAttribute('type', 'button'); input5.className = 'btn_cancel'; input5.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_cancel.gif);'; input5.setAttribute('value', ' '+this.decode_lang('common.cancel')+' '); input6.setAttribute('type', 'button'); input6.className = 'btn_preview'; input6.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_preview.gif);'; input6.setAttribute('value', ' '+this.decode_lang('common.preview')+' '); var table = asaEditorLib.ce('table'); table.width='100%'; table.cellPadding = table.cellSpacing = 0; var row = table.insertRow(0); var col = row.insertCell(0); col.style.textAlign='left'; col.appendChild(span4); col.appendChild(input2); col = row.insertCell(1); col.appendChild(span5); col.appendChild(input3); this.setText(span2, names + ' '+this.decode_lang('confirm.inputUrl')); this.setText(span3, ' '+example); this.setText(span4, this.decode_lang('common.width')+' : '); this.setText(span5, this.decode_lang('common.height')+' : '); div8.setAttribute('id', command + 'Preview'); input1.setAttribute('id', command + 'Input'); input1.setAttribute('type', 'text'); input1.setAttribute('value', 'http://'); input2.setAttribute('id', command + 'Width'); input2.setAttribute('type', 'text'); input2.setAttribute('value', '100'); input3.setAttribute('id', command + 'Height'); input3.setAttribute('type', 'text'); input3.setAttribute('value', '80'); this.attachEventControl(input4, 'click', 'createVideoDialog', 1, command); this.attachEventControl(input5, 'click', 'forceHideLayer', null, null); this.attachEventControl(input6, 'click', 'createVideoDialog', 3, command); div2.appendChild(span1); div2.appendChild(div3); div3.appendChild(span2); div3.appendChild(input1); div3.appendChild(div4); div4.appendChild(span3); div3.appendChild(div5); div5.appendChild(table); div2.appendChild(div7); div7.appendChild(fieldset); div9.appendChild(input4); div9.appendChild(input5); div9.appendChild(input6); var c = this.createContextBox({ attr : { id : viewLayer, _cmd : command }, appendChild : div2, style : { width : '245px', padding : '6px' } }); c.appendChild(div9); } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.createVideoDialog = function (mode, command){ var htmls = ''; if(document.all){ this.focusObj.select(); } switch (mode) { case 1 : htmls = this.createMediaPreview(command); if (!htmls) { return false; } this.insertHTML(htmls); this.forceHideLayer(); break; case 3 : htmls = this.createMediaPreview(command); if (!htmls) { return false; } asaEditorLib.$(command + 'Preview').innerHTML = htmls; break; }};asaEd.prototype.createMediaPreview = function (command){ var url = asaEditorLib.$(command + 'Input'); var w = asaEditorLib.$(command + 'Width'); var h = asaEditorLib.$(command + 'Height'); var wv = (w.value == '') ? 10 : w.value; var hv = (h.value == '') ? 10 : h.value; var values = url.value.replace(/http\:\/\//g, ''); if (url.value.match(/https\:\/\//g)) { values = url.value.replace(/https\:\/\//g, ''); } if (command == 'flash') { if (values == '') { alert(this.decode_lang('confirm.inputFlashUrl')); url.focus(); return false; } return '<embed src="' + url.value + '" width="' + wv + '" height="' +hv + '" type="application/x-shockwave-flash" play="true" loop="true" menu="true"></embed>'; } else { if (values == '') { alert(this.decode_lang('confirm.inputMediaUrl')); url.focus(); return false; } return this.getMovieObject(wv, hv, url.value); }};asaEd.prototype.getMovieObject = function (w, h, v){ return '<embed src="' + v + '" volume="100" width="' + w + '" height="' + h + '" type="application/x-mplayer2" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"></embed>';};asaEd.prototype.createTableDialog = function (){ try { var zone = {}; viewLayer = 'tableBox'; this.setFocus(); this.setSelection(); var div2 = asaEditorLib.ce('div', ''); var div3 = asaEditorLib.ce('div', ''); var div4 = asaEditorLib.ce('div', 'margin-top: 2px;'); var div5 = asaEditorLib.ce('div', 'margin-top: 2px;'); var div6 = asaEditorLib.ce('div', 'margin-top: 4px;text-align:center;'); var input1 = asaEditorLib.ce('input', 'width: 80px;'); var input2 = asaEditorLib.ce('input', 'width: 80px;margin-left:4px;'); input1.setAttribute('type', 'button'); input1.className = 'btn_ok'; input1.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_ok.gif);'; input1.setAttribute('value', ' '+this.decode_lang('common.ok')+' '); input2.setAttribute('type', 'button'); input2.className = 'btn_cancel'; input2.style.cssText = 'background-image:url('+this.configs.imgDir+'/btn_cancel.gif);'; input2.setAttribute('value', ' '+this.decode_lang('common.cancel')+' '); this.attachEventControl(input1, 'click', 'insertTable', null, null); this.attachEventControl(input2, 'click', 'forceHideLayer', null, null); div3.innerHTML = '<fieldset style="_height: 35px; padding-bottom: 5px; text-align: left; font-size:9pt;">' + ' <legend>'+this.decode_lang('common.table')+' '+this.decode_lang('common.setting')+'</legend>' + ' <table border="0" width="100%" cellpadding="0" cellspacing="0"><tr><td width="50%">' + ' <span style="font-size:9pt;padding-left: 5px;">'+this.decode_lang('table.rowCount')+' : </span>' + ' <input type="text" id="tableWidth" value="2" style="width: 36px; font-size: 12px; margin-left: 3px;border: 1px solid #c9c9c9;"></td><td>' + ' <span style="font-size:9pt;padding-left: 5px;">'+this.decode_lang('table.colCount')+' : </span>' + ' <input type="text" id="tableHeight" value="2" style="width: 36px; font-size: 12px; margin-left: 3px;border: 1px solid #c9c9c9;">' + ' </td></tr></table>' + '</fieldset>'; div4.innerHTML = '<fieldset style="_height: 35px; padding-bottom: 5px; text-align: left;">' + ' <legend>'+this.decode_lang('common.table')+' '+this.decode_lang('common.align')+'</legend>' + ' <table border="0" cellpadding="0" cellspacing="0" width="98%" align="center">' + ' <tr>' + ' <td width="45%" style="font-size:9pt;padding-left:2px;">'+this.decode_lang('common.align')+' : ' + ' <select id="tableAlign" style="font-size:9pt;">' + ' <option value="left">'+this.decode_lang('common.left')+'</option>' + ' <option value="center">'+this.decode_lang('common.center')+'</option>' + ' <option value="right">'+this.decode_lang('common.right')+'</option>' + ' </select></td>' + ' <td width="55%" align="right" style="padding-right:2px;">' + ' <div style="padding:0; padding-left: 2px;font-size:9pt;">' + ' '+this.decode_lang('table.cellPadding')+' : <input type="text" value="2" id="tablePadding" style="font-size:9pt;border: 1px solid #c9c9c9;width:40px;">' + ' </div>' + ' </td>' + ' </tr>' + ' </table>' + '</fieldset>'; div5.innerHTML = '<fieldset style="_height: 35px; padding-bottom: 5px; text-align: left;">' + ' <legend>'+this.decode_lang('common.border')+' '+this.decode_lang('common.setting')+'</legend>' + ' <table border="0" cellpadding="0" cellspacing="0" width="98%" align="center">' + ' <tr>' + ' <td width="40%" style="font-size:9pt;padding-left:5px;">'+this.decode_lang('table.line')+this.decode_lang('table.thickness')+' : ' + ' <input type="text" value="1" id="tableBorder" style="width: 40px; font-size:9pt;border: 1px solid #c9c9c9;">' + ' </td>' + ' <td width="60%" align="right" style="font-size:9pt;padding-right:5px;">'+this.decode_lang('common.color')+' :' + ' <select id="tableBgcolor" style="font-size:9pt; font-family: Tahoma,'+this.decode_lang('common.defaultFont')+'">' + ' <option value="">'+this.decode_lang('common.base')+this.decode_lang('common.color')+'</option>' + ' <option value="#000000" style="color:#000000" selected="selected">#000000</option>' + ' <option value="#333333" style="color:#333333">#333333</option>' + ' <option value="#666666" style="color:#666666">#666666</option>' + ' <option value="#999999" style="color:#999999">#999999</option>' + ' <option value="#CCCCCC" style="color:#CCCCCC">#CCCCCC</option>' + ' <option value="#FFFFFF" style="color:#E1E1E1">#FFFFFF</option>' + ' <option value="#FF0000" style="color:#FF0000">#FF0000</option>' + ' <option value="#00FF00" style="color:#00FF00">#00FF00</option>' + ' <option value="#0000FF" style="color:#0000FF">#0000FF</option>' + ' <option value="#C0C0C0" style="color:#C0C0C0">#C0C0C0</option>' + ' <option value="#008000" style="color:#008000">#008000</option>' + ' <option value="#800000" style="color:#800000">#800000</option>' + ' <option value="#808000" style="color:#808000">#808000</option>' + ' <option value="#000080" style="color:#000080">#000080</option>' + ' <option value="#808080" style="color:#808080">#808080</option>' + ' <option value="#008080" style="color:#008080">#008080</option>' + ' <option value="#800080" style="color:#800080">#800080</option>' + ' </select></td></tr>' + ' </table>' + '</fieldset>'; div6.appendChild(input1); div6.appendChild(input2); div2.appendChild(div3); div2.appendChild(div4); div2.appendChild(div5); div2.appendChild(div6); var c = this.createContextBox({ attr : { id : viewLayer, _cmd : 'table' }, appendChild : div2, style : { width : '260px', padding: '6px' } }); } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.insertTable = function (){ var wcnt = asaEditorLib.$('tableWidth').value; var hcnt = asaEditorLib.$('tableHeight').value; var tborder = asaEditorLib.$('tableBorder').value; var talign = asaEditorLib.$('tableAlign').value; var tpadding= asaEditorLib.$('tablePadding').value; var tbgcolor= asaEditorLib.$('tableBgcolor').value; var bgcolor = (tbgcolor == '') ? '' : tbgcolor; var table = ''; var editor = this; var getSelectedNode = function() { var w = editor.getWin(); var d = editor.getDocument(); var node,selection; if (w.getSelection) { selection = w.getSelection(); node = selection.anchorNode; } if (!node && d.selection) { selection = d.selection; var range = selection.getRangeAt ? selection.getRangeAt(0) : selection.createRange(); node = range.commonAncestorContainer ? range.commonAncestorContainer : range.parentElement ? range.parentElement() : range.item(0); } if (node) { return (node.nodeName == "#text" ? node.parentNode : node); } }; var editorWidth = asaEditorLib.getWidth(this.getDocument().body); editorWidth = (editorWidth>30) ? (editorWidth-30) : editorWidth; var cellWidth = Math.floor(editorWidth/wcnt); editorWidth = cellWidth * wcnt; var width = ' width="' + editorWidth + 'px"'; var borderStyle = 'border-width:'+tborder+'px;border-color:'+bgcolor+';border-style:solid;border-collapse:collapse;'; table = '<table style="'+this.fontStyle+';'+borderStyle+'" border="0"' + width + ' cellpadding="' + tpadding + '" cellspacing="" align="' + talign + '">'; for (var i=0; i<wcnt; i++) { table += '<tr>'; for (var j=0; j<hcnt; j++) { table += '<td width="'+cellWidth+'" style="'+borderStyle+'">&nbsp;</td>'; } table += '</tr>'; } table += '</table>'; this.insertHTML(table); this.forceHideLayer();};asaEd.prototype.createColorDialog = function (sender, command){ try { var zone = {}; var w = window, d = document; viewLayer = 'colorBox'; if( asaEditorLib.$(viewLayer) ) return; this.setFocus(); this.setSelection(); var div2 = asaEditorLib.ce('div', 'margin:0;padding:0;'); div2.id = 'asaEditor_ColorDialog'; div2.innerHTML = '<table border="0" cellpadding="0" cellspacing="2" style="margin:0;height:20px" width="90%">' + '<tr align="">' + ' <td style="font-size:9pt">' + ' '+this.decode_lang('common.color')+' : ' + ' </td>' + ' <td style="width:50px;border:1px solid #FFFFFF;background-color:#000000;" id="select_color" bgcolor="#000000">' + ' ' + ' </td>' + ' <td style="width:54px;border:1px solid #565656;text-align:center;font-size:8pt;" id="select_color_code"></td><td><input type="button" id="asaEdit_btnColorInsert" class="btn_ok" value="'+this.decode_lang('common.input')+'" style="background-image:url('+this.configs.imgDir+'/btn_input.gif)"></tr>' + '</table>'; var div5 = asaEditorLib.ce('div', 'margin:2px 0 0 0;padding:0;'); (function(box){ var c, r, t = asaEditorLib.ce('table'); t.cellPadding = t.cellSpacing = 1; t.border = 0; t.style.cssText = "width:230px;margin:0;background-color:#000000;"; t.onselectstart = t.ondragstart = null; for(var i=0, len=Cpk.colors.length; i<len; i++){ if(i % 24 == 0) r = t.insertRow(t.rows.length); c = r.insertCell(r.cells.length); c.style.cssText = "height:10px;padding:2px;background-color:"+Cpk.colors[i]+";"; c.onclick = function(){ var color = this.style.backgroundColor; if (color.indexOf('#') == -1) color = Cpk.cth(color); asaEditorLib.$('select_color').style.backgroundColor = color; asaEditorLib.$('select_color_code').innerHTML = color; }; } box.appendChild(t); })(div5); var c = this.createContextBox({ attr : { id : viewLayer, _cmd : command }, appendChild : div2, style : { 'width' : (asaEditorLib.Browser.isIE ? '244px' : '238px'), 'clear' : 'both', 'margin' : '0', 'padding' : '0 0 0 6px', 'text-align':'center' } }); c.appendChild(div5); var div3 = asaEditorLib.ce('div', 'display:none;padding: 0; margin:2px 0 0 0; font-size:9pt;'); div3.id = 'asaEditor_DetailColor'; c.appendChild(div3); Cpk.setRender(div3, { imgDir:this.configs.imgDir, onselected:function(color){ asaEditorLib.$('select_color').style.backgroundColor = color; asaEditorLib.$('select_color_code').innerHTML = color; } }); (function(editor, cc){ var divBtn = asaEditorLib.ce('div', 'text-align:right;padding: 0; margin:4px 0 8px 0; font-size:9pt;'); var btn = asaEditorLib.ce('input', 'background-image:url('+editor.configs.imgDir+'/btn_more_on.gif);'); btn.type = 'button'; btn.className='btn_more'; btn.onclick = function(){ var d = asaEditorLib.$('asaEditor_DetailColor'); if(d.style.display=='none'){ this.style.cssText = 'background-image:url('+editor.configs.imgDir+'/btn_more_off.gif);'; d.style.display=''; } else { this.style.cssText = 'background-image:url('+editor.configs.imgDir+'/btn_more_on.gif);'; d.style.display='none'; } }; divBtn.appendChild(btn); cc.appendChild(divBtn); })(this, c); var btn = asaEditorLib.$('asaEdit_btnColorInsert'); if(btn){ this.attachEventControl(btn, 'click', 'insertColor', command, null); } } catch (e) { alert(this.decode_lang('confirm.notLoaded')); }};asaEd.prototype.insertColor = function (command){ var selects = ''; var d = document; var objects = asaEditorLib.$('select_color_code'); selects = (asaEditorLib.Browser.isIE) ? this.focusObj.text : this.oFO.contentWindow.getSelection().toString(); if(d.all){ this.focusObj.select(); } switch (command) { case 'forecolor' : this.execCommand('ForeColor', false, objects.innerHTML); break; case 'BackColor' : this.execCommand('BackColor', false, objects.innerHTML); break; } this.forceHideLayer();};asaEd.prototype.createFormatBlockBox = function(){ var editor = this, w = window, d = document; var top = this.toolbarObj; var caption = this.decode_lang('Cmd.FontName'); var html = '<ul style="margin:0; padding:3px 3px 3px 3px;">'; for(var i=1; i<=6; i++) { html += '<li style="padding:0 8px 0 6px;font-size:12px;list-style-type:none;text-align: left; cursor: pointer;" val="h'+i+'">'+this.decode_lang('common.heading')+i+'</li>'; } html = html+'</ul>'; var c = this.createContextBox({ attr : { id : 'formatblockDiv', _cmd : 'FormatBlock' }, innerHTML : html, style : { backgroundColor : '#FFFFFF', width:'100px' } }); var items = c.getElementsByTagName('li'); for(var i = 0; i<items.length; i++){ items[i].onmouseover = function(){ asaEditorLib.addClassName(this, 'itemActive'); }; items[i].onmouseout = function(){ asaEditorLib.removeClassName(this, 'itemActive'); }; var val = items[i].getAttribute('val'); if(asaEditorLib.Browser.isIE){ val = '<'+val+'>'; } this.attachEventControl(items[i], 'click', 'execCommandEx', val, 'FormatBlock'); }};asaEd.prototype.createFontFamilyBox = function(){ var editor = this, w = window, d = document; var top = this.toolbarObj; var caption = this.decode_lang('Cmd.FontName'); var val = asaEditor_lang[this.lang].Fonts; var html = '<ul style="margin:0; padding:3px 3px 3px 3px;">'; for(var i in val) { html += '<li style="padding:0 8px 0 6px;font-size:12px;font-family:'+i+';list-style-type:none;text-align: left; cursor: pointer;" val="'+i+'">'+val[i]+'</li>'; } html = html+'</ul>'; var c = this.createContextBox({ attr : { id : 'fontnameDiv', _cmd : 'FontName' }, innerHTML : html, style : { backgroundColor : '#FFFFFF', width:'120px' } }); var items = c.getElementsByTagName('li'); for(var i = 0; i<items.length; i++){ items[i].onmouseover = function(){ asaEditorLib.addClassName(this, 'itemActive'); }; items[i].onmouseout = function(){ asaEditorLib.removeClassName(this, 'itemActive'); }; this.attachEventControl(items[i], 'click', 'execCommandEx', items[i].getAttribute('val'), 'FontName'); }};asaEd.prototype.createFontSizeBox = function(){ var editor = this; var w = window, d = document; var caption = asaEditor_lang[this.lang].Cmd.FontSize; var val = [1, 2, 3, 4, 5, 6, 7]; var pxSize = [7, 9, 11, 12, 15, 20, 30]; var html = '<ul style="margin:0; padding:3px 3px 3px 3px;">'; for(var i = 0; i<val.length; i++) { html += '<li style="padding:0 8px 0 6px;list-style-type:none;text-align: left; cursor: pointer; line-height:'+(pxSize[i]+6)+'pt;" val="'+val[i]+'"><span style="font-size:'+pxSize[i]+'pt;">'+this.decode_lang('font.sizeText')+'('+val[i]+')</span></li>'; } html = html+'</ul>'; var c = this.createContextBox({ attr : { id : 'fontsizeDiv', _cmd : 'FontSize' }, innerHTML : html, style : { backgroundColor : '#FFFFFF' } }); var items = c.getElementsByTagName('li'); for(var i = 0; i<items.length; i++){ items[i].onmouseover = function(){ asaEditorLib.addClassName(this, 'itemActive'); }; items[i].onmouseout = function(){ asaEditorLib.removeClassName(this, 'itemActive'); }; this.attachEventControl(items[i], 'click', 'execCommandEx', items[i].getAttribute('val'), 'FontSize'); }};asaEd.prototype.createLineHeightBox = function(){ var editor = this, w = window, d = document; var top = this.toolbarObj; var caption = this.decode_lang('Cmd.FontName'); var html = '<ul style="margin:0; padding:3px 3px 3px 3px;">'; for(var i=0; i<=5; i++) { var lh = (i*20)+100; html += '<li style="padding:0 8px 0 6px;font-size:12px;list-style-type:none;text-align: left; cursor: pointer;" val="'+lh+'%">'+lh+'%</li>'; } html = html+'</ul>'; var c = this.createContextBox({ attr : { id : 'lineheightDiv', _cmd : 'LineHeight' }, innerHTML : html, style : { backgroundColor : '#FFFFFF', width:'120px' } }); var items = c.getElementsByTagName('li'); for(var i = 0; i<items.length; i++){ items[i].onmouseover = function(){ asaEditorLib.addClassName(this, 'itemActive'); }; items[i].onmouseout = function(){ asaEditorLib.removeClassName(this, 'itemActive'); }; var val = items[i].getAttribute('val'); this.attachEventControl(items[i], 'click', 'insertLineHeight', val, 'LineHeight'); }};/* surroundContents : function(newParent){ newParent.appendChild(this.extractContents()); this.insertNode(newParent); this.selectNode(newParent); }, extractContents : function(){ var oClonedContents = this.cloneContents(); this.deleteContents(); return oClonedContents; },*/asaEd.prototype.insertLineHeight = function(v){ var x = asaEditorLib, ag = x.A(arguments), t = this; var p = null; if(x.Browser.isIE){ p = this.focusObj.parentElement(); } else { p = this.getSelection().focusNode.parentNode; } p.style.lineHeight = v; if(x.Browser.isIE){ try{ this.focusObj.select(); } catch(e){} } this.forceHideLayer(); this.setFocus();};asaEd.prototype.getBodyHTML = function () { var d = this.oFO.contentWindow.document; return d.body.innerHTML;};asaEd.prototype.setTextValue = function(val){ this.oTO.value = val;};asaEd.prototype.getFullHTML = function () { debug('getFullHTML'); var begin = this.configs.htmlBegin, end = this.configs.htmlEnd; if (this.modes == 'edit') { this.setTextValue(begin + this.getBodyHTML() + end); /**this.oFO.contentWindow.document.body.innerHTML = this.getTextareaText();**/ } else if (this.modes == 'html') { /*this.oFO.contentWindow.document.body.innerHTML = this.getTextareaText();*/ this.reloadFromTextbox(); this.setTextValue(begin + this.getBodyHTML() + end); } return this.oTO.value;};asaEd.prototype.getText= function () { if (this.modes == 'html'){ this.reloadFromTextbox(); } return this.oFO.contentWindow.document.body.innerText; };asaEd.prototype.getLinks= function () { return this.oFO.contentWindow.document.getElementsByTagName('A'); };asaEd.prototype.getImages= function () { return this.oFO.contentWindow.document.getElementsByTagName('IMG'); };asaEd.prototype.getDocument= function () { return this.oFO.contentWindow.document; };asaEd.prototype.getEditor= function () { return this.oFO.contentWindow; };asaEd.prototype.getContent = function(){ return this.oFO.contentWindow.document.innerHTML;};asaEd.prototype.setContent = function(sHTML){ this.oFO.contentWindow.document.innerHTML = sHTML;};asaEd.prototype.previewUploadedImage = function (){ var zone = {}; zone['urlObj' ] = asaEditorLib.$('imgUrl'); if(zone['urlObj'].value == 'http://') return; zone['preObj' ] = asaEditorLib.$('imgPreview'); zone['preObj' ].innerHTML = '<img id="previewImg" src="' + zone['urlObj'].value + '" alt=""/>'; zone['imgObj' ] = asaEditorLib.$('previewImg'); zone['width' ] = asaEditorLib.$('imageWidth').value; zone['height' ] = asaEditorLib.$('imageHeight').value; zone['align' ] = asaEditorLib.$('imageAlign').value; zone['border'] = asaEditorLib.$('imageBorder').value; var css = ''; if( zone['width' ] && !isNaN(zone['width' ])) { css = 'width: ' + zone['width'] + 'px;'; } if( zone['height' ] && !isNaN(zone['height' ])) { css += 'height: ' + zone['height'] + 'px;'; } zone['imgObj' ].style.cssText = css; if(zone['align']) { zone['imgObj' ].align = zone['align']; } else { zone['imgObj' ].align = ''; } if(zone['border'] && !isNaN(zone['border'])) { zone['imgObj'].border = zone['border']; } else { zone['imgObj'].border = ''; } zone['imgObj' ].removeAttribute('id');/* asaEditorLib.addEvent(asaEditorLib.$('previewImg'), 'load', function(){ asaEditorLib.$('imageWidth').value=this.width; asaEditorLib.$('imageHeight').value=this.height; });*/};asaEd.prototype.setUploadImage = function(url, width, height){ var d = document; asaEditorLib.$('imgUrl').value = url; asaEditorLib.$('imageWidth').value = width; asaEditorLib.$('imageHeight').value = height; this.previewUploadedImage();};var setUploadImage = function(url, width, height){ if(asaEditorGlobal.activeEditor){ asaEditorGlobal.activeEditor.setUploadImage(url, width, height); }};asaEd.prototype.showPreview = function(attr){ attr = attr || {}; var win = window.open('', 'asaEditorPreview', 'menubar=no, width='+(attr.width || 800)+', height='+(attr.height || 600)+''+(attr.left ? ',left='+attr.left : '')+(attr.top ? ',top='+attr.top : '')); var tryingCnt = 0, editor = this; setTimeout(function(){ if(win && win.document){ var content = editor.getContentMsg(true); var html=''; if( attr.html){ html = attr.html; } else { if(attr.cancelWrite !== true) { html = editor.configs.htmlBegin+content+editor.configs.htmlEnd; } } win.document.open(); win.document.write(html); win.document.close(); win.focus(); return; } else { tryingCnt += 1; if(tryingCnt>100){ alert('Sorry, Popup is blocking!'); return; } setTimeout(arguments.callee, 100); } }, 100);};asaEd.prototype.setAPI = function(){ var editor = this; this.API = { insertHTML : function(html){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } editor.setFocus(); editor.setSelection(); editor.insertHTML(html); }, showPreview : function(attr){ editor.showPreview(attr); }, getDocument : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getDocument(); }, getImages : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getImages(); }, getFullHTML : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getFullHTML(); }, getBodyHTML : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getBodyHTML(); }, getBody : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getDocument().body; }, getEditor : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getWin(); }, getText : function(){ if(editor.modes != 'edit'){ alert(asaEditor_lang[editor.lang].confirm.notEditMode); return false; } return editor.getDocument().body.innerText; } };};/* * Search AddOn*/var DHTMLSearcher = function(editor){ this._keyword = ""; this._range = null; this._iCurrent = 0; this._iTmp = 0; this._editor = editor; this._win = editor.getWin(); this._doc = editor.getDocument();};asaEditorLib.extend(DHTMLSearcher.prototype, { _find : function(sText){ if( !sText ) return false; var bResult = false, tmp = null; this._keyword = sText; if(this._win.find){ this._findReset(); bResult = this._win.find(sText); } else if( this._doc.body.createTextRange ){ this._range = this._doc.body.createTextRange(); bResult = this._range.findText(sText); this._range.select(); } return bResult; }, _findNext : function(sKeyword){ if( !sKeyword ) return false; var bResult = false, tmp = null; if(this._win.find){ bResult = this._win.find(sKeyword); } else if( this._doc.body.createTextRange ){ this._range.collapse(false); bResult = this._range.findText(sKeyword); this._range.select(); } return bResult; },/* _findPrev : function(sKeyword, sReplaceword){ if( !sKeyword ) return false; var bResult = false, tmp = null; if( tmp = this._win.find ){ bResult = tmp(sKeyword); } else if(this._doc.body.createTextRange){ this._range.pasteHTML(sReplaceword); this._range.select(); } return bResult; },*/ _findReset : function(){ if(this._win.find){ this._win.getSelection().removeAllRanges(); } else { this._range.moveStart('textedit'); this._range.select(); } }, searchkey : function(editor, keyword){ var sKeyword = keyword; var bRet = false, lang = asaEditor_lang[this._editor.lang]; this._editor.setFocus(); if(document.domain != document.location.hostname){ if( !asaEditorLib.Browser.isIE ){ alert(asaEditorLib.decode_lang(lang.confirm.notSupport)); return false; } } if(sKeyword){ if(this._keyword != sKeyword){ this._iCurrent = 0; } if(this._iCurrent==1){ bRet = this._findNext(sKeyword); } else { bRet = this._find(sKeyword); } } else { alert(asaEditorLib.decode_lang(lang.confirm.inputFindWord)); return false; } if(!bRet){ if(this._iCurrent == 1){ this._findReset(); this._iCurrent = 0; this._findReset(alert(asaEditorLib.decode_lang(lang.confirm.notFoundWord))); return false; } else { this._findReset(); alert(asaEditorLib.decode_lang(lang.confirm.notFoundWord)); return false; } } else { this._iCurrent = 1; return false; } }, Search:function(sKeyword){ /*//var sKeyword=$("keyword_re").value;*/ var bRet=this.searchkey(this._editor, sKeyword); this._iTemp=1; return bRet; }, Replace:function(sKeyword, sRelaceword){ this._editor.setFocus(); /*//var sKeyword=$("keyword_re").value; //var sRelaceword=$("replace").value;*/ var Selection=null; var bRet=null; sRelaceword=asaEditorLib.escapeHTMLText(sRelaceword); if(this._iTemp==0){ bRet=this.searchkey(this._editor,sKeyword); if(bRet)Selection=this._editor.getSelection(); } if(this._iCurrent==1){ this._iTemp=1; Selection=this._editor.getSelection(); if(asaEditorLib.Browser.isIE){ this._range.pasteHTML(sRelaceword); this._range.select(); }else{ this._range = Selection.getRangeAt(0); var fcs=this._doc.createRange(); var div=this._doc.createElement('div'); div.innerHTML=sRelaceword; var end=div.lastChild; this._range.deleteContents(); while(div.lastChild) this._range.insertNode(div.lastChild); fcs.setStartAfter(end); Selection.removeAllRanges(); Selection.addRange(fcs); } bRet=this.searchkey(this._editor,sKeyword); if(!bRet) Selection=this._editor.getSelection(); } if(this._iCurrent!=1){this._iTemp=0;} return bRet; }, ReplaceAll:function(sKeyword, sRelaceword){ var editor=this._editor; var lang = asaEditor_lang[editor.lang]; editor.setFocus(); /*//var sKeyword=$("keyword_re").value; //var sRelaceword=$("replace").value;*/ var sDoc=editor.getContent(); var sFindResult=new String(); if(sKeyword){ sFindResult=this.sAllReplace(sKeyword,sRelaceword,sDoc); }else{ sFindResult=false; alert(asaEditorLib.decode_lang(lang.confirm.inputFindWord)); } if(sFindResult!=false){ editor.setContent(sFindResult); }else{ editor.setContent(sDoc); } if(this._iTemp!=0){ this._iTemp=0; this._iCurrent=0; } return true; }, sAllReplace:function(sKeyword,sRelaceword,sDoc){ var lang = asaEditor_lang[this._editor.lang]; var sFindResult=new String(); var rSaerchExp=null; var rNotHTMLExp=/([^<]+)|<[^<>]*>/gi;var rHTMLTags=/<[^>]*>/gi; sKeyword=asaEditorLib.escapeHTMLText(sKeyword); rSaerchExp=new RegExp(sKeyword,"gi"); var iTemp=0; if(rSaerchExp.test(sDoc)){ iTemp=sDoc.replace(rHTMLTags,"").match(rSaerchExp).length; sFindResult=sDoc.replace(rNotHTMLExp,function(){ var retVal=new String(); if(arguments[1]==undefined)return arguments[0]; if(arguments[1].length){ retVal=arguments[1].replace(rSaerchExp,sRelaceword); }else{ retVal=arguments[0]; } return retVal; }); /*//alert('plugin.searchreplace.allreplace1');*/ return sFindResult; }else{ alert(asaEditorLib.decode_lang(lang.confirm.notFoundWord)); return false; } }});var asaEditorDrager = { _dragObj:{zIndex:0}, dragStart : function(event, id){ var el, x, y; var browser = asaEditorLib.Browser; var dragObj = asaEditorDrager._dragObj; if(id){ dragObj.elNode = asaEditorLib.$(id); } else { if(browser.isIE) dragObj.elNode = window.event.srcElement; else dragObj.elNode = event.target; if(dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode; } if (browser.isIE) { x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; } if (browser.isNS) { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; } dragObj.cursorStartX = x; dragObj.cursorStartY = y; dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10); dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10); if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0; if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0; dragObj.elNode.style.zIndex = ++dragObj.zIndex; if (browser.isIE) { document.attachEvent("onmousemove", asaEditorDrager.dragGo); document.attachEvent("onmouseup", asaEditorDrager.dragStop); window.event.cancelBubble = true; window.event.returnValue = false; } if (browser.isNS) { document.addEventListener("mousemove", asaEditorDrager.dragGo, true); document.addEventListener("mouseup", asaEditorDrager.dragStop, true); event.preventDefault(); } }, dragGo : function(event) { var x, y; var browser = asaEditorLib.Browser; var dragObj = asaEditorDrager._dragObj; if (browser.isIE) { x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; } if (browser.isNS) { x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; } dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px"; dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px"; if (browser.isIE) { window.event.cancelBubble = true; window.event.returnValue = false; } if (browser.isNS){ event.preventDefault(); } }, dragStop:function(event) { var browser = asaEditorLib.Browser; if (browser.isIE) { document.detachEvent("onmousemove", asaEditorDrager.dragGo); document.detachEvent("onmouseup", asaEditorDrager.dragStop); } if (browser.isNS) { document.removeEventListener("mousemove", asaEditorDrager.dragGo, true); document.removeEventListener("mouseup", asaEditorDrager.dragStop, true); } }};/* * @author Moxiecode * @copyright Copyright 2004-2008, Moxiecode Systems AB, All rights reserved.*/var Cpk = { colors : [ "#000000","#000033","#000066","#000099","#0000cc","#0000ff","#330000","#330033", "#330066","#330099","#3300cc","#3300ff","#660000","#660033","#660066","#660099", "#6600cc","#6600ff","#990000","#990033","#990066","#990099","#9900cc","#9900ff", "#cc0000","#cc0033","#cc0066","#cc0099","#cc00cc","#cc00ff","#ff0000","#ff0033", "#ff0066","#ff0099","#ff00cc","#ff00ff","#003300","#003333","#003366","#003399", "#0033cc","#0033ff","#333300","#333333","#333366","#333399","#3333cc","#3333ff", "#663300","#663333","#663366","#663399","#6633cc","#6633ff","#993300","#993333", "#993366","#993399","#9933cc","#9933ff","#cc3300","#cc3333","#cc3366","#cc3399", "#cc33cc","#cc33ff","#ff3300","#ff3333","#ff3366","#ff3399","#ff33cc","#ff33ff", "#006600","#006633","#006666","#006699","#0066cc","#0066ff","#336600","#336633", "#336666","#336699","#3366cc","#3366ff","#666600","#666633","#666666","#666699", "#6666cc","#6666ff","#996600","#996633","#996666","#996699","#9966cc","#9966ff", "#cc6600","#cc6633","#cc6666","#cc6699","#cc66cc","#cc66ff","#ff6600","#ff6633", "#ff6666","#ff6699","#ff66cc","#ff66ff","#009900","#009933","#009966","#009999", "#0099cc","#0099ff","#339900","#339933","#339966","#339999","#3399cc","#3399ff", "#669900","#669933","#669966","#669999","#6699cc","#6699ff","#999900","#999933", "#999966","#999999","#9999cc","#9999ff","#cc9900","#cc9933","#cc9966","#cc9999", "#cc99cc","#cc99ff","#ff9900","#ff9933","#ff9966","#ff9999","#ff99cc","#ff99ff", "#00cc00","#00cc33","#00cc66","#00cc99","#00cccc","#00ccff","#33cc00","#33cc33", "#33cc66","#33cc99","#33cccc","#33ccff","#66cc00","#66cc33","#66cc66","#66cc99", "#66cccc","#66ccff","#99cc00","#99cc33","#99cc66","#99cc99","#99cccc","#99ccff", "#cccc00","#cccc33","#cccc66","#cccc99","#cccccc","#ccccff","#ffcc00","#ffcc33", "#ffcc66","#ffcc99","#ffcccc","#ffccff","#00ff00","#00ff33","#00ff66","#00ff99", "#00ffcc","#00ffff","#33ff00","#33ff33","#33ff66","#33ff99","#33ffcc","#33ffff", "#66ff00","#66ff33","#66ff66","#66ff99","#66ffcc","#66ffff","#99ff00","#99ff33", "#99ff66","#99ff99","#99ffcc","#99ffff","#ccff00","#ccff33","#ccff66","#ccff99", "#ccffcc","#ccffff","#ffff00","#ffff33","#ffff66","#ffff99","#ffffcc","#ffffff" ], detail : 50, li : 25, strhex : "0123456789abcdef", isMouseDown : false, isMouseOver : false, isMouseDown2 : false, isMouseOver2 : false, onselected:function(){}, cth:function(col) { var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); if (!col) return col; var rgb = col.replace(re, "$1,$2,$3").split(','); if (rgb.length == 3) { r = parseInt(rgb[0]).toString(16); g = parseInt(rgb[1]).toString(16); b = parseInt(rgb[2]).toString(16); r = r.length == 1 ? '0' + r : r; g = g.length == 1 ? '0' + g : g; b = b.length == 1 ? '0' + b : b; return "#" + r + g + b; } return col; }, dh:function(n) { return Cpk.strhex.charAt(Math.floor(n / 16)) + Cpk.strhex.charAt(n % 16); }, cc:function(e) { /* var x, y; x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); */ var mpos = asaEditorLib.getMouseXY(e); var pos = asaEditorLib.getAbsPos(e.srcElement || e.target); var x = (mpos.x-pos.x); var y = (mpos.y-pos.y); Cpk.cc2(x, y); }, cc2:function(x, y){ var partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB; partWidth = 210 / 6; /*document.getElementById('colors').width / 6;*/ partDetail = Cpk.detail / 2; imHeight = 100; /*document.getElementById('colors').height;*/ r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth); coef = (imHeight - y) / imHeight; r = 128 + (r - 128) * coef; g = 128 + (g - 128) * coef; b = 128 + (b - 128) * coef; Cpk.ul(r, g, b); Cpk.cfc(); }, ul:function(r, g, b) { var i, partDetail = Cpk.detail / 2, finalCoef, finalR, finalG, finalB, color; for (i=0; i<Cpk.detail; i++) { if ((i>=0) && (i<partDetail)) { finalCoef = i / partDetail; finalR = Cpk.dh(255 - (255 - r) * finalCoef); finalG = Cpk.dh(255 - (255 - g) * finalCoef); finalB = Cpk.dh(255 - (255 - b) * finalCoef); } else { finalCoef = 2 - i / partDetail; finalR = Cpk.dh(r * finalCoef); finalG = Cpk.dh(g * finalCoef); finalB = Cpk.dh(b * finalCoef); } color = finalR + finalG + finalB; Cpk.sc('gs' + i, '#'+color); } }, cfc:function(color) { color = color || document.getElementById('gs'+Cpk.li).style.backgroundColor; if (color.indexOf('#') == -1) color = Cpk.cth(color); Cpk.onselected(color); }, sc:function(e, c) { try { document.getElementById(e).style.backgroundColor = c; } catch (ex) { } }, setRender:function(box, attr){ var dc = document; if(typeof box == 'string') box = document.getElementById(box); if(attr.onselected){ Cpk.onselected = attr.onselected; } box.onselectstart = box.ondragstart = null; var table = dc.createElement('table'); table.cellPadding = table.cellSpacing = table.border = 0; table.style.cssText = "margin:0;"; var tr = table.insertRow(0); var td = tr.insertCell(0); var leftDiv = dc.createElement('div'); var leftDiv = dc.createElement('div'); leftDiv.style.cssText = "cursor:crosshair;width:210px;height:100px;background:url("+attr.imgDir+"/colorpicker_small.jpg);"; leftDiv.onselectstart = leftDiv.ondragstart = null; leftDiv.onmousedown = function(){ Cpk.isMouseDown = true; }; leftDiv.onmouseup = function(){ Cpk.isMouseDown = false; }; leftDiv.onmouseover = function(){ Cpk.isMouseOver=true; }; leftDiv.onmouseout = function(){ Cpk.isMouseOver=false; }; leftDiv.onmousemove = function(e){ e = e || event; if(Cpk.isMouseDown && Cpk.isMouseOver) Cpk.cc(e); }; leftDiv.onclick = function(e){ e = e || event; Cpk.cc(e); }; td.appendChild(leftDiv); td = tr.insertCell(1); var rightDiv = dc.createElement('div'); rightDiv.onselectstart = rightDiv.ondragstart = null; rightDiv.style.cssText = "position:relative;width:15px;height:100px;margin-left:4px;"; rightDiv.onmousedown = function(){ Cpk.isMouseDown2 = true; }; rightDiv.onmouseup = function(){ Cpk.isMouseDown2 = false; }; rightDiv.onmouseover = function(){ Cpk.isMouseOver2 = true; }; rightDiv.onmouseout = function(){ Cpk.isMouseOver2 = false; }; if( ! Cpk['select_line']){ Cpk['select_line'] = new Image(); Cpk['select_line'].onselectstart = Cpk['select_line'].ondragstart = null; Cpk['select_line'].src = attr.imgDir+'/color_position.gif'; Cpk['select_line'].style.cssText = "position:absolute;left:-3px;"; } rightDiv.appendChild(Cpk['select_line']); for(var i=0; i<50; i++){ var rowDiv = dc.createElement('div'); rowDiv.id = 'gs'+i; rowDiv.style.cssText = 'cursor:crosshair;margin:0;padding:0;width:15px;height:2px;font-size:0pt;'; (function(idx){ rowDiv.onmousemove = function(){ if(Cpk.isMouseDown2 && Cpk.isMouseOver2) { Cpk.li = idx; Cpk.rePositionSelectLine(); Cpk.cfc(this.style.backgroundColor); } }; rowDiv.onclick = function(){ Cpk.li = idx; Cpk.rePositionSelectLine(); Cpk.cfc(this.style.backgroundColor); }; })(i); rightDiv.appendChild(rowDiv); } td.appendChild(rightDiv); box.appendChild(table); Cpk.li = 25; Cpk.cc2(0, 100); Cpk.rePositionSelectLine(); Cpk.cfc(); }, rePositionSelectLine:function(){ Cpk['select_line'].style.top = (Cpk.li * 2)+'px'; }};
