Skip to content

Commit

Permalink
Commit 88 (v0.9.88 - Beta)
Browse files Browse the repository at this point in the history
Minor bug fixes and improvements. No breaking changes.

Feature improvements:
- Added support for 'mouse editing' of textboxes for browsers
  supporting HTML5 'oninput' event.
  #391

Minor bug fix:

- #388

Unit tests:

- Several additional unit tests

Documentation:
- New documentation topics added for JsRender custom tags:
  http://www.jsviews.com/#tags
  http://www.jsviews.com/#tagsapi

- New documentation topics added for $.views object:
  http://www.jsviews.com/#viewsobject
  http://www.jsviews.com/#jsvviewsobject

- New documentation topics added for compiled template objects:
  http://www.jsviews.com/#templateobject
  http://www.jsviews.com/#jsvtemplateobject

- New documentation topics and samples added for using {{props}}
  to iterate over a top-level dictionary/hash data-collection:
  http://www.jsviews.com/#samples/editable/hash
  http://www.jsviews.com/#jsvpropstag@load-hash

- Several improvements and bug fixes on www.jsviews.com site.
  • Loading branch information
BorisMoore committed Aug 26, 2017
1 parent 8559dcf commit c433fc3
Show file tree
Hide file tree
Showing 28 changed files with 664 additions and 556 deletions.
16 changes: 12 additions & 4 deletions jquery.observable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsObservable v0.9.87 (Beta): http://jsviews.com/#jsobservable */
/*! JsObservable v0.9.88 (Beta): http://jsviews.com/#jsobservable */
/*
* Subcomponent of JsViews
* Data change events for data-linking
Expand Down Expand Up @@ -44,7 +44,7 @@ if (!$ || !$.fn) {
throw "JsObservable requires jQuery"; // We require jQuery
}

var versionNumber = "v0.9.87",
var versionNumber = "v0.9.88",
_ocp = "_ocp", // Observable contextual parameter
$observe, $observable,

Expand Down Expand Up @@ -473,7 +473,7 @@ if (!$.observe) {
}

var i, p, skip, parts, prop, path, dep, unobserve, callback, cbId, inId, el, data, events, contextCb, innerContextCb,
items, cbBindings, depth, innerCb, parentObs, allPath, filter, initNsArr, initNsArrLen, view,
items, cbBindings, depth, innerCb, parentObs, allPath, filter, initNsArr, initNsArrLen, view, cbItemCount,
ns = observeStr,
paths = this != 1 // Using != for IE<10 bug- see jsviews/issues/237
? concat.apply([], arguments) // Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
Expand Down Expand Up @@ -551,7 +551,14 @@ if (!$.observe) {
}
}
depth = 0;
cbItemCount = 0;
for (i = 0; i < l; i++) {
if (cbItemCount) {
cbItemCount--; // contextCb was moved to a contextual parameter outer context. Needs to revert after cbItemCount
} else {
contextCb = innerContextCb;
}

path = paths[i];
if (path === "" || path === root) {
continue;
Expand Down Expand Up @@ -586,14 +593,15 @@ if (!$.observe) {
} else if (path && path._cxp) { // contextual parameter
view = path.shift(); // Contextual data
if (_ocp in view) {
root = view;
root = view; // observable contextual parameter
contextCb = 0;
} else {
contextCb = $sub._gccb(view); // getContextCb: Get context callback for the contextual view (where contextual param evaluated/assigned)
root = view.data;
}
items = path;
items.push(origRoot);
cbItemCount = items.length;
} else {
if (!$isFunction(path)) {
if (path && path._cpfn) {
Expand Down
4 changes: 2 additions & 2 deletions jquery.observable.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jquery.observable.min.js.map

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions jquery.views.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jquery.views.js v0.9.87 (Beta): http://jsviews.com/ */
/*! jquery.views.js v0.9.88 (Beta): http://jsviews.com/ */
/*
* Interactive data-driven views using JsRender templates.
* Subcomponent of JsViews
Expand Down Expand Up @@ -44,7 +44,7 @@ var setGlobals = $ === false; // Only set globals if script block in browser (no
jsr = jsr || setGlobals && global.jsrender;
$ = $ || global.jQuery;

var versionNumber = "v0.9.87",
var versionNumber = "v0.9.88",
requiresStr = "JsViews requires ";

if (!$ || !$.fn) {
Expand Down Expand Up @@ -91,7 +91,7 @@ var document = global.document,
if ($.link) { return $; } // JsViews is already loaded

$subSettings.trigger = true;
var activeBody, rTagDatalink, $view, $viewsLinkAttr, linkViewsSel, wrapMap, viewStore, oldAdvSet,
var activeBody, rTagDatalink, $view, $viewsLinkAttr, linkViewsSel, wrapMap, viewStore, oldAdvSet, useInput,
jsvAttrStr = "data-jsv",
elementChangeStr = "change.jsv",
onBeforeChangeStr = "onBeforeChange",
Expand Down Expand Up @@ -986,10 +986,10 @@ function $link(tmplOrLinkExpr, to, from, context, noIteration, parentView, prevN

if (!activeBody) {
activeBody = document.body;
useInput = "oninput" in activeBody;
$(activeBody)
.on(elementChangeStr, onElemChange)
.on('input', 'input[type="number"]', onElemChange)
.on('blur', '[contenteditable]', onElemChange);
.on('blur.jsv', '[contenteditable]', onElemChange);
}

var i, k, html, vwInfos, view, placeholderParent, targetEl, refresh, topLevelCall, late,
Expand Down Expand Up @@ -1716,11 +1716,11 @@ function addDataBinding(late, linkMarkup, node, currentView, boundTagId, isLink,
rTagIndex = rTagDatalink.lastIndex;
attr = tokens[1];
tagExpr = tokens[3];
while (linkExpressions[0] && linkExpressions[0][4] === "else") { // If this is {someTag...} and is followed by an {else...} add to tagExpr
while (linkExpressions[0] && linkExpressions[0][4] === "else") { // If this is {sometag...} and is followed by an {else...} add to tagExpr
tagExpr += delimCloseChar1 + delimOpenChar0 + linkExpressions.shift()[3];
hasElse = true;
}
if (hasElse) { // If an {else} has been added, need also to add closing {{/someTag}}
if (hasElse) { // If an {else} has been added, need also to add closing {{/sometag}}
tagExpr += delimCloseChar1 + delimOpenChar0 + delimOpenChar1 + "/" + tokens[4] + delimCloseChar0;
}
linkCtx = {
Expand Down Expand Up @@ -1948,7 +1948,10 @@ function asyncOnElemChange(ev) {
function bindTriggerEvent($elem, trig, onoff) {
// Bind keydown, or other trigger - (rather than use the default change event bubbled to activeBody)
if (trig) {
trig = "" + trig === trig ? trig : "keydown"; // Set trigger to (true || truey non-string (e.g. 1) || 'keydown')
if (useInput) {
$elem[onoff]("input.jsv", onElemChange); // For HTML5 browser with "oninput" support - for mouse editing of text
}
trig = "" + trig === trig ? trig : "keydown.jsv"; // Set trigger to (true || truey non-string (e.g. 1) || 'keydown')
$elem[onoff](trig, trig.indexOf("keydown") >= 0 ? asyncOnElemChange : onElemChange); // Get 'keydown' with async
}
}
Expand Down Expand Up @@ -2247,8 +2250,7 @@ function $unlink(to) {
if (activeBody) {
$(activeBody)
.off(elementChangeStr, onElemChange)
.off('input', 'input[type="number"]', onElemChange)
.off('blur', '[contenteditable]', onElemChange);
.off('blur.jsv', '[contenteditable]', onElemChange);
activeBody = undefined;
}
topView.removeViews();
Expand Down
6 changes: 3 additions & 3 deletions jquery.views.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jquery.views.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions jsrender.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! JsRender v0.9.87 (Beta): http://jsviews.com/#jsrender */
/*! JsRender v0.9.88 (Beta): http://jsviews.com/#jsrender */
/*! **VERSION FOR WEB** (For NODE.JS see http://jsviews.com/download/jsrender-node.js) */
/*
* Best-of-breed templating in browser or on Node.js.
Expand Down Expand Up @@ -44,7 +44,7 @@ var setGlobals = $ === false; // Only set globals if script block in browser (no

$ = $ && $.fn ? $ : global.jQuery; // $ is jQuery passed in by CommonJS loader (Browserify), or global jQuery.

var versionNumber = "v0.9.87",
var versionNumber = "v0.9.88",
jsvStoreName, rTag, rTmplString, topView, $views, $expando,
_ocp = "_ocp", // Observable contextual parameter

Expand Down Expand Up @@ -1571,7 +1571,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
result += newView._.onRender ? newView._.onRender(itemResult, childView) : itemResult;
}
} else {
// Create a view for singleton data object. The type of the view will be the tag name, e.g. "if" or "myTag" except for
// Create a view for singleton data object. The type of the view will be the tag name, e.g. "if" or "mytag" except for
// "item", "array" and "data" views. A "data" view is from programmatic render(object) against a 'singleton'.
if (itemVar) {
setItemVar(data);
Expand Down
4 changes: 2 additions & 2 deletions jsrender.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsrender.min.js.map

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions jsviews.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jsviews.js v0.9.87 (Beta) single-file version: http://jsviews.com/ */
/*! jsviews.js v0.9.88 (Beta) single-file version: http://jsviews.com/ */
/*! includes JsRender, JsObservable and JsViews - see: http://jsviews.com/#download */

/* Interactive data-driven views using JsRender templates */
Expand Down Expand Up @@ -47,7 +47,7 @@ if (!$ || !$.fn) {
throw "JsViews requires jQuery"; // We require jQuery
}

var versionNumber = "v0.9.87",
var versionNumber = "v0.9.88",

jsvStoreName, rTag, rTmplString, topView, $views, $observe, $observable, $expando,
_ocp = "_ocp", // Observable contextual parameter
Expand Down Expand Up @@ -1575,7 +1575,7 @@ function renderWithViews(tmpl, data, context, noIteration, view, key, onRender,
result += newView._.onRender ? newView._.onRender(itemResult, childView) : itemResult;
}
} else {
// Create a view for singleton data object. The type of the view will be the tag name, e.g. "if" or "myTag" except for
// Create a view for singleton data object. The type of the view will be the tag name, e.g. "if" or "mytag" except for
// "item", "array" and "data" views. A "data" view is from programmatic render(object) against a 'singleton'.
if (itemVar) {
setItemVar(data);
Expand Down Expand Up @@ -2889,7 +2889,7 @@ if (!$.observe) {
}

var i, p, skip, parts, prop, path, dep, unobserve, callback, cbId, inId, el, data, events, contextCb, innerContextCb,
items, cbBindings, depth, innerCb, parentObs, allPath, filter, initNsArr, initNsArrLen, view,
items, cbBindings, depth, innerCb, parentObs, allPath, filter, initNsArr, initNsArrLen, view, cbItemCount,
ns = observeStr,
paths = this != 1 // Using != for IE<10 bug- see jsviews/issues/237
? concat.apply([], arguments) // Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
Expand Down Expand Up @@ -2967,7 +2967,14 @@ if (!$.observe) {
}
}
depth = 0;
cbItemCount = 0;
for (i = 0; i < l; i++) {
if (cbItemCount) {
cbItemCount--; // contextCb was moved to a contextual parameter outer context. Needs to revert after cbItemCount
} else {
contextCb = innerContextCb;
}

path = paths[i];
if (path === "" || path === root) {
continue;
Expand Down Expand Up @@ -3002,14 +3009,15 @@ if (!$.observe) {
} else if (path && path._cxp) { // contextual parameter
view = path.shift(); // Contextual data
if (_ocp in view) {
root = view;
root = view; // observable contextual parameter
contextCb = 0;
} else {
contextCb = $sub._gccb(view); // getContextCb: Get context callback for the contextual view (where contextual param evaluated/assigned)
root = view.data;
}
items = path;
items.push(origRoot);
cbItemCount = items.length;
} else {
if (!$isFunction(path)) {
if (path && path._cpfn) {
Expand Down Expand Up @@ -3575,7 +3583,7 @@ rFirstElem = /<(?!script)(\w+)[>\s]/;
if ($.link) { return $; } // JsViews is already loaded

$subSettings.trigger = true;
var activeBody, rTagDatalink, $view, $viewsLinkAttr, linkViewsSel, wrapMap, viewStore, oldAdvSet,
var activeBody, rTagDatalink, $view, $viewsLinkAttr, linkViewsSel, wrapMap, viewStore, oldAdvSet, useInput,
jsvAttrStr = "data-jsv",
elementChangeStr = "change.jsv",
onBeforeChangeStr = "onBeforeChange",
Expand Down Expand Up @@ -4470,10 +4478,10 @@ function $link(tmplOrLinkExpr, to, from, context, noIteration, parentView, prevN

if (!activeBody) {
activeBody = document.body;
useInput = "oninput" in activeBody;
$(activeBody)
.on(elementChangeStr, onElemChange)
.on('input', 'input[type="number"]', onElemChange)
.on('blur', '[contenteditable]', onElemChange);
.on('blur.jsv', '[contenteditable]', onElemChange);
}

var i, k, html, vwInfos, view, placeholderParent, targetEl, refresh, topLevelCall, late,
Expand Down Expand Up @@ -5200,11 +5208,11 @@ function addDataBinding(late, linkMarkup, node, currentView, boundTagId, isLink,
rTagIndex = rTagDatalink.lastIndex;
attr = tokens[1];
tagExpr = tokens[3];
while (linkExpressions[0] && linkExpressions[0][4] === "else") { // If this is {someTag...} and is followed by an {else...} add to tagExpr
while (linkExpressions[0] && linkExpressions[0][4] === "else") { // If this is {sometag...} and is followed by an {else...} add to tagExpr
tagExpr += delimCloseChar1 + delimOpenChar0 + linkExpressions.shift()[3];
hasElse = true;
}
if (hasElse) { // If an {else} has been added, need also to add closing {{/someTag}}
if (hasElse) { // If an {else} has been added, need also to add closing {{/sometag}}
tagExpr += delimCloseChar1 + delimOpenChar0 + delimOpenChar1 + "/" + tokens[4] + delimCloseChar0;
}
linkCtx = {
Expand Down Expand Up @@ -5432,7 +5440,10 @@ function asyncOnElemChange(ev) {
function bindTriggerEvent($elem, trig, onoff) {
// Bind keydown, or other trigger - (rather than use the default change event bubbled to activeBody)
if (trig) {
trig = "" + trig === trig ? trig : "keydown"; // Set trigger to (true || truey non-string (e.g. 1) || 'keydown')
if (useInput) {
$elem[onoff]("input.jsv", onElemChange); // For HTML5 browser with "oninput" support - for mouse editing of text
}
trig = "" + trig === trig ? trig : "keydown.jsv"; // Set trigger to (true || truey non-string (e.g. 1) || 'keydown')
$elem[onoff](trig, trig.indexOf("keydown") >= 0 ? asyncOnElemChange : onElemChange); // Get 'keydown' with async
}
}
Expand Down Expand Up @@ -5731,8 +5742,7 @@ function $unlink(to) {
if (activeBody) {
$(activeBody)
.off(elementChangeStr, onElemChange)
.off('input', 'input[type="number"]', onElemChange)
.off('blur', '[contenteditable]', onElemChange);
.off('blur.jsv', '[contenteditable]', onElemChange);
activeBody = undefined;
}
topView.removeViews();
Expand Down
6 changes: 3 additions & 3 deletions jsviews.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsviews.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsviews",
"version": "v0.9.87",
"version": "v0.9.88",
"description": "Next-generation MVVM and MVP framework - built on top of JsRender templates. Bringing templates to life...",
"main": "./jsviews.js",
"author": {
Expand Down Expand Up @@ -35,7 +35,7 @@
"glob-stream": "^5.0.0",
"gulp": "^3.9.0",
"jquery": "^2.1.4",
"jsrender": "^0.9.86",
"jsrender": "^0.9.88",
"qunit": "^0.7.6"
},
"dependencies": {}
Expand Down
8 changes: 4 additions & 4 deletions test/browserify/bundles/1-bundle.js

Large diffs are not rendered by default.

Loading

0 comments on commit c433fc3

Please sign in to comment.