mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
set svn property - svn:eol-style LF
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8253 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
9802eaa60a
commit
620b03d184
763 changed files with 114595 additions and 114595 deletions
|
|
@ -1,113 +1,113 @@
|
|||
/**
|
||||
* @file common.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief 몇가지 유용한 & 기본적으로 자주 사용되는 자바스크립트 함수들 모음
|
||||
**/
|
||||
if(jQuery)jQuery.noConflict();(function($){var UA=navigator.userAgent.toLowerCase();$.os={Linux:/linux/.test(UA),Unix:/x11/.test(UA),Mac:/mac/.test(UA),Windows:/win/.test(UA)};$.os.name=($.os.Windows)?'Windows':($.os.Linux)?'Linux':($.os.Unix)?'Unix':($.os.Mac)?'Mac':'';window.XE={loaded_popup_menus:new Array(),addedDocument:new Array(),checkboxToggleAll:function(){var itemName='cart';var options={wrap:null,checked:'toggle',doClick:false};switch(arguments.length){case 1:if(typeof(arguments[0])=="string"){itemName=arguments[0];}else{$.extend(options,arguments[0]||{});}
|
||||
break;case 2:itemName=arguments[0];$.extend(options,arguments[1]||{});}
|
||||
if(options.doClick==true)options.checked=null;if(typeof(options.wrap)=="string")options.wrap='#'+options.wrap;if(options.wrap){var obj=$(options.wrap).find('input[name='+itemName+']:checkbox');}else{var obj=$('input[name='+itemName+']:checkbox');}
|
||||
if(options.checked=='toggle'){obj.each(function(){$(this).attr('checked',($(this).attr('checked'))?false:true);});}else{(options.doClick==true)?obj.click():obj.attr('checked',options.checked);}},displayPopupMenu:function(ret_obj,response_tags,params){var target_srl=params["target_srl"];var menu_id=params["menu_id"];var menus=ret_obj['menus'];var html="";if(this.loaded_popup_menus[menu_id]){html=this.loaded_popup_menus[menu_id];}else{if(menus){var item=menus['item'];if(typeof(item.length)=='undefined'||item.length<1)item=new Array(item);if(item.length){for(var i=0;i<item.length;i++){var url=item[i].url;var str=item[i].str;var icon=item[i].icon;var target=item[i].target;var styleText="";var click_str="";if(icon)styleText=" style=\"background-image:url('"+icon+"')\" ";switch(target){case"popup":click_str=" onclick=\"popopen(this.href,'"+target+"'); return false;\"";break;case"self":break;case"javascript":click_str=" onclick=\""+url+"; return false; \"";url="#";break;default:click_str=" onclick=\"window.open(this.href); return false;\"";break;}
|
||||
html+='<li '+styleText+'><a href="'+url+'"'+click_str+'>'+str+'</a></li> ';}}}
|
||||
this.loaded_popup_menus[menu_id]=html;}
|
||||
if(html){var area=$('#popup_menu_area').html('<ul>'+html+'</ul>');var areaOffset={top:params['page_y'],left:params['page_x']};if(area.outerHeight()+areaOffset.top>$(window).height()+$(window).scrollTop())
|
||||
areaOffset.top=$(window).height()-area.outerHeight()+$(window).scrollTop();if(area.outerWidth()+areaOffset.left>$(window).width()+$(window).scrollLeft())
|
||||
areaOffset.left=$(window).width()-area.outerWidth()+$(window).scrollLeft();area.css({top:areaOffset.top,left:areaOffset.left}).show();}}}})(jQuery);jQuery(function($){if(!$('#popup_menu_area').length){var menuObj=$('<div>').attr('id','popup_menu_area').css({display:'none',zIndex:9999});$(document.body).append(menuObj);}
|
||||
$(document).click(function(evt){var area=$('#popup_menu_area');if(!area.length)return;area.hide();var targetObj=$(evt.target);if(!targetObj.length)return;if(targetObj.length&&$.inArray(targetObj.attr('nodeName'),['DIV','SPAN','A'])==-1)targetObj=targetObj.parent();if(!targetObj.length||$.inArray(targetObj.attr('nodeName'),['DIV','SPAN','A'])==-1)return;var class_name=targetObj.attr('className');if(class_name.indexOf('_')<=0)return;var class_name_list=class_name.split(' ');var menu_id='';var menu_id_regx=/^([a-zA-Z]+)_([0-9]+)$/;for(var i=0,c=class_name_list.length;i<c;i++){if(menu_id_regx.test(class_name_list[i])){menu_id=class_name_list[i];}}
|
||||
if(!menu_id)return;var tmp_arr=menu_id.split('_');var module_name=tmp_arr[0];var target_srl=tmp_arr[1];if(!module_name||!target_srl||target_srl<1)return;var action_name="get"+module_name.substr(0,1).toUpperCase()+module_name.substr(1,module_name.length-1)+"Menu";var params=new Array();params["target_srl"]=target_srl;params["mid"]=params["cur_mid"]=current_mid;params["cur_act"]=current_url.getQuery('act');params["menu_id"]=menu_id;params["page_x"]=evt.pageX;params["page_y"]=evt.pageY;if(typeof(xeVid)!='undefined')params["vid"]=xeVid;var response_tags=new Array("error","message","menus");if(typeof(XE.loaded_popup_menus[menu_id])!='undefined'){XE.displayPopupMenu(params,response_tags,params);return;}
|
||||
show_waiting_message=false;exec_xml(module_name,action_name,params,XE.displayPopupMenu,response_tags,params);show_waiting_message=true;});if($.browser.msie){$('select').each(function(i,sels){var disabled_exists=false;var first_enable=new Array();for(var j=0;j<sels.options.length;j++){if(sels.options[j].disabled){sels.options[j].style.color='#CCCCCC';disabled_exists=true;}else{first_enable[i]=(first_enable[i]>-1)?first_enable[i]:j;}}
|
||||
if(!disabled_exists)return;sels.oldonchange=sels.onchange;sels.onchange=function(){if(this.options[this.selectedIndex].disabled){this.selectedIndex=first_enable[i];}else{if(this.oldonchange)this.oldonchange();}};if(sels.selectedIndex>=0&&sels.options[sels.selectedIndex].disabled)sels.onchange();});}
|
||||
var drEditorFold=$('.xe_content .fold_button');if(drEditorFold.size()){var fold_container=$('div.fold_container',drEditorFold);$('button.more',drEditorFold).click(function(){$(this).hide().next('button').show().parent().next(fold_container).show();});$('button.less',drEditorFold).click(function(){$(this).hide().prev('button').show().parent().next(fold_container).hide();});}});String.prototype.getQuery=function(key){var idx=this.indexOf('?');if(idx==-1)return null;var query_string=this.substr(idx+1,this.length);var args={};query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(){args[arguments[1]]=arguments[2];});var q=args[key];if(typeof(q)=="undefined")q="";return q;}
|
||||
String.prototype.setQuery=function(key,val){var idx=this.indexOf('?');var uri=this.replace(/#$/,'');if(idx!=-1){var query_string=uri.substr(idx+1,this.length),args={},q_list=[];uri=this.substr(0,idx);query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(all,key,val){args[key]=val;});args[key]=val;jQuery.each(args,function(key,val){if(!jQuery.trim(val))return;q_list.push(key+'='+decodeURI(val));});query_string=q_list.join('&');uri=uri+(query_string?'?'+query_string:'');}else{if(val.toString().trim())uri=uri+"?"+key+"="+val;}
|
||||
var re=/https:\/\/([^:\/]+)(:\d+|)/i;var check=re.exec(uri);if(check)
|
||||
{var toReplace="http://"+check[1];if(typeof(http_port)!='undefined'&&http_port!=80)
|
||||
{toReplace+=":"+http_port;}
|
||||
uri=uri.replace(re,toReplace);}
|
||||
var bUseSSL=false;if(typeof(enforce_ssl)!='undefined'&&enforce_ssl)
|
||||
{bUseSSL=true;}
|
||||
else if(typeof(ssl_actions)!='undefined'&&typeof(ssl_actions.length)!='undefined'&&uri.getQuery('act')){var act=uri.getQuery('act');for(i=0;i<ssl_actions.length;i++){if(ssl_actions[i]==act){bUseSSL=true;break;}}}
|
||||
if(bUseSSL)
|
||||
{var re=/http:\/\/([^:\/]+)(:\d+|)/i;var check=re.exec(uri);if(check)
|
||||
{var toReplace="https://"+check[1];if(typeof(https_port)!='undefined'&&https_port!=443)
|
||||
{toReplace+=":"+https_port;}
|
||||
uri=uri.replace(re,toReplace);}}
|
||||
return encodeURI(uri);}
|
||||
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
|
||||
function xSleep(sec){sec=sec/1000;var now=new Date();var sleep=new Date();while(sleep.getTime()-now.getTime()<sec){sleep=new Date();}}
|
||||
function isDef(){for(var i=0;i<arguments.length;++i){if(typeof(arguments[i])=="undefined")return false;}
|
||||
return true;}
|
||||
var winopen_list=new Array();function winopen(url,target,attribute){if(typeof(xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);try{if(target!="_blank"&&winopen_list[target]){winopen_list[target].close();winopen_list[target]=null;}}catch(e){}
|
||||
if(typeof(target)=='undefined')target='_blank';if(typeof(attribute)=='undefined')attribute='';var win=window.open(url,target,attribute);win.focus();if(target!="_blank")winopen_list[target]=win;}
|
||||
function popopen(url,target){if(typeof(target)=="undefined")target="_blank";if(typeof(xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);winopen(url,target,"left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no");}
|
||||
function sendMailTo(to){location.href="mailto:"+to;}
|
||||
function move_url(url,open_wnidow){if(!url)return false;if(typeof(open_wnidow)=='undefined')open_wnidow='N';if(open_wnidow=='N'){open_wnidow=false;}else{open_wnidow=true;}
|
||||
if(/^\./.test(url))url=request_uri+url;if(open_wnidow){winopen(url);}else{location.href=url;}
|
||||
return false;}
|
||||
function displayMultimedia(src,width,height,options){var html=_displayMultimedia(src,width,height,options);if(html)document.writeln(html);}
|
||||
function _displayMultimedia(src,width,height,options){if(src.indexOf('files')==0)src=request_uri+src;var defaults={wmode:'transparent',allowScriptAccess:'sameDomain',quality:'high',flashvars:'',autostart:false};var params=jQuery.extend(defaults,options||{});var autostart=(params.autostart&¶ms.autostart!='false')?'true':'false';delete(params.autostart);var clsid="";var codebase="";var html="";if(/\.(gif|jpg|jpeg|bmp|png)$/i.test(src)){html='<img src="'+src+'" width="'+width+'" height="'+height+'" />';}else if(/\.flv$/i.test(src)||/\.mov$/i.test(src)||/\.moov$/i.test(src)||/\.m4v$/i.test(src)){html='<embed src="'+request_uri+'common/tpl/images/flvplayer.swf" allowfullscreen="true" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="&file='+src+'&width='+width+'&height='+height+'&autostart='+autostart+'" wmode="'+params.wmode+'" />';}else if(/\.swf/i.test(src)){clsid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';if(typeof(enforce_ssl)!='undefined'&&enforce_ssl){codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";}
|
||||
else{codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";}
|
||||
html='<object classid="'+clsid+'" codebase="'+codebase+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'">';html+='<param name="movie" value="'+src+'" />';for(var name in params){if(params[name]!='undefined'&¶ms[name]!=''){html+='<param name="'+name+'" value="'+params[name]+'" />';}}
|
||||
html+=''
|
||||
+'<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'" wmode="'+params.wmode+'"></embed>'
|
||||
+'</object>';}else{if(jQuery.browser.mozilla||jQuery.browser.opera){autostart=(params.autostart&¶ms.autostart!='false')?'1':'0';}
|
||||
html='<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'"';if(params.wmode=='transparent'){html+=' windowlessvideo="1"';}
|
||||
html+='></embed>';}
|
||||
return html;}
|
||||
function zbxe_folder_open(id){jQuery("#folder_open_"+id).hide();jQuery("#folder_close_"+id).show();jQuery("#folder_"+id).show();}
|
||||
function zbxe_folder_close(id){jQuery("#folder_open_"+id).show();jQuery("#folder_close_"+id).hide();jQuery("#folder_"+id).hide();}
|
||||
function setFixedPopupSize(){var $=jQuery;var $header=$('#popHeader');var $body=$('#popBody');if($body.length){if($body.height()>400){$body.css({overflow:'auto',overflowX:'hidden',height:400+'px'});}}
|
||||
var $win=$(window);var $pc=$('#popup_content');var w=Math.max($pc[0].offsetWidth,600);var h=$pc[0].offsetHeight;var dw=$win.width();var dh=$win.height();var _w=0,_h=0;if(w!=dw)_w=w-dw;if(h!=dh)_h=h-dh;if(_w||_h){window.resizeBy(_w,_h);}
|
||||
if(!arguments.callee.executed){setTimeout(setFixedPopupSize,300);arguments.callee.executed=true;}}
|
||||
function doCallModuleAction(module,action,target_srl){var params=new Array();params['target_srl']=target_srl;params['cur_mid']=current_mid;exec_xml(module,action,params,completeCallModuleAction);}
|
||||
function completeCallModuleAction(ret_obj,response_tags){if(ret_obj['message']!='success')alert(ret_obj['message']);location.reload();}
|
||||
function completeMessage(ret_obj){alert(ret_obj['message']);location.reload();}
|
||||
function doChangeLangType(obj){if(typeof(obj)=="string"){setLangType(obj);}else{var val=obj.options[obj.selectedIndex].value;setLangType(val);}
|
||||
location.href=location.href.setQuery('l','');}
|
||||
function setLangType(lang_type){var expire=new Date();expire.setTime(expire.getTime()+(7000*24*3600000));setCookie('lang_type',lang_type,expire,'/');}
|
||||
function doDocumentPreview(obj){var fo_obj=obj;while(fo_obj.nodeName!="FORM"){fo_obj=fo_obj.parentNode;}
|
||||
if(fo_obj.nodeName!="FORM")return;var editor_sequence=fo_obj.getAttribute('editor_sequence');var content=editorGetContent(editor_sequence);var win=window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");var dummy_obj=jQuery("#previewDocument");if(!dummy_obj.length){jQuery('<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'">'+'<input type="hidden" name="module" value="document" />'+'<input type="hidden" name="act" value="dispDocumentPreview" />'+'<input type="hidden" name="content" />'+'</form>').appendTo(document.body);dummy_obj=jQuery("#previewDocument")[0];}
|
||||
if(dummy_obj){dummy_obj.content.value=content;dummy_obj.submit();}}
|
||||
function doDocumentSave(obj){var editor_sequence=obj.form.getAttribute('editor_sequence');var prev_content=editorRelKeys[editor_sequence]['content'].value;if(typeof(editor_sequence)!='undefined'&&editor_sequence&&typeof(editorRelKeys)!='undefined'&&typeof(editorGetContent)=='function'){var content=editorGetContent(editor_sequence);editorRelKeys[editor_sequence]['content'].value=content;}
|
||||
var params={},responses=['error','message','document_srl'],elms=obj.form.elements,data=jQuery(obj.form).serializeArray();;jQuery.each(data,function(i,field){var val=jQuery.trim(field.value);if(!val)return true;if(/\[\]$/.test(field.name))field.name=field.name.replace(/\[\]$/,'');if(params[field.name])params[field.name]+='|@|'+val;else params[field.name]=field.value;});exec_xml('member','procMemberSaveDocument',params,completeDocumentSave,responses,params,obj.form);editorRelKeys[editor_sequence]['content'].value=prev_content;return false;}
|
||||
function completeDocumentSave(ret_obj){jQuery('input[name=document_srl]').eq(0).val(ret_obj['document_srl']);alert(ret_obj['message']);}
|
||||
var objForSavedDoc=null;function doDocumentLoad(obj){objForSavedDoc=obj.form;popopen(request_uri.setQuery('module','member').setQuery('act','dispSavedDocumentList'));}
|
||||
function doDocumentSelect(document_srl){if(!opener||!opener.objForSavedDoc){window.close();return;}
|
||||
opener.location.href=opener.current_url.setQuery('document_srl',document_srl).setQuery('act','dispBoardWrite');window.close();}
|
||||
function viewSkinInfo(module,skin){popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin,'SkinInfo');}
|
||||
var addedDocument=new Array();function doAddDocumentCart(obj){var srl=obj.value;addedDocument[addedDocument.length]=srl;setTimeout(function(){callAddDocumentCart(addedDocument.length);},100);}
|
||||
function callAddDocumentCart(document_length){if(addedDocument.length<1||document_length!=addedDocument.length)return;var params=new Array();params["srls"]=addedDocument.join(",");exec_xml("document","procDocumentAddCart",params,null);addedDocument=new Array();}
|
||||
function transRGB2Hex(value){if(!value)return value;if(value.indexOf('#')>-1)return value.replace(/^#/,'');if(value.toLowerCase().indexOf('rgb')<0)return value;value=value.replace(/^rgb\(/i,'').replace(/\)$/,'');value_list=value.split(',');var hex='';for(var i=0;i<value_list.length;i++){var color=parseInt(value_list[i],10).toString(16);if(color.length==1)color='0'+color;hex+=color;}
|
||||
return hex;}
|
||||
function toggleSecuritySignIn(){var href=location.href;if(/https:\/\//i.test(href))location.href=href.replace(/^https/i,'http');else location.href=href.replace(/^http/i,'https');}
|
||||
function reloadDocument(){location.reload();}
|
||||
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._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+
|
||||
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
|
||||
this._keyStr.charAt(enc3)+this._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=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._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=Base64._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;}}
|
||||
if(typeof(resizeImageContents)=='undefined'){function resizeImageContents(){}}
|
||||
if(typeof(activateOptionDisabled)=='undefined'){function activateOptionDisabled(){}}
|
||||
objectExtend=jQuery.extend;function toggleDisplay(objId){jQuery('#'+objId).toggle();}
|
||||
function checkboxSelectAll(formObj,name,checked){var itemName=name;var option={};if(typeof(formObj)!="undefined")option.wrap=formObj;if(typeof(checked)!="undefined")option.checked=checked;XE.checkboxToggleAll(itemName,option);}
|
||||
function clickCheckBoxAll(formObj,name){var itemName=name;var option={doClick:true};if(typeof(formObj)!="undefined")option.wrap=formObj;XE.checkboxToggleAll(itemName,option);}
|
||||
function svc_folder_open(id){jQuery("#_folder_open_"+id).hide();jQuery("#_folder_close_"+id).show();jQuery("#_folder_"+id).show();}
|
||||
function svc_folder_close(id){jQuery("#_folder_open_"+id).show();jQuery("#_folder_close_"+id).hide();jQuery("#_folder_"+id).hide();}
|
||||
function open_calendar(fo_id,day_str,callback_func){if(typeof(day_str)=="undefined")day_str="";var url="./common/tpl/calendar.php?";if(fo_id)url+="fo_id="+fo_id;if(day_str)url+="&day_str="+day_str;if(callback_func)url+="&callback_func="+callback_func;popopen(url,'Calendar');}
|
||||
var loaded_popup_menus=XE.loaded_popup_menus;function createPopupMenu(){}
|
||||
function chkPopupMenu(){}
|
||||
function displayPopupMenu(ret_obj,response_tags,params){XE.displayPopupMenu(ret_obj,response_tags,params);}
|
||||
function GetObjLeft(obj){return jQuery(obj).offset().left;}
|
||||
function GetObjTop(obj){return jQuery(obj).offset().top;}
|
||||
function replaceOuterHTML(obj,html){jQuery(obj).replaceWith(html);}
|
||||
function getOuterHTML(obj){return jQuery(obj).html().trim();}
|
||||
function setCookie(name,value,expire,path){var s_cookie=name+"="+escape(value)+
|
||||
((!expire)?"":("; expires="+expire.toGMTString()))+"; path="+((!path)?"/":path);document.cookie=s_cookie;}
|
||||
jQuery(function(){jQuery(".lang_code").each(function()
|
||||
/**
|
||||
* @file common.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief 몇가지 유용한 & 기본적으로 자주 사용되는 자바스크립트 함수들 모음
|
||||
**/
|
||||
if(jQuery)jQuery.noConflict();(function($){var UA=navigator.userAgent.toLowerCase();$.os={Linux:/linux/.test(UA),Unix:/x11/.test(UA),Mac:/mac/.test(UA),Windows:/win/.test(UA)};$.os.name=($.os.Windows)?'Windows':($.os.Linux)?'Linux':($.os.Unix)?'Unix':($.os.Mac)?'Mac':'';window.XE={loaded_popup_menus:new Array(),addedDocument:new Array(),checkboxToggleAll:function(){var itemName='cart';var options={wrap:null,checked:'toggle',doClick:false};switch(arguments.length){case 1:if(typeof(arguments[0])=="string"){itemName=arguments[0];}else{$.extend(options,arguments[0]||{});}
|
||||
break;case 2:itemName=arguments[0];$.extend(options,arguments[1]||{});}
|
||||
if(options.doClick==true)options.checked=null;if(typeof(options.wrap)=="string")options.wrap='#'+options.wrap;if(options.wrap){var obj=$(options.wrap).find('input[name='+itemName+']:checkbox');}else{var obj=$('input[name='+itemName+']:checkbox');}
|
||||
if(options.checked=='toggle'){obj.each(function(){$(this).attr('checked',($(this).attr('checked'))?false:true);});}else{(options.doClick==true)?obj.click():obj.attr('checked',options.checked);}},displayPopupMenu:function(ret_obj,response_tags,params){var target_srl=params["target_srl"];var menu_id=params["menu_id"];var menus=ret_obj['menus'];var html="";if(this.loaded_popup_menus[menu_id]){html=this.loaded_popup_menus[menu_id];}else{if(menus){var item=menus['item'];if(typeof(item.length)=='undefined'||item.length<1)item=new Array(item);if(item.length){for(var i=0;i<item.length;i++){var url=item[i].url;var str=item[i].str;var icon=item[i].icon;var target=item[i].target;var styleText="";var click_str="";if(icon)styleText=" style=\"background-image:url('"+icon+"')\" ";switch(target){case"popup":click_str=" onclick=\"popopen(this.href,'"+target+"'); return false;\"";break;case"self":break;case"javascript":click_str=" onclick=\""+url+"; return false; \"";url="#";break;default:click_str=" onclick=\"window.open(this.href); return false;\"";break;}
|
||||
html+='<li '+styleText+'><a href="'+url+'"'+click_str+'>'+str+'</a></li> ';}}}
|
||||
this.loaded_popup_menus[menu_id]=html;}
|
||||
if(html){var area=$('#popup_menu_area').html('<ul>'+html+'</ul>');var areaOffset={top:params['page_y'],left:params['page_x']};if(area.outerHeight()+areaOffset.top>$(window).height()+$(window).scrollTop())
|
||||
areaOffset.top=$(window).height()-area.outerHeight()+$(window).scrollTop();if(area.outerWidth()+areaOffset.left>$(window).width()+$(window).scrollLeft())
|
||||
areaOffset.left=$(window).width()-area.outerWidth()+$(window).scrollLeft();area.css({top:areaOffset.top,left:areaOffset.left}).show();}}}})(jQuery);jQuery(function($){if(!$('#popup_menu_area').length){var menuObj=$('<div>').attr('id','popup_menu_area').css({display:'none',zIndex:9999});$(document.body).append(menuObj);}
|
||||
$(document).click(function(evt){var area=$('#popup_menu_area');if(!area.length)return;area.hide();var targetObj=$(evt.target);if(!targetObj.length)return;if(targetObj.length&&$.inArray(targetObj.attr('nodeName'),['DIV','SPAN','A'])==-1)targetObj=targetObj.parent();if(!targetObj.length||$.inArray(targetObj.attr('nodeName'),['DIV','SPAN','A'])==-1)return;var class_name=targetObj.attr('className');if(class_name.indexOf('_')<=0)return;var class_name_list=class_name.split(' ');var menu_id='';var menu_id_regx=/^([a-zA-Z]+)_([0-9]+)$/;for(var i=0,c=class_name_list.length;i<c;i++){if(menu_id_regx.test(class_name_list[i])){menu_id=class_name_list[i];}}
|
||||
if(!menu_id)return;var tmp_arr=menu_id.split('_');var module_name=tmp_arr[0];var target_srl=tmp_arr[1];if(!module_name||!target_srl||target_srl<1)return;var action_name="get"+module_name.substr(0,1).toUpperCase()+module_name.substr(1,module_name.length-1)+"Menu";var params=new Array();params["target_srl"]=target_srl;params["mid"]=params["cur_mid"]=current_mid;params["cur_act"]=current_url.getQuery('act');params["menu_id"]=menu_id;params["page_x"]=evt.pageX;params["page_y"]=evt.pageY;if(typeof(xeVid)!='undefined')params["vid"]=xeVid;var response_tags=new Array("error","message","menus");if(typeof(XE.loaded_popup_menus[menu_id])!='undefined'){XE.displayPopupMenu(params,response_tags,params);return;}
|
||||
show_waiting_message=false;exec_xml(module_name,action_name,params,XE.displayPopupMenu,response_tags,params);show_waiting_message=true;});if($.browser.msie){$('select').each(function(i,sels){var disabled_exists=false;var first_enable=new Array();for(var j=0;j<sels.options.length;j++){if(sels.options[j].disabled){sels.options[j].style.color='#CCCCCC';disabled_exists=true;}else{first_enable[i]=(first_enable[i]>-1)?first_enable[i]:j;}}
|
||||
if(!disabled_exists)return;sels.oldonchange=sels.onchange;sels.onchange=function(){if(this.options[this.selectedIndex].disabled){this.selectedIndex=first_enable[i];}else{if(this.oldonchange)this.oldonchange();}};if(sels.selectedIndex>=0&&sels.options[sels.selectedIndex].disabled)sels.onchange();});}
|
||||
var drEditorFold=$('.xe_content .fold_button');if(drEditorFold.size()){var fold_container=$('div.fold_container',drEditorFold);$('button.more',drEditorFold).click(function(){$(this).hide().next('button').show().parent().next(fold_container).show();});$('button.less',drEditorFold).click(function(){$(this).hide().prev('button').show().parent().next(fold_container).hide();});}});String.prototype.getQuery=function(key){var idx=this.indexOf('?');if(idx==-1)return null;var query_string=this.substr(idx+1,this.length);var args={};query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(){args[arguments[1]]=arguments[2];});var q=args[key];if(typeof(q)=="undefined")q="";return q;}
|
||||
String.prototype.setQuery=function(key,val){var idx=this.indexOf('?');var uri=this.replace(/#$/,'');if(idx!=-1){var query_string=uri.substr(idx+1,this.length),args={},q_list=[];uri=this.substr(0,idx);query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(all,key,val){args[key]=val;});args[key]=val;jQuery.each(args,function(key,val){if(!jQuery.trim(val))return;q_list.push(key+'='+decodeURI(val));});query_string=q_list.join('&');uri=uri+(query_string?'?'+query_string:'');}else{if(val.toString().trim())uri=uri+"?"+key+"="+val;}
|
||||
var re=/https:\/\/([^:\/]+)(:\d+|)/i;var check=re.exec(uri);if(check)
|
||||
{var toReplace="http://"+check[1];if(typeof(http_port)!='undefined'&&http_port!=80)
|
||||
{toReplace+=":"+http_port;}
|
||||
uri=uri.replace(re,toReplace);}
|
||||
var bUseSSL=false;if(typeof(enforce_ssl)!='undefined'&&enforce_ssl)
|
||||
{bUseSSL=true;}
|
||||
else if(typeof(ssl_actions)!='undefined'&&typeof(ssl_actions.length)!='undefined'&&uri.getQuery('act')){var act=uri.getQuery('act');for(i=0;i<ssl_actions.length;i++){if(ssl_actions[i]==act){bUseSSL=true;break;}}}
|
||||
if(bUseSSL)
|
||||
{var re=/http:\/\/([^:\/]+)(:\d+|)/i;var check=re.exec(uri);if(check)
|
||||
{var toReplace="https://"+check[1];if(typeof(https_port)!='undefined'&&https_port!=443)
|
||||
{toReplace+=":"+https_port;}
|
||||
uri=uri.replace(re,toReplace);}}
|
||||
return encodeURI(uri);}
|
||||
String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
|
||||
function xSleep(sec){sec=sec/1000;var now=new Date();var sleep=new Date();while(sleep.getTime()-now.getTime()<sec){sleep=new Date();}}
|
||||
function isDef(){for(var i=0;i<arguments.length;++i){if(typeof(arguments[i])=="undefined")return false;}
|
||||
return true;}
|
||||
var winopen_list=new Array();function winopen(url,target,attribute){if(typeof(xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);try{if(target!="_blank"&&winopen_list[target]){winopen_list[target].close();winopen_list[target]=null;}}catch(e){}
|
||||
if(typeof(target)=='undefined')target='_blank';if(typeof(attribute)=='undefined')attribute='';var win=window.open(url,target,attribute);win.focus();if(target!="_blank")winopen_list[target]=win;}
|
||||
function popopen(url,target){if(typeof(target)=="undefined")target="_blank";if(typeof(xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);winopen(url,target,"left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no");}
|
||||
function sendMailTo(to){location.href="mailto:"+to;}
|
||||
function move_url(url,open_wnidow){if(!url)return false;if(typeof(open_wnidow)=='undefined')open_wnidow='N';if(open_wnidow=='N'){open_wnidow=false;}else{open_wnidow=true;}
|
||||
if(/^\./.test(url))url=request_uri+url;if(open_wnidow){winopen(url);}else{location.href=url;}
|
||||
return false;}
|
||||
function displayMultimedia(src,width,height,options){var html=_displayMultimedia(src,width,height,options);if(html)document.writeln(html);}
|
||||
function _displayMultimedia(src,width,height,options){if(src.indexOf('files')==0)src=request_uri+src;var defaults={wmode:'transparent',allowScriptAccess:'sameDomain',quality:'high',flashvars:'',autostart:false};var params=jQuery.extend(defaults,options||{});var autostart=(params.autostart&¶ms.autostart!='false')?'true':'false';delete(params.autostart);var clsid="";var codebase="";var html="";if(/\.(gif|jpg|jpeg|bmp|png)$/i.test(src)){html='<img src="'+src+'" width="'+width+'" height="'+height+'" />';}else if(/\.flv$/i.test(src)||/\.mov$/i.test(src)||/\.moov$/i.test(src)||/\.m4v$/i.test(src)){html='<embed src="'+request_uri+'common/tpl/images/flvplayer.swf" allowfullscreen="true" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="&file='+src+'&width='+width+'&height='+height+'&autostart='+autostart+'" wmode="'+params.wmode+'" />';}else if(/\.swf/i.test(src)){clsid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';if(typeof(enforce_ssl)!='undefined'&&enforce_ssl){codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";}
|
||||
else{codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";}
|
||||
html='<object classid="'+clsid+'" codebase="'+codebase+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'">';html+='<param name="movie" value="'+src+'" />';for(var name in params){if(params[name]!='undefined'&¶ms[name]!=''){html+='<param name="'+name+'" value="'+params[name]+'" />';}}
|
||||
html+=''
|
||||
+'<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'" flashvars="'+params.flashvars+'" wmode="'+params.wmode+'"></embed>'
|
||||
+'</object>';}else{if(jQuery.browser.mozilla||jQuery.browser.opera){autostart=(params.autostart&¶ms.autostart!='false')?'1':'0';}
|
||||
html='<embed src="'+src+'" autostart="'+autostart+'" width="'+width+'" height="'+height+'"';if(params.wmode=='transparent'){html+=' windowlessvideo="1"';}
|
||||
html+='></embed>';}
|
||||
return html;}
|
||||
function zbxe_folder_open(id){jQuery("#folder_open_"+id).hide();jQuery("#folder_close_"+id).show();jQuery("#folder_"+id).show();}
|
||||
function zbxe_folder_close(id){jQuery("#folder_open_"+id).show();jQuery("#folder_close_"+id).hide();jQuery("#folder_"+id).hide();}
|
||||
function setFixedPopupSize(){var $=jQuery;var $header=$('#popHeader');var $body=$('#popBody');if($body.length){if($body.height()>400){$body.css({overflow:'auto',overflowX:'hidden',height:400+'px'});}}
|
||||
var $win=$(window);var $pc=$('#popup_content');var w=Math.max($pc[0].offsetWidth,600);var h=$pc[0].offsetHeight;var dw=$win.width();var dh=$win.height();var _w=0,_h=0;if(w!=dw)_w=w-dw;if(h!=dh)_h=h-dh;if(_w||_h){window.resizeBy(_w,_h);}
|
||||
if(!arguments.callee.executed){setTimeout(setFixedPopupSize,300);arguments.callee.executed=true;}}
|
||||
function doCallModuleAction(module,action,target_srl){var params=new Array();params['target_srl']=target_srl;params['cur_mid']=current_mid;exec_xml(module,action,params,completeCallModuleAction);}
|
||||
function completeCallModuleAction(ret_obj,response_tags){if(ret_obj['message']!='success')alert(ret_obj['message']);location.reload();}
|
||||
function completeMessage(ret_obj){alert(ret_obj['message']);location.reload();}
|
||||
function doChangeLangType(obj){if(typeof(obj)=="string"){setLangType(obj);}else{var val=obj.options[obj.selectedIndex].value;setLangType(val);}
|
||||
location.href=location.href.setQuery('l','');}
|
||||
function setLangType(lang_type){var expire=new Date();expire.setTime(expire.getTime()+(7000*24*3600000));setCookie('lang_type',lang_type,expire,'/');}
|
||||
function doDocumentPreview(obj){var fo_obj=obj;while(fo_obj.nodeName!="FORM"){fo_obj=fo_obj.parentNode;}
|
||||
if(fo_obj.nodeName!="FORM")return;var editor_sequence=fo_obj.getAttribute('editor_sequence');var content=editorGetContent(editor_sequence);var win=window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");var dummy_obj=jQuery("#previewDocument");if(!dummy_obj.length){jQuery('<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'">'+'<input type="hidden" name="module" value="document" />'+'<input type="hidden" name="act" value="dispDocumentPreview" />'+'<input type="hidden" name="content" />'+'</form>').appendTo(document.body);dummy_obj=jQuery("#previewDocument")[0];}
|
||||
if(dummy_obj){dummy_obj.content.value=content;dummy_obj.submit();}}
|
||||
function doDocumentSave(obj){var editor_sequence=obj.form.getAttribute('editor_sequence');var prev_content=editorRelKeys[editor_sequence]['content'].value;if(typeof(editor_sequence)!='undefined'&&editor_sequence&&typeof(editorRelKeys)!='undefined'&&typeof(editorGetContent)=='function'){var content=editorGetContent(editor_sequence);editorRelKeys[editor_sequence]['content'].value=content;}
|
||||
var params={},responses=['error','message','document_srl'],elms=obj.form.elements,data=jQuery(obj.form).serializeArray();;jQuery.each(data,function(i,field){var val=jQuery.trim(field.value);if(!val)return true;if(/\[\]$/.test(field.name))field.name=field.name.replace(/\[\]$/,'');if(params[field.name])params[field.name]+='|@|'+val;else params[field.name]=field.value;});exec_xml('member','procMemberSaveDocument',params,completeDocumentSave,responses,params,obj.form);editorRelKeys[editor_sequence]['content'].value=prev_content;return false;}
|
||||
function completeDocumentSave(ret_obj){jQuery('input[name=document_srl]').eq(0).val(ret_obj['document_srl']);alert(ret_obj['message']);}
|
||||
var objForSavedDoc=null;function doDocumentLoad(obj){objForSavedDoc=obj.form;popopen(request_uri.setQuery('module','member').setQuery('act','dispSavedDocumentList'));}
|
||||
function doDocumentSelect(document_srl){if(!opener||!opener.objForSavedDoc){window.close();return;}
|
||||
opener.location.href=opener.current_url.setQuery('document_srl',document_srl).setQuery('act','dispBoardWrite');window.close();}
|
||||
function viewSkinInfo(module,skin){popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin,'SkinInfo');}
|
||||
var addedDocument=new Array();function doAddDocumentCart(obj){var srl=obj.value;addedDocument[addedDocument.length]=srl;setTimeout(function(){callAddDocumentCart(addedDocument.length);},100);}
|
||||
function callAddDocumentCart(document_length){if(addedDocument.length<1||document_length!=addedDocument.length)return;var params=new Array();params["srls"]=addedDocument.join(",");exec_xml("document","procDocumentAddCart",params,null);addedDocument=new Array();}
|
||||
function transRGB2Hex(value){if(!value)return value;if(value.indexOf('#')>-1)return value.replace(/^#/,'');if(value.toLowerCase().indexOf('rgb')<0)return value;value=value.replace(/^rgb\(/i,'').replace(/\)$/,'');value_list=value.split(',');var hex='';for(var i=0;i<value_list.length;i++){var color=parseInt(value_list[i],10).toString(16);if(color.length==1)color='0'+color;hex+=color;}
|
||||
return hex;}
|
||||
function toggleSecuritySignIn(){var href=location.href;if(/https:\/\//i.test(href))location.href=href.replace(/^https/i,'http');else location.href=href.replace(/^http/i,'https');}
|
||||
function reloadDocument(){location.reload();}
|
||||
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._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+
|
||||
this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+
|
||||
this._keyStr.charAt(enc3)+this._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=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._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=Base64._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;}}
|
||||
if(typeof(resizeImageContents)=='undefined'){function resizeImageContents(){}}
|
||||
if(typeof(activateOptionDisabled)=='undefined'){function activateOptionDisabled(){}}
|
||||
objectExtend=jQuery.extend;function toggleDisplay(objId){jQuery('#'+objId).toggle();}
|
||||
function checkboxSelectAll(formObj,name,checked){var itemName=name;var option={};if(typeof(formObj)!="undefined")option.wrap=formObj;if(typeof(checked)!="undefined")option.checked=checked;XE.checkboxToggleAll(itemName,option);}
|
||||
function clickCheckBoxAll(formObj,name){var itemName=name;var option={doClick:true};if(typeof(formObj)!="undefined")option.wrap=formObj;XE.checkboxToggleAll(itemName,option);}
|
||||
function svc_folder_open(id){jQuery("#_folder_open_"+id).hide();jQuery("#_folder_close_"+id).show();jQuery("#_folder_"+id).show();}
|
||||
function svc_folder_close(id){jQuery("#_folder_open_"+id).show();jQuery("#_folder_close_"+id).hide();jQuery("#_folder_"+id).hide();}
|
||||
function open_calendar(fo_id,day_str,callback_func){if(typeof(day_str)=="undefined")day_str="";var url="./common/tpl/calendar.php?";if(fo_id)url+="fo_id="+fo_id;if(day_str)url+="&day_str="+day_str;if(callback_func)url+="&callback_func="+callback_func;popopen(url,'Calendar');}
|
||||
var loaded_popup_menus=XE.loaded_popup_menus;function createPopupMenu(){}
|
||||
function chkPopupMenu(){}
|
||||
function displayPopupMenu(ret_obj,response_tags,params){XE.displayPopupMenu(ret_obj,response_tags,params);}
|
||||
function GetObjLeft(obj){return jQuery(obj).offset().left;}
|
||||
function GetObjTop(obj){return jQuery(obj).offset().top;}
|
||||
function replaceOuterHTML(obj,html){jQuery(obj).replaceWith(html);}
|
||||
function getOuterHTML(obj){return jQuery(obj).html().trim();}
|
||||
function setCookie(name,value,expire,path){var s_cookie=name+"="+escape(value)+
|
||||
((!expire)?"":("; expires="+expire.toGMTString()))+"; path="+((!path)?"/":path);document.cookie=s_cookie;}
|
||||
jQuery(function(){jQuery(".lang_code").each(function()
|
||||
{var objText=jQuery(this);var targetName=objText.attr("id");if(typeof(targetName)=="undefined")targetName=objText.attr("name");if(typeof(targetName)=="undefined")return;objText.after("<a href='"+request_uri.setQuery('module','module').setQuery('act','dispModuleAdminLangcode').setQuery('target',targetName)+"' class='buttonSet buttonSetting' onclick='popopen(this.href);return false;'><span>find_langcode</span></a>");});});
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
|
||||
// (c) 2008 Angus Turnbull http://www.twinhelix.com
|
||||
|
||||
// This is licensed under the GNU LGPL, version 2.1 or later.
|
||||
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
var IEPNGFix=window.IEPNGFix||{};IEPNGFix.tileBG=function(elm,pngSrc,ready){var data=this.data[elm.uniqueID],elmW=Math.max(elm.clientWidth,elm.scrollWidth),elmH=Math.max(elm.clientHeight,elm.scrollHeight),bgX=elm.currentStyle.backgroundPositionX,bgY=elm.currentStyle.backgroundPositionY,bgR=elm.currentStyle.backgroundRepeat;if(!data.tiles){data.tiles={elm:elm,src:'',cache:[],img:new Image(),old:{}};}
|
||||
var tiles=data.tiles,pngW=tiles.img.width,pngH=tiles.img.height;if(pngSrc){if(!ready&&pngSrc!=tiles.src){tiles.img.onload=function(){this.onload=null;IEPNGFix.tileBG(elm,pngSrc,1);};return tiles.img.src=pngSrc;}}else{if(tiles.src)ready=1;pngW=pngH=0;}
|
||||
tiles.src=pngSrc;if(!ready&&elmW==tiles.old.w&&elmH==tiles.old.h&&bgX==tiles.old.x&&bgY==tiles.old.y&&bgR==tiles.old.r){return;}
|
||||
var pos={top:'0%',left:'0%',center:'50%',bottom:'100%',right:'100%'},x,y,pc;x=pos[bgX]||bgX;y=pos[bgY]||bgY;if(pc=x.match(/(\d+)%/)){x=Math.round((elmW-pngW)*(parseInt(pc[1])/100));}
|
||||
if(pc=y.match(/(\d+)%/)){y=Math.round((elmH-pngH)*(parseInt(pc[1])/100));}
|
||||
x=parseInt(x);y=parseInt(y);var repeatX={'repeat':1,'repeat-x':1}[bgR],repeatY={'repeat':1,'repeat-y':1}[bgR];if(repeatX){x%=pngW;if(x>0)x-=pngW;}
|
||||
if(repeatY){y%=pngH;if(y>0)y-=pngH;}
|
||||
this.hook.enabled=0;if(!({relative:1,absolute:1}[elm.currentStyle.position])){elm.style.position='relative';}
|
||||
var count=0,xPos,maxX=repeatX?elmW:x+0.1,yPos,maxY=repeatY?elmH:y+0.1,d,s,isNew;if(pngW&&pngH){for(xPos=x;xPos<maxX;xPos+=pngW){for(yPos=y;yPos<maxY;yPos+=pngH){isNew=0;if(!tiles.cache[count]){tiles.cache[count]=document.createElement('div');isNew=1;}
|
||||
var clipR=(xPos+pngW>elmW?elmW-xPos:pngW),clipB=(yPos+pngH>elmH?elmH-yPos:pngH);d=tiles.cache[count];s=d.style;s.behavior='none';s.left=xPos+'px';s.top=yPos+'px';s.width=clipR+'px';s.height=clipB+'px';s.clip='rect('+
|
||||
(yPos<0?0-yPos:0)+'px,'+
|
||||
clipR+'px,'+
|
||||
clipB+'px,'+
|
||||
(xPos<0?0-xPos:0)+'px)';s.display='block';if(isNew){s.position='absolute';s.zIndex=-999;if(elm.firstChild){elm.insertBefore(d,elm.firstChild);}else{elm.appendChild(d);}}
|
||||
this.fix(d,pngSrc,0);count++;}}}
|
||||
while(count<tiles.cache.length){this.fix(tiles.cache[count],'',0);tiles.cache[count++].style.display='none';}
|
||||
// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
|
||||
// (c) 2008 Angus Turnbull http://www.twinhelix.com
|
||||
|
||||
// This is licensed under the GNU LGPL, version 2.1 or later.
|
||||
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
var IEPNGFix=window.IEPNGFix||{};IEPNGFix.tileBG=function(elm,pngSrc,ready){var data=this.data[elm.uniqueID],elmW=Math.max(elm.clientWidth,elm.scrollWidth),elmH=Math.max(elm.clientHeight,elm.scrollHeight),bgX=elm.currentStyle.backgroundPositionX,bgY=elm.currentStyle.backgroundPositionY,bgR=elm.currentStyle.backgroundRepeat;if(!data.tiles){data.tiles={elm:elm,src:'',cache:[],img:new Image(),old:{}};}
|
||||
var tiles=data.tiles,pngW=tiles.img.width,pngH=tiles.img.height;if(pngSrc){if(!ready&&pngSrc!=tiles.src){tiles.img.onload=function(){this.onload=null;IEPNGFix.tileBG(elm,pngSrc,1);};return tiles.img.src=pngSrc;}}else{if(tiles.src)ready=1;pngW=pngH=0;}
|
||||
tiles.src=pngSrc;if(!ready&&elmW==tiles.old.w&&elmH==tiles.old.h&&bgX==tiles.old.x&&bgY==tiles.old.y&&bgR==tiles.old.r){return;}
|
||||
var pos={top:'0%',left:'0%',center:'50%',bottom:'100%',right:'100%'},x,y,pc;x=pos[bgX]||bgX;y=pos[bgY]||bgY;if(pc=x.match(/(\d+)%/)){x=Math.round((elmW-pngW)*(parseInt(pc[1])/100));}
|
||||
if(pc=y.match(/(\d+)%/)){y=Math.round((elmH-pngH)*(parseInt(pc[1])/100));}
|
||||
x=parseInt(x);y=parseInt(y);var repeatX={'repeat':1,'repeat-x':1}[bgR],repeatY={'repeat':1,'repeat-y':1}[bgR];if(repeatX){x%=pngW;if(x>0)x-=pngW;}
|
||||
if(repeatY){y%=pngH;if(y>0)y-=pngH;}
|
||||
this.hook.enabled=0;if(!({relative:1,absolute:1}[elm.currentStyle.position])){elm.style.position='relative';}
|
||||
var count=0,xPos,maxX=repeatX?elmW:x+0.1,yPos,maxY=repeatY?elmH:y+0.1,d,s,isNew;if(pngW&&pngH){for(xPos=x;xPos<maxX;xPos+=pngW){for(yPos=y;yPos<maxY;yPos+=pngH){isNew=0;if(!tiles.cache[count]){tiles.cache[count]=document.createElement('div');isNew=1;}
|
||||
var clipR=(xPos+pngW>elmW?elmW-xPos:pngW),clipB=(yPos+pngH>elmH?elmH-yPos:pngH);d=tiles.cache[count];s=d.style;s.behavior='none';s.left=xPos+'px';s.top=yPos+'px';s.width=clipR+'px';s.height=clipB+'px';s.clip='rect('+
|
||||
(yPos<0?0-yPos:0)+'px,'+
|
||||
clipR+'px,'+
|
||||
clipB+'px,'+
|
||||
(xPos<0?0-xPos:0)+'px)';s.display='block';if(isNew){s.position='absolute';s.zIndex=-999;if(elm.firstChild){elm.insertBefore(d,elm.firstChild);}else{elm.appendChild(d);}}
|
||||
this.fix(d,pngSrc,0);count++;}}}
|
||||
while(count<tiles.cache.length){this.fix(tiles.cache[count],'',0);tiles.cache[count++].style.display='none';}
|
||||
this.hook.enabled=1;tiles.old={w:elmW,h:elmH,x:bgX,y:bgY,r:bgR};};IEPNGFix.update=function(){for(var i in IEPNGFix.data){var t=IEPNGFix.data[i].tiles;if(t&&t.elm&&t.src){IEPNGFix.tileBG(t.elm,t.src);}}};IEPNGFix.update.timer=0;if(window.attachEvent&&!window.opera){window.attachEvent('onresize',function(){clearTimeout(IEPNGFix.update.timer);IEPNGFix.update.timer=setTimeout(IEPNGFix.update,100);});}
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
/**
|
||||
* @file js_app.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief XE JavaScript Application Framework (JAF)
|
||||
* @namespace xe
|
||||
* @update 20100701
|
||||
*/
|
||||
|
||||
(function($){var _xe_base,_app_base,_plugin_base;var _apps=[];_xe_base={getName:function(){return'Core';},createApp:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_app_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},createPlugin:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_plugin_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},getApps:function(){return $.makeArray(_apps);},getApp:function(indexOrName){indexOrName=(indexOrName||'').toLowerCase();if(typeof _apps[indexOrName]!='undefined'){return _apps[indexOrName];}else{return null;}},registerApp:function(oApp){var sName=oApp.getName().toLowerCase();_apps.push(oApp);if(!$.isArray(_apps[sName])){_apps[sName]=[];}
|
||||
_apps[sName].push(oApp);oApp.parent=this;if($.isFunction(oApp.activate))oApp.activate();},unregisterApp:function(oApp){var sName=oPlugin.getName().toLowerCase();var nIndex=$.inArray(oApp,_apps);if(nIndex>=0)_apps.splice(nIndex,1);if($.isArray(_apps[sName])){nIndex=$.inArray(oApp,_apps[sName]);if(nIndex>=0)_apps[sName].splice(nIndex,1);}
|
||||
if($.isFunction(oApp.deactivate))oApp.deactivate();},broadcast:function(msg,params){this._broadcast(this,msg,params);},_broadcast:function(sender,msg,params){for(var i=0;i<_apps.length;i++){_apps[i]._cast(sender,msg,params);}
|
||||
this._cast(sender,msg,params);}}
|
||||
_app_base={_plugins:[],_messages:{},getPlugin:function(sPluginName){sPluginName=sPluginName.toLowerCase();if($.isArray(this._plugins[sPluginName])){return this._plugins[sPluginName];}else{return[];}},registerPlugin:function(oPlugin){var self=this;var sName=oPlugin.getName().toLowerCase();if($.inArray(oPlugin,this._plugins)>=0)return false;this._plugins.push(oPlugin);if(!$.isArray(this._plugins[sName]))this._plugins[sName]=[];this._plugins[sName].push(oPlugin);$.each(oPlugin._binded_fn,function(api,fn){self.registerHandler(api,fn);});oPlugin.oApp=this;if($.isFunction(oPlugin.activate))oPlugin.activate();return true;},registerHandler:function(api,func){var msgs=this._messages;api=api.toUpperCase();if(!$.isArray(msgs[api]))msgs[api]=[];msgs[api].push(func);},cast:function(msg,params){return this._cast(this,msg,params||[]);},broadcast:function(sender,msg,params){if(this.parent&&this.parent._broadcast){this.parent._broadcast(sender,msg,params);}},_cast:function(sender,msg,params){var i,len;var aMsg=this._messages;msg=msg.toUpperCase();if(aMsg['BEFORE_'+msg]||this['API_BEFORE_'+msg]){var bContinue=this._cast(sender,'BEFORE_'+msg,params);if(!bContinue)return;}
|
||||
var vRet=[],sFn='API_'+msg;if($.isArray(aMsg[msg])){for(i=0;i<aMsg[msg].length;i++){vRet.push(aMsg[msg][i](sender,params));}}
|
||||
if(vRet.length<2)vRet=vRet[0];if(aMsg['AFTER_'+msg]||this['API_AFTER_'+msg]){this._cast(sender,'AFTER_'+msg,params);}
|
||||
if(!/^(?:AFTER|BEFORE)_/.test(msg)){return vRet;}else{return $.isArray(vRet)?($.inArray(false,vRet)<0):((typeof vRet=='undefined')?true:!!vRet);}}};_plugin_base={oApp:null,cast:function(msg,params){if(this.oApp&&this.oApp._cast){return this.oApp._cast(this,msg,params||[]);}},broadcast:function(msg,params){if(this.oApp&&this.oApp.broadcast){this.oApp.broadcast(this,mag,params||[]);}}};function getTypeBase(){var _base=function(){var self=this;var pool=null;if($.isArray(this._plugins))this._plugins=[];if(this._messages)this._messages={};else this._binded_fn={};$.each(this,function(key,val){if(!$.isFunction(val))return true;if(!/^API_([A-Z0-9_]+)$/.test(key))return true;var api=RegExp.$1;var fn=function(sender,params){return self[key](sender,params)};if(self._messages)self._messages[api]=[fn];else self._binded_fn[api]=fn;});if($.isFunction(this.init))this.init.apply(this,arguments);};return _base;}
|
||||
/**
|
||||
* @file js_app.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief XE JavaScript Application Framework (JAF)
|
||||
* @namespace xe
|
||||
* @update 20100701
|
||||
*/
|
||||
|
||||
(function($){var _xe_base,_app_base,_plugin_base;var _apps=[];_xe_base={getName:function(){return'Core';},createApp:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_app_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},createPlugin:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_plugin_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},getApps:function(){return $.makeArray(_apps);},getApp:function(indexOrName){indexOrName=(indexOrName||'').toLowerCase();if(typeof _apps[indexOrName]!='undefined'){return _apps[indexOrName];}else{return null;}},registerApp:function(oApp){var sName=oApp.getName().toLowerCase();_apps.push(oApp);if(!$.isArray(_apps[sName])){_apps[sName]=[];}
|
||||
_apps[sName].push(oApp);oApp.parent=this;if($.isFunction(oApp.activate))oApp.activate();},unregisterApp:function(oApp){var sName=oPlugin.getName().toLowerCase();var nIndex=$.inArray(oApp,_apps);if(nIndex>=0)_apps.splice(nIndex,1);if($.isArray(_apps[sName])){nIndex=$.inArray(oApp,_apps[sName]);if(nIndex>=0)_apps[sName].splice(nIndex,1);}
|
||||
if($.isFunction(oApp.deactivate))oApp.deactivate();},broadcast:function(msg,params){this._broadcast(this,msg,params);},_broadcast:function(sender,msg,params){for(var i=0;i<_apps.length;i++){_apps[i]._cast(sender,msg,params);}
|
||||
this._cast(sender,msg,params);}}
|
||||
_app_base={_plugins:[],_messages:{},getPlugin:function(sPluginName){sPluginName=sPluginName.toLowerCase();if($.isArray(this._plugins[sPluginName])){return this._plugins[sPluginName];}else{return[];}},registerPlugin:function(oPlugin){var self=this;var sName=oPlugin.getName().toLowerCase();if($.inArray(oPlugin,this._plugins)>=0)return false;this._plugins.push(oPlugin);if(!$.isArray(this._plugins[sName]))this._plugins[sName]=[];this._plugins[sName].push(oPlugin);$.each(oPlugin._binded_fn,function(api,fn){self.registerHandler(api,fn);});oPlugin.oApp=this;if($.isFunction(oPlugin.activate))oPlugin.activate();return true;},registerHandler:function(api,func){var msgs=this._messages;api=api.toUpperCase();if(!$.isArray(msgs[api]))msgs[api]=[];msgs[api].push(func);},cast:function(msg,params){return this._cast(this,msg,params||[]);},broadcast:function(sender,msg,params){if(this.parent&&this.parent._broadcast){this.parent._broadcast(sender,msg,params);}},_cast:function(sender,msg,params){var i,len;var aMsg=this._messages;msg=msg.toUpperCase();if(aMsg['BEFORE_'+msg]||this['API_BEFORE_'+msg]){var bContinue=this._cast(sender,'BEFORE_'+msg,params);if(!bContinue)return;}
|
||||
var vRet=[],sFn='API_'+msg;if($.isArray(aMsg[msg])){for(i=0;i<aMsg[msg].length;i++){vRet.push(aMsg[msg][i](sender,params));}}
|
||||
if(vRet.length<2)vRet=vRet[0];if(aMsg['AFTER_'+msg]||this['API_AFTER_'+msg]){this._cast(sender,'AFTER_'+msg,params);}
|
||||
if(!/^(?:AFTER|BEFORE)_/.test(msg)){return vRet;}else{return $.isArray(vRet)?($.inArray(false,vRet)<0):((typeof vRet=='undefined')?true:!!vRet);}}};_plugin_base={oApp:null,cast:function(msg,params){if(this.oApp&&this.oApp._cast){return this.oApp._cast(this,msg,params||[]);}},broadcast:function(msg,params){if(this.oApp&&this.oApp.broadcast){this.oApp.broadcast(this,mag,params||[]);}}};function getTypeBase(){var _base=function(){var self=this;var pool=null;if($.isArray(this._plugins))this._plugins=[];if(this._messages)this._messages={};else this._binded_fn={};$.each(this,function(key,val){if(!$.isFunction(val))return true;if(!/^API_([A-Z0-9_]+)$/.test(key))return true;var api=RegExp.$1;var fn=function(sender,params){return self[key](sender,params)};if(self._messages)self._messages[api]=[fn];else self._binded_fn[api]=fn;});if($.isFunction(this.init))this.init.apply(this,arguments);};return _base;}
|
||||
window.xe=$.extend(_app_base,_xe_base);window.xe.lang={};$(function(){xe.broadcast('ONREADY');});$(window).load(function(){xe.broadcast('ONLOAD');});})(jQuery);
|
||||
|
|
@ -1,82 +1,82 @@
|
|||
|
||||
;(function($) {
|
||||
|
||||
var defaults = {
|
||||
};
|
||||
|
||||
var filebox = {
|
||||
selected : null,
|
||||
/**
|
||||
* 파일 박스 창 팝업
|
||||
*/
|
||||
open : function(input_obj, filter) {
|
||||
this.selected = input_obj;
|
||||
|
||||
var url = request_uri
|
||||
.setQuery('module', 'module')
|
||||
.setQuery('act', 'dispModuleFileBox')
|
||||
.setQuery('input', this.selected.name)
|
||||
.setQuery('filter', filter);
|
||||
|
||||
popopen(url, 'filebox');
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 선택
|
||||
*/
|
||||
selectFile : function(file_url, module_filebox_srl){
|
||||
var target = $(opener.XE.filebox.selected);
|
||||
var target_name = target.attr('name');
|
||||
|
||||
target.val(file_url);
|
||||
var html = _displayMultimedia(file_url, '100%', '100%');
|
||||
$('#filebox_preview_' + target_name, opener.document).html(html).show();
|
||||
$('#filebox_cancel_' + target_name, opener.document).show();
|
||||
|
||||
window.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 선택 취소
|
||||
*/
|
||||
cancel : function(name) {
|
||||
$('[name=' + name + ']').val('');
|
||||
$('#filebox_preview_' + name).hide().html('');
|
||||
$('#filebox_cancel_' + name).hide();
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 삭제
|
||||
*/
|
||||
deleteFile : function(module_filebox_srl){
|
||||
var params = {
|
||||
'module_filebox_srl' : module_filebox_srl
|
||||
};
|
||||
|
||||
$.exec_json('module.procModuleFileBoxDelete', params, function() { document.location.reload(); });
|
||||
},
|
||||
|
||||
/**
|
||||
* 초기화
|
||||
*/
|
||||
init : function(name) {
|
||||
var file;
|
||||
|
||||
if(opener && opener.selectedWidget && opener.selectedWidget.getAttribute("widget")) {
|
||||
file = opener.selectedWidget.getAttribute(name);
|
||||
} else if($('[name=' + name + ']').val()) {
|
||||
file = $('[name=' + name + ']').val();
|
||||
}
|
||||
|
||||
if(file) {
|
||||
var html = _displayMultimedia(file, '100%', '100%');
|
||||
$('#filebox_preview_' + name).html(html).show();
|
||||
$('#filebox_cancel_' + name).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// XE에 담기
|
||||
$.extend(window.XE, {'filebox' : filebox});
|
||||
|
||||
}) (jQuery);
|
||||
|
||||
;(function($) {
|
||||
|
||||
var defaults = {
|
||||
};
|
||||
|
||||
var filebox = {
|
||||
selected : null,
|
||||
/**
|
||||
* 파일 박스 창 팝업
|
||||
*/
|
||||
open : function(input_obj, filter) {
|
||||
this.selected = input_obj;
|
||||
|
||||
var url = request_uri
|
||||
.setQuery('module', 'module')
|
||||
.setQuery('act', 'dispModuleFileBox')
|
||||
.setQuery('input', this.selected.name)
|
||||
.setQuery('filter', filter);
|
||||
|
||||
popopen(url, 'filebox');
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 선택
|
||||
*/
|
||||
selectFile : function(file_url, module_filebox_srl){
|
||||
var target = $(opener.XE.filebox.selected);
|
||||
var target_name = target.attr('name');
|
||||
|
||||
target.val(file_url);
|
||||
var html = _displayMultimedia(file_url, '100%', '100%');
|
||||
$('#filebox_preview_' + target_name, opener.document).html(html).show();
|
||||
$('#filebox_cancel_' + target_name, opener.document).show();
|
||||
|
||||
window.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 선택 취소
|
||||
*/
|
||||
cancel : function(name) {
|
||||
$('[name=' + name + ']').val('');
|
||||
$('#filebox_preview_' + name).hide().html('');
|
||||
$('#filebox_cancel_' + name).hide();
|
||||
},
|
||||
|
||||
/**
|
||||
* 파일 삭제
|
||||
*/
|
||||
deleteFile : function(module_filebox_srl){
|
||||
var params = {
|
||||
'module_filebox_srl' : module_filebox_srl
|
||||
};
|
||||
|
||||
$.exec_json('module.procModuleFileBoxDelete', params, function() { document.location.reload(); });
|
||||
},
|
||||
|
||||
/**
|
||||
* 초기화
|
||||
*/
|
||||
init : function(name) {
|
||||
var file;
|
||||
|
||||
if(opener && opener.selectedWidget && opener.selectedWidget.getAttribute("widget")) {
|
||||
file = opener.selectedWidget.getAttribute(name);
|
||||
} else if($('[name=' + name + ']').val()) {
|
||||
file = $('[name=' + name + ']').val();
|
||||
}
|
||||
|
||||
if(file) {
|
||||
var html = _displayMultimedia(file, '100%', '100%');
|
||||
$('#filebox_preview_' + name).html(html).show();
|
||||
$('#filebox_cancel_' + name).show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// XE에 담기
|
||||
$.extend(window.XE, {'filebox' : filebox});
|
||||
|
||||
}) (jQuery);
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
@charset "utf-8";
|
||||
/* Calendar */
|
||||
.ui-calendar {display:none; padding:25px 15px 15px 15px; position:absolute; border:2px solid #737373; background:#fff; color:#333; *zoom:1;}
|
||||
.ui-calendar .close{ position:absolute; _display:block !important; top:10px; right:15px; width:17px; height:17px; border:0; padding:0; background:url(./img/buttonCloseLayerX.gif) no-repeat center center; cursor:pointer; *zoom:1;}
|
||||
.ui-calendar .close span{ position:absolute; width:0; height:0; font-size:0; line-height:0; overflow:hidden; z-index:-1; visibility:hidden;}
|
||||
.ui-calendar table{ border:0; border-spacing:0; _width:200px;}
|
||||
.ui-calendar caption{ font-weight:bold; text-align:center; position:relative;}
|
||||
.ui-calendar caption span{ display:block; position:relative; padding:10px 0 15px 0; *zoom:1;}
|
||||
.ui-calendar caption .today{ font-size:11px; border:0; padding:0; border-bottom:1px solid; background:none; cursor:pointer;}
|
||||
.ui-calendar caption .today span{text-decoration:underline;}
|
||||
.ui-calendar caption .navi{ position:absolute; top:10px; border:0; padding:0; width:17px; height:18px; background-color:transparent; background-image:url(./img/buttonPaginate.gif); background-repeat:no-repeat; cursor:pointer;}
|
||||
.ui-calendar caption .navi span{ position:absolute; width:0; height:0; overflow:hidden; font-size:0; line-height:0; z-index:-1; visibility:hidden;}
|
||||
.ui-calendar caption .navi.prev{ left:20px; background-position:left top;}
|
||||
.ui-calendar caption .navi.next{ right:20px; background-position:right top;}
|
||||
.ui-calendar caption .navi.prev_year,
|
||||
.ui-calendar caption .navi.next_year{ width:22px; background-image:url(./img/buttonPaginateDuble.gif); }
|
||||
.ui-calendar caption .navi.prev_year{ left:0; background-position:left top;}
|
||||
.ui-calendar caption .navi.next_year{ right:0; background-position:right top;}
|
||||
.ui-calendar th,
|
||||
.ui-calendar td{ border:0; text-align:center;}
|
||||
.ui-calendar th{ color:#666; background:#f2f2f2; padding:3px 8px;}
|
||||
.ui-calendar td{ font-size:11px; padding:3px 8px;}
|
||||
.ui-calendar td button{ padding:0; border:0; background:none; cursor:pointer; width:20px; font-size:11px; font-family:Tahoma, Sans-serif;}
|
||||
.ui-calendar td button.today{ font-weight:bold;}
|
||||
.ui-calendar td button.book,
|
||||
.ui-calendar td button.active,
|
||||
.ui-calendar tr.active button{ background:#ff4747; color:#fff;}
|
||||
.ui-calendar .sun,
|
||||
.ui-calendar .sun button{ color:#ff1a1a;}
|
||||
|
||||
.ui-calendar table.month{ border-top:1px solid #f2f2f2; border-left:1px solid #f2f2f2;}
|
||||
.ui-calendar table.month td{ border-right:1px solid #f2f2f2; border-bottom:1px solid #f2f2f2;}
|
||||
.ui-calendar table.month td button{ width:50px; color:#bababa;}
|
||||
.ui-calendar table.month td button.past{ color:#333;}
|
||||
.ui-calendar table.month td button.active{ color:#fff;}
|
||||
@charset "utf-8";
|
||||
/* Calendar */
|
||||
.ui-calendar {display:none; padding:25px 15px 15px 15px; position:absolute; border:2px solid #737373; background:#fff; color:#333; *zoom:1;}
|
||||
.ui-calendar .close{ position:absolute; _display:block !important; top:10px; right:15px; width:17px; height:17px; border:0; padding:0; background:url(./img/buttonCloseLayerX.gif) no-repeat center center; cursor:pointer; *zoom:1;}
|
||||
.ui-calendar .close span{ position:absolute; width:0; height:0; font-size:0; line-height:0; overflow:hidden; z-index:-1; visibility:hidden;}
|
||||
.ui-calendar table{ border:0; border-spacing:0; _width:200px;}
|
||||
.ui-calendar caption{ font-weight:bold; text-align:center; position:relative;}
|
||||
.ui-calendar caption span{ display:block; position:relative; padding:10px 0 15px 0; *zoom:1;}
|
||||
.ui-calendar caption .today{ font-size:11px; border:0; padding:0; border-bottom:1px solid; background:none; cursor:pointer;}
|
||||
.ui-calendar caption .today span{text-decoration:underline;}
|
||||
.ui-calendar caption .navi{ position:absolute; top:10px; border:0; padding:0; width:17px; height:18px; background-color:transparent; background-image:url(./img/buttonPaginate.gif); background-repeat:no-repeat; cursor:pointer;}
|
||||
.ui-calendar caption .navi span{ position:absolute; width:0; height:0; overflow:hidden; font-size:0; line-height:0; z-index:-1; visibility:hidden;}
|
||||
.ui-calendar caption .navi.prev{ left:20px; background-position:left top;}
|
||||
.ui-calendar caption .navi.next{ right:20px; background-position:right top;}
|
||||
.ui-calendar caption .navi.prev_year,
|
||||
.ui-calendar caption .navi.next_year{ width:22px; background-image:url(./img/buttonPaginateDuble.gif); }
|
||||
.ui-calendar caption .navi.prev_year{ left:0; background-position:left top;}
|
||||
.ui-calendar caption .navi.next_year{ right:0; background-position:right top;}
|
||||
.ui-calendar th,
|
||||
.ui-calendar td{ border:0; text-align:center;}
|
||||
.ui-calendar th{ color:#666; background:#f2f2f2; padding:3px 8px;}
|
||||
.ui-calendar td{ font-size:11px; padding:3px 8px;}
|
||||
.ui-calendar td button{ padding:0; border:0; background:none; cursor:pointer; width:20px; font-size:11px; font-family:Tahoma, Sans-serif;}
|
||||
.ui-calendar td button.today{ font-weight:bold;}
|
||||
.ui-calendar td button.book,
|
||||
.ui-calendar td button.active,
|
||||
.ui-calendar tr.active button{ background:#ff4747; color:#fff;}
|
||||
.ui-calendar .sun,
|
||||
.ui-calendar .sun button{ color:#ff1a1a;}
|
||||
|
||||
.ui-calendar table.month{ border-top:1px solid #f2f2f2; border-left:1px solid #f2f2f2;}
|
||||
.ui-calendar table.month td{ border-right:1px solid #f2f2f2; border-bottom:1px solid #f2f2f2;}
|
||||
.ui-calendar table.month td button{ width:50px; color:#bababa;}
|
||||
.ui-calendar table.month td button.past{ color:#333;}
|
||||
.ui-calendar table.month td button.active{ color:#fff;}
|
||||
|
|
|
|||
|
|
@ -1,368 +1,368 @@
|
|||
/**
|
||||
* @brief XE Calendar
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*
|
||||
* 사용법
|
||||
*
|
||||
**/
|
||||
(function($){
|
||||
|
||||
if (!$.ui) $.ui = {};
|
||||
$.extend($.ui, { calendar: { version:'0.3' } });
|
||||
|
||||
var PROP_NAME = 'calendar';
|
||||
var index = 0;
|
||||
var calendars = {};
|
||||
var template = {calendar:'',month:''};
|
||||
|
||||
function Calendar() {
|
||||
}
|
||||
|
||||
$.extend(Calendar.prototype, {
|
||||
_activeCalendar : null,
|
||||
_getuid : function(obj) {
|
||||
var uid = obj.attr('class').match(/ui-calendar-(\d+-\d+)/);
|
||||
|
||||
if (!uid) return -1;
|
||||
return uid[1];
|
||||
},
|
||||
_show : function(obj) {
|
||||
if (this._activeCalendar) this._hide(this._activeCalendar);
|
||||
|
||||
// disabled?
|
||||
if (obj.hasClass('ui-calendar-disabled')) return;
|
||||
|
||||
// Active Calendar
|
||||
this._activeCalendar = obj.show(300);
|
||||
},
|
||||
_hide : function(obj) {
|
||||
if (this._activeCalendar && this._activeCalendar.get(0) == obj.get(0)) this._activeCalendar = null;
|
||||
obj.hide(300);
|
||||
},
|
||||
_toggle : function(obj) {
|
||||
(obj.css('display' ) == 'none')?this._show(obj):this._hide(obj);
|
||||
},
|
||||
_attachCalendar : function(obj, options) {
|
||||
if ((obj=$(obj)).hasClass('ui-calendar')) return;
|
||||
|
||||
var uid = $.calendar.uuid+'-'+(index++);
|
||||
var c = calendars[uid] = {};
|
||||
|
||||
// uid 추가
|
||||
obj.addClass('ui-calendar-'+uid).mousedown(function(){return false});
|
||||
|
||||
// default options
|
||||
c.options = $.extend({
|
||||
type : 'day',
|
||||
activeDate : ''
|
||||
}, options||{});
|
||||
c.lang = $.extend({
|
||||
weekdays : 'Sun,Mon,Tue,Wed,Thu,Fri,Sat',
|
||||
today : 'Today',
|
||||
prevmonth : 'Prev Month',
|
||||
nextmonth : 'Next Month',
|
||||
prevyear : 'Prev Year',
|
||||
nextyear : 'Next Year',
|
||||
close : 'Close'
|
||||
}, options.lang||{});
|
||||
|
||||
c.lang.weekdays = c.lang.weekdays.split(',');
|
||||
|
||||
// 날짜 설정
|
||||
var d;
|
||||
if (typeof c.options.activeDate == 'string' && c.options.activeDate) {
|
||||
var s = c.options.activeDate.split('/');
|
||||
d = new Date(s[0], s[1]-1, s[2]-0);
|
||||
} else {
|
||||
d = new Date();
|
||||
}
|
||||
this._setDate(obj, d);
|
||||
|
||||
// 토글 버튼
|
||||
if (c.options.button) {
|
||||
(c.button=$(c.options.button)).click(function(){ obj.calendar('toggle') });
|
||||
}
|
||||
|
||||
// 클래스 추가
|
||||
obj.addClass('ui-calendar');
|
||||
|
||||
// position 설정한 후, 좌표를 (0,0)으로 변경
|
||||
var pos = obj.css({position:'absolute',top:0,left:0}).show().offset();
|
||||
|
||||
// 버튼의 위치 구해서 좌표 조정
|
||||
var bpos = c.button.offset();
|
||||
var dx = bpos.left - pos.left;
|
||||
var dy = bpos.top - pos.top;
|
||||
|
||||
// 좌표 조정 후 레이어 숨김
|
||||
obj.css({top:(dy+c.button.height())+'px',left:dx+'px'}).hide();
|
||||
},
|
||||
_checkExternalClick : function(e) {
|
||||
if ($.calendar._activeCalendar) $.calendar._hide($.calendar._activeCalendar);
|
||||
},
|
||||
_processTemplate : function(tpl, vars) {
|
||||
tpl = (' '+tpl+' ').split(/[\{\}]/g);
|
||||
|
||||
for(var i=0; i < tpl.length; i++) {
|
||||
if (i%2) {
|
||||
if (/^[\w\.\[\]]+$/.test(tpl[i])) tpl[i] = 'try{v=vv.'+tpl[i]+'}catch(e){v=""};ret.push(v);';
|
||||
else if (/^@(\w+)\s+in\s+(\w+)$/.test(tpl[i])) tpl[i] = 'for(i=0,l=vv.'+RegExp.$2+'.length;i<l;i++) { vv.'+RegExp.$1+'=vv.'+RegExp.$2+'[i];';
|
||||
else if (tpl[i] == '/') tpl[i] = '};';
|
||||
else tpl[i] = 'ret.push("{'+tpl[i]+'}");';
|
||||
} else {
|
||||
tpl[i] = 'ret.push("'+tpl[i].replace(/"/g, '\\"')+'");'; //"
|
||||
}
|
||||
}
|
||||
|
||||
tpl.push('return ret.join("");');
|
||||
tpl = (['var i,l,v,t,ret=[];'].concat(tpl)).join('');
|
||||
|
||||
return (new Function('vv',tpl))(vars);
|
||||
},
|
||||
_draw : function(obj) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return;
|
||||
|
||||
var cal = calendars[uid];
|
||||
var tpl = (cal.options.type == 'month')?template.month:template.calendar;
|
||||
var v = {lang:cal.lang};
|
||||
|
||||
// 날짜 관련 변수
|
||||
v['yyyy'] = cal.date.getFullYear();
|
||||
v['yy'] = (v['yyyy']+'').substring(2);
|
||||
v['m'] = cal.date.getMonth() + 1;
|
||||
v['mm'] = v['m'] > 9?v['m']:'0'+v['m'];
|
||||
|
||||
// 연간 달력이 아니라면 이 달의 날짜를 구한다.
|
||||
if (cal.options.type != 'month') {
|
||||
// 날짜에 사용할 달력
|
||||
v['weeks'] = [];
|
||||
|
||||
var d = new Date(cal.date.getTime()), w = [];
|
||||
var last = (v.m!=2)? ((v.m+(v.m>7?1:0))%2?31:30) : ((new Date(v.yyyy,v.m-1,29)).getMonth()==v.m?29:28); // 마지막 날
|
||||
|
||||
d.setDate(1); // 1일로 설정 후 1일의 요일을 가져온다.
|
||||
var start = d.getDay(), end = last+start;
|
||||
|
||||
for(var i=0,len=end+(7-(end%7||7));i<len;i++) {
|
||||
if (i%7 == 0) v['weeks'].push(w=[]);
|
||||
if (i < start || i >= end) w.push(' ');
|
||||
else w.push('<button type="button" class="day'+v.yyyy+'-'+v.m+'-'+(i+1-start)+'">'+(i+1-start)+'</button>');
|
||||
}
|
||||
}
|
||||
|
||||
// 템플릿 처리
|
||||
tpl = this._processTemplate(tpl, v);
|
||||
obj.html(tpl);
|
||||
|
||||
// 선택한 날짜
|
||||
if (cal.options.type == 'month') {
|
||||
|
||||
} else {
|
||||
var t = new Date();
|
||||
obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('today');
|
||||
|
||||
t = cal.activeDate;
|
||||
obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('active');
|
||||
}
|
||||
|
||||
// 이벤트 핸들러
|
||||
obj.find('button.close').click(function(){ $.calendar._hide(obj); });
|
||||
obj.find('button.today').click(function(){ $.calendar._moveToday(obj); });
|
||||
if (cal.options.type == 'month') {
|
||||
obj.find('button.prev').click(function(){ $.calendar._prevYear(obj) });
|
||||
obj.find('button.next').click(function(){ $.calendar._nextYear(obj) });
|
||||
} else {
|
||||
obj.find('button.prev').click(function(){ $.calendar._prevMonth(obj) });
|
||||
obj.find('button.next').click(function(){ $.calendar._nextMonth(obj) });
|
||||
obj.find('button.prev_year').click(function(){ $.calendar._prevYear(obj) });
|
||||
obj.find('button.next_year').click(function(){ $.calendar._nextYear(obj) });
|
||||
}
|
||||
obj.find('td>button').click(function(){ $.calendar._selectDate(obj, $(this)) });
|
||||
},
|
||||
_selectDate : function(obj, btn) {
|
||||
var cal = calendars[ this._getuid(obj) ];
|
||||
var date = btn.attr('class').match(/day([\d\-]+)/);
|
||||
if (!date) return;
|
||||
|
||||
date = date[1].split('-');
|
||||
|
||||
var ad = cal.activeDate;
|
||||
ad.setFullYear(date[0]-0);
|
||||
ad.setMonth(date[1]-1);
|
||||
ad.setDate(date[2]-0);
|
||||
|
||||
this._setDate(obj, ad);
|
||||
},
|
||||
_setDate : function(obj, newDate) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return null;
|
||||
if (!newDate || !(newDate instanceof Date)) newDate = new Date();
|
||||
|
||||
var cal = calendars[uid];
|
||||
cal.activeDate = new Date(newDate.getTime());
|
||||
cal.date = new Date(newDate.getTime());
|
||||
this._draw(obj);
|
||||
|
||||
if ($.isFunction(cal.options.select) && obj.hasClass('ui-calendar')) {
|
||||
cal.options.select(newDate.getFullYear(), newDate.getMonth()+1, newDate.getDate());
|
||||
}
|
||||
},
|
||||
_getDate : function(obj, format) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return null;
|
||||
if (typeof format != 'string') return calendars[uid].activeDate;
|
||||
|
||||
// format string
|
||||
},
|
||||
_moveToday : function(obj) {
|
||||
calendars[this._getuid(obj)].date = new Date();
|
||||
this._draw(obj);
|
||||
},
|
||||
_prevMonth : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
var m = cal.date.getMonth();
|
||||
|
||||
cal.date.setDate(1);
|
||||
if (m == 0) {
|
||||
cal.date.setFullYear(cal.date.getFullYear()-1);
|
||||
cal.date.setMonth(11);
|
||||
} else {
|
||||
cal.date.setMonth(m-1);
|
||||
}
|
||||
|
||||
this._draw(obj);
|
||||
},
|
||||
_nextMonth : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
var m = cal.date.getMonth();
|
||||
|
||||
cal.date.setDate(1);
|
||||
if (m == 11) {
|
||||
cal.date.setFullYear(cal.date.getFullYear()+1);
|
||||
cal.date.setMonth(0);
|
||||
} else {
|
||||
cal.date.setMonth(m+1);
|
||||
}
|
||||
|
||||
this._draw(obj);
|
||||
},
|
||||
_prevYear : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
|
||||
cal.date.setFullYear(cal.date.getFullYear()-1);
|
||||
this._draw(obj);
|
||||
},
|
||||
_nextYear : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
|
||||
cal.date.setFullYear(cal.date.getFullYear()+1);
|
||||
this._draw(obj);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Invoke the calednar functionallity
|
||||
* @return jQuery object
|
||||
*/
|
||||
$.fn.calendar = function(options) {
|
||||
var args = $.makeArray(arguments);
|
||||
|
||||
if (!$.calendar.initialized) {
|
||||
$(document).mousedown($.calendar._checkExternalClick);
|
||||
$.calendar.initialized = true;
|
||||
}
|
||||
|
||||
if (typeof options == 'string' && $.inArray(options, ['getDate'])) {
|
||||
args.shift();
|
||||
return $.calendar['_'+options].apply($.calendar, [$(this[0])].concat(args) );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
if (typeof options == 'string') {
|
||||
args.shift();
|
||||
$.calendar['_'+ options].apply($.calendar, [$(this)].concat(args));
|
||||
} else {
|
||||
$.calendar._attachCalendar($(this), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.calendar = new Calendar(); // singleton instance
|
||||
$.calendar.initialized = false;
|
||||
$.calendar.uuid = new Date().getTime();
|
||||
$.calendar.version = $.ui.calendar.version;
|
||||
|
||||
// template
|
||||
template.calendar = '<button type="button" class="close"><span>{lang.close_layer}</span></button>\
|
||||
<table border="1" cellspacing="0" summary="달력에서 날짜를 선택하기">\
|
||||
<caption>\
|
||||
<span>\
|
||||
{yyyy}.{mm}.\
|
||||
<button type="button" class="today">{lang.today}</button>\
|
||||
<button type="button" class="navi prev"><span>{lang.prevmonth}</span></button>\
|
||||
<button type="button" class="navi next"><span>{lang.nextmonth}</span></button>\
|
||||
<button type="button" class="navi prev_year"><span>{lang.prevyear}</span></button>\
|
||||
<button type="button" class="navi next_year"><span>{lang.nextyear}</span></button>\
|
||||
</span>\
|
||||
</caption>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th scope="col" class="sun">{lang.weekdays[0]}</th>\
|
||||
<th scope="col">{lang.weekdays[1]}</th>\
|
||||
<th scope="col">{lang.weekdays[2]}</th>\
|
||||
<th scope="col">{lang.weekdays[3]}</th>\
|
||||
<th scope="col">{lang.weekdays[4]}</th>\
|
||||
<th scope="col">{lang.weekdays[5]}</th>\
|
||||
<th scope="col">{lang.weekdays[6]}</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
{@week in weeks}\
|
||||
<tr class="ui-calenar-repeat">\
|
||||
<td class="sun">{week[0]}</td>\
|
||||
<td>{week[1]}</td>\
|
||||
<td>{week[2]}</td>\
|
||||
<td>{week[3]}</td>\
|
||||
<td>{week[4]}</td>\
|
||||
<td>{week[5]}</td>\
|
||||
<td>{week[6]}</td>\
|
||||
</tr>\
|
||||
{/}\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<button type="button" class="close"><span>{lang.close_layer}</span></button>';
|
||||
|
||||
template.month = '<button type="button" class="close"><span>{lang.close_layer}</span></button>\
|
||||
<table border="1" cellspacing="0" summary="달력에서 날짜를 선택하기" class="month">\
|
||||
<caption>\
|
||||
<span>\
|
||||
{yyyy}.{mm} <button type="button" class="today">{lang.today}</button>\
|
||||
<button type="button" class="navi prev"><span>{lang.prevyear}</span></button>\
|
||||
<button type="button" class="navi next"><span>{lang.nextyear}</span></button>\
|
||||
</span>\
|
||||
</caption>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td><button type="button" class="past"><strong>1</strong><br />January</button></td>\
|
||||
<td><button type="button" class="past"><strong>2</strong><br />Februry</button></td>\
|
||||
<td><button type="button" class="past"><strong>3</strong><br />March</button></td>\
|
||||
<td><button type="button" class="past"><strong>4</strong><br />April</button></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td><button type="button" class="past"><strong>5</strong><br />May</button></td>\
|
||||
<td><button type="button" class="active"><strong>6</strong><br />June</button></td>\
|
||||
<td><button type="button"><strong>7</strong><br />July</button></td>\
|
||||
<td><button type="button"><strong>8</strong><br />August</button></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td><button type="button"><strong>9</strong><br />September</button></td>\
|
||||
<td><button type="button"><strong>10</strong><br />October</button></td>\
|
||||
<td><button type="button"><strong>11</strong><br />Nobember</button></td>\
|
||||
<td><button type="button"><strong>12</strong><br />December</button></td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<button type="button" class="close"><span>{lang.close_layer}</span></button>';
|
||||
|
||||
/**
|
||||
* @brief XE Calendar
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
*
|
||||
* 사용법
|
||||
*
|
||||
**/
|
||||
(function($){
|
||||
|
||||
if (!$.ui) $.ui = {};
|
||||
$.extend($.ui, { calendar: { version:'0.3' } });
|
||||
|
||||
var PROP_NAME = 'calendar';
|
||||
var index = 0;
|
||||
var calendars = {};
|
||||
var template = {calendar:'',month:''};
|
||||
|
||||
function Calendar() {
|
||||
}
|
||||
|
||||
$.extend(Calendar.prototype, {
|
||||
_activeCalendar : null,
|
||||
_getuid : function(obj) {
|
||||
var uid = obj.attr('class').match(/ui-calendar-(\d+-\d+)/);
|
||||
|
||||
if (!uid) return -1;
|
||||
return uid[1];
|
||||
},
|
||||
_show : function(obj) {
|
||||
if (this._activeCalendar) this._hide(this._activeCalendar);
|
||||
|
||||
// disabled?
|
||||
if (obj.hasClass('ui-calendar-disabled')) return;
|
||||
|
||||
// Active Calendar
|
||||
this._activeCalendar = obj.show(300);
|
||||
},
|
||||
_hide : function(obj) {
|
||||
if (this._activeCalendar && this._activeCalendar.get(0) == obj.get(0)) this._activeCalendar = null;
|
||||
obj.hide(300);
|
||||
},
|
||||
_toggle : function(obj) {
|
||||
(obj.css('display' ) == 'none')?this._show(obj):this._hide(obj);
|
||||
},
|
||||
_attachCalendar : function(obj, options) {
|
||||
if ((obj=$(obj)).hasClass('ui-calendar')) return;
|
||||
|
||||
var uid = $.calendar.uuid+'-'+(index++);
|
||||
var c = calendars[uid] = {};
|
||||
|
||||
// uid 추가
|
||||
obj.addClass('ui-calendar-'+uid).mousedown(function(){return false});
|
||||
|
||||
// default options
|
||||
c.options = $.extend({
|
||||
type : 'day',
|
||||
activeDate : ''
|
||||
}, options||{});
|
||||
c.lang = $.extend({
|
||||
weekdays : 'Sun,Mon,Tue,Wed,Thu,Fri,Sat',
|
||||
today : 'Today',
|
||||
prevmonth : 'Prev Month',
|
||||
nextmonth : 'Next Month',
|
||||
prevyear : 'Prev Year',
|
||||
nextyear : 'Next Year',
|
||||
close : 'Close'
|
||||
}, options.lang||{});
|
||||
|
||||
c.lang.weekdays = c.lang.weekdays.split(',');
|
||||
|
||||
// 날짜 설정
|
||||
var d;
|
||||
if (typeof c.options.activeDate == 'string' && c.options.activeDate) {
|
||||
var s = c.options.activeDate.split('/');
|
||||
d = new Date(s[0], s[1]-1, s[2]-0);
|
||||
} else {
|
||||
d = new Date();
|
||||
}
|
||||
this._setDate(obj, d);
|
||||
|
||||
// 토글 버튼
|
||||
if (c.options.button) {
|
||||
(c.button=$(c.options.button)).click(function(){ obj.calendar('toggle') });
|
||||
}
|
||||
|
||||
// 클래스 추가
|
||||
obj.addClass('ui-calendar');
|
||||
|
||||
// position 설정한 후, 좌표를 (0,0)으로 변경
|
||||
var pos = obj.css({position:'absolute',top:0,left:0}).show().offset();
|
||||
|
||||
// 버튼의 위치 구해서 좌표 조정
|
||||
var bpos = c.button.offset();
|
||||
var dx = bpos.left - pos.left;
|
||||
var dy = bpos.top - pos.top;
|
||||
|
||||
// 좌표 조정 후 레이어 숨김
|
||||
obj.css({top:(dy+c.button.height())+'px',left:dx+'px'}).hide();
|
||||
},
|
||||
_checkExternalClick : function(e) {
|
||||
if ($.calendar._activeCalendar) $.calendar._hide($.calendar._activeCalendar);
|
||||
},
|
||||
_processTemplate : function(tpl, vars) {
|
||||
tpl = (' '+tpl+' ').split(/[\{\}]/g);
|
||||
|
||||
for(var i=0; i < tpl.length; i++) {
|
||||
if (i%2) {
|
||||
if (/^[\w\.\[\]]+$/.test(tpl[i])) tpl[i] = 'try{v=vv.'+tpl[i]+'}catch(e){v=""};ret.push(v);';
|
||||
else if (/^@(\w+)\s+in\s+(\w+)$/.test(tpl[i])) tpl[i] = 'for(i=0,l=vv.'+RegExp.$2+'.length;i<l;i++) { vv.'+RegExp.$1+'=vv.'+RegExp.$2+'[i];';
|
||||
else if (tpl[i] == '/') tpl[i] = '};';
|
||||
else tpl[i] = 'ret.push("{'+tpl[i]+'}");';
|
||||
} else {
|
||||
tpl[i] = 'ret.push("'+tpl[i].replace(/"/g, '\\"')+'");'; //"
|
||||
}
|
||||
}
|
||||
|
||||
tpl.push('return ret.join("");');
|
||||
tpl = (['var i,l,v,t,ret=[];'].concat(tpl)).join('');
|
||||
|
||||
return (new Function('vv',tpl))(vars);
|
||||
},
|
||||
_draw : function(obj) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return;
|
||||
|
||||
var cal = calendars[uid];
|
||||
var tpl = (cal.options.type == 'month')?template.month:template.calendar;
|
||||
var v = {lang:cal.lang};
|
||||
|
||||
// 날짜 관련 변수
|
||||
v['yyyy'] = cal.date.getFullYear();
|
||||
v['yy'] = (v['yyyy']+'').substring(2);
|
||||
v['m'] = cal.date.getMonth() + 1;
|
||||
v['mm'] = v['m'] > 9?v['m']:'0'+v['m'];
|
||||
|
||||
// 연간 달력이 아니라면 이 달의 날짜를 구한다.
|
||||
if (cal.options.type != 'month') {
|
||||
// 날짜에 사용할 달력
|
||||
v['weeks'] = [];
|
||||
|
||||
var d = new Date(cal.date.getTime()), w = [];
|
||||
var last = (v.m!=2)? ((v.m+(v.m>7?1:0))%2?31:30) : ((new Date(v.yyyy,v.m-1,29)).getMonth()==v.m?29:28); // 마지막 날
|
||||
|
||||
d.setDate(1); // 1일로 설정 후 1일의 요일을 가져온다.
|
||||
var start = d.getDay(), end = last+start;
|
||||
|
||||
for(var i=0,len=end+(7-(end%7||7));i<len;i++) {
|
||||
if (i%7 == 0) v['weeks'].push(w=[]);
|
||||
if (i < start || i >= end) w.push(' ');
|
||||
else w.push('<button type="button" class="day'+v.yyyy+'-'+v.m+'-'+(i+1-start)+'">'+(i+1-start)+'</button>');
|
||||
}
|
||||
}
|
||||
|
||||
// 템플릿 처리
|
||||
tpl = this._processTemplate(tpl, v);
|
||||
obj.html(tpl);
|
||||
|
||||
// 선택한 날짜
|
||||
if (cal.options.type == 'month') {
|
||||
|
||||
} else {
|
||||
var t = new Date();
|
||||
obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('today');
|
||||
|
||||
t = cal.activeDate;
|
||||
obj.find('td>button.day'+t.getFullYear()+'-'+(t.getMonth()+1)+'-'+t.getDate()).addClass('active');
|
||||
}
|
||||
|
||||
// 이벤트 핸들러
|
||||
obj.find('button.close').click(function(){ $.calendar._hide(obj); });
|
||||
obj.find('button.today').click(function(){ $.calendar._moveToday(obj); });
|
||||
if (cal.options.type == 'month') {
|
||||
obj.find('button.prev').click(function(){ $.calendar._prevYear(obj) });
|
||||
obj.find('button.next').click(function(){ $.calendar._nextYear(obj) });
|
||||
} else {
|
||||
obj.find('button.prev').click(function(){ $.calendar._prevMonth(obj) });
|
||||
obj.find('button.next').click(function(){ $.calendar._nextMonth(obj) });
|
||||
obj.find('button.prev_year').click(function(){ $.calendar._prevYear(obj) });
|
||||
obj.find('button.next_year').click(function(){ $.calendar._nextYear(obj) });
|
||||
}
|
||||
obj.find('td>button').click(function(){ $.calendar._selectDate(obj, $(this)) });
|
||||
},
|
||||
_selectDate : function(obj, btn) {
|
||||
var cal = calendars[ this._getuid(obj) ];
|
||||
var date = btn.attr('class').match(/day([\d\-]+)/);
|
||||
if (!date) return;
|
||||
|
||||
date = date[1].split('-');
|
||||
|
||||
var ad = cal.activeDate;
|
||||
ad.setFullYear(date[0]-0);
|
||||
ad.setMonth(date[1]-1);
|
||||
ad.setDate(date[2]-0);
|
||||
|
||||
this._setDate(obj, ad);
|
||||
},
|
||||
_setDate : function(obj, newDate) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return null;
|
||||
if (!newDate || !(newDate instanceof Date)) newDate = new Date();
|
||||
|
||||
var cal = calendars[uid];
|
||||
cal.activeDate = new Date(newDate.getTime());
|
||||
cal.date = new Date(newDate.getTime());
|
||||
this._draw(obj);
|
||||
|
||||
if ($.isFunction(cal.options.select) && obj.hasClass('ui-calendar')) {
|
||||
cal.options.select(newDate.getFullYear(), newDate.getMonth()+1, newDate.getDate());
|
||||
}
|
||||
},
|
||||
_getDate : function(obj, format) {
|
||||
var uid = this._getuid(obj);
|
||||
if (uid < 0) return null;
|
||||
if (typeof format != 'string') return calendars[uid].activeDate;
|
||||
|
||||
// format string
|
||||
},
|
||||
_moveToday : function(obj) {
|
||||
calendars[this._getuid(obj)].date = new Date();
|
||||
this._draw(obj);
|
||||
},
|
||||
_prevMonth : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
var m = cal.date.getMonth();
|
||||
|
||||
cal.date.setDate(1);
|
||||
if (m == 0) {
|
||||
cal.date.setFullYear(cal.date.getFullYear()-1);
|
||||
cal.date.setMonth(11);
|
||||
} else {
|
||||
cal.date.setMonth(m-1);
|
||||
}
|
||||
|
||||
this._draw(obj);
|
||||
},
|
||||
_nextMonth : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
var m = cal.date.getMonth();
|
||||
|
||||
cal.date.setDate(1);
|
||||
if (m == 11) {
|
||||
cal.date.setFullYear(cal.date.getFullYear()+1);
|
||||
cal.date.setMonth(0);
|
||||
} else {
|
||||
cal.date.setMonth(m+1);
|
||||
}
|
||||
|
||||
this._draw(obj);
|
||||
},
|
||||
_prevYear : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
|
||||
cal.date.setFullYear(cal.date.getFullYear()-1);
|
||||
this._draw(obj);
|
||||
},
|
||||
_nextYear : function(obj) {
|
||||
var cal = calendars[this._getuid(obj)];
|
||||
|
||||
cal.date.setFullYear(cal.date.getFullYear()+1);
|
||||
this._draw(obj);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Invoke the calednar functionallity
|
||||
* @return jQuery object
|
||||
*/
|
||||
$.fn.calendar = function(options) {
|
||||
var args = $.makeArray(arguments);
|
||||
|
||||
if (!$.calendar.initialized) {
|
||||
$(document).mousedown($.calendar._checkExternalClick);
|
||||
$.calendar.initialized = true;
|
||||
}
|
||||
|
||||
if (typeof options == 'string' && $.inArray(options, ['getDate'])) {
|
||||
args.shift();
|
||||
return $.calendar['_'+options].apply($.calendar, [$(this[0])].concat(args) );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
if (typeof options == 'string') {
|
||||
args.shift();
|
||||
$.calendar['_'+ options].apply($.calendar, [$(this)].concat(args));
|
||||
} else {
|
||||
$.calendar._attachCalendar($(this), options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$.calendar = new Calendar(); // singleton instance
|
||||
$.calendar.initialized = false;
|
||||
$.calendar.uuid = new Date().getTime();
|
||||
$.calendar.version = $.ui.calendar.version;
|
||||
|
||||
// template
|
||||
template.calendar = '<button type="button" class="close"><span>{lang.close_layer}</span></button>\
|
||||
<table border="1" cellspacing="0" summary="달력에서 날짜를 선택하기">\
|
||||
<caption>\
|
||||
<span>\
|
||||
{yyyy}.{mm}.\
|
||||
<button type="button" class="today">{lang.today}</button>\
|
||||
<button type="button" class="navi prev"><span>{lang.prevmonth}</span></button>\
|
||||
<button type="button" class="navi next"><span>{lang.nextmonth}</span></button>\
|
||||
<button type="button" class="navi prev_year"><span>{lang.prevyear}</span></button>\
|
||||
<button type="button" class="navi next_year"><span>{lang.nextyear}</span></button>\
|
||||
</span>\
|
||||
</caption>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th scope="col" class="sun">{lang.weekdays[0]}</th>\
|
||||
<th scope="col">{lang.weekdays[1]}</th>\
|
||||
<th scope="col">{lang.weekdays[2]}</th>\
|
||||
<th scope="col">{lang.weekdays[3]}</th>\
|
||||
<th scope="col">{lang.weekdays[4]}</th>\
|
||||
<th scope="col">{lang.weekdays[5]}</th>\
|
||||
<th scope="col">{lang.weekdays[6]}</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
{@week in weeks}\
|
||||
<tr class="ui-calenar-repeat">\
|
||||
<td class="sun">{week[0]}</td>\
|
||||
<td>{week[1]}</td>\
|
||||
<td>{week[2]}</td>\
|
||||
<td>{week[3]}</td>\
|
||||
<td>{week[4]}</td>\
|
||||
<td>{week[5]}</td>\
|
||||
<td>{week[6]}</td>\
|
||||
</tr>\
|
||||
{/}\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<button type="button" class="close"><span>{lang.close_layer}</span></button>';
|
||||
|
||||
template.month = '<button type="button" class="close"><span>{lang.close_layer}</span></button>\
|
||||
<table border="1" cellspacing="0" summary="달력에서 날짜를 선택하기" class="month">\
|
||||
<caption>\
|
||||
<span>\
|
||||
{yyyy}.{mm} <button type="button" class="today">{lang.today}</button>\
|
||||
<button type="button" class="navi prev"><span>{lang.prevyear}</span></button>\
|
||||
<button type="button" class="navi next"><span>{lang.nextyear}</span></button>\
|
||||
</span>\
|
||||
</caption>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td><button type="button" class="past"><strong>1</strong><br />January</button></td>\
|
||||
<td><button type="button" class="past"><strong>2</strong><br />Februry</button></td>\
|
||||
<td><button type="button" class="past"><strong>3</strong><br />March</button></td>\
|
||||
<td><button type="button" class="past"><strong>4</strong><br />April</button></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td><button type="button" class="past"><strong>5</strong><br />May</button></td>\
|
||||
<td><button type="button" class="active"><strong>6</strong><br />June</button></td>\
|
||||
<td><button type="button"><strong>7</strong><br />July</button></td>\
|
||||
<td><button type="button"><strong>8</strong><br />August</button></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td><button type="button"><strong>9</strong><br />September</button></td>\
|
||||
<td><button type="button"><strong>10</strong><br />October</button></td>\
|
||||
<td><button type="button"><strong>11</strong><br />Nobember</button></td>\
|
||||
<td><button type="button"><strong>12</strong><br />December</button></td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<button type="button" class="close"><span>{lang.close_layer}</span></button>';
|
||||
|
||||
})(jQuery);
|
||||
|
|
@ -1,366 +1,366 @@
|
|||
/**
|
||||
* @brief XE Colorpicker
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
jQuery(function($){
|
||||
var ready = false;
|
||||
var tmp = $('<span>').hide();
|
||||
// var panel = null;
|
||||
|
||||
$.fn.xe_colorpicker = function(settings){
|
||||
var selection = this;
|
||||
|
||||
if (!ready) {
|
||||
ColorPicker.init(settings);
|
||||
ready = true;
|
||||
}
|
||||
|
||||
this.each(function(){
|
||||
var col = color($(this).val());
|
||||
|
||||
$(this).val( col ).css('background-color', col );
|
||||
setTextColor( $(this) );
|
||||
}).focus(function(event){
|
||||
var t = this;
|
||||
$(this).select();
|
||||
|
||||
// show color picker
|
||||
ColorPicker.show(this);
|
||||
}).keypress(function(event){
|
||||
if (!ColorPicker.is(':visible')) return;
|
||||
|
||||
if (/^#?[0-9a-f]{6}$/i.test( event.target.value )) {
|
||||
ColorPicker.color( event.target.value );
|
||||
}
|
||||
});
|
||||
|
||||
$(document).mousedown(function(event){
|
||||
var target = event.target;
|
||||
|
||||
if (selection.index(target) > -1) return;
|
||||
if ($(target).parents().add(target).index(ColorPicker.element) > -1) return;
|
||||
if ($(target).parents().add(target).index(ColorPicker.buttons) > -1) return;
|
||||
|
||||
ColorPicker.hide();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var ColorPicker = {
|
||||
element : null,
|
||||
picker : null,
|
||||
colpane: null,
|
||||
buttons : null,
|
||||
_target : null,
|
||||
_backup : null,
|
||||
_hsv : null,
|
||||
_mode : 'none',
|
||||
|
||||
init : function() {
|
||||
var cp = this;
|
||||
|
||||
this.element = $('<div class="xe_colorpicker"><div class="colorpicker"><div class="colortable"><div class="background"><div class="indicator"></div></div></div><div class="huebar"><div class="background"><div class="indicator"></div></div></div></div><div class="buttons"><button type="button" class="ok">OK</button><button type="button" class="cancel">Cancel</button><button type="button" class="none">None</button></div></div>');
|
||||
|
||||
this.picker = this.element.find('> div.colorpicker');
|
||||
this.colpane = this.picker.find('div.colortable > div.background');
|
||||
this.colpoint = this.colpane.find('> .indicator');
|
||||
this.buttons = this.element.find('> div.buttons');
|
||||
this.huepane = this.element.find('div.huebar > .background');
|
||||
this.huepoint = this.huepane.find('> .indicator');
|
||||
|
||||
this._mousedown = method(this.onmousedown, this);
|
||||
this._mousemove = method(this.onmousemove, this);
|
||||
this._mouseup = method(this.onmouseup, this);
|
||||
|
||||
this.picker.find('.background').mousedown(this._mousedown);
|
||||
|
||||
this.buttons.find('button.ok').click(method(this.ok,this));
|
||||
this.buttons.find('button.cancel').click(method(this.cancel,this));
|
||||
this.buttons.find('button.none').click(method(this.none,this));
|
||||
|
||||
// only for IE6
|
||||
if ($.browser.msie && parseInt($.browser.version) < 7) {
|
||||
this.element.append( $('<iframe>').css({position:'absolute','z-index':-1,left:0,top:0,width:9999,height:9999}) );
|
||||
}
|
||||
},
|
||||
show : function(input) {
|
||||
var pos = (input=$(input)).offset(), pos_panel;
|
||||
//var par = input.get(0).offsetParent;
|
||||
var par = $("body").get(0);
|
||||
var btn = this.buttons.hide();
|
||||
var col = color(input.val());
|
||||
|
||||
this._target = input;
|
||||
this._backup = col;
|
||||
|
||||
this.color(col);
|
||||
this._target.val(col);
|
||||
|
||||
pos_panel = this.element.hide().css({'z-index':99999,left:0,top:0}).appendTo( par ).show(300,function(){btn.slideDown(150)}).offset();
|
||||
this.element.css({left:pos.left-pos_panel.left,top:pos.top-pos_panel.top+input.get(0).offsetHeight});
|
||||
},
|
||||
hide : function() {
|
||||
var e = this.element;
|
||||
|
||||
this._target = null;
|
||||
this.buttons.slideUp(100, function(){e.hide(200)});
|
||||
},
|
||||
visible : function() {
|
||||
return this.element.is(':visible');
|
||||
},
|
||||
color : function(sColor) {
|
||||
if (typeof sColor == 'string') {
|
||||
var col = color(sColor);
|
||||
var hsv = _hsv(rgb2hsv(hex2rgb(col)));
|
||||
|
||||
this.hsv(hsv.h, hsv.s, hsv.v);
|
||||
} else if (this._target) {
|
||||
return color(this._target.val());
|
||||
}
|
||||
},
|
||||
hsv : function(h, s, v) {
|
||||
var col = rgb2hex(hsv2rgb(h, s, v));
|
||||
|
||||
this._hsv = _hsv(h, s, v);
|
||||
|
||||
// background color and text color
|
||||
this._target.val(col).css('background-color', col);
|
||||
setTextColor(this._target);
|
||||
|
||||
// hue bar indicator
|
||||
if (this._hue_h) this.huepoint.css('top', limit(0, Math.round((360-this._hsv.h)/360*this._hue_h), this._hue_h-1) - 3 );
|
||||
|
||||
// color - background
|
||||
this.colpane.css('background-color', rgb2hex(hsv2rgb(h, 100, 100)) );
|
||||
|
||||
// color - indicator
|
||||
if (this._col_h && this._col_w) {
|
||||
this.colpoint.css({
|
||||
top : limit(0, Math.round((100-this._hsv.v)/100*this._col_h), this._col_h-1) - 5,
|
||||
left : limit(0, Math.round(this._hsv.s/100*this._col_w), this._col_w-1 ) - 5
|
||||
});
|
||||
}
|
||||
},
|
||||
onmousedown : function(event) {
|
||||
var cur = $(event.target);
|
||||
var par = cur.parent();
|
||||
var pos = cur.offset();
|
||||
var hue, sat, val; // hue, saturation, value
|
||||
|
||||
this._height = cur.height();
|
||||
this._width = cur.width();
|
||||
this._top = pos.top;
|
||||
this._left = pos.left;
|
||||
|
||||
this._col_w = this.colpane.width();
|
||||
this._col_h = this.colpane.width();
|
||||
this._hue_h = this.huepane.height();
|
||||
|
||||
if (par.is('.colortable')) {
|
||||
this._mode = 'color';
|
||||
hue = this._hsv.h;
|
||||
sat = ( limit(0, (event.pageX - this._left), this._width ) / this._width * 100);
|
||||
val = ( limit(0, (this._height - event.pageY + this._top), this._height ) / this._height * 100);
|
||||
} else if (par.is('.huebar')) {
|
||||
this._mode = 'hue';
|
||||
hue = limit(0, (this._height - event.pageY + this._top), this._height) / this._height * 360;
|
||||
sat = this._hsv.s;
|
||||
val = this._hsv.v;
|
||||
}
|
||||
|
||||
this.hsv( hue, sat, val );
|
||||
|
||||
$(document).bind('mousemove', this._mousemove).bind('mouseup', this._mouseup);
|
||||
},
|
||||
onmousemove : function(event) {
|
||||
var hue, sat, val; // hue, saturation, value
|
||||
|
||||
switch(this._mode) {
|
||||
case 'color':
|
||||
hue = this._hsv.h;
|
||||
sat = ( limit(0, (event.pageX - this._left), this._width ) / this._width * 100);
|
||||
val = ( limit(0, (this._height - event.pageY + this._top), this._height ) / this._height * 100);
|
||||
break;
|
||||
case 'hue':
|
||||
hue = limit(0, (this._height - event.pageY + this._top), this._height) / this._height * 360;
|
||||
sat = this._hsv.s;
|
||||
val = this._hsv.v;
|
||||
break;
|
||||
}
|
||||
|
||||
this.hsv( hue, sat, val );
|
||||
},
|
||||
onmouseup : function(event) {
|
||||
this._mode = 'none';
|
||||
$(document).unbind('mousemove', this._mousemove).unbind('mouseup', this._mouseup);
|
||||
},
|
||||
ok : function() {
|
||||
this.hide();
|
||||
},
|
||||
cancel : function() {
|
||||
this.color(this._backup);
|
||||
this.hide();
|
||||
},
|
||||
none : function() {
|
||||
this._target.attr('value','transparent').css('background','').css('color','#000000');
|
||||
this.hide();
|
||||
}
|
||||
};
|
||||
|
||||
function setTextColor(input) {
|
||||
var hex = input.css('color', '').val(), hsv, rgb;
|
||||
|
||||
if (hex == 'transparent' || hex == '') return;
|
||||
|
||||
rgb = hex2rgb(hex);
|
||||
hsv = rgb2hsv(255-rgb.r, 255-rgb.g, 255-rgb.b); // 보색을 구한 뒤
|
||||
hex = rgb2hex(hsv2rgb(0, 0, hsv.v>50?100:0)); // 보색에 해당하는 흑백으로 결정
|
||||
|
||||
input.css('color', hex);
|
||||
}
|
||||
|
||||
function method(func, thisObj) {
|
||||
return function() { return func.apply(thisObj, arguments) }
|
||||
}
|
||||
|
||||
function color(str) {
|
||||
var col = $.trim(str);
|
||||
var regHex1 = /^#[0-9a-f]{6}$/i;
|
||||
var regHex2 = /^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i; // short hex
|
||||
|
||||
if (regHex1.test(col)) return col.toUpperCase();
|
||||
if (regHex2.test(col)) return col.replace(regHex2, '#$1$1$2$2$3$3').toUpperCase();
|
||||
|
||||
try {
|
||||
col = tmp.appendTo($('<body>')).css('background-color', col).css('background-color');
|
||||
} catch(e) {
|
||||
col = 'transparent';
|
||||
} finally {
|
||||
tmp.css('background-color','').remove();
|
||||
}
|
||||
|
||||
if (/^rgb\(([0-9, ]+)\)$/i.test(col)) col = rgb2hex(RegExp.$1.split(/,\s*/));
|
||||
if (!/#[0-9a-f]{6}/i.test(col)) col = 'transparent';
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
function _rgb(rgb, _g, _b) {
|
||||
var r, g, b;
|
||||
|
||||
if (typeof arguments[2] == "number") {
|
||||
r = rgb;
|
||||
g = _g;
|
||||
b = _b;
|
||||
} else if (typeof rgb == "object") {
|
||||
if (rgb.constructor == Array) {
|
||||
r = rgb[0] || 0; g = rgb[1] || 0; b = rgb[2] || 0;
|
||||
} else {
|
||||
r = rgb.r || 0; g = rgb.g || 0; b = rgb.b || 0;
|
||||
}
|
||||
}
|
||||
|
||||
rgb = [];
|
||||
|
||||
rgb.r = rgb[0] = r = parseInt(r, 10);
|
||||
rgb.g = rgb[1] = g = parseInt(g, 10);
|
||||
rgb.b = rgb[2] = b = parseInt(b, 10);
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
function _hsv(hsv, _s, _v) {
|
||||
var h, s, v;
|
||||
|
||||
if (typeof arguments[2] == "number") {
|
||||
h = hsv; s = _s; v = _v;
|
||||
} else if (typeof hsv == "object") {
|
||||
if (hsv.constructor == Array) {
|
||||
h = hsv[0] || 0; s = hsv[1] || 0; v = hsv[2] || 0;
|
||||
} else {
|
||||
h = hsv.h || 0; s = hsv.s || 0; v = hsv.v || 0;
|
||||
}
|
||||
}
|
||||
|
||||
hsv = [];
|
||||
|
||||
hsv.h = hsv[0] = h = parseInt(h, 10);
|
||||
hsv.s = hsv[1] = s = parseInt(s, 10);
|
||||
hsv.v = hsv[2] = v = parseInt(v, 10);
|
||||
|
||||
return hsv;
|
||||
}
|
||||
|
||||
function rgb2hex(rgb, _g, _b) {
|
||||
var rgb = _rgb(rgb, _g, _b);
|
||||
|
||||
for(var i=0; i < rgb.length; i++) {
|
||||
(rgb[i] = Number(rgb[i]).toString(16)).length<2?rgb[i]='0'+rgb[i]:0;
|
||||
}
|
||||
|
||||
return '#'+rgb.join('').toUpperCase();
|
||||
}
|
||||
|
||||
function hex2rgb(hex) {
|
||||
var r=0, g=0, b=0;
|
||||
|
||||
if (/^#?([0-9a-f]{1,2})([0-9a-f]{1,2})([0-9a-f]{1,2})$/i.test(hex)) {
|
||||
r = parseInt(RegExp.$1, 16);
|
||||
g = parseInt(RegExp.$2, 16);
|
||||
b = parseInt(RegExp.$3, 16);
|
||||
}
|
||||
|
||||
return _rgb(r, g, b);
|
||||
}
|
||||
|
||||
function hsv2rgb(hsv, _s, _v) {
|
||||
var r=0, g=0, b=0;
|
||||
var h=0, s=0, v=0;
|
||||
var i, f, p, q, t;
|
||||
|
||||
hsv = _hsv(hsv, _s, _v);
|
||||
|
||||
h = (hsv[0] % 360) / 60; s = hsv[1] / 100; v = hsv[2] / 100;
|
||||
|
||||
i = Math.floor(h);
|
||||
f = h-i;
|
||||
p = v*(1-s);
|
||||
q = v*(1-s*f);
|
||||
t = v*(1-s*(1-f));
|
||||
|
||||
switch (i) {
|
||||
case 0: r=v; g=t; b=p; break;
|
||||
case 1: r=q; g=v; b=p; break;
|
||||
case 2: r=p; g=v; b=t; break;
|
||||
case 3: r=p; g=q; b=v; break;
|
||||
case 4: r=t; g=p; b=v; break;
|
||||
case 5: r=v; g=p; b=q; break;
|
||||
case 6: break;
|
||||
}
|
||||
|
||||
return _rgb(Math.floor(r*255), Math.floor(g*255), Math.floor(b*255));
|
||||
}
|
||||
|
||||
function rgb2hsv(rgb, _g, _b) {
|
||||
var rgb = _rgb(rgb, _g, _b);
|
||||
var r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
var h = 0, s = 0, v = Math.max(r,g,b), min = Math.min(r,g,b), delta = v - min;
|
||||
|
||||
if (s = v?delta/v:0) {
|
||||
if (r == v) h = 60 * (g - b) / delta;
|
||||
else if (g == v) h = 120 + 60 * (b - r) / delta;
|
||||
else if (b == v) h = 240 + 60 * (r - g) / delta;
|
||||
|
||||
if (h < 0) h += 360;
|
||||
}
|
||||
|
||||
return _hsv(Math.floor(h), Math.floor(s*100), Math.floor(v/255*100));
|
||||
}
|
||||
|
||||
function limit(min, val, max){
|
||||
return Math.min(Math.max(min, val), max);
|
||||
}
|
||||
|
||||
$('input.color-indicator').xe_colorpicker();
|
||||
});
|
||||
/**
|
||||
* @brief XE Colorpicker
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
jQuery(function($){
|
||||
var ready = false;
|
||||
var tmp = $('<span>').hide();
|
||||
// var panel = null;
|
||||
|
||||
$.fn.xe_colorpicker = function(settings){
|
||||
var selection = this;
|
||||
|
||||
if (!ready) {
|
||||
ColorPicker.init(settings);
|
||||
ready = true;
|
||||
}
|
||||
|
||||
this.each(function(){
|
||||
var col = color($(this).val());
|
||||
|
||||
$(this).val( col ).css('background-color', col );
|
||||
setTextColor( $(this) );
|
||||
}).focus(function(event){
|
||||
var t = this;
|
||||
$(this).select();
|
||||
|
||||
// show color picker
|
||||
ColorPicker.show(this);
|
||||
}).keypress(function(event){
|
||||
if (!ColorPicker.is(':visible')) return;
|
||||
|
||||
if (/^#?[0-9a-f]{6}$/i.test( event.target.value )) {
|
||||
ColorPicker.color( event.target.value );
|
||||
}
|
||||
});
|
||||
|
||||
$(document).mousedown(function(event){
|
||||
var target = event.target;
|
||||
|
||||
if (selection.index(target) > -1) return;
|
||||
if ($(target).parents().add(target).index(ColorPicker.element) > -1) return;
|
||||
if ($(target).parents().add(target).index(ColorPicker.buttons) > -1) return;
|
||||
|
||||
ColorPicker.hide();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var ColorPicker = {
|
||||
element : null,
|
||||
picker : null,
|
||||
colpane: null,
|
||||
buttons : null,
|
||||
_target : null,
|
||||
_backup : null,
|
||||
_hsv : null,
|
||||
_mode : 'none',
|
||||
|
||||
init : function() {
|
||||
var cp = this;
|
||||
|
||||
this.element = $('<div class="xe_colorpicker"><div class="colorpicker"><div class="colortable"><div class="background"><div class="indicator"></div></div></div><div class="huebar"><div class="background"><div class="indicator"></div></div></div></div><div class="buttons"><button type="button" class="ok">OK</button><button type="button" class="cancel">Cancel</button><button type="button" class="none">None</button></div></div>');
|
||||
|
||||
this.picker = this.element.find('> div.colorpicker');
|
||||
this.colpane = this.picker.find('div.colortable > div.background');
|
||||
this.colpoint = this.colpane.find('> .indicator');
|
||||
this.buttons = this.element.find('> div.buttons');
|
||||
this.huepane = this.element.find('div.huebar > .background');
|
||||
this.huepoint = this.huepane.find('> .indicator');
|
||||
|
||||
this._mousedown = method(this.onmousedown, this);
|
||||
this._mousemove = method(this.onmousemove, this);
|
||||
this._mouseup = method(this.onmouseup, this);
|
||||
|
||||
this.picker.find('.background').mousedown(this._mousedown);
|
||||
|
||||
this.buttons.find('button.ok').click(method(this.ok,this));
|
||||
this.buttons.find('button.cancel').click(method(this.cancel,this));
|
||||
this.buttons.find('button.none').click(method(this.none,this));
|
||||
|
||||
// only for IE6
|
||||
if ($.browser.msie && parseInt($.browser.version) < 7) {
|
||||
this.element.append( $('<iframe>').css({position:'absolute','z-index':-1,left:0,top:0,width:9999,height:9999}) );
|
||||
}
|
||||
},
|
||||
show : function(input) {
|
||||
var pos = (input=$(input)).offset(), pos_panel;
|
||||
//var par = input.get(0).offsetParent;
|
||||
var par = $("body").get(0);
|
||||
var btn = this.buttons.hide();
|
||||
var col = color(input.val());
|
||||
|
||||
this._target = input;
|
||||
this._backup = col;
|
||||
|
||||
this.color(col);
|
||||
this._target.val(col);
|
||||
|
||||
pos_panel = this.element.hide().css({'z-index':99999,left:0,top:0}).appendTo( par ).show(300,function(){btn.slideDown(150)}).offset();
|
||||
this.element.css({left:pos.left-pos_panel.left,top:pos.top-pos_panel.top+input.get(0).offsetHeight});
|
||||
},
|
||||
hide : function() {
|
||||
var e = this.element;
|
||||
|
||||
this._target = null;
|
||||
this.buttons.slideUp(100, function(){e.hide(200)});
|
||||
},
|
||||
visible : function() {
|
||||
return this.element.is(':visible');
|
||||
},
|
||||
color : function(sColor) {
|
||||
if (typeof sColor == 'string') {
|
||||
var col = color(sColor);
|
||||
var hsv = _hsv(rgb2hsv(hex2rgb(col)));
|
||||
|
||||
this.hsv(hsv.h, hsv.s, hsv.v);
|
||||
} else if (this._target) {
|
||||
return color(this._target.val());
|
||||
}
|
||||
},
|
||||
hsv : function(h, s, v) {
|
||||
var col = rgb2hex(hsv2rgb(h, s, v));
|
||||
|
||||
this._hsv = _hsv(h, s, v);
|
||||
|
||||
// background color and text color
|
||||
this._target.val(col).css('background-color', col);
|
||||
setTextColor(this._target);
|
||||
|
||||
// hue bar indicator
|
||||
if (this._hue_h) this.huepoint.css('top', limit(0, Math.round((360-this._hsv.h)/360*this._hue_h), this._hue_h-1) - 3 );
|
||||
|
||||
// color - background
|
||||
this.colpane.css('background-color', rgb2hex(hsv2rgb(h, 100, 100)) );
|
||||
|
||||
// color - indicator
|
||||
if (this._col_h && this._col_w) {
|
||||
this.colpoint.css({
|
||||
top : limit(0, Math.round((100-this._hsv.v)/100*this._col_h), this._col_h-1) - 5,
|
||||
left : limit(0, Math.round(this._hsv.s/100*this._col_w), this._col_w-1 ) - 5
|
||||
});
|
||||
}
|
||||
},
|
||||
onmousedown : function(event) {
|
||||
var cur = $(event.target);
|
||||
var par = cur.parent();
|
||||
var pos = cur.offset();
|
||||
var hue, sat, val; // hue, saturation, value
|
||||
|
||||
this._height = cur.height();
|
||||
this._width = cur.width();
|
||||
this._top = pos.top;
|
||||
this._left = pos.left;
|
||||
|
||||
this._col_w = this.colpane.width();
|
||||
this._col_h = this.colpane.width();
|
||||
this._hue_h = this.huepane.height();
|
||||
|
||||
if (par.is('.colortable')) {
|
||||
this._mode = 'color';
|
||||
hue = this._hsv.h;
|
||||
sat = ( limit(0, (event.pageX - this._left), this._width ) / this._width * 100);
|
||||
val = ( limit(0, (this._height - event.pageY + this._top), this._height ) / this._height * 100);
|
||||
} else if (par.is('.huebar')) {
|
||||
this._mode = 'hue';
|
||||
hue = limit(0, (this._height - event.pageY + this._top), this._height) / this._height * 360;
|
||||
sat = this._hsv.s;
|
||||
val = this._hsv.v;
|
||||
}
|
||||
|
||||
this.hsv( hue, sat, val );
|
||||
|
||||
$(document).bind('mousemove', this._mousemove).bind('mouseup', this._mouseup);
|
||||
},
|
||||
onmousemove : function(event) {
|
||||
var hue, sat, val; // hue, saturation, value
|
||||
|
||||
switch(this._mode) {
|
||||
case 'color':
|
||||
hue = this._hsv.h;
|
||||
sat = ( limit(0, (event.pageX - this._left), this._width ) / this._width * 100);
|
||||
val = ( limit(0, (this._height - event.pageY + this._top), this._height ) / this._height * 100);
|
||||
break;
|
||||
case 'hue':
|
||||
hue = limit(0, (this._height - event.pageY + this._top), this._height) / this._height * 360;
|
||||
sat = this._hsv.s;
|
||||
val = this._hsv.v;
|
||||
break;
|
||||
}
|
||||
|
||||
this.hsv( hue, sat, val );
|
||||
},
|
||||
onmouseup : function(event) {
|
||||
this._mode = 'none';
|
||||
$(document).unbind('mousemove', this._mousemove).unbind('mouseup', this._mouseup);
|
||||
},
|
||||
ok : function() {
|
||||
this.hide();
|
||||
},
|
||||
cancel : function() {
|
||||
this.color(this._backup);
|
||||
this.hide();
|
||||
},
|
||||
none : function() {
|
||||
this._target.attr('value','transparent').css('background','').css('color','#000000');
|
||||
this.hide();
|
||||
}
|
||||
};
|
||||
|
||||
function setTextColor(input) {
|
||||
var hex = input.css('color', '').val(), hsv, rgb;
|
||||
|
||||
if (hex == 'transparent' || hex == '') return;
|
||||
|
||||
rgb = hex2rgb(hex);
|
||||
hsv = rgb2hsv(255-rgb.r, 255-rgb.g, 255-rgb.b); // 보색을 구한 뒤
|
||||
hex = rgb2hex(hsv2rgb(0, 0, hsv.v>50?100:0)); // 보색에 해당하는 흑백으로 결정
|
||||
|
||||
input.css('color', hex);
|
||||
}
|
||||
|
||||
function method(func, thisObj) {
|
||||
return function() { return func.apply(thisObj, arguments) }
|
||||
}
|
||||
|
||||
function color(str) {
|
||||
var col = $.trim(str);
|
||||
var regHex1 = /^#[0-9a-f]{6}$/i;
|
||||
var regHex2 = /^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i; // short hex
|
||||
|
||||
if (regHex1.test(col)) return col.toUpperCase();
|
||||
if (regHex2.test(col)) return col.replace(regHex2, '#$1$1$2$2$3$3').toUpperCase();
|
||||
|
||||
try {
|
||||
col = tmp.appendTo($('<body>')).css('background-color', col).css('background-color');
|
||||
} catch(e) {
|
||||
col = 'transparent';
|
||||
} finally {
|
||||
tmp.css('background-color','').remove();
|
||||
}
|
||||
|
||||
if (/^rgb\(([0-9, ]+)\)$/i.test(col)) col = rgb2hex(RegExp.$1.split(/,\s*/));
|
||||
if (!/#[0-9a-f]{6}/i.test(col)) col = 'transparent';
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
function _rgb(rgb, _g, _b) {
|
||||
var r, g, b;
|
||||
|
||||
if (typeof arguments[2] == "number") {
|
||||
r = rgb;
|
||||
g = _g;
|
||||
b = _b;
|
||||
} else if (typeof rgb == "object") {
|
||||
if (rgb.constructor == Array) {
|
||||
r = rgb[0] || 0; g = rgb[1] || 0; b = rgb[2] || 0;
|
||||
} else {
|
||||
r = rgb.r || 0; g = rgb.g || 0; b = rgb.b || 0;
|
||||
}
|
||||
}
|
||||
|
||||
rgb = [];
|
||||
|
||||
rgb.r = rgb[0] = r = parseInt(r, 10);
|
||||
rgb.g = rgb[1] = g = parseInt(g, 10);
|
||||
rgb.b = rgb[2] = b = parseInt(b, 10);
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
function _hsv(hsv, _s, _v) {
|
||||
var h, s, v;
|
||||
|
||||
if (typeof arguments[2] == "number") {
|
||||
h = hsv; s = _s; v = _v;
|
||||
} else if (typeof hsv == "object") {
|
||||
if (hsv.constructor == Array) {
|
||||
h = hsv[0] || 0; s = hsv[1] || 0; v = hsv[2] || 0;
|
||||
} else {
|
||||
h = hsv.h || 0; s = hsv.s || 0; v = hsv.v || 0;
|
||||
}
|
||||
}
|
||||
|
||||
hsv = [];
|
||||
|
||||
hsv.h = hsv[0] = h = parseInt(h, 10);
|
||||
hsv.s = hsv[1] = s = parseInt(s, 10);
|
||||
hsv.v = hsv[2] = v = parseInt(v, 10);
|
||||
|
||||
return hsv;
|
||||
}
|
||||
|
||||
function rgb2hex(rgb, _g, _b) {
|
||||
var rgb = _rgb(rgb, _g, _b);
|
||||
|
||||
for(var i=0; i < rgb.length; i++) {
|
||||
(rgb[i] = Number(rgb[i]).toString(16)).length<2?rgb[i]='0'+rgb[i]:0;
|
||||
}
|
||||
|
||||
return '#'+rgb.join('').toUpperCase();
|
||||
}
|
||||
|
||||
function hex2rgb(hex) {
|
||||
var r=0, g=0, b=0;
|
||||
|
||||
if (/^#?([0-9a-f]{1,2})([0-9a-f]{1,2})([0-9a-f]{1,2})$/i.test(hex)) {
|
||||
r = parseInt(RegExp.$1, 16);
|
||||
g = parseInt(RegExp.$2, 16);
|
||||
b = parseInt(RegExp.$3, 16);
|
||||
}
|
||||
|
||||
return _rgb(r, g, b);
|
||||
}
|
||||
|
||||
function hsv2rgb(hsv, _s, _v) {
|
||||
var r=0, g=0, b=0;
|
||||
var h=0, s=0, v=0;
|
||||
var i, f, p, q, t;
|
||||
|
||||
hsv = _hsv(hsv, _s, _v);
|
||||
|
||||
h = (hsv[0] % 360) / 60; s = hsv[1] / 100; v = hsv[2] / 100;
|
||||
|
||||
i = Math.floor(h);
|
||||
f = h-i;
|
||||
p = v*(1-s);
|
||||
q = v*(1-s*f);
|
||||
t = v*(1-s*(1-f));
|
||||
|
||||
switch (i) {
|
||||
case 0: r=v; g=t; b=p; break;
|
||||
case 1: r=q; g=v; b=p; break;
|
||||
case 2: r=p; g=v; b=t; break;
|
||||
case 3: r=p; g=q; b=v; break;
|
||||
case 4: r=t; g=p; b=v; break;
|
||||
case 5: r=v; g=p; b=q; break;
|
||||
case 6: break;
|
||||
}
|
||||
|
||||
return _rgb(Math.floor(r*255), Math.floor(g*255), Math.floor(b*255));
|
||||
}
|
||||
|
||||
function rgb2hsv(rgb, _g, _b) {
|
||||
var rgb = _rgb(rgb, _g, _b);
|
||||
var r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
var h = 0, s = 0, v = Math.max(r,g,b), min = Math.min(r,g,b), delta = v - min;
|
||||
|
||||
if (s = v?delta/v:0) {
|
||||
if (r == v) h = 60 * (g - b) / delta;
|
||||
else if (g == v) h = 120 + 60 * (b - r) / delta;
|
||||
else if (b == v) h = 240 + 60 * (r - g) / delta;
|
||||
|
||||
if (h < 0) h += 360;
|
||||
}
|
||||
|
||||
return _hsv(Math.floor(h), Math.floor(s*100), Math.floor(v/255*100));
|
||||
}
|
||||
|
||||
function limit(min, val, max){
|
||||
return Math.min(Math.max(min, val), max);
|
||||
}
|
||||
|
||||
$('input.color-indicator').xe_colorpicker();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,186 +1,186 @@
|
|||
|
||||
.simpleTree
|
||||
{
|
||||
|
||||
margin:0;
|
||||
padding:0;
|
||||
/*
|
||||
overflow:auto;
|
||||
width: 250px;
|
||||
height:350px;
|
||||
overflow:auto;
|
||||
border: 1px solid #444444;
|
||||
*/
|
||||
}
|
||||
.simpleTree li
|
||||
{
|
||||
white-space: nowrap;
|
||||
list-style: none;
|
||||
margin:0;
|
||||
padding:0 0 0 34px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.simpleTree li span
|
||||
{
|
||||
display:inline;
|
||||
clear: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.simpleTree li a img
|
||||
{
|
||||
padding:0 1px 0px 3px;
|
||||
}
|
||||
|
||||
.simpleTree ul
|
||||
{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.simpleTree .root
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/root.gif) no-repeat 16px 0 #ffffff;
|
||||
}
|
||||
.simpleTree .line
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-last
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/spacer.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-over
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg_over.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-over-last
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg_over_last.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .folder-open
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/collapsable.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-open-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/collapsable-last.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-close
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/expandable.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-close-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/expandable-last.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .doc
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/leaf.gif) 0 -1px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .doc-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/leaf-last.gif) 0 -1px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .ajax
|
||||
{
|
||||
background: url(./images/spinner.gif) no-repeat 0 0 #ffffff;
|
||||
height: 16px;
|
||||
display:none;
|
||||
}
|
||||
.simpleTree .ajax li
|
||||
{
|
||||
display:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.simpleTree .trigger
|
||||
{
|
||||
display:inline;
|
||||
margin-left:-32px;
|
||||
width: 28px;
|
||||
height: 11px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.simpleTree .text
|
||||
{
|
||||
cursor: default;
|
||||
}
|
||||
.simpleTree .active
|
||||
{
|
||||
cursor: default;
|
||||
background-color:#F7BE77;
|
||||
padding:0px 2px;
|
||||
border: 1px dashed #444;
|
||||
}
|
||||
#drag_container
|
||||
{
|
||||
background:#ffffff;
|
||||
color:#000;
|
||||
font: normal 11px arial, tahoma, helvetica, sans-serif;
|
||||
border: 1px dashed #767676;
|
||||
}
|
||||
#drag_container ul
|
||||
{
|
||||
list-style: none;
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
#drag_container li
|
||||
{
|
||||
list-style: none;
|
||||
background-color:#ffffff;
|
||||
line-height:18px;
|
||||
white-space: nowrap;
|
||||
padding:1px 1px 0px 16px;
|
||||
margin:0;
|
||||
}
|
||||
#drag_container li span
|
||||
{
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#drag_container li.doc, #drag_container li.doc-last
|
||||
{
|
||||
background: url(./images/leaf.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
#drag_container .folder-close, #drag_container .folder-close-last
|
||||
{
|
||||
background: url(./images/expandable.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
|
||||
#drag_container .folder-open, #drag_container .folder-open-last
|
||||
{
|
||||
background: url(./images/collapsable.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
.contextMenu
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.simpleTree
|
||||
{
|
||||
|
||||
margin:0;
|
||||
padding:0;
|
||||
/*
|
||||
overflow:auto;
|
||||
width: 250px;
|
||||
height:350px;
|
||||
overflow:auto;
|
||||
border: 1px solid #444444;
|
||||
*/
|
||||
}
|
||||
.simpleTree li
|
||||
{
|
||||
white-space: nowrap;
|
||||
list-style: none;
|
||||
margin:0;
|
||||
padding:0 0 0 34px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.simpleTree li span
|
||||
{
|
||||
display:inline;
|
||||
clear: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.simpleTree li a img
|
||||
{
|
||||
padding:0 1px 0px 3px;
|
||||
}
|
||||
|
||||
.simpleTree ul
|
||||
{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.simpleTree .root
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/root.gif) no-repeat 16px 0 #ffffff;
|
||||
}
|
||||
.simpleTree .line
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-last
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/spacer.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-over
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg_over.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .line-over-last
|
||||
{
|
||||
margin:0 0 0 -16px;
|
||||
padding:0;
|
||||
line-height: 3px;
|
||||
height:3px;
|
||||
font-size:3px;
|
||||
background: url(./images/line_bg_over_last.gif) 0 0 no-repeat transparent;
|
||||
}
|
||||
.simpleTree .folder-open
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/collapsable.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-open-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/collapsable-last.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-close
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/expandable.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .folder-close-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/expandable-last.gif) 0 -2px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .doc
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/leaf.gif) 0 -1px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .doc-last
|
||||
{
|
||||
margin-left:-16px;
|
||||
background: url(./images/leaf-last.gif) 0 -1px no-repeat #fff;
|
||||
}
|
||||
.simpleTree .ajax
|
||||
{
|
||||
background: url(./images/spinner.gif) no-repeat 0 0 #ffffff;
|
||||
height: 16px;
|
||||
display:none;
|
||||
}
|
||||
.simpleTree .ajax li
|
||||
{
|
||||
display:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.simpleTree .trigger
|
||||
{
|
||||
display:inline;
|
||||
margin-left:-32px;
|
||||
width: 28px;
|
||||
height: 11px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.simpleTree .text
|
||||
{
|
||||
cursor: default;
|
||||
}
|
||||
.simpleTree .active
|
||||
{
|
||||
cursor: default;
|
||||
background-color:#F7BE77;
|
||||
padding:0px 2px;
|
||||
border: 1px dashed #444;
|
||||
}
|
||||
#drag_container
|
||||
{
|
||||
background:#ffffff;
|
||||
color:#000;
|
||||
font: normal 11px arial, tahoma, helvetica, sans-serif;
|
||||
border: 1px dashed #767676;
|
||||
}
|
||||
#drag_container ul
|
||||
{
|
||||
list-style: none;
|
||||
padding:0;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
#drag_container li
|
||||
{
|
||||
list-style: none;
|
||||
background-color:#ffffff;
|
||||
line-height:18px;
|
||||
white-space: nowrap;
|
||||
padding:1px 1px 0px 16px;
|
||||
margin:0;
|
||||
}
|
||||
#drag_container li span
|
||||
{
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#drag_container li.doc, #drag_container li.doc-last
|
||||
{
|
||||
background: url(./images/leaf.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
#drag_container .folder-close, #drag_container .folder-close-last
|
||||
{
|
||||
background: url(./images/expandable.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
|
||||
#drag_container .folder-open, #drag_container .folder-open-last
|
||||
{
|
||||
background: url(./images/collapsable.gif) no-repeat -17px 0 #ffffff;
|
||||
}
|
||||
.contextMenu
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,61 @@
|
|||
/**
|
||||
* @brief Watch Input box
|
||||
* @author NHN (developers@xpresseingine.com)
|
||||
**/
|
||||
(function($){
|
||||
|
||||
var class_name = '_watch_input';
|
||||
|
||||
$.fn.watch_input = function(settings)
|
||||
{
|
||||
if (this.length == 0) return false;
|
||||
if (this.length > 1) {
|
||||
this.each(function(){ $(this).watch_input(settings) });
|
||||
return true;
|
||||
}
|
||||
if (!$.isFunction(settings.oninput)) return false;
|
||||
if (this.hasClass(class_name)) return false;
|
||||
|
||||
this[0].__wi_oninput = settings.oninput;
|
||||
this.addClass(class_name).keydown(_onkeydown).focus(_onfocus).blur(_onblur);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var timer = null, val = '', ie=$.browser.msie;
|
||||
|
||||
function _onkeydown(event)
|
||||
{
|
||||
if ($(this).val() != val) {
|
||||
val = $(this).val();
|
||||
this.__wi_oninput();
|
||||
}
|
||||
}
|
||||
|
||||
function _onfocus(event)
|
||||
{
|
||||
var self = $(this);
|
||||
|
||||
val = self.val();
|
||||
if (ie) return true;
|
||||
|
||||
(function fn() {
|
||||
if ( (self.val() != val) && $.isFunction(self[0].__wi_oninput) ) {
|
||||
val = self.val();
|
||||
self[0].__wi_oninput();
|
||||
}
|
||||
|
||||
timer = setTimeout(arguments.callee, 100);
|
||||
})();
|
||||
}
|
||||
|
||||
function _onblur(event)
|
||||
{
|
||||
val = '';
|
||||
if (!ie && timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
/**
|
||||
* @brief Watch Input box
|
||||
* @author NHN (developers@xpresseingine.com)
|
||||
**/
|
||||
(function($){
|
||||
|
||||
var class_name = '_watch_input';
|
||||
|
||||
$.fn.watch_input = function(settings)
|
||||
{
|
||||
if (this.length == 0) return false;
|
||||
if (this.length > 1) {
|
||||
this.each(function(){ $(this).watch_input(settings) });
|
||||
return true;
|
||||
}
|
||||
if (!$.isFunction(settings.oninput)) return false;
|
||||
if (this.hasClass(class_name)) return false;
|
||||
|
||||
this[0].__wi_oninput = settings.oninput;
|
||||
this.addClass(class_name).keydown(_onkeydown).focus(_onfocus).blur(_onblur);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
var timer = null, val = '', ie=$.browser.msie;
|
||||
|
||||
function _onkeydown(event)
|
||||
{
|
||||
if ($(this).val() != val) {
|
||||
val = $(this).val();
|
||||
this.__wi_oninput();
|
||||
}
|
||||
}
|
||||
|
||||
function _onfocus(event)
|
||||
{
|
||||
var self = $(this);
|
||||
|
||||
val = self.val();
|
||||
if (ie) return true;
|
||||
|
||||
(function fn() {
|
||||
if ( (self.val() != val) && $.isFunction(self[0].__wi_oninput) ) {
|
||||
val = self.val();
|
||||
self[0].__wi_oninput();
|
||||
}
|
||||
|
||||
timer = setTimeout(arguments.callee, 100);
|
||||
})();
|
||||
}
|
||||
|
||||
function _onblur(event)
|
||||
{
|
||||
val = '';
|
||||
if (!ie && timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,173 +1,173 @@
|
|||
// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
|
||||
// (c) 2008 Angus Turnbull http://www.twinhelix.com
|
||||
|
||||
// This is licensed under the GNU LGPL, version 2.1 or later.
|
||||
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
|
||||
var IEPNGFix = window.IEPNGFix || {};
|
||||
|
||||
IEPNGFix.tileBG = function(elm, pngSrc, ready) {
|
||||
// Params: A reference to a DOM element, the PNG src file pathname, and a
|
||||
// hidden "ready-to-run" passed when called back after image preloading.
|
||||
|
||||
var data = this.data[elm.uniqueID],
|
||||
elmW = Math.max(elm.clientWidth, elm.scrollWidth),
|
||||
elmH = Math.max(elm.clientHeight, elm.scrollHeight),
|
||||
bgX = elm.currentStyle.backgroundPositionX,
|
||||
bgY = elm.currentStyle.backgroundPositionY,
|
||||
bgR = elm.currentStyle.backgroundRepeat;
|
||||
|
||||
// Cache of DIVs created per element, and image preloader/data.
|
||||
if (!data.tiles) {
|
||||
data.tiles = {
|
||||
elm: elm,
|
||||
src: '',
|
||||
cache: [],
|
||||
img: new Image(),
|
||||
old: {}
|
||||
};
|
||||
}
|
||||
var tiles = data.tiles,
|
||||
pngW = tiles.img.width,
|
||||
pngH = tiles.img.height;
|
||||
|
||||
if (pngSrc) {
|
||||
if (!ready && pngSrc != tiles.src) {
|
||||
// New image? Preload it with a callback to detect dimensions.
|
||||
tiles.img.onload = function() {
|
||||
this.onload = null;
|
||||
IEPNGFix.tileBG(elm, pngSrc, 1);
|
||||
};
|
||||
return tiles.img.src = pngSrc;
|
||||
}
|
||||
} else {
|
||||
// No image?
|
||||
if (tiles.src) ready = 1;
|
||||
pngW = pngH = 0;
|
||||
}
|
||||
tiles.src = pngSrc;
|
||||
|
||||
if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
|
||||
bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert English and percentage positions to pixels.
|
||||
var pos = {
|
||||
top: '0%',
|
||||
left: '0%',
|
||||
center: '50%',
|
||||
bottom: '100%',
|
||||
right: '100%'
|
||||
},
|
||||
x,
|
||||
y,
|
||||
pc;
|
||||
x = pos[bgX] || bgX;
|
||||
y = pos[bgY] || bgY;
|
||||
if (pc = x.match(/(\d+)%/)) {
|
||||
x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
|
||||
}
|
||||
if (pc = y.match(/(\d+)%/)) {
|
||||
y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
|
||||
}
|
||||
x = parseInt(x);
|
||||
y = parseInt(y);
|
||||
|
||||
// Handle backgroundRepeat.
|
||||
var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
|
||||
repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
|
||||
if (repeatX) {
|
||||
x %= pngW;
|
||||
if (x > 0) x -= pngW;
|
||||
}
|
||||
if (repeatY) {
|
||||
y %= pngH;
|
||||
if (y > 0) y -= pngH;
|
||||
}
|
||||
|
||||
// Go!
|
||||
this.hook.enabled = 0;
|
||||
if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
|
||||
elm.style.position = 'relative';
|
||||
}
|
||||
var count = 0,
|
||||
xPos,
|
||||
maxX = repeatX ? elmW : x + 0.1,
|
||||
yPos,
|
||||
maxY = repeatY ? elmH : y + 0.1,
|
||||
d,
|
||||
s,
|
||||
isNew;
|
||||
if (pngW && pngH) {
|
||||
for (xPos = x; xPos < maxX; xPos += pngW) {
|
||||
for (yPos = y; yPos < maxY; yPos += pngH) {
|
||||
isNew = 0;
|
||||
if (!tiles.cache[count]) {
|
||||
tiles.cache[count] = document.createElement('div');
|
||||
isNew = 1;
|
||||
}
|
||||
var clipR = (xPos + pngW > elmW ? elmW - xPos : pngW),
|
||||
clipB = (yPos + pngH > elmH ? elmH - yPos : pngH);
|
||||
d = tiles.cache[count];
|
||||
s = d.style;
|
||||
s.behavior = 'none';
|
||||
s.left = xPos + 'px';
|
||||
s.top = yPos + 'px';
|
||||
s.width = clipR + 'px';
|
||||
s.height = clipB + 'px';
|
||||
s.clip = 'rect(' +
|
||||
(yPos < 0 ? 0 - yPos : 0) + 'px,' +
|
||||
clipR + 'px,' +
|
||||
clipB + 'px,' +
|
||||
(xPos < 0 ? 0 - xPos : 0) + 'px)';
|
||||
s.display = 'block';
|
||||
if (isNew) {
|
||||
s.position = 'absolute';
|
||||
s.zIndex = -999;
|
||||
if (elm.firstChild) {
|
||||
elm.insertBefore(d, elm.firstChild);
|
||||
} else {
|
||||
elm.appendChild(d);
|
||||
}
|
||||
}
|
||||
this.fix(d, pngSrc, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (count < tiles.cache.length) {
|
||||
this.fix(tiles.cache[count], '', 0);
|
||||
tiles.cache[count++].style.display = 'none';
|
||||
}
|
||||
|
||||
this.hook.enabled = 1;
|
||||
|
||||
// Cache so updates are infrequent.
|
||||
tiles.old = {
|
||||
w: elmW,
|
||||
h: elmH,
|
||||
x: bgX,
|
||||
y: bgY,
|
||||
r: bgR
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
IEPNGFix.update = function() {
|
||||
// Update all PNG backgrounds.
|
||||
for (var i in IEPNGFix.data) {
|
||||
var t = IEPNGFix.data[i].tiles;
|
||||
if (t && t.elm && t.src) {
|
||||
IEPNGFix.tileBG(t.elm, t.src);
|
||||
}
|
||||
}
|
||||
};
|
||||
IEPNGFix.update.timer = 0;
|
||||
|
||||
if (window.attachEvent && !window.opera) {
|
||||
window.attachEvent('onresize', function() {
|
||||
clearTimeout(IEPNGFix.update.timer);
|
||||
IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
|
||||
});
|
||||
}
|
||||
// IE5.5+ PNG Alpha Fix v2.0 Alpha: Background Tiling Support
|
||||
// (c) 2008 Angus Turnbull http://www.twinhelix.com
|
||||
|
||||
// This is licensed under the GNU LGPL, version 2.1 or later.
|
||||
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
|
||||
var IEPNGFix = window.IEPNGFix || {};
|
||||
|
||||
IEPNGFix.tileBG = function(elm, pngSrc, ready) {
|
||||
// Params: A reference to a DOM element, the PNG src file pathname, and a
|
||||
// hidden "ready-to-run" passed when called back after image preloading.
|
||||
|
||||
var data = this.data[elm.uniqueID],
|
||||
elmW = Math.max(elm.clientWidth, elm.scrollWidth),
|
||||
elmH = Math.max(elm.clientHeight, elm.scrollHeight),
|
||||
bgX = elm.currentStyle.backgroundPositionX,
|
||||
bgY = elm.currentStyle.backgroundPositionY,
|
||||
bgR = elm.currentStyle.backgroundRepeat;
|
||||
|
||||
// Cache of DIVs created per element, and image preloader/data.
|
||||
if (!data.tiles) {
|
||||
data.tiles = {
|
||||
elm: elm,
|
||||
src: '',
|
||||
cache: [],
|
||||
img: new Image(),
|
||||
old: {}
|
||||
};
|
||||
}
|
||||
var tiles = data.tiles,
|
||||
pngW = tiles.img.width,
|
||||
pngH = tiles.img.height;
|
||||
|
||||
if (pngSrc) {
|
||||
if (!ready && pngSrc != tiles.src) {
|
||||
// New image? Preload it with a callback to detect dimensions.
|
||||
tiles.img.onload = function() {
|
||||
this.onload = null;
|
||||
IEPNGFix.tileBG(elm, pngSrc, 1);
|
||||
};
|
||||
return tiles.img.src = pngSrc;
|
||||
}
|
||||
} else {
|
||||
// No image?
|
||||
if (tiles.src) ready = 1;
|
||||
pngW = pngH = 0;
|
||||
}
|
||||
tiles.src = pngSrc;
|
||||
|
||||
if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
|
||||
bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert English and percentage positions to pixels.
|
||||
var pos = {
|
||||
top: '0%',
|
||||
left: '0%',
|
||||
center: '50%',
|
||||
bottom: '100%',
|
||||
right: '100%'
|
||||
},
|
||||
x,
|
||||
y,
|
||||
pc;
|
||||
x = pos[bgX] || bgX;
|
||||
y = pos[bgY] || bgY;
|
||||
if (pc = x.match(/(\d+)%/)) {
|
||||
x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
|
||||
}
|
||||
if (pc = y.match(/(\d+)%/)) {
|
||||
y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
|
||||
}
|
||||
x = parseInt(x);
|
||||
y = parseInt(y);
|
||||
|
||||
// Handle backgroundRepeat.
|
||||
var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
|
||||
repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
|
||||
if (repeatX) {
|
||||
x %= pngW;
|
||||
if (x > 0) x -= pngW;
|
||||
}
|
||||
if (repeatY) {
|
||||
y %= pngH;
|
||||
if (y > 0) y -= pngH;
|
||||
}
|
||||
|
||||
// Go!
|
||||
this.hook.enabled = 0;
|
||||
if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
|
||||
elm.style.position = 'relative';
|
||||
}
|
||||
var count = 0,
|
||||
xPos,
|
||||
maxX = repeatX ? elmW : x + 0.1,
|
||||
yPos,
|
||||
maxY = repeatY ? elmH : y + 0.1,
|
||||
d,
|
||||
s,
|
||||
isNew;
|
||||
if (pngW && pngH) {
|
||||
for (xPos = x; xPos < maxX; xPos += pngW) {
|
||||
for (yPos = y; yPos < maxY; yPos += pngH) {
|
||||
isNew = 0;
|
||||
if (!tiles.cache[count]) {
|
||||
tiles.cache[count] = document.createElement('div');
|
||||
isNew = 1;
|
||||
}
|
||||
var clipR = (xPos + pngW > elmW ? elmW - xPos : pngW),
|
||||
clipB = (yPos + pngH > elmH ? elmH - yPos : pngH);
|
||||
d = tiles.cache[count];
|
||||
s = d.style;
|
||||
s.behavior = 'none';
|
||||
s.left = xPos + 'px';
|
||||
s.top = yPos + 'px';
|
||||
s.width = clipR + 'px';
|
||||
s.height = clipB + 'px';
|
||||
s.clip = 'rect(' +
|
||||
(yPos < 0 ? 0 - yPos : 0) + 'px,' +
|
||||
clipR + 'px,' +
|
||||
clipB + 'px,' +
|
||||
(xPos < 0 ? 0 - xPos : 0) + 'px)';
|
||||
s.display = 'block';
|
||||
if (isNew) {
|
||||
s.position = 'absolute';
|
||||
s.zIndex = -999;
|
||||
if (elm.firstChild) {
|
||||
elm.insertBefore(d, elm.firstChild);
|
||||
} else {
|
||||
elm.appendChild(d);
|
||||
}
|
||||
}
|
||||
this.fix(d, pngSrc, 0);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (count < tiles.cache.length) {
|
||||
this.fix(tiles.cache[count], '', 0);
|
||||
tiles.cache[count++].style.display = 'none';
|
||||
}
|
||||
|
||||
this.hook.enabled = 1;
|
||||
|
||||
// Cache so updates are infrequent.
|
||||
tiles.old = {
|
||||
w: elmW,
|
||||
h: elmH,
|
||||
x: bgX,
|
||||
y: bgY,
|
||||
r: bgR
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
IEPNGFix.update = function() {
|
||||
// Update all PNG backgrounds.
|
||||
for (var i in IEPNGFix.data) {
|
||||
var t = IEPNGFix.data[i].tiles;
|
||||
if (t && t.elm && t.src) {
|
||||
IEPNGFix.tileBG(t.elm, t.src);
|
||||
}
|
||||
}
|
||||
};
|
||||
IEPNGFix.update.timer = 0;
|
||||
|
||||
if (window.attachEvent && !window.opera) {
|
||||
window.attachEvent('onresize', function() {
|
||||
clearTimeout(IEPNGFix.update.timer);
|
||||
IEPNGFix.update.timer = setTimeout(IEPNGFix.update, 100);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,279 +1,279 @@
|
|||
/**
|
||||
* @file js_app.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief XE JavaScript Application Framework (JAF)
|
||||
* @namespace xe
|
||||
* @update 20100701
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var _xe_base, _app_base, _plugin_base;
|
||||
var _apps = [];
|
||||
|
||||
_xe_base = {
|
||||
/**
|
||||
* @brief return the name of Core module
|
||||
*/
|
||||
getName : function() {
|
||||
return 'Core';
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Create an application class
|
||||
*/
|
||||
createApp : function(sName, oDef) {
|
||||
var _base = getTypeBase();
|
||||
|
||||
$.extend(_base.prototype, _app_base, oDef);
|
||||
|
||||
_base.prototype.getName = function() {
|
||||
return sName;
|
||||
};
|
||||
|
||||
return _base;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Create a plugin class
|
||||
*/
|
||||
createPlugin : function(sName, oDef) {
|
||||
var _base = getTypeBase();
|
||||
|
||||
$.extend(_base.prototype, _plugin_base, oDef);
|
||||
|
||||
_base.prototype.getName = function() {
|
||||
return sName;
|
||||
};
|
||||
|
||||
return _base;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Get the array of applications
|
||||
*/
|
||||
getApps : function() {
|
||||
return $.makeArray(_apps);
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Get one application
|
||||
*/
|
||||
getApp : function(indexOrName) {
|
||||
indexOrName = (indexOrName||'').toLowerCase();
|
||||
if(typeof _apps[indexOrName] != 'undefined') {
|
||||
return _apps[indexOrName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Register an application instance
|
||||
*/
|
||||
registerApp : function(oApp) {
|
||||
var sName = oApp.getName().toLowerCase();
|
||||
|
||||
_apps.push(oApp);
|
||||
if (!$.isArray(_apps[sName])) {
|
||||
_apps[sName] = [];
|
||||
}
|
||||
_apps[sName].push(oApp);
|
||||
|
||||
oApp.parent = this;
|
||||
|
||||
// register event
|
||||
if ($.isFunction(oApp.activate)) oApp.activate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Unregister an application instance
|
||||
*/
|
||||
unregisterApp : function(oApp) {
|
||||
var sName = oPlugin.getName().toLowerCase();
|
||||
var nIndex = $.inArray(oApp, _apps);
|
||||
|
||||
if (nIndex >= 0) _apps.splice(nIndex, 1);
|
||||
|
||||
if ($.isArray(_apps[sName])) {
|
||||
nIndex = $.inArray(oApp, _apps[sName]);
|
||||
if (nIndex >= 0) _apps[sName].splice(nIndex, 1);
|
||||
}
|
||||
|
||||
// unregister event
|
||||
if ($.isFunction(oApp.deactivate)) oApp.deactivate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief overrides broadcast method
|
||||
*/
|
||||
broadcast : function(msg, params) {
|
||||
this._broadcast(this, msg, params);
|
||||
},
|
||||
|
||||
_broadcast : function(sender, msg, params) {
|
||||
for(var i=0; i < _apps.length; i++) {
|
||||
_apps[i]._cast(sender, msg, params);
|
||||
}
|
||||
|
||||
|
||||
// cast to child plugins
|
||||
this._cast(sender, msg, params);
|
||||
}
|
||||
}
|
||||
|
||||
_app_base = {
|
||||
_plugins : [],
|
||||
_messages : {},
|
||||
|
||||
/**
|
||||
* @brief get plugin
|
||||
*/
|
||||
getPlugin : function(sPluginName) {
|
||||
sPluginName = sPluginName.toLowerCase();
|
||||
if ($.isArray(this._plugins[sPluginName])) {
|
||||
return this._plugins[sPluginName];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief register a plugin instance
|
||||
*/
|
||||
registerPlugin : function(oPlugin) {
|
||||
var self = this;
|
||||
var sName = oPlugin.getName().toLowerCase();
|
||||
|
||||
// check if the plugin is already registered
|
||||
if ($.inArray(oPlugin, this._plugins) >= 0) return false;
|
||||
|
||||
// push the plugin into the _plugins array
|
||||
this._plugins.push(oPlugin);
|
||||
|
||||
if (!$.isArray(this._plugins[sName])) this._plugins[sName] = [];
|
||||
this._plugins[sName].push(oPlugin);
|
||||
|
||||
// register method pool
|
||||
$.each(oPlugin._binded_fn, function(api, fn){ self.registerHandler(api, fn); });
|
||||
|
||||
// binding
|
||||
oPlugin.oApp = this;
|
||||
|
||||
// registered event
|
||||
if ($.isFunction(oPlugin.activate)) oPlugin.activate();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief register api message handler
|
||||
*/
|
||||
registerHandler : function(api, func) {
|
||||
var msgs = this._messages; api = api.toUpperCase();
|
||||
if (!$.isArray(msgs[api])) msgs[api] = [];
|
||||
msgs[api].push(func);
|
||||
},
|
||||
|
||||
cast : function(msg, params) {
|
||||
return this._cast(this, msg, params || []);
|
||||
},
|
||||
|
||||
broadcast : function(sender, msg, params) {
|
||||
if (this.parent && this.parent._broadcast) {
|
||||
this.parent._broadcast(sender, msg, params);
|
||||
}
|
||||
},
|
||||
|
||||
_cast : function(sender, msg, params) {
|
||||
var i, len;
|
||||
var aMsg = this._messages;
|
||||
|
||||
msg = msg.toUpperCase();
|
||||
|
||||
// BEFORE hooker
|
||||
if (aMsg['BEFORE_'+msg] || this['API_BEFORE_'+msg]) {
|
||||
var bContinue = this._cast(sender, 'BEFORE_'+msg, params);
|
||||
if (!bContinue) return;
|
||||
}
|
||||
|
||||
// main api function
|
||||
var vRet = [], sFn = 'API_'+msg;
|
||||
if ($.isArray(aMsg[msg])) {
|
||||
for(i=0; i < aMsg[msg].length; i++) {
|
||||
vRet.push( aMsg[msg][i](sender, params) );
|
||||
}
|
||||
}
|
||||
if (vRet.length < 2) vRet = vRet[0];
|
||||
|
||||
// AFTER hooker
|
||||
if (aMsg['AFTER_'+msg] || this['API_AFTER_'+msg]) {
|
||||
this._cast(sender, 'AFTER_'+msg, params);
|
||||
}
|
||||
|
||||
if (!/^(?:AFTER|BEFORE)_/.test(msg)) { // top level function
|
||||
return vRet;
|
||||
} else {
|
||||
return $.isArray(vRet)?($.inArray(false, vRet)<0):((typeof vRet=='undefined')?true:!!vRet);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_plugin_base = {
|
||||
oApp : null,
|
||||
|
||||
cast : function(msg, params) {
|
||||
if (this.oApp && this.oApp._cast) {
|
||||
return this.oApp._cast(this, msg, params || []);
|
||||
}
|
||||
},
|
||||
|
||||
broadcast : function(msg, params) {
|
||||
if (this.oApp && this.oApp.broadcast) {
|
||||
this.oApp.broadcast(this, mag, params || []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler prototype
|
||||
*
|
||||
* function (oSender, params)
|
||||
*/
|
||||
};
|
||||
|
||||
function getTypeBase() {
|
||||
var _base = function() {
|
||||
var self = this;
|
||||
var pool = null;
|
||||
|
||||
if ($.isArray(this._plugins)) this._plugins = [];
|
||||
if (this._messages) this._messages = {};
|
||||
else this._binded_fn = {};
|
||||
|
||||
// bind functions
|
||||
$.each(this, function(key, val){
|
||||
if (!$.isFunction(val)) return true;
|
||||
if (!/^API_([A-Z0-9_]+)$/.test(key)) return true;
|
||||
|
||||
var api = RegExp.$1;
|
||||
var fn = function(sender, params){ return self[key](sender, params) };
|
||||
|
||||
if (self._messages) self._messages[api] = [fn];
|
||||
else self._binded_fn[api] = fn;
|
||||
});
|
||||
|
||||
if ($.isFunction(this.init)) this.init.apply(this, arguments);
|
||||
};
|
||||
|
||||
return _base;
|
||||
}
|
||||
|
||||
window.xe = $.extend(_app_base, _xe_base);
|
||||
window.xe.lang = {}; // language repository
|
||||
|
||||
// domready event
|
||||
$(function(){ xe.broadcast('ONREADY'); });
|
||||
|
||||
// load event
|
||||
$(window).load(function(){ xe.broadcast('ONLOAD'); });
|
||||
|
||||
})(jQuery);
|
||||
/**
|
||||
* @file js_app.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief XE JavaScript Application Framework (JAF)
|
||||
* @namespace xe
|
||||
* @update 20100701
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var _xe_base, _app_base, _plugin_base;
|
||||
var _apps = [];
|
||||
|
||||
_xe_base = {
|
||||
/**
|
||||
* @brief return the name of Core module
|
||||
*/
|
||||
getName : function() {
|
||||
return 'Core';
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Create an application class
|
||||
*/
|
||||
createApp : function(sName, oDef) {
|
||||
var _base = getTypeBase();
|
||||
|
||||
$.extend(_base.prototype, _app_base, oDef);
|
||||
|
||||
_base.prototype.getName = function() {
|
||||
return sName;
|
||||
};
|
||||
|
||||
return _base;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Create a plugin class
|
||||
*/
|
||||
createPlugin : function(sName, oDef) {
|
||||
var _base = getTypeBase();
|
||||
|
||||
$.extend(_base.prototype, _plugin_base, oDef);
|
||||
|
||||
_base.prototype.getName = function() {
|
||||
return sName;
|
||||
};
|
||||
|
||||
return _base;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Get the array of applications
|
||||
*/
|
||||
getApps : function() {
|
||||
return $.makeArray(_apps);
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Get one application
|
||||
*/
|
||||
getApp : function(indexOrName) {
|
||||
indexOrName = (indexOrName||'').toLowerCase();
|
||||
if(typeof _apps[indexOrName] != 'undefined') {
|
||||
return _apps[indexOrName];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Register an application instance
|
||||
*/
|
||||
registerApp : function(oApp) {
|
||||
var sName = oApp.getName().toLowerCase();
|
||||
|
||||
_apps.push(oApp);
|
||||
if (!$.isArray(_apps[sName])) {
|
||||
_apps[sName] = [];
|
||||
}
|
||||
_apps[sName].push(oApp);
|
||||
|
||||
oApp.parent = this;
|
||||
|
||||
// register event
|
||||
if ($.isFunction(oApp.activate)) oApp.activate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Unregister an application instance
|
||||
*/
|
||||
unregisterApp : function(oApp) {
|
||||
var sName = oPlugin.getName().toLowerCase();
|
||||
var nIndex = $.inArray(oApp, _apps);
|
||||
|
||||
if (nIndex >= 0) _apps.splice(nIndex, 1);
|
||||
|
||||
if ($.isArray(_apps[sName])) {
|
||||
nIndex = $.inArray(oApp, _apps[sName]);
|
||||
if (nIndex >= 0) _apps[sName].splice(nIndex, 1);
|
||||
}
|
||||
|
||||
// unregister event
|
||||
if ($.isFunction(oApp.deactivate)) oApp.deactivate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief overrides broadcast method
|
||||
*/
|
||||
broadcast : function(msg, params) {
|
||||
this._broadcast(this, msg, params);
|
||||
},
|
||||
|
||||
_broadcast : function(sender, msg, params) {
|
||||
for(var i=0; i < _apps.length; i++) {
|
||||
_apps[i]._cast(sender, msg, params);
|
||||
}
|
||||
|
||||
|
||||
// cast to child plugins
|
||||
this._cast(sender, msg, params);
|
||||
}
|
||||
}
|
||||
|
||||
_app_base = {
|
||||
_plugins : [],
|
||||
_messages : {},
|
||||
|
||||
/**
|
||||
* @brief get plugin
|
||||
*/
|
||||
getPlugin : function(sPluginName) {
|
||||
sPluginName = sPluginName.toLowerCase();
|
||||
if ($.isArray(this._plugins[sPluginName])) {
|
||||
return this._plugins[sPluginName];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief register a plugin instance
|
||||
*/
|
||||
registerPlugin : function(oPlugin) {
|
||||
var self = this;
|
||||
var sName = oPlugin.getName().toLowerCase();
|
||||
|
||||
// check if the plugin is already registered
|
||||
if ($.inArray(oPlugin, this._plugins) >= 0) return false;
|
||||
|
||||
// push the plugin into the _plugins array
|
||||
this._plugins.push(oPlugin);
|
||||
|
||||
if (!$.isArray(this._plugins[sName])) this._plugins[sName] = [];
|
||||
this._plugins[sName].push(oPlugin);
|
||||
|
||||
// register method pool
|
||||
$.each(oPlugin._binded_fn, function(api, fn){ self.registerHandler(api, fn); });
|
||||
|
||||
// binding
|
||||
oPlugin.oApp = this;
|
||||
|
||||
// registered event
|
||||
if ($.isFunction(oPlugin.activate)) oPlugin.activate();
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief register api message handler
|
||||
*/
|
||||
registerHandler : function(api, func) {
|
||||
var msgs = this._messages; api = api.toUpperCase();
|
||||
if (!$.isArray(msgs[api])) msgs[api] = [];
|
||||
msgs[api].push(func);
|
||||
},
|
||||
|
||||
cast : function(msg, params) {
|
||||
return this._cast(this, msg, params || []);
|
||||
},
|
||||
|
||||
broadcast : function(sender, msg, params) {
|
||||
if (this.parent && this.parent._broadcast) {
|
||||
this.parent._broadcast(sender, msg, params);
|
||||
}
|
||||
},
|
||||
|
||||
_cast : function(sender, msg, params) {
|
||||
var i, len;
|
||||
var aMsg = this._messages;
|
||||
|
||||
msg = msg.toUpperCase();
|
||||
|
||||
// BEFORE hooker
|
||||
if (aMsg['BEFORE_'+msg] || this['API_BEFORE_'+msg]) {
|
||||
var bContinue = this._cast(sender, 'BEFORE_'+msg, params);
|
||||
if (!bContinue) return;
|
||||
}
|
||||
|
||||
// main api function
|
||||
var vRet = [], sFn = 'API_'+msg;
|
||||
if ($.isArray(aMsg[msg])) {
|
||||
for(i=0; i < aMsg[msg].length; i++) {
|
||||
vRet.push( aMsg[msg][i](sender, params) );
|
||||
}
|
||||
}
|
||||
if (vRet.length < 2) vRet = vRet[0];
|
||||
|
||||
// AFTER hooker
|
||||
if (aMsg['AFTER_'+msg] || this['API_AFTER_'+msg]) {
|
||||
this._cast(sender, 'AFTER_'+msg, params);
|
||||
}
|
||||
|
||||
if (!/^(?:AFTER|BEFORE)_/.test(msg)) { // top level function
|
||||
return vRet;
|
||||
} else {
|
||||
return $.isArray(vRet)?($.inArray(false, vRet)<0):((typeof vRet=='undefined')?true:!!vRet);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_plugin_base = {
|
||||
oApp : null,
|
||||
|
||||
cast : function(msg, params) {
|
||||
if (this.oApp && this.oApp._cast) {
|
||||
return this.oApp._cast(this, msg, params || []);
|
||||
}
|
||||
},
|
||||
|
||||
broadcast : function(msg, params) {
|
||||
if (this.oApp && this.oApp.broadcast) {
|
||||
this.oApp.broadcast(this, mag, params || []);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler prototype
|
||||
*
|
||||
* function (oSender, params)
|
||||
*/
|
||||
};
|
||||
|
||||
function getTypeBase() {
|
||||
var _base = function() {
|
||||
var self = this;
|
||||
var pool = null;
|
||||
|
||||
if ($.isArray(this._plugins)) this._plugins = [];
|
||||
if (this._messages) this._messages = {};
|
||||
else this._binded_fn = {};
|
||||
|
||||
// bind functions
|
||||
$.each(this, function(key, val){
|
||||
if (!$.isFunction(val)) return true;
|
||||
if (!/^API_([A-Z0-9_]+)$/.test(key)) return true;
|
||||
|
||||
var api = RegExp.$1;
|
||||
var fn = function(sender, params){ return self[key](sender, params) };
|
||||
|
||||
if (self._messages) self._messages[api] = [fn];
|
||||
else self._binded_fn[api] = fn;
|
||||
});
|
||||
|
||||
if ($.isFunction(this.init)) this.init.apply(this, arguments);
|
||||
};
|
||||
|
||||
return _base;
|
||||
}
|
||||
|
||||
window.xe = $.extend(_app_base, _xe_base);
|
||||
window.xe.lang = {}; // language repository
|
||||
|
||||
// domready event
|
||||
$(function(){ xe.broadcast('ONREADY'); });
|
||||
|
||||
// load event
|
||||
$(window).load(function(){ xe.broadcast('ONLOAD'); });
|
||||
|
||||
})(jQuery);
|
||||
|
|
|
|||
1352
common/js/src/x.js
1352
common/js/src/x.js
File diff suppressed because it is too large
Load diff
|
|
@ -1,409 +1,409 @@
|
|||
/**
|
||||
* @file common/js/xml_handler.js
|
||||
* @brief XE에서 ajax기능을 이용함에 있어 module, act를 잘 사용하기 위한 자바스크립트
|
||||
**/
|
||||
|
||||
// xml handler을 이용하는 user function
|
||||
var show_waiting_message = true;
|
||||
|
||||
/* This work is licensed under Creative Commons GNU LGPL License.
|
||||
|
||||
License: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
Version: 0.9
|
||||
Author: Stefan Goessner/2006
|
||||
Web: http://goessner.net/
|
||||
*/
|
||||
function xml2json(xml, tab, ignoreAttrib) {
|
||||
var X = {
|
||||
toObj: function(xml) {
|
||||
var o = {};
|
||||
if (xml.nodeType==1) { // element node ..
|
||||
if (ignoreAttrib && xml.attributes.length) // element with attributes ..
|
||||
for (var i=0; i<xml.attributes.length; i++)
|
||||
o["@"+xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue||"").toString();
|
||||
if (xml.firstChild) { // element has child nodes ..
|
||||
var textChild=0, cdataChild=0, hasElementChild=false;
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling) {
|
||||
if (n.nodeType==1) hasElementChild = true;
|
||||
else if (n.nodeType==3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) textChild++; // non-whitespace text
|
||||
else if (n.nodeType==4) cdataChild++; // cdata section node
|
||||
}
|
||||
if (hasElementChild) {
|
||||
if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node ..
|
||||
X.removeWhite(xml);
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling) {
|
||||
if (n.nodeType == 3) // text node
|
||||
o = X.escape(n.nodeValue);
|
||||
else if (n.nodeType == 4) // cdata node
|
||||
// o["#cdata"] = X.escape(n.nodeValue);
|
||||
o = X.escape(n.nodeValue);
|
||||
else if (o[n.nodeName]) { // multiple occurence of element ..
|
||||
if (o[n.nodeName] instanceof Array)
|
||||
o[n.nodeName][o[n.nodeName].length] = X.toObj(n);
|
||||
else
|
||||
o[n.nodeName] = [o[n.nodeName], X.toObj(n)];
|
||||
}
|
||||
else // first occurence of element..
|
||||
o[n.nodeName] = X.toObj(n);
|
||||
}
|
||||
}
|
||||
else { // mixed content
|
||||
if (!xml.attributes.length)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
o["#text"] = X.escape(X.innerXml(xml));
|
||||
}
|
||||
}
|
||||
else if (textChild) { // pure text
|
||||
if (!xml.attributes.length)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
o["#text"] = X.escape(X.innerXml(xml));
|
||||
}
|
||||
else if (cdataChild) { // cdata
|
||||
if (cdataChild > 1)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling){
|
||||
//o["#cdata"] = X.escape(n.nodeValue);
|
||||
o = X.escape(n.nodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!xml.attributes.length && !xml.firstChild) o = null;
|
||||
}
|
||||
else if (xml.nodeType==9) { // document.node
|
||||
o = X.toObj(xml.documentElement);
|
||||
}
|
||||
else
|
||||
alert("unhandled node type: " + xml.nodeType);
|
||||
return o;
|
||||
},
|
||||
toJson: function(o, name, ind) {
|
||||
var json = name ? ("\""+name+"\"") : "";
|
||||
if (o instanceof Array) {
|
||||
for (var i=0,n=o.length; i<n; i++)
|
||||
o[i] = X.toJson(o[i], "", ind+"\t");
|
||||
json += (name?":[":"[") + (o.length > 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]";
|
||||
}
|
||||
else if (o == null)
|
||||
json += (name&&":") + "null";
|
||||
else if (typeof(o) == "object") {
|
||||
var arr = [];
|
||||
for (var m in o)
|
||||
arr[arr.length] = X.toJson(o[m], m, ind+"\t");
|
||||
json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}";
|
||||
}
|
||||
else if (typeof(o) == "string")
|
||||
json += (name&&":") + "\"" + o.toString() + "\"";
|
||||
else
|
||||
json += (name&&":") + o.toString();
|
||||
return json;
|
||||
},
|
||||
innerXml: function(node) {
|
||||
var s = ""
|
||||
if ("innerHTML" in node)
|
||||
s = node.innerHTML;
|
||||
else {
|
||||
var asXml = function(n) {
|
||||
var s = "";
|
||||
if (n.nodeType == 1) {
|
||||
s += "<" + n.nodeName;
|
||||
for (var i=0; i<n.attributes.length;i++)
|
||||
s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue||"").toString() + "\"";
|
||||
if (n.firstChild) {
|
||||
s += ">";
|
||||
for (var c=n.firstChild; c; c=c.nextSibling)
|
||||
s += asXml(c);
|
||||
s += "</"+n.nodeName+">";
|
||||
}
|
||||
else
|
||||
s += "/>";
|
||||
}
|
||||
else if (n.nodeType == 3)
|
||||
s += n.nodeValue;
|
||||
else if (n.nodeType == 4)
|
||||
s += "<![CDATA[" + n.nodeValue + "]]>";
|
||||
return s;
|
||||
};
|
||||
for (var c=node.firstChild; c; c=c.nextSibling)
|
||||
s += asXml(c);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
escape: function(txt) {
|
||||
return txt.replace(/[\\]/g, "\\\\")
|
||||
.replace(/[\"]/g, '\\"')
|
||||
.replace(/[\n]/g, '\\n')
|
||||
.replace(/[\r]/g, '\\r');
|
||||
},
|
||||
removeWhite: function(e) {
|
||||
e.normalize();
|
||||
for (var n = e.firstChild; n; ) {
|
||||
if (n.nodeType == 3) { // text node
|
||||
if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node
|
||||
var nxt = n.nextSibling;
|
||||
e.removeChild(n);
|
||||
n = nxt;
|
||||
}
|
||||
else
|
||||
n = n.nextSibling;
|
||||
}
|
||||
else if (n.nodeType == 1) { // element node
|
||||
X.removeWhite(n);
|
||||
n = n.nextSibling;
|
||||
}
|
||||
else // any other node
|
||||
n = n.nextSibling;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
};
|
||||
if (xml.nodeType == 9) // document node
|
||||
xml = xml.documentElement;
|
||||
|
||||
var json_obj = X.toObj(X.removeWhite(xml)), json_str;
|
||||
|
||||
if (typeof(JSON)=='object' && jQuery.isFunction(JSON.stringify) && false) {
|
||||
var obj = {}; obj[xml.nodeName] = json_obj;
|
||||
json_str = JSON.stringify(obj);
|
||||
return json_str;
|
||||
} else {
|
||||
json_str = X.toJson(json_obj, xml.nodeName, "");
|
||||
return "{" + (tab ? json_str.replace(/\t/g, tab) : json_str.replace(/\t|\n/g, "")) + "}";
|
||||
}
|
||||
}
|
||||
|
||||
(function($){
|
||||
/**
|
||||
* @brief exec_xml
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
$.exec_xml = window.exec_xml = function(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj) {
|
||||
var xml_path = request_uri+"index.php"
|
||||
if(!params) params = {};
|
||||
|
||||
// {{{ set parameters
|
||||
if($.isArray(params)) params = arr2obj(params);
|
||||
params['module'] = module;
|
||||
params['act'] = act;
|
||||
|
||||
if(typeof(xeVid)!='undefined') params['vid'] = xeVid;
|
||||
if(typeof(response_tags)=="undefined" || response_tags.length<1) response_tags = ['error','message'];
|
||||
else {
|
||||
response_tags.push('error', 'message');
|
||||
}
|
||||
// }}} set parameters
|
||||
|
||||
// use ssl?
|
||||
if ($.isArray(ssl_actions) && params['act'] && $.inArray(params['act'], ssl_actions) >= 0)
|
||||
{
|
||||
var url = default_url || request_uri;
|
||||
var port = window.https_port || 443;
|
||||
var _ul = $('<a>').attr('href', url)[0];
|
||||
var target = 'https://' + _ul.hostname.replace(/:\d+$/, '');
|
||||
|
||||
if(port != 443) target += ':'+port;
|
||||
if(_ul.pathname[0] != '/') target += '/';
|
||||
|
||||
target += _ul.pathname;
|
||||
xml_path = target.replace(/\/$/, '')+'/index.php';
|
||||
}
|
||||
|
||||
var _u1 = $('<a>').attr('href', location.href)[0];
|
||||
var _u2 = $('<a>').attr('href', xml_path)[0];
|
||||
|
||||
// 현 url과 ajax call 대상 url의 schema 또는 port가 다르면 직접 form 전송
|
||||
if(_u1.protocol != _u2.protocol || _u1.port != _u2.port) return send_by_form(xml_path, params);
|
||||
|
||||
var xml = [], i = 0;
|
||||
xml[i++] = '<?xml version="1.0" encoding="utf-8" ?>';
|
||||
xml[i++] = '<methodCall>';
|
||||
xml[i++] = '<params>';
|
||||
|
||||
$.each(params, function(key, val) {
|
||||
xml[i++] = '<'+key+'><![CDATA['+val+']]></'+key+'>';
|
||||
});
|
||||
|
||||
xml[i++] = '</params>';
|
||||
xml[i++] = '</methodCall>';
|
||||
|
||||
var _xhr = null;
|
||||
if (_xhr && _xhr.readyState != 0) _xhr.abort();
|
||||
|
||||
// 전송 성공시
|
||||
function onsuccess(data, textStatus, xhr) {
|
||||
var resp_xml = $(data).find('response')[0], resp_obj, txt='', ret=[], tags={}, json_str='';
|
||||
|
||||
waiting_obj.css('visibility', 'hidden');
|
||||
|
||||
if(!resp_xml) {
|
||||
alert(_xhr.responseText);
|
||||
return null;
|
||||
}
|
||||
|
||||
json_str = xml2json(resp_xml, false, false);
|
||||
resp_obj = (typeof(JSON)=='object' && $.isFunction(JSON.parse))?JSON.parse(json_str):eval('('+json_str+')');
|
||||
resp_obj = resp_obj.response;
|
||||
|
||||
if (typeof(resp_obj)=='undefined') {
|
||||
ret['error'] = -1;
|
||||
ret['message'] = 'Unexpected error occured.';
|
||||
try {
|
||||
if(typeof(txt=resp_xml.childNodes[0].firstChild.data)!='undefined') ret['message'] += '\r\n'+txt;
|
||||
} catch(e){};
|
||||
return ret;
|
||||
}
|
||||
|
||||
$.each(response_tags, function(key, val){ tags[val] = true; });
|
||||
tags["redirect_url"] = true;
|
||||
tags["act"] = true;
|
||||
$.each(resp_obj, function(key, val){ if(tags[key]) ret[key] = val; });
|
||||
|
||||
if(ret['error'] != 0) {
|
||||
if ($.isFunction($.exec_xml.onerror)) {
|
||||
return $.exec_xml.onerror(module, act, ret, callback_func, response_tags, callback_func_arg, fo_obj);
|
||||
}
|
||||
|
||||
alert(ret['message'] || 'error!');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(ret['redirect_url']) {
|
||||
location.href = ret['redirect_url'].replace(/&/g, '&');
|
||||
return null;
|
||||
}
|
||||
|
||||
if($.isFunction(callback_func)) callback_func(ret, response_tags, callback_func_arg, fo_obj);
|
||||
}
|
||||
|
||||
// 모든 xml데이터는 POST방식으로 전송. try-catch문으로 오류 발생시 대처
|
||||
try {
|
||||
$.ajax({
|
||||
url : xml_path,
|
||||
type : 'POST',
|
||||
dataType : 'xml',
|
||||
data : xml.join('\n'),
|
||||
contentType : 'text/plain',
|
||||
beforeSend : function(xhr){ _xhr = xhr; },
|
||||
success : onsuccess,
|
||||
error : function(xhr, textStatus) {
|
||||
waiting_obj.css('visibility', 'hidden');
|
||||
|
||||
var msg = '';
|
||||
if (textStatus == 'parsererror') {
|
||||
msg = 'The result is not valid XML :\n-------------------------------------\n';
|
||||
if(xhr.responseText == "") return;
|
||||
msg += xhr.responseText.replace(/<[^>]+>/g, '');
|
||||
} else {
|
||||
msg = textStatus;
|
||||
}
|
||||
|
||||
alert(msg);
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
alert(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// ajax 통신중 대기 메세지 출력 (show_waiting_message값을 false로 세팅시 보이지 않음)
|
||||
var waiting_obj = $('#waitingforserverresponse');
|
||||
if(show_waiting_message && waiting_obj.length) {
|
||||
var d = $(document);
|
||||
waiting_obj.html(waiting_message).css({
|
||||
'top' : (d.scrollTop()+20)+'px',
|
||||
'left' : (d.scrollLeft()+20)+'px',
|
||||
'visibility' : 'visible'
|
||||
});
|
||||
}
|
||||
}
|
||||
function send_by_form(url, params) {
|
||||
var frame_id = 'xeTmpIframe';
|
||||
var form_id = 'xeVirtualForm';
|
||||
|
||||
if (!$('#'+frame_id).length) {
|
||||
$('<iframe name="%id%" id="%id%" style="position:absolute;left:-1px;top:1px;width:1px;height:1px"></iframe>'.replace(/%id%/g, frame_id)).appendTo(document.body);
|
||||
}
|
||||
|
||||
$('#'+form_id).remove();
|
||||
var form = $('<form id="%id%"></form>'.replace(/%id%/g, form_id)).attr({
|
||||
'id' : form_id,
|
||||
'method' : 'post',
|
||||
'action' : url,
|
||||
'target' : frame_id
|
||||
});
|
||||
|
||||
params['xeVirtualRequestMethod'] = 'xml';
|
||||
params['xeRequestURI'] = location.href.replace(/#(.*)$/i,'');
|
||||
params['xeVirtualRequestUrl'] = request_uri;
|
||||
|
||||
$.each(params, function(key, value){
|
||||
$('<input type="hidden">').attr('name', key).attr('value', value).appendTo(form);
|
||||
});
|
||||
|
||||
form.appendTo(document.body).submit();
|
||||
}
|
||||
function arr2obj(arr) {
|
||||
var ret = {};
|
||||
for(var key in arr) {
|
||||
if(arr.hasOwnProperty(key)) ret[key] = arr[key];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exec_json (exec_xml와 같은 용도)
|
||||
**/
|
||||
$.exec_json = function(action,data,func){
|
||||
if(typeof(data) == 'undefined') data = {};
|
||||
action = action.split(".");
|
||||
if(action.length == 2){
|
||||
|
||||
if(show_waiting_message) {
|
||||
$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');
|
||||
}
|
||||
|
||||
$.extend(data,{module:action[0],act:action[1]});
|
||||
if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid});
|
||||
$.ajax({
|
||||
type:"POST"
|
||||
,dataType:"json"
|
||||
,url:request_uri
|
||||
,contentType:"application/json"
|
||||
,data:$.param(data)
|
||||
,success : function(data){
|
||||
$("#waitingforserverresponse").css('visibility','hidden');
|
||||
if(data.error > 0) alert(data.message);
|
||||
if($.isFunction(func)) func(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.exec_html = function(action,data,type,func,args){
|
||||
if(typeof(data) == 'undefined') data = {};
|
||||
if(!$.inArray(type, ['html','append','prepend'])) type = 'html';
|
||||
|
||||
var self = $(this);
|
||||
action = action.split(".");
|
||||
if(action.length == 2){
|
||||
if(show_waiting_message) {
|
||||
$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');
|
||||
}
|
||||
|
||||
$.extend(data,{module:action[0],act:action[1]});
|
||||
$.ajax({
|
||||
type:"POST"
|
||||
,dataType:"html"
|
||||
,url:request_uri
|
||||
,data:$.param(data)
|
||||
,success : function(html){
|
||||
$("#waitingforserverresponse").css('visibility','hidden');
|
||||
self[type](html);
|
||||
if($.isFunction(func)) func(args);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
/**
|
||||
* @file common/js/xml_handler.js
|
||||
* @brief XE에서 ajax기능을 이용함에 있어 module, act를 잘 사용하기 위한 자바스크립트
|
||||
**/
|
||||
|
||||
// xml handler을 이용하는 user function
|
||||
var show_waiting_message = true;
|
||||
|
||||
/* This work is licensed under Creative Commons GNU LGPL License.
|
||||
|
||||
License: http://creativecommons.org/licenses/LGPL/2.1/
|
||||
Version: 0.9
|
||||
Author: Stefan Goessner/2006
|
||||
Web: http://goessner.net/
|
||||
*/
|
||||
function xml2json(xml, tab, ignoreAttrib) {
|
||||
var X = {
|
||||
toObj: function(xml) {
|
||||
var o = {};
|
||||
if (xml.nodeType==1) { // element node ..
|
||||
if (ignoreAttrib && xml.attributes.length) // element with attributes ..
|
||||
for (var i=0; i<xml.attributes.length; i++)
|
||||
o["@"+xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue||"").toString();
|
||||
if (xml.firstChild) { // element has child nodes ..
|
||||
var textChild=0, cdataChild=0, hasElementChild=false;
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling) {
|
||||
if (n.nodeType==1) hasElementChild = true;
|
||||
else if (n.nodeType==3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) textChild++; // non-whitespace text
|
||||
else if (n.nodeType==4) cdataChild++; // cdata section node
|
||||
}
|
||||
if (hasElementChild) {
|
||||
if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node ..
|
||||
X.removeWhite(xml);
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling) {
|
||||
if (n.nodeType == 3) // text node
|
||||
o = X.escape(n.nodeValue);
|
||||
else if (n.nodeType == 4) // cdata node
|
||||
// o["#cdata"] = X.escape(n.nodeValue);
|
||||
o = X.escape(n.nodeValue);
|
||||
else if (o[n.nodeName]) { // multiple occurence of element ..
|
||||
if (o[n.nodeName] instanceof Array)
|
||||
o[n.nodeName][o[n.nodeName].length] = X.toObj(n);
|
||||
else
|
||||
o[n.nodeName] = [o[n.nodeName], X.toObj(n)];
|
||||
}
|
||||
else // first occurence of element..
|
||||
o[n.nodeName] = X.toObj(n);
|
||||
}
|
||||
}
|
||||
else { // mixed content
|
||||
if (!xml.attributes.length)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
o["#text"] = X.escape(X.innerXml(xml));
|
||||
}
|
||||
}
|
||||
else if (textChild) { // pure text
|
||||
if (!xml.attributes.length)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
o["#text"] = X.escape(X.innerXml(xml));
|
||||
}
|
||||
else if (cdataChild) { // cdata
|
||||
if (cdataChild > 1)
|
||||
o = X.escape(X.innerXml(xml));
|
||||
else
|
||||
for (var n=xml.firstChild; n; n=n.nextSibling){
|
||||
//o["#cdata"] = X.escape(n.nodeValue);
|
||||
o = X.escape(n.nodeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!xml.attributes.length && !xml.firstChild) o = null;
|
||||
}
|
||||
else if (xml.nodeType==9) { // document.node
|
||||
o = X.toObj(xml.documentElement);
|
||||
}
|
||||
else
|
||||
alert("unhandled node type: " + xml.nodeType);
|
||||
return o;
|
||||
},
|
||||
toJson: function(o, name, ind) {
|
||||
var json = name ? ("\""+name+"\"") : "";
|
||||
if (o instanceof Array) {
|
||||
for (var i=0,n=o.length; i<n; i++)
|
||||
o[i] = X.toJson(o[i], "", ind+"\t");
|
||||
json += (name?":[":"[") + (o.length > 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]";
|
||||
}
|
||||
else if (o == null)
|
||||
json += (name&&":") + "null";
|
||||
else if (typeof(o) == "object") {
|
||||
var arr = [];
|
||||
for (var m in o)
|
||||
arr[arr.length] = X.toJson(o[m], m, ind+"\t");
|
||||
json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}";
|
||||
}
|
||||
else if (typeof(o) == "string")
|
||||
json += (name&&":") + "\"" + o.toString() + "\"";
|
||||
else
|
||||
json += (name&&":") + o.toString();
|
||||
return json;
|
||||
},
|
||||
innerXml: function(node) {
|
||||
var s = ""
|
||||
if ("innerHTML" in node)
|
||||
s = node.innerHTML;
|
||||
else {
|
||||
var asXml = function(n) {
|
||||
var s = "";
|
||||
if (n.nodeType == 1) {
|
||||
s += "<" + n.nodeName;
|
||||
for (var i=0; i<n.attributes.length;i++)
|
||||
s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue||"").toString() + "\"";
|
||||
if (n.firstChild) {
|
||||
s += ">";
|
||||
for (var c=n.firstChild; c; c=c.nextSibling)
|
||||
s += asXml(c);
|
||||
s += "</"+n.nodeName+">";
|
||||
}
|
||||
else
|
||||
s += "/>";
|
||||
}
|
||||
else if (n.nodeType == 3)
|
||||
s += n.nodeValue;
|
||||
else if (n.nodeType == 4)
|
||||
s += "<![CDATA[" + n.nodeValue + "]]>";
|
||||
return s;
|
||||
};
|
||||
for (var c=node.firstChild; c; c=c.nextSibling)
|
||||
s += asXml(c);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
escape: function(txt) {
|
||||
return txt.replace(/[\\]/g, "\\\\")
|
||||
.replace(/[\"]/g, '\\"')
|
||||
.replace(/[\n]/g, '\\n')
|
||||
.replace(/[\r]/g, '\\r');
|
||||
},
|
||||
removeWhite: function(e) {
|
||||
e.normalize();
|
||||
for (var n = e.firstChild; n; ) {
|
||||
if (n.nodeType == 3) { // text node
|
||||
if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node
|
||||
var nxt = n.nextSibling;
|
||||
e.removeChild(n);
|
||||
n = nxt;
|
||||
}
|
||||
else
|
||||
n = n.nextSibling;
|
||||
}
|
||||
else if (n.nodeType == 1) { // element node
|
||||
X.removeWhite(n);
|
||||
n = n.nextSibling;
|
||||
}
|
||||
else // any other node
|
||||
n = n.nextSibling;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
};
|
||||
if (xml.nodeType == 9) // document node
|
||||
xml = xml.documentElement;
|
||||
|
||||
var json_obj = X.toObj(X.removeWhite(xml)), json_str;
|
||||
|
||||
if (typeof(JSON)=='object' && jQuery.isFunction(JSON.stringify) && false) {
|
||||
var obj = {}; obj[xml.nodeName] = json_obj;
|
||||
json_str = JSON.stringify(obj);
|
||||
return json_str;
|
||||
} else {
|
||||
json_str = X.toJson(json_obj, xml.nodeName, "");
|
||||
return "{" + (tab ? json_str.replace(/\t/g, tab) : json_str.replace(/\t|\n/g, "")) + "}";
|
||||
}
|
||||
}
|
||||
|
||||
(function($){
|
||||
/**
|
||||
* @brief exec_xml
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
**/
|
||||
$.exec_xml = window.exec_xml = function(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj) {
|
||||
var xml_path = request_uri+"index.php"
|
||||
if(!params) params = {};
|
||||
|
||||
// {{{ set parameters
|
||||
if($.isArray(params)) params = arr2obj(params);
|
||||
params['module'] = module;
|
||||
params['act'] = act;
|
||||
|
||||
if(typeof(xeVid)!='undefined') params['vid'] = xeVid;
|
||||
if(typeof(response_tags)=="undefined" || response_tags.length<1) response_tags = ['error','message'];
|
||||
else {
|
||||
response_tags.push('error', 'message');
|
||||
}
|
||||
// }}} set parameters
|
||||
|
||||
// use ssl?
|
||||
if ($.isArray(ssl_actions) && params['act'] && $.inArray(params['act'], ssl_actions) >= 0)
|
||||
{
|
||||
var url = default_url || request_uri;
|
||||
var port = window.https_port || 443;
|
||||
var _ul = $('<a>').attr('href', url)[0];
|
||||
var target = 'https://' + _ul.hostname.replace(/:\d+$/, '');
|
||||
|
||||
if(port != 443) target += ':'+port;
|
||||
if(_ul.pathname[0] != '/') target += '/';
|
||||
|
||||
target += _ul.pathname;
|
||||
xml_path = target.replace(/\/$/, '')+'/index.php';
|
||||
}
|
||||
|
||||
var _u1 = $('<a>').attr('href', location.href)[0];
|
||||
var _u2 = $('<a>').attr('href', xml_path)[0];
|
||||
|
||||
// 현 url과 ajax call 대상 url의 schema 또는 port가 다르면 직접 form 전송
|
||||
if(_u1.protocol != _u2.protocol || _u1.port != _u2.port) return send_by_form(xml_path, params);
|
||||
|
||||
var xml = [], i = 0;
|
||||
xml[i++] = '<?xml version="1.0" encoding="utf-8" ?>';
|
||||
xml[i++] = '<methodCall>';
|
||||
xml[i++] = '<params>';
|
||||
|
||||
$.each(params, function(key, val) {
|
||||
xml[i++] = '<'+key+'><![CDATA['+val+']]></'+key+'>';
|
||||
});
|
||||
|
||||
xml[i++] = '</params>';
|
||||
xml[i++] = '</methodCall>';
|
||||
|
||||
var _xhr = null;
|
||||
if (_xhr && _xhr.readyState != 0) _xhr.abort();
|
||||
|
||||
// 전송 성공시
|
||||
function onsuccess(data, textStatus, xhr) {
|
||||
var resp_xml = $(data).find('response')[0], resp_obj, txt='', ret=[], tags={}, json_str='';
|
||||
|
||||
waiting_obj.css('visibility', 'hidden');
|
||||
|
||||
if(!resp_xml) {
|
||||
alert(_xhr.responseText);
|
||||
return null;
|
||||
}
|
||||
|
||||
json_str = xml2json(resp_xml, false, false);
|
||||
resp_obj = (typeof(JSON)=='object' && $.isFunction(JSON.parse))?JSON.parse(json_str):eval('('+json_str+')');
|
||||
resp_obj = resp_obj.response;
|
||||
|
||||
if (typeof(resp_obj)=='undefined') {
|
||||
ret['error'] = -1;
|
||||
ret['message'] = 'Unexpected error occured.';
|
||||
try {
|
||||
if(typeof(txt=resp_xml.childNodes[0].firstChild.data)!='undefined') ret['message'] += '\r\n'+txt;
|
||||
} catch(e){};
|
||||
return ret;
|
||||
}
|
||||
|
||||
$.each(response_tags, function(key, val){ tags[val] = true; });
|
||||
tags["redirect_url"] = true;
|
||||
tags["act"] = true;
|
||||
$.each(resp_obj, function(key, val){ if(tags[key]) ret[key] = val; });
|
||||
|
||||
if(ret['error'] != 0) {
|
||||
if ($.isFunction($.exec_xml.onerror)) {
|
||||
return $.exec_xml.onerror(module, act, ret, callback_func, response_tags, callback_func_arg, fo_obj);
|
||||
}
|
||||
|
||||
alert(ret['message'] || 'error!');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(ret['redirect_url']) {
|
||||
location.href = ret['redirect_url'].replace(/&/g, '&');
|
||||
return null;
|
||||
}
|
||||
|
||||
if($.isFunction(callback_func)) callback_func(ret, response_tags, callback_func_arg, fo_obj);
|
||||
}
|
||||
|
||||
// 모든 xml데이터는 POST방식으로 전송. try-catch문으로 오류 발생시 대처
|
||||
try {
|
||||
$.ajax({
|
||||
url : xml_path,
|
||||
type : 'POST',
|
||||
dataType : 'xml',
|
||||
data : xml.join('\n'),
|
||||
contentType : 'text/plain',
|
||||
beforeSend : function(xhr){ _xhr = xhr; },
|
||||
success : onsuccess,
|
||||
error : function(xhr, textStatus) {
|
||||
waiting_obj.css('visibility', 'hidden');
|
||||
|
||||
var msg = '';
|
||||
if (textStatus == 'parsererror') {
|
||||
msg = 'The result is not valid XML :\n-------------------------------------\n';
|
||||
if(xhr.responseText == "") return;
|
||||
msg += xhr.responseText.replace(/<[^>]+>/g, '');
|
||||
} else {
|
||||
msg = textStatus;
|
||||
}
|
||||
|
||||
alert(msg);
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
alert(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// ajax 통신중 대기 메세지 출력 (show_waiting_message값을 false로 세팅시 보이지 않음)
|
||||
var waiting_obj = $('#waitingforserverresponse');
|
||||
if(show_waiting_message && waiting_obj.length) {
|
||||
var d = $(document);
|
||||
waiting_obj.html(waiting_message).css({
|
||||
'top' : (d.scrollTop()+20)+'px',
|
||||
'left' : (d.scrollLeft()+20)+'px',
|
||||
'visibility' : 'visible'
|
||||
});
|
||||
}
|
||||
}
|
||||
function send_by_form(url, params) {
|
||||
var frame_id = 'xeTmpIframe';
|
||||
var form_id = 'xeVirtualForm';
|
||||
|
||||
if (!$('#'+frame_id).length) {
|
||||
$('<iframe name="%id%" id="%id%" style="position:absolute;left:-1px;top:1px;width:1px;height:1px"></iframe>'.replace(/%id%/g, frame_id)).appendTo(document.body);
|
||||
}
|
||||
|
||||
$('#'+form_id).remove();
|
||||
var form = $('<form id="%id%"></form>'.replace(/%id%/g, form_id)).attr({
|
||||
'id' : form_id,
|
||||
'method' : 'post',
|
||||
'action' : url,
|
||||
'target' : frame_id
|
||||
});
|
||||
|
||||
params['xeVirtualRequestMethod'] = 'xml';
|
||||
params['xeRequestURI'] = location.href.replace(/#(.*)$/i,'');
|
||||
params['xeVirtualRequestUrl'] = request_uri;
|
||||
|
||||
$.each(params, function(key, value){
|
||||
$('<input type="hidden">').attr('name', key).attr('value', value).appendTo(form);
|
||||
});
|
||||
|
||||
form.appendTo(document.body).submit();
|
||||
}
|
||||
function arr2obj(arr) {
|
||||
var ret = {};
|
||||
for(var key in arr) {
|
||||
if(arr.hasOwnProperty(key)) ret[key] = arr[key];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief exec_json (exec_xml와 같은 용도)
|
||||
**/
|
||||
$.exec_json = function(action,data,func){
|
||||
if(typeof(data) == 'undefined') data = {};
|
||||
action = action.split(".");
|
||||
if(action.length == 2){
|
||||
|
||||
if(show_waiting_message) {
|
||||
$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');
|
||||
}
|
||||
|
||||
$.extend(data,{module:action[0],act:action[1]});
|
||||
if(typeof(xeVid)!='undefined') $.extend(data,{vid:xeVid});
|
||||
$.ajax({
|
||||
type:"POST"
|
||||
,dataType:"json"
|
||||
,url:request_uri
|
||||
,contentType:"application/json"
|
||||
,data:$.param(data)
|
||||
,success : function(data){
|
||||
$("#waitingforserverresponse").css('visibility','hidden');
|
||||
if(data.error > 0) alert(data.message);
|
||||
if($.isFunction(func)) func(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.exec_html = function(action,data,type,func,args){
|
||||
if(typeof(data) == 'undefined') data = {};
|
||||
if(!$.inArray(type, ['html','append','prepend'])) type = 'html';
|
||||
|
||||
var self = $(this);
|
||||
action = action.split(".");
|
||||
if(action.length == 2){
|
||||
if(show_waiting_message) {
|
||||
$("#waitingforserverresponse").html(waiting_message).css('top',$(document).scrollTop()+20).css('left',$(document).scrollLeft()+20).css('visibility','visible');
|
||||
}
|
||||
|
||||
$.extend(data,{module:action[0],act:action[1]});
|
||||
$.ajax({
|
||||
type:"POST"
|
||||
,dataType:"html"
|
||||
,url:request_uri
|
||||
,data:$.param(data)
|
||||
,success : function(html){
|
||||
$("#waitingforserverresponse").css('visibility','hidden');
|
||||
self[type](html);
|
||||
if($.isFunction(func)) func(args);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -1,338 +1,338 @@
|
|||
/**
|
||||
* @file common/js/xml_js_filter.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief xml filter (validator) plugin
|
||||
*
|
||||
* A rule is a method validate one field.
|
||||
* A filter is made up of one or more rules.
|
||||
**/
|
||||
(function($){
|
||||
|
||||
var messages = [];
|
||||
var rules = [];
|
||||
var filters = [];
|
||||
var callbacks = [];
|
||||
var extras = {};
|
||||
|
||||
var Validator = xe.createApp('Validator', {
|
||||
init : function() {
|
||||
// {{{ add filters
|
||||
// email
|
||||
var regEmail = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
|
||||
this.cast('ADD_RULE', ['email', regEmail]);
|
||||
this.cast('ADD_RULE', ['email_address', regEmail]);
|
||||
|
||||
// userid
|
||||
var regUserid = /^[a-z]+[\w-]*[a-z0-9_]+$/i;
|
||||
this.cast('ADD_RULE', ['userid', regUserid]);
|
||||
this.cast('ADD_RULE', ['user_id', regUserid]);
|
||||
|
||||
// url
|
||||
var regUrl = /^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;
|
||||
this.cast('ADD_RULE', ['url', regUrl]);
|
||||
this.cast('ADD_RULE', ['homepage', regUrl]);
|
||||
|
||||
// korean
|
||||
var regKor = /^[가-힣]*$/;
|
||||
this.cast('ADD_RULE', ['korean', regKor]);
|
||||
|
||||
// korean_number
|
||||
var regKorNum = /^[가-힣0-9]*$/;
|
||||
this.cast('ADD_RULE', ['korean_number', regKorNum]);
|
||||
|
||||
// alpha
|
||||
var regAlpha = /^[a-z]*$/i;
|
||||
this.cast('ADD_RULE', ['alpha', regAlpha]);
|
||||
|
||||
// alpha_number
|
||||
var regAlphaNum = /^[a-z][a-z0-9_]*$/i;
|
||||
this.cast('ADD_RULE', ['alpha_number', regAlphaNum]);
|
||||
|
||||
// number
|
||||
var regNum = /^[0-9]*$/;
|
||||
this.cast('ADD_RULE', ['number', regNum]);
|
||||
// }}} add filters
|
||||
},
|
||||
// run validator
|
||||
run : function(oForm) {
|
||||
var filter = '';
|
||||
|
||||
if (oForm._filter) filter = oForm._filter.value;
|
||||
|
||||
var params = [oForm, filter];
|
||||
var result = this.cast('VALIDATE', params);
|
||||
if (typeof result == 'undefined') result = false;
|
||||
|
||||
return result;
|
||||
},
|
||||
API_ONREADY : function() {
|
||||
var self = this;
|
||||
|
||||
// hook form submit event
|
||||
$('form')
|
||||
.each(function(){
|
||||
if (this.onsubmit) {
|
||||
this['xe:onsubmit'] = this.onsubmit;
|
||||
this.onsubmit = null;
|
||||
}
|
||||
})
|
||||
.submit(function(){
|
||||
var legacyFn = this['xe:onsubmit'];
|
||||
var hasLegacyFn = $.isFunction(legacyFn);
|
||||
var bResult = hasLegacyFn?legacyFn.apply(this):self.run(this);
|
||||
|
||||
return bResult;
|
||||
});
|
||||
},
|
||||
API_VALIDATE : function(sender, params) {
|
||||
var self = this, result = true, form = params[0], filter=null, callback=null;
|
||||
|
||||
if (form.elements['_filter']) filter = form.elements['_filter'].value;
|
||||
if (!filter) return true;
|
||||
if ($.isFunction(callbacks[filter])) callback = callbacks[filter];
|
||||
filter = $.extend({}, filters[filter.toLowerCase()] || {}, extras);
|
||||
|
||||
$.each(filter, function(name) {
|
||||
var _el = form.elements[name];
|
||||
|
||||
if (!_el) return true;
|
||||
|
||||
var el = $(_el), val = $.trim(get_value(el));
|
||||
var minlen = parseInt(this.minlength) || 0;
|
||||
var maxlen = parseInt(this.maxlength) || 0;
|
||||
var rule = (this.rule || '').split(',');
|
||||
|
||||
if (this.required && !val) return (result = (!!self.cast('ALERT', [form, name, 'isnull']) && false));
|
||||
if (!this.required && !val) return (result = true);
|
||||
if ((minlen && val.length < minlen) || (maxlen && val.length > maxlen)) return (result = (!!self.cast('ALERT', [form, name, 'outofrange', minlen, maxlen]) && false));
|
||||
|
||||
if (this.equalto) {
|
||||
var eq_val = get_value($(form.elements[this.equalto]));
|
||||
if (eq_val != val) return (result = (!!self.cast('ALERT', [form, name, 'equalto']) && false));
|
||||
}
|
||||
|
||||
if (rule) {
|
||||
$.each(rule, function(i,r) {
|
||||
if (!r) return true;
|
||||
|
||||
var ret = self.cast('APPLY_RULE', [r, val]);
|
||||
if (!ret) {
|
||||
self.cast('ALERT', [form, name, 'invalid_'+this]);
|
||||
return (result = false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!result) return false;
|
||||
});
|
||||
|
||||
if (!result) return false;
|
||||
if ($.isFunction(callback)) return callback(form);
|
||||
|
||||
return true;
|
||||
},
|
||||
API_ADD_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
rules[name] = params[1];
|
||||
},
|
||||
API_DEL_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete rules[name];
|
||||
},
|
||||
API_GET_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
|
||||
if (rules[name]) {
|
||||
return rules[name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
API_ADD_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
var filter = params[1];
|
||||
|
||||
filters[name] = filter;
|
||||
},
|
||||
API_DEL_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete filters[name];
|
||||
},
|
||||
API_GET_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
|
||||
if (filters[name]) {
|
||||
return filters[name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
API_ADD_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
var prop = params[1];
|
||||
|
||||
extras[name] = prop;
|
||||
},
|
||||
API_GET_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
return extras[name];
|
||||
},
|
||||
API_DEL_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete extras[name];
|
||||
},
|
||||
API_APPLY_RULE : function(sender, params) {
|
||||
var name = params[0];
|
||||
var value = params[1];
|
||||
|
||||
if (typeof(rules[name]) == 'undefined') return true; // no filter
|
||||
if ($.isFunction(rules[name])) return rules[name](value);
|
||||
if (rules[name] instanceof RegExp) return rules[name].test(value);
|
||||
|
||||
return true;
|
||||
},
|
||||
API_ALERT : function(sender, params) {
|
||||
var form = params[0];
|
||||
var field_name = params[1];
|
||||
var msg_code = params[2];
|
||||
var minlen = params[3];
|
||||
var maxlen = params[4];
|
||||
|
||||
var field_msg = this.cast('GET_MESSAGE', [field_name]);
|
||||
var msg = this.cast('GET_MESSAGE', [msg_code]);
|
||||
|
||||
if (msg != msg_code) msg = (msg.indexOf('%s')<0)?(field_msg+msg):(msg.replace('%s',field_msg));
|
||||
if (minlen||maxlen) msg += '('+(minlen||'')+'~'+(maxlen||'')+')';
|
||||
|
||||
this.cast('SHOW_ALERT', [msg]);
|
||||
|
||||
// set focus
|
||||
$(form.elements[field_name]).focus();
|
||||
},
|
||||
API_SHOW_ALERT : function(sender, params) {
|
||||
alert(params[0]);
|
||||
},
|
||||
API_ADD_MESSAGE : function(sender, params) {
|
||||
var msg_code = params[0];
|
||||
var msg_str = params[1];
|
||||
|
||||
messages[msg_code] = msg_str;
|
||||
},
|
||||
API_GET_MESSAGE : function(sender, params) {
|
||||
var msg_code = params[0];
|
||||
|
||||
return messages[msg_code] || msg_code;
|
||||
},
|
||||
API_ADD_CALLBACK : function(sender, params) {
|
||||
var name = params[0];
|
||||
var func = params[1];
|
||||
|
||||
callbacks[name] = func;
|
||||
},
|
||||
API_REMOVE_CALLBACK : function(sender, params) {
|
||||
var name = params[0];
|
||||
|
||||
delete callbacks[name];
|
||||
}
|
||||
});
|
||||
|
||||
var oValidator = new Validator;
|
||||
|
||||
// register validator
|
||||
xe.registerApp(oValidator);
|
||||
|
||||
// 호환성을 위해 추가한 플러그인 - 에디터에서 컨텐트를 가져와서 설정한다.
|
||||
var EditorStub = xe.createPlugin('editor_stub', {
|
||||
API_BEFORE_VALIDATE : function(sender, params) {
|
||||
var form = params[0];
|
||||
var seq = form.getAttribute('editor_sequence');
|
||||
|
||||
// bug fix for IE6,7
|
||||
if (seq && typeof seq == 'object') seq = seq.value;
|
||||
|
||||
if (seq) {
|
||||
try {
|
||||
editorRelKeys[seq].content.value = editorRelKeys[seq].func(seq) || '';
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
});
|
||||
oValidator.registerPlugin(new EditorStub);
|
||||
|
||||
// functions
|
||||
function get_value(elem) {
|
||||
var vals = [];
|
||||
if (elem.is(':radio')){
|
||||
return elem.filter(':checked').val();
|
||||
} else if (elem.is(':checkbox')) {
|
||||
elem.filter(':checked').each(function(){
|
||||
vals.push(this.value);
|
||||
});
|
||||
return vals.join('|@|');
|
||||
} else {
|
||||
return elem.val();
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* @function filterAlertMessage
|
||||
* @brief ajax로 서버에 요청후 결과를 처리할 callback_function을 지정하지 않았을 시 호출되는 기본 함수
|
||||
**/
|
||||
function filterAlertMessage(ret_obj) {
|
||||
var error = ret_obj["error"];
|
||||
var message = ret_obj["message"];
|
||||
var act = ret_obj["act"];
|
||||
var redirect_url = ret_obj["redirect_url"];
|
||||
var url = location.href;
|
||||
|
||||
if(typeof(message)!="undefined"&&message&&message!="success") alert(message);
|
||||
|
||||
if(typeof(act)!="undefined" && act) url = current_url.setQuery("act", act);
|
||||
else if(typeof(redirect_url)!="undefined" && redirect_url) url = redirect_url;
|
||||
|
||||
if(url == location.href) url = url.replace(/#(.*)$/,'');
|
||||
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to process filters
|
||||
* @deprecated
|
||||
*/
|
||||
function procFilter(form, filter_func) {
|
||||
filter_func(form);
|
||||
return false;
|
||||
}
|
||||
|
||||
function legacy_filter(filter_name, form, module, act, callback, responses, confirm_msg, rename_params) {
|
||||
var v = xe.getApp('Validator')[0], $ = jQuery, args = [];
|
||||
|
||||
if (!v) return false;
|
||||
|
||||
if (!form.elements['_filter']) $(form).prepend('<input type="hidden" name="_filter" />');
|
||||
form.elements['_filter'].value = filter_name;
|
||||
|
||||
args[0] = filter_name;
|
||||
args[1] = function(f) {
|
||||
var params = {}, res = [], elms = f.elements, data = $(f).serializeArray();
|
||||
$.each(data, function(i, field) {
|
||||
var v = $.trim(field.value), n = field.name;
|
||||
if(!v || !n) return true;
|
||||
if(rename_params[n]) n = rename_params[n];
|
||||
|
||||
if(/\[\]$/.test(n)) n = n.replace(/\[\]$/, '');
|
||||
if(params[n]) params[n] += '|@|'+v;
|
||||
else params[n] = field.value;
|
||||
});
|
||||
|
||||
if (confirm_msg && !confirm(confirm_msg)) return false;
|
||||
exec_xml(module, act, params, callback, responses, params, form);
|
||||
};
|
||||
|
||||
v.cast('ADD_CALLBACK', args);
|
||||
v.cast('VALIDATE', [form, filter_name]);
|
||||
|
||||
return false;
|
||||
/**
|
||||
* @file common/js/xml_js_filter.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief xml filter (validator) plugin
|
||||
*
|
||||
* A rule is a method validate one field.
|
||||
* A filter is made up of one or more rules.
|
||||
**/
|
||||
(function($){
|
||||
|
||||
var messages = [];
|
||||
var rules = [];
|
||||
var filters = [];
|
||||
var callbacks = [];
|
||||
var extras = {};
|
||||
|
||||
var Validator = xe.createApp('Validator', {
|
||||
init : function() {
|
||||
// {{{ add filters
|
||||
// email
|
||||
var regEmail = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
|
||||
this.cast('ADD_RULE', ['email', regEmail]);
|
||||
this.cast('ADD_RULE', ['email_address', regEmail]);
|
||||
|
||||
// userid
|
||||
var regUserid = /^[a-z]+[\w-]*[a-z0-9_]+$/i;
|
||||
this.cast('ADD_RULE', ['userid', regUserid]);
|
||||
this.cast('ADD_RULE', ['user_id', regUserid]);
|
||||
|
||||
// url
|
||||
var regUrl = /^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;
|
||||
this.cast('ADD_RULE', ['url', regUrl]);
|
||||
this.cast('ADD_RULE', ['homepage', regUrl]);
|
||||
|
||||
// korean
|
||||
var regKor = /^[가-힣]*$/;
|
||||
this.cast('ADD_RULE', ['korean', regKor]);
|
||||
|
||||
// korean_number
|
||||
var regKorNum = /^[가-힣0-9]*$/;
|
||||
this.cast('ADD_RULE', ['korean_number', regKorNum]);
|
||||
|
||||
// alpha
|
||||
var regAlpha = /^[a-z]*$/i;
|
||||
this.cast('ADD_RULE', ['alpha', regAlpha]);
|
||||
|
||||
// alpha_number
|
||||
var regAlphaNum = /^[a-z][a-z0-9_]*$/i;
|
||||
this.cast('ADD_RULE', ['alpha_number', regAlphaNum]);
|
||||
|
||||
// number
|
||||
var regNum = /^[0-9]*$/;
|
||||
this.cast('ADD_RULE', ['number', regNum]);
|
||||
// }}} add filters
|
||||
},
|
||||
// run validator
|
||||
run : function(oForm) {
|
||||
var filter = '';
|
||||
|
||||
if (oForm._filter) filter = oForm._filter.value;
|
||||
|
||||
var params = [oForm, filter];
|
||||
var result = this.cast('VALIDATE', params);
|
||||
if (typeof result == 'undefined') result = false;
|
||||
|
||||
return result;
|
||||
},
|
||||
API_ONREADY : function() {
|
||||
var self = this;
|
||||
|
||||
// hook form submit event
|
||||
$('form')
|
||||
.each(function(){
|
||||
if (this.onsubmit) {
|
||||
this['xe:onsubmit'] = this.onsubmit;
|
||||
this.onsubmit = null;
|
||||
}
|
||||
})
|
||||
.submit(function(){
|
||||
var legacyFn = this['xe:onsubmit'];
|
||||
var hasLegacyFn = $.isFunction(legacyFn);
|
||||
var bResult = hasLegacyFn?legacyFn.apply(this):self.run(this);
|
||||
|
||||
return bResult;
|
||||
});
|
||||
},
|
||||
API_VALIDATE : function(sender, params) {
|
||||
var self = this, result = true, form = params[0], filter=null, callback=null;
|
||||
|
||||
if (form.elements['_filter']) filter = form.elements['_filter'].value;
|
||||
if (!filter) return true;
|
||||
if ($.isFunction(callbacks[filter])) callback = callbacks[filter];
|
||||
filter = $.extend({}, filters[filter.toLowerCase()] || {}, extras);
|
||||
|
||||
$.each(filter, function(name) {
|
||||
var _el = form.elements[name];
|
||||
|
||||
if (!_el) return true;
|
||||
|
||||
var el = $(_el), val = $.trim(get_value(el));
|
||||
var minlen = parseInt(this.minlength) || 0;
|
||||
var maxlen = parseInt(this.maxlength) || 0;
|
||||
var rule = (this.rule || '').split(',');
|
||||
|
||||
if (this.required && !val) return (result = (!!self.cast('ALERT', [form, name, 'isnull']) && false));
|
||||
if (!this.required && !val) return (result = true);
|
||||
if ((minlen && val.length < minlen) || (maxlen && val.length > maxlen)) return (result = (!!self.cast('ALERT', [form, name, 'outofrange', minlen, maxlen]) && false));
|
||||
|
||||
if (this.equalto) {
|
||||
var eq_val = get_value($(form.elements[this.equalto]));
|
||||
if (eq_val != val) return (result = (!!self.cast('ALERT', [form, name, 'equalto']) && false));
|
||||
}
|
||||
|
||||
if (rule) {
|
||||
$.each(rule, function(i,r) {
|
||||
if (!r) return true;
|
||||
|
||||
var ret = self.cast('APPLY_RULE', [r, val]);
|
||||
if (!ret) {
|
||||
self.cast('ALERT', [form, name, 'invalid_'+this]);
|
||||
return (result = false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!result) return false;
|
||||
});
|
||||
|
||||
if (!result) return false;
|
||||
if ($.isFunction(callback)) return callback(form);
|
||||
|
||||
return true;
|
||||
},
|
||||
API_ADD_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
rules[name] = params[1];
|
||||
},
|
||||
API_DEL_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete rules[name];
|
||||
},
|
||||
API_GET_RULE : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
|
||||
if (rules[name]) {
|
||||
return rules[name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
API_ADD_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
var filter = params[1];
|
||||
|
||||
filters[name] = filter;
|
||||
},
|
||||
API_DEL_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete filters[name];
|
||||
},
|
||||
API_GET_FILTER : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
|
||||
if (filters[name]) {
|
||||
return filters[name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
API_ADD_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
var prop = params[1];
|
||||
|
||||
extras[name] = prop;
|
||||
},
|
||||
API_GET_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
return extras[name];
|
||||
},
|
||||
API_DEL_EXTRA_FIELD : function(sender, params) {
|
||||
var name = params[0].toLowerCase();
|
||||
delete extras[name];
|
||||
},
|
||||
API_APPLY_RULE : function(sender, params) {
|
||||
var name = params[0];
|
||||
var value = params[1];
|
||||
|
||||
if (typeof(rules[name]) == 'undefined') return true; // no filter
|
||||
if ($.isFunction(rules[name])) return rules[name](value);
|
||||
if (rules[name] instanceof RegExp) return rules[name].test(value);
|
||||
|
||||
return true;
|
||||
},
|
||||
API_ALERT : function(sender, params) {
|
||||
var form = params[0];
|
||||
var field_name = params[1];
|
||||
var msg_code = params[2];
|
||||
var minlen = params[3];
|
||||
var maxlen = params[4];
|
||||
|
||||
var field_msg = this.cast('GET_MESSAGE', [field_name]);
|
||||
var msg = this.cast('GET_MESSAGE', [msg_code]);
|
||||
|
||||
if (msg != msg_code) msg = (msg.indexOf('%s')<0)?(field_msg+msg):(msg.replace('%s',field_msg));
|
||||
if (minlen||maxlen) msg += '('+(minlen||'')+'~'+(maxlen||'')+')';
|
||||
|
||||
this.cast('SHOW_ALERT', [msg]);
|
||||
|
||||
// set focus
|
||||
$(form.elements[field_name]).focus();
|
||||
},
|
||||
API_SHOW_ALERT : function(sender, params) {
|
||||
alert(params[0]);
|
||||
},
|
||||
API_ADD_MESSAGE : function(sender, params) {
|
||||
var msg_code = params[0];
|
||||
var msg_str = params[1];
|
||||
|
||||
messages[msg_code] = msg_str;
|
||||
},
|
||||
API_GET_MESSAGE : function(sender, params) {
|
||||
var msg_code = params[0];
|
||||
|
||||
return messages[msg_code] || msg_code;
|
||||
},
|
||||
API_ADD_CALLBACK : function(sender, params) {
|
||||
var name = params[0];
|
||||
var func = params[1];
|
||||
|
||||
callbacks[name] = func;
|
||||
},
|
||||
API_REMOVE_CALLBACK : function(sender, params) {
|
||||
var name = params[0];
|
||||
|
||||
delete callbacks[name];
|
||||
}
|
||||
});
|
||||
|
||||
var oValidator = new Validator;
|
||||
|
||||
// register validator
|
||||
xe.registerApp(oValidator);
|
||||
|
||||
// 호환성을 위해 추가한 플러그인 - 에디터에서 컨텐트를 가져와서 설정한다.
|
||||
var EditorStub = xe.createPlugin('editor_stub', {
|
||||
API_BEFORE_VALIDATE : function(sender, params) {
|
||||
var form = params[0];
|
||||
var seq = form.getAttribute('editor_sequence');
|
||||
|
||||
// bug fix for IE6,7
|
||||
if (seq && typeof seq == 'object') seq = seq.value;
|
||||
|
||||
if (seq) {
|
||||
try {
|
||||
editorRelKeys[seq].content.value = editorRelKeys[seq].func(seq) || '';
|
||||
} catch(e) { }
|
||||
}
|
||||
}
|
||||
});
|
||||
oValidator.registerPlugin(new EditorStub);
|
||||
|
||||
// functions
|
||||
function get_value(elem) {
|
||||
var vals = [];
|
||||
if (elem.is(':radio')){
|
||||
return elem.filter(':checked').val();
|
||||
} else if (elem.is(':checkbox')) {
|
||||
elem.filter(':checked').each(function(){
|
||||
vals.push(this.value);
|
||||
});
|
||||
return vals.join('|@|');
|
||||
} else {
|
||||
return elem.val();
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/**
|
||||
* @function filterAlertMessage
|
||||
* @brief ajax로 서버에 요청후 결과를 처리할 callback_function을 지정하지 않았을 시 호출되는 기본 함수
|
||||
**/
|
||||
function filterAlertMessage(ret_obj) {
|
||||
var error = ret_obj["error"];
|
||||
var message = ret_obj["message"];
|
||||
var act = ret_obj["act"];
|
||||
var redirect_url = ret_obj["redirect_url"];
|
||||
var url = location.href;
|
||||
|
||||
if(typeof(message)!="undefined"&&message&&message!="success") alert(message);
|
||||
|
||||
if(typeof(act)!="undefined" && act) url = current_url.setQuery("act", act);
|
||||
else if(typeof(redirect_url)!="undefined" && redirect_url) url = redirect_url;
|
||||
|
||||
if(url == location.href) url = url.replace(/#(.*)$/,'');
|
||||
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to process filters
|
||||
* @deprecated
|
||||
*/
|
||||
function procFilter(form, filter_func) {
|
||||
filter_func(form);
|
||||
return false;
|
||||
}
|
||||
|
||||
function legacy_filter(filter_name, form, module, act, callback, responses, confirm_msg, rename_params) {
|
||||
var v = xe.getApp('Validator')[0], $ = jQuery, args = [];
|
||||
|
||||
if (!v) return false;
|
||||
|
||||
if (!form.elements['_filter']) $(form).prepend('<input type="hidden" name="_filter" />');
|
||||
form.elements['_filter'].value = filter_name;
|
||||
|
||||
args[0] = filter_name;
|
||||
args[1] = function(f) {
|
||||
var params = {}, res = [], elms = f.elements, data = $(f).serializeArray();
|
||||
$.each(data, function(i, field) {
|
||||
var v = $.trim(field.value), n = field.name;
|
||||
if(!v || !n) return true;
|
||||
if(rename_params[n]) n = rename_params[n];
|
||||
|
||||
if(/\[\]$/.test(n)) n = n.replace(/\[\]$/, '');
|
||||
if(params[n]) params[n] += '|@|'+v;
|
||||
else params[n] = field.value;
|
||||
});
|
||||
|
||||
if (confirm_msg && !confirm(confirm_msg)) return false;
|
||||
exec_xml(module, act, params, callback, responses, params, form);
|
||||
};
|
||||
|
||||
v.cast('ADD_CALLBACK', args);
|
||||
v.cast('VALIDATE', [form, filter_name]);
|
||||
|
||||
return false;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,210 +1,210 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<title>JSSpec results</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/JSSpec.css" />
|
||||
<script type="text/javascript" src="diff_match_patch.js"></script>
|
||||
<script type="text/javascript" src="JSSpec.js"></script>
|
||||
<script type="text/javascript">// <![CDATA[
|
||||
describe('Foo (base)', {
|
||||
'before': function() {
|
||||
target = {sayFoo: function() {return "foo";}};
|
||||
},
|
||||
'should say "foo"': function() {
|
||||
value_of(target.sayFoo()).should_be("foo");
|
||||
}
|
||||
})
|
||||
|
||||
describe('Boo (derived)', {
|
||||
'before': function() {
|
||||
target = {
|
||||
sayFoo: function() {return "foo";},
|
||||
sayBar: function() {return "bar";}
|
||||
};
|
||||
},
|
||||
'should also say "bar"': function() {
|
||||
value_of(target.sayBar()).should_be("bar");
|
||||
}
|
||||
}, 'Foo (base)')
|
||||
|
||||
describe('Plus operator (just for example)', {
|
||||
'should concatenate two strings': function() {
|
||||
value_of("Hello " + "World").should_be("Hello World");
|
||||
},
|
||||
'should add two numbers': function() {
|
||||
value_of(1 + 2).should_be(3);
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should match"s', {
|
||||
'Should match': function() {
|
||||
value_of("Hello").should_match(/ell/);
|
||||
},
|
||||
'Should match 1': function() {
|
||||
value_of("Hello").should_match(/x/);
|
||||
},
|
||||
'Should match 2': function() {
|
||||
value_of([1,2,3]).should_match(/x/);
|
||||
},
|
||||
'Should not match 1': function() {
|
||||
value_of("Hello").should_not_match(/ell/);
|
||||
},
|
||||
'Should not match 2': function() {
|
||||
value_of([1,2,3]).should_not_match(/x/);
|
||||
}
|
||||
})
|
||||
describe('"Should include"s', {
|
||||
'Should include': function() {
|
||||
value_of([1,2,3]).should_include(4);
|
||||
},
|
||||
'Should not include': function() {
|
||||
value_of([1,2,3]).should_not_include(2);
|
||||
},
|
||||
'Should include / Non-array object': function() {
|
||||
value_of(new Date()).should_include(4);
|
||||
},
|
||||
'Should not include / Non-array object': function() {
|
||||
value_of(new Date()).should_not_include('getMonth');
|
||||
},
|
||||
'Should include 2': function() {
|
||||
value_of({a:1, b:2}).should_not_include('a');
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should have"s', {
|
||||
'String length': function() {
|
||||
value_of("Hello").should_have(4, "characters");
|
||||
},
|
||||
'Array length': function() {
|
||||
value_of([1,2,3]).should_have(4, "items");
|
||||
},
|
||||
'Object\'s item length': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
|
||||
},
|
||||
'No match': function() {
|
||||
value_of("This is a string").should_have(5, "players");
|
||||
},
|
||||
'Exactly': function() {
|
||||
value_of([1,2,3]).should_have_exactly(2, "items");
|
||||
},
|
||||
'At least': function() {
|
||||
value_of([1,2,3]).should_have_at_least(4, "items");
|
||||
},
|
||||
'At most': function() {
|
||||
value_of([1,2,3]).should_have_at_most(2, "items");
|
||||
},
|
||||
'Member': function() {
|
||||
value_of({x: 0}).should_have_member('x'); // true
|
||||
value_of({x: 0}).should_have_member('y'); // false
|
||||
}
|
||||
})
|
||||
describe('"Should be empty"s', {
|
||||
'String': function() {
|
||||
value_of("Hello").should_be_empty();
|
||||
},
|
||||
'Array': function() {
|
||||
value_of([1,2,3]).should_be_empty();
|
||||
},
|
||||
'Object\'s item': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(0, "accounts");
|
||||
}
|
||||
})
|
||||
|
||||
describe('Failure messages', {
|
||||
'Should be (String)': function() {
|
||||
value_of("Hello World").should_be("Good-bye world");
|
||||
},
|
||||
'Should have (Object\s item)': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
|
||||
},
|
||||
'Should have at least': function() {
|
||||
value_of([1,2,3]).should_have_at_least(4, "items");
|
||||
},
|
||||
'Should include': function() {
|
||||
value_of([1,2,3]).should_include(4);
|
||||
},
|
||||
'Should match': function() {
|
||||
value_of("Hello").should_match(/bye/);
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should be"s', {
|
||||
'String mismatch': function() {
|
||||
value_of("Hello world").should_be("Good-bye world");
|
||||
},
|
||||
'Array item mismatch': function() {
|
||||
value_of(['ab','cd','ef']).should_be(['ab','bd','ef']);
|
||||
},
|
||||
'Array length mismatch': function() {
|
||||
value_of(['a',2,'4',5]).should_be([1,2,[4,5,6],6,7]);
|
||||
},
|
||||
'Undefined value': function() {
|
||||
value_of("Test").should_be(undefined);
|
||||
},
|
||||
'Null value': function() {
|
||||
value_of(null).should_be("Test");
|
||||
},
|
||||
'Boolean value 1': function() {
|
||||
value_of(true).should_be(false);
|
||||
},
|
||||
'Boolean value 2': function() {
|
||||
value_of(false).should_be_true();
|
||||
},
|
||||
'Boolean value 3': function() {
|
||||
value_of(true).should_be_false();
|
||||
},
|
||||
'Number mismatch': function() {
|
||||
value_of(1+2).should_be(4);
|
||||
},
|
||||
'Date mismatch': function() {
|
||||
value_of(new Date(1979, 3, 27)).should_be(new Date(1976, 7, 23));
|
||||
},
|
||||
'Object mismatch 1': function() {
|
||||
var actual = {a:1, b:2};
|
||||
var expected = {a:1, b:2, d:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'Object mismatch 2': function() {
|
||||
var actual = {a:1, b:2, c:3, d:4};
|
||||
var expected = {a:1, b:2, c:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'Object mismatch 3': function() {
|
||||
var actual = {a:1, b:4, c:3};
|
||||
var expected = {a:1, b:2, c:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'null should be null': function() {
|
||||
value_of(null).should_be(null);
|
||||
},
|
||||
'null should not be undefined': function() {
|
||||
value_of(null).should_be(undefined);
|
||||
},
|
||||
'null should not be null': function() {
|
||||
value_of(null).should_not_be(null);
|
||||
},
|
||||
'empty array 1': function() {
|
||||
value_of([]).should_be_empty();
|
||||
value_of([1]).should_be_empty();
|
||||
},
|
||||
'empty array 2': function() {
|
||||
value_of([1]).should_not_be_empty();
|
||||
value_of([]).should_not_be_empty();
|
||||
}
|
||||
})
|
||||
|
||||
describe('Equality operator', {
|
||||
'should work for different Date instances which have same value': function() {
|
||||
var date1 = new Date(1979, 03, 27);
|
||||
var date2 = new Date(1979, 03, 27);
|
||||
value_of(date1).should_be(date2);
|
||||
}
|
||||
})
|
||||
// ]]></script>
|
||||
</head>
|
||||
<body><div style="display:none;"><p>A</p><p>B</p></div></body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<title>JSSpec results</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/JSSpec.css" />
|
||||
<script type="text/javascript" src="diff_match_patch.js"></script>
|
||||
<script type="text/javascript" src="JSSpec.js"></script>
|
||||
<script type="text/javascript">// <![CDATA[
|
||||
describe('Foo (base)', {
|
||||
'before': function() {
|
||||
target = {sayFoo: function() {return "foo";}};
|
||||
},
|
||||
'should say "foo"': function() {
|
||||
value_of(target.sayFoo()).should_be("foo");
|
||||
}
|
||||
})
|
||||
|
||||
describe('Boo (derived)', {
|
||||
'before': function() {
|
||||
target = {
|
||||
sayFoo: function() {return "foo";},
|
||||
sayBar: function() {return "bar";}
|
||||
};
|
||||
},
|
||||
'should also say "bar"': function() {
|
||||
value_of(target.sayBar()).should_be("bar");
|
||||
}
|
||||
}, 'Foo (base)')
|
||||
|
||||
describe('Plus operator (just for example)', {
|
||||
'should concatenate two strings': function() {
|
||||
value_of("Hello " + "World").should_be("Hello World");
|
||||
},
|
||||
'should add two numbers': function() {
|
||||
value_of(1 + 2).should_be(3);
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should match"s', {
|
||||
'Should match': function() {
|
||||
value_of("Hello").should_match(/ell/);
|
||||
},
|
||||
'Should match 1': function() {
|
||||
value_of("Hello").should_match(/x/);
|
||||
},
|
||||
'Should match 2': function() {
|
||||
value_of([1,2,3]).should_match(/x/);
|
||||
},
|
||||
'Should not match 1': function() {
|
||||
value_of("Hello").should_not_match(/ell/);
|
||||
},
|
||||
'Should not match 2': function() {
|
||||
value_of([1,2,3]).should_not_match(/x/);
|
||||
}
|
||||
})
|
||||
describe('"Should include"s', {
|
||||
'Should include': function() {
|
||||
value_of([1,2,3]).should_include(4);
|
||||
},
|
||||
'Should not include': function() {
|
||||
value_of([1,2,3]).should_not_include(2);
|
||||
},
|
||||
'Should include / Non-array object': function() {
|
||||
value_of(new Date()).should_include(4);
|
||||
},
|
||||
'Should not include / Non-array object': function() {
|
||||
value_of(new Date()).should_not_include('getMonth');
|
||||
},
|
||||
'Should include 2': function() {
|
||||
value_of({a:1, b:2}).should_not_include('a');
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should have"s', {
|
||||
'String length': function() {
|
||||
value_of("Hello").should_have(4, "characters");
|
||||
},
|
||||
'Array length': function() {
|
||||
value_of([1,2,3]).should_have(4, "items");
|
||||
},
|
||||
'Object\'s item length': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
|
||||
},
|
||||
'No match': function() {
|
||||
value_of("This is a string").should_have(5, "players");
|
||||
},
|
||||
'Exactly': function() {
|
||||
value_of([1,2,3]).should_have_exactly(2, "items");
|
||||
},
|
||||
'At least': function() {
|
||||
value_of([1,2,3]).should_have_at_least(4, "items");
|
||||
},
|
||||
'At most': function() {
|
||||
value_of([1,2,3]).should_have_at_most(2, "items");
|
||||
},
|
||||
'Member': function() {
|
||||
value_of({x: 0}).should_have_member('x'); // true
|
||||
value_of({x: 0}).should_have_member('y'); // false
|
||||
}
|
||||
})
|
||||
describe('"Should be empty"s', {
|
||||
'String': function() {
|
||||
value_of("Hello").should_be_empty();
|
||||
},
|
||||
'Array': function() {
|
||||
value_of([1,2,3]).should_be_empty();
|
||||
},
|
||||
'Object\'s item': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(0, "accounts");
|
||||
}
|
||||
})
|
||||
|
||||
describe('Failure messages', {
|
||||
'Should be (String)': function() {
|
||||
value_of("Hello World").should_be("Good-bye world");
|
||||
},
|
||||
'Should have (Object\s item)': function() {
|
||||
value_of({name:'Alan Kang', email:'jania902@gmail.com', accounts:['A', 'B']}).should_have(3, "accounts");
|
||||
},
|
||||
'Should have at least': function() {
|
||||
value_of([1,2,3]).should_have_at_least(4, "items");
|
||||
},
|
||||
'Should include': function() {
|
||||
value_of([1,2,3]).should_include(4);
|
||||
},
|
||||
'Should match': function() {
|
||||
value_of("Hello").should_match(/bye/);
|
||||
}
|
||||
})
|
||||
|
||||
describe('"Should be"s', {
|
||||
'String mismatch': function() {
|
||||
value_of("Hello world").should_be("Good-bye world");
|
||||
},
|
||||
'Array item mismatch': function() {
|
||||
value_of(['ab','cd','ef']).should_be(['ab','bd','ef']);
|
||||
},
|
||||
'Array length mismatch': function() {
|
||||
value_of(['a',2,'4',5]).should_be([1,2,[4,5,6],6,7]);
|
||||
},
|
||||
'Undefined value': function() {
|
||||
value_of("Test").should_be(undefined);
|
||||
},
|
||||
'Null value': function() {
|
||||
value_of(null).should_be("Test");
|
||||
},
|
||||
'Boolean value 1': function() {
|
||||
value_of(true).should_be(false);
|
||||
},
|
||||
'Boolean value 2': function() {
|
||||
value_of(false).should_be_true();
|
||||
},
|
||||
'Boolean value 3': function() {
|
||||
value_of(true).should_be_false();
|
||||
},
|
||||
'Number mismatch': function() {
|
||||
value_of(1+2).should_be(4);
|
||||
},
|
||||
'Date mismatch': function() {
|
||||
value_of(new Date(1979, 3, 27)).should_be(new Date(1976, 7, 23));
|
||||
},
|
||||
'Object mismatch 1': function() {
|
||||
var actual = {a:1, b:2};
|
||||
var expected = {a:1, b:2, d:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'Object mismatch 2': function() {
|
||||
var actual = {a:1, b:2, c:3, d:4};
|
||||
var expected = {a:1, b:2, c:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'Object mismatch 3': function() {
|
||||
var actual = {a:1, b:4, c:3};
|
||||
var expected = {a:1, b:2, c:3};
|
||||
|
||||
value_of(actual).should_be(expected);
|
||||
},
|
||||
'null should be null': function() {
|
||||
value_of(null).should_be(null);
|
||||
},
|
||||
'null should not be undefined': function() {
|
||||
value_of(null).should_be(undefined);
|
||||
},
|
||||
'null should not be null': function() {
|
||||
value_of(null).should_not_be(null);
|
||||
},
|
||||
'empty array 1': function() {
|
||||
value_of([]).should_be_empty();
|
||||
value_of([1]).should_be_empty();
|
||||
},
|
||||
'empty array 2': function() {
|
||||
value_of([1]).should_not_be_empty();
|
||||
value_of([]).should_not_be_empty();
|
||||
}
|
||||
})
|
||||
|
||||
describe('Equality operator', {
|
||||
'should work for different Date instances which have same value': function() {
|
||||
var date1 = new Date(1979, 03, 27);
|
||||
var date2 = new Date(1979, 03, 27);
|
||||
value_of(date1).should_be(date2);
|
||||
}
|
||||
})
|
||||
// ]]></script>
|
||||
</head>
|
||||
<body><div style="display:none;"><p>A</p><p>B</p></div></body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,224 +1,224 @@
|
|||
@CHARSET "UTF-8";
|
||||
|
||||
/* --------------------
|
||||
* @Layout
|
||||
*/
|
||||
|
||||
html {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body, #jsspec_container {
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#title {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#list {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 0px;
|
||||
bottom: 0px;
|
||||
overflow: auto;
|
||||
width: 250px;
|
||||
_height:expression(document.body.clientHeight-40);
|
||||
}
|
||||
|
||||
#log {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 250px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
overflow: auto;
|
||||
_height:expression(document.body.clientHeight-40);
|
||||
_width:expression(document.body.clientWidth-250);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------
|
||||
* @Decorations and colors
|
||||
*/
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: "Lucida Grande", Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* hiding subtitles */
|
||||
h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* title section */
|
||||
div#title {
|
||||
padding: 0em 0.5em;
|
||||
}
|
||||
|
||||
div#title h1 {
|
||||
font-size: 1.5em;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div#title ul li {
|
||||
float: left;
|
||||
padding: 0.5em 0em 0.5em 0.75em;
|
||||
}
|
||||
|
||||
div#title p {
|
||||
float:right;
|
||||
margin-right:1em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
/* spec container */
|
||||
ul.specs {
|
||||
margin: 0.5em;
|
||||
}
|
||||
ul.specs li {
|
||||
margin-bottom: 0.1em;
|
||||
}
|
||||
|
||||
/* spec title */
|
||||
ul.specs li h3 {
|
||||
font-weight: bold;
|
||||
font-size: 0.75em;
|
||||
padding: 0.2em 1em;
|
||||
cursor: pointer;
|
||||
_cursor: hand;
|
||||
}
|
||||
|
||||
/* example container */
|
||||
ul.examples li {
|
||||
border-style: solid;
|
||||
border-width: 0px 0px 1px 5px;
|
||||
margin: 0.2em 0em 0.2em 1em;
|
||||
}
|
||||
|
||||
/* example title */
|
||||
ul.examples li h4 {
|
||||
font-weight: normal;
|
||||
font-size: 0.75em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
pre.examples-code {
|
||||
margin: 0.5em 2em;
|
||||
padding: 0.5em;
|
||||
background: white;
|
||||
border: solid 1px #CCC;
|
||||
}
|
||||
|
||||
/* example explaination */
|
||||
ul.examples li div {
|
||||
padding: 1em 2em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
/* styles for ongoing, success, failure, error */
|
||||
div.success, div.success a {
|
||||
color: #FFFFFF;
|
||||
background-color: #65C400;
|
||||
}
|
||||
|
||||
ul.specs li.success h3, ul.specs li.success h3 a {
|
||||
color: #FFFFFF;
|
||||
background-color: #65C400;
|
||||
}
|
||||
|
||||
ul.examples li.success, ul.examples li.success a {
|
||||
color: #3D7700;
|
||||
background-color: #DBFFB4;
|
||||
border-color: #65C400;
|
||||
}
|
||||
|
||||
div.exception, div.exception a {
|
||||
color: #FFFFFF;
|
||||
background-color: #C20000;
|
||||
}
|
||||
|
||||
ul.specs li.exception h3, ul.specs li.exception h3 a {
|
||||
color: #FFFFFF;
|
||||
background-color: #C20000;
|
||||
}
|
||||
|
||||
ul.examples li.exception, ul.examples li.exception a {
|
||||
color: #C20000;
|
||||
background-color: #FFFBD3;
|
||||
border-color: #C20000;
|
||||
}
|
||||
|
||||
div.ongoing, div.ongoing a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
}
|
||||
|
||||
ul.specs li.ongoing h3, ul.specs li.ongoing h3 a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
}
|
||||
|
||||
ul.examples li.ongoing, ul.examples li.ongoing a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
border-color: #DDDD00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------
|
||||
* values
|
||||
*/
|
||||
.number_value, .string_value, .regexp_value, .boolean_value, .dom_value {
|
||||
font-family: monospace;
|
||||
color: blue;
|
||||
}
|
||||
.object_value, .array_value {
|
||||
line-height: 2em;
|
||||
padding: 0.1em 0.2em;
|
||||
margin: 0.1em 0;
|
||||
}
|
||||
.date_value {
|
||||
font-family: monospace;
|
||||
color: olive;
|
||||
}
|
||||
.undefined_value, .null_value {
|
||||
font-style: italic;
|
||||
color: blue;
|
||||
}
|
||||
.dom_attr_name {
|
||||
}
|
||||
.dom_attr_value {
|
||||
color: red;
|
||||
}
|
||||
.dom_path {
|
||||
font-size: 0.75em;
|
||||
color: gray;
|
||||
}
|
||||
strong {
|
||||
font-weight: normal;
|
||||
background-color: #FFC6C6;
|
||||
@CHARSET "UTF-8";
|
||||
|
||||
/* --------------------
|
||||
* @Layout
|
||||
*/
|
||||
|
||||
html {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
body, #jsspec_container {
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#title {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#list {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 0px;
|
||||
bottom: 0px;
|
||||
overflow: auto;
|
||||
width: 250px;
|
||||
_height:expression(document.body.clientHeight-40);
|
||||
}
|
||||
|
||||
#log {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 40px;
|
||||
left: 250px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
overflow: auto;
|
||||
_height:expression(document.body.clientHeight-40);
|
||||
_width:expression(document.body.clientWidth-250);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------
|
||||
* @Decorations and colors
|
||||
*/
|
||||
* {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: "Lucida Grande", Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
/* hiding subtitles */
|
||||
h2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* title section */
|
||||
div#title {
|
||||
padding: 0em 0.5em;
|
||||
}
|
||||
|
||||
div#title h1 {
|
||||
font-size: 1.5em;
|
||||
float: left;
|
||||
}
|
||||
|
||||
div#title ul li {
|
||||
float: left;
|
||||
padding: 0.5em 0em 0.5em 0.75em;
|
||||
}
|
||||
|
||||
div#title p {
|
||||
float:right;
|
||||
margin-right:1em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
/* spec container */
|
||||
ul.specs {
|
||||
margin: 0.5em;
|
||||
}
|
||||
ul.specs li {
|
||||
margin-bottom: 0.1em;
|
||||
}
|
||||
|
||||
/* spec title */
|
||||
ul.specs li h3 {
|
||||
font-weight: bold;
|
||||
font-size: 0.75em;
|
||||
padding: 0.2em 1em;
|
||||
cursor: pointer;
|
||||
_cursor: hand;
|
||||
}
|
||||
|
||||
/* example container */
|
||||
ul.examples li {
|
||||
border-style: solid;
|
||||
border-width: 0px 0px 1px 5px;
|
||||
margin: 0.2em 0em 0.2em 1em;
|
||||
}
|
||||
|
||||
/* example title */
|
||||
ul.examples li h4 {
|
||||
font-weight: normal;
|
||||
font-size: 0.75em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
pre.examples-code {
|
||||
margin: 0.5em 2em;
|
||||
padding: 0.5em;
|
||||
background: white;
|
||||
border: solid 1px #CCC;
|
||||
}
|
||||
|
||||
/* example explaination */
|
||||
ul.examples li div {
|
||||
padding: 1em 2em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
|
||||
/* styles for ongoing, success, failure, error */
|
||||
div.success, div.success a {
|
||||
color: #FFFFFF;
|
||||
background-color: #65C400;
|
||||
}
|
||||
|
||||
ul.specs li.success h3, ul.specs li.success h3 a {
|
||||
color: #FFFFFF;
|
||||
background-color: #65C400;
|
||||
}
|
||||
|
||||
ul.examples li.success, ul.examples li.success a {
|
||||
color: #3D7700;
|
||||
background-color: #DBFFB4;
|
||||
border-color: #65C400;
|
||||
}
|
||||
|
||||
div.exception, div.exception a {
|
||||
color: #FFFFFF;
|
||||
background-color: #C20000;
|
||||
}
|
||||
|
||||
ul.specs li.exception h3, ul.specs li.exception h3 a {
|
||||
color: #FFFFFF;
|
||||
background-color: #C20000;
|
||||
}
|
||||
|
||||
ul.examples li.exception, ul.examples li.exception a {
|
||||
color: #C20000;
|
||||
background-color: #FFFBD3;
|
||||
border-color: #C20000;
|
||||
}
|
||||
|
||||
div.ongoing, div.ongoing a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
}
|
||||
|
||||
ul.specs li.ongoing h3, ul.specs li.ongoing h3 a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
}
|
||||
|
||||
ul.examples li.ongoing, ul.examples li.ongoing a {
|
||||
color: #000000;
|
||||
background-color: #FFFF80;
|
||||
border-color: #DDDD00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------
|
||||
* values
|
||||
*/
|
||||
.number_value, .string_value, .regexp_value, .boolean_value, .dom_value {
|
||||
font-family: monospace;
|
||||
color: blue;
|
||||
}
|
||||
.object_value, .array_value {
|
||||
line-height: 2em;
|
||||
padding: 0.1em 0.2em;
|
||||
margin: 0.1em 0;
|
||||
}
|
||||
.date_value {
|
||||
font-family: monospace;
|
||||
color: olive;
|
||||
}
|
||||
.undefined_value, .null_value {
|
||||
font-style: italic;
|
||||
color: blue;
|
||||
}
|
||||
.dom_attr_name {
|
||||
}
|
||||
.dom_attr_value {
|
||||
color: red;
|
||||
}
|
||||
.dom_path {
|
||||
font-size: 0.75em;
|
||||
color: gray;
|
||||
}
|
||||
strong {
|
||||
font-weight: normal;
|
||||
background-color: #FFC6C6;
|
||||
}
|
||||
|
|
@ -1,74 +1,74 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<title>JSSpec results</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/JSSpec.css" />
|
||||
<script type="text/javascript" src="JSSpec/JSSpec.js"></script>
|
||||
<script type="text/javascript" src="JSSpec/diff_match_patch.js"></script>
|
||||
<script type="text/javascript" src="../jquery.js"></script>
|
||||
<script type="text/javascript" src="../common.js"></script>
|
||||
<script type="text/javascript">// <![CDATA[
|
||||
describe('SetQuery', {
|
||||
'should satisfy basic uri condition' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
value_of(target.setQuery("q","r")).should_be("http://xpressengine.com/?q=r");
|
||||
},
|
||||
'should work when ssl is on' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work when ssl is on and https_port is set (not 443)' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
https_port = 445;
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin");
|
||||
},
|
||||
'should work when ssl is on and https_port is set as 443' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
https_port = 443;
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should replace https to http if act is not a member of ssl_actions': function() {
|
||||
targets = "https://xpressengine.com/";
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(targets.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?act=dispLogin2");
|
||||
},
|
||||
'should remove https port' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should remove https port and add http port if http port is defined' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
http_port = 8000;
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/:8000/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should only remove https port and if http port is defined as 80' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
http_port = 80;
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should work if enforce_ssl is set' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work if enforce_ssl is set with 443 port' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
https_port = 443;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work if enforce_ssl is set with none-443 port' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
https_port = 445;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin");
|
||||
}
|
||||
})
|
||||
// ]]></script>
|
||||
</head>
|
||||
<body><div style="display:none;"><p>A</p><p>B</p></div></body>
|
||||
</html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<title>JSSpec results</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/JSSpec.css" />
|
||||
<script type="text/javascript" src="JSSpec/JSSpec.js"></script>
|
||||
<script type="text/javascript" src="JSSpec/diff_match_patch.js"></script>
|
||||
<script type="text/javascript" src="../jquery.js"></script>
|
||||
<script type="text/javascript" src="../common.js"></script>
|
||||
<script type="text/javascript">// <![CDATA[
|
||||
describe('SetQuery', {
|
||||
'should satisfy basic uri condition' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
value_of(target.setQuery("q","r")).should_be("http://xpressengine.com/?q=r");
|
||||
},
|
||||
'should work when ssl is on' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work when ssl is on and https_port is set (not 443)' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
https_port = 445;
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin");
|
||||
},
|
||||
'should work when ssl is on and https_port is set as 443' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
https_port = 443;
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should replace https to http if act is not a member of ssl_actions': function() {
|
||||
targets = "https://xpressengine.com/";
|
||||
ssl_actions = new Array("dispLogin");
|
||||
value_of(targets.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?act=dispLogin2");
|
||||
},
|
||||
'should remove https port' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should remove https port and add http port if http port is defined' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
http_port = 8000;
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/:8000/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should only remove https port and if http port is defined as 80' : function() {
|
||||
targetsp = "https://xpressengine.com:443/?q=r";
|
||||
http_port = 80;
|
||||
value_of(targetsp.setQuery("act","dispLogin2")).should_be("http://xpressengine.com/?q=r&act=dispLogin2");
|
||||
},
|
||||
'should work if enforce_ssl is set' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work if enforce_ssl is set with 443 port' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
https_port = 443;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com/?act=dispLogin");
|
||||
},
|
||||
'should work if enforce_ssl is set with none-443 port' : function() {
|
||||
target = "http://xpressengine.com/";
|
||||
enforce_ssl = true;
|
||||
https_port = 445;
|
||||
value_of(target.setQuery("act","dispLogin")).should_be("https://xpressengine.com:445/?act=dispLogin");
|
||||
}
|
||||
})
|
||||
// ]]></script>
|
||||
</head>
|
||||
<body><div style="display:none;"><p>A</p><p>B</p></div></body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
/**
|
||||
* @file common/js/xml_js_filter.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief xml filter (validator) plugin
|
||||
*
|
||||
* A rule is a method validate one field.
|
||||
* A filter is made up of one or more rules.
|
||||
**/
|
||||
|
||||
(function($){var messages=[];var rules=[];var filters=[];var callbacks=[];var extras={};var Validator=xe.createApp('Validator',{init:function(){var regEmail=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;this.cast('ADD_RULE',['email',regEmail]);this.cast('ADD_RULE',['email_address',regEmail]);var regUserid=/^[a-z]+[\w-]*[a-z0-9_]+$/i;this.cast('ADD_RULE',['userid',regUserid]);this.cast('ADD_RULE',['user_id',regUserid]);var regUrl=/^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;this.cast('ADD_RULE',['url',regUrl]);this.cast('ADD_RULE',['homepage',regUrl]);var regKor=/^[가-힣]*$/;this.cast('ADD_RULE',['korean',regKor]);var regKorNum=/^[가-힣0-9]*$/;this.cast('ADD_RULE',['korean_number',regKorNum]);var regAlpha=/^[a-z]*$/i;this.cast('ADD_RULE',['alpha',regAlpha]);var regAlphaNum=/^[a-z][a-z0-9_]*$/i;this.cast('ADD_RULE',['alpha_number',regAlphaNum]);var regNum=/^[0-9]*$/;this.cast('ADD_RULE',['number',regNum]);},run:function(oForm){var filter='';if(oForm._filter)filter=oForm._filter.value;var params=[oForm,filter];var result=this.cast('VALIDATE',params);if(typeof result=='undefined')result=false;return result;},API_ONREADY:function(){var self=this;$('form').each(function(){if(this.onsubmit){this['xe:onsubmit']=this.onsubmit;this.onsubmit=null;}}).submit(function(){var legacyFn=this['xe:onsubmit'];var hasLegacyFn=$.isFunction(legacyFn);var bResult=hasLegacyFn?legacyFn.apply(this):self.run(this);return bResult;});},API_VALIDATE:function(sender,params){var self=this,result=true,form=params[0],filter=null,callback=null;if(form.elements['_filter'])filter=form.elements['_filter'].value;if(!filter)return true;if($.isFunction(callbacks[filter]))callback=callbacks[filter];filter=$.extend({},filters[filter.toLowerCase()]||{},extras);$.each(filter,function(name){var _el=form.elements[name];if(!_el)return true;var el=$(_el),val=$.trim(get_value(el));var minlen=parseInt(this.minlength)||0;var maxlen=parseInt(this.maxlength)||0;var rule=(this.rule||'').split(',');if(this.required&&!val)return(result=(!!self.cast('ALERT',[form,name,'isnull'])&&false));if(!this.required&&!val)return(result=true);if((minlen&&val.length<minlen)||(maxlen&&val.length>maxlen))return(result=(!!self.cast('ALERT',[form,name,'outofrange',minlen,maxlen])&&false));if(this.equalto){var eq_val=get_value($(form.elements[this.equalto]));if(eq_val!=val)return(result=(!!self.cast('ALERT',[form,name,'equalto'])&&false));}
|
||||
if(rule){$.each(rule,function(i,r){if(!r)return true;var ret=self.cast('APPLY_RULE',[r,val]);if(!ret){self.cast('ALERT',[form,name,'invalid_'+this]);return(result=false);}});}
|
||||
if(!result)return false;});if(!result)return false;if($.isFunction(callback))return callback(form);return true;},API_ADD_RULE:function(sender,params){var name=params[0].toLowerCase();rules[name]=params[1];},API_DEL_RULE:function(sender,params){var name=params[0].toLowerCase();delete rules[name];},API_GET_RULE:function(sender,params){var name=params[0].toLowerCase();if(rules[name]){return rules[name];}else{return null;}},API_ADD_FILTER:function(sender,params){var name=params[0].toLowerCase();var filter=params[1];filters[name]=filter;},API_DEL_FILTER:function(sender,params){var name=params[0].toLowerCase();delete filters[name];},API_GET_FILTER:function(sender,params){var name=params[0].toLowerCase();if(filters[name]){return filters[name];}else{return null;}},API_ADD_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();var prop=params[1];extras[name]=prop;},API_GET_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();return extras[name];},API_DEL_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();delete extras[name];},API_APPLY_RULE:function(sender,params){var name=params[0];var value=params[1];if(typeof(rules[name])=='undefined')return true;if($.isFunction(rules[name]))return rules[name](value);if(rules[name]instanceof RegExp)return rules[name].test(value);return true;},API_ALERT:function(sender,params){var form=params[0];var field_name=params[1];var msg_code=params[2];var minlen=params[3];var maxlen=params[4];var field_msg=this.cast('GET_MESSAGE',[field_name]);var msg=this.cast('GET_MESSAGE',[msg_code]);if(msg!=msg_code)msg=(msg.indexOf('%s')<0)?(field_msg+msg):(msg.replace('%s',field_msg));if(minlen||maxlen)msg+='('+(minlen||'')+'~'+(maxlen||'')+')';this.cast('SHOW_ALERT',[msg]);$(form.elements[field_name]).focus();},API_SHOW_ALERT:function(sender,params){alert(params[0]);},API_ADD_MESSAGE:function(sender,params){var msg_code=params[0];var msg_str=params[1];messages[msg_code]=msg_str;},API_GET_MESSAGE:function(sender,params){var msg_code=params[0];return messages[msg_code]||msg_code;},API_ADD_CALLBACK:function(sender,params){var name=params[0];var func=params[1];callbacks[name]=func;},API_REMOVE_CALLBACK:function(sender,params){var name=params[0];delete callbacks[name];}});var oValidator=new Validator;xe.registerApp(oValidator);var EditorStub=xe.createPlugin('editor_stub',{API_BEFORE_VALIDATE:function(sender,params){var form=params[0];var seq=form.getAttribute('editor_sequence');if(seq && typeof seq=='object')seq=seq.value;if(seq){try{editorRelKeys[seq].content.value=editorRelKeys[seq].func(seq)||'';}catch(e){}}}});oValidator.registerPlugin(new EditorStub);function get_value(elem){var vals=[];if(elem.is(':radio')){return elem.filter(':checked').val();}else if(elem.is(':checkbox')){elem.filter(':checked').each(function(){vals.push(this.value);});return vals.join('|@|');}else{return elem.val();}}})(jQuery);function filterAlertMessage(ret_obj){var error=ret_obj["error"];var message=ret_obj["message"];var act=ret_obj["act"];var redirect_url=ret_obj["redirect_url"];var url=location.href;if(typeof(message)!="undefined"&&message&&message!="success")alert(message);if(typeof(act)!="undefined"&&act)url=current_url.setQuery("act",act);else if(typeof(redirect_url)!="undefined"&&redirect_url)url=redirect_url;if(url==location.href)url=url.replace(/#(.*)$/,'');location.href=url;}
|
||||
function procFilter(form,filter_func){filter_func(form);return false;}
|
||||
/**
|
||||
* @file common/js/xml_js_filter.js
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @brief xml filter (validator) plugin
|
||||
*
|
||||
* A rule is a method validate one field.
|
||||
* A filter is made up of one or more rules.
|
||||
**/
|
||||
|
||||
(function($){var messages=[];var rules=[];var filters=[];var callbacks=[];var extras={};var Validator=xe.createApp('Validator',{init:function(){var regEmail=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;this.cast('ADD_RULE',['email',regEmail]);this.cast('ADD_RULE',['email_address',regEmail]);var regUserid=/^[a-z]+[\w-]*[a-z0-9_]+$/i;this.cast('ADD_RULE',['userid',regUserid]);this.cast('ADD_RULE',['user_id',regUserid]);var regUrl=/^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;this.cast('ADD_RULE',['url',regUrl]);this.cast('ADD_RULE',['homepage',regUrl]);var regKor=/^[가-힣]*$/;this.cast('ADD_RULE',['korean',regKor]);var regKorNum=/^[가-힣0-9]*$/;this.cast('ADD_RULE',['korean_number',regKorNum]);var regAlpha=/^[a-z]*$/i;this.cast('ADD_RULE',['alpha',regAlpha]);var regAlphaNum=/^[a-z][a-z0-9_]*$/i;this.cast('ADD_RULE',['alpha_number',regAlphaNum]);var regNum=/^[0-9]*$/;this.cast('ADD_RULE',['number',regNum]);},run:function(oForm){var filter='';if(oForm._filter)filter=oForm._filter.value;var params=[oForm,filter];var result=this.cast('VALIDATE',params);if(typeof result=='undefined')result=false;return result;},API_ONREADY:function(){var self=this;$('form').each(function(){if(this.onsubmit){this['xe:onsubmit']=this.onsubmit;this.onsubmit=null;}}).submit(function(){var legacyFn=this['xe:onsubmit'];var hasLegacyFn=$.isFunction(legacyFn);var bResult=hasLegacyFn?legacyFn.apply(this):self.run(this);return bResult;});},API_VALIDATE:function(sender,params){var self=this,result=true,form=params[0],filter=null,callback=null;if(form.elements['_filter'])filter=form.elements['_filter'].value;if(!filter)return true;if($.isFunction(callbacks[filter]))callback=callbacks[filter];filter=$.extend({},filters[filter.toLowerCase()]||{},extras);$.each(filter,function(name){var _el=form.elements[name];if(!_el)return true;var el=$(_el),val=$.trim(get_value(el));var minlen=parseInt(this.minlength)||0;var maxlen=parseInt(this.maxlength)||0;var rule=(this.rule||'').split(',');if(this.required&&!val)return(result=(!!self.cast('ALERT',[form,name,'isnull'])&&false));if(!this.required&&!val)return(result=true);if((minlen&&val.length<minlen)||(maxlen&&val.length>maxlen))return(result=(!!self.cast('ALERT',[form,name,'outofrange',minlen,maxlen])&&false));if(this.equalto){var eq_val=get_value($(form.elements[this.equalto]));if(eq_val!=val)return(result=(!!self.cast('ALERT',[form,name,'equalto'])&&false));}
|
||||
if(rule){$.each(rule,function(i,r){if(!r)return true;var ret=self.cast('APPLY_RULE',[r,val]);if(!ret){self.cast('ALERT',[form,name,'invalid_'+this]);return(result=false);}});}
|
||||
if(!result)return false;});if(!result)return false;if($.isFunction(callback))return callback(form);return true;},API_ADD_RULE:function(sender,params){var name=params[0].toLowerCase();rules[name]=params[1];},API_DEL_RULE:function(sender,params){var name=params[0].toLowerCase();delete rules[name];},API_GET_RULE:function(sender,params){var name=params[0].toLowerCase();if(rules[name]){return rules[name];}else{return null;}},API_ADD_FILTER:function(sender,params){var name=params[0].toLowerCase();var filter=params[1];filters[name]=filter;},API_DEL_FILTER:function(sender,params){var name=params[0].toLowerCase();delete filters[name];},API_GET_FILTER:function(sender,params){var name=params[0].toLowerCase();if(filters[name]){return filters[name];}else{return null;}},API_ADD_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();var prop=params[1];extras[name]=prop;},API_GET_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();return extras[name];},API_DEL_EXTRA_FIELD:function(sender,params){var name=params[0].toLowerCase();delete extras[name];},API_APPLY_RULE:function(sender,params){var name=params[0];var value=params[1];if(typeof(rules[name])=='undefined')return true;if($.isFunction(rules[name]))return rules[name](value);if(rules[name]instanceof RegExp)return rules[name].test(value);return true;},API_ALERT:function(sender,params){var form=params[0];var field_name=params[1];var msg_code=params[2];var minlen=params[3];var maxlen=params[4];var field_msg=this.cast('GET_MESSAGE',[field_name]);var msg=this.cast('GET_MESSAGE',[msg_code]);if(msg!=msg_code)msg=(msg.indexOf('%s')<0)?(field_msg+msg):(msg.replace('%s',field_msg));if(minlen||maxlen)msg+='('+(minlen||'')+'~'+(maxlen||'')+')';this.cast('SHOW_ALERT',[msg]);$(form.elements[field_name]).focus();},API_SHOW_ALERT:function(sender,params){alert(params[0]);},API_ADD_MESSAGE:function(sender,params){var msg_code=params[0];var msg_str=params[1];messages[msg_code]=msg_str;},API_GET_MESSAGE:function(sender,params){var msg_code=params[0];return messages[msg_code]||msg_code;},API_ADD_CALLBACK:function(sender,params){var name=params[0];var func=params[1];callbacks[name]=func;},API_REMOVE_CALLBACK:function(sender,params){var name=params[0];delete callbacks[name];}});var oValidator=new Validator;xe.registerApp(oValidator);var EditorStub=xe.createPlugin('editor_stub',{API_BEFORE_VALIDATE:function(sender,params){var form=params[0];var seq=form.getAttribute('editor_sequence');if(seq && typeof seq=='object')seq=seq.value;if(seq){try{editorRelKeys[seq].content.value=editorRelKeys[seq].func(seq)||'';}catch(e){}}}});oValidator.registerPlugin(new EditorStub);function get_value(elem){var vals=[];if(elem.is(':radio')){return elem.filter(':checked').val();}else if(elem.is(':checkbox')){elem.filter(':checked').each(function(){vals.push(this.value);});return vals.join('|@|');}else{return elem.val();}}})(jQuery);function filterAlertMessage(ret_obj){var error=ret_obj["error"];var message=ret_obj["message"];var act=ret_obj["act"];var redirect_url=ret_obj["redirect_url"];var url=location.href;if(typeof(message)!="undefined"&&message&&message!="success")alert(message);if(typeof(act)!="undefined"&&act)url=current_url.setQuery("act",act);else if(typeof(redirect_url)!="undefined"&&redirect_url)url=redirect_url;if(url==location.href)url=url.replace(/#(.*)$/,'');location.href=url;}
|
||||
function procFilter(form,filter_func){filter_func(form);return false;}
|
||||
function legacy_filter(filter_name,form,module,act,callback,responses,confirm_msg,rename_params){var v=xe.getApp('Validator')[0],$=jQuery,args=[];if(!v)return false;if(!form.elements['_filter'])$(form).prepend('<input type="hidden" name="_filter" />');form.elements['_filter'].value=filter_name;args[0]=filter_name;args[1]=function(f){var params={},res=[],elms=f.elements,data=$(f).serializeArray();$.each(data,function(i,field){var v=$.trim(field.value),n=field.name;if(!v||!n)return true;if(rename_params[n])n=rename_params[n];if(/\[\]$/.test(n))n=n.replace(/\[\]$/,'');if(params[n])params[n]+='|@|'+v;else params[n]=field.value;});if(confirm_msg&&!confirm(confirm_msg))return false;exec_xml(module,act,params,callback,responses,params,form);};v.cast('ADD_CALLBACK',args);v.cast('VALIDATE',[form,filter_name]);return false;}
|
||||
Loading…
Add table
Add a link
Reference in a new issue