function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv|firefox/i.test(ua))&&/trident|msie/i.test(ua)&&/(msie\s|rv\:)(\d+)/.test(ua))?('ie ie'+RegExp.$2):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js'];if(document.documentMode||/Edge/.test(navigator.userAgent)){b.push("edge")} c=b.join(' ');h.className+=' '+c;return c};css_browser_selector(navigator.userAgent);(function($){$.belowthefold=function(element,settings){var fold=$(window).height()+$(window).scrollTop();return fold<=$(element).offset().top-settings.threshold};$.abovethetop=function(element,settings){var top=$(window).scrollTop();return top>=$(element).offset().top+$(element).height()-settings.threshold};$.rightofscreen=function(element,settings){var fold=$(window).width()+$(window).scrollLeft();return fold<=$(element).offset().left-settings.threshold};$.leftofscreen=function(element,settings){var left=$(window).scrollLeft();return left>=$(element).offset().left+$(element).width()-settings.threshold};$.inviewport=function(element,settings){return!$.rightofscreen(element,settings)&&!$.leftofscreen(element,settings)&&!$.belowthefold(element,settings)&&!$.abovethetop(element,settings)};$.extend($.expr[':'],{"below-the-fold":function(a,i,m){return $.belowthefold(a,{threshold:0})},"above-the-top":function(a,i,m){return $.abovethetop(a,{threshold:0})},"left-of-screen":function(a,i,m){return $.leftofscreen(a,{threshold:0})},"right-of-screen":function(a,i,m){return $.rightofscreen(a,{threshold:0})},"in-viewport":function(a,i,m){return $.inviewport(a,{threshold:0})}})})(jQuery);function loadPopupForm(title,formURL,cccFormAPI,uid,addClass,callback,oncloseCallback,disableCenter,disableCloseBtn){var thisApp;cms.loadingDiv($("body"));var div=$('
');div.load(formURL,function(){cms.removeLoadingDiv($("body"));BootstrapDialog.confirm(1,'info',title,'',!0,!0,{'callback':function(result){if(result){}else{$('form.mainForm').find('input[type="submit"]').prop('disabled',!1)}}},(disableCloseBtn?[]:[{label:lang('Close'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}}]),function(dialog){dialog.$modalBody.append(div);if(addClass)$(dialog.$modalDialog).addClass(addClass)},function(dialog){thisApp=cms.cccApp.init(cccFormAPI,$(dialog.$modalDialog).find(".cccApp"),(uid?uid:!1),!1,function(thisApp){if(callback)callback(thisApp,dialog)},function(){if(canDebug())console.log('onDestory App');dialog.close()});formSelect(thisApp)},function(dialog){if(canDebug())console.log('onhide')},function(dialog){if(canDebug())console.log('onhidden');if(oncloseCallback)oncloseCallback(thisApp)},disableCenter,!0)})} function rawurldecode(str){return decodeURIComponent((str+'').replace(/%(?![\da-f]{2})/gi,function(){return '%25'}))} function rawurlencode(str){str=(str+'').toString();return encodeURIComponent(str).replace(/!/g,'%21').replace(/'/g,'%27').replace(/\(/g,'%28').replace(/\)/g,'%29').replace(/\*/g,'%2A')} function canDebug(){return!1} var randomIDs=[];var cms={functionControl:function(func){var setting={swipe:!0};if(setting[func]){return setting[func]}else{return!1}},ready:function(){},init:function(){},translate:function(id,cmsPath){console.log('Translate',id,cmsPath);if(!cmsPath)cmsPath=root_header_path loadPopupForm('Translate',cmsPath+'cccframework/cccApp/getApp/?app=translate',cmsPath+'|cccms/ucp/api/ucp-v1/translate',id,!1,function(thisApp,dialog){thisApp.onSave=function(){dialog.close()}},!1,!1,!0)},siteSettingContent:function(client,settingSwitch,field,id,cmsPath){console.log('settingContent',client,settingSwitch,field,cmsPath);if(!cmsPath)cmsPath=root_header_path loadPopupForm('Site Setting Content',cmsPath+'cccframework/cccApp/getSiteSettingApp/?field='+field+'&client='+client+'&setting_switch='+settingSwitch,cmsPath+'|cccms/ucp/api/ucp-v1/site-setting',id,"modal-lg",function(thisApp,dialog){thisApp.onSave=function(){}},!1,!1,!0)},inArray:function(needle,haystack){var length=haystack.length;for(var i=0;i')},loadingDiv:function(target,addLoading,setting){if($(target).length>1){$(target).each(function(){cms.loadingDiv(this,addLoading,setting)});return!1} var LoadingDivID=cms.makeID();if(!setting)setting={loading:{},background:{}};if(!setting.loading)setting.loading={};if(!setting.background)setting.background={};if($("html,body").hasClass("hasSelectable")){$('html,body').selectable("disable")} var loading;if(!addLoading){loading=$('')}else{loading=$("
")} $.each(setting.loading,function(k,v){if(loading)$(loading).css(k,v)});var background=$("
");var final=$("
").css({position:($(target).is("body")?"fixed":"absolute"),'z-index':'65535',height:$(target).height(),width:$(target).width()}).append(background).append(loading);var thisCallBack=function(){$(background).css({position:($(target).is("body")?"fixed":"absolute"),opacity:(addLoading?'0':'0.5'),background:'#ffffff',height:$(target).outerHeight(),width:$(target).outerWidth()}).mousemove(function(e){e.preventDefault();return!1}).mousedown(function(e){e.preventDefault();return!1});$.each(setting.background,function(k,v){if(background)$(background).css(k,v)});$.each(['border-top-left-radius','border-top-right-radius','border-bottom-right-radius','border-bottom-left-radius','-webkit-border-radius','-webkit-border-top-left-radius','-webkit-border-top-right-radius','-webkit-border-bottom-right-radius','-webkit-border-bottom-left-radius','-moz-border-radius','-moz-border-radius-topleft','-moz-border-radius-topright','-moz-border-radius-bottomright','-moz-border-radius-bottomleft'],function(k,keyword){if($(target).css(keyword))$(background).css(keyword,$(target).css(keyword))});$.each({"padding-top":'margin-top',"padding-left":'margin-left'},function(keyword,value){if($(target).css(keyword))$(background).css(value,'-'+$(target).css(keyword))})};thisCallBack();final.attr("LoadingDivID",LoadingDivID);var subCallBack=function(){if(!$(final).is(":visible")){$(window).unbind("resize."+LoadingDivID);$(document).unbind("LoadingDivResize."+LoadingDivID);return!1} $(final).css({position:'absolute','z-index':'65535',height:$(target).height(),width:$(target).width()});thisCallBack()};$(window).bind("resize."+LoadingDivID,function(){subCallBack()});$(document).bind("LoadingDivResize."+LoadingDivID,function(){subCallBack()});cms.removeLoadingDiv(target);$(target).prepend(final);if($(target).is("body"))$("body").css("overflow","hidden");return{'setText':function(text){console.log($(target).children(".LoadingDiv").find(".statusGif"));$(target).children(".LoadingDiv").find(".statusGif").html(""+text+"")}}},removeLoadingDiv:function(target){if($(target).is("body"))$("body").css("overflow","");if($(target).length>1){$(target).each(function(){cms.removeLoadingDiv(this)});return!1} if($("html").hasClass("hasSelectable")){$('html,body').selectable("enable")} if(target.attr)var LoadingDivID=target.attr("LoadingDivID");if(LoadingDivID){$(window).unbind("resize."+LoadingDivID);$(document).unbind("LoadingDivResize."+LoadingDivID)} $(target).children(".LoadingDiv").remove()},simpleHrefValue:function(obj,title){var $obj=$(obj);var value=obj.href;value=value.replace("javascript:void('",'').replace("');",'');BootstrapDialog.show({'title':title,'message':'
'+value+'
'})},simpleConfirm:function(type,message,callback){var btnColorType='default';switch(type){case 'alert':btnColorType='danger';break;default:btnColorType=type;break} BootstrapDialog.confirm(!1,type,!1,lang(message),!1,!1,callback,[{label:lang('cancel'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}},{label:lang('enter'),cssClass:'btn-'+btnColorType,action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!0);dialog.close()}}])},simpleAjax:function(ajaxOptions,doneCallBack,failCallBack){$.ajax(ajaxOptions).done(function(data,textStatus,jqXHR){if(doneCallBack&&typeof(doneCallBack)=='function'){doneCallBack(data,textStatus,jqXHR)}}).fail(function(data,textStatus,jqXHR){if(failCallBack&&typeof(failCallBack)=='function'){failCallBack(data,textStatus,jqXHR)}else{console.warn(data,textStatus,jqXHR)}})},windowFocus:function($windowFocusFunc,$windowBlurFunc,$tabFocusFunc,$tabBlurFunc){var vis=(function(){var stateKey,eventKey,keys={hidden:"visibilitychange",webkitHidden:"webkitvisibilitychange",mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange"};for(stateKey in keys){if(stateKey in document){if(keys[stateKey]){eventKey=keys[stateKey];break}}} return function(c){if(c){document.addEventListener(eventKey,c)}else{return!document[stateKey]}}})();vis(function(){if(vis()){if($tabFocusFunc&&typeof($tabFocusFunc)!=='undefined'){$tabFocusFunc()}}else{if($tabBlurFunc&&typeof($tabBlurFunc)!=='undefined'){$tabBlurFunc()}}});var notIE=(document.documentMode===undefined),isChromium=window.chrome;if(notIE&&!isChromium){$(window).on("focusin",function(){if($windowFocusFunc&&typeof($windowFocusFunc)!=='undefined'){$windowFocusFunc()}}).on("focusout",function(){if($windowBlurFunc&&typeof($windowBlurFunc)!=='undefined'){$windowBlurFunc()}})}else{if(window.addEventListener){window.addEventListener("focus",function(event){if($windowFocusFunc&&typeof($windowFocusFunc)!=='undefined'){$windowFocusFunc()}},!1);window.addEventListener("blur",function(event){if($windowBlurFunc&&typeof($windowBlurFunc)!=='undefined'){$windowBlurFunc()}},!1)}else{window.attachEvent("focus",function(event){if($windowFocusFunc&&typeof($windowFocusFunc)!=='undefined'){$windowFocusFunc()}});window.attachEvent("blur",function(event){if($windowBlurFunc&&typeof($windowBlurFunc)!=='undefined'){$windowBlurFunc()}})}}},in_array:function(needle,haystack){var length=haystack.length;for(var i=0;i';end_span=''}else{start_span='';end_span=''} var errorCode=start_span+(codecheck?'400':code)+end_span;if(tempData.lang){if(langID in tempData.lang&&typeof tempData.lang[langID]!=='undefined'){var $breakSpace=!1;if('breakspace' in tempData.lang[langID])$breakSpace=tempData.lang[langID].breakspace;if(code in tempData.lang[langID]){return start_span+tempData.lang[langID][code]+end_span}else{return code}}else{return code}}else{return errorCode}} function LoadLangPackage(langID,callback,update){$(document).trigger('reloadLayout');var mainHandler=function(){if(!tempData.lang)tempData.lang={};if(!langID&&clang>0){langID=clang}else{if(!(langID>=0)||langID==null){langID=2}} var obj;var handler=function(){if(tempData.oldLangID!=tempData.currentLangID){obj=$('.langPack')}else{obj=$('.langPack:not(.langEcho)');obj=$('.langPack')} $(obj).each(function(){var $this=$(this);if($this.hasClass('langSpan')){$this.css({'width':'auto','height':'auto','display':'','position':'relative','float':'none','padding':'0px','margin':'0px','top':'0px','left':'0px','font-size':$('body').css('font-size'),'line-height':$('body').css('line-height')})} var rawlangCode=$this.attr('lang');if(rawlangCode){if((new RegExp("^attr:.*")).test(rawlangCode)){rawlangCode=rawlangCode.replace('attr:','');rawlangCode=rawlangCode.split(":");if(rawlangCode.length>1){$this.attr(rawlangCode[0],lang(rawlangCode[1]))}}else{if(tempData.oldLangID!=tempData.currentLangID){rawlangCode=rawlangCode.replace('pp:','').replace('ap:','').replace('ib:','').replace('ia:','');$this.contents().filter(function(){return this.nodeType==3}).each(function(){if(this.textContent){this.textContent=this.textContent.replace(lang(rawlangCode,tempData.oldLangID),lang(rawlangCode,tempData.currentLangID))}else{location.reload()}})}else{if(!($this.hasClass('langEcho'))){if((new RegExp("^pp:.*")).test(rawlangCode)){if(!((new RegExp("^"+lang(rawlangCode.replace('pp:',''))+".*")).test($this.html()))){$this.prepend(lang(rawlangCode.replace('pp:','')))}}else if((new RegExp("^ap:.*")).test(rawlangCode)){if(!((new RegExp(".*"+lang(rawlangCode.replace('ap:',''))+"$")).test($this.html()))){$this.append(lang(rawlangCode.replace('ap:','')))}}else if((new RegExp("^ib:.*")).test(rawlangCode)){$this.insertBefore(lang(rawlangCode.replace('ib:','')))}else if((new RegExp("^ia:.*")).test(rawlangCode)){$this.insertAfter(lang(rawlangCode.replace('ia:','')))}else{$this.text(lang(rawlangCode))} $this.addClass('langEcho')}}}}});if(tempData.oldLangID!=tempData.currentLangID){tempData.oldLangID=tempData.currentLangID} if(callback&&typeof(callback)==="function"){callback.call()} cms.setCookie('lang',tempData.currentLangID,10);clang=tempData.currentLangID;$(document).trigger('langPackLoaded')};if(langID>0){if(langID in tempData.lang){tempData.currentLangID=langID;if(!(tempData.oldLangID>=0))tempData.oldLangID=langID;handler()}else{if('isExportMode' in window||'skipAjaxLang' in window){if(callback&&typeof(callback)==="function"){callback.call()} $(document).trigger('langPackLoaded')}else{$.ajax({url:root_header_path+'lib/ajax/lang/get/',data:{lang:langID},type:'GET',dataType:"json",error:function(data){tempData.lang[langID]=data.lang;tempData.currentLangID=langID;if(!(tempData.oldLangID>=0))tempData.oldLangID=langID;handler()},success:function(data){tempData.lang[langID]=data.lang;tempData.currentLangID=langID;if(!(tempData.oldLangID>=0))tempData.oldLangID=langID;handler()}})}}}else{handler()}};if(update&&langID>0&&(tempData.oldLangID!=tempData.currentLangID)){mainHandler()}else{mainHandler()}} $(window).load(function(){if(!clang)clang=1;LoadLangPackage(clang,function(){$(document).trigger("langLoaded");$("body").addClass("langLoaded")})});var pad=function(n,width,z){z=z||'0';n=n+'';return n.length>=width?n:new Array(width-n.length+1).join(z)+n};function htmlEntities(str){return String(str).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"')} var waitForFinalEvent=(function(){var timers={};return function(callback,ms,uniqueId){if(!uniqueId){uniqueId="Don't call this twice without a uniqueId"} if(timers[uniqueId]){clearTimeout(timers[uniqueId])} timers[uniqueId]=setTimeout(callback,ms)}})();$.fn.extend({animateCss:function(animationName){var animationEnd='webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';$(this).addClass('animated '+animationName).one(animationEnd,function(){$(this).removeClass('animated '+animationName)})}});$(document).ready(function(){$("[data-animation]").each(function(){var thisData=($(this).attr('data-animation')).split(",");var $this=this;switch(thisData[1]){case 'hover':$($this).hover(function(){$(this).animateCss(thisData[0])});break;case 'hover-long':$($this).hover(function(){switch(thisData[0]){case 'scale':if($(this).attr("data-animation-target")){$(this).find($(this).attr("data-animation-target")).addClass("hoverScale");$(this).find($(this).attr("data-animation-target")).addClass("hoverScaled")}else{$(this).addClass("hoverScale");$(this).addClass("hoverScaled")} break;default:$($this).hover(function(){$(this).animateCss(thisData[0])});break}},function(){switch(thisData[0]){case 'scale':if($(this).attr("data-animation-target")){var $target=$(this).find($(this).attr("data-animation-target"));$($target).removeClass("hoverScale");setTimeout(function(){if(!$($target).hasClass("hoverScale")){$($target).removeClass("hoverScaled")}},500)}else{$(this).removeClass("hoverScale");setTimeout(function(){if(!$($this).hasClass("hoverScale")){$($this).removeClass("hoverScaled")}},500)} break;default:break}});break}})});var getPercentage=function(orgValue,str){var s="%";if(str.indexOf(s)>-1){return orgValue*(parseInt(str.replace("%",""))/100)}else{return parseInt(str.replace("%",""))}};var positionObj=function(thisObj){var obj=$(thisObj);if(obj.hasClass("reset-animate-me")){console.log('reset-animate-me');$($this).css({'-webkit-transform':'scale('+ratio+')','-moz-transform':'scale('+ratio+')','-ms-transform':'scale('+ratio+')','-o-transform':'scale('+ratio+')','transform':'scale('+ratio+')'});obj.css({'top':'0px','left':'0px','margin-left':'0px','margin-top':'0px'});return} var $this=obj;var baseWidth=$(obj).attr('data-base-scale-width');var refObj=$(obj).attr(' data-base-scale-min="0.9" data-base-scale-obj-ref');var minRatio=$(obj).attr('data-base-scale-min');var maxRatio=$(obj).attr('data-base-scale-max');var targetObj=$(obj).parent();if(refObj){targetObj=$(refObj)} var ratio=$(targetObj).width()/baseWidth;if(minRatio)if(ratiomaxRatio)ratio=maxRatio;$($this).css({'-webkit-transform':'scale('+ratio+')','-moz-transform':'scale('+ratio+')','-ms-transform':'scale('+ratio+')','-o-transform':'scale('+ratio+')','transform':'scale('+ratio+')'});var targetX=obj.attr('data-center-x');var targetY=obj.attr('data-center-y');if($(window).width()<1200){var mdY=obj.attr('data-center-y-md');if(mdY)targetY=mdY;var mdX=obj.attr('data-center-x-md');if(mdX)targetX=mdX} if($(window).width()<992){var smY=obj.attr('data-center-y-sm');if(smY)targetY=smY;var smX=obj.attr('data-center-x-sm');if(smX)targetX=smX} if($(window).width()<768){var xsY=obj.attr('data-center-y-xs');if(xsY)targetY=xsY;var xsX=obj.attr('data-center-x-xs');if(xsX)targetX=xsX} if(targetY=="bottom"||targetY=="top"){var thisWidth=obj.width();var thisHeight=obj.height();var css={left:(targetX?getPercentage(targetObj.width(),targetX):"0px"),'margin-left':'-'+(targetX?thisWidth/2:0)+'px','margin-top':'0px'};if(targetY=="bottom"){css.bottom="0"} if(targetY=="top"){css.top="0"}}else{var thisWidth=obj.width();var thisHeight=obj.height();var css={left:(targetX?getPercentage(targetObj.width(),targetX):"0px"),top:getPercentage(targetObj.height(),targetY),'margin-left':'-'+(targetX?thisWidth/2:0)+'px','margin-top':'-'+(targetY?thisHeight/2:0)+'px'}} obj.css(css)};var animateMe=function(){$(".animate-me,.reset-animate-me").each(function(){var $this=this;positionObj($this);if(!$($this).attr('id'))$($this).attr('id',cms.makeID());$(window).resize(function(){waitForFinalEvent(function(){positionObj($this);setTimeout(function(){positionObj($this)},500)},200,"id-"+$($this).attr('id'))})});$("[data-refHeight]").each(function(){var $this=this;var obj=$($this).attr('data-refHeight');var thisHeight="auto";if($(obj).length){thisHeight=$(obj).first().outerHeight()} $($this).height(thisHeight)});$("[data-flex-col]").each(function(){var totalCol=0;$(this).parent().children("[data-flex-col]").each(function(){var thisCol=parseInt($(this).attr('data-flex-col'));if(thisCol)totalCol+=thisCol});var othersHeight=0;$(this).parent().children().not("[data-flex-col]").not(".LoadingDiv").filter(function(){var position=$(this).css('position');return position!=='absolute'}).each(function(){othersHeight+=$(this).outerHeight()});var thisHeight=($(this).parent().height()-othersHeight)/totalCol*parseInt($(this).attr('data-flex-col'));$(this).height(thisHeight)});$("[data-flex-row]").each(function(){var totalCol=0;$(this).parent().children("[data-flex-row]").each(function(){var thisCol=parseInt($(this).attr('data-flex-row'));if(thisCol)totalCol+=thisCol});var othersWidth=0;$(this).parent().children().not("[data-flex-row]").not(".LoadingDiv").filter(function(){var position=$(this).css('position');return position!=='absolute'}).each(function(){othersWidth+=$(this).outerWidth()});var thisWidth=($(this).parent().width()-othersWidth)/totalCol*parseInt($(this).attr('data-flex-row'));$(this).width(thisWidth)})};var initBackstretchImage=function(){$("[data-backstretchImage]").each(function(){var imagePath=$(this).attr('data-backstretchImage');if(imagePath)$(this).resizeOrInitBackstretch(imagePath)});$("[data-xs-class],[data-sm-class],[data-md-class],[data-lg-class]").each(function(){var dataXS=$(this).attr('data-xs-class');var dataSM=$(this).attr('data-sm-class');var dataMD=$(this).attr('data-md-class');var dataLG=$(this).attr('data-lg-class');$(this).removeClass(dataXS);$(this).removeClass(dataSM);$(this).removeClass(dataMD);$(this).removeClass(dataLG);$(this).addClass(dataXS);if($(window).width()>=768){$(this).removeClass(dataXS);$(this).addClass(dataSM)} if($(window).width()>=992){$(this).removeClass(dataXS);$(this).removeClass(dataSM);$(this).addClass(dataMD)} if($(window).width()>=1200){$(this).removeClass(dataXS);$(this).removeClass(dataSM);$(this).removeClass(dataMD);$(this).addClass(dataLG)}})};$(document).bind("refHeightLoaded.positionObj",function(){$(document).unbind("refHeightLoaded.positionObj");animateMe();var callback=function(){initBackstretchImage()};callback();$(window).resize(function(){callback();setTimeout(callback,500)})});$(window).load(function(){if(!('noReFontSize' in window)){var f=cms.getCookie('font-size');if(f){$('a[rel='+f+']').addClass('fontSizeActive').siblings().removeClass('fontSizeActive');$.switchFontSize(f)}} $('.fontSizeM, .fontSizeL, .fontSizeEx').attr('href','javascript:void(0)').click(function(e){$('.fontSizeM, .fontSizeL, .fontSizeEx').removeClass("fontSizeActive");$.switchFontSize($(this).attr('rel'));$(this).addClass('fontSizeActive').siblings().removeClass('fontSizeActive')});if($(".scrollToObj").length){$('html, body').stop(!0).animate({scrollTop:$(".scrollToObj").offset().top},500)}});var fontChangeCall=!1;$.switchFontSize=function(fz){if(fontChangeCall)clearInterval(fontChangeCall);if(fz=="font-size-largest"||fz=="font-size-larger"){fontChangeCall=setInterval(runCallback,200)} cms.setCookie('font-size',fz);if('refHeight' in window)refHeight()};var isCtrl=!1;var isShift=!1;var adminLoginOpen=!1;function initAdminMode(){if("FRONTEND_IS_ADMIN" in window&&!FRONTEND_IS_ADMIN){$(document).keyup(function(e){if(e.which==17){isCtrl=!1} if(e.which==16){isShift=!1}});$(document).keydown(function(e){if(e.which==17){isCtrl=!0} if(e.which==16){isShift=!0} if(e.which==65&&isCtrl&&isShift&&adminLoginOpen===!1){adminLoginOpen=!0;console.log("Admin mode open");cmsPath=root_header_path;loadPopupForm('Admin Login',cmsPath+'cccframework/cccApp/getApp/?app=front-login&client_id='+CLIENT_ID,cmsPath+'|cccms/ucp/api/ucp-v1/login/front',"","modal-lg",function(thisApp,dialog){thisApp.onSave=function(data){if(data.status=="1"){cms.loadingDiv("body");$.ajax({url:root_header_path+'cccframework/admin-mode/',data:{token:data.data.token,user_id:data.data.user_id,},type:'GET',dataType:"json",error:function(data){cms.removeLoadingDiv("body")},success:function(data){cms.removeLoadingDiv("body");location.reload()}});dialog.close()}}},function(){adminLoginOpen=!1},!1,!0)}})}} function frontAdminLogout(){cms.loadingDiv("body");$.ajax({url:root_header_path+'cccframework/admin-mode/logout/',data:{},type:'GET',dataType:"json",error:function(data){cms.removeLoadingDiv("body")},success:function(data){location.reload();cms.removeLoadingDiv("body")}})} function enableTranslateMode(value){cms.loadingDiv("body");$.ajax({url:root_header_path+'cccframework/admin-mode/translate/',data:{mode:value},type:'GET',dataType:"json",error:function(data){cms.removeLoadingDiv("body")},success:function(data){location.reload();cms.removeLoadingDiv("body")}})} function enableSiteSetting(value){cms.loadingDiv("body");$.ajax({url:root_header_path+'cccframework/admin-mode/site-setting/',data:{mode:value},type:'GET',dataType:"json",error:function(data){cms.removeLoadingDiv("body")},success:function(data){location.reload();cms.removeLoadingDiv("body")}})} $(document).ready(function(){if("FRONTEND_LOGIN" in window&&FRONTEND_LOGIN){initAdminMode()}});function setupDatatable(obj,data,key){$(obj).data('datatable_settings',data);if(!key)key="dataTable";$(obj).data('datatable_key',key)} $(window).load(function(){$('.auto_datatable').each(function(){var thisTable=$(this);var dataTableSetting=$(this).data('datatable_settings');if(canDebug())console.log(dataTableSetting);$(thisTable).dataTable(dataTableSetting)})});if(jQuery.fn.dataTableExt)jQuery.fn.dataTableExt.oApi.fnGetColumnData=function(oSettings,iColumn,bUnique,bFiltered,bIgnoreEmpty){if(typeof iColumn=="undefined"){return[]} if(typeof bUnique=="undefined"){bUnique=!0} if(typeof bFiltered=="undefined"){bFiltered=!0} if(typeof bIgnoreEmpty=="undefined"){bIgnoreEmpty=!0} var aiRows;if(bFiltered===!0){aiRows=oSettings.aiDisplay} else{aiRows=oSettings.aiDisplayMaster} var asResultData=[];for(var i=0,c=aiRows.length;i-1){continue} else{asResultData.push(sValue)}} return asResultData};var initTooltipster=function(){$(".tooltipster").not(".tooltipstered").each(function(){var theme=$(this).attr("data-theme");if(canDebug())console.log('theme',theme);$(this).tooltipster({speed:200,animation:'grow',position:($(this).attr("data-position")?$(this).attr("data-position"):'top'),theme:(theme?theme:'tooltipster-shadow'),content:$(this).attr('data-title')});$(this).addClass(".tooltipstered")})};$(window).load(function(){initTooltipster()});function ajax_showStatusMessage(status_number){switch(status_number){default:case-1001:switch(Number(global_js_params.lang)){default:return '404 Error or Unstable Internet Connection';break;case 2:return '404 錯誤 或 網絡連接不穩定';break;case 3:return '404 错误 或 网络连接不稳定';break} break} return lang(status_number)} $.noty.defaults={layout:'top',theme:'defaultTheme',type:'alert',text:'',dismissQueue:!0,template:'
',animation:{open:{height:'toggle'},close:{height:'toggle'},easing:'swing',speed:500},timeout:!1,force:!1,modal:!1,maxVisible:5,killer:!1,closeWith:['click'],callback:{onShow:function(){},afterShow:function(){},onClose:function(){},afterClose:function(){},onCloseClick:function(){}},buttons:!1};$.noty.themes.bootstrapTheme={name:'bootstrapTheme',modal:{css:{position:'fixed',width:'100%',height:'100%',backgroundColor:'#000',zIndex:10000,opacity:0.6,display:'none',left:0,top:0}},style:function(){var containerSelector=this.options.layout.container.selector;this.$closeButton.append('Close');this.$closeButton.addClass('close');this.$bar.css('padding','10px');switch(this.options.type){case 'alert':case 'notification':this.$bar.css('background','#36AEEA');this.$bar.css('color','#fff');this.$bar.find(".noty_text").addClass("f15");break;case 'warning':this.$bar.css('background','#ff0000');this.$bar.css('color','#fff');this.$bar.find(".noty_text").addClass("f15");break;case 'error':break;case 'information':break;case 'success':break} this.$message.css({fontSize:'13px',lineHeight:'16px',textAlign:'center',width:'auto',position:'relative'})},callback:{onShow:function(){},onClose:function(){}}};$.noty.layouts.top={name:'top',options:{},container:{object:'
    ',selector:'ul#noty_top_layout_container',style:function(){$(this).css({top:0,left:'0%',position:'fixed',width:'100%',height:'auto',margin:0,padding:0,listStyleType:'none',zIndex:9999999})}},parent:{object:'
  • ',selector:'li',css:{}},css:{display:'none'},addClass:''};$(window).load(function(){});function showNotyWithText(str){noty({text:str,animation:{open:{height:'toggle'},close:{height:'toggle'},easing:'swing',speed:100},theme:'bootstrapTheme',timeout:2000})} function showErrorNotyWithText(str){noty({text:str,type:'warning',animation:{open:{height:'toggle'},close:{height:'toggle'},easing:'swing',speed:100},theme:'bootstrapTheme',timeout:2000})} var cccResize=function(){if($(".footerMinHeight").length){if($(".footerMinHeight").offset().top>$(window).height()){$(".footerMinHeight").hide()}else{$(".footerMinHeight").show();$(".footerMinHeight").height($(window).outerHeight()-$(".footerMinHeight").offset().top-$(".footerContainer").height()-50)}}};$(window).load(cccResize);$(window).bind("langLoaded",cccResize);$(window).resize(cccResize);function checkData(data){if(data.status==-9999){if(!$("html").hasClass("sessionError")){$("html").addClass("sessionError");BootstrapDialog.confirm(1,'info',lang('Notice'),lang('Your session has expired. Please log-in again.'),!0,{'callback':function(result){if(result){}else{}}},[],function(dialog){},function(dialog){},function(dialog){},function(dialog){location.reload()})}}} function init_page_cccms_v4(){if($('.cccmsv4_datatable').length){$('.cccmsv4_datatable').not(".datatable_loaded").each(function(){$('.cccmsv4_datatable').addClass("datatable_loaded");var thisTable=$(this);var dataTableSetting=$(this).data('datatable_settings');var dataTableKey=$(this).data('datatable_key');if(canDebug())console.log(dataTableSetting);var initDelBtnCallback=function(){$(thisTable).find('.delBtn').bind('click',function(){var api=$(this).attr("data-api");var uid=$(this).attr("data-ref-id");var row=$(this).parent().closest('tr');if($('#dialog').length){var t='';var confirmBtnTxt='';var cancelBtnTxt='';var contentTxt='';switch(Number(global_js_params.lang)){default:case 1:t='Delete Item';confirmBtnTxt='Confirm';cancelBtnTxt='Cancel';contentTxt='Are you sure to remove for this item ?
    All removal processes are irreversible.';break;case 2:t='移除項目';confirmBtnTxt='確定';cancelBtnTxt='取消';contentTxt='您是否確定移除此項目 ?
    所有帳戶一經移除,一律不設取消。';break;case 3:t='移除项目';confirmBtnTxt='确定';cancelBtnTxt='取消';contentTxt='您是否确定移除此项目 ?
    所有帐户一经移除,一律不设取消。';break} $("#dialog").html(contentTxt);$("#dialog").dialog({resizable:!1,open:function(){$('.ui-widget-overlay').hide().fadeIn();$('.ui-widget-overlay').bind('click',function(){$('#dialog').dialog('close')})},show:{effect:"clip",duration:200},hide:{effect:"clip",duration:200},autoOpen:!0,draggable:!1,width:'auto',modal:!0,closeOnEscape:!1,title:t,buttons:[{text:confirmBtnTxt,click:function(){$.ajax({url:local_url+'lib/ajax/'+api+'/remove/?uid='+uid,headers:{'X-Cccms-Key-Secret':$('#h').val()},data:$('form').serialize(),type:"POST",dataType:'json',beforeSend:function(msg){ajax_show_loading_mask(!0)},complete:function(msg){setTimeout(function(){ajax_show_loading_mask(!1)},500)},success:function(json_data){setTimeout(function(){$(thisTable).dataTable().fnDeleteRow(row)},500)},error:function(xhr,ajaxOptions,thrownError){}});$(this).dialog("close")}},{text:cancelBtnTxt,click:function(){$(this).dialog("close")}}]})}})};if(dataTableSetting)if('drawCallback' in dataTableSetting&&typeof dataTableSetting.drawCallback==="function"){var orgCallback=dataTableSetting.drawCallback;dataTableSetting.drawCallback=function(a){orgCallback(a);initDelBtnCallback(a)}}else{dataTableSetting.drawCallback=initDelBtnCallback} if(!window.dataTableGS)window.dataTableGS=[];dataTableGS[dataTableKey]=$(thisTable).dataTable(dataTableSetting)})}} $(window).load(init_page_cccms_v4);!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r} function r(n,t){return n<>>32-t} function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)} function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)} function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)} function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)} function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)} function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255);return r} function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))} function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t);return e} function v(n){return unescape(encodeURIComponent(n))} function m(n){return h(v(n))} function p(n){return g(m(n))} function s(n,t){return l(v(n),v(t))} function C(n,t){return g(s(n,t))} function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)} "function"==typeof define&&define.amd?define(function(){return A}):"object"==typeof module&&module.exports?module.exports=A:n.md5=A}(this);(function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory)}else if(typeof exports==='object'){module.exports=factory}else{factory(jQuery)}}(function($){var toFix=['wheel','mousewheel','DOMMouseScroll','MozMousePixelScroll'],toBind=('onwheel' in document||document.documentMode>=9)?['wheel']:['mousewheel','DomMouseScroll','MozMousePixelScroll'],slice=Array.prototype.slice,nullLowestDeltaTimeout,lowestDelta;if($.event.fixHooks){for(var i=toFix.length;i;){$.event.fixHooks[toFix[--i]]=$.event.mouseHooks}} var special=$.event.special.mousewheel={version:'3.1.12',setup:function(){if(this.addEventListener){for(var i=toBind.length;i;){this.addEventListener(toBind[--i],handler,!1)}}else{this.onmousewheel=handler} $.data(this,'mousewheel-line-height',special.getLineHeight(this));$.data(this,'mousewheel-page-height',special.getPageHeight(this))},teardown:function(){if(this.removeEventListener){for(var i=toBind.length;i;){this.removeEventListener(toBind[--i],handler,!1)}}else{this.onmousewheel=null} $.removeData(this,'mousewheel-line-height');$.removeData(this,'mousewheel-page-height')},getLineHeight:function(elem){var $elem=$(elem),$parent=$elem['offsetParent' in $.fn?'offsetParent':'parent']();if(!$parent.length){$parent=$('body')} return parseInt($parent.css('fontSize'),10)||parseInt($elem.css('fontSize'),10)||16},getPageHeight:function(elem){return $(elem).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};$.fn.extend({mousewheel:function(fn){return fn?this.bind('mousewheel',fn):this.trigger('mousewheel')},unmousewheel:function(fn){return this.unbind('mousewheel',fn)}});function handler(event){var orgEvent=event||window.event,args=slice.call(arguments,1),delta=0,deltaX=0,deltaY=0,absDelta=0,offsetX=0,offsetY=0;event=$.event.fix(orgEvent);event.type='mousewheel';if('detail' in orgEvent){deltaY=orgEvent.detail*-1} if('wheelDelta' in orgEvent){deltaY=orgEvent.wheelDelta} if('wheelDeltaY' in orgEvent){deltaY=orgEvent.wheelDeltaY} if('wheelDeltaX' in orgEvent){deltaX=orgEvent.wheelDeltaX*-1} if('axis' in orgEvent&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){deltaX=deltaY*-1;deltaY=0} delta=deltaY===0?deltaX:deltaY;if('deltaY' in orgEvent){deltaY=orgEvent.deltaY*-1;delta=deltaY} if('deltaX' in orgEvent){deltaX=orgEvent.deltaX;if(deltaY===0){delta=deltaX*-1}} if(deltaY===0&&deltaX===0){return} if(orgEvent.deltaMode===1){var lineHeight=$.data(this,'mousewheel-line-height');delta*=lineHeight;deltaY*=lineHeight;deltaX*=lineHeight}else if(orgEvent.deltaMode===2){var pageHeight=$.data(this,'mousewheel-page-height');delta*=pageHeight;deltaY*=pageHeight;deltaX*=pageHeight} absDelta=Math.max(Math.abs(deltaY),Math.abs(deltaX));if(!lowestDelta||absDelta=1?'floor':'ceil'](delta/lowestDelta);deltaX=Math[deltaX>=1?'floor':'ceil'](deltaX/lowestDelta);deltaY=Math[deltaY>=1?'floor':'ceil'](deltaY/lowestDelta);if(special.settings.normalizeOffset&&this.getBoundingClientRect){var boundingRect=this.getBoundingClientRect();offsetX=event.clientX-boundingRect.left;offsetY=event.clientY-boundingRect.top} event.deltaX=deltaX;event.deltaY=deltaY;event.deltaFactor=lowestDelta;event.offsetX=offsetX;event.offsetY=offsetY;event.deltaMode=0;args.unshift(event,delta,deltaX,deltaY);if(nullLowestDeltaTimeout){clearTimeout(nullLowestDeltaTimeout)} nullLowestDeltaTimeout=setTimeout(nullLowestDelta,200);return($.event.dispatch||$.event.handle).apply(this,args)} function nullLowestDelta(){lowestDelta=null} function shouldAdjustOldDeltas(orgEvent,absDelta){return special.settings.adjustOldDeltas&&orgEvent.type==='mousewheel'&&absDelta%120===0}}));function getFormBuilderData(id){return $("#textarea_"+id).val()} function setFormBuilderData(id,data){return $("#textarea_"+id).val(data)} function cccFormExportMatrix(obj){var data={};$(obj).closest('.matrixItem').find(".cccInput").each(function(){data[$(this).attr('cccdata-ref-name')]=$(this).val()}) BootstrapDialog.confirm(1,'info',lang('Exported Field Data'),"
    "+lang('Please Copy data.')+"

    ",!0,!0,{'callback':function(result){if(result){}else{}}},[{label:lang('Close'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}}],function(dialog){},function(dialog){},function(dialog){if(canDebug())console.log('onhide')},function(dialog){if(canDebug())console.log('onhidden')})} function cccFormExportImportMatrix(obj){var person=prompt("Please enter Field data");var data=JSON.parse(cms.cccApp.Base64.decode(person));$(obj).closest(".cccApp").trigger("cccApp",[function(thisApp){$.each(data,function(k,v){var thisObj=$(obj).closest('.matrixItem').find("[cccdata-ref-name='"+k+"']");if(thisObj.length){thisApp.objVal(thisObj,v)}})}]);$(obj).closest('.matrixItem').find(".cccInput").each(function(){data[$(this).attr('cccdata-ref-name')]=$(this).val()})} var cccFormRecaptchaLoaded=!1;var cccFormRecaptcha=function(){cccFormRecaptchaLoaded=!0;$(document).trigger('cccFormRecaptchaLoaded')};var loadRecaptcha=function(thisApp){$(thisApp.obj).find(".ccc-grecaptcha").not(".ccc-grecaptcha-init").each(function(){var $this=this;$($this).addClass('ccc-grecaptcha-init');var id=$($this).attr('id');id=id.split('_');id=id[1];if(id){cms.grecaptcha[id]=function(){if($($this).attr('sitekey')){var thisCaptcha=grecaptcha.render('grecaptcha_'+id,{'sitekey':$($this).attr('sitekey'),'callback':function(response){$("#"+id).val(response);formChecking(thisApp,!1,!1,$('[cccdata-cccapp-id="'+id+'"]').find("#"+id))}});$(document).unbind("cccApp_"+thisApp.appID+"_reset_grecaptcha.field_"+id).bind("cccApp_"+thisApp.appID+"_reset_grecaptcha.field_"+id,function(){grecaptcha.reset(thisCaptcha);$("#"+id).val('')});if($($this).hasClass('ccc-grecaptcha-fullwidth')){var callback=function(){var scale=1;if($(window).width()<768){var width=$('#grecaptcha_'+id).parent().width();scale=width/302} $('#grecaptcha_'+id).css('transform','scale('+scale+')');$('#grecaptcha_'+id).css('-webkit-transform','scale('+scale+')');$('#grecaptcha_'+id).css('transform-origin','0 0');$('#grecaptcha_'+id).css('-webkit-transform-origin','0 0')};callback();$(window).resize(function(){callback()})}}else{$($this).html("Please setup sitekey for Google reCAPTCHA")}};if(cccFormRecaptchaLoaded){cms.grecaptcha[id]()}else{$(document).bind('cccFormRecaptchaLoaded',cms.grecaptcha[id])}}})};function getBase64(file){cms.loadingDiv($(file).closest(".formItem"));var textarea=$(file).closest(".formItem").find("textarea.cccInput");var obj=$(file);file=file.files[0];try{var reader=new FileReader();reader.readAsDataURL(file);reader.onload=function(){cms.removeLoadingDiv($(textarea).closest(".formItem"));$(obj).next(".base64UploadLabel").addClass('upload-success').find(".cccFormIcon").removeClass("hidden").filter(".cccappicon-upload").addClass('hidden').parent().find(".uploadLabelText").addClass("hidden").last().text(file.name).removeClass("hidden");textarea.val(reader.result).triggerHandler("change")};reader.onerror=function(error){$(obj).parent().get(0).reset();cms.removeLoadingDiv($(textarea).closest(".formItem"));cms.cccApp.error($(file).closest(".cccApp"),error)}}catch(e){cms.removeLoadingDiv($(textarea).closest(".formItem"))}} var onchangeCaseCheck=function(obj,thisApp){var onchangecallback=$(obj).closest(".formItem").attr('cccdata-onchange-callback');if(onchangecallback){var fn=new Function("obj","thisApp",thisApp.Base64.decode(onchangecallback));fn(obj,thisApp)}};$(document).on('focusin',function(e){if($(e.target).closest(".mce-window").length){e.stopImmediatePropagation()}});(function(){var $,__indexOf=[].indexOf||function(item){for(var i=0,l=this.length;i=0){_results.push(card)}} return _results})();for(_j=0,_len1=_ref1.length;_j<_len1;_j++){card_type=_ref1[_j];if(number.match(card_type.pattern)){return card_type}} return null};is_valid_luhn=function(number){var digit,n,sum,_j,_len1,_ref1;sum=0;_ref1=number.split('').reverse();for(n=_j=0,_len1=_ref1.length;_j<_len1;n=++_j){digit=_ref1[n];digit=+digit;if(n%2){digit*=2;if(digit<10){sum+=digit}else{sum+=digit-9}}else{sum+=digit}} return sum%10===0};is_valid_length=function(number,card_type){var _ref1;return _ref1=number.length,__indexOf.call(card_type.valid_length,_ref1)>=0};validate_number=(function(_this){return function(number){var length_valid,luhn_valid;card_type=get_card_type(number);luhn_valid=!1;length_valid=!1;if(card_type!=null){luhn_valid=is_valid_luhn(number);length_valid=is_valid_length(number,card_type)} return{card_type:card_type,valid:luhn_valid&&length_valid,luhn_valid:luhn_valid,length_valid:length_valid}}})(this);validate=(function(_this){return function(){var number;number=normalize($(_this).val());return validate_number(number)}})(this);normalize=function(number){return number.replace(/[ -]/g,'')};if(!bind){return validate()} this.on('input.jccv',(function(_this){return function(){$(_this).off('keyup.jccv');return callback.call(_this,validate())}})(this));this.on('keyup.jccv',(function(_this){return function(){return callback.call(_this,validate())}})(this));callback.call(this,validate());return this}}).call(this);if(!$("html").hasClass("ie8")){(function(c){try{document.createEvent("TouchEvent");return}catch(f){} var d={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};var a=function(){for(var e in d){document.body.addEventListener(e,function(i){var h=b(d[i.type],i);i.target.dispatchEvent(h);var g=i.target["on"+d[i.type]];if(typeof g==="function"){g(i)}},!1)}};var b=function(g,i){var h=document.createEvent("MouseEvents");h.initMouseEvent(g,i.bubbles,i.cancelable,i.view,i.detail,i.screenX,i.screenY,i.clientX,i.clientY,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.button,i.relatedTarget);return h};if(document.readyState==="complete"||document.readyState==="loaded"){a()}else{c.addEventListener("load",a,!1)}})(window)};(function($,window,undefined){'use strict';$.fn.resizeOrInitBackstretch=function(images,options){return this.each(function(){var obj=$(this);if($(obj).hasClass("backstretched")){$(obj).trigger("backstretchResize")}else{if(images){$(obj).backstretch(images,options);$(obj).addClass("backstretched")}}})};$.fn.backstretch=function(images,options){if(images===undefined||images.length===0){return this} if($(window).scrollTop()===0){window.scrollTo(0,0)} return this.each(function(){var $this=$(this),obj=$this.data('backstretch');if(obj){if(typeof images=='string'&&typeof obj[images]=='function'){obj[images](options);return} options=$.extend(obj.options,options);obj.destroy(!0)} obj=new Backstretch(this,images,options);$this.data('backstretch',obj)})};$.backstretch=function(images,options){return $('body').backstretch(images,options).data('backstretch')};$.expr[':'].backstretch=function(elem){return $(elem).data('backstretch')!==undefined};$.fn.backstretch.defaults={centeredX:!0,centeredY:!0,duration:5000,fade:0};var styles={wrap:{left:0,top:0,overflow:'hidden',margin:0,padding:0,height:'100%',width:'100%',zIndex:-999999},img:{position:'absolute',display:'none',margin:0,padding:0,border:'none',width:'auto',height:'auto',maxHeight:'none',maxWidth:'none',zIndex:-999999}};var Backstretch=function(container,images,options){this.options=$.extend({},$.fn.backstretch.defaults,options||{});this.images=$.isArray(images)?images:[images];$.each(this.images,function(){$('')[0].src=this});this.isBody=container===document.body;this.$container=$(container);this.$root=this.isBody?supportsFixedPosition?$(window):$(document):this.$container;var $existing=this.$container.children(".backstretch").first();this.$wrap=$existing.length?$existing:$('
    ').css(styles.wrap).appendTo(this.$container);if(!this.isBody){var position=this.$container.css('position'),zIndex=this.$container.css('zIndex');this.$container.css({position:position==='static'?'relative':position,zIndex:zIndex==='auto'?0:zIndex,background:'none'});this.$wrap.css({zIndex:-999998})} this.$wrap.css({position:this.isBody&&supportsFixedPosition?'fixed':'absolute'});this.index=0;this.show(this.index);this.id=cms.makeID();var $this=this;$(container).bind("backstretchResize",function(){$this.resize()});$(window).bind('resize.backstretch-'+this.id,this.resize).bind('orientationchange.backstretch-'+this.id,function(){if($this.isBody&&window.pageYOffset===0){window.scrollTo(0,1);$this.resize()}})};Backstretch.prototype={resize:function(){try{var bgCSS={left:0,top:0},rootWidth=this.isBody?this.$root.width():this.$root.innerWidth(),bgWidth=rootWidth,rootHeight=this.isBody?(window.innerHeight?window.innerHeight:this.$root.height()):this.$root.innerHeight(),bgHeight=bgWidth/this.$img.data('ratio'),bgOffset;if(bgHeight>=rootHeight){bgOffset=(bgHeight-rootHeight)/2;if(this.options.centeredY){bgCSS.top='-'+bgOffset+'px'}}else{bgHeight=rootHeight;bgWidth=bgHeight*this.$img.data('ratio');bgOffset=(bgWidth-rootWidth)/2;if(this.options.centeredX){bgCSS.left='-'+bgOffset+'px'}} this.$wrap.css({width:rootWidth,height:rootHeight}).find('img:not(.deleteable)').css({width:bgWidth,height:bgHeight}).css(bgCSS)}catch(err){} return this},show:function(newIndex){if(Math.abs(newIndex)>this.images.length-1){return} var self=this,oldImage=self.$wrap.find('img').addClass('deleteable'),evtOptions={relatedTarget:self.$container[0]};self.$container.trigger($.Event('backstretch.before',evtOptions),[self,newIndex]);this.index=newIndex;clearInterval(self.interval);self.$img=$('').css(styles.img).bind('load',function(e){var imgWidth=this.width||$(e.target).width(),imgHeight=this.height||$(e.target).height();$(this).data('ratio',imgWidth/imgHeight);$(this).fadeIn(self.options.speed||self.options.fade,function(){oldImage.remove();if(!self.paused){self.cycle()} $(['after','show']).each(function(){self.$container.trigger($.Event('backstretch.'+this,evtOptions),[self,newIndex])})});self.resize()}).error(function(){$(['error']).each(function(){self.$container.trigger($.Event('backstretch.'+this,evtOptions),[self,newIndex])})}).appendTo(self.$wrap);self.$img.attr('src',self.images[newIndex]);return self},next:function(){return this.show(this.index1){clearInterval(this.interval);this.interval=setInterval($.proxy(function(){if(!this.paused){this.next()}},this),this.options.duration)} return this},destroy:function(preserveBackground){$(window).unbind('resize.backstretch-'+this.id);$(window).unbind('orientationchange.backstretch-'+this.id);clearInterval(this.interval);if(!preserveBackground){this.$wrap.remove()} this.$container.removeData('backstretch')}};var supportsFixedPosition=(function(){var ua=navigator.userAgent,platform=navigator.platform,wkmatch=ua.match(/AppleWebKit\/([0-9]+)/),wkversion=!!wkmatch&&wkmatch[1],ffmatch=ua.match(/Fennec\/([0-9]+)/),ffversion=!!ffmatch&&ffmatch[1],operammobilematch=ua.match(/Opera Mobi\/([0-9]+)/),omversion=!!operammobilematch&&operammobilematch[1],iematch=ua.match(/MSIE ([0-9]+)/),ieversion=!!iematch&&iematch[1];return!(((platform.indexOf("iPhone")>-1||platform.indexOf("iPad")>-1||platform.indexOf("iPod")>-1)&&wkversion&&wkversion<534)||(window.operamini&&({}).toString.call(window.operamini)==="[object OperaMini]")||(operammobilematch&&omversion<7458)||(ua.indexOf("Android")>-1&&wkversion&&wkversion<533)||(ffversion&&ffversion<6)||("palmGetResource" in window&&wkversion&&wkversion<534)||(ua.indexOf("MeeGo")>-1&&ua.indexOf("NokiaBrowser/8.5.0")>-1)||(ieversion&&ieversion<=6))}())}(jQuery,window));(function(original){jQuery.fn.clone=function(){var result=original.apply(this,arguments),my_textareas=this.find('textarea').add(this.filter('textarea')),result_textareas=result.find('textarea').add(result.filter('textarea')),my_selects=this.find('select').add(this.filter('select')),result_selects=result.find('select').add(result.filter('select'));for(var i=0,l=my_textareas.length;i0){wysiwygPendingTimer=setTimeout(function(){var newList=[];$(wysiwygPending).each(function(k,v){if($(this).length){if($(this).is(":in-viewport")){wysiwygCallback(this);if($(this).hasClass('wysiwygInit')||$(this).hasClass('wysiwyged')){delete wysiwygPending[k]}}}else{delete wysiwygPending[k]}}) wysiwygPending=wysiwygPending.filter(function(v){return v!=undefined});checkPendingWysiwyg()},500)}};function getRandomArbitrary(min,max){return Math.random()*(max-min)+min} var checkSelect=function(thisApp){setTimeout(function(){var group=$(thisApp);var notSelectinit=group.find('.selectpicker').not(".coreTpl").not(".selectinit");var objs=group.filter(":visible").find('.selectpicker').not(".coreTpl").not(".selectinit").filter(":in-viewport");if(objs.length){if(cms.cccApp.isMobile()){objs.selectpicker('mobile')}else{objs.selectpicker()} objs.addClass("selectinit");group.find('.selectpicker.selectinit').selectpicker('refresh')}else if(notSelectinit.length){checkSelect(selectGroup)}},getRandomArbitrary(500,1000))};var formSelect=function(thisApp){$(".isListener").not(".linked").each(function(){if(!$(this).closest(".coreTpl").length){var $this=this;$($this).addClass("linked");var targetField=$(this).attr('cccdata-link-to-field');var targetFormItem=$(this).closest(".cccApp").find(".formItem_"+targetField).find(".cccInput");if(targetFormItem.length){var thisCallback=function(){var v=$(targetFormItem).val();selectObjVal($this,v,!0)};$(targetFormItem).bind("cccInputChange.cccListener",thisCallback);thisCallback()}}});loadRecaptcha(thisApp);waitForFinalEvent(function(){$(thisApp.obj).find("[cccdata-subtext]").each(function(){$(this).data('subtext',$(this).attr('cccdata-subtext'))}) $(thisApp.obj).find(".isDatetime").not(".dated").each(function(){if($(this).closest(".coreTpl").length)return;$(this).addClass("dated");var options=$(this).siblings('textarea.dateTimeSettings').text();if(options){options=$.parseJSON($.trim(options))}else{options={}} if($(this).val())options.date=$(this).val();$(this).datetimepicker($.extend({format:'YYYY-MM-DD HH:mm:ss'},options))});$(thisApp.obj).find(".isColor").not(".colored").each(function(){if($(this).closest(".coreTpl").length)return;$(this).addClass("colored");var options=$(this).siblings('textarea.colorSettings').text();if(options){options=$.parseJSON($.trim(options))}else{options={}} $(this).colorpicker($.extend(options,{}))});$(thisApp.obj).find(".isMapPicker").not(".mapPickered").filter(":visible").each(function(){if($(this).closest(".coreTpl").length)return;$(this).addClass("mapPickered");var $this=$(this);var options=$(this).siblings('textarea.mapOptions').text();if(options){options=$.parseJSON($.trim(options))}else{options={}} var map=$(this).parent().find(".cccMapplic");var init=!1;map.bind('positionchanged mapready',function(){if(!init){var getMapplicOptions=$this.parent().find(".mapplic-map-image").find("[display='none']");if(getMapplicOptions.length){init=!0;$.each(getMapplicOptions,function(k,v){var div=$("
    "+($(v).attr('id')?$(v).attr('id').replace('_x26_',' & '):$(v).attr('id'))+"
    ");if($(v).attr('id')==$this.val()){$(v).attr('display','block').attr('clicked','true')} div.click(function(){$this.val($(v).attr('id'));$(getMapplicOptions).attr('display','none');$(getMapplicOptions).removeAttr('clicked');$(v).attr('display','block').attr('clicked','true')});div.hover(function(){$(getMapplicOptions).attr('display','none');$(v).attr('display','block')},function(){$(getMapplicOptions).attr('display','none');$(getMapplicOptions).filter('[clicked="true"]').attr('display','block')});$this.parent().find(".cccMapplicControl").append(div)})} if(options.case){var getMapplicOptions=$this.parent().find(".mapplic-map-image").find(options.case);if(getMapplicOptions.length){init=!0;$.each(getMapplicOptions,function(k,v){var div=$("
    "+($(v).attr('id')?$(v).attr('id').replace('_x26_',' & '):$(v).attr('id'))+"
    ");if($(v).attr('id')==$this.val()){$(v).attr('display','block').attr('clicked','true')} div.click(function(){$this.val($(v).attr('id'));$(getMapplicOptions).removeAttr('clicked');$(getMapplicOptions).attr('fill',options.fillColor) $(v).attr('fill','#0078e5').attr('clicked','true');$(v).attr('style','fill:#FF0000!important');$(v).children().attr('style','fill:#FF0000!important')});div.hover(function(){$(v).attr('fill','#0078e5');$(v).attr('style','fill:#FF0000!important');$(v).children().attr('style','fill:#FF0000!important')},function(){$(v).attr('fill',options.fillColor);$(v).removeAttr('style');$(v).children().removeAttr('style');$(getMapplicOptions).filter('[clicked="true"]').attr('fill','#0078e5')});$this.parent().find(".cccMapplicControl").append(div)})} $this.parent().find(".cccMapplicControl").append($("
    "))}}});map.mapplic($.extend(options,{}))});$(thisApp.obj).find(".isDate").not(".dated").each(function(){if($(this).closest(".coreTpl").length)return;$(this).addClass("dated");var options=$(this).siblings('textarea.dateTimeSettings').text();if(options){options=$.parseJSON($.trim(options))}else{options={}} if($(this).val())options.date=moment($(this).val(),'YYYY-MM-DD');$(this).datetimepicker($.extend({format:'YYYY-MM-DD'},options))});$(thisApp.obj).find(".isTime").not(".dated").each(function(){if($(this).closest(".coreTpl").length)return;$(this).addClass("dated");var options=$(this).siblings('textarea.dateTimeSettings').text();if(options){options=$.parseJSON($.trim(options))}else{options={}} if($(this).val())options.date=moment($(this).val(),'HH:mm:ss');$(this).datetimepicker($.extend({format:'HH:mm:ss'},options))});$(thisApp.obj).find(".wysiwyg").not(".wysiwyged").not(".wysiwygInit").each(function(){});if(cms.cccApp.isMobile()){$(".selectGroup").find('.selectpicker').not(".coreTpl").not(".selectinit").selectpicker('mobile')}else{$(".selectGroup").find('.selectpicker').not(".coreTpl").not(".selectinit").selectpicker()} $(".selectGroup").find('.selectpicker').not(".coreTpl").not(".selectinit").addClass("selectinit");$(".selectGroup").find('.selectpicker.selectinit').selectpicker('refresh');$(document).unbind("changeLang").bind("changeLang",function(){$(".selectGroup").find('.selectpicker.selectinit').selectpicker('refresh')});$(thisApp.obj).find(".toggleBeautiful").not(".coreTpl").not(".toggleinit").each(function(){var $this=$(this);$($this).switchy();var selectGroup=$($this).closest(".selectGroup");$($this).off('change.switchy').on('change.switchy',function(){var $this=$(this);setTimeout(function(){var bgColor='#CCCCCC';if($($this).val()=='On'){bgColor='#8895B4';if($this.attr('cccdata-on-color'))bgColor=$this.attr('cccdata-on-color');var onTextColor=bgColor;if($this.attr('cccdata-on-text-color'))onTextColor=$this.attr('cccdata-on-text-color');$(selectGroup).find(".onLabel").css("color",onTextColor).show();$(selectGroup).find(".offLabel").hide()}else if($($this).val()=='Off'){bgColor='#BBBBBB';if($this.attr('cccdata-off-color'))bgColor=$this.attr('cccdata-off-color');var offTextColor=bgColor;if($this.attr('cccdata-off-text-color'))offTextColor=$this.attr('cccdata-off-text-color');$(selectGroup).find(".offLabel").css("color",offTextColor).show();$(selectGroup).find(".onLabel").hide();$(selectGroup).find(".offLabel").show()} $($this).parent().find(".switchy-container").removeClass('toggle-On toggle-Off').addClass('toggle-'+$($this).val());$($this).parent().find(".switchy-bar").stop(!0).animate({backgroundColor:bgColor})},1)});$($this).triggerHandler('change.switchy');if($this.closest(".cccApp").hasClass("isPreviewAppInit")){$(thisApp.obj).find(".fileUploadOverlay,[type=file],[type=radio],.bootstrap-select,.matrixBtn,.toggleLabel,.switchy-container").remove();return!1}});$(thisApp.obj).find(".tooltipster").not(".tooltipstered").each(function(){var theme=$(this).attr("cccdata-theme");if(canDebug())console.log('theme',theme);$(this).tooltipster({speed:200,contentAsHTML:!0,animation:'grow',position:'top',theme:(theme?theme:'tooltipster-shadow'),content:$(this).attr('cccdata-title')});$(this).addClass(".tooltipstered")});if('refHeight' in window){refHeight()} var resizerCallback=function(obj){$(obj).closest(".cccApp").trigger("cccApp",[function(thisApp){var widthRatio=(thisApp.settings&&'imageHolderWidthRatio' in thisApp.settings?thisApp.settings.imageHolderWidthRatio:0);var heightRatio=(thisApp.settings&&'imageHolderHeightRatio' in thisApp.settings?thisApp.settings.imageHolderHeightRatio:0);if(widthRatio!==!1&&heightRatio!==!1){var newHeight=$(obj).width()/widthRatio*heightRatio;$(obj).height(newHeight)}}])};$(thisApp.obj).find(".tempImageHolder .uploadLabel").not(".initResizer").each(function(){var $this=this;$($this).addClass("initResizer");resizerCallback($this);var id=cms.makeID();$(window).on("resize.cccAppResizer_"+thisApp.appID,function(){waitForFinalEvent(function(){resizerCallback($this)},200,"cccAppResizer-"+id)})})},(!thisApp?50:(thisApp.disableBinding?1000:50)),"formSelect-"+thisApp.uniqueId)};function CCC_get_utf8_word_count_CHINESE_ONLY(str){var $UTF8_CHINESE_PATTERN=/[\u4e00-\u9fff\uf900-\ufaff]/g;var $UTF8_SYMBOL_PATTERN=/[\uff00-\uffef\u2000-\u206F]/g;str=str.replace($UTF8_SYMBOL_PATTERN,"");if(str){var matches=str.match($UTF8_CHINESE_PATTERN);if(matches)return(matches).length} return 0} function CCC_get_utf8_word_count(str){var $UTF8_CHINESE_PATTERN=/[\u4e00-\u9fff\uf900-\ufaff]/g;var $UTF8_SYMBOL_PATTERN=/[\uff00-\uffef\u2000-\u206F]/g;str=str.replace($UTF8_SYMBOL_PATTERN,"");var nonChinese=str.replace($UTF8_CHINESE_PATTERN,"");var matches;if(nonChinese){matches=nonChinese.split(" ")} return CCC_get_utf8_word_count_CHINESE_ONLY(str)+(matches?matches.length:0)} function countCharacters(obj,thisApp,textarea,check,disableAbort){if(check&&$(obj).attr('cccdata-characterscount')){if(thisApp.wordCountTimer&&!disableAbort)clearTimeout(thisApp.wordCountTimer);thisApp.wordCountTimer=setTimeout(function(){$(obj).data('characterscount',$(obj).val().length);formChecking(thisApp,!1,!1,obj)},100)}else{if(canDebug())console.log('checking')} return($(obj).data('characterscount')?$(obj).data('characterscount'):0)} function countWords(obj,thisApp,textarea,check,disableAbort){if(check&&$(obj).attr('cccdata-wordcount')){if(thisApp.wordCount&&!disableAbort)thisApp.wordCount.abort();if(thisApp.wordCountTimer&&!disableAbort)clearTimeout(thisApp.wordCountTimer);thisApp.wordCountTimer=setTimeout(function(){thisApp.wordCount=$.ajax({type:'POST',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:{str:$(obj).val(),h:$(thisApp.obj).find('#h').val()},dataType:'json',url:cccframework_path+'cccForm/wordcount/',success:function(d){if(canDebug())console.log(textarea);if(textarea)textarea.text(d.word);$(obj).data('wordcount',d.word);formChecking(thisApp,!1,!1,obj)}})},100)}else{if(canDebug())console.log('checking')} return($(obj).data('wordcount')?$(obj).data('wordcount'):0)} var onChangeInsertValue=function(obj,switchObj,enableChecker,skipToggle,disableRemoveValue,parentObj){if(canDebug())console.log(obj,switchObj,enableChecker);switch(switchObj){case 'checkbox':var values=[];$.each($(obj).closest(".checkboxGroup").find("input[type=checkbox]").filter(":checked"),function(){if($(this).val())values.push($(this).val())});if(values.length){values="|||"+values.join("||")+"|||"}else{values=""} $(obj).closest(".checkboxGroup").find("input.cccInput").val(values).trigger("change");if(enableChecker){if(canDebug())console.log('enableChecker');onChangeChecker(obj,'checked',!1,disableRemoveValue,parentObj)} break;case 'select':$(obj).closest(".selectGroup").find("input.cccInput").val($(obj).val()).trigger("change").trigger("cccInputChange");if(enableChecker){if(canDebug())console.log('enableChecker');onChangeChecker(obj,'selected',!1,disableRemoveValue,parentObj)} break;case 'radio':$(obj).closest(".radioGroup").find("input.cccInput").val($(obj).closest(".radioGroup").find("input[type=radio]").filter(":checked").val()).trigger("change");if(enableChecker){if(canDebug())console.log('enableChecker');onChangeChecker(obj,'checked',!1,disableRemoveValue,parentObj)} break}};var getErrorMessage=function(thisApp,str,replace,obj){var errorMsg,customSettings={},globalSettings={},settings={};if(thisApp.settings)globalSettings=thisApp.settings.errorMessage;if(obj){errorMsg=$(obj).data('errorMessage');if(!errorMsg){var customErrorData=$(obj).closest(".formItem").find(".customErrorMessage").first().val();customSettings=$.parseJSON(customErrorData)}} settings=$.extend(settings,globalSettings,customSettings);if(str in settings){str=settings[str]} if(replace){$.each(replace,function(k,v){str=str.replace('{'+k+'}',v)})} return str};var inputStyleChecking=function(thisApp,obj){if($(obj).val()){$(obj).closest(".selectGroup").addClass("hasText");$(obj).addClass("hasText")}else{$(obj).closest(".selectGroup").removeClass("hasText");$(obj).removeClass("hasText")}};var addhttp=function(url){if(!/^(?:f|ht)tps?\:\/\//.test(url)){url="http://"+url} return url};var regexChecking=function(thisApp,v,check,error,thisCase){if(canDebug())console.log('regexChecking');var settings=$(v).data("regexChecking");if(canDebug())console.log('settings',settings);if(settings){$.each(settings,function(type,regexList){$.each(regexList,function(key,regex){if(check&&canDebug())console.log('type',type);if(check&&canDebug())console.log('regex.regex',regex.regex);if(check&&canDebug())console.log('check',check);if(check){switch(type){case "value-checking":if(check!=regex.regex){error.push({obj:v,errMsg:type,displayMsg:(regex.isGetErrMsg?getErrorMessage(thisApp,regex.errMsg):regex.errMsg)});check=!1} break;case "callback":var callbackName=regex.regex;if(callbackName in window){if(!window[callbackName](check)){error.push({obj:v,errMsg:type,displayMsg:(regex.isGetErrMsg?getErrorMessage(thisApp,regex.errMsg):regex.errMsg)});check=!1}}else{error.push({obj:v,errMsg:type,displayMsg:getErrorMessage(thisApp,'errorCheckingCallbackFunction')});check=!1} break;case "check-id":if(!($(v).val()==$("#"+regex.regex).val())){error.push({obj:v,errMsg:type,displayMsg:(regex.isGetErrMsg?getErrorMessage(thisApp,regex.errMsg):regex.errMsg)});check=!1} break;case "check-field":if(!($(v).val()==$(v).closest(".cccApp").find("input[name='"+regex.regex+"']").val())){error.push({obj:v,errMsg:type,displayMsg:(regex.isGetErrMsg?getErrorMessage(thisApp,regex.errMsg):regex.errMsg)});check=!1} break;default:var re=new RegExp(regex.regex,regex.flag);if(!re.test(check)){error.push({obj:v,errMsg:type,displayMsg:(regex.isGetErrMsg?getErrorMessage(thisApp,regex.errMsg):regex.errMsg)});check=!1}}}})})} if(check){if($(v).closest(".cccCC").length){var cardCheck=!0;var cardError='';var ccType=$(v).closest(".cccCC").attr('ccType');var str='';$(v).closest(".cccCC").find(".cccCardNumber").each(function(){str+=$(this).val()});var result=$("").val(str).validateCreditCard({accept:[ccType]});if(result.card_type){if(result.card_type.name!=ccType){cardCheck=!1;cardError='card-type-error'}}else{cardCheck=!1;cardError='card-type-error'} if(cardCheck&&!result.length_valid){cardCheck=!1;cardError='card-length-invalid'} if(cardCheck&&!result.luhn_valid){cardCheck=!1;cardError='card-luhn-invalid'} if(cardCheck&&!result.valid){cardCheck=!1;cardError='card-invalid'} if(!cardCheck){error.push({obj:v,errMsg:'cardChecking',displayMsg:getErrorMessage(thisApp,cardError)});check=!1}}} return check};var formChecking=function(thisApp,obj,pass,onlyThisObj,isScroll,textareaCheck){var findObj=$(thisApp.obj);if(obj)findObj=$(thisApp.obj).find(obj).closest(".tab-pane");var finalCheck=!0;var formItem=$(findObj).find(".formItem:not(.hidden)").find(".cccInput");var error=[];if(onlyThisObj){formItem=[];var targetObjs=[];$(onlyThisObj).each(function(){if($(this).closest(".formItem.cccChecked").find(".cccInput").length){targetObjs.push($(this).closest(".formItem.cccChecked").find(".cccInput"))}});if(targetObjs.length>0)formItem=targetObjs} if(obj){$.each($(findObj).find(".matrixGroup").filter(":visible"),function(k,v){formItem.push(v)})} $.each(formItem,function(k,v){if(v){if(($(v).closest(".formItem").hasClass("cccRequired")&&$(v).closest(".formItem").is(":visible"))||($(v).closest(".matrixItem").hasClass("matrixRequired")&&$(v).closest(".matrixItem").is(":visible"))||($(v).val()!=""&&$(v).is(":visible"))){var allObj;if($(v).val()){allObj=$(v)}else{allObj=$(v).closest(".formItem.cccRequired").filter(":visible").find(".cccInput")} if(allObj.length>=1){var check=!1;if(allObj.length==1){var settings=$(v).data("regexChecking");if(settings===undefined||!settings){if($(v).siblings(".regexChecking").length){settings=$.parseJSON($.trim($(v).siblings(".regexChecking").first().val()));if(settings===undefined||!settings){settings={}} if(settings)$(v).data("regexChecking",settings)}} check=$(v).val();if(check){if($(v).is("input")){switch($(v).attr("type")){case "url":if(!$(this).data("hasfocus")){$(v).val(addhttp(check))} if(check&&!$.isEmptyObject(settings)&&!$(v).hasClass("skipChecking")){if(!regexChecking(thisApp,v,check,error,1))check=!1} break;case "password":if(!$.isEmptyObject(settings)&&!$(v).hasClass("skipChecking")){if(!regexChecking(thisApp,v,check,error,1))check=!1}else{var re=/^[a-zA-Z0-9-_\~\!\@\#\$\%\^\&\*\(\)]{8,}$/i;if(!re.test(check)&&!$(v).hasClass("skipChecking")){error.push({obj:v,errMsg:'password',displayMsg:getErrorMessage(thisApp,'password',!1,v)});check=!1}} break;case "tel":break;case "email":case "hidden":case "text":var checkWordCount=$(v).attr("cccdata-wordcount");var checkWordCountMessage=$(v).attr("cccdata-wordcount-message");var checkWordCountMin=$(v).attr("cccdata-wordcount-min");var countWord=countWords($(v),thisApp,!1,textareaCheck);var checkCharactersCount=$(v).attr("cccdata-characterscount");var countCharacter=countCharacters($(v),thisApp,!1,textareaCheck);if((!checkWordCountMin&&checkWordCount&&parseInt(countWord)>parseInt(checkWordCount))||((checkWordCountMin&&parseInt(countWord)parseInt(checkWordCount)))){if(checkWordCountMessage){error.push({obj:v,errMsg:'textarea-wordcount',displayMsg:checkWordCountMessage})}else{error.push({obj:v,errMsg:'textarea-wordcount',displayMsg:getErrorMessage(thisApp,'wordcount',{'NUM':checkWordCount},v)})} check=!1}else if(checkCharactersCount&&parseInt(countCharacter)>parseInt(checkCharactersCount)){error.push({obj:v,errMsg:'textarea-characterscount',displayMsg:getErrorMessage(thisApp,'characters_count',{'NUM':checkCharactersCount},v)});check=!1}else if(check&&!$.isEmptyObject(settings)&&!$(v).hasClass("skipChecking")){if(!regexChecking(thisApp,v,check,error,1))check=!1} break}}else if($(v).is("textarea")){var checkWordCount=$(v).attr("cccdata-wordcount");var checkWordCountMessage=$(v).attr("cccdata-wordcount-message");var checkWordCountMin=$(v).attr("cccdata-wordcount-min");var countWord=countWords($(v),thisApp,!1,textareaCheck);var checkCharactersCount=$(v).attr("cccdata-characterscount");var countCharacter=countCharacters($(v),thisApp,!1,textareaCheck);if((!checkWordCountMin&&checkWordCount&&parseInt(countWord)>parseInt(checkWordCount))||((checkWordCountMin&&parseInt(countWord)parseInt(checkWordCount)))){if(checkWordCountMessage){error.push({obj:v,errMsg:'textarea-wordcount',displayMsg:checkWordCountMessage})}else{error.push({obj:v,errMsg:'textarea-wordcount',displayMsg:getErrorMessage(thisApp,'wordcount',{'NUM':checkWordCount},v)})} check=!1}else if(checkCharactersCount&&parseInt(countCharacter)>parseInt(checkCharactersCount)){error.push({obj:v,errMsg:'textarea-characterscount',displayMsg:getErrorMessage(thisApp,'characters_count',{'NUM':checkCharactersCount},v)});check=!1}else if(!$(v).val()){error.push({obj:v,errMsg:'textarea-no-value',displayMsg:getErrorMessage(thisApp,'required',!1,v)});check=!1}else if(!$(v).hasClass("skipChecking")){if(!regexChecking(thisApp,v,$(v).val(),error,3)){check=!1}else{check=!0}}}}else{error.push({obj:v,errMsg:'no-value',displayMsg:getErrorMessage(thisApp,'required',!1,v)})}}else{check=!0;$.each(allObj,function(key,value){var settings=$(value).data("regexChecking");if(settings===undefined||!settings){if($(value).siblings(".regexChecking").length){settings=$.parseJSON($.trim($(value).siblings(".regexChecking").first().val()));if(settings===undefined||!settings){settings={}} if(settings)$(value).data("regexChecking",settings)}} if(canDebug())console.log(value);if(!$.isEmptyObject(settings)){if(!regexChecking(thisApp,value,$(value).val(),error,2))check=!1} if($(v).closest(".formItem").hasClass("cccRequired")&&!$(value).val()){error.push({obj:value,errMsg:'textarea-wordcount',displayMsg:getErrorMessage(thisApp,'required',!1,v)});check=!1}})} if(!check&&!pass){if(canDebug())console.log(check,pass);finalCheck=!1}}}else if($(v).hasClass("matrixGroup")){var isPass=matrixChecking($(v),!1,!1,!0);if(canDebug())console.log('isPass',isPass);if(!isPass){error.push({obj:v,errMsg:'matrix-error-not-match',displayMsg:getErrorMessage(thisApp,'matrix-error',!1,v)});finalCheck=!1}} if($(v).closest(".matrixGroup").length){$(v).closest(".matrixGroup").closest(".formItem").children(".cccAlertMessage").text("")} $(v).closest(".formItem").removeClass("matrix-error");$(v).closest(".formItem").removeClass("has-error");$(v).closest(".formItem").find(".inputErrorStatus").remove();$(v).children(".inputErrorStatus").remove();$(v).closest(".formItem").find(".cccAlertMessage").text("");$(v).children(".cccAlertMessage").text("")}});if(!finalCheck){if(canDebug())console.log('finalCheck',error);if(canDebug())console.log("========ERROR INPUT START========");var allObjs=[];$.each(error,function(k,data){if(canDebug())console.log("========MESSAGE => ",data.errMsg);var v=data.obj;allObjs.push($(v).closest(".formItem"));if(!$(v).hasClass("resetChecking")){if($(v).hasClass("matrixGroup")){$(v).closest(".formItem").addClass("matrix-error cccChecked");$(v).closest(".formItem").find(".errorHolder").find(".inputErrorStatus").remove();$(v).closest(".formItem").children(".inputErrorStatus").remove();$(v).closest(".formItem").children(".cccAlertMessage").text(data.displayMsg);var errorSpan='';if($(v).find(".errorHolder").length){$(v).find(".errorHolder").append(errorSpan)}else{var appendTo=v;if($(appendTo).next(".cccform-style-fix").length){appendTo=$(appendTo).next(".cccform-style-fix").first()} $(errorSpan).insertAfter(appendTo)}}else{$(v).closest(".formItem").addClass("has-error cccChecked");$(v).closest(".formItem").find(".inputErrorStatus").remove();$(v).closest(".formItem").find(".cccAlertMessage").text(data.displayMsg);var errorSpan='';if($(v).find(".errorHolder").length){$(v).find(".errorHolder").append(errorSpan)}else{var appendTo=v;if($(appendTo).next(".cccform-style-fix").length){appendTo=$(appendTo).next(".cccform-style-fix").first()} $(errorSpan).insertAfter(appendTo)}}} if(canDebug())console.log($(v).closest(".formItem").find(".cccAlertMessage"));if(canDebug())console.log(v);if(canDebug())console.log("================")});if(allObjs.length){var scrollTo=!1;$.each(allObjs,function(){if($(this).is(":visible")&&!scrollTo){scrollTo=$(this);return}});if(scrollTo&&isScroll&&$(thisApp.obj).closest(".modal-body").length==0&&!('noScroll' in thisApp.settings)){if(canDebug())console.log(scrollTo);$('html, body').stop(!0).animate({scrollTop:$(scrollTo).offset().top-30-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500);var obj=$(scrollTo).find("input").filter(":visible");if(obj.length){obj.focus()}else{var obj=$(scrollTo).find(".dropdown-toggle");if(obj.length){obj.focus()}}} if(canDebug())console.log("========ERROR INPUT END========")}} $.each(formItem,function(k,v){$(v).trigger("cccChecked")});if('dialog' in thisApp){if(typeof thisApp.dialog==="function"){thisApp.dialog().setClosable(finalCheck)}else if(thisApp.dialog){thisApp.dialog.setClosable(finalCheck)}} return finalCheck};var formPrev=function(obj,callback,mustCheck,data,passCheck){var cccApp=$(obj).closest(".cccApp");var finalCallback;if(mustCheck){finalCallback=function(){var id=$(obj).closest(".cccApp").attr("cccdata-cccapp-id");$('.cccTabs_'+id+' > .active').prev('li').find('a').triggerHandler('click');cccApp.trigger("reloadLayout");if(callback)callback()}}else{var id=$(obj).closest(".cccApp").attr("cccdata-cccapp-id");$('.cccTabs_'+id+' > .active').prev('li').find('a').triggerHandler('click');cccApp.trigger("reloadLayout");finalCallback=callback} $(cccApp).trigger("checkFormSectionSave",[finalCallback,!1,obj,data,passCheck])};var formNext=function(obj,callback,falseCallback,data,mustCheck,passCheck){var cccApp=$(obj).closest(".cccApp");var finalCallback=function(){var id=$(obj).closest(".cccApp").attr("cccdata-cccapp-id");if(canDebug())console.log($('.cccTabs_'+id+' > .active').next('li'));$('.cccTabs_'+id+' > .active').next('li').find('a').triggerHandler('click');if(callback)callback();cccApp.trigger("reloadLayout")};if(canDebug())console.log(mustCheck);console.log('trigger');$(cccApp).trigger("checkFormSectionSave",[finalCallback,(mustCheck?!1:falseCallback),obj,data,passCheck])};var formSave=function(obj,callback,falseCallback,data,pass){if(canDebug())console.log('formSave');var cccApp=$(obj).closest(".cccApp");if($(obj).hasClass("cccApp")){cccApp=$(obj)} if(canDebug())console.log(cccApp);window.onbeforeunload=null;$(cccApp).trigger("checkFormSave",[callback,falseCallback,data,pass])};var autoSave=function(thisApp,pass,callback,obj,falseCallback,data,noSubmit,disableOnSave){if(canDebug())console.log('autoSave');if($(thisApp.obj).hasClass("cccPreview")){return!1} var saveCallback=function(){var thisCheck=formChecking(thisApp,obj,pass,!1,!0);var basicForm=!1;var ENABLE_MOD_SECURITY=!1;if(thisApp.settings){if('method' in thisApp.settings){if(thisApp.settings.method=="POST"){basicForm="POST"}} if('ENABLE_MOD_SECURITY' in thisApp.settings&&!thisApp.isLocalStorage){ENABLE_MOD_SECURITY=thisApp.settings.ENABLE_MOD_SECURITY;if(ENABLE_MOD_SECURITY=="ENABLE_MOD_SECURITY")ENABLE_MOD_SECURITY=!1}} if(thisCheck||pass){var replaceBase64=function(str){if(typeof str==='object'){$.each(str,function(k,v){str[k]=replaceBase64(v)})}else if($.isArray(str)){str=$.map(str,function(str){return replaceBase64(str)})}else{if(str!==''){str='cccForm::B64::'+thisApp.Base64.encode(str)}} return str};var form;var createForm=function(replaceHyphen){if(form)$(form).remove();var orgObj=$(thisApp.obj).find(".formItem:not(.hidden)").find(".cccInput:not(.cccHiddenInput)");orgObj=$(orgObj).filter(function(){return $(this).closest('.formItem.hidden').length===0}) $(orgObj).filter("textarea").each(function(){var cloneID=$(this).attr('cccdata-clone-id');if(!cloneID)$(this).attr('cccdata-clone-id',cms.makeID())});form=$("
    ").append(orgObj.clone());if($(thisApp.obj).find(".cccHiddenFormItem:not(.hidden)").find(".cccHiddenInput").length)form.append($(thisApp.obj).find(".cccHiddenFormItem:not(.hidden)").find(".cccHiddenInput").clone());$(form).find("input,textarea").each(function(){if($(this).is("textarea")){var cloneID=$(this).attr('cccdata-clone-id');$(this).val($(orgObj).filter("[cccdata-clone-id='"+cloneID+"']").val())} $(this).attr('id','');var thisName=$(this).attr('name');if(thisName&&replaceHyphen){thisName=thisName.replace(/\-/g,'_hyphen_');$(this).attr('name',thisName)} if(ENABLE_MOD_SECURITY){$(this).val(replaceBase64($(this).val()))}})};if(basicForm){if(noSubmit){if(callback&&(thisCheck||!falseCallback))callback(data);if(!thisCheck&&falseCallback)falseCallback(data)}else{createForm();cms.loadingDiv($(thisApp.obj));$("body").append(form);if(data){$.each(data,function(k,v){var input=$("");input.attr('name',k);if(ENABLE_MOD_SECURITY){input.attr('value','cccForm::B64::'+thisApp.Base64.encode(v))}else{input.attr('value',v)} $(form).append(input)})} $(form).attr("method",basicForm).attr("action",thisApp.settings.action).submit();$(window).bind("blur.submit",function(){$(window).unbind("blur.submit");cms.removeLoadingDiv($(thisApp.obj))})}}else{if(!data)data={};var finalData=data;finalData.uid=(thisApp.getID()?thisApp.getID():'');if(thisApp.ref_id)finalData.ref_id=thisApp.ref_id;finalData.h=$(thisApp.obj).find('#h').val();var errorCallback=function(data){var thisObj=$(thisApp.obj).find("div[cccdata-ref-cccapp-id='errMsg']");var errMsgCallback=function(allObjs,v){$.each(allObjs,function(k,thisObj){thisObj=$(thisObj);if(thisObj.length){if(v===parseInt(v,10)){thisObj.closest(".formItem").find(".cccAlertMessage").last().html(ajax_showStatusMessage(v))}else{thisObj.closest(".formItem").find(".cccAlertMessage").last().html(v)} if(k==0&&!$(thisApp.obj).closest(".modal-body").length){$('html, body').stop(!0).animate({scrollTop:$(thisObj).closest(".formItem").offset().top-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}})};if(data.errMsg){if(typeof data.errMsg=='object'){$.each(data.errMsg,function(k,v){var re=/^(.*)\[([0-9]+)\]\[(.*)\]$/;if(re.test(k)){var matrixGroupName=k.replace(re,"$1");var eq=k.replace(re,"$2");var inputName=k.replace(re,"$3");var thisObj=$(thisApp.obj).find("div[cccdata-ref-cccapp-id='"+matrixGroupName+"']");if(thisObj.hasClass("matrixGroup")&&matrixGroupName!=''&&eq!=''&&inputName!=''){var thisObj=$(thisObj).find(".matrixItem:not(.coreTpl)").eq(eq).find("div[cccdata-ref-cccapp-id='"+inputName+"']");errMsgCallback([thisObj],v)}else{errMsgCallback([thisObj],v)}}else{var thisObj=$(thisApp.obj).find("div[cccdata-ref-cccapp-id='"+k+"']");var filterNotObj=$(thisObj).closest(".matrixItem").find("div[cccdata-ref-cccapp-id='"+k+"']");thisObj=$(thisObj).not(filterNotObj);errMsgCallback(thisObj,v)}})}else{if(thisObj.length){$(thisObj).parent().removeClass("hidden");$(thisObj).html(data.errMsg);if(!$(thisApp.obj).closest(".modal-body").length){$('html, body').stop(!0).animate({scrollTop:$(thisObj).closest(".formItem").offset().top-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}}}else{if(thisObj.length)$(thisObj).parent().addClass("hidden")}};if(thisApp.isLocalStorage){createForm(!0);var thisData=$(form).serializeObject();thisData=JSON.stringify(thisData);thisData=thisData.replace(/_hyphen_/g,'-');thisData=JSON.parse(thisData);var finalData=$.extend(finalData,thisData);thisApp.setFormData(finalData);if(thisApp.onSave&&!disableOnSave)thisApp.onSave(finalData)}else{var saveCallback=function(){cms.loadingDiv($(thisApp.obj));createForm();if(thisApp.getID())finalData.uid=thisApp.getID();if(ENABLE_MOD_SECURITY){finalData=replaceBase64(finalData)} $(form).ajaxSubmit({type:(thisApp.isRestFulAPI()&&'uid' in finalData&&finalData.uid?'PUT':'POST'),headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:finalData,beforeSend:function(xhr){thisApp.saveConnection=xhr},dataType:'json',url:(thisApp.isRestFulAPI()?thisApp.root+thisApp.api+('uid' in finalData&&finalData.uid?'/'+thisApp.getID():''):thisApp.root+'lib/ajax/'+thisApp.api+'/save/'),error:function(data){$(document).trigger("cccApp_"+thisApp.appID+"_reset_grecaptcha")},success:function(data){$(document).trigger("cccApp_"+thisApp.appID+"_reset_grecaptcha");cms.removeLoadingDiv($(thisApp.obj));if(data&&data.status>=1){if(data.uid){thisApp.setID(data.uid)} var objList=[];if(data.redirect){window.location.href=data.url} if(data.hiddenApp){$(thisApp.obj).find(".formItem").addClass("hidden");$(thisApp.obj).find(".cccSubmit").addClass("hidden")} if(data.destroyApp){if(thisApp.onDestory)thisApp.onDestory()} errorCallback(data);var thisObj=$(thisApp.obj).find("div[cccdata-ref-cccapp-id='msg']");if(thisObj.length){if(data.msg){$(thisObj).parent().removeClass("hidden");$(thisObj).html(data.msg);if(!$(thisApp.obj).closest(".modal-body").length){$('html, body').stop(!0).animate({scrollTop:$(thisObj).closest(".formItem").offset().top-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}else{$(thisObj).parent().addClass("hidden")}} if(callback&&(thisCheck||!falseCallback))callback(data);if(!thisCheck&&falseCallback)falseCallback(data);if(canDebug())console.log(data)}else{if(data.uid){thisApp.setID(data.uid)} var statusErrorMsg=ajax_showStatusMessage(data.status);if(!data.errMsg&&statusErrorMsg)data.errMsg=statusErrorMsg;errorCallback(data);if(falseCallback)falseCallback(data)} thisApp.saveConnection=!1;if(thisApp.saveConnectionQueue.length){if(typeof thisApp.saveConnectionQueue[0]=="function"){thisApp.saveConnectionQueue[0]();thisApp.saveConnectionQueue.shift()}} if(thisApp.onSave&&!disableOnSave)thisApp.onSave(data)}})};var timeoutChecking=function(){if(thisApp.saveConnection){thisApp.saveConnectionQueue.push(saveCallback)}else{saveCallback()}};timeoutChecking()}} return!0}else{if(falseCallback)falseCallback();return!1}};var id=thisApp.uniqueId;if(id&&thisApp.delaySave){if(thisApp.autoSaveDelay[id])clearTimeout(thisApp.autoSaveDelay[id]);thisApp.autoSaveDelay[id]=setTimeout(saveCallback,300)}else{return saveCallback()}};var selectObjVal=function(obj,v,skipFormChecking){var selectGroup=$(obj).closest(".selectGroup");if($(obj).hasClass("formItem")){$(obj).removeClass("has-error");$(obj).find(".cccAlertMessage").text("");$(obj).find(".inputErrorStatus").remove();selectGroup=$(obj).find(".selectGroup")} var input;if($(obj).hasClass("isListener")){input=$(selectGroup).find("input.isSelect")}else{input=$(selectGroup).find(".cccInput.isSelect")} var select=$(selectGroup).find("select");input.val(v).trigger("cccInputChange");if(v==""){input.removeClass("hasClass");select.removeClass("hasClass")} if(input.hasClass("isSelect")){select.find("option").prop("selected",!1).filter("[value='"+v+"']").prop("selected",!0);if(select.hasClass(".selectinit")){select.val(v).selectpicker('refresh')}else{select.val(v)}} select.trigger("change",[skipFormChecking])};var getOptionsIDS=function(othersRadio,obj,thisAppObj){var ids=[];$.each(othersRadio,function(){var optionID=$(this).attr('cccdata-ref-id');if(obj){$(thisAppObj).trigger("formID_"+optionID+".hide",[function(objs){if(objs.length){$.each(objs,function(objKey,objValue){if($(thisAppObj).find(".formItem_"+objValue).length)ids.push($(".formItem_"+objValue))})}}])}else{ids.push(optionID)}});return ids};var onChangeChecker=function(allObj,checkStr,objCheck,disableRemoveValue,parentObj){if(canDebug())console.log("onChangeChecker",allObj,allObj.len);if(!$(allObj).length)return;if(!parentObj){parentObj={add:function(id){if($.inArray(id,targetObjs)==-1)targetObjs.push(id)},get:function(){return targetObjs}};if(canDebug())console.log('create Parent Obj')} var targetObjs=[];var checkType;if($(allObj).is("select")){checkType="select"}else{checkType=$(allObj).attr("type")} var thisAppObj=$(allObj).closest(".cccApp");if(checkStr=="selected"){allObj=$(allObj).find("option")}else{if($(allObj).filter(":"+checkStr).length==0&&checkType=="checkbox"){var tempAllObj=[];$(allObj).each(function(k,obj){var groupID=$(obj).attr('cccdata-ref-group');var othersRadio=$(obj).closest(".cccApp").find("*[cccdata-ref-group='"+groupID+"']").not(obj).filter(":"+checkStr);if(othersRadio.length>0){tempAllObj.push(othersRadio.first().get(0))}else{$(obj).closest(".cccApp").find("input[cccdata-ref-group='"+groupID+"']").each(function(k,obj){if($(obj).closest(".formItem").hasClass("hidden"))return;if(obj.length==0)return;if(objCheck)onChangeInsertValue(obj,checkType,!1,!1,disableRemoveValue,parentObj)});othersRadio=$(obj).closest(".formItem").find("*[cccdata-ref-group='"+groupID+"']").not(":"+checkStr);$(document).trigger("formID.hide",[thisAppObj,getOptionsIDS(othersRadio,!1,thisAppObj),$(obj).closest(".matrixItem"),disableRemoveValue,parentObj])}});allObj=tempAllObj}} var currentOptionID=[];$(allObj).filter(":"+checkStr).each(function(k,obj){var thisID=$(obj).filter(":"+checkStr).attr('cccdata-ref-id');$(thisAppObj).trigger("formID_"+thisID+".hide",[function(objs){if(objs.length){$.each(objs,function(objKey,objValue){if(objValue){currentOptionID.push(objValue)}})}}])});$(allObj).filter(":"+checkStr).each(function(k,obj){if(obj.length==0)return;var groupID=$(obj).filter(":"+checkStr).attr('cccdata-ref-group');var othersRadio;if(checkStr=="selected"){othersRadio=$(obj).siblings("*[cccdata-ref-group='"+groupID+"'][value!='']").not(obj).not(":"+checkStr)}else if(checkType=="checkbox"){othersRadio=$(obj).closest(".formItem").find("input[cccdata-ref-group='"+groupID+"']").not(obj).not(":"+checkStr)}else if(checkType=="radio"){othersRadio=$(obj).closest(".formItem").find("input[cccdata-ref-group='"+groupID+"'][value!='']").not(obj).not(":"+checkStr)} $(document).trigger("formID.hide",[thisAppObj,getOptionsIDS(othersRadio,!1,thisAppObj),$(obj).closest(".matrixItem"),disableRemoveValue,parentObj,currentOptionID])});$(allObj).filter(":"+checkStr).each(function(k,obj){if($(obj).closest(".formItem").hasClass("beforeHidden")){$(document).trigger("formID.hide",[thisAppObj,getOptionsIDS([obj],!1,thisAppObj),$(obj).closest(".matrixItem"),disableRemoveValue,parentObj]);return} if($(obj).closest(".formItem").hasClass("hidden"))return;if(obj.length==0)return;if(objCheck)onChangeInsertValue(obj,checkType,!1,!1,disableRemoveValue,parentObj);var optionID=$(obj).filter(":"+checkStr).attr('cccdata-ref-id');var classProfile=$(obj).filter(":"+checkStr).attr('cccdata-profile');$(thisAppObj).trigger("formID_"+optionID+".show",[!0,$(obj).closest(".matrixItem"),classProfile,disableRemoveValue,parentObj])})};var changeClassProfile=function(objs,profile){if(objs.length){$.each(objs,function(){var $this=$(this);var thisProfile=$($this).attr('cccdata-class-profile');if(thisProfile){if(thisProfile!=""){var str=rawurldecode(thisProfile);var classObj=$.parseJSON(str);var removeClass=[];var addClass=[];$.each(classObj,function(k,v){if(k==profile){addClass.push(v)}else{removeClass.push(v)}});$(this).removeClass(removeClass.join(" "));$(this).addClass(addClass.join(" "))}} var thisProfile=$($this).attr('cccdata-string-class-profile');if(thisProfile){if(thisProfile!=""){var str=rawurldecode(thisProfile);var classObj=$.parseJSON(str);$.each(classObj,function(k,v){if(k==profile){$($this).text(v)}})}}})}};$(document).bind("formID.hide",function(e,thisAppObj,ids,matrixItem,disableRemoveValue,parentObj,exceptionID){var targetObjs=[];if(ids.length){$.each(ids,function(k,optionID){$(thisAppObj).trigger("formID_"+optionID+".hide",[function(objs){if(objs.length){$.each(objs,function(objKey,objValue){if(objValue&&$.inArray(objValue,parentObj.get())==-1){targetObjs.push(objValue);parentObj.add(objValue)}})}}])})} if(targetObjs.length){if(canDebug())console.log(ids,targetObjs,parentObj.get());$.each(targetObjs,function(v,k){if($.inArray(k,exceptionID)==-1){var obj=$(thisAppObj).find(".formItem_"+k);if(matrixItem){if(matrixItem.length){obj=$(matrixItem).find($(thisAppObj).find(".formItem_"+k))}} $(obj).addClass("beforeHidden");var thisApp=!1;$(obj).closest(".cccApp").trigger("cccApp",[function(app){thisApp=app}]);var checkStr="";if(thisApp&&!thisApp.isDisableResetOnToggle()){if($(obj).find("select").length){var value='';if($(obj).find("select").find("option").filter(".preselected").length)value=$(obj).find("select").find("option").filter(".preselected").attr('value');if(!disableRemoveValue){selectObjVal(obj,value,!0)} onChangeChecker($(obj).find("select"),'selected',!1,disableRemoveValue,parentObj)}else if($(obj).find(".radioGroup").length){if($(obj).find(".radioGroup").find("input").filter(".preselected").length){$(obj).find(".radioGroup").find("input").filter(".preselected").prop("checked",!0)} onChangeChecker($(obj).find(".radioGroup").find("input[type=radio]"),'checked',!1,disableRemoveValue,parentObj)}else if($(obj).find(".checkboxGroup").length){if($(obj).find(".checkboxGroup").find("input").filter(".preselected").length){$(obj).find(".checkboxGroup").find("input").filter(".preselected").prop("checked",!0).trigger("change")}else{$(obj).find(".checkboxGroup").find("input").prop("checked",!1).trigger("change")} onChangeChecker($(obj).find(".radioGroup").find("input[type=checkbox]"),'checked',!1,disableRemoveValue,parentObj)}else{$(obj).find(".cccInput").each(function(){if($(this).hasClass("uploadInput")){$(this).closest('.uploadPlaceHolder').removeClass('initUploader').html('');cms.uploader.check(thisApp)} thisApp.objVal($(this),$(this).attr('cccdata-default-value')?thisApp.Base64.decode($(this).attr('cccdata-default-value')):'')})}} $(obj).removeClass("beforeHidden");$(obj).addClass("hidden");$(obj).each(function(){var relatedObject=$(obj).attr('cccdata-field-id');if(!cms.cccApp.disableAnimateCSS)$(".formSubItem_"+relatedObject).addClass("hidden").addClass('animated fadeInUp')});$(document).trigger("formID.hide",[thisAppObj,[k],matrixItem,disableRemoveValue,parentObj]);if(matrixItem)if(matrixItem.length)$(matrixItem).closest(".cccApp").trigger("reloadLayout")}})}});var scheduleChecker=function(appID,id,str,mode){if(str=='')return!1;var thisAppObj=$("[cccdata-cccapp-id='"+appID+"']");$(thisAppObj).bind("formID_"+id+".show",function(e,isChange,matrixItem,profile,disableRemoveValue,parentObj){var targetObjs=str.split(",");if(canDebug())console.log(targetObjs);$.each(targetObjs,function(v,k){var obj=$(thisAppObj).find(".formItem_"+k);if(obj.length){changeClassProfile([obj],profile);changeClassProfile(obj.find("*[cccdata-class-profile!='']"),profile);changeClassProfile(obj.find("*[cccdata-string-class-profile!='']"),profile)} if(matrixItem.length){obj=$(matrixItem).find($(thisAppObj).find(".formItem_"+k))} if($(obj).hasClass('hidden')){$(obj).removeClass("hidden");if(!cms.cccApp.disableAnimateCSS)$(obj).addClass('animated fadeInUp')} $(obj).each(function(){var relatedObject=$(obj).attr('cccdata-field-id');$(".formSubItem_"+relatedObject).removeClass("hidden");if(!cms.cccApp.disableAnimateCSS){$(".formSubItem_"+relatedObject).addClass('animated fadeInUp').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){$(this).removeClass('animated fadeInUp')})}});if(!cms.cccApp.disableAnimateCSS){$(obj).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend',function(){$(obj).removeClass('animated fadeInUp')})} if($(obj).find(".wysiwyg")){$(obj).closest(".cccApp").trigger("cccApp",[function(thisApp){formSelect(thisApp)}])} onChangeChecker($(obj).find("input[type=checkbox]"),'checked',!1,disableRemoveValue,parentObj);onChangeChecker($(obj).find("input[type=radio]"),'checked',!1,disableRemoveValue,parentObj);onChangeChecker($(obj).find("select"),'selected',!1,disableRemoveValue,parentObj);if(matrixItem.length){$(matrixItem).closest(".cccApp").trigger("reloadLayout")} if(v==0&&isChange){waitForFinalEvent(function(){$(obj).closest(".cccApp").trigger("cccApp",[function(thisApp){if(canDebug())console.log('run noScroll');if(!('noScroll' in thisApp.settings)){if($(obj).length&&$(thisAppObj).find(".formItem_"+k).is(":visible")){$('html, body').stop(!0).animate({scrollTop:$(obj).offset().top-$(obj).outerHeight()-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}}])},50,"body-scroll")}})});$(thisAppObj).bind("formID_"+id+".hide",function(e,callback){var targetObjs=str.split(",");if(callback)callback(targetObjs)})};var fileCallback=function(data,thisApp){var thisID=data.target;var uploaderForm=$("#uploaderForm_"+thisID);var uploadInput=$("#uploadInput_"+thisID);if(data&&data.status==1){if(canDebug())console.log('data ==> ',data);uploaderForm.find(".uploadLabel").trigger('uploadLabelReset').trigger("uploadLabelUploadSuccess",[data.uid]);if(canDebug())console.log('fileCallback ====> ',uploadInput);if(canDebug())console.log('fileCallback ====> ',uploaderForm);if(!uploadInput.closest(".formItem").hasClass("onChangeSave")){uploadInput.val(data.uid).trigger('change')}else{uploadInput.val(data.uid).trigger("formSave")} thisApp.bindChangeEvent()}else{if(canDebug())console.log(data,'thisID',thisID);uploaderForm.find(".uploadLabel").trigger('uploadLabelReset');var errMsg;if(data.status!=1){errMsg=lang(data.message)} var errorID=cms.makeID();var showErrorList=function(){if(!thisApp.errorDisplay){var key=Object.keys(thisApp.error)[0];if(typeof thisApp.error[key]=="function"){thisApp.error[key]()}}};thisApp.error[errorID]=function(){thisApp.errorDisplay=!0;BootstrapDialog.confirm(1,'info',('msg' in data?data.msg:(errMsg?errMsg:'ERROR UPLOAD')),data.filename,!0,!0,{'callback':function(result){if(result){}else{}}},[{label:lang('Close'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}}],function(dialog){},function(dialog){},function(dialog){if(canDebug())console.log(data);if('isAppend' in data){if(uploaderForm.closest(".uploadPlaceHolder").hasClass("autoRemove")){uploaderForm.closest(".matrixItem").find(".matrixRemove").triggerHandler("click",[!0])}} if(canDebug())console.log('onhide')},function(dialog){if(canDebug())console.log('onhidden');delete thisApp.error[errorID];thisApp.errorDisplay=!1;showErrorList()},!1,!0)};showErrorList()} thisApp.checkPreloadList()};applicationInit=!1;cms.uploader={check:function(thisApp){var uploader=this;var callback=function(obj){var thisID='uploader_'+cms.makeID();$(obj).attr("id",thisID);$(obj).addClass("initUploader");uploader.build(thisID,thisApp)};$(".matrixItem").not(".coreTpl").find(".uploadPlaceHolder").not(".initUploader").each(function(){callback(this)});$(".uploadPlaceHolder").not(".initUploader").each(function(){if(!($(this).closest(".matrixItem").length>0)){callback(this)}})},build:function(thisID,thisApp){var uploader=this;var obj=$("#"+thisID);obj.find(".uploadForm").remove();var uploadForm='';var strVar="";var parentName=obj.attr("cccdata-parent-name");var readOnly=!1;var isRequired=!1;if(obj.attr("readonly")){readOnly=!0} if(obj.attr("required")){isRequired=!0} if(canDebug())console.log(parentName);strVar+="
    ";strVar+=" ";if(!readOnly)strVar+="";if(!readOnly)strVar+="
    ";strVar+="
    " if(!readOnly&&!isRequired)strVar+="
    ";strVar+="
    ";if(!readOnly)strVar+="
    " strVar+="
    ";strVar+="
    "+lang("Select or Drop a file")+"
    ("+obj.attr("cccdata-regex")+")
    ";strVar+="
    ";strVar+="<\/span>";strVar+="<\/form>";strVar+='';if(canDebug())console.log('thisID',thisID);obj.append($(strVar));var allOverlayClasses='cccappicon-upload cccappicon-success_circle';var uploadBtn=$(obj).find(".cccAppUploadBtn");$(obj).find(".fileUploadInput").hover(function(){uploadBtn.addClass('active')},function(){uploadBtn.removeClass('active')});var format=obj.attr("cccdata-regex").split(',');if($.inArray('png',format)!=-1||$.inArray('jpg',format)!=-1||$.inArray('jpeg',format)!=-1||$.inArray('gif',format)!=-1){obj.addClass("tempImageHolder")} $(obj).find(".fileUploadOverlayConfirm").hover(function(){uploadBtn.addClass('active')},function(){$(obj).find(".fileUploadOverlayConfirm").removeClass('active')});$(obj).find(".uploadLabel").bind("uploadLabelUploadConfirm",function(e,html,callback){var dialog=$(obj).find(".fileUploadOverlayConfirm").html(html).addClass("active");if(callback)callback(dialog)});$(obj).find(".uploadLabel").bind("uploadLabelUploadSuccess",function(e,id){$(obj).find(".fileUploadOverlay").addClass("upload-success").find(".cccFormIcon").first().removeClass(allOverlayClasses).addClass("cccappicon-success_circle");$(obj).find(".uploadLabelText").html('Uploaded');$(this).html("
    ").addClass('btn-success');$(obj).find(".fileUploadOverlayBtn").addClass('active')});$(obj).find(".uploadLabel").bind("uploadLabelUploadLoading",function(){$(obj).find(".fileUploadOverlayBtn").removeClass('active');$(obj).find(".fileUploadOverlay").removeClass("upload-success").find(".cccFormIcon").removeClass(allOverlayClasses);$(obj).find(".uploadLabelText").html('Uploading... ') $(this).html("");$(this).addClass('btn-warning')});$(obj).find(".uploadLabel").bind("uploadLabelReset",function(){$(obj).find(".fileUploadOverlay").removeClass("upload-success").find(".cccFormIcon").removeClass(allOverlayClasses).addClass("cccappicon-upload");$(obj).find(".fileUploadOverlayBtn").removeClass('active');$(obj).find(".uploadLabelText").html(lang("Select or Drop a file")+"
    ("+obj.attr("cccdata-regex")+")") $(this).html("").css("background","").removeClass("btn-success backstretched btn-warning initResizer").attr("cccdata-file-path","").attr("cccdata-type","");var currentFile=$(this).closest('.uploadPlaceHolder').find(".uploadInput").val();if(currentFile){$(this).trigger("uploadLabelUploadSuccess",[currentFile]);thisApp.bindChangeEvent()}});$(obj).find(".cccAppDeleteBtn").unbind("click").bind("click",function(e){var resetInput=function(){$(obj).closest('.uploadPlaceHolder').removeClass('initUploader').html('');cms.uploader.check(thisApp);cms.cccInput.order($(obj).closest('.matrixGroup'),thisApp,!0);$(obj).find(".uploadInput").trigger("formSaveWithoutOnSave")} $(obj).find(".uploadLabel").trigger("uploadLabelUploadConfirm",["
    ",function(dialog){$(dialog).find(".cccAppCancelBtn").click(function(){dialog.removeClass("active")}) $(dialog).find(".cccAppConfirmBtn").click(function(){cms.loadingDiv($(obj));var currentFile=$(obj).find(".uploadInput").val();if(currentFile){$.ajax({type:'POST',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:{uids:[currentFile],h:$(thisApp.obj).find('#h').val()},dataType:'json',url:cccframework_path+'cccForm/uploader/remove/',error:function(d){dialog.removeClass("active");cms.removeLoadingDiv($(obj));resetInput()},success:function(d){dialog.removeClass("active");cms.removeLoadingDiv($(obj));resetInput()}})}})}])});$(obj).find(".cccAppPreviewBtn").unbind("click").bind("click",function(e){e.preventDefault();var v=$(obj).find(".uploadLabel");var data;switch($(v).attr('cccdata-type')){case 'image':$.fancybox({'type':'image',href:$(v).attr("cccdata-file-path")+'&org=1',openEffect:'elastic',closeEffect:'elastic',helpers:{overlay:{locked:!1}}});break case 'music':$.fancybox({type:'iframe',href:cccframework_path+'cccForm/preview/music/?mp3='+encodeURIComponent($(v).attr("cccdata-file-path")),openEffect:'elastic',closeEffect:'elastic',helpers:{overlay:{locked:!1}}});break case 'doc':window.open($(v).attr("cccdata-file-path"));break default:BootstrapDialog.confirm(1,'info',lang('Preview not available'),"
    "+lang('Please upload a file.')+"
    ",!0,!0,{'callback':function(result){if(result){}else{}}},[{label:lang('Close'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}}],function(dialog){},function(dialog){},function(dialog){if(canDebug())console.log('onhide')},function(dialog){if(canDebug())console.log('onhidden')})}});uploader.bind(thisID,thisApp)},fileupload:function(thisApp,isMatrix,input,dropZone,refObj,thisID){var fileSize=refObj.attr('cccdata-file-size');var regexData="";var regex="";if(refObj.attr("cccdata-regex")){regexData=refObj.attr("cccdata-regex");if(!regexData)console.error("cccdata-ref-name not found.");if(regexData)regex=new RegExp("(\\.|\\/)("+regexData.split(",").join("|")+")$","i")} $(dropZone).bind("dragover",function(){$(this).addClass('dragenter')});$(dropZone).bind("dragleave",function(){$(this).removeClass('dragenter')});$(input).fileupload({url:cccframework_path+'cccForm/uploader/upload/',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),dropZone:dropZone,formData:{target:(thisID?thisID:""),'uploader-token':refObj.attr('cccdata-uploader-token')},messages:{maxNumberOfFiles:lang('Maximum number of files exceeded'),acceptFileTypes:lang('File type not allowed'),maxFileSize:lang('File is too large'),minFileSize:lang('File is too small')},dataType:'json',autoUpload:!0,acceptFileTypes:(regex?regex:!1),maxFileSize:fileSize?parseInt(fileSize):1024*1024*10}).on('fileuploadadd',function(e,data){$(dropZone).removeClass('dragenter');if(isMatrix&&$(e.currentTarget).closest(".matrixGroup").length>0){if(matrixChecking($(e.currentTarget).closest(".matrixGroup")))return!1} if(!data.files[0].id){data.files[0].id=cms.makeID()} var id=data.files[0].id;if(isMatrix&&$(e.currentTarget).closest(".matrixGroup").length>0){var callback=function(obj){var input=$(obj).find("*[cccdata-single-name='"+$(e.currentTarget).attr('cccdata-ref-name')+"']");$(input).closest(".uploadPlaceHolder").attr('cccdata-file-upload-ref',id).find(".uploadLabel").trigger('uploadLabelReset').trigger("uploadLabelUploadLoading")};$(e.currentTarget).closest(".matrixGroup").trigger("matrixItem.add",[callback])}else if(!isMatrix){var input=$("#uploaderForm_"+thisID).find("input[type='file']");$(input).closest(".uploadPlaceHolder").attr('cccdata-file-upload-ref',id).find(".uploadLabel").trigger('uploadLabelReset').trigger("uploadLabelUploadLoading")}}).on('fileuploadprocessalways',function(e,data){var file=data.files[0],id=file.id;var input=$("[cccdata-file-upload-ref='"+id+"']").find("input.cccInput");if(data.files[0].error){fileCallback({status:-1,msg:file.error,filename:file.name,target:$(input).attr('cccdata-thisid'),isAppend:!0},thisApp)}}).on('fileuploadprogress',function(e,data,file){var id=data.files[0].id;var input=$("[cccdata-file-upload-ref='"+id+"']").find("input.cccInput");var progress=parseInt(data.loaded/data.total*100,10);$(input).closest(".uploadPlaceHolder").find(".progress").text(progress+"%")}).on('fileuploaddone',function(e,data){var id=data.files[0].id;var input=$("[cccdata-file-upload-ref='"+id+"']").find("input.cccInput");if(data._response.result&&data._response.result.status==1){var currentFile=$(refObj).find(".uploadInput").val();if(currentFile){$.ajax({type:'POST',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:{uids:[currentFile],h:$(thisApp.obj).find('#h').val()},dataType:'json',url:cccframework_path+'cccForm/uploader/remove/',success:function(d){var thisID=data._response.result.target;$("#uploadInput_"+thisID).val("").trigger("formSaveWithoutOnSave");fileCallback(data._response.result,thisApp)}})}else{var uploadLabel=$("#uploaderForm_"+$(input).attr('cccdata-thisid')).find(".uploadLabel");uploadLabel.trigger('uploadLabelReset').trigger("uploadLabelUploadLoading");data._response.result.target=$(input).attr('cccdata-thisid');data._response.result.isAppend=!0;fileCallback(data._response.result,thisApp)}}else{fileCallback({status:-1,msg:data._response.result.message,filename:data._response.result.filename,target:$(input).attr('cccdata-thisid')},thisApp)}}).on('fileuploadfail',function(e,data){}).prop('disabled',!$.support.fileInput).parent().addClass($.support.fileInput?undefined:'disabled')},bind:function(thisID,thisApp){var input=$("#uploaderForm_"+thisID).find("input[type='file']");var uploadPlaceHolder=$(input).closest(".uploadPlaceHolder");cms.uploader.fileupload(thisApp,!1,input,uploadPlaceHolder,uploadPlaceHolder,thisID)}};var matrixChecking=function($this,addRowChecking,isFirstInit,checkVaild){var isVaild=!1;var isReachLimit=!1;var min=$($this).attr("cccdata-min-item");var max=$($this).attr("cccdata-max-item");var defaultItem=$($this).attr("cccdata-default-item");var notTPL=$($this).find(".matrixItem").not(".coreTpl");var currentItem=notTPL.length;if(!isFirstInit||currentItem>0)defaultItem=0;notTPL.find(".matrixRemove").removeClass("halfOpacity");notTPL.find(".matrixItem").removeClass("matrixRequired");if(canDebug())console.log('matrixValue',currentItem,min,max);if(canDebug())console.log('matrixChecking',(min&¤tItem<=min&&max&¤tItem>=max),(!max&&min&¤tItem>=min),(!min&&max&¤tItem<=max));if((min&&max&¤tItem>=min&¤tItem<=max)||(!max&&min&¤tItem>=min)||(!min&&max&¤tItem<=max)||(!min&&!max)){isVaild=!0} if((min&¤tItemmin?defaultItem:min)-currentItem;if(canDebug())console.log(isFirstInit,addRow,$this);if($($this).hasClass("showMin")&&addRow){for(var i=0;iaddRow){break} $($this).trigger("matrixItem.add",[!1,!0])}}} $($this).find(".matrixAdd").removeClass("hidden");$($this).find(".matrixAddGroup").removeClass("hidden")}else if(max&¤tItem>=max){isReachLimit=!0;$($this).find(".matrixAdd").addClass("hidden");$($this).find(".matrixAddGroup").addClass("hidden")}else{$($this).find(".matrixAdd").removeClass("hidden");$($this).find(".matrixAddGroup").removeClass("hidden")} if(currentItem<=min){$($this).find(".matrixItem").not(".coreTpl").addClass("matrixRequired").filter(":lt("+min+")").find(".matrixRemove").addClass("halfOpacity")} return(checkVaild?isVaild:isReachLimit)};var matrixSetCount=function($this,count){var isReachLimit=!1;var min=count;var defaultItem=$($this).attr("cccdata-default-item");var notTPL=$($this).find(".matrixItem").not(".coreTpl");var currentItem=notTPL.length;if(currentItemmin){var addRow=currentItem-min;if(addRow){for(var i=0;i0){$.each($($this).closest(".matrixItem"),function(){cms.loadingDiv($(this))});$.ajax({type:'POST',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:{uids:removeItems,h:$(thisApp.obj).find('#h').val()},dataType:'json',url:cccframework_path+'cccForm/uploader/remove/',success:function(data){if(data){if(data.status>0){if(canDebug())console.log(data);if(canDebug())console.log($this);removeCallback()}else{} if($(group).closest(".modal-body.autoSaveModal").length>0&&!$(group).closest(".formItem").hasClass("disableAutoSave")){autoSave(thisApp,!0)}} $.each($($this).closest(".matrixItem"),function(){cms.removeLoadingDiv($(this))})}})}else{removeCallback();if($(group).closest(".modal-body.autoSaveModal").length>0&&!$(group).closest(".formItem").hasClass("disableAutoSave")){autoSave(thisApp,!0)}}};if(mustDel){delCallback()}else{BootstrapDialog.confirm(1,'info',lang('Delete item'),"
    "+lang('Confirm to delete this item?')+"
    ",!0,!0,{'callback':function(result){if(result){delCallback()}else{}}},[{label:lang('Delete'),cssClass:'btn-warning',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!0);dialog.close()}},{label:lang('Close'),cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);dialog.close()}}],function(dialog){},function(dialog){},function(dialog){if(canDebug())console.log('onhide')},function(dialog){if(canDebug())console.log('onhidden')})}};$.each(groupData,function(k,obj){if(canDebug())console.log(obj,$(obj).find(".matrixItemClear"));$(obj).find(".matrixItemClear").addClass("cccInput");$(obj).find(".matrixItem").not(".coreTpl").unbind("matrixItem.remove").bind("matrixItem.remove",deleteAction).each(function(k,v){var thisID=cms.makeID();$(v).find(".checkbox-radio").find("input").each(function(){$(this).attr("name",$(this).attr("name")+'_'+thisID);var labelID=$(this).attr("id")+'_'+cms.makeID();$(this).attr("id",labelID);$(this).next("label").attr("for",labelID)});$(v).find("*[cccdata-ref-name]").each(function(){$(this).attr("name",($(this).attr("cccdata-ref-name")).replace("%order%",k));if(!$(this).hasClass("uploadInput")){if(!$(this).hasClass("initID")){$(this).addClass("initID");$(this).attr("id",cms.makeID())}}});$(obj).find(".matrixItemClear").removeClass("cccInput")});if($(obj).find(".matrixItem").not(".coreTpl").length==0){$(obj).find(".matrixReset").addClass("cccInput")}});$(thisApp.obj).find(".matrixRemove").unbind("click.matrixRemove").bind("click.matrixRemove",deleteAction);if(thisApp.applicationInit&&isAutoSave)$(groupData).first().trigger("formSave");thisApp.bindChangeEvent()}};var eventMethod=window.addEventListener?"addEventListener":"attachEvent";var eventer=window[eventMethod];var messageEvent=eventMethod=="attachEvent"?"onmessage":"message";eventer(messageEvent,function(e){if(typeof e.data=="object"){$.each(e.data,function(k,v){if(k=="set-form-builder-height"){$("#"+e.data.callbackID).height(v)} if(k=="set-form-builder-data"){setFormBuilderData(e.data.callbackID,v)}})}},!1);cms.grecaptcha={};cms.cccApp={decodeData:function(data,recursive){var prefix="JSON::";if(typeof data==="string"&&data.indexOf(prefix)===0){data=data.substr(prefix.length);data=$.parseJSON(data);data=cms.cccApp.decodeData(data,recursive)} if(recursive){if(data instanceof Array){var newData=[];$.each(data,function(k,v){newData.push(cms.cccApp.decodeData(v,recursive))});data=newData}else if(data instanceof Object){var newData={};$.each(data,function(k,v){newData[k]=cms.cccApp.decodeData(v,recursive)});data=newData}} return data},error:function(thisApp,str){var obj=thisApp;if('obj' in thisApp){obj=$(thisApp.obj)} $(obj).find('.notyError').noty({text:htmlEntities(str),type:'error',animation:{open:{height:'toggle'},close:{height:'toggle'},easing:'swing',speed:100},theme:'relax'})},disableAnimateCSS:!1,isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)},init:function(targetTagAPI,obj,uid,ref_id,initCallback,onDestory,onRecordCreate){var isLocalStorage,dialog,localData,onSave,onSectionChange,onSectionChangeError,onDataLoadError,onFieldChange,onHeaders,disableInitPreloadImages=!1,delaySave=!0,openClipboard=function(){};if(targetTagAPI&&typeof targetTagAPI=='object'){isLocalStorage=targetTagAPI.isLocalStorage;dialog=targetTagAPI.dialog;localData=targetTagAPI.data;obj=targetTagAPI.obj;uid=targetTagAPI.uid;ref_id=targetTagAPI.ref_id;if('disableInitPreloadImages' in targetTagAPI)disableInitPreloadImages=targetTagAPI.disableInitPreloadImages;if('delaySave' in targetTagAPI)delaySave=targetTagAPI.delaySave;if('on' in targetTagAPI){if('init' in targetTagAPI.on)initCallback=targetTagAPI.on.init;if('destory' in targetTagAPI.on)onDestory=targetTagAPI.on.destory;if('recordCreate' in targetTagAPI.on)onRecordCreate=targetTagAPI.on.recordCreate;if('save' in targetTagAPI.on)onSave=targetTagAPI.on.save;if('sectionChange' in targetTagAPI.on)onSectionChange=targetTagAPI.on.sectionChange;if('sectionChangeError' in targetTagAPI.on)onSectionChangeError=targetTagAPI.on.sectionChangeError;if('fieldChange' in targetTagAPI.on)onFieldChange=targetTagAPI.on.fieldChange;if('dataLoadError' in targetTagAPI.on)onDataLoadError=targetTagAPI.on.dataLoadError;if('headers' in targetTagAPI.on)onHeaders=targetTagAPI.on.headers} if('openClipboard' in targetTagAPI)openClipboard=targetTagAPI.openClipboard;targetTagAPI=targetTagAPI.apiTarget} var key=cms.makeID();var thisApp=this.app();this.store[key]=thisApp;var $this=this;thisApp.destroy=function(){$(thisApp.obj).find(".wysiwyged").each(function(){tinymce.execCommand('mceRemoveControl',!0,$(this).attr('id'))});$(thisApp.obj).unbind();$(thisApp.obj).find("*").unbind();$(window).off("resize.cccAppResizer_"+thisApp.appID);delete $this.store[key]};thisApp.uniqueId=key;thisApp.openClipboard=openClipboard;thisApp.delaySave=delaySave;thisApp.autoSaveDelay={};thisApp.isLocalStorage=isLocalStorage;thisApp.root=local_url;thisApp.appID=$(obj).attr('cccdata-cccapp-id');thisApp.api=targetTagAPI;thisApp.dialog=dialog;thisApp.disableInitPreloadImages=disableInitPreloadImages;if(targetTagAPI){var paths=targetTagAPI.split("|");if('0' in paths&&'1' in paths){if(paths[0])thisApp.root=paths[0];if(paths[1])thisApp.api=paths[1]}} thisApp.ref_id=ref_id;thisApp.obj=obj;var settings={};if($(obj).find(".cccAppSettings").length){settings=$.parseJSON($(obj).find(".cccAppSettings").val())} if(canDebug())console.log('settings',settings);if(settings.isLocalStorage){thisApp.isLocalStorage=settings.isLocalStorage} thisApp.settings=settings;thisApp.onSave=onSave;thisApp.onSectionChange=onSectionChange;thisApp.onSectionChangeError=onSectionChangeError;thisApp.onFieldChange=onFieldChange;thisApp.onDataLoadError=onDataLoadError;thisApp.onHeaders=onHeaders;thisApp.onDestory=onDestory;thisApp.onRecordCreate=onRecordCreate;thisApp.isFieldChanged=!1;$(thisApp.obj).find(".cccapp-form-builder").each(function(){$(this).on('load',function(){$(this).get(0).contentWindow.postMessage(getFormBuilderData($(this).attr('id')),'*')}).attr('src',cccframework_path+'cccForm/form-builder/iframe/?callback='+$(this).attr('id')+'&lang='+$(this).attr('lang')+'&client_id='+$(this).attr('client-id')).load()});$(thisApp.obj).find(".formPrevBtn").click(function(){var cccApp=$(this).closest(".cccApp");var finalCallback=function(){var currentIndex=$(thisApp.obj).find(".tab-pane").index($(thisApp.obj).find(".tab-pane").filter(".active"));var prevIndex=!1;if((currentIndex-1)>0){prevIndex=(currentIndex-1)} else{prevIndex=0} $(thisApp.obj).find(".tab-pane").removeClass("in active");$(thisApp.obj).find(".tab-pane").eq(prevIndex).addClass("in active");var data={index:prevIndex,id:$(thisApp.obj).find(".tab-pane").eq(prevIndex).attr("id"),trigger:'prev'} if(thisApp.onSectionChange){thisApp.onSectionChange(data)} cccApp.trigger("reloadLayout")};$(cccApp).trigger("checkFormSectionSave",[finalCallback,thisApp.onSectionChangeError,$(this)])});$(thisApp.obj).find(".formNextBtn").click(function(){var cccApp=$(this).closest(".cccApp");var finalCallback=function(){var currentIndex=$(thisApp.obj).find(".tab-pane").index($(thisApp.obj).find(".tab-pane").filter(".active"));var total=$(thisApp.obj).find(".tab-pane").length;var nextIndex=!1;if((currentIndex+1)>=total){nextIndex=currentIndex} else{nextIndex=currentIndex+1} $(thisApp.obj).find(".tab-pane").removeClass("in active");$(thisApp.obj).find(".tab-pane").eq(nextIndex).addClass("in active");var data={index:nextIndex,id:$(thisApp.obj).find(".tab-pane").eq(nextIndex).attr("id"),trigger:$(this).hasClass("lastBtn")?'last':'next'} if(thisApp.onSectionChange){thisApp.onSectionChange(data)} cccApp.trigger("reloadLayout")};$(cccApp).trigger("checkFormSectionSave",[finalCallback.bind(this),thisApp.onSectionChangeError,$(this)])});$(thisApp.obj).find(".cccform-checker").each(function(){var classes=$(this).attr('class');classes=classes.split(' ');var parentID='';var toggleIDs=[];$.each(classes,function(k,v){var type=v.split('_');if((1 in type||"1" in type)&&type[1]){if(type[0]=="parent"){parentID=type[1]} if(type[0]=="toggle"){toggleIDs.push(type[1])}}});scheduleChecker(thisApp.appID,parentID,toggleIDs.join(','),$(this).attr('mode'));$(this).remove()});thisApp.setID(uid);thisApp.setData(localData);thisApp.loadApplication(function(data){$(obj).removeClass("cccLoading");if(initCallback)initCallback(thisApp,data);if($(thisApp.obj).hasClass("isPreviewApp")){$(thisApp.obj).find(".uploadPlaceHolder").find("input").remove();console.log($(thisApp.obj).find(".cccInput"));$(thisApp.obj).find(".cccInput,.cccInputReadOnly").each(function(k,v){var str=$(v).val();if($(v).hasClass("isRadio")){str=$(v).closest(".radioGroup").find("input[type='radio']").filter("[value='"+str+"']").attr("cccdata-label");var input=$("
    "+htmlEntities(str)+"
    ");$(this).closest(".radioGroup").replaceWith(input)}else if($(v).hasClass("isCheckbox")){var values=str.replace(/\|\|\|/g,"").split("||");str=[];$.each(values,function(k,singleValue){str.push($(v).closest(".checkboxGroup").find("input[type='checkbox']").filter("[value='"+singleValue+"']").attr("cccdata-label"))});var input=$("
    "+htmlEntities(str.join(","))+"
    ");$(this).closest(".checkboxGroup").replaceWith(input)}else if($(v).hasClass("isToggle")||$(v).hasClass("isSelect")){var finalValue="";if($(v).hasClass("isSelect")){finalValue=$(this).closest(".selectGroup").find("option[value='"+$(this).val()+"']").text()}else{if($(this).val()=="On"){finalValue=$(this).closest(".selectGroup").find("option[value='On']").text()}else if($(this).val()=="Off"){finalValue=$(this).closest(".selectGroup").find("option[value='Off']").text()}} var input=$("
    "+htmlEntities((finalValue?finalValue:"-"))+"
    ");$(this).replaceWith(input)}else{var input=$("
    "+htmlEntities(($(this).val()?$(this).val():"-"))+"
    ");$(this).replaceWith(input)}});$(thisApp.obj).find("[type=checkbox]").parent().remove();$(thisApp.obj).find("iframe,.cccFormBtn,.fileUploadOverlay,[type=file],[type=radio],.bootstrap-select,.matrixBtn,.toggleLabel,.switchy-container").remove();$(".isPreviewApp").animate({"opacity":1},500).addClass('isPreviewAppInit')} $(window).triggerHandler("resize");$(thisApp.obj).change(function(){thisApp.isFieldChanged=!0;if(thisApp.onFieldChange){thisApp.onFieldChange(thisApp.isFieldChanged)}})});return thisApp},Base64:{_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=this._utf8_encode(e);while(f>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64} t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)} return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)} if(a!=64){t=t+String.fromCharCode(i)}} t=this._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}} return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}} return t}},app:function(){return{getSections:function(){var sections=[];$('.tab-pane').each(function(){sections.push({id:$(this).attr('id'),title:$(this).find('.cccSectionTitle').attr("title")})}) return sections},switchSection:function(id){$(this.obj).find(".tab-pane").removeClass("in active");$(this.obj).find(".tab-pane#"+id).addClass("in active")},getInput:function(name){return $(this.obj).find("[cccdata-ref-cccapp-id='"+name+"']")},isRestFulAPI:function(){return 'restful-api' in this.settings&&this.settings['restful-api']},isDisableResetOnToggle:function(){return 'disable-reset-on-toggle' in this.settings&&this.settings['disable-reset-on-toggle']},headers:function(headers){if(typeof this.onHeaders==="function"){return this.onHeaders(headers)} return headers},error:{},isLocalStorage:!1,localData:!1,formData:{},saveConnection:!1,saveConnectionTimer:!1,saveConnectionQueue:[],errorDisplay:!1,applicationInit:!1,disableBinding:!1,root:!1,obj:!1,id:!1,settings:!1,api:!1,Base64:{encode:function(e){return cms.cccApp.Base64.encode(e)},decode:function(e){return cms.cccApp.Base64.decode(e)}},getFormData:function(needRetrun){autoSave(this,!0);var isFalse=autoSave(this,!1,function(){},!1,function(){});if(!isFalse&&needRetrun){return!1}else{return this.formData}},save:function(data){return autoSave(this,!1,function(){},!1,function(){},data)},setFormData:function(data){this.formData=data},getData:function(){return this.localData},setData:function(data){this.localData=data},getID:function(){return this.id},setID:function(uid){var id=this.id;if(id&&$.trim(id)!=""&&uid)return!1;$(this.obj).attr("uid",uid);this.id=uid;if(uid){if(this.onRecordCreate)this.onRecordCreate()}},resetInput:function(scrollToFirstObject,noDefaultValue){var $this=this;$(this.obj).find(".inputErrorStatus").remove();$(this.obj).find(".cccAlertMessage").text("");$(this.obj).find("input.cccInput[type!='hidden'],.cccRadio input[type='radio']:checked,.cccRadio input[type='checkbox']:checked").not(".isSelect").not(".isToggle").each(function(){if($(this).attr('type')=="radio"||$(this).attr('type')=="checkbox"){$(this).prop('checked',!1)}else{if(!noDefaultValue){$(this).val($this.Base64.decode($(this).attr('cccdata-default-value')))}else{$(this).val("")}}});$(this.obj).find("textarea.cccInput").each(function(){if(!noDefaultValue){$(this).val($this.Base64.decode($(this).attr('cccdata-default-value')))}else{$(this).val("")}});$(this.obj).find("select").find("option").each(function(){$(this).prop('selected',!1)});$(this.obj).find(".base64UploadLabel").each(function(){$(this).removeClass("upload-success");$(this).find(".cccFormIcon").addClass("hidden").first().removeClass("hidden");$(this).find(".uploadLabelText").addClass("hidden").first().removeClass("hidden");$(this).parent().get(0).reset()});$(this.obj).find(".cccRadio input[type='radio'].preselected,.cccRadio input[type='checkbox'].preselected").each(function(){$(this).prop('checked',!0)});$(this.obj).find("select").find("option.preselected").each(function(){$(this).prop('selected',!0)});$(this.obj).find("input.cccInput").addClass("resetChecking");$(this.obj).find(".cccRadio input[type='radio'],.cccRadio input[type='checkbox']").each(function(){$(this).trigger("change")});$(this.obj).find("select").each(function(){$(this).trigger("change",[!1,!0])});$(this.obj).find("textarea.cccInput").each(function(){$(this).trigger("change")});$(this.obj).find("input.cccInput[type!='hidden']").not(".isSelect").not(".isToggle").each(function(){$(this).trigger("change")});$(this.obj).find("input.cccInput").removeClass("resetChecking");$(document).trigger("cccApp_"+this.appID+"_reset_grecaptcha");formSelect(this);if(scrollToFirstObject){var finalOffset=[];if($($this.obj).find(".radioGroup").first().length){var checkRadioOffset=$($this.obj).find(".radioGroup").first().closest(".formItem").not(".hidden").offset().top;if(checkRadioOffset>0)finalOffset.push(checkRadioOffset)} if($($this.obj).find(".checkboxGroup").first().length){var checkCheckboxOffset=$($this.obj).find(".checkboxGroup").first().closest(".formItem").not(".hidden").offset().top;if(checkCheckboxOffset>0)finalOffset.push(checkCheckboxOffset)} if($($this.obj).find("select").length){var checkSelectOffset=$($this.obj).closest(".formItem").not(".hidden");if(checkSelectOffset>0)finalOffset.push(checkSelectOffset)} var checkCCCInput=$($this.obj).find("input.cccInput").filter(":visible").closest(".formItem").offset().top;if(checkCCCInput>0)finalOffset.push(checkCCCInput);finalOffset=Math.min.apply(Math,finalOffset);if(finalOffset){$('html, body').stop(!0).animate({scrollTop:finalOffset-30-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}},loadApplication:function(initCallback){var thisApp=this;$(thisApp.obj).bind("cccApp",function(e,callback){callback(thisApp)});$(thisApp.obj).find(".cccFirstItem").removeClass("cccFirstItem");$(thisApp.obj).find(".tab-pane").each(function(){$(this).find(".formItem").not(".hidden").first().addClass("cccFirstItem")});var checkStyle=function(){$(thisApp.obj).find("input[value!='']").each(function(){inputStyleChecking(thisApp,$(this))});$(thisApp.obj).find("textarea.cccInput").each(function(){inputStyleChecking(thisApp,$(this))})};checkStyle();if($(thisApp.obj).find(".matrixGroup").find("input.fileupload").length){$(thisApp.obj).find(".matrixGroup").find("input.fileupload").each(function(k,v){var regex=!1;var inputButton=this;if($(v).attr("cccdata-ref-name")){var thisObj=$(v).closest(".matrixGroup").find(".coreTpl").find("*[cccdata-this-name='"+$(v).attr("cccdata-ref-name")+"']");cms.uploader.fileupload(thisApp,!0,v,$(inputButton).parent(),thisObj,!1)}else{cms.cccApp.error(thisApp,'Missing `cccdata-ref-name` attr under Matrix Group :'+$(v).closest(".matrixGroup").attr('cccdata-ref-cccapp-id')+' under multiple upload input : '+this.outerHTML);cms.cccApp.error(thisApp,'Missing `cccdata-ref-name` attr under Matrix Group :'+$(v).closest(".matrixGroup").attr('cccdata-ref-cccapp-id')+' under multiple upload input : '+this.outerHTML)}})} var handleScroll=function(){scrollTimer=null;thisApp.reloadLayout()};var scrollTimer=null;$(window).scroll(function(){if(scrollTimer){clearTimeout(scrollTimer)} scrollTimer=setTimeout(handleScroll,150)});$(window).resize(function(){if(scrollTimer){clearTimeout(scrollTimer)} scrollTimer=setTimeout(handleScroll,150)});cms.loadingDiv($(thisApp.obj));function ordinal_suffix_of(i){var j=i%10,k=i%100;if(j==1&&k!=11){return "st"} if(j==2&&k!=12){return "nd"} if(j==3&&k!=13){return "rd"} return "th"} $(thisApp.obj).find(".matrixGroup").unbind("matrixItem.add").bind("matrixItem.add",function(e,callback,isSystem){var $this=$(this);$($this).find(".matrixReset").removeClass("cccInput");var newItem=$(thisApp.obj).find(".coreTpl."+$($this).attr("cccdata-ref-targetGroup")).clone();var thisItemID=cms.makeID();newItem.attr('cccdata-matrixItem-id',thisItemID);newItem.find("*[cccdata-clone-id]").removeAttr("cccdata-clone-id");newItem.find(".selectCoreTpl").removeClass("selectCoreTpl").addClass("selectpicker");newItem.find(".toggleCoreTpl").removeClass("toggleCoreTpl").addClass("toggleBeautiful");newItem.removeClass("coreTpl");newItem.addClass("sortableItem");$(newItem).find(".cccInput").each(function(){thisApp.objVal($(this),$(this).attr('cccdata-default-value')?thisApp.Base64.decode($(this).attr('cccdata-default-value')):'')}) if($this.find(".keepLastItem").length>0){$(newItem).insertBefore($this.find(".keepLastItem"))}else{$($this).append(newItem)} $(newItem).closest(".matrixGroup").bind("reOrder.item_"+thisItemID,function(){var currentIndex=$(newItem).closest(".matrixGroup").find(".matrixItem").not(".coreTpl").index(newItem);$(newItem).find(".cccLabel").each(function(){var label=this;$(label).find(".engOrder").html(""+ordinal_suffix_of(currentIndex+1)+"");$(label).find(".matrixOrder").html(currentIndex+1);var html=$(label).html();html=html.replace("%matrixOrder%",currentIndex+1);html=html.replace("%engOrder%",""+ordinal_suffix_of(currentIndex+1)+"");$(label).html(html)});$(newItem).find(".cccHTML").each(function(){var label=this;$(label).find(".engOrder").html(""+ordinal_suffix_of(currentIndex+1)+"");$(label).find(".matrixOrder").html(currentIndex+1);var html=$(label).html();html=html.replace("%matrixOrder%",currentIndex+1);html=html.replace("%engOrder%",""+ordinal_suffix_of(currentIndex+1)+"");$(label).html(html)})});var matrixGroupID=$($this).attr('matrixGroup-id');waitForFinalEvent(function(){$(newItem).closest(".matrixGroup").trigger("reOrder")},1000,"matrix-reOrder-"+matrixGroupID);if(!$($this).hasClass("sortable")){$($this).attr('matrixGroup-id',cms.makeID());$($this).sortable({opacity:0.5,handle:".sortableHandle",items:".sortableItem",placeholder:"matrix-highlight "+$(newItem).attr('cccdata-matrixClass'),stop:function(event,ui){$(ui.item).find(".wysiwyged").each(function(){tinymce.execCommand('mceAddEditor',!1,$(this).attr('id'))});if('refHeight' in window){refHeight()} $(this).sortable("refresh")},start:function(event,ui){$(ui.item).find(".wysiwyged").each(function(){tinymce.execCommand('mceRemoveEditor',!1,$(this).attr('id'))});var height=$(ui.item).height();$($this).find(".matrix-highlight").height(height)},update:function(){cms.cccInput.order($($this),thisApp);if(!$($this).closest(".formItem").hasClass("disableAutoSave")&&$($this).closest(".modal-body.autoSaveModal").length>0){autoSave(thisApp,!0)}},helper:function(event,ui){var $clone=$(ui).clone();$clone.css('position','absolute');return $clone.get(0)},scroll:!0});$($this).addClass("sortable")}else{waitForFinalEvent(function(){$($this).sortable("refresh")},(thisApp.disableBinding?1000:50),"matrix-refresh-sortable-"+matrixGroupID);if(!$($this).closest(".formItem").hasClass("disableAutoSave")&&$($this).closest(".modal-body.autoSaveModal").length>0){autoSave(thisApp,!0)}} matrixChecking($(thisApp.obj).find($this));cms.uploader.check(thisApp);cms.cccInput.order($this,thisApp,!$($this).closest(".formItem").hasClass("disableAutoSave"));thisApp.reloadLayout();var formSelected=!1;if($(newItem).find(".selectpicker").length>0){formSelect(thisApp);formSelected=!0} if(!formSelected&&$(newItem).find(".wysiwyg").length>0){formSelect(thisApp)} if(callback)callback(newItem);if($($this).closest(".formItem").hasClass("matrix-error")){if(!isSystem)formChecking(thisApp,$this)} onchangeCaseCheck($this.closest('.formItem'),thisApp);var obj=newItem;if(!('noScroll' in thisApp.settings)&&thisApp.applicationInit){if($(obj).length&&$(obj).is(":visible")){$('html, body').stop(!0).animate({scrollTop:$(obj).offset().top-$(obj).outerHeight()*0.1-($(".cccFormOffsetTop").length?$(".cccFormOffsetTop").height():0)},500)}}});cms.uploader.check(thisApp);$(thisApp.obj).find(".matrixAdd").unbind("click.matrixAdd").bind("click.matrixAdd",function(){$(this).closest(".matrixGroup").trigger("matrixItem.add")});var successCall=function(data){thisApp.disableBinding=!0;if(data){if(data.status>=1&&data.data){if(canDebug())console.log('thisApp.obj',thisApp.obj);var formCheckObjs=[];$.each(data.data,function(k,v){if($.isArray(v)){var order=0;$.each(v,function(o,mdata){var canAdd=!1;$.each(mdata,function(mk,mv){if($.trim(mv)!="")canAdd=!0});canAdd=!0;if(canAdd){$.each(mdata,function(mk,mv){var obj=$(thisApp.obj).find("*[name='"+k+"["+order+"]["+mk+"]']");if(obj.length==0){if($(thisApp.obj).find("*[cccdata-matrixGroup='"+k+"']").find(".coreTpl").find("div[cccdata-ref-cccapp-id='"+mk+"']").length){$(thisApp.obj).find("*[cccdata-matrixGroup='"+k+"']").trigger("matrixItem.add");obj=$(thisApp.obj).find("*[name='"+k+"["+order+"]["+mk+"]']")}else{obj=!1}} if(obj){if(mv){thisApp.objVal(obj,mv);formCheckObjs.push(obj)}}});order++}})}else{var obj=$(thisApp.obj).find("*[name='"+k+"']");var thisPlaceHolder=$(obj).attr('placeholder');if(v){thisApp.objVal(obj,v);formCheckObjs.push(obj)}}});formChecking(thisApp,!1,!1,formCheckObjs,!1,!0);if(canDebug())console.log('onChangeChecker checkbox Run after Get');onChangeChecker($(thisApp.obj).find("input[type=checkbox]"),'checked',!0,!0);if(canDebug())console.log('onChangeChecker radio Run after Get');onChangeChecker($(thisApp.obj).find("input[type=radio]"),'checked',!0,!0);if(canDebug())console.log('onChangeChecker selected Run after Get');onChangeChecker($(thisApp.obj).find("select"),'selected',!0,!0);thisApp.applicationInit=!0;$(thisApp.obj).find(".textareaChecker").each(function(){countWords($(this),thisApp,$(this).closest(".formItem").find(".countPlaceHolder"),!0,!0);countCharacters($(this),thisApp,$(this).closest(".formItem").find(".countPlaceHolder"),!0,!0)})}else{if(thisApp.onDataLoadError){thisApp.onDataLoadError(data)} onChangeChecker($(thisApp.obj).find("input[type=checkbox]"),'checked');onChangeChecker($(thisApp.obj).find("input[type=radio]"),'checked');onChangeChecker($(thisApp.obj).find("select"),'selected')}}else{onChangeChecker($(thisApp.obj).find("input[type=checkbox]"),'checked');onChangeChecker($(thisApp.obj).find("input[type=radio]"),'checked');onChangeChecker($(thisApp.obj).find("select"),'selected')} thisApp.disableBinding=!1;formSelect(thisApp);thisApp.bindChangeEvent(!0);$(thisApp.obj).find(".matrixGroup").each(function(){var $this=this;matrixChecking($this,!0,!0)});checkStyle();$(thisApp.obj).find(".tab-pane").filter(".preload").removeClass("preload");cms.removeLoadingDiv($(thisApp.obj));if(thisApp.disableInitPreloadImages){thisApp.checkPreloadList(!1,data);if(initCallback)initCallback(data)}else{if(!thisApp.checkPreloadList(initCallback,data)){if(initCallback)initCallback(data)}}};if(thisApp.api&&thisApp.getID()){var passData=(thisApp.isRestFulAPI()?{h:$(thisApp.obj).find('#h').val()}:{uid:thisApp.getID(),h:$(thisApp.obj).find('#h').val()});$.ajax({type:(thisApp.isRestFulAPI()?'GET':'POST'),headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:passData,dataType:'json',url:(thisApp.isRestFulAPI()?thisApp.root+thisApp.api+'/'+thisApp.getID():thisApp.root+'lib/ajax/'+thisApp.api+'/get/'),success:successCall,error:function(){successCall(!1)}})}else if(thisApp.isLocalStorage){var thisAppData=thisApp.getData();successCall((thisAppData?{'status':1,'data':thisAppData}:!1))}else{onChangeChecker($(thisApp.obj).find("input[type=checkbox]"),'checked');onChangeChecker($(thisApp.obj).find("input[type=radio]"),'checked');onChangeChecker($(thisApp.obj).find("select"),'selected');formSelect(thisApp);$(thisApp.obj).find(".matrixGroup").each(function(){var $this=this;matrixChecking($this,!0,!0)});thisApp.applicationInit=!0;$(thisApp.obj).find(".tab-pane").filter(".preload").removeClass("preload");cms.removeLoadingDiv($(thisApp.obj));if(initCallback)initCallback();thisApp.bindChangeEvent()}},objVal:function(obj,v){var thisApp=this;if($(obj).is("input")){if($(obj).is("input[type=password]")){return} $(obj).val(v);if($(obj).hasClass("isRadio")){if(canDebug())console.log(obj);$(obj).closest(".radioGroup").find("input[type='radio']").filter("[value='"+v+"']").prop("checked",!0)} if($(obj).hasClass("isToggle")){var options=$(obj).closest(".selectGroup").find("option");if(v=="1"&&$(options).filter("[value='On']").length>0){v="On"} if(v=="0"&&$(options).filter("[value='Off']").length>0){v="Off"}} if($(obj).hasClass("isSelect")){selectObjVal($(obj),v);if(canDebug())console.log('select change ',v)} if($(obj).hasClass("isCheckbox")){var values=v.replace(/\|\|\|/g,"").split("||");$.each(values,function(k,v){$(obj).closest(".checkboxGroup").find("input[type='checkbox']").filter("[value='"+v+"']").prop("checked",!0)})} if(canDebug())console.log('uploadInput',v);if(canDebug())console.log('uploadInput',obj);if(canDebug())console.log('uploadInput Class',$(obj).hasClass("uploadInput"));if($(obj).hasClass("uploadInput")&&v){if(canDebug())console.log($(obj).closest(".uploadPlaceHolder"));if(canDebug())console.log($(obj).closest(".uploadPlaceHolder").find(".uploadLabel"));$(obj).closest(".uploadPlaceHolder").find(".uploadLabel").trigger("uploadLabelUploadSuccess",[v])} inputStyleChecking(thisApp,$(obj))}else if($(obj).is("textarea")){if($(obj).hasClass("wysiwyged")){tinyMCE.get($(obj).attr('id')).setContent(v);$(obj).val(v)}else{if($(obj).hasClass("cccForm")&&typeof v==="object")v="JSON::"+JSON.stringify(v);$(obj).val(v)} inputStyleChecking(thisApp,$(obj))}},bindChangeEvent:function(noPreload){var thisApp=this;if(thisApp.disableBinding)return;if(canDebug())console.log('bindChangeEvent');$(thisApp.obj).find(".cccFormBtn").unbind("click.cccFormBtn").bind("click.cccFormBtn",function(){var $this=this;var textareaObj=$($this).parent().next();var cccFormAPI=$(textareaObj).attr('cccdata-application-url');var cccFormAPIData=$(textareaObj).attr('cccdata-application-data');var cache=$(textareaObj).attr('cccdata-cache');if(cccFormAPI){var headers=thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()});var cacheKey=cccFormAPI+JSON.stringify(headers);cms.loadingDiv($("body"));var div=$('
    ');if(!thisApp.cacheHTML){thisApp.cacheHTML={}} var tplCallback=function(data){if(data)thisApp.cacheHTML[cacheKey]=data;cms.removeLoadingDiv($("body"));var innerApp;var thisDialog=BootstrapDialog.confirm(1,'info',$($this).text(),'',!0,!0,{'callback':function(result){if(result){}else{$('form.mainForm').find('input[type="submit"]').prop('disabled',!1)}}},[{label:'SAVE & CLOSE',hotkey:27,cssClass:'btn-default',action:function(dialog){typeof dialog.getData('callback')==='function'&&dialog.getData('callback')(!1);if(formChecking(innerApp)){if(innerApp)autoSave(innerApp,!0);dialog.close()}}}],function(dialog){dialog.$modalBody.append(div);$(dialog.$modalDialog).addClass("modal-90")},function(dialog){thisDialog.setCloseByKeyboard(!1);thisDialog.setCloseByBackdrop(!1);var data=$(textareaObj).val();data=cms.cccApp.decodeData(data);var appLoaded=!1;innerApp=cms.cccApp.init({isLocalStorage:!0,dialog:function(){return thisDialog},obj:$(dialog.$modalDialog).find(".cccApp"),data:(data?data:''),on:{"headers":function(headers){return thisApp.headers(headers)},"init":function(){cms.removeLoadingDiv($("body"));$(dialog.$modalDialog).find(".cccApp").animate({"opacity":1},500,function(){appLoaded=!0})},"save":function(data){if(data&&appLoaded){var saveData="JSON::"+JSON.stringify(data);if(saveData!=$(textareaObj).val()){$(textareaObj).val(saveData);if($(dialog.$modalDialog).find(".cccApp").closest(".modal-body.autoSaveModal").length>0){autoSave(thisApp,!0)}}}},"destory":function(){if(canDebug())console.log('onDestory App');dialog.close();innerApp.destroy()},"recordCreate":function(){}}});formSelect(thisApp)},function(dialog){if(canDebug())console.log('onhide')},function(dialog){innerApp.destroy()},!0)};if(thisApp.cacheHTML[cacheKey]&&cache){div.html(thisApp.cacheHTML[cacheKey]);tplCallback()}else{$.ajax({type:'POST',headers:headers,data:{'application':cccFormAPI,'pass_data':cccFormAPIData,},dataType:'html',url:cccframework_path+'cccApp/getApp/',success:function(data){div.html(data);tplCallback(data)}})}}});$(thisApp.obj).find("input,textarea").unbind("focus.cccForm").bind("focus.cccForm",function(){$(this).data("hasfocus",!0);$(this).bind("keyup.esc,keydown.esc",function(e){if(e.keyCode==27)e.stopPropagation()})});$(thisApp.obj).find("input,textarea").unbind("blur.cccForm").bind("blur.cccForm",function(){$(this).data("hasfocus",!1);$(this).unbind("keyup.esc,keydown.esc");if(canDebug())console.log('===',1);formChecking(thisApp,!1,!1,$(this));inputStyleChecking(thisApp,$(this))});$(thisApp.obj).find("input").unbind("keyup.cccAppEnter").bind("keyup.cccAppEnter",function(e){if(e.which===13&&$(this).data("hasfocus")){if(canDebug())console.log($(this));if($(this).closest(".tab-pane").length){$(this).closest(".tab-pane").find(".cccSubmit").triggerHandler("click")}else{$(this).closest(".cccApp").find(".cccSubmit").triggerHandler("click")}}});$(thisApp.obj).find("input").unbind('change.cccForm keyup.cccForm').bind('change.cccForm keyup.cccForm',function(){if(canDebug())console.log('===',2);formChecking(thisApp,!1,!1,$(this));inputStyleChecking(thisApp,$(this));onchangeCaseCheck(this,thisApp)});$(thisApp.obj).find("textarea.cccInput").unbind('change.cccForm').bind('change.cccForm',function(){formChecking(thisApp,!1,!1,$(this));inputStyleChecking(thisApp,$(this))});$(thisApp.obj).find("textarea").unbind('keyup.cccForm').bind('keyup.cccForm',function(){if(canDebug())console.log('===',3);formChecking(thisApp,!1,!1,$(this));inputStyleChecking(thisApp,$(this))});$(thisApp.obj).find("textarea").unbind('keydown.cccForm').bind('keydown.cccForm',function(){inputStyleChecking(thisApp,$(this))});$(thisApp.obj).find("input").unbind('keydown.cccForm').bind('keydown.cccForm',function(){inputStyleChecking(thisApp,$(this))});var checkTimer=!1;var objectList=[];$(thisApp.obj).find("select").unbind('change.cccForm').bind('change.cccForm',function(e,skipFormChecking,runNow){onChangeInsertValue(this,'select',!0);if(skipFormChecking)return;var $this=this;objectList.push($this);var runFunction=function(){formChecking(thisApp,!1,!1,$(objectList));objectList=[]};if(runNow){runFunction()}else{if(checkTimer)clearTimeout(checkTimer);checkTimer=setTimeout(runFunction,200)} inputStyleChecking(thisApp,$(this));onchangeCaseCheck(this,thisApp)});$(thisApp.obj).find("input[type=radio]").unbind('change.cccForm').bind('change.cccForm',function(){onChangeInsertValue(this,'radio',!0);if(canDebug())console.log('===',5);formChecking(thisApp,!1,!1,$(this))});$(thisApp.obj).find("input[type=checkbox]").unbind('change.cccForm').bind('change.cccForm',function(){onChangeInsertValue(this,'checkbox',!0);if(canDebug())console.log('===',6);formChecking(thisApp,!1,!1,$(this))});$(thisApp.obj).find("input.cccInput,select.cccInput,textarea.cccInput").unbind("change.autosave").bind("change.autosave",function(){if($(this).closest(".modal-body.autoSaveModal").length>0||$(this).closest(".formItem").hasClass("onChangeSave")){if($(this).closest(".matrixGroup").length){if(!$(this).closest(".matrixGroup").closest(".formItem").hasClass("disableAutoSave")){autoSave(thisApp,!0)}}else{autoSave(thisApp,!0)}} thisApp.reloadLayout()});$(thisApp.obj).find("input.cccCardNumber").unbind("keyup.cccCC").bind("keyup.cccCC",function(e){var obj=$(this);var group=$(obj).closest(".cccCC");if($(obj).val().length>=parseInt($(obj).attr('maxlength'))){var thisIndex=group.find(".cccCardNumber").index(obj);if(thisIndex>=0)group.find(".cccCardNumber").eq(thisIndex+1).focus()}else if($(obj).val().length==0&&e.keyCode==8){var thisIndex=group.find(".cccCardNumber").index(obj);if(thisIndex-1>=0&&thisIndex<=group.find(".cccCardNumber").length)group.find(".cccCardNumber").eq(thisIndex-1).focus()}});$(thisApp.obj).find("input,select,textarea").unbind("formSave").bind("formSave",function(){if(canDebug())console.log($(this));autoSave(thisApp,!0)});$(thisApp.obj).find("input,select,textarea").unbind("formSaveWithoutOnSave").bind("formSaveWithoutOnSave",function(){if(canDebug())console.log($(this));autoSave(thisApp,!0,!1,!1,!1,!1,!1,!0)});$(thisApp.obj).unbind("formSave").bind("formSave",function(){if(canDebug())console.log($(this));autoSave(thisApp,!0)});$(thisApp.obj).unbind("reloadLayout").bind("reloadLayout",thisApp.reloadLayout);$(thisApp.obj).unbind("checkFormSave").bind("checkFormSave",function(e,callback,falseCallback,data,pass){autoSave(thisApp,(pass==undefined?!1:pass),callback,!1,falseCallback,data)});$(thisApp.obj).unbind("checkFormSectionSave").bind("checkFormSectionSave",function(e,callback,falseCallback,obj,data,pass){autoSave(thisApp,(pass==undefined?!1:pass),callback,obj,falseCallback,data,!0)});$(thisApp.obj).find(".textareaChecker").unbind("change.wordcount keyup.wordcount").bind("change.wordcount keyup.wordcount",function(){countWords($(this),thisApp,$(this).closest(".formItem").find(".countPlaceHolder"),!0);countCharacters($(this),thisApp,$(this).closest(".formItem").find(".countPlaceHolder"),!0)});$(thisApp.obj).find(".matrixGroup").each(function(){var $this=this;matrixChecking($this,!0)});thisApp.reloadLayout();if(!noPreload)thisApp.checkPreloadList();formSelect(thisApp)},reloadLayout:function(){var thisApp=this;var checkSize=function(){if(canDebug())console.log('reloadLayout');$(".backstretched").each(function(k,v){$(v).backstretch($(v).attr("cccdata-file-path"));if($(v).closest(".matrixItem").length)$(v).closest(".matrixItem").find(".imageURLPreview").find("input.form-control").val($(v).attr("cccdata-file-path"));if($(thisApp.obj).hasClass("cccPreview")){$(v).addClass("pointer");$(v).unbind("click").bind("click",function(e){e.preventDefault();$.fancybox({'type':'image',href:$(v).attr("cccdata-file-path")+'&org=1',openEffect:'elastic',closeEffect:'elastic',helpers:{overlay:{locked:!1}}})})}});waitForFinalEvent(function(){$(thisApp.obj).find(".layoutBlockHeight").each(function(){if(canDebug())console.log($(this).parent().find(".layoutRefHeight"),$(this).parent().find(".layoutRefHeight").height());$(this).height($(this).parent().find(".layoutRefHeight").height())})},(thisApp.disableBinding?1000:50),"layoutRefHeight")};if(thisApp.reloadLayoutTimer)clearTimeout(thisApp.reloadLayoutTimer);thisApp.reloadLayoutTimer=setTimeout(checkSize,30)},checkPreloadList:function(callback,data){var thisApp=this;var thisAction=function(){var returnData=!1;$(thisApp.obj).find(".previewHolder").not(".loadingPreviewHolder").not(".previewInit").each(function(){var $this=this;$($this).addClass("loadingPreviewHolder");thisApp.preloadFile($this,callback,data);if(thisApp.preloadFileList.length>0){returnData=!0}});return returnData} if(thisApp.disableInitPreloadImages){setTimeout(function(){thisAction()},1);return!1} return thisAction()},disableInitPreloadImages:!1,preloadFileList:[],preloadFileListTimer:!1,preloadFile:function($this,callback,data){var thisApp=this;thisApp.preloadFileList.push($($this).attr('cccdata-file-id'));if(thisApp.preloadFileListTimer)clearTimeout(thisApp.preloadFileListTimer);thisApp.preloadFileListTimer=setTimeout(function(){$.ajax({type:'POST',headers:thisApp.headers({'X-Cccms-Key-Secret':$(thisApp.obj).find('#h').val()}),data:{uids:thisApp.preloadFileList,local_url:local_url,h:$(thisApp.obj).find('#h').val()},dataType:'json',url:cccframework_path+'cccForm/uploader/get/',success:function(data){if(data){$.each(data.data,function(k,v){var thisObj=$("[cccdata-file-id='"+k+"']");thisObj.html(v.split('.').pop())});$.each(data.deleted,function(k,v){var found=!1;if(data.image){if(Object.keys(data.image).length){if(v in data.image){found=!0}}} if(!found){var thisObj=$("[cccdata-file-id='"+v+"']");$(thisObj).closest(".uploadPlaceHolder").find(".uploadInput").val("");$(thisObj).closest(".uploadLabel").trigger('uploadLabelReset')}});var totalImage=0;var loadedImage=0;var thisCallback=function(){if(canDebug())console.log(totalImage,loadedImage);if(totalImage==loadedImage){$(window).trigger("resize");if(callback)callback(data);$(".cccImageFancybox").fancybox();formSelect(thisApp)}};var tarea_regex=/^(http|https)/;$.each(data.data,function(k,v){var thisObj=$("[cccdata-file-id='"+k+"']");var path=root_header_path+v;if(tarea_regex.test(String(v).toLowerCase())==!0){path=v} var uploadLabel=$(thisObj.closest(".uploadLabel"));uploadLabel.css("background","").removeClass("backstretched initResizer").attr("cccdata-file-path",path).attr("cccdata-type","").find(".backstretch").remove();if(v.split('.').pop().includes("mp3")||v.split('.').pop().includes("wav")){uploadLabel.attr("cccdata-type","music")} if(v.split('.').pop().includes("doc")||v.split('.').pop().includes("docx")||v.split('.').pop().includes("pdf")){uploadLabel.attr("cccdata-type","doc")}});if(data.image){if(Object.keys(data.image).length){$.each(data.image,function(k,v){var imagePath=cccframework_path+'cccForm/thumb/?option=s&size=800x600&file='+v;var thisObj=$("[cccdata-file-id='"+k+"']");totalImage++;thisObj.removeClass("loadingPreviewHolder").addClass("previewInit");$(thisObj.closest(".uploadPlaceHolder")).find(".uploadLabel").addClass("backstretched").attr("cccdata-type","image").attr("cccdata-file-path",imagePath).bind("backstretch.after",function(){$(this).unbind("backstretch.after");loadedImage++;thisCallback()}).bind("backstretch.error",function(){$(this).unbind("backstretch.error");loadedImage++;thisCallback()}).backstretch(imagePath)})}else{thisCallback()}}else{thisCallback()}}}});thisApp.preloadFileList=[]},200);return thisApp.preloadFileList}}},store:{}};function reposition(modal){var dialog=modal.find('.modal-dialog');modal.css('display','block');modal.css('width','100%');modal.css('height','100%');dialog.css("margin-top",($(window).height()-dialog.height())/2)};function changeGrecaptchaImage(obj){var newRandromID="";var possible="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";for(var i=0;i<5;i++)newRandromID+=possible.charAt(Math.floor(Math.random()*possible.length));$(obj).attr("src",cccframework_path+"lib/php/securimage-master/securimage_show.php?namespace="+newRandromID);$(obj).parent().find("input[name='grecaptchaImage_namespace']").val(newRandromID)} BootstrapDialog.confirm=function(size,type,title,message,closable,draggable,data,buttons,onshow,onshown,onhide,onhidden,disableCenter,isHTML){if(!title)title="Message";if(!closable)closable=!1;if(!draggable)draggable=!1;if(!isHTML){title=lang(title)} if(!isHTML){message=lang(message)} switch(size){case 2:size='size-large';break;default:size='size-normal';break} switch(type){case 'info':type='type-info';break;case 'primary':type='type-primary';break;case 'success':type='type-success';break;case 'warning':type='type-warning';break;case 'alert':type='type-danger';break;default:type='type-default';break} var dialog=new BootstrapDialog({type:type,size:size,title:title,message:message,closable:closable,draggable:!1,autodestroy:!0,data:data,buttons:buttons,onshow:function(dialogRef){$(dialogRef.$modalDialog).find(".bootstrap-dialog-title").addClass("f22");if(onshow&&typeof onshow=='function')onshow(dialogRef);var $htmlBody=$('html,body');$htmlBody.addClass("BootstrapDialog");if($htmlBody.hasClass("hasSelectable")){$htmlBody.selectable("disable")} if(!disableCenter)dialogRef.$modal.css('opacity',0)},onshown:function(dialogRef){if(!disableCenter)reposition(dialogRef.$modal);if(!disableCenter)dialogRef.$modal.fadeTo(200,1);if(onshown&&typeof onshown=='function')onshown(dialogRef)},onhide:function(dialogRef){if(onhide&&typeof onhide=='function')onhide(dialogRef);if(!disableCenter)dialogRef.$modal.fadeTo(200,0)},onhidden:function(dialogRef){if(onhidden&&typeof onhidden=='function')onhidden(dialogRef);if($('.bootstrap-dialog').length==1){var $htmlBody=$('html,body');$htmlBody.removeClass("BootstrapDialog");if($htmlBody.hasClass("hasSelectable")){$htmlBody.selectable("enable")}}}});dialog.realize();dialog.open();return dialog};$.ajaxSetup({always:function(data){if('checkData' in window){checkData(data)}}});$(document).ajaxSuccess(function(d,data,e){var finalData=!1;try{finalData=$.parseJSON(data.responseText)}catch(e){return!1} if(finalData){if('checkData' in window)checkData(finalData)}});