Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Cleaning up custom mobify.js build file example, adding example for o…
Browse files Browse the repository at this point in the history
…ne that works with v6
  • Loading branch information
jansepar committed Feb 25, 2013
1 parent cfc26f9 commit d44b740
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
28 changes: 11 additions & 17 deletions mobify-custom.js.example
@@ -1,21 +1,15 @@
require(["capture", "resizeImages"], function(Capture, ResizeImages) {
var Mobify = window.Mobify = window.Mobify || {};

// DECLARE LIBRARIES ATTACHED TO MOBIFY OBJECT HERE
Mobify.Capture = Capture;
Mobify.ResizeImages = ResizeImages;

// === HACKS TO ENSURE NEW CODE WORKING WITH v6 TAG === //

if (Mobify.api != "2.0.0") { // same as if (capturing)
// legacy need for v6 tags
Mobify.api = "2.0.0";

// Remove the bootstrap and tag scripts
var scripts = document.getElementsByTagName("script");
var preview = scripts[1];
preview.parentNode.removeChild(preview);
var tag = scripts[1];
tag.parentNode.removeChild(tag);

// === END HACKS ====//

// OPTIONAL: Also add main executable logic to compile library + main
// instead of having seperate main.js file
/*
var capturing = window.capturing || false;
if (capturing) {
// Grab reference to a newly created document
var capture = new Capture();
var capturedDoc = capture.capturedDoc;
Expand All @@ -24,7 +18,7 @@ require(["capture", "resizeImages"], function(Capture, ResizeImages) {
ResizeImages.resize(capturedDoc, 320);
// Render source DOM to document
capture.renderCapturedDoc();
}
}*/

}, undefined, true);
// relPath, forceSync
// relPath, forceSync
30 changes: 30 additions & 0 deletions mobify-custom.js.example.v6
@@ -0,0 +1,30 @@
require(["capture", "resizeImages"], function(Capture, ResizeImages) {
var Mobify = window.Mobify = window.Mobify || {};

// === HACKS TO ENSURE NEW CODE WORKING WITH v6 TAG === //

if (Mobify.api != "2.0.0") { // same as if (capturing)
// legacy need for v6 tags
Mobify.api = "2.0.0";

// Remove the bootstrap and tag scripts
var scripts = document.getElementsByTagName("script");
var preview = scripts[1];
preview.parentNode.removeChild(preview);
var tag = scripts[1];
tag.parentNode.removeChild(tag);

// === END HACKS ====//

// Grab reference to a newly created document
var capture = new Capture();
var capturedDoc = capture.capturedDoc;

// Resize images using Mobify Image Resizer
ResizeImages.resize(capturedDoc, 320);
// Render source DOM to document
capture.renderCapturedDoc();
}

}, undefined, true);
// relPath, forceSync

0 comments on commit d44b740

Please sign in to comment.