Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Format a few more files.

  • Loading branch information...
commit 2b99ef6551da55f9245dc44dc4dfca896d1b62a5 1 parent 309326e
John Boxall johnboxall authored
Showing with 62 additions and 50 deletions.
  1. +44 −35 api/main.js
  2. +1 −0  api/resizeImages.js
  3. +17 −15 konf/defaults.konf
79 api/main.js
View
@@ -27,26 +27,31 @@ The current document is replaced by using document.open/write/close. This makes
the browser behave as if the templated HTML was the regular source.
*/
-(function(document, $, Mobify) {
+(function(document, Mobify) {
-var timing = Mobify.timing
+var $ = Mobify.$
+ , config = Mobify.config
+ , timing = Mobify.timing
, transform = Mobify.transform = Mobify.transform || {};
-$.extend(Mobify.transform, {
- // Read the conf, extract the Source DOM and begin the evaluation.
- prepareConf : function(rawConf) {
+$.extend(transform, {
+ /**
+ * Read the conf, extract the Source DOM and begin the evaluation.
+ */
+ prepareConf: function(rawConf) {
var capturedState = Mobify.html.extractDOM();
- capturedState.config = Mobify.config;
+ capturedState.config = config;
// If conf is using data2 evaluation in a {+conf} or {+konf}, this call would provide
// an interpretable source data object.
// If conf is using just a function(), the return value is not useful,
// as result HTML would be provided as sole argument of a callback.
var conf = Mobify.conf = rawConf.call(
- Mobify.data2 && Mobify.data2.M,
- capturedState,
- transform.acceptData // This is escape path for function-based confs
- );
+ Mobify.data2 && Mobify.data2.M,
+ capturedState,
+ // This is escape path for function-based confs
+ transform.acceptData);
+
// And this is the normal data evaluation
if (conf && conf.data) {
@@ -55,30 +60,35 @@ $.extend(Mobify.transform, {
Mobify.evaluatedData = undefined;
var cont = Mobify.data2.makeCont({source: capturedState})
- .on('complete', transform.acceptData);
+ .on('complete', transform.acceptData);
timing.addPoint('Prepared conf for evaluation');
timing.addSelector('Start');
+
cont.eval();
}
- },
+ }
- // `acceptData` is exposed on `Mobify` so it can be overridden for server-side adaptation.
- // Called when the `konf` has been evaluated.
- acceptData: function(data, cont) {
+ /**
+ * `acceptData` is exposed on `Mobify` so it can be overridden for server-side adaptation.
+ * Called when the `konf` has been evaluated.
+ */
+ , acceptData: function(data, cont) {
if (!Mobify.evaluatedData) {
Mobify.evaluatedData = data;
Mobify.evaluatedCont = cont;
timing.addPoint('Evaluated Conf');
}
- var outputHTML = (typeof data == "string") ? data : data.OUTPUTHTML;
- var enabled = Mobify.html.enable(outputHTML || '');
+ var outputHTML = (typeof data == "string") ? data : data.OUTPUTHTML
+ , enabled = Mobify.html.enable(outputHTML || '');
+
timing.addPoint('Enabled Markup');
+
transform.emitMarkup(enabled);
- },
+ }
- emitMarkup: function(markup) {
+ , emitMarkup: function(markup) {
timing.addPoint('DOMContentLoaded');
if (!markup) {
@@ -88,37 +98,36 @@ $.extend(Mobify.transform, {
timing.addPoint('Writing Document');
- if (Mobify.config.isDebug) {
+ if (config.isDebug) {
timing.logPoints();
}
- // We'll write markup a tick later, as Firefox logging is async
- // and gets interrupted if followed by synchronous document.open
- window.setTimeout(function(){
- // `document.open` clears events bound to `document`.
+ // Write markup on the next tick as Firefox logging is async
+ // and gets interrupted if followed by synchronous document.open.
+ setTimeout(function() {
document.open();
-
- // In Webkit, `document.write` immediately executes inline scripts
- // not preceded by an external resource.
document.write(markup);
document.close();
});
},
- // Kickstart processing. Guard against beginning before the document is ready.
+ /**
+ * Kickstart processing. Guard against beginning before the document is ready.
+ */
run: function(conf) {
var prepareConf = function() {
- // Do NOT proceed unless we're ready.
- if (!/complete|loaded/.test(document.readyState)) {
- return setTimeout(prepareConf, 15);
- }
- Mobify.transform.prepareConf(conf);
- };
+ // Do NOT proceed unless we're ready.
+ if (!/complete|loaded/.test(document.readyState)) {
+ return setTimeout(prepareConf, 15);
+ }
+
+ transform.prepareConf(conf);
+ };
prepareConf();
}
});
-})(document, Mobify.$, Mobify);
+})(document, Mobify);
Mobify.timing.addPoint('Walked Mobify.js');
1  api/resizeImages.js
View
@@ -90,6 +90,7 @@ var absolutify = document.createElement('a')
}
});
}
+
, defaults = resizeImages.defaults = {
selector: 'img[x-src]'
, attribute: 'x-src'
32 konf/defaults.konf
View
@@ -1,36 +1,38 @@
-/* Default configuration. Override these settings in your site-specific conf */
+/**
+ * Default configuration. Override these settings in your site-specific conf
+ */
{
- '?unmobify': false,
+ '?unmobify': false
- mobileViewport: 'width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=no;',
+ , mobileViewport: 'width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=no;'
// 'example.png'
- touchIcon: undefined,
+ , touchIcon: undefined
- formatDetection: ["telephone=no", "address=no"],
+ , formatDetection: ["telephone=no", "address=no"]
- cssDir: function(cont) {
+ , cssDir: function(cont) {
return cont.data('config.configDir')
- },
+ }
- imageDir: function(cont) {
+ , imageDir: function(cont) {
return cont.data('config.configDir') + 'i/'
- },
+ }
- '?HD' : function(cont) {
+ , '?HD' : function(cont) {
return cont.data('config.HD')
- },
+ }
// Populated from `site.json`.
- siteConfig: {site_config|s},
+ , siteConfig: {site_config|s}
// Timestamp when this string was made.
- buildDate: {build_dt},
+ , buildDate: {build_dt}
// JB: Update this property to work with new builds.
- configName: '{conf}',
+ , configName: '{conf}'
- cssName: function(cont) {
+ , cssName: function(cont) {
return cont.data('configName').split('/').pop().split('.')[0] || 'stylesheet';
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.