-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincoding.framework.min.js
More file actions
11 lines (11 loc) · 33.6 KB
/
incoding.framework.min.js
File metadata and controls
11 lines (11 loc) · 33.6 KB
1
2
3
4
5
6
7
8
9
10
11
"use strict";function IncAjaxEvent(){this.ResponseText="";this.StatusCode="";this.StatusText=""}IncAjaxEvent.Create=function(a){var b=new IncAjaxEvent();b.ResponseText=a.responseText;b.StatusCode=a.status;b.StatusText=a.statusText;return b};function IncSpecialBinds(){}IncSpecialBinds.Incoding="incoding";IncSpecialBinds.InitIncoding="initincoding";IncSpecialBinds.IncChangeUrl="incchangeurl";IncSpecialBinds.IncAjaxBefore="incajaxbefore";IncSpecialBinds.IncAjaxError="incajaxerror";IncSpecialBinds.IncAjaxComplete="incajaxcomplete";IncSpecialBinds.IncAjaxSuccess="incajaxsuccess";IncSpecialBinds.IncInsert="incinsert";IncSpecialBinds.DocumentBinds=[IncSpecialBinds.IncChangeUrl,IncSpecialBinds.IncAjaxBefore,IncSpecialBinds.IncAjaxError,IncSpecialBinds.IncAjaxComplete,IncSpecialBinds.IncAjaxSuccess,IncSpecialBinds.IncInsert];function AjaxAdapter(){this.params=function(b){var a=[];$(b).each(function(){var e=this.name;var f=this.selector;if(ExecutableHelper.IsNullOrEmpty(f)){a.push({name:e,value:f});return}var d=$.byName(e.replaceAll("[","\\[").replaceAll("]","\\]")).is("[type=checkbox],select,[type=radio]");var c=_.isArray(f)||f.toString().contains(",");if(_.isArray(f)||(c&&d)){$(f.toString().split(",")).each(function(){a.push({name:e,value:this})})}else{a.push({name:e,value:f})}});return a};this.request=function(a,b){$.extend(a,{headers:{"X-Requested-With":"XMLHttpRequest"},dataType:"JSON",success:function(d,f,c){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxSuccess),IncodingResult.Success(IncAjaxEvent.Create(c)));var e=new IncodingResult(d);b(e)},beforeSend:function(d,c){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxBefore),IncodingResult.Success(IncAjaxEvent.Create(d)))},complete:function(c,d){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxComplete),IncodingResult.Success(IncAjaxEvent.Create(c)))},error:function(c,e,d){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxError),IncodingResult.Success(IncAjaxEvent.Create(c)))},data:this.params(a.data)});return $.ajax(a)}}AjaxAdapter.Instance=new AjaxAdapter();function ExecutableHelper(){var getValAction=function(selector){if($(selector).is(":checkbox")){var onlyCheckbox=$(selector).filter(":checkbox");if(onlyCheckbox.length==1){return $(onlyCheckbox).is(":checked")}if(onlyCheckbox.length>1){var res=[];$(onlyCheckbox).each(function(){if(!$(this).is(":checked")){return true}res.push($(this).val());return true});return res}}else{if(($(selector).is("select")&&$(selector).length>1)){var res=[];$(selector).each(function(){var val=$(this).val();if(!ExecutableHelper.IsNullOrEmpty(val)){res.push(val)}});return res}else{if($(selector).is("select[multiple]")){var res=[];$($(selector).val()).each(function(){if(!ExecutableHelper.IsNullOrEmpty(this)){res.push(this)}});return res}else{if($(selector).is(":radio")){return $.byName($(selector).prop("name"),":checked").val()}else{if($(selector).is("select,textarea,input")){return $(selector).val()}}}}}var something=$(selector).val();return ExecutableHelper.IsNullOrEmpty(something)?$.trim($(selector).html()):something};this.self="";this.target="";this.event="";this.result="";this.TryGetVal=function(selector){if(ExecutableHelper.IsNullOrEmpty(selector)){return selector}if(selector instanceof jQuery){return selector.length!=0?getValAction(selector):""}var isPrimitiveType=(_.isNumber(selector)||_.isBoolean(selector)||_.isArray(selector)||_.isDate(selector)||_.isFunction(selector));var isObject=_.isObject(selector)&&!_.isElement($(selector)[0]);if((isPrimitiveType||isObject)&&!_.isString(selector)){return selector}selector=selector.toString();var isJqueryVariable=selector.startsWith("$(");var isSelector=(selector.startsWith("||")&&selector.endWith("||"));if(!isJqueryVariable&&!isSelector){return selector}if(isJqueryVariable){return this.TryGetVal(eval(selector))}var res;if(isSelector){var valueSelector=selector.substring(2,selector.length-2);valueSelector=valueSelector.substring(selector.indexOf("*")-1,selector.length);var isTypeSelector=function(type){return selector.startsWith("||{0}*".f(type))};if(isTypeSelector("ajax")||isTypeSelector("buildurl")){var options=$.parseJSON(valueSelector);if(!ExecutableHelper.IsNullOrEmpty(options.data)){for(var i=0;i<options.data.length;i++){options.data[i].selector=ExecutableHelper.Instance.TryGetVal(options.data[i].selector)}}if(isTypeSelector("buildurl")){var dataAsString="";if(!ExecutableHelper.IsNullOrEmpty(options.data)){for(var i=0;i<options.data.length;i++){options.data[i].selector=this.TryGetVal(options.data[i].selector)}dataAsString=options.data.select(function(item){return"{0}={1}".f(item.name,item.selector)}).join("&")}res="{0}?{1}".f(options.url,dataAsString)}else{var ajaxData;AjaxAdapter.Instance.request(options,function(result){ajaxData=result.data});res=ajaxData}}else{if(isTypeSelector("cookie")){res=$.cookie(valueSelector)}else{if(isTypeSelector("hashQueryString")){res=$.url(window.location.href).fparam(valueSelector.split(":")[0],valueSelector.split(":")[1])}else{if(isTypeSelector("hashUrl")){res=$.url(window.location.href).furl(valueSelector)}else{if(isTypeSelector("queryString")){res=$.url(window.location.href).param(valueSelector)}else{if(isTypeSelector("javascript")){res=eval(valueSelector)}}}}}}}return ExecutableHelper.IsNullOrEmpty(res)?"":res};this.TrySetValue=function(element,val){if($(element).is("[type=hidden]")&&$.byName($(element).prop("name")).length==2){return}if($(element).is(":checkbox")){var onlyCheckBoxes=$(element).filter(":checkbox");$(onlyCheckBoxes).prop("checked",false);if($(onlyCheckBoxes).length==1){if(ExecutableHelper.ToBool(val)){$(onlyCheckBoxes).prop("checked",true)}}else{var arrayVal=_.isArray(val)?val:val.split(",");$(onlyCheckBoxes).each(function(){if(arrayVal.contains($(this).val())){$(this).prop("checked",true)}else{$(this).prop("checked",false)}})}return}if($(element).is("select[multiple]")){$(element).val(val.split(","));return}if($(element).is("select")&&$(element).length>1){var arrayVal=_.isArray(val)?val:val.split(",");$(arrayVal).each(function(){if(this.toString()!=""){$('option[value="{0}"]'.f(this)).closest("select").val(this.toString())}});return}if($(element).is(":radio")){$.byName($(element).prop("name"),'[value="{0}"]'.f(val)).prop("checked",true);return}if($(element).is("script,label,div,span,p")){$(element).html(val)}else{$(element).val(val)}}}ExecutableHelper.Instance=new ExecutableHelper();ExecutableHelper.IsData=function(d,c,b){if(ExecutableHelper.IsNullOrEmpty(c)){return b.call(d)}var a=false;$(!_.isArray(d)?[d]:d).each(function(){var e=this[c];if(b.call(ExecutableHelper.IsNullOrEmpty(e)?"":e)){a=true;return false}});return a};ExecutableHelper.Filter=function(c,b){var a;if(_.isArray(c)){a=[];$(c).each(function(){if(b.isSatisfied(this)){a.push(this)}})}else{a=b.isSatisfied(c)?c:{}}return a};ExecutableHelper.Compare=function(c,a,b){b=b.toString().toLowerCase();if(b=="isempty"){return ExecutableHelper.IsNullOrEmpty(c)}c=ExecutableHelper.IsNullOrEmpty(c)?"":c.toString().toUpperCase();a=ExecutableHelper.IsNullOrEmpty(a)?"":a.toString().toUpperCase();if(b=="equal"){return c===a}if(b=="notequal"){return c!==a}if(b=="iscontains"){return c.contains(a)}if(b=="lessthan"){return parseFloat(c)<parseFloat(a)}if(b=="lessthanorequal"){return parseFloat(c)<=parseFloat(a)}if(b=="greaterthan"){return parseFloat(c)>parseFloat(a)}if(b=="greaterthanorequal"){return parseFloat(c)>=parseFloat(a)}throw new IncClientException({message:"Can't compare by method {0}".f(b)},{})};ExecutableHelper.IsNullOrEmpty=function(b){var c=_.isUndefined(b)||_.isNull(b)||_.isNaN(b)||b=="undefined";if(c){return true}if(_.isString(b)){return _.isEmpty(b.toString())}if(_.isArray(b)){return b.length==0}if(_.isNumber(b)||_.isDate(b)||_.isBoolean(b)||_.isFunction(b)){return false}var a=false;$.eachProperties(b,function(){a=true});return !a};ExecutableHelper.RedirectTo=function(c){var b=decodeURIComponent(c);var d=decodeURIComponent(window.location.hash);var a=b.contains("#")&&d.replace("#","")==b.split("#")[1];if(a){$(document).trigger(jQuery.Event(IncSpecialBinds.IncChangeUrl));return}window.location=c};ExecutableHelper.UrlDecode=function(a){return decodeURIComponent(a)};ExecutableHelper.UrlEncode=function(c){if(ExecutableHelper.IsNullOrEmpty(c)){return c}var b=function(){return this.replaceAll("&","%26").replaceAll("?","%3F").replaceAll("/","%2F").replaceAll("=","%3D").replaceAll(":","%3A").replaceAll("@","%40").replaceAll("#","%23")};if(c instanceof Array){for(var a=0;a<c.length;a++){c[a]=b.call(c[a])}return c}else{return b.call(c.toString())}};ExecutableHelper.ToBool=function(b){if(ExecutableHelper.IsNullOrEmpty(b)){return false}if(b instanceof Boolean){return b}var a=b.toString().toLocaleLowerCase();return a==="true"};function IncMustacheTemplate(){this.compile=function(a){return a};this.render=function(a,c){var b=Mustache.compile(a);return b(c)}}function IncHandlerbarsTemplate(){this.compile=function(tmpl){return navigator.Ie8?tmpl:Handlebars.precompile(tmpl)};this.render=function(tmpl,data){if(navigator.Ie8){return Handlebars.compile(tmpl)(data)}if(!_.isFunction(tmpl)){tmpl=eval("("+tmpl+")")}return Handlebars.template(tmpl)(data)}}function TemplateFactory(){}TemplateFactory.Version="";TemplateFactory.ToHtml=function(a,h,b,f){h=h+TemplateFactory.Version;if(navigator.Ie8){h=h+"ie8"}var d="";var c=typeof(Storage)!=="undefined";if(c){try{d=localStorage.getItem(h)}catch(g){d=""}}if(ExecutableHelper.IsNullOrEmpty(d)){var i=b();if(ExecutableHelper.IsNullOrEmpty(i)){throw"Template is empty"}d=a.compile(i);if(c){try{localStorage.setItem(h,d)}catch(g){if(g.name==="QUOTA_EXCEEDED_ERR"){localStorage.clear()}}}}if(!_.isArray(f)&&!ExecutableHelper.IsNullOrEmpty(f)){f=[f]}return a.render(d,{data:f})};function purl(a){function b(){this.parseUri=function(d){var e={attr:{},param:{}};if(d.contains("#")){e.attr.fragment=d.split("#")[1].replace("!","");var f=this;var c={};$.each(e.attr.fragment.split("&"),function(){var g=this.contains(":")?this.split(":")[0]:"root";var i=this.contains("?")?this.split("?")[1]:this;i=i.replace(g+":","");var h=f.parseString(i,"/");$.eachProperties(h,function(){var j="{0}__{1}".f(g,this);c[j]=h[this]})});e.param.fragment=c}else{e.attr.fragment="";e.param.fragment={}}if(d.split("#")[0].contains("?")){e.param.query=this.parseString(d.split("#")[0].split("?")[1],"&")}else{e.param.query={}}e.attr.base=d.split("#")[0].contains("?")?d.split("?")[0]:d;e.attr.fullBase=d.contains("#")?d.split("#")[0]:d;return e};this.merge=function(d,c,e){this.set(d.base,c,e);return d};this.parseString=function(d,e){var c=this;return this.reduce(String(d).split(e),function(f,k){try{k=ExecutableHelper.UrlDecode(k.replace(/\+/g," "))}catch(h){}var l=k.indexOf("="),j=c.lastBraceInKey(k),g=k.substr(0,j||l),i=k.substr(j||l,k.length),i=i.substr(i.indexOf("=")+1,i.length);if(""==g){g=k,i=""}return c.merge(f,g,i)},{base:{}}).base};this.set=function(e,d,f){var c=e[d];if(undefined===c){e[d]=f}};this.lastBraceInKey=function(g){var d=g.length,f,h;for(var e=0;e<d;++e){h=g[e];if("]"==h){f=false}if("["==h){f=true}if("="==h&&!f){return e}}};this.reduce=function(g,d){var e=0,c=g.length>>0,f=arguments[2];while(e<c){if(e in g){f=d.call(undefined,f,g[e],e,g)}++e}return f}}return{data:new b().parseUri(a||window.location.toString()),attr:function(c){c={anchor:"fragment"}[c]||c;return typeof c!=="undefined"?this.data.attr[c]:this.data.attr},param:function(c){return typeof c!=="undefined"?this.data.param.query[c]:this.data.param.query},fparam:function(e,d){if(arguments.length==0){return this.data.param.fragment}var c="{0}__{1}".f(d,e);return this.data.param.fragment.hasOwnProperty(c)?ExecutableHelper.UrlDecode(this.data.param.fragment[c]):""},encodeAllParams:function(){var c=this;var d=c.fparam();$.eachProperties(d,function(){var e=this.split("__")[1];var g=this.split("__")[0];var f=d[this.toString()];c.setFparam(e,f,g)})},setFparam:function(f,e,d){var c="{0}__{1}".f(d,f);return this.data.param.fragment[c]=ExecutableHelper.UrlEncode(e)},removeFparam:function(e,d){var c="{0}__{1}".f(d,e);if(this.data.param.fragment.hasOwnProperty(c)){delete this.data.param.fragment[c]}},clearFparam:function(){return this.data.param.fragment=[]},fprefixes:function(){var c=["root"];$.eachProperties(this.fparam(),function(){var d=this.split("__")[0];if(c.contains(d)){return true}c.push(d)});return c},furl:function(d){var e={root:""};var c=this.data.attr.fragment.contains("&")?this.data.attr.fragment.split("&"):[this.data.attr.fragment];$(c).each(function(){if(this.contains(":")){var g=this.split(":");e[g[0]]=g[1]}else{e.root=this}});var f=e[d];if(_.isUndefined(f)){return""}return f.contains("?")?f.split("?")[0]:""},setFurl:function(d){var c=d.contains("?")?d:d+"?";this.data.attr.fragment=c},url:function(){return this.data.attr.fullBase},toHref:function(){var d=this;var c="#!";$.each(d.fprefixes(),function(){var f=this;if(f!="root"){c+="{0}:".f(f)}if(!_.isEmpty(d.furl(f))){c+=d.furl(f)+"?"}var e=d.fparam();$.eachProperties(e,function(){var h=f+"__";if(!this.contains(h)){return true}var g=this.replace(h,"");if(_.isEmpty(g)){return true}c+="{0}={1}/".f(g,ExecutableHelper.UrlEncode(e[this]))});if(c.charAt(c.length-1)=="/"){c=c.cutLastChar()}c+="&"});return d.url()+c.trim().cutLastChar()}}}
/*!
* Incoding framework v 1.0.252.1122
* http://incframework.com
*
* Copyright 2013, 2013 Incoding software
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*/
"use strict";if(!window.console){window.console={log:function(){},error:function(){},dir:function(){}}}function InitGps(){if(navigator.geolocation&&!navigator.geolocation.currentPosition){navigator.geolocation.currentPosition={longitude:0,latitude:0};navigator.geolocation.getCurrentPosition(function(a){navigator.geolocation.currentPosition=a.coords},function(){})}}$.extend(String.prototype,{replaceAll:function(b,a){return this.split(b).join(a)},endWith:function(a){return(this.substr(this.length-a.length)===a)},startsWith:function(a){return(this.substr(0,a.length)===a)},trim:function(){return this.replace(/^\s\s*|\s\s*$/g,"")},ltrim:function(){return this.replace(/^\s+/,"")},rtrim:function(){return this.replace(/\s+$/,"")},cutLastChar:function(){return this.substring(0,this.length-1)},contains:function(a){return this.indexOf(a)!==-1},f:function(){var b=this;var a=arguments.length;while(a--){b=b.replace(new RegExp("\\{"+a+"\\}","gm"),arguments[a])}return b}});$.extend(Array.prototype,{contains:function(a){return $.inArray(a,this)!=-1},remove:function(c,b){var a=this.slice((b||c)+1||this.length);this.length=c<0?this.length+c:c;return this.push.apply(this,a)},sum:function(){var a=0;$(this).each(function(){a+=parseFloat(this)});return a},max:function(){return this.length>0?Math.max.apply(Math,this):0},min:function(){return this.length>0?Math.min.apply(Math,this):0},average:function(){return this.length>0?this.sum()/this.length:0},first:function(){return this.length>0?this[0]:""},last:function(){return this.length>0?this[this.length-1]:""},count:function(){return this.length},select:function(b){var a=[];$(this).each(function(){a.push(b(this))});return a}});function incodingExtend(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype}$.fn.extend({maxZIndex:function(b){var c={inc:10,group:"*"};$.extend(c,b);var a=0;$(c.group).each(function(){var d=parseInt($(this).css("z-index"));a=d>a?d:a});return this.each(function(){a+=c.inc;$(this).css({"z-index":a})})},toggleProp:function(a){if(this.prop(a)){$(this).prop(a,false)}else{$(this).prop(a,true)}return this},toggleAttr:function(a){if(this.attr(a)){$(this).removeAttr(a)}else{this.attr(a,a)}return this},increment:function(a){return $(this).each(function(){var b=parseInt($(this).val());$(this).val((_.isNaN(b)?0:b)+parseInt(a))})}});$.extend({eachProperties:function(a,b){for(var c in a){var d=!_.isUndefined(c)||!_.isEmpty(c);if(d&&a.hasOwnProperty(c)){b.call(c)}}},byName:function(a,c){if(ExecutableHelper.IsNullOrEmpty(a)){a=""}var b='[name="{0}"]'.f(a.toString().replaceAll("[","\\[").replaceAll("]","\\]"));if(ExecutableHelper.IsNullOrEmpty(c)){return $(b)}else{return $(b+c)}},eachFormElements:function(b,c){var e="input,select,textarea";var f='[type="submit"],[type="reset"],[type="button"]';var a;if($(b).is("input,select")){a=b.length>1?b:[b]}else{var d=$(b).find(e).not(f);a=d.length>1?d:[d]}$(a).each(c)},url:function(a){return purl(a)}});(function(e,b){var a=/\+/g;function c(f){return decodeURIComponent(f.replace(a," "))}var d=e.cookie=function(n,m,r){if(m!==undefined){r=e.extend({},d.defaults,r);if(m===null){r.expires=-1}if(typeof r.expires==="number"){var o=r.expires,q=r.expires=new Date();q.setDate(q.getDate()+o)}m=d.json?JSON.stringify(m):String(m);return(b.cookie=[encodeURIComponent(n),"=",encodeURIComponent(m),r.expires?"; expires="+r.expires.toUTCString():"",r.path?"; path="+r.path:"",r.domain?"; domain="+r.domain:"",r.secure?"; secure":""].join(""))}var f=c;var p=b.cookie.split("; ");for(var k=0,h=p.length;k<h;k++){var j=p[k].split("=");if(f(j.shift())===n){var g=f(j.join("="));return d.json?JSON.parse(g):g}}return null};d.defaults={};e.removeCookie=function(g,f){if(e.cookie(g)!==null){e.cookie(g,null,f);return true}return false}})(jQuery,document);navigator.Ie8=(function(){var c=navigator.appName,b=navigator.userAgent,a;var d=b.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);if(d&&(a=b.match(/version\/([\.\d]+)/i))!=null){d[2]=a[1]}d=d?[d[1],d[2]]:[c,navigator.appVersion,"-?"];return d.contains("MSIE")&&d.contains("8.0")})();function IncodingMetaElement(b){var c="incoding-runner";var a=function(e,d){var f=$(e).attr(d);if(!ExecutableHelper.IsNullOrEmpty(f)){return f}f=$(e).prop(d);if(!ExecutableHelper.IsNullOrEmpty(f)){return f}f=$.data(e,d);if(!ExecutableHelper.IsNullOrEmpty(f)){return f}return $(e).data(d)};this.element=b;this.runner=a(b,c);this.executables=!ExecutableHelper.IsNullOrEmpty(a(b,"incoding"))?$.parseJSON(a(b,"incoding")):"";this.bind=function(e,d){var f=this.element;$.each(IncSpecialBinds.DocumentBinds,function(){if(!e.contains(this)){return true}e=e.replaceAll(this,"");$(document).bind(this.toString(),function(h,g){new IncodingMetaElement(f).invoke(h,g);return false})});if(e===""){return}$(this.element).bind(e.toString(),function(i,g){new IncodingMetaElement(this).invoke(i,g);var h=d.toString();if(h==="4"||e===IncSpecialBinds.Incoding){return false}if(h==="2"){i.preventDefault()}if(h==="3"){i.stopPropagation()}return true})};this.invoke=function(f,d){if(!ExecutableHelper.IsNullOrEmpty(this.runner)){this.runner.DoIt(f,d)}};this.flushRunner=function(d){$.data(this.element,c,d)}}function IncodingRunner(){this.actions=[];this.before=[];this.success=[];this.error=[];this.complete=[];this.breakes=[]}IncodingRunner.prototype={DoIt:function(c,a){var e=this;var d=function(f){var g=$.trim(f.onBind).split(" ").contains(c.type);if(g){f.event=c}return g};try{$($.grep(this.before,d)).each(function(){this.execute()})}catch(b){if(b instanceof IncClientException){$($.grep(this.breakes,d)).each(function(){this.execute(b)});return}throw b}$($.grep(this.actions,d)).each(function(){this.execute({success:$.grep(e.success,d),error:$.grep(e.error,d),complete:$.grep(e.complete,d),breakes:$.grep(e.breakes,d),eventResult:a,event:c})})},Registry:function(c,b,a){if(c.contains("Action")){this.actions.push(a)}else{switch(b){case 1:this.before.push(a);break;case 2:this.success.push(a);break;case 3:this.error.push(a);break;case 4:this.complete.push(a);break;case 5:this.breakes.push(a);break;default:throw"Not found status {0}".f(b)}}}};function IncClientException(){}function IncodingResult(a){var b=function(f){try{var d=_.isObject(f)?f:$.parseJSON(f);var c=_.has(d,"success")&&_.has(d,"redirectTo")&&_.has(d,"data");if(!c){throw new "Not valid json result"}return d}catch(g){console.log("fail parse result:{0}".f(f));console.log("with exception:{0}".f(g));return""}};this.parseJson=b(a);this.isValid=function(){return !ExecutableHelper.IsNullOrEmpty(this.parseJson)};this.redirectTo=this.isValid()?this.parseJson.redirectTo:"";this.success=this.isValid()?this.parseJson.success:false;this.data=this.isValid()?this.parseJson.data:""}IncodingResult.Success=function(a){return new IncodingResult({success:true,data:a,redirectTo:""})};IncodingResult.Empty=new IncodingResult({data:"",redirectTo:"",success:true});function IncodingEngine(){this.parse=function(b){var c="[incoding]";var a=[];$(c,b).add($(b).is(c)?b:"").each(function(){var d=new IncodingMetaElement(this);var e=new IncodingRunner();var f=[];$(d.executables).each(function(){var h=this;var k=_.isObject(h.data)?h.data:$.parseJSON(h.data);var l=ExecutableFactory.Create(h.type,k,d.element);e.Registry(h.type,k.onStatus,l);var i=k.onBind.toString();if(f.contains(i)){return true}f.push(i);var j=ExecutableHelper.IsNullOrEmpty(h.data.onEventStatus)?"1":h.data.onEventStatus;d.bind(i.toString().replaceAll(IncSpecialBinds.InitIncoding,"").replaceAll(" "+IncSpecialBinds.InitIncoding,"").replaceAll(IncSpecialBinds.InitIncoding+" ","").trim().toString(),j.toString())});d.flushRunner(e);$(this).removeAttr("incoding");var g=$.grep(f,function(h){return h.contains(IncSpecialBinds.InitIncoding)}).length!=0;if(g){d.bind(IncSpecialBinds.InitIncoding,"4");a.push(this)}});$(a).each(function(){new IncodingMetaElement(this).invoke(jQuery.Event(IncSpecialBinds.InitIncoding))})}}IncodingEngine.Current=new IncodingEngine();var initializedHistoryPlugin=false;$(document).ready(function(){if($.history){$.history.init(function(){if(initializedHistoryPlugin){$(document).trigger(jQuery.Event(IncSpecialBinds.IncChangeUrl))}initializedHistoryPlugin=true})}IncodingEngine.Current.parse(document)});function ExecutableFactory(){}ExecutableFactory.Create=function(type,data,self){var json=_.isObject(data)?data:$.parseJSON(data);var executable=eval("new "+type+"();");executable.jsonData=json;executable.onBind=json.onBind;executable.self=self;executable.timeOut=json.timeOut;executable.interval=json.interval;executable.intervalId=json.intervalId;executable.ands=json.ands;executable.getTarget=function(){return eval(json.target)};return executable};function ExecutableBase(){this.jsonData="";this.onBind="";this.self="";this.event="";this.timeOut=0;this.interval=0;this.intervalId="";this.target="";this.ands=null;this.getTarget=function(){return this.self}}ExecutableBase.prototype={execute:function(a){var b=this;b.target=b.getTarget();if(!b.isValid(a)){return}if(b.timeOut>0){window.setTimeout(function(){b.target=b.getTarget();b.internalExecute(a)},b.timeOut);return}if(b.interval>0){ExecutableBase.IntervalIds[b.intervalId]=window.setInterval(function(){b.target=b.getTarget();b.internalExecute(a)},b.interval);return}b.internalExecute(a)},internalExecute:function(a){},isValid:function(b){var c=this;if(ExecutableHelper.IsNullOrEmpty(c.ands)){return true}var a=false;$(c.ands).each(function(){var d=false;$(this).each(function(){d=ConditionalFactory.Create(this,c).isSatisfied(b);if(!d){return false}});if(d){a=true;return false}});return a},tryGetVal:function(a){ExecutableHelper.Instance.self=this.self;ExecutableHelper.Instance.target=this.target;ExecutableHelper.Instance.event=this.event;return ExecutableHelper.Instance.TryGetVal(a)}};ExecutableBase.IntervalIds={};incodingExtend(ExecutableActionBase,ExecutableBase);function ExecutableActionBase(){}$.extend(ExecutableActionBase.prototype,{complete:function(a,f){if(!ExecutableHelper.IsNullOrEmpty(a.redirectTo)){ExecutableHelper.RedirectTo(a.redirectTo);return}var c=a.data;if(!ExecutableHelper.IsNullOrEmpty(this.jsonData.filterResult)){var e=ConditionalFactory.Create(this.jsonData.filterResult,this);c=ExecutableHelper.Filter(a.data,e)}var b=false;var d=function(){try{this.execute(c)}catch(g){if(g instanceof IncClientException){b=true;return false}console.log("Incoding exception: {0}".f(g.message?g.messsage:g));if(navigator.Ie8){return false}throw g}};$(a.success?f.success:f.error).each(d);$(f.complete).each(d);if(b){$(f.breakes).each(d)}}});incodingExtend(ExecutableDirectAction,ExecutableActionBase);function ExecutableDirectAction(){}ExecutableDirectAction.prototype.internalExecute=function(b){var a=ExecutableHelper.IsNullOrEmpty(this.jsonData.result)?IncodingResult.Empty:new IncodingResult(this.jsonData.result);this.complete(a,b)};incodingExtend(ExecutableEventAction,ExecutableActionBase);function ExecutableEventAction(){}ExecutableEventAction.prototype.internalExecute=function(a){this.complete(a.eventResult,a)};incodingExtend(ExecutableAjaxAction,ExecutableActionBase);function ExecutableAjaxAction(){}ExecutableAjaxAction.prototype.internalExecute=function(e){var f=this;var b=$.extend(true,{data:[]},this.jsonData.ajax);for(var d=0;d<b.data.length;d++){b.data[d].selector=this.tryGetVal(b.data[d].selector)}if(this.jsonData.hash){var a=$.url(document.location.href);if(ExecutableHelper.IsNullOrEmpty(b.url)){b.url=a.furl(this.jsonData.prefix)}var c=a.fparam();$.eachProperties(c,function(){var g=this.replace(f.jsonData.prefix+"__","");b.data.push({name:g,selector:c[this]})})}AjaxAdapter.Instance.request(b,function(g){f.complete(g,e)})};incodingExtend(ExecutableSubmitAction,ExecutableActionBase);function ExecutableSubmitAction(){}ExecutableSubmitAction.prototype.internalExecute=function(data){var current=this;var formSelector=eval(this.jsonData.formSelector);var form=$(formSelector).is("form")?formSelector:$(formSelector).closest("form").first();var ajaxOptions=$.extend(true,{error:function(error){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxError),IncodingResult.Success(IncAjaxEvent.Create(error)));$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxComplete),IncodingResult.Success(IncAjaxEvent.Create(error)))},success:function(responseText,statusText,xhr,$form){$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxSuccess),IncodingResult.Success(IncAjaxEvent.Create(xhr)));$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxComplete),IncodingResult.Success(IncAjaxEvent.Create(xhr)));current.complete(new IncodingResult(responseText),data)},beforeSubmit:function(formData,jqForm,options){var isValid=$(form).valid();if(!isValid){$(form).validate().focusInvalid()}else{$(document).trigger(jQuery.Event(IncSpecialBinds.IncAjaxBefore),IncodingResult.Success({}))}return isValid}},this.jsonData.options);if(!ExecutableHelper.IsNullOrEmpty(this.jsonData.options.data)){for(var i=0;i<this.jsonData.options.data.length;i++){ajaxOptions.data[i].value=this.tryGetVal(this.jsonData.options.data[i].value)}}$(form).ajaxSubmit(ajaxOptions)};incodingExtend(ExecutableInsert,ExecutableBase);function ExecutableInsert(){}ExecutableInsert.prototype.internalExecute=function(data){var current=this;var insertContent=ExecutableHelper.IsNullOrEmpty(data)?"":data;if(!ExecutableHelper.IsNullOrEmpty(current.jsonData.property)){var insertObject=data;if(_.isArray(data)){insertObject=data.length>0?data[0]:{}}insertContent=insertObject.hasOwnProperty(current.jsonData.property)?insertObject[current.jsonData.property]:""}if(ExecutableHelper.ToBool(current.jsonData.prepare)){$(_.isArray(insertContent)?insertContent:[insertContent]).each(function(){var item=this;$.eachProperties(this,function(){item[this]=current.tryGetVal(item[this])})})}if(!ExecutableHelper.IsNullOrEmpty(current.jsonData.template)){var templateId=current.jsonData.template;if(templateId.startsWith("||ajax*")){var buildUrlKey="||buildurl*"+templateId.substring(7,templateId.length);templateId=current.tryGetVal(buildUrlKey)}insertContent=TemplateFactory.ToHtml(ExecutableInsert.Template,templateId,function(){return current.tryGetVal(current.jsonData.template)},insertContent)}if(ExecutableHelper.IsNullOrEmpty(insertContent)){insertContent=""}eval("$(current.target).{0}(insertContent.toString())".f(current.jsonData.insertType));IncodingEngine.Current.parse(current.target);$(document).trigger(jQuery.Event(IncSpecialBinds.IncInsert))};ExecutableInsert.Template=new IncHandlerbarsTemplate();incodingExtend(ExecutableTrigger,ExecutableBase);function ExecutableTrigger(){}ExecutableTrigger.prototype.internalExecute=function(b){var a=ExecutableHelper.IsNullOrEmpty(this.jsonData.property)?b:b.hasOwnProperty(this.jsonData.property)?b[this.jsonData.property]:"";$(this.target).trigger(this.jsonData.trigger,new IncodingResult({success:true,data:a,redirectTo:""}))};incodingExtend(ExecutableValidationParse,ExecutableBase);function ExecutableValidationParse(){}ExecutableValidationParse.prototype.internalExecute=function(){var a=$(this.target).is("form")?this.target:$(this.target).closest("form").first();$(a).removeData("validator").removeData("unobtrusiveValidation");$.validator.unobtrusive.parse(a);$("[data-val-equalto-other]",a).each(function(){var b="#"+$(this).data("val-equalto-other").replaceAll("*.","Input_");if($(b).length>0){$(this).rules("add",{required:true,equalTo:b})}})};incodingExtend(ExecutableValidationRefresh,ExecutableBase);function ExecutableValidationRefresh(){}ExecutableValidationRefresh.prototype.internalExecute=function(a){var b=this;$(a).each(function(){var f=this.name.toString();var e=$("[name]",b.target).filter(function(){return $(this).attr("name").toLowerCase()==f.toLowerCase()});var g=$("[data-valmsg-for]",b.target).filter(function(){return $(this).attr("data-valmsg-for").toLowerCase()==f.toLowerCase()});var d="input-validation-error";var h="field-validation-error";var c="field-validation-valid";if(ExecutableHelper.ToBool(this.isValid)){$(e).removeClass(d);$(g).removeClass(h).addClass(c)}else{$(e).addClass(d);$(g).removeClass(c).addClass(h).html(this.errorMessage)}});$($(b.target).is("form")?b.target:$("form",this.target)).validate().focusInvalid()};incodingExtend(ExecutableEval,ExecutableBase);function ExecutableEval(){}ExecutableEval.prototype.internalExecute=function(data){eval(this.jsonData.code)};incodingExtend(ExecutableEvalMethod,ExecutableBase);function ExecutableEvalMethod(){}ExecutableEvalMethod.prototype.internalExecute=function(data){var length=this.jsonData.args.length;var args="";for(var i=0;i<length;i++){args+="this.tryGetVal(this.jsonData.args[{0}])".f(i);if(i!=length-1){args+=","}}var contextStr=ExecutableHelper.IsNullOrEmpty(this.jsonData.context)?"":this.jsonData.context+".";eval("{0}{1}({2})".f(contextStr,this.jsonData.method,args))};incodingExtend(ExecutableBreak,ExecutableBase);function ExecutableBreak(){}ExecutableBreak.prototype.internalExecute=function(a){throw new IncClientException()};incodingExtend(ExecutableStoreInsert,ExecutableBase);function ExecutableStoreInsert(){}ExecutableStoreInsert.prototype.internalExecute=function(){var a=$.url(document.location.href);var b=this.jsonData.prefix;if(ExecutableHelper.ToBool(this.jsonData.replace)){a.clearFparam()}$.eachFormElements(this.target,function(){var c=$(this).prop("name");if(ExecutableHelper.IsNullOrEmpty(c)){return}var d=ExecutableHelper.Instance.TryGetVal($.byName(c));if(ExecutableHelper.IsNullOrEmpty(d)){a.removeFparam(c,b)}else{a.setFparam(c,d,b)}});ExecutableHelper.RedirectTo(a.toHref())};incodingExtend(ExecutableStoreFetch,ExecutableBase);function ExecutableStoreFetch(){}ExecutableStoreFetch.prototype.internalExecute=function(){var a=this.jsonData.prefix+"__";var b=$.url(window.location.href).fparam();$.eachFormElements(this.target,function(){var c=$(this).prop("name");var d=a+c;var e="";if(b.hasOwnProperty(d)){e=b[d]}ExecutableHelper.Instance.TrySetValue($.byName(c),e)})};incodingExtend(ExecutableStoreManipulate,ExecutableBase);function ExecutableStoreManipulate(){}ExecutableStoreManipulate.prototype.internalExecute=function(c){var d=this;switch(d.jsonData.type){case"hash":var b=$.url(document.location.href);b.encodeAllParams();var a=$.parseJSON(d.jsonData.methods);$(a).each(function(){switch(this.verb){case"remove":b.removeFparam(this.key,this.prefix);break;case"set":b.setFparam(this.key,d.tryGetVal(this.value),this.prefix);break}});return ExecutableHelper.RedirectTo(b.toHref());default:throw"Argument out of range {0}".f(this.jsonData.type)}};incodingExtend(ExecutableForm,ExecutableBase);function ExecutableForm(){}ExecutableForm.prototype.internalExecute=function(){var a=$(this.target).is("form")?this.target:$(this.target).closest("form").first();var b=this.jsonData.method;switch(b){case"reset":$(a).resetForm();break;case"clear":$(a).clearForm();break}};incodingExtend(ExecutableBind,ExecutableBase);function ExecutableBind(){}ExecutableBind.prototype.internalExecute=function(){var a=this.jsonData.type;switch(a){case"attach":$(this.target).removeData("incoding-runner");$(this.target).attr("incoding",this.jsonData.meta);IncodingEngine.Current.parse(this.target);break;case"detach":if(ExecutableHelper.IsNullOrEmpty(this.jsonData.bind)){$(this.target).unbind()}else{$(this.target).unbind(this.jsonData.bind)}break}};function ConditionalFactory(){}ConditionalFactory.Create=function(data,executable){var conditional=eval("new Conditional"+data.type+"();");conditional.jsonData=data;conditional.executable=executable;return conditional};function ConditionalBase(){this.jsonData="";this.executable="";this.self="";this.target=""}ConditionalBase.prototype={isSatisfied:function(b){this.self=this.executable.self;this.target=this.executable.getTarget();var a=this.isInternalSatisfied(b);return ExecutableHelper.ToBool(this.jsonData.inverse)?!a:a},isInternalSatisfied:function(a){},tryGetVal:function(a){return this.executable.tryGetVal(a)}};incodingExtend(ConditionalData,ConditionalBase);function ConditionalData(){}ConditionalData.prototype.isInternalSatisfied=function(b){var a=this.tryGetVal(this.jsonData.value);var c=this.jsonData.method;return ExecutableHelper.IsData(b,this.jsonData.property,function(){return ExecutableHelper.Compare(this,a,c)})};incodingExtend(ConditionalDataIsId,ConditionalBase);function ConditionalDataIsId(){}ConditionalDataIsId.prototype.isInternalSatisfied=function(a){return ExecutableHelper.IsData(a,this.jsonData.property,function(){return $("#"+this).length>0})};incodingExtend(ConditionalEval,ConditionalBase);function ConditionalEval(){}ConditionalEval.prototype.isInternalSatisfied=function(data){return eval(this.jsonData.code)};incodingExtend(ConditionalIs,ConditionalBase);function ConditionalIs(){}ConditionalIs.prototype.isInternalSatisfied=function(b){var c=this.tryGetVal(this.jsonData.left);var a=this.tryGetVal(this.jsonData.right);return ExecutableHelper.Compare(c,a,this.jsonData.method)};