New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ax5ui-binder

Package Overview
Dependencies
Maintainers
1
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ax5ui-binder - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

2

bower.json
{
"name": "ax5ui-binder",
"version": "0.1.1",
"version": "0.2.0",
"authors": [

@@ -5,0 +5,0 @@ "ThomasJ <tom@axisj.com>"

@@ -11,3 +11,3 @@ "use strict";

className: "binder",
version: "0.1.1"
version: "0.2.0"
}, function () {

@@ -70,7 +70,14 @@

},
get_real_path = function get_real_path(dataPath) {
get_real_path = function get_real_path(_dataPath) {
var path = [];
var _path = [].concat(_dataPath.split(/[\.\[\]]/g));
_path.forEach(function (n) {
if (n !== "") path.push("[\"" + n.replace(/['\"]/g, "") + "\"]");
});
_path = null;
return path.join("");
/*
var path = [];
var _path = [].concat(dataPath.split(/[\.\[\]]/g));
_path.forEach(function (n) {
_path.forEach(function (n) {
if (n !== "") path.push(n);

@@ -80,2 +87,3 @@ });

return "'" + path.join("']['") + "'";
*/
};

@@ -124,3 +132,3 @@

Function("val", "this[" + get_real_path(dataPath) + "] = val;").call(this.model, value);
Function("val", "this" + get_real_path(dataPath) + " = val;").call(this.model, value);
obj_type = get_type(value);

@@ -160,3 +168,3 @@

} else {
return Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
return Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
}

@@ -230,3 +238,3 @@ };

this.add = function (dataPath, item) {
var list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -236,3 +244,3 @@ item['@i'] = list.length;

item.__ADDED__ = true;
Function("val", "this[" + get_real_path(dataPath) + "].push(val);").call(this.model, item);
Function("val", "this" + get_real_path(dataPath) + ".push(val);").call(this.model, item);

@@ -275,3 +283,3 @@ // 다중 템플릿 처리

this.remove = function (dataPath, index) {
var list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -319,3 +327,3 @@ if (typeof index == "undefined") index = list.length - 1;

this.update = function (dataPath, index, item) {
var list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -352,4 +360,4 @@ if (typeof index != "undefined" && item) list.splice(index, 1, item);

this.childAdd = function (dataPath, index, child_path, child_item) {
var _list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";").call(this.model);
var _list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";").call(this.model);
child_item.__ADDED__ = true;

@@ -368,4 +376,4 @@ list.push(child_item);

this.childRemove = function (dataPath, index, child_path, child_index) {
var _list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";").call(this.model);
var _list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";").call(this.model);
var remove_item = list[child_index];

@@ -389,4 +397,4 @@ if (remove_item.__ADDED__) {

this.childUpdate = function (dataPath, index, child_path, child_index, child_item) {
var _list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";").call(this.model);
var _list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";").call(this.model);
list[child_index] = child_item;

@@ -407,3 +415,3 @@ this.update(dataPath, index, _list[index]);

i;
Function("val", "this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + " = val;").call(this.model, value);
Function("val", "this" + get_real_path(dataPath) + "[" + index + "]." + child_path + " = val;").call(this.model, value);

@@ -448,3 +456,3 @@ // apply data value to els

try {
val = Function("", "return this[" + get_real_path(dataPath) + "];").call(_this.model);
val = Function("", "return this" + get_real_path(dataPath) + ";").call(_this.model);
} catch (e) {

@@ -496,3 +504,3 @@ /**

dataPath = dom.attr("data-ax-path"),
origin_value = Function("", "return this[" + get_real_path(dataPath) + "];").call(_this.model),
origin_value = Function("", "return this" + get_real_path(dataPath) + ";").call(_this.model),
this_type = (this.type || "").toLowerCase(),

@@ -537,3 +545,3 @@ value_type = get_type(origin_value),

Function("val", "this[" + get_real_path(dataPath) + "] = val;").call(_this.model, origin_value);
Function("val", "this" + get_real_path(dataPath) + " = val;").call(_this.model, origin_value);
_this.change(dataPath, {

@@ -544,3 +552,3 @@ el: this, jquery: dom, tagname: this.tagName.toLowerCase(), value: origin_value

if (setAllow) {
Function("val", "this[" + get_real_path(dataPath) + "] = val;").call(_this.model, this.value);
Function("val", "this" + get_real_path(dataPath) + " = val;").call(_this.model, this.value);
_this.change(dataPath, {

@@ -623,5 +631,5 @@ el: this, jquery: dom, tagname: this.tagName.toLowerCase(), value: this.value

options[0].selected = true;
Function("val", "this[" + get_real_path(dataPath) + "] = val;").call(this.model, options[0].value);
Function("val", "this" + get_real_path(dataPath) + " = val;").call(this.model, options[0].value);
} else {
Function("val", "this[" + get_real_path(dataPath) + "] = val;").call(this.model, "");
Function("val", "this" + get_real_path(dataPath) + " = val;").call(this.model, "");
}

@@ -670,3 +678,3 @@ }

this.print_tmpl = function (dataPath, tmpl, isInit) {
var list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);
if (list && get_type(list) == "array") {

@@ -702,3 +710,3 @@ for (var i = 0, l = list.length; i < l; i++) {

index = target.attr("data-ax-repeat-i");
var list = Function("", "return this[" + get_real_path(dataPath) + "];").call(this.model);
var list = Function("", "return this" + get_real_path(dataPath) + ";").call(this.model);

@@ -853,3 +861,3 @@ target.find('[data-ax-repeat-click]').unbind("click.axbinder").bind("click.axbinder", function (e) {

if (is_validate) {
var val = Function("", "return this[" + get_real_path(dataPath) + "];").call(_this.model);
var val = Function("", "return this" + get_real_path(dataPath) + ";").call(_this.model);
if (typeof val === "undefined") val = "";

@@ -886,3 +894,3 @@ var _val = val.toString();

item_path = dom.attr("data-ax-item-path");
var val = Function("", "return this[" + get_real_path(dataPath) + "][" + repeat_idx + "]." + item_path + ";").call(_this.model);
var val = Function("", "return this" + get_real_path(dataPath) + "[" + repeat_idx + "]." + item_path + ";").call(_this.model);
if (typeof val === "undefined") val = "";

@@ -889,0 +897,0 @@ var _val = val.toString();

@@ -1,1 +0,1 @@

"use strict";!function(){var t=ax5.ui,e=ax5.util;t.addClass({className:"binder",version:"0.1.1"},function(){var t=function(){var t;this.instanceId=ax5.getGuid(),this.config={},t=this.config,this.model={},this.tmpl={},this.view_target=null,this.change_trigger={},this.click_trigger={},this.update_trigger={},this.onerror=null;var a=Object.prototype.toString,i=function(t){var e;return null!=t&&t==t.window?e="window":t&&1==t.nodeType?e="element":t&&11==t.nodeType?e="fragment":"undefined"==typeof t?e="undefined":"[object Object]"==a.call(t)?e="object":"[object Array]"==a.call(t)?e="array":"[object String]"==a.call(t)?e="string":"[object Number]"==a.call(t)?e="number":"[object NodeList]"==a.call(t)?e="nodelist":"function"==typeof t&&(e="function"),e},n=function(t,e,a){return t+"["+e+"]"+("."==a?"":"."+a)},r=function(t){var e=[],a=[].concat(t.split(/[\.\[\]]/g));return a.forEach(function(t){""!==t&&e.push(t)}),a=null,"'"+e.join("']['")+"'"};this.setModel=function(t,e){return this.model=t,!this.view_target&&e?(this.view_target=e,this._binding()):this._binding("update"),this},this.set=function(t,e){var a,n,h,s=this;if(Function("val","this["+r(t)+"] = val;").call(this.model,e),a=i(e),"object"==a)for(var l in e)this.set(t+"."+l,e[l]);else if("array"==a)for(this.view_target.find('[data-ax-path="'+t+'"]').each(function(){h=(this.type||"").toLowerCase(),("checkbox"==h||"radio"==h)&&s.set_els_value(this,this.tagName.toLowerCase(),h,e,t,"change")}),n=e.length;n--;)this.set(t+"["+n+"]",e[n]);else this.view_target.find('[data-ax-path="'+t+'"]').each(function(){s.set_els_value(this,this.tagName.toLowerCase(),(this.type||"").toLowerCase(),e,t,"change")});return this},this.get=function(t){return"undefined"==typeof t?this.model:Function("","return this["+r(t)+"];").call(this.model)},this.onChange=function(t,e){return this.change_trigger[t||"*"]=e,this},this.onClick=function(t,e){return this.click_trigger[t]=e,this},this.add=function(t,e){var a=Function("","return this["+r(t)+"];").call(this.model),i=this.tmpl[t];e["@i"]=a.length,e["@r"]=a.length,e.__ADDED__=!0,Function("val","this["+r(t)+"].push(val);").call(this.model,e);for(var n in i){var h=$(ax5.mustache.render(i[n].content,e));h.attr("data-ax-repeat-path",t),h.attr("data-ax-repeat-i",e["@i"]),this.bind_event_tmpl(h,t),i[n].container.append(h)}this.change("*");var s=this.update_trigger[t];if(s){var l={repeat_path:t,tmpl:i,list:a};s.call(l,l)}return this},this.remove=function(t,e){var a=Function("","return this["+r(t)+"];").call(this.model),i=this.tmpl[t];"undefined"==typeof e&&(e=a.length-1);var n=a[e];n.__ADDED__?a.splice(e,1):a[e].__DELETED__=!0;for(var h in i)i[h].container.empty(),this.print_tmpl(t,i[h]);this.change("*");var s=this.update_trigger[t];if(s){var l={repeat_path:t,tmpl:i,list:a};s.call(l,l)}return this},this.update=function(t,e,a){var i=Function("","return this["+r(t)+"];").call(this.model),n=this.tmpl[t];"undefined"!=typeof e&&a&&i.splice(e,1,a);for(var h in n)n[h].container.empty(),this.print_tmpl(t,n[h]);this.change("*");var s=this.update_trigger[t];if(s){var l={repeat_path:t,tmpl:n,list:i};s.call(l,l)}return this},this.childAdd=function(t,e,a,i){var n=Function("","return this["+r(t)+"];").call(this.model),h=Function("","return this["+r(t)+"]["+e+"]."+a+";").call(this.model);i.__ADDED__=!0,h.push(i),this.update(t,e,n[e])},this.childRemove=function(t,e,a,i){var n=Function("","return this["+r(t)+"];").call(this.model),h=Function("","return this["+r(t)+"]["+e+"]."+a+";").call(this.model),s=h[i];s.__ADDED__?h.splice(i,1):h[i].__DELETED__=!0,this.update(t,e,n[e])},this.childUpdate=function(t,e,a,i,n){var h=Function("","return this["+r(t)+"];").call(this.model),s=Function("","return this["+r(t)+"]["+e+"]."+a+";").call(this.model);s[i]=n,this.update(t,e,h[e])},this.childSet=function(t,e,a,i){var n=this;return Function("val","this["+r(t)+"]["+e+"]."+a+" = val;").call(this.model,i),this.view_target.find('[data-ax-repeat="'+t+'"]').find('[data-ax-repeat-i="'+e+'"]').find('[data-ax-item-path="'+a+'"]').each(function(){n.set_els_value(this,this.tagName.toLowerCase(),(this.type||"").toLowerCase(),i,t+"["+e+"]."+a)}),this},this.onUpdate=function(t,e){return this.update_trigger[t]=e,this},this._binding=function(t){var e=this;this.view_target.find("[data-ax-path]").each(function(){var t,a=$(this),i=a.attr("data-ax-path"),n=(this.type||"").toLowerCase();try{t=Function("","return this["+r(i)+"];").call(e.model)}catch(h){e.onerror&&e.onerror("not found target [model."+r(i)+"]")}e.set_els_value(this,this.tagName.toLowerCase(),n,t||"",i)}),"undefined"==typeof t?this.view_target.find("[data-ax-repeat]").each(function(){var t=$(this),a=t.attr("data-ax-repeat"),i=t.attr("data-ax-repeat-idx");"undefined"==typeof e.tmpl[a]&&(e.tmpl[a]={}),"undefined"!=typeof i?e.tmpl[a][i]={container:t,content:t.find("script").html()}:e.tmpl[a][0]={container:t,content:t.find("script").html()},t.empty()}):this.view_target.find("[data-ax-repeat]").each(function(){var t=$(this);t.empty().show()}),this.view_target.find("[data-ax-path]").unbind("change.axbinder").bind("change.axbinder",function(t){var a,n,h=!1,s=[],l=$(t.target),o=l.attr("data-ax-path"),c=Function("","return this["+r(o)+"];").call(e.model),u=(this.type||"").toLowerCase(),d=i(c),f=!0;if(("object"==d||"array"==d)&&(f=!1),"checkbox"==u){if(e.view_target.find('[data-ax-path="'+o+'"]').length>1){for("array"!=i(c)&&(c="undefined"==typeof c||""==c?[]:[].concat(c)),a=c.length,h=!1,n=this.checked;a--;)c[a]==this.value&&(h=!0);if(n)h||c.push(this.value);else{for(a=c.length;a--;)c[a]==this.value||s.push(c[a]);c=s}}else c=this.checked?this.value:"";Function("val","this["+r(o)+"] = val;").call(e.model,c),e.change(o,{el:this,jquery:l,tagname:this.tagName.toLowerCase(),value:c})}else f&&(Function("val","this["+r(o)+"] = val;").call(e.model,this.value),e.change(o,{el:this,jquery:l,tagname:this.tagName.toLowerCase(),value:this.value}));l.data("changedTime",(new Date).getTime())});var a;for(var n in e.tmpl){for(var h in e.tmpl[n])this.print_tmpl(n,e.tmpl[n][h],"isInit");if(a=this.update_trigger[n]){var s={repeat_path:n,tmpl:e.tmpl[n],list:Function("","return this."+n+";").call(this.model)};a.call(s,s)}}},this.set_els_value=function(t,e,a,i,n,h){i="undefined"==typeof i?[]:[].concat(i);var s,l;if("input"==e)if("checkbox"==a||"radio"==a){l=i.length;var o=!1;try{if(l>0)for(;l--;)"undefined"!=typeof i[l]&&t.value===i[l].toString()&&(o=!0)}catch(c){console.log(c)}t.checked=o}else t.value=i.join("");else if("select"==e){s=t.options,l=s.length;for(var u,d=!1;l--;){for(u=i.length;u--;)if("undefined"!=typeof i[u]&&s[l].value===i[u].toString()){s[l].selected=!0,d=!0;break}if(d)break}d||(s[0]?(s[0].selected=!0,Function("val","this["+r(n)+"] = val;").call(this.model,s[0].value)):Function("val","this["+r(n)+"] = val;").call(this.model,"")),window.AXSelect&&$("undefined"!=typeof i&&t).bindSelectSetValue(i[i.length-1])}else"textarea"==e?t.value=i.join("")||"":t.innerText?t.innerText=i.join(""):t.innerHTML=i.join("");return h&&this.change(n,{el:t,tagname:e,value:i}),this},this.change=function(t,e){var a=this.change_trigger[t];a&&a.call(e,e),"*"!=t&&this.change_trigger["*"]&&this.change_trigger["*"].call(e,e)},this.click=function(t,e){var a=this.click_trigger[t];a&&a.call(e,e)},this.sync_model=function(){},this.print_tmpl=function(t,e,a){var n=Function("","return this["+r(t)+"];").call(this.model);if(n&&"array"==i(n))for(var h=0,s=n.length;s>h;h++){var l=n[h];if(jQuery.isPlainObject(l)?(l["@i"]=h,l["@r"]=h,0===h&&(l["@first"]=!0)):(l={"@i":h,"@value":l},0===h&&(l["@first"]=!0),console.log(l)),!l.__DELETED__){var o=$(ax5.mustache.render(e.content,l));o.attr("data-ax-repeat-path",t),o.attr("data-ax-repeat-i",l["@i"]),this.bind_event_tmpl(o,t),e.container.append(o)}}},this.bind_event_tmpl=function(t,e){var a=this,h=t.attr("data-ax-repeat-i"),s=Function("","return this["+r(e)+"];").call(this.model);t.find("[data-ax-repeat-click]").unbind("click.axbinder").bind("click.axbinder",function(t){var i=ax5.util.findParentNode(t.target,function(t){return t.getAttribute("data-ax-repeat-click")});if(i){var n=$(i),r=n.attr("data-ax-repeat-click"),l=(n.attr("data-ax-repeat-path"),{el:i,jquery:n,tagname:i.tagName.toLowerCase(),value:r,repeat_path:e,item:s[h],item_index:h,item_path:e+"["+h+"]"});a.click(e,l)}}),t.find("[data-ax-item-path]").each(function(){var t,i=$(this),r=i.attr("data-ax-item-path"),s=n(e,h,r),l=(this.type||"").toLowerCase();try{t=Function("","return this."+s+";").call(a.model)}catch(o){a.onerror&&a.onerror("not found target [model."+s+"]")}a.set_els_value(this,this.tagName.toLowerCase(),l,t||"",s)}),t.find("[data-ax-item-path]").unbind("change.axbinder").bind("change.axbinder",function(r){var s,l,o=!1,c=[],u=(this.type||"").toLowerCase(),d=$(r.target),f=d.attr("data-ax-item-path"),p=n(e,h,f),g=Function("","return this."+p+";").call(a.model),v=i(g),m=!0;if(("object"==v||"array"==v)&&(m=!1),"checkbox"==u){if(t.find('[data-ax-item-path="'+f+'"]').length>1){for("array"!=i(g)&&(g="undefined"==typeof g||""==g?[]:[].concat(g)),s=g.length,o=!1,l=this.checked;s--;)g[s]==this.value&&(o=!0);if(l)o||g.push(this.value);else{for(s=g.length;s--;)g[s]==this.value||c.push(g[s]);g=c}}else g=this.checked?this.value:"";Function("val","this."+p+" = val;").call(a.model,g),a.change(p,{el:this,jquery:d,tagname:this.tagName.toLowerCase(),value:g})}else m&&(Function("val","this."+p+" = val;").call(a.model,this.value),a.change(p,{el:this,jquery:d,tagname:this.tagName.toLowerCase(),value:this.value}));d.data("changedTime",(new Date).getTime())}),t.find("[data-ax-item-path]").unbind("blur.axbinder").bind("blur.axbinder",function(t){var e=$(t.target);("undefined"==typeof e.data("changedTime")||e.data("changedTime")<(new Date).getTime()-10)&&e.trigger("change")})},this.focus=function(t){return this.view_target.find('[data-ax-path="'+t+'"]').focus(),this},this.validate=function(){var t=this,e=[];return this.view_target.find("[data-ax-path]").each(function(){var a=$(this),i=a.attr("data-ax-path"),n=a.attr("data-ax-validate");if(n){var h=Function("","return this["+r(i)+"];").call(t.model);"undefined"==typeof h&&(h="");var s=h.toString(),l=!1;"required"==n&&""==s.trim()?l=!0:!/\D.?/g.test(n)&&s.trim().length<n.number()&&(l=!0),l&&e.push({type:n,dataPath:i,el:this,jquery:a,value:h})}}),this.view_target.find("[data-ax-repeat-path]").each(function(){var a=$(this),i=a.attr("data-ax-repeat-path"),n=a.attr("data-ax-repeat-i");a.find("[data-ax-validate]").each(function(){var a=$(this),h=a.attr("data-ax-validate"),s=a.attr("data-ax-item-path"),l=Function("","return this["+r(i)+"]["+n+"]."+s+";").call(t.model);"undefined"==typeof l&&(l="");var o=l.toString();if(h){var c=!1;"required"==h&&""==o.trim()?c=!0:!/\D.?/g.test(h)&&o.trim().length<h.number()&&(c=!0),c&&e.push({type:h,dataPath:i,el:this,jquery:a,value:l})}})}),e.length>0?{error:e}:{}},this.main=function(){arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};return t}())}();
"use strict";!function(){var t=ax5.ui,e=ax5.util;t.addClass({className:"binder",version:"0.2.0"},function(){var t=function(){var t;this.instanceId=ax5.getGuid(),this.config={},t=this.config,this.model={},this.tmpl={},this.view_target=null,this.change_trigger={},this.click_trigger={},this.update_trigger={},this.onerror=null;var a=Object.prototype.toString,i=function(t){var e;return null!=t&&t==t.window?e="window":t&&1==t.nodeType?e="element":t&&11==t.nodeType?e="fragment":"undefined"==typeof t?e="undefined":"[object Object]"==a.call(t)?e="object":"[object Array]"==a.call(t)?e="array":"[object String]"==a.call(t)?e="string":"[object Number]"==a.call(t)?e="number":"[object NodeList]"==a.call(t)?e="nodelist":"function"==typeof t&&(e="function"),e},n=function(t,e,a){return t+"["+e+"]"+("."==a?"":"."+a)},r=function(t){var e=[],a=[].concat(t.split(/[\.\[\]]/g));return a.forEach(function(t){""!==t&&e.push('["'+t.replace(/['\"]/g,"")+'"]')}),a=null,e.join("")};this.setModel=function(t,e){return this.model=t,!this.view_target&&e?(this.view_target=e,this._binding()):this._binding("update"),this},this.set=function(t,e){var a,n,h,l=this;if(Function("val","this"+r(t)+" = val;").call(this.model,e),a=i(e),"object"==a)for(var s in e)this.set(t+"."+s,e[s]);else if("array"==a)for(this.view_target.find('[data-ax-path="'+t+'"]').each(function(){h=(this.type||"").toLowerCase(),("checkbox"==h||"radio"==h)&&l.set_els_value(this,this.tagName.toLowerCase(),h,e,t,"change")}),n=e.length;n--;)this.set(t+"["+n+"]",e[n]);else this.view_target.find('[data-ax-path="'+t+'"]').each(function(){l.set_els_value(this,this.tagName.toLowerCase(),(this.type||"").toLowerCase(),e,t,"change")});return this},this.get=function(t){return"undefined"==typeof t?this.model:Function("","return this"+r(t)+";").call(this.model)},this.onChange=function(t,e){return this.change_trigger[t||"*"]=e,this},this.onClick=function(t,e){return this.click_trigger[t]=e,this},this.add=function(t,e){var a=Function("","return this"+r(t)+";").call(this.model),i=this.tmpl[t];e["@i"]=a.length,e["@r"]=a.length,e.__ADDED__=!0,Function("val","this"+r(t)+".push(val);").call(this.model,e);for(var n in i){var h=$(ax5.mustache.render(i[n].content,e));h.attr("data-ax-repeat-path",t),h.attr("data-ax-repeat-i",e["@i"]),this.bind_event_tmpl(h,t),i[n].container.append(h)}this.change("*");var l=this.update_trigger[t];if(l){var s={repeat_path:t,tmpl:i,list:a};l.call(s,s)}return this},this.remove=function(t,e){var a=Function("","return this"+r(t)+";").call(this.model),i=this.tmpl[t];"undefined"==typeof e&&(e=a.length-1);var n=a[e];n.__ADDED__?a.splice(e,1):a[e].__DELETED__=!0;for(var h in i)i[h].container.empty(),this.print_tmpl(t,i[h]);this.change("*");var l=this.update_trigger[t];if(l){var s={repeat_path:t,tmpl:i,list:a};l.call(s,s)}return this},this.update=function(t,e,a){var i=Function("","return this"+r(t)+";").call(this.model),n=this.tmpl[t];"undefined"!=typeof e&&a&&i.splice(e,1,a);for(var h in n)n[h].container.empty(),this.print_tmpl(t,n[h]);this.change("*");var l=this.update_trigger[t];if(l){var s={repeat_path:t,tmpl:n,list:i};l.call(s,s)}return this},this.childAdd=function(t,e,a,i){var n=Function("","return this"+r(t)+";").call(this.model),h=Function("","return this"+r(t)+"["+e+"]."+a+";").call(this.model);i.__ADDED__=!0,h.push(i),this.update(t,e,n[e])},this.childRemove=function(t,e,a,i){var n=Function("","return this"+r(t)+";").call(this.model),h=Function("","return this"+r(t)+"["+e+"]."+a+";").call(this.model),l=h[i];l.__ADDED__?h.splice(i,1):h[i].__DELETED__=!0,this.update(t,e,n[e])},this.childUpdate=function(t,e,a,i,n){var h=Function("","return this"+r(t)+";").call(this.model),l=Function("","return this"+r(t)+"["+e+"]."+a+";").call(this.model);l[i]=n,this.update(t,e,h[e])},this.childSet=function(t,e,a,i){var n=this;return Function("val","this"+r(t)+"["+e+"]."+a+" = val;").call(this.model,i),this.view_target.find('[data-ax-repeat="'+t+'"]').find('[data-ax-repeat-i="'+e+'"]').find('[data-ax-item-path="'+a+'"]').each(function(){n.set_els_value(this,this.tagName.toLowerCase(),(this.type||"").toLowerCase(),i,t+"["+e+"]."+a)}),this},this.onUpdate=function(t,e){return this.update_trigger[t]=e,this},this._binding=function(t){var e=this;this.view_target.find("[data-ax-path]").each(function(){var t,a=$(this),i=a.attr("data-ax-path"),n=(this.type||"").toLowerCase();try{t=Function("","return this"+r(i)+";").call(e.model)}catch(h){e.onerror&&e.onerror("not found target [model."+r(i)+"]")}e.set_els_value(this,this.tagName.toLowerCase(),n,t||"",i)}),"undefined"==typeof t?this.view_target.find("[data-ax-repeat]").each(function(){var t=$(this),a=t.attr("data-ax-repeat"),i=t.attr("data-ax-repeat-idx");"undefined"==typeof e.tmpl[a]&&(e.tmpl[a]={}),"undefined"!=typeof i?e.tmpl[a][i]={container:t,content:t.find("script").html()}:e.tmpl[a][0]={container:t,content:t.find("script").html()},t.empty()}):this.view_target.find("[data-ax-repeat]").each(function(){var t=$(this);t.empty().show()}),this.view_target.find("[data-ax-path]").unbind("change.axbinder").bind("change.axbinder",function(t){var a,n,h=!1,l=[],s=$(t.target),o=s.attr("data-ax-path"),c=Function("","return this"+r(o)+";").call(e.model),u=(this.type||"").toLowerCase(),d=i(c),f=!0;if(("object"==d||"array"==d)&&(f=!1),"checkbox"==u){if(e.view_target.find('[data-ax-path="'+o+'"]').length>1){for("array"!=i(c)&&(c="undefined"==typeof c||""==c?[]:[].concat(c)),a=c.length,h=!1,n=this.checked;a--;)c[a]==this.value&&(h=!0);if(n)h||c.push(this.value);else{for(a=c.length;a--;)c[a]==this.value||l.push(c[a]);c=l}}else c=this.checked?this.value:"";Function("val","this"+r(o)+" = val;").call(e.model,c),e.change(o,{el:this,jquery:s,tagname:this.tagName.toLowerCase(),value:c})}else f&&(Function("val","this"+r(o)+" = val;").call(e.model,this.value),e.change(o,{el:this,jquery:s,tagname:this.tagName.toLowerCase(),value:this.value}));s.data("changedTime",(new Date).getTime())});var a;for(var n in e.tmpl){for(var h in e.tmpl[n])this.print_tmpl(n,e.tmpl[n][h],"isInit");if(a=this.update_trigger[n]){var l={repeat_path:n,tmpl:e.tmpl[n],list:Function("","return this."+n+";").call(this.model)};a.call(l,l)}}},this.set_els_value=function(t,e,a,i,n,h){i="undefined"==typeof i?[]:[].concat(i);var l,s;if("input"==e)if("checkbox"==a||"radio"==a){s=i.length;var o=!1;try{if(s>0)for(;s--;)"undefined"!=typeof i[s]&&t.value===i[s].toString()&&(o=!0)}catch(c){console.log(c)}t.checked=o}else t.value=i.join("");else if("select"==e){l=t.options,s=l.length;for(var u,d=!1;s--;){for(u=i.length;u--;)if("undefined"!=typeof i[u]&&l[s].value===i[u].toString()){l[s].selected=!0,d=!0;break}if(d)break}d||(l[0]?(l[0].selected=!0,Function("val","this"+r(n)+" = val;").call(this.model,l[0].value)):Function("val","this"+r(n)+" = val;").call(this.model,"")),window.AXSelect&&$("undefined"!=typeof i&&t).bindSelectSetValue(i[i.length-1])}else"textarea"==e?t.value=i.join("")||"":t.innerText?t.innerText=i.join(""):t.innerHTML=i.join("");return h&&this.change(n,{el:t,tagname:e,value:i}),this},this.change=function(t,e){var a=this.change_trigger[t];a&&a.call(e,e),"*"!=t&&this.change_trigger["*"]&&this.change_trigger["*"].call(e,e)},this.click=function(t,e){var a=this.click_trigger[t];a&&a.call(e,e)},this.sync_model=function(){},this.print_tmpl=function(t,e,a){var n=Function("","return this"+r(t)+";").call(this.model);if(n&&"array"==i(n))for(var h=0,l=n.length;l>h;h++){var s=n[h];if(jQuery.isPlainObject(s)?(s["@i"]=h,s["@r"]=h,0===h&&(s["@first"]=!0)):(s={"@i":h,"@value":s},0===h&&(s["@first"]=!0),console.log(s)),!s.__DELETED__){var o=$(ax5.mustache.render(e.content,s));o.attr("data-ax-repeat-path",t),o.attr("data-ax-repeat-i",s["@i"]),this.bind_event_tmpl(o,t),e.container.append(o)}}},this.bind_event_tmpl=function(t,e){var a=this,h=t.attr("data-ax-repeat-i"),l=Function("","return this"+r(e)+";").call(this.model);t.find("[data-ax-repeat-click]").unbind("click.axbinder").bind("click.axbinder",function(t){var i=ax5.util.findParentNode(t.target,function(t){return t.getAttribute("data-ax-repeat-click")});if(i){var n=$(i),r=n.attr("data-ax-repeat-click"),s=(n.attr("data-ax-repeat-path"),{el:i,jquery:n,tagname:i.tagName.toLowerCase(),value:r,repeat_path:e,item:l[h],item_index:h,item_path:e+"["+h+"]"});a.click(e,s)}}),t.find("[data-ax-item-path]").each(function(){var t,i=$(this),r=i.attr("data-ax-item-path"),l=n(e,h,r),s=(this.type||"").toLowerCase();try{t=Function("","return this."+l+";").call(a.model)}catch(o){a.onerror&&a.onerror("not found target [model."+l+"]")}a.set_els_value(this,this.tagName.toLowerCase(),s,t||"",l)}),t.find("[data-ax-item-path]").unbind("change.axbinder").bind("change.axbinder",function(r){var l,s,o=!1,c=[],u=(this.type||"").toLowerCase(),d=$(r.target),f=d.attr("data-ax-item-path"),p=n(e,h,f),g=Function("","return this."+p+";").call(a.model),v=i(g),m=!0;if(("object"==v||"array"==v)&&(m=!1),"checkbox"==u){if(t.find('[data-ax-item-path="'+f+'"]').length>1){for("array"!=i(g)&&(g="undefined"==typeof g||""==g?[]:[].concat(g)),l=g.length,o=!1,s=this.checked;l--;)g[l]==this.value&&(o=!0);if(s)o||g.push(this.value);else{for(l=g.length;l--;)g[l]==this.value||c.push(g[l]);g=c}}else g=this.checked?this.value:"";Function("val","this."+p+" = val;").call(a.model,g),a.change(p,{el:this,jquery:d,tagname:this.tagName.toLowerCase(),value:g})}else m&&(Function("val","this."+p+" = val;").call(a.model,this.value),a.change(p,{el:this,jquery:d,tagname:this.tagName.toLowerCase(),value:this.value}));d.data("changedTime",(new Date).getTime())}),t.find("[data-ax-item-path]").unbind("blur.axbinder").bind("blur.axbinder",function(t){var e=$(t.target);("undefined"==typeof e.data("changedTime")||e.data("changedTime")<(new Date).getTime()-10)&&e.trigger("change")})},this.focus=function(t){return this.view_target.find('[data-ax-path="'+t+'"]').focus(),this},this.validate=function(){var t=this,e=[];return this.view_target.find("[data-ax-path]").each(function(){var a=$(this),i=a.attr("data-ax-path"),n=a.attr("data-ax-validate");if(n){var h=Function("","return this"+r(i)+";").call(t.model);"undefined"==typeof h&&(h="");var l=h.toString(),s=!1;"required"==n&&""==l.trim()?s=!0:!/\D.?/g.test(n)&&l.trim().length<n.number()&&(s=!0),s&&e.push({type:n,dataPath:i,el:this,jquery:a,value:h})}}),this.view_target.find("[data-ax-repeat-path]").each(function(){var a=$(this),i=a.attr("data-ax-repeat-path"),n=a.attr("data-ax-repeat-i");a.find("[data-ax-validate]").each(function(){var a=$(this),h=a.attr("data-ax-validate"),l=a.attr("data-ax-item-path"),s=Function("","return this"+r(i)+"["+n+"]."+l+";").call(t.model);"undefined"==typeof s&&(s="");var o=s.toString();if(h){var c=!1;"required"==h&&""==o.trim()?c=!0:!/\D.?/g.test(h)&&o.trim().length<h.number()&&(c=!0),c&&e.push({type:h,dataPath:i,el:this,jquery:a,value:s})}})}),e.length>0?{error:e}:{}},this.main=function(){arguments&&e.isObject(arguments[0])&&this.setConfig(arguments[0])}.apply(this,arguments)};return t}())}();
{
"name": "ax5ui-binder",
"version": "0.1.1",
"version": "0.2.0",
"description": "Simple 2way binder plugin that works with Bootstrap & jQuery",

@@ -5,0 +5,0 @@ "license": "LGPLv3",

@@ -9,3 +9,3 @@ // ax5.ui.binder

className: "binder",
version : "0.1.1"
version : "0.2.0"
}, (function () {

@@ -78,4 +78,12 @@

},
get_real_path = function (dataPath) {
get_real_path = function (_dataPath) {
var path = [];
var _path = [].concat(_dataPath.split(/[\.\[\]]/g));
_path.forEach(function (n) {
if (n !== "") path.push("[\"" + n.replace(/['\"]/g, "") + "\"]");
});
_path = null;
return path.join("");
/*
var path = [];
var _path = [].concat(dataPath.split(/[\.\[\]]/g));

@@ -88,2 +96,3 @@

return "'" + path.join("']['") + "'";
*/
};

@@ -130,3 +139,3 @@

(Function("val", "this[" + get_real_path(dataPath) + "] = val;")).call(this.model, value);
(Function("val", "this" + get_real_path(dataPath) + " = val;")).call(this.model, value);
obj_type = get_type(value);

@@ -170,3 +179,3 @@

else {
return (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
return (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
}

@@ -241,3 +250,3 @@ };

this.add = function (dataPath, item) {
var list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -247,3 +256,3 @@ item['@i'] = list.length;

item.__ADDED__ = true;
(Function("val", "this[" + get_real_path(dataPath) + "].push(val);")).call(this.model, item);
(Function("val", "this" + get_real_path(dataPath) + ".push(val);")).call(this.model, item);

@@ -286,3 +295,3 @@ // 다중 템플릿 처리

this.remove = function (dataPath, index) {
var list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -331,3 +340,3 @@ if (typeof index == "undefined") index = list.length - 1;

this.update = function (dataPath, index, item) {
var list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var tmpl = this.tmpl[dataPath];

@@ -364,4 +373,4 @@ if (typeof index != "undefined" && item) list.splice(index, 1, item);

this.childAdd = function (dataPath, index, child_path, child_item) {
var _list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";")).call(this.model);
var _list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";")).call(this.model);
child_item.__ADDED__ = true;

@@ -380,4 +389,4 @@ list.push(child_item);

this.childRemove = function (dataPath, index, child_path, child_index) {
var _list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";")).call(this.model);
var _list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";")).call(this.model);
var remove_item = list[child_index];

@@ -402,4 +411,4 @@ if (remove_item.__ADDED__) {

this.childUpdate = function (dataPath, index, child_path, child_index, child_item) {
var _list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + ";")).call(this.model);
var _list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + "[" + index + "]." + child_path + ";")).call(this.model);
list[child_index] = child_item;

@@ -419,3 +428,3 @@ this.update(dataPath, index, _list[index]);

var _this = this, i;
(Function("val", "this[" + get_real_path(dataPath) + "][" + index + "]." + child_path + " = val;")).call(this.model, value);
(Function("val", "this" + get_real_path(dataPath) + "[" + index + "]." + child_path + " = val;")).call(this.model, value);

@@ -459,3 +468,3 @@ // apply data value to els

try {
val = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(_this.model);
val = (Function("", "return this" + get_real_path(dataPath) + ";")).call(_this.model);
} catch (e) {

@@ -508,3 +517,3 @@ /**

dataPath = dom.attr("data-ax-path"),
origin_value = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(_this.model),
origin_value = (Function("", "return this" + get_real_path(dataPath) + ";")).call(_this.model),
this_type = (this.type || "").toLowerCase(),

@@ -555,3 +564,3 @@ value_type = get_type(origin_value),

(Function("val", "this[" + get_real_path(dataPath) + "] = val;")).call(_this.model, origin_value);
(Function("val", "this" + get_real_path(dataPath) + " = val;")).call(_this.model, origin_value);
_this.change(dataPath, {

@@ -563,3 +572,3 @@ el: this, jquery: dom, tagname: this.tagName.toLowerCase(), value: origin_value

if (setAllow) {
(Function("val", "this[" + get_real_path(dataPath) + "] = val;")).call(_this.model, this.value);
(Function("val", "this" + get_real_path(dataPath) + " = val;")).call(_this.model, this.value);
_this.change(dataPath, {

@@ -644,6 +653,6 @@ el: this, jquery: dom, tagname: this.tagName.toLowerCase(), value: this.value

options[0].selected = true;
(Function("val", "this[" + get_real_path(dataPath) + "] = val;")).call(this.model, options[0].value);
(Function("val", "this" + get_real_path(dataPath) + " = val;")).call(this.model, options[0].value);
}
else {
(Function("val", "this[" + get_real_path(dataPath) + "] = val;")).call(this.model, "");
(Function("val", "this" + get_real_path(dataPath) + " = val;")).call(this.model, "");
}

@@ -696,3 +705,3 @@ }

this.print_tmpl = function (dataPath, tmpl, isInit) {
var list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);
if (list && get_type(list) == "array") {

@@ -728,3 +737,3 @@ for (var i = 0, l = list.length; i < l; i++) {

var _this = this, index = target.attr("data-ax-repeat-i");
var list = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(this.model);
var list = (Function("", "return this" + get_real_path(dataPath) + ";")).call(this.model);

@@ -883,3 +892,3 @@ target.find('[data-ax-repeat-click]').unbind("click.axbinder").bind("click.axbinder", function (e) {

if (is_validate) {
var val = (Function("", "return this[" + get_real_path(dataPath) + "];")).call(_this.model);
var val = (Function("", "return this" + get_real_path(dataPath) + ";")).call(_this.model);
if (typeof val === "undefined") val = "";

@@ -915,3 +924,3 @@ var _val = val.toString();

var dom = $(this), is_validate = dom.attr("data-ax-validate"), item_path = dom.attr("data-ax-item-path");
var val = (Function("", "return this[" + get_real_path(dataPath) + "][" + repeat_idx + "]." + item_path + ";")).call(_this.model);
var val = (Function("", "return this" + get_real_path(dataPath) + "[" + repeat_idx + "]." + item_path + ";")).call(_this.model);
if (typeof val === "undefined") val = "";

@@ -918,0 +927,0 @@ var _val = val.toString();

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc