Skip to content

Commit

Permalink
1.1.7
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
ermouth committed Jun 18, 2015
1 parent 8b8598f commit 919da28
Show file tree
Hide file tree
Showing 8 changed files with 4,171 additions and 70 deletions.
4,079 changes: 4,079 additions & 0 deletions Release/1.1/jquerymy-1.1.7.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Release/1.1/jquerymy-1.1.7.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Release/jquery.my.last.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquerymy",
"version": "1.1.6",
"version": "1.1.7",
"description": "A lightweight jQuery plugin for complex two-way data binding in real time.",
"main": "./jquerymy.js",
"authors": [
Expand Down
138 changes: 77 additions & 61 deletions jquerymy.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/*
* jQuery.my 1.1.6
* jQuery.my 1.1.7
* Requires jQuery 1.11.0+, SugarJS 1.3.9-1.4.x
*
* — fixed a bug caused forever-pending init if a member of .files section is zero length base64
* — fixed memoization of screen shield color for global modal, when global is tied to $control
* — fixed inability to close modal when $root no more exist
* — fixed several bugs in list ider and hasher, defined as strings or arrays
* — fixed serious bug in _normalize, caused corruption of id:"id" or hash:"id" for lists
* — small fix for inlined resources
* — better linting
*
* More details at jquerymy.com
*
* (c) @ermouth, thanks @carpogoryanin, @ftescht
* 2015-06-16
* 2015-06-18
*/

;(function ($) {var _version = "jQuery.my 1.1.6";
;(function ($) {var _version = "jQuery.my 1.1.7";

// Some shortcuts and constants
var lang = "en",
Expand All @@ -36,7 +37,10 @@
isR = Object.isRegExp,
isF = Object.isFunction,
Keys = Object.keys,
isP = function (a) {/*is promise*/return !!(null!=a&&(isO(a)||a.jquery)&&isF(a.then)&&isF(a.fail)&&isF(a.state));};
isP = function (a) {
// detects promise
return !!(null!=a&&(isO(a)||a.jquery)&&isF(a.then)&&isF(a.fail)&&isF(a.state));
};

//=======================================

Expand Down Expand Up @@ -205,7 +209,7 @@
$.extend (!0, root, f.unmask("",id));
}
// Re-mount version from repo
$.extend (!0, root, f.unmask(root._src[id], id))
$.extend (!0, root, f.unmask(root._src[id], id));
});

// Mount _self link to uncompiled manifest
Expand Down Expand Up @@ -233,24 +237,26 @@
//blobify files
for (i in obj.files) {
file = obj.files[i];
if (isO(file) && isS(file.data) && !file.url) {
if (wURL) {
try {
f.base642blob(file.data,function(res){
file.blob = res;
file.url = wURL.createObjectURL(file.blob);
},(file.content_type||file.mime));
if (isO(file)) {
if (isS(file.data) && !file.url) {
if (wURL) {
try {
f.base642blob(file.data,function(res){
file.blob = res;
file.url = wURL.createObjectURL(file.blob);
},(file.content_type||file.mime));
flist.push(i);
} catch(e) {
return "Invalid base64 data in files/"+i+".";
}
} else {
//ie8-9 fallback
file.url = 'data:'+(file.content_type||file.mime)+';base64,'+file.data;
flist.push(i);
} catch(e) {
return "Invalid base64 data in files/"+i+".";
}
} else {
//ie8-9 fallback
file.url = 'data:'+(file.content_type||file.mime)+';base64,'+file.data;
flist.push(i);
}
}
else return "Non-object member "+i+" in files section."
else return "Non-object member "+i+" in files section.";
}
}
return flist;
Expand Down Expand Up @@ -866,7 +872,7 @@
"textarea": {
".my-codemirror": function ($o) {
$o[0].nextSibling.CodeMirror.toTextArea();
$o.removeClass("my-codemirror")
$o.removeClass("my-codemirror");
}
}
}
Expand Down Expand Up @@ -926,7 +932,7 @@
try{
v = fn.call( my.manifest || my.root.my().manifest, my.data, msg.message, $c);
} catch(e) {
_ERR("Listener failed", e.message, e.stack)
_ERR("Listener failed", e.message, e.stack);
}
if (v!==undefined) {
if (v===null) $c.trigger("check");
Expand Down Expand Up @@ -1043,7 +1049,7 @@
if (!chunk) {
// we are done, recheck
var list = _present(checks),
errs = Keys(Object.findAll(list, function(i, e) {return !e}));
errs = Keys(Object.findAll(list, function(i, e) {return !e;}));
if (errs.length) err.push(
(errs.length===1?'Key '+errs[0]+' is':('Keys '+errs.join(", ")+' are'))
+' not present after all.'
Expand Down Expand Up @@ -1296,7 +1302,7 @@
disable = (r!==css),
toSelf = (r.to(5)==="self:");
if (toSelf) {
r = r.replace(/^self:/g,'')
r = r.replace(/^self:/g,'');
}
$we.each(function () {
var $d = $(this),
Expand Down Expand Up @@ -1558,8 +1564,14 @@
selector:lsel,
parent:man,
bind:ui.bind,
hash:isF(ui.hash)?ui.hash.bind(man):_snapshooter(ui.hash),
id: isF(ui.id)?ui.id.bind(man):_snapshooter(ui.id),
hash:isF(ui.hash)?ui.hash.bind(man):
isS(ui.hash)?_snapStr.fill(void 0, ui.hash):
isA(ui.hash)?_snapArr.fill(void 0, ui.hash.slice(0)):
null,
id: isF(ui.id)?ui.id.bind(man):
isS(ui.id)?_snapStr.fill(void 0, ui.id):
isA(ui.id)?_snapArr.fill(void 0, ui.id.slice(0)):
null,
ext:!!(ui.id || ui.hash),
stamp:0
};
Expand Down Expand Up @@ -1608,12 +1620,14 @@

// - - - - - - - - - - - - - - - - - - - - - - -

function _snapshooter (src) {
var t = T(src).to(3);
return !src?null:
t==="str"?_getref.fill(undefined, src):
t==="arr"? f.mask.fill(undefined, src):
null;

function _snapStr (objdata, st) {
var h = _getref(objdata, st)||"";
return (typeof h === "string")?h:f.sdbmCode(h);
}

function _snapArr (objdata, arr) {
return f.sdbmCode(f.mask(objdata, arr));
}

// - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -1855,13 +1869,13 @@

function _NewFunction (A1, A2) {
var f;
try { f = new Function(A1, A2); } catch(e) { f = { message:e.message, stack:e.stack } }
try { f = new Function(A1, A2); } catch(e) { f = { message:e.message, stack:e.stack }; }
return f;
}

function _NewRegExp (A1, A2) {
var f;
try { f = new RegExp(A1, A2); } catch(e) { f = { message:e.message, stack:e.stack } }
try { f = new RegExp(A1, A2); } catch(e) { f = { message:e.message, stack:e.stack }; }
return f;
}

Expand Down Expand Up @@ -1917,7 +1931,9 @@
if (null!==manifest) ["css","check","manifest","list","hash","id"].each(function (elt){
if (isS(v[elt])) {
var ref = _getref (manifest, v[elt].replace(rthis,""));
if (ref!=null) v[elt]=ref;
if (ref!=null && !isS(ref)) {
v[elt]=ref;
}
}
});

Expand All @@ -1930,11 +1946,11 @@

function _functionize(a){
var i, r = {}, row, f0 = function(){return null;};
if (isS(a)) a.split(/[,\s]+/).compact(true).unique().map(function(e){r[e]=f0});
else if (isA(a)) a.compact(true).unique().map(function(e){r[e]=f0});
if (isS(a)) a.split(/[,\s]+/).compact(true).unique().map(function(e){r[e]=f0;});
else if (isA(a)) a.compact(true).unique().map(function(e){r[e]=f0;});
else if (isO(a)) {
for (i in a) {
if (!isF(a[i])) r[i] = function(){return a[i]};
if (!isF(a[i])) r[i] = function(){return a[i];};
else r[i] = a[i];
}
}
Expand Down Expand Up @@ -2106,7 +2122,7 @@
})
.fail(function(err){
_makeup();
_f("Linker of ‘require’ property failed.", err)
_f("Linker of ‘require’ property failed.", err);
});

// turn on radio & listeners
Expand Down Expand Up @@ -2166,7 +2182,7 @@
fc = manifest.radio[msg.channel];

try {next = fc.call(manifest,evt,msg);}
catch(e) {_ERR("Radio handler for form "+mid+"failed", e.message, e.stack)}
catch(e) {_ERR("Radio handler for form "+mid+"failed", e.message, e.stack);}

if (next!==undefined) {
evt.stopPropagation();
Expand Down Expand Up @@ -2274,7 +2290,7 @@
if (!$locstyle.size()) {
$locstyle = $(html(style[1], formClass)).appendTo($("body"));
if (p.restyle>-1 && !restyles[cid]) {
restyles[cid] = (function restyle (){ _styler(true)}).debounce(p.restyle);
restyles[cid] = (function restyle (){ _styler(true); }).debounce(p.restyle);
}
$root.data("my").restyle = _styler.fill(true).debounce(0);
}
Expand Down Expand Up @@ -2336,7 +2352,7 @@
} else _controls();

if (!_fail) {
if (!$root.my()) return _f("Internal error initializing controls",""), $root;
if (!$root.my()) return _f("Internal error initializing controls.",""), $root;

//save initial data for $.my("reset")
$root.data("my").initial = $E(true,{},d);
Expand Down Expand Up @@ -2422,7 +2438,7 @@
function _f (msg, obj) {
var html;
_fail=true;
_ERR("Form "+myid+" failed to initialize", msg, obj);
_ERR("Form "+myid+" failed to initialize.", msg, obj);
$root.removeClass(initCss);
html = ehandler(msg, obj);
if (isS(html) || (isO(html) && html.jquery)) $root.html(html);
Expand Down Expand Up @@ -3009,7 +3025,7 @@
},
"blob2base64": function(blob, done, nosplit) {
var reader = new FileReader();
reader.onload = function() {done(nosplit?reader.result:reader.result.split(',')[1])};
reader.onload = function() {done(nosplit?reader.result:reader.result.split(',')[1]);};
reader.readAsDataURL(blob);
},
"base642blob": function(base64, done, mime) {
Expand Down Expand Up @@ -3277,7 +3293,7 @@
$E(true,sys,f.params, params||{});
return form.length?form.reduce(chain.fill(undefined,undefined,sys),''):"";
} else if (isO(form)) {
$.extend(f, form)
$.extend(f, form);
}else return "";
}

Expand Down Expand Up @@ -3424,7 +3440,7 @@
"img:eq(0)":"img",
"h4":{
bind:"text",
css:{hide:function(d,v){return !v}}
css:{hide:function(d,v){return !v;}}
}
}
},
Expand Down Expand Up @@ -3498,28 +3514,28 @@
} else {
return $o.modal(obj);
}
}
};

// - - - - - - - - - - - - - - - - - -


root.modal.loading = function (onoff) {
$(parent).find(">.my-modal").toggleClass("my-modal-loading",!!onoff);
}
};

root.modal.parent = function (s) {
// sets parent DOM node selector for $.my.modal
if (!s || !$(s).size()) return $(parent);
parent = s;
}
};

root.modal.parentBack = function (s) {
// sets parent DOM node selector for $.my.modal background
if (!s || !$(s).size()) return $(parentBack||parent);
parentBack = s;
}
};

root.modal.visible = function () {return !!isOpen;}
root.modal.visible = function () {return !!isOpen;};

if (!$.my) $.my={};
$.my.modal = root.modal;
Expand Down Expand Up @@ -3723,7 +3739,7 @@
$o.data("modal", m);

// silent
if (m.silent) $m.on("change.my", function(){ return false; })
if (m.silent) $m.on("change.my", function(){ return false; });

// position
$m.css({
Expand Down Expand Up @@ -3764,8 +3780,8 @@
$E(m,{
form: $f,
bg:$bg,
cancel: function(){$o.modal(true)},
commit: function(){$o.modal()}
cancel: function(){$o.modal(true);},
commit: function(){$o.modal();}
});
$m.data("modal",m);

Expand Down Expand Up @@ -3813,7 +3829,7 @@
m.commit.delay(50);
return false;
}
})
});
}

// autofocus
Expand Down Expand Up @@ -3923,7 +3939,7 @@

if (m.pos.pw - 2*mb < m.width+padx) {
// we are wider
m.pos.vx = -(m.width+padx-m.pos.pw)/2
m.pos.vx = -(m.width+padx-m.pos.pw)/2;
}
else if (m.pos.vx+m.width+padx > m.pos.pw-mb) {
// we went over right
Expand Down Expand Up @@ -3997,7 +4013,7 @@
width: m.pos.pw+"px",
height: m.pos.ph+"px",
display:"block",
background:isS(m.screen)? m.screen:'rgba(40,80,120,0.5)',
background:isS(m.screen)? m.screen:'rgba(40,80,120,0.6)',
"z-index":m.z-1
});
else {
Expand All @@ -4010,7 +4026,7 @@
"z-index":m.z-1
});
if (isS(m.screen)) $bg.css({
background:m.screen? m.screen:'rgba(30,65,100,0.8)'
background:m.screen? m.screen:'rgba(25, 39, 59, 0.88)'
});
}
}
Expand Down Expand Up @@ -4041,7 +4057,7 @@
if (!g || !isOpen) $bg.hide();
if (!!g && !isOpen) {
// repair screen color
$bg.css({background:'rgba(30,65,100,0.8)'});
$bg.css({background:'rgba(25, 39, 59, 0.88)'});
}
}).delay(50, m.global); // curry m.global
}
Expand Down
6 changes: 3 additions & 3 deletions jquerymy.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion my.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": [
"MVVM", "framework", "ui", "form", "validation", "data binding"
],
"version": "1.1.6",
"version": "1.1.7",
"author": {
"name": "ermouth",
"url": "https://github.com/ermouth"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquerymy",
"version": "1.1.6",
"version": "1.1.7",
"description": "A lightweight jQuery plugin for complex two-way data binding in real time.",
"homepage": "http://jquerymy.com/",
"author": "ermouth <[email protected]>",
Expand Down

0 comments on commit 919da28

Please sign in to comment.