Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Last active August 19, 2016 13:18
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save wilsonpage/8598603 to your computer and use it in GitHub Desktop.
Save wilsonpage/8598603 to your computer and use it in GitHub Desktop.
UMD (amd, common.js, window)
;(function(define){define(function(require,exports,module){
//...
});})(typeof define=='function'&&define.amd?define
:(function(n,w){'use strict';return typeof module=='object'?function(c){
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
return w[n];},m.exports,m);w[n]=m.exports;};})('module-name',this));
@jrburke
Copy link

jrburke commented Jan 24, 2014

This will likely not work for static analysis build tools for AMD, where they look for a function literal passed to define() to parse for the commonjs sugar syntax.

@wilsonpage
Copy link
Author

Ah, thanks for the feedback @jrburke! Which tools, like r.js? Can you suggest improvements?

@jrburke
Copy link

jrburke commented Jan 25, 2014

Yes, r.js would be one, but i can see others, just hard to account for all possible patterns otherwise. The umdjs/umd ones were designed to thread all the issues.

@timdream
Copy link

I wonder if you need to check for define.amd === true on line 6?

@wilsonpage
Copy link
Author

@jrburke revised version. Not as pretty, but still nice to have the junk at the bottom I think :) Thought?

@jrburke
Copy link

jrburke commented Jan 25, 2014

@wilsonpage, looks like it should work now. This one requires two levels of code indent for people that like to indent for each brace body. For some people that compromises more on usable space than having the stuff at the top. So, it is down to person choice.

As @timdream suggests, I would do typeof define=='function' && define.amd for the AMD define check, to avoid possible conflicts with another define on the page.

@jlettvin
Copy link

jlettvin commented Oct 4, 2015

After some experiments with ftcolumnflow, I have some observations and a recommendation.
I have a github project implementing markup for scientific paper writing. For this project,
a principle value of this ftcolumnflow is an ability to print documents reliably on 8.5"x11" paper.
Multi-column multi-page flow is very valuable, and you have done a great job of achieving this.
One remaining challenge is to output a page break just before horizontal red outlines after the first.
I would like your help.

I have spent a couple of days experimenting with page sizes and modifications to your code.
In Chrome Browser 1090x1470 is close, but the red boundary creeps up to the previous page
from being on the next page by page 34 of print preview. In Safari, 1090x1468 had no creep
by page 129. Experiments with Firefox were incomplete so far.

Some code modifications I tried included CSS page-break-before, but those all fail because
You ingest the text hidden and rewrite it into your cf-pages. Beautiful, but refractory to breaks.
I am happy to adjust the size of the red outline, but during my experiments I found that
sometimes the text overlaps the outline.

Is there any advice you can give me? I will continue experimenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment