Comparing version 0.0.3 to 0.0.4
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "d6.js", | ||
@@ -31,7 +31,7 @@ "homepage": "http://lighter.io/d6", | ||
"dependencies": { | ||
"jymin": "0.1.11" | ||
"jymin": "0.2.0" | ||
}, | ||
"devDependencies": { | ||
"zeriousify": "0.1.5", | ||
"mocha": "1.20.0", | ||
"mocha": "1.20.1", | ||
"istanbul": "0.2.10", | ||
@@ -38,0 +38,0 @@ "assert-plus": "0.1.5", |
@@ -8,2 +8,8 @@ /** | ||
var d6Load = function (url) { | ||
if (window.d6) { | ||
d6._LOAD(url); | ||
} | ||
}; | ||
(function () { | ||
@@ -21,3 +27,3 @@ | ||
var views = d6.views = {}; | ||
var views = d6._VIEWS = {}; | ||
@@ -104,11 +110,21 @@ var cache = {}; | ||
*/ | ||
var loadUrl = function (url, callback) { | ||
var loadUrl = d6._LOAD = function (url, callback) { | ||
// Set all spinners in the page to their loading state. | ||
all('._SPINNER', function (spinner) { | ||
addClass(spinner, '_LOADING'); | ||
}); | ||
// A resource is either a cached response, a callback queue, or nothing. | ||
var resource = cache[url]; | ||
// If there's no resource, start the JSON request. | ||
if (!resource) { | ||
getD6Json(url, callback); | ||
} | ||
// If the "resource" is a callback queue, then pushing means listening. | ||
else if (isArray(resource)) { | ||
resource.push(callback); | ||
push(resource, callback); | ||
} | ||
// If the resource exists and isn't an array, render it. | ||
else { | ||
@@ -120,7 +136,9 @@ resource.request.url = url; | ||
// Request JSON, indicating with a URL param that D6 is requesting it. | ||
var getD6Json = function (url, callback) { | ||
url += (containsString(url, '?') ? '&' : '?') + 'd6=on'; | ||
url += (contains(url, '?') ? '&' : '?') + 'd6=on'; | ||
getJson(url, callback); | ||
}; | ||
// Render a template with the given context, and display the resulting HTML. | ||
var renderResponse = function (context) { | ||
@@ -130,2 +148,9 @@ var err = context._ERROR; | ||
var html; | ||
// Reset any spinners. | ||
all('._SPINNER', function (spinner) { | ||
removeClass(spinner, '_LOADING'); | ||
}); | ||
// If there's an error, render the error text. | ||
if (err) { | ||
@@ -138,2 +163,4 @@ html = context._TEXT; | ||
} | ||
// If the context refers to a view that we have, render it. | ||
else if (view) { | ||
@@ -143,2 +170,4 @@ html = view.call(views, context); | ||
} | ||
// If we can't find a corresponding view, navigate the old-fashioned way. | ||
else { | ||
@@ -145,0 +174,0 @@ //+env:dev |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11049
256
+ Addedjymin@0.2.0(transitive)
- Removedjymin@0.1.11(transitive)
Updatedjymin@0.2.0