adaptivejs
Advanced tools
Comparing version 0.1.16 to 0.1.17
{ | ||
"name": "adaptivejs", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"description": "A framework for creating adaptive websites.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -1,27 +0,15 @@ | ||
define(['adaptivejs/context', | ||
'adaptivejs/defaults', | ||
define(['adaptivejs/defaults', | ||
'adaptivejs/logger', | ||
'adaptivejs/router', | ||
'adaptivejs/selectorEngine', | ||
'adaptivejs/utils', | ||
'adaptivejs/view', | ||
'mobifyjs/capture' | ||
], function(Context, Defaults, Logger, Router, SelectorEngine, Utils, View, Capture) { | ||
], function(Defaults, Logger, SelectorEngine, Utils, Capture) { | ||
// Backwards compatibility fix needed for v6 tag | ||
window.Mobify = window.Mobify || {}; | ||
// Backwards compatibility fix needed for v6 tag | ||
window.Mobify.api = true; | ||
// Collect all APIs under the 'Adaptive' namespace | ||
var Adaptive = {}; | ||
Adaptive.Context = Context; | ||
Adaptive.View = View; | ||
Adaptive.Router = Router; | ||
// Instantiate the Adaptive object | ||
var Adaptive = window.Adaptive = window.Adaptive || {}; | ||
// Expose Almond to UI scripts | ||
Adaptive.AMD = {}; | ||
Adaptive.AMD.require = require; | ||
Adaptive.AMD.define = define; | ||
window.Adaptive = window.Adaptive || Adaptive; | ||
/** | ||
@@ -64,36 +52,33 @@ * Restore the original document when capturing | ||
// TODO: Figure out workflow for using Adaptive.js without capturing | ||
Adaptive.useCapturing = true; | ||
window.Mobify.$ = SelectorEngine; | ||
// Backwards compatibility fix needed for v6 tag | ||
window.Mobify.api = true; | ||
var capturing = window.Mobify && window.Mobify.capturing || false; | ||
if (Adaptive.useCapturing) { | ||
if (capturing) { | ||
if (capturing) { | ||
// Setup the logger and initialize the start time | ||
Logger.init(Mobify.points[0], Utils.isDebug()); | ||
// Setup the logger and initialize the start time | ||
Logger.init(Mobify.points[0], Utils.isDebug()); | ||
// Grab reference to a newly created document | ||
Capture.init(function(capture){ | ||
// Store the 'capture' object on 'Adaptive' for later use when | ||
// rendering | ||
Adaptive.capture = capture; | ||
// Grab reference to a newly created document | ||
Capture.init(function(capture){ | ||
// Store the 'capture' object on 'Adaptive' for later use when | ||
// rendering | ||
Adaptive.capture = capture; | ||
// Bind selector engine to the captured document | ||
SelectorEngine.attachDocument(capture.capturedDoc); | ||
callback(capture.capturedDoc); | ||
}); | ||
} | ||
else { | ||
// Expose Almond to UI scripts | ||
Adaptive.AMD = {}; | ||
Adaptive.AMD.require = require; | ||
Adaptive.AMD.define = define; | ||
// Expose $ for front-end scripts | ||
Adaptive.$ = SelectorEngine; | ||
// Bind selector engine to the captured document | ||
SelectorEngine.attachDocument(capture.capturedDoc); | ||
callback(capture.capturedDoc); | ||
}); | ||
} | ||
else { | ||
// We're not capturing. Bind selector library to original document | ||
SelectorEngine.attachDocument(document); | ||
// Adds logging points for Load and DOMContentLoaded events | ||
Logger.addPoint('Rendering Done'); | ||
Logger.addDOMContentListener(); | ||
Logger.addOnLoadListener(); | ||
} | ||
// We're not capturing. Bind selector library to original document | ||
SelectorEngine.attachDocument(document); | ||
// Adds logging points for Load and DOMContentLoaded events | ||
Logger.addPoint('Rendering Done'); | ||
Logger.addDOMContentListener(); | ||
Logger.addOnLoadListener(); | ||
} | ||
@@ -103,3 +88,3 @@ }; | ||
Adaptive.renderPage = function(htmlStr) { | ||
if (Adaptive.useCapturing && !Adaptive.disabled) { | ||
if (!Adaptive.disabled) { | ||
if (!Adaptive.capture) { | ||
@@ -106,0 +91,0 @@ throw 'We are using Capturing, but there is no capture object to render'; |
@@ -24,5 +24,9 @@ define([ | ||
config.projectName = projectName; | ||
config.isDebug = Utils.isDebug; | ||
config.adaptiveBuild = Utils.getAdaptiveBuild(); | ||
config.isDebug = Utils.isDebug(); | ||
config.adaptiveBuildScript = Utils.getAdaptiveBuildScript(); | ||
config.adaptiveBuild = config.adaptiveBuildScript && config.adaptiveBuildScript.getAttribute('x-src'); | ||
config.buildOrigin = Utils.getBuildOrigin(); | ||
config.ajs = function(context) { | ||
return Utils.getAjs(config.projectName, context.templateName); | ||
}; | ||
@@ -29,0 +33,0 @@ defaultContext.config = config; |
@@ -68,5 +68,8 @@ define([ | ||
var cachedBuildScript; | ||
AdaptiveUtils.getAdaptiveBuild = function() { | ||
AdaptiveUtils.getAdaptiveBuildScript = function() { | ||
try { | ||
cachedBuildScript = cachedBuildScript || $('script[x-src]')[0].getAttribute('x-src') || ''; | ||
var buildScript = $('script[x-src]'); | ||
if (buildScript) { | ||
cachedBuildScript = cachedBuildScript || buildScript.remove()[0]; | ||
} | ||
return cachedBuildScript; | ||
@@ -86,3 +89,3 @@ } catch (e) { | ||
try { | ||
var adaptiveBuild = this.getAdaptiveBuild(); | ||
var adaptiveBuild = this.getAdaptiveBuildScript().getAttribute('x-src');; | ||
buildOrigin = adaptiveBuild.replace(/\/[^\/]*$/, '/'); | ||
@@ -89,0 +92,0 @@ } catch (e) { |
Sorry, the diff of this file is not supported yet
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
140826
3116